2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp-api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp-api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp-api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp-api/vpe_all_api_h.h>
74 unformat_sw_if_index (unformat_input_t * input, va_list * args)
76 vat_main_t *vam = va_arg (*args, vat_main_t *);
77 u32 *result = va_arg (*args, u32 *);
81 if (!unformat (input, "%s", &if_name))
84 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
91 /* Parse an IP4 address %d.%d.%d.%d. */
93 unformat_ip4_address (unformat_input_t * input, va_list * args)
95 u8 *result = va_arg (*args, u8 *);
98 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
101 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
114 unformat_ethernet_address (unformat_input_t * input, va_list * args)
116 u8 *result = va_arg (*args, u8 *);
119 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
120 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
124 for (i = 0; i < 6; i++)
125 if (a[i] >= (1 << 8))
128 for (i = 0; i < 6; i++)
134 /* Returns ethernet type as an int in host byte order. */
136 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
139 u16 *result = va_arg (*args, u16 *);
143 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
145 if (type >= (1 << 16))
153 /* Parse an IP6 address. */
155 unformat_ip6_address (unformat_input_t * input, va_list * args)
157 ip6_address_t *result = va_arg (*args, ip6_address_t *);
159 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
160 uword c, n_colon, double_colon_index;
162 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
163 double_colon_index = ARRAY_LEN (hex_quads);
164 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
167 if (c >= '0' && c <= '9')
169 else if (c >= 'a' && c <= 'f')
170 hex_digit = c + 10 - 'a';
171 else if (c >= 'A' && c <= 'F')
172 hex_digit = c + 10 - 'A';
173 else if (c == ':' && n_colon < 2)
177 unformat_put_input (input);
181 /* Too many hex quads. */
182 if (n_hex_quads >= ARRAY_LEN (hex_quads))
187 hex_quad = (hex_quad << 4) | hex_digit;
189 /* Hex quad must fit in 16 bits. */
190 if (n_hex_digits >= 4)
197 /* Save position of :: */
200 /* More than one :: ? */
201 if (double_colon_index < ARRAY_LEN (hex_quads))
203 double_colon_index = n_hex_quads;
206 if (n_colon > 0 && n_hex_digits > 0)
208 hex_quads[n_hex_quads++] = hex_quad;
214 if (n_hex_digits > 0)
215 hex_quads[n_hex_quads++] = hex_quad;
220 /* Expand :: to appropriate number of zero hex quads. */
221 if (double_colon_index < ARRAY_LEN (hex_quads))
223 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
225 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
226 hex_quads[n_zero + i] = hex_quads[i];
228 for (i = 0; i < n_zero; i++)
229 hex_quads[double_colon_index + i] = 0;
231 n_hex_quads = ARRAY_LEN (hex_quads);
234 /* Too few hex quads given. */
235 if (n_hex_quads < ARRAY_LEN (hex_quads))
238 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
239 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
246 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
248 u32 *r = va_arg (*args, u32 *);
251 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
252 foreach_ipsec_policy_action
260 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
262 u32 *r = va_arg (*args, u32 *);
265 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
266 foreach_ipsec_crypto_alg
274 format_ipsec_crypto_alg (u8 * s, va_list * args)
276 u32 i = va_arg (*args, u32);
281 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
282 foreach_ipsec_crypto_alg
285 return format (s, "unknown");
287 return format (s, "%s", t);
291 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
293 u32 *r = va_arg (*args, u32 *);
296 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
297 foreach_ipsec_integ_alg
305 format_ipsec_integ_alg (u8 * s, va_list * args)
307 u32 i = va_arg (*args, u32);
312 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
313 foreach_ipsec_integ_alg
316 return format (s, "unknown");
318 return format (s, "%s", t);
322 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
324 u32 *r = va_arg (*args, u32 *);
327 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
328 foreach_ikev2_auth_method
336 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
338 u32 *r = va_arg (*args, u32 *);
341 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
342 foreach_ikev2_id_type
350 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
352 u8 *r = va_arg (*args, u8 *);
354 if (unformat (input, "kbps"))
355 *r = SSE2_QOS_RATE_KBPS;
356 else if (unformat (input, "pps"))
357 *r = SSE2_QOS_RATE_PPS;
364 unformat_policer_round_type (unformat_input_t * input, va_list * args)
366 u8 *r = va_arg (*args, u8 *);
368 if (unformat (input, "closest"))
369 *r = SSE2_QOS_ROUND_TO_CLOSEST;
370 else if (unformat (input, "up"))
371 *r = SSE2_QOS_ROUND_TO_UP;
372 else if (unformat (input, "down"))
373 *r = SSE2_QOS_ROUND_TO_DOWN;
380 unformat_policer_type (unformat_input_t * input, va_list * args)
382 u8 *r = va_arg (*args, u8 *);
384 if (unformat (input, "1r2c"))
385 *r = SSE2_QOS_POLICER_TYPE_1R2C;
386 else if (unformat (input, "1r3c"))
387 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
388 else if (unformat (input, "2r3c-2698"))
389 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
390 else if (unformat (input, "2r3c-4115"))
391 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
392 else if (unformat (input, "2r3c-mef5cf1"))
393 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
400 unformat_dscp (unformat_input_t * input, va_list * va)
402 u8 *r = va_arg (*va, u8 *);
405 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
414 unformat_policer_action_type (unformat_input_t * input, va_list * va)
416 sse2_qos_pol_action_params_st *a
417 = va_arg (*va, sse2_qos_pol_action_params_st *);
419 if (unformat (input, "drop"))
420 a->action_type = SSE2_QOS_ACTION_DROP;
421 else if (unformat (input, "transmit"))
422 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
423 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
424 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
431 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
433 u32 *r = va_arg (*va, u32 *);
436 if (unformat (input, "ip4"))
437 tid = POLICER_CLASSIFY_TABLE_IP4;
438 else if (unformat (input, "ip6"))
439 tid = POLICER_CLASSIFY_TABLE_IP6;
440 else if (unformat (input, "l2"))
441 tid = POLICER_CLASSIFY_TABLE_L2;
450 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
452 u32 *r = va_arg (*va, u32 *);
455 if (unformat (input, "ip4"))
456 tid = FLOW_CLASSIFY_TABLE_IP4;
457 else if (unformat (input, "ip6"))
458 tid = FLOW_CLASSIFY_TABLE_IP6;
467 format_ip4_address (u8 * s, va_list * args)
469 u8 *a = va_arg (*args, u8 *);
470 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
474 format_ip6_address (u8 * s, va_list * args)
476 ip6_address_t *a = va_arg (*args, ip6_address_t *);
477 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
479 i_max_n_zero = ARRAY_LEN (a->as_u16);
481 i_first_zero = i_max_n_zero;
483 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
485 u32 is_zero = a->as_u16[i] == 0;
486 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
492 if ((!is_zero && n_zeros > max_n_zeros)
493 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
495 i_max_n_zero = i_first_zero;
496 max_n_zeros = n_zeros;
497 i_first_zero = ARRAY_LEN (a->as_u16);
502 last_double_colon = 0;
503 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
505 if (i == i_max_n_zero && max_n_zeros > 1)
507 s = format (s, "::");
508 i += max_n_zeros - 1;
509 last_double_colon = 1;
513 s = format (s, "%s%x",
514 (last_double_colon || i == 0) ? "" : ":",
515 clib_net_to_host_u16 (a->as_u16[i]));
516 last_double_colon = 0;
523 /* Format an IP46 address. */
525 format_ip46_address (u8 * s, va_list * args)
527 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
528 ip46_type_t type = va_arg (*args, ip46_type_t);
534 is_ip4 = ip46_address_is_ip4 (ip46);
545 format (s, "%U", format_ip4_address, &ip46->ip4) :
546 format (s, "%U", format_ip6_address, &ip46->ip6);
550 format_ethernet_address (u8 * s, va_list * args)
552 u8 *a = va_arg (*args, u8 *);
554 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
555 a[0], a[1], a[2], a[3], a[4], a[5]);
559 increment_v4_address (ip4_address_t * a)
563 v = ntohl (a->as_u32) + 1;
564 a->as_u32 = ntohl (v);
568 increment_v6_address (ip6_address_t * a)
572 v0 = clib_net_to_host_u64 (a->as_u64[0]);
573 v1 = clib_net_to_host_u64 (a->as_u64[1]);
578 a->as_u64[0] = clib_net_to_host_u64 (v0);
579 a->as_u64[1] = clib_net_to_host_u64 (v1);
583 increment_mac_address (u64 * mac)
587 tmp = clib_net_to_host_u64 (tmp);
588 tmp += 1 << 16; /* skip unused (least significant) octets */
589 tmp = clib_host_to_net_u64 (tmp);
593 static void vl_api_create_loopback_reply_t_handler
594 (vl_api_create_loopback_reply_t * mp)
596 vat_main_t *vam = &vat_main;
597 i32 retval = ntohl (mp->retval);
599 vam->retval = retval;
600 vam->regenerate_interface_table = 1;
601 vam->sw_if_index = ntohl (mp->sw_if_index);
602 vam->result_ready = 1;
605 static void vl_api_create_loopback_reply_t_handler_json
606 (vl_api_create_loopback_reply_t * mp)
608 vat_main_t *vam = &vat_main;
609 vat_json_node_t node;
611 vat_json_init_object (&node);
612 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
613 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
615 vat_json_print (vam->ofp, &node);
616 vat_json_free (&node);
617 vam->retval = ntohl (mp->retval);
618 vam->result_ready = 1;
621 static void vl_api_af_packet_create_reply_t_handler
622 (vl_api_af_packet_create_reply_t * mp)
624 vat_main_t *vam = &vat_main;
625 i32 retval = ntohl (mp->retval);
627 vam->retval = retval;
628 vam->regenerate_interface_table = 1;
629 vam->sw_if_index = ntohl (mp->sw_if_index);
630 vam->result_ready = 1;
633 static void vl_api_af_packet_create_reply_t_handler_json
634 (vl_api_af_packet_create_reply_t * mp)
636 vat_main_t *vam = &vat_main;
637 vat_json_node_t node;
639 vat_json_init_object (&node);
640 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
641 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
643 vat_json_print (vam->ofp, &node);
644 vat_json_free (&node);
646 vam->retval = ntohl (mp->retval);
647 vam->result_ready = 1;
650 static void vl_api_create_vlan_subif_reply_t_handler
651 (vl_api_create_vlan_subif_reply_t * mp)
653 vat_main_t *vam = &vat_main;
654 i32 retval = ntohl (mp->retval);
656 vam->retval = retval;
657 vam->regenerate_interface_table = 1;
658 vam->sw_if_index = ntohl (mp->sw_if_index);
659 vam->result_ready = 1;
662 static void vl_api_create_vlan_subif_reply_t_handler_json
663 (vl_api_create_vlan_subif_reply_t * mp)
665 vat_main_t *vam = &vat_main;
666 vat_json_node_t node;
668 vat_json_init_object (&node);
669 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
670 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
672 vat_json_print (vam->ofp, &node);
673 vat_json_free (&node);
675 vam->retval = ntohl (mp->retval);
676 vam->result_ready = 1;
679 static void vl_api_create_subif_reply_t_handler
680 (vl_api_create_subif_reply_t * mp)
682 vat_main_t *vam = &vat_main;
683 i32 retval = ntohl (mp->retval);
685 vam->retval = retval;
686 vam->regenerate_interface_table = 1;
687 vam->sw_if_index = ntohl (mp->sw_if_index);
688 vam->result_ready = 1;
691 static void vl_api_create_subif_reply_t_handler_json
692 (vl_api_create_subif_reply_t * mp)
694 vat_main_t *vam = &vat_main;
695 vat_json_node_t node;
697 vat_json_init_object (&node);
698 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
699 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
701 vat_json_print (vam->ofp, &node);
702 vat_json_free (&node);
704 vam->retval = ntohl (mp->retval);
705 vam->result_ready = 1;
708 static void vl_api_interface_name_renumber_reply_t_handler
709 (vl_api_interface_name_renumber_reply_t * mp)
711 vat_main_t *vam = &vat_main;
712 i32 retval = ntohl (mp->retval);
714 vam->retval = retval;
715 vam->regenerate_interface_table = 1;
716 vam->result_ready = 1;
719 static void vl_api_interface_name_renumber_reply_t_handler_json
720 (vl_api_interface_name_renumber_reply_t * mp)
722 vat_main_t *vam = &vat_main;
723 vat_json_node_t node;
725 vat_json_init_object (&node);
726 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
728 vat_json_print (vam->ofp, &node);
729 vat_json_free (&node);
731 vam->retval = ntohl (mp->retval);
732 vam->result_ready = 1;
736 * Special-case: build the interface table, maintain
737 * the next loopback sw_if_index vbl.
739 static void vl_api_sw_interface_details_t_handler
740 (vl_api_sw_interface_details_t * mp)
742 vat_main_t *vam = &vat_main;
743 u8 *s = format (0, "%s%c", mp->interface_name, 0);
745 hash_set_mem (vam->sw_if_index_by_interface_name, s,
746 ntohl (mp->sw_if_index));
748 /* In sub interface case, fill the sub interface table entry */
749 if (mp->sw_if_index != mp->sup_sw_if_index)
751 sw_interface_subif_t *sub = NULL;
753 vec_add2 (vam->sw_if_subif_table, sub, 1);
755 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
756 strncpy ((char *) sub->interface_name, (char *) s,
757 vec_len (sub->interface_name));
758 sub->sw_if_index = ntohl (mp->sw_if_index);
759 sub->sub_id = ntohl (mp->sub_id);
761 sub->sub_dot1ad = mp->sub_dot1ad;
762 sub->sub_number_of_tags = mp->sub_number_of_tags;
763 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
764 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
765 sub->sub_exact_match = mp->sub_exact_match;
766 sub->sub_default = mp->sub_default;
767 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
768 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
770 /* vlan tag rewrite */
771 sub->vtr_op = ntohl (mp->vtr_op);
772 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
773 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
774 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
778 static void vl_api_sw_interface_details_t_handler_json
779 (vl_api_sw_interface_details_t * mp)
781 vat_main_t *vam = &vat_main;
782 vat_json_node_t *node = NULL;
784 if (VAT_JSON_ARRAY != vam->json_tree.type)
786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
787 vat_json_init_array (&vam->json_tree);
789 node = vat_json_array_add (&vam->json_tree);
791 vat_json_init_object (node);
792 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
793 vat_json_object_add_uint (node, "sup_sw_if_index",
794 ntohl (mp->sup_sw_if_index));
795 vat_json_object_add_uint (node, "l2_address_length",
796 ntohl (mp->l2_address_length));
797 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
798 sizeof (mp->l2_address));
799 vat_json_object_add_string_copy (node, "interface_name",
801 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
802 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
803 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
804 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
805 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
806 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
807 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
808 vat_json_object_add_uint (node, "sub_number_of_tags",
809 mp->sub_number_of_tags);
810 vat_json_object_add_uint (node, "sub_outer_vlan_id",
811 ntohs (mp->sub_outer_vlan_id));
812 vat_json_object_add_uint (node, "sub_inner_vlan_id",
813 ntohs (mp->sub_inner_vlan_id));
814 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
815 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
816 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
817 mp->sub_outer_vlan_id_any);
818 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
819 mp->sub_inner_vlan_id_any);
820 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
821 vat_json_object_add_uint (node, "vtr_push_dot1q",
822 ntohl (mp->vtr_push_dot1q));
823 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
824 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
827 static void vl_api_sw_interface_set_flags_t_handler
828 (vl_api_sw_interface_set_flags_t * mp)
830 vat_main_t *vam = &vat_main;
831 if (vam->interface_event_display)
832 errmsg ("interface flags: sw_if_index %d %s %s\n",
833 ntohl (mp->sw_if_index),
834 mp->admin_up_down ? "admin-up" : "admin-down",
835 mp->link_up_down ? "link-up" : "link-down");
838 static void vl_api_sw_interface_set_flags_t_handler_json
839 (vl_api_sw_interface_set_flags_t * mp)
841 /* JSON output not supported */
845 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
847 vat_main_t *vam = &vat_main;
848 i32 retval = ntohl (mp->retval);
850 vam->retval = retval;
851 vam->shmem_result = (u8 *) mp->reply_in_shmem;
852 vam->result_ready = 1;
856 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 vat_json_node_t node;
860 api_main_t *am = &api_main;
864 vat_json_init_object (&node);
865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
866 vat_json_object_add_uint (&node, "reply_in_shmem",
867 ntohl (mp->reply_in_shmem));
868 /* Toss the shared-memory original... */
869 pthread_mutex_lock (&am->vlib_rp->mutex);
870 oldheap = svm_push_data_heap (am->vlib_rp);
872 reply = (u8 *) (mp->reply_in_shmem);
875 svm_pop_heap (oldheap);
876 pthread_mutex_unlock (&am->vlib_rp->mutex);
878 vat_json_print (vam->ofp, &node);
879 vat_json_free (&node);
881 vam->retval = ntohl (mp->retval);
882 vam->result_ready = 1;
886 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 i32 retval = ntohl (mp->retval);
891 vam->retval = retval;
892 vam->cmd_reply = mp->reply;
893 vam->result_ready = 1;
897 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
899 vat_main_t *vam = &vat_main;
900 vat_json_node_t node;
902 vat_json_init_object (&node);
903 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
904 vat_json_object_add_string_copy (&node, "reply", mp->reply);
906 vat_json_print (vam->ofp, &node);
907 vat_json_free (&node);
909 vam->retval = ntohl (mp->retval);
910 vam->result_ready = 1;
913 static void vl_api_classify_add_del_table_reply_t_handler
914 (vl_api_classify_add_del_table_reply_t * mp)
916 vat_main_t *vam = &vat_main;
917 i32 retval = ntohl (mp->retval);
920 vam->async_errors += (retval < 0);
924 vam->retval = retval;
926 ((mp->new_table_index != 0xFFFFFFFF) ||
927 (mp->skip_n_vectors != 0xFFFFFFFF) ||
928 (mp->match_n_vectors != 0xFFFFFFFF)))
930 * Note: this is just barely thread-safe, depends on
931 * the main thread spinning waiting for an answer...
933 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
934 ntohl (mp->new_table_index),
935 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
936 vam->result_ready = 1;
940 static void vl_api_classify_add_del_table_reply_t_handler_json
941 (vl_api_classify_add_del_table_reply_t * mp)
943 vat_main_t *vam = &vat_main;
944 vat_json_node_t node;
946 vat_json_init_object (&node);
947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
948 vat_json_object_add_uint (&node, "new_table_index",
949 ntohl (mp->new_table_index));
950 vat_json_object_add_uint (&node, "skip_n_vectors",
951 ntohl (mp->skip_n_vectors));
952 vat_json_object_add_uint (&node, "match_n_vectors",
953 ntohl (mp->match_n_vectors));
955 vat_json_print (vam->ofp, &node);
956 vat_json_free (&node);
958 vam->retval = ntohl (mp->retval);
959 vam->result_ready = 1;
962 static void vl_api_get_node_index_reply_t_handler
963 (vl_api_get_node_index_reply_t * mp)
965 vat_main_t *vam = &vat_main;
966 i32 retval = ntohl (mp->retval);
969 vam->async_errors += (retval < 0);
973 vam->retval = retval;
975 errmsg ("node index %d\n", ntohl (mp->node_index));
976 vam->result_ready = 1;
980 static void vl_api_get_node_index_reply_t_handler_json
981 (vl_api_get_node_index_reply_t * mp)
983 vat_main_t *vam = &vat_main;
984 vat_json_node_t node;
986 vat_json_init_object (&node);
987 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
988 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
990 vat_json_print (vam->ofp, &node);
991 vat_json_free (&node);
993 vam->retval = ntohl (mp->retval);
994 vam->result_ready = 1;
997 static void vl_api_get_next_index_reply_t_handler
998 (vl_api_get_next_index_reply_t * mp)
1000 vat_main_t *vam = &vat_main;
1001 i32 retval = ntohl (mp->retval);
1002 if (vam->async_mode)
1004 vam->async_errors += (retval < 0);
1008 vam->retval = retval;
1010 errmsg ("next node index %d\n", ntohl (mp->next_index));
1011 vam->result_ready = 1;
1015 static void vl_api_get_next_index_reply_t_handler_json
1016 (vl_api_get_next_index_reply_t * mp)
1018 vat_main_t *vam = &vat_main;
1019 vat_json_node_t node;
1021 vat_json_init_object (&node);
1022 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1023 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1025 vat_json_print (vam->ofp, &node);
1026 vat_json_free (&node);
1028 vam->retval = ntohl (mp->retval);
1029 vam->result_ready = 1;
1032 static void vl_api_add_node_next_reply_t_handler
1033 (vl_api_add_node_next_reply_t * mp)
1035 vat_main_t *vam = &vat_main;
1036 i32 retval = ntohl (mp->retval);
1037 if (vam->async_mode)
1039 vam->async_errors += (retval < 0);
1043 vam->retval = retval;
1045 errmsg ("next index %d\n", ntohl (mp->next_index));
1046 vam->result_ready = 1;
1050 static void vl_api_add_node_next_reply_t_handler_json
1051 (vl_api_add_node_next_reply_t * mp)
1053 vat_main_t *vam = &vat_main;
1054 vat_json_node_t node;
1056 vat_json_init_object (&node);
1057 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1058 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1060 vat_json_print (vam->ofp, &node);
1061 vat_json_free (&node);
1063 vam->retval = ntohl (mp->retval);
1064 vam->result_ready = 1;
1067 static void vl_api_show_version_reply_t_handler
1068 (vl_api_show_version_reply_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 i32 retval = ntohl (mp->retval);
1075 errmsg (" program: %s\n", mp->program);
1076 errmsg (" version: %s\n", mp->version);
1077 errmsg (" build date: %s\n", mp->build_date);
1078 errmsg ("build directory: %s\n", mp->build_directory);
1080 vam->retval = retval;
1081 vam->result_ready = 1;
1084 static void vl_api_show_version_reply_t_handler_json
1085 (vl_api_show_version_reply_t * mp)
1087 vat_main_t *vam = &vat_main;
1088 vat_json_node_t node;
1090 vat_json_init_object (&node);
1091 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1092 vat_json_object_add_string_copy (&node, "program", mp->program);
1093 vat_json_object_add_string_copy (&node, "version", mp->version);
1094 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1095 vat_json_object_add_string_copy (&node, "build_directory",
1096 mp->build_directory);
1098 vat_json_print (vam->ofp, &node);
1099 vat_json_free (&node);
1101 vam->retval = ntohl (mp->retval);
1102 vam->result_ready = 1;
1106 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1108 vat_main_t *vam = &vat_main;
1109 errmsg ("arp %s event: address %U new mac %U sw_if_index %d\n",
1110 mp->mac_ip ? "mac/ip binding" : "address resolution",
1111 format_ip4_address, &mp->address,
1112 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1116 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1118 /* JSON output not supported */
1122 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1124 vat_main_t *vam = &vat_main;
1125 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d\n",
1126 mp->mac_ip ? "mac/ip binding" : "address resolution",
1127 format_ip6_address, mp->address,
1128 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1132 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1134 /* JSON output not supported */
1138 * Special-case: build the bridge domain table, maintain
1139 * the next bd id vbl.
1141 static void vl_api_bridge_domain_details_t_handler
1142 (vl_api_bridge_domain_details_t * mp)
1144 vat_main_t *vam = &vat_main;
1145 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1147 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1148 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1150 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1151 ntohl (mp->bd_id), mp->learn, mp->forward,
1152 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1155 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1159 static void vl_api_bridge_domain_details_t_handler_json
1160 (vl_api_bridge_domain_details_t * mp)
1162 vat_main_t *vam = &vat_main;
1163 vat_json_node_t *node, *array = NULL;
1165 if (VAT_JSON_ARRAY != vam->json_tree.type)
1167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1168 vat_json_init_array (&vam->json_tree);
1170 node = vat_json_array_add (&vam->json_tree);
1172 vat_json_init_object (node);
1173 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1174 vat_json_object_add_uint (node, "flood", mp->flood);
1175 vat_json_object_add_uint (node, "forward", mp->forward);
1176 vat_json_object_add_uint (node, "learn", mp->learn);
1177 vat_json_object_add_uint (node, "bvi_sw_if_index",
1178 ntohl (mp->bvi_sw_if_index));
1179 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1180 array = vat_json_object_add (node, "sw_if");
1181 vat_json_init_array (array);
1185 * Special-case: build the bridge domain sw if table.
1187 static void vl_api_bridge_domain_sw_if_details_t_handler
1188 (vl_api_bridge_domain_sw_if_details_t * mp)
1190 vat_main_t *vam = &vat_main;
1195 sw_if_index = ntohl (mp->sw_if_index);
1197 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1199 if ((u32) p->value[0] == sw_if_index)
1201 sw_if_name = (u8 *)(p->key);
1207 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1208 mp->shg, sw_if_name ? (char *) sw_if_name :
1209 "sw_if_index not found!");
1212 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1213 (vl_api_bridge_domain_sw_if_details_t * mp)
1215 vat_main_t *vam = &vat_main;
1216 vat_json_node_t *node = NULL;
1217 uword last_index = 0;
1219 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1220 ASSERT (vec_len (vam->json_tree.array) >= 1);
1221 last_index = vec_len (vam->json_tree.array) - 1;
1222 node = &vam->json_tree.array[last_index];
1223 node = vat_json_object_get_element (node, "sw_if");
1224 ASSERT (NULL != node);
1225 node = vat_json_array_add (node);
1227 vat_json_init_object (node);
1228 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1230 vat_json_object_add_uint (node, "shg", mp->shg);
1233 static void vl_api_control_ping_reply_t_handler
1234 (vl_api_control_ping_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 i32 retval = ntohl (mp->retval);
1238 if (vam->async_mode)
1240 vam->async_errors += (retval < 0);
1244 vam->retval = retval;
1245 vam->result_ready = 1;
1249 static void vl_api_control_ping_reply_t_handler_json
1250 (vl_api_control_ping_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1255 if (VAT_JSON_NONE != vam->json_tree.type)
1257 vat_json_print (vam->ofp, &vam->json_tree);
1258 vat_json_free (&vam->json_tree);
1259 vam->json_tree.type = VAT_JSON_NONE;
1264 vat_json_init_array (&vam->json_tree);
1265 vat_json_print (vam->ofp, &vam->json_tree);
1266 vam->json_tree.type = VAT_JSON_NONE;
1269 vam->retval = retval;
1270 vam->result_ready = 1;
1274 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 i32 retval = ntohl (mp->retval);
1278 if (vam->async_mode)
1280 vam->async_errors += (retval < 0);
1284 vam->retval = retval;
1285 vam->result_ready = 1;
1289 static void vl_api_l2_flags_reply_t_handler_json
1290 (vl_api_l2_flags_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 vat_json_node_t node;
1295 vat_json_init_object (&node);
1296 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1297 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1298 ntohl (mp->resulting_feature_bitmap));
1300 vat_json_print (vam->ofp, &node);
1301 vat_json_free (&node);
1303 vam->retval = ntohl (mp->retval);
1304 vam->result_ready = 1;
1307 static void vl_api_bridge_flags_reply_t_handler
1308 (vl_api_bridge_flags_reply_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 i32 retval = ntohl (mp->retval);
1312 if (vam->async_mode)
1314 vam->async_errors += (retval < 0);
1318 vam->retval = retval;
1319 vam->result_ready = 1;
1323 static void vl_api_bridge_flags_reply_t_handler_json
1324 (vl_api_bridge_flags_reply_t * mp)
1326 vat_main_t *vam = &vat_main;
1327 vat_json_node_t node;
1329 vat_json_init_object (&node);
1330 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1331 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1332 ntohl (mp->resulting_feature_bitmap));
1334 vat_json_print (vam->ofp, &node);
1335 vat_json_free (&node);
1337 vam->retval = ntohl (mp->retval);
1338 vam->result_ready = 1;
1341 static void vl_api_tap_connect_reply_t_handler
1342 (vl_api_tap_connect_reply_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 i32 retval = ntohl (mp->retval);
1346 if (vam->async_mode)
1348 vam->async_errors += (retval < 0);
1352 vam->retval = retval;
1353 vam->sw_if_index = ntohl (mp->sw_if_index);
1354 vam->result_ready = 1;
1359 static void vl_api_tap_connect_reply_t_handler_json
1360 (vl_api_tap_connect_reply_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 vat_json_node_t node;
1365 vat_json_init_object (&node);
1366 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1367 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1369 vat_json_print (vam->ofp, &node);
1370 vat_json_free (&node);
1372 vam->retval = ntohl (mp->retval);
1373 vam->result_ready = 1;
1378 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1380 vat_main_t *vam = &vat_main;
1381 i32 retval = ntohl (mp->retval);
1382 if (vam->async_mode)
1384 vam->async_errors += (retval < 0);
1388 vam->retval = retval;
1389 vam->sw_if_index = ntohl (mp->sw_if_index);
1390 vam->result_ready = 1;
1394 static void vl_api_tap_modify_reply_t_handler_json
1395 (vl_api_tap_modify_reply_t * mp)
1397 vat_main_t *vam = &vat_main;
1398 vat_json_node_t node;
1400 vat_json_init_object (&node);
1401 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1402 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1404 vat_json_print (vam->ofp, &node);
1405 vat_json_free (&node);
1407 vam->retval = ntohl (mp->retval);
1408 vam->result_ready = 1;
1412 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1414 vat_main_t *vam = &vat_main;
1415 i32 retval = ntohl (mp->retval);
1416 if (vam->async_mode)
1418 vam->async_errors += (retval < 0);
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 static void vl_api_tap_delete_reply_t_handler_json
1428 (vl_api_tap_delete_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 vat_json_node_t node;
1433 vat_json_init_object (&node);
1434 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = ntohl (mp->retval);
1440 vam->result_ready = 1;
1443 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1444 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 i32 retval = ntohl (mp->retval);
1448 if (vam->async_mode)
1450 vam->async_errors += (retval < 0);
1454 vam->retval = retval;
1455 vam->result_ready = 1;
1459 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1460 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 vat_json_node_t node;
1465 vat_json_init_object (&node);
1466 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1467 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1468 ntohl (mp->sw_if_index));
1470 vat_json_print (vam->ofp, &node);
1471 vat_json_free (&node);
1473 vam->retval = ntohl (mp->retval);
1474 vam->result_ready = 1;
1477 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1478 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1480 vat_main_t *vam = &vat_main;
1481 i32 retval = ntohl (mp->retval);
1482 if (vam->async_mode)
1484 vam->async_errors += (retval < 0);
1488 vam->retval = retval;
1489 vam->sw_if_index = ntohl (mp->sw_if_index);
1490 vam->result_ready = 1;
1494 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1495 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 vat_json_node_t node;
1500 vat_json_init_object (&node);
1501 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1502 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1504 vat_json_print (vam->ofp, &node);
1505 vat_json_free (&node);
1507 vam->retval = ntohl (mp->retval);
1508 vam->result_ready = 1;
1512 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1513 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1515 vat_main_t *vam = &vat_main;
1516 i32 retval = ntohl (mp->retval);
1517 if (vam->async_mode)
1519 vam->async_errors += (retval < 0);
1523 vam->retval = retval;
1524 vam->result_ready = 1;
1528 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1529 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1531 vat_main_t *vam = &vat_main;
1532 vat_json_node_t node;
1534 vat_json_init_object (&node);
1535 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1536 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1538 vat_json_print (vam->ofp, &node);
1539 vat_json_free (&node);
1541 vam->retval = ntohl (mp->retval);
1542 vam->result_ready = 1;
1545 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1546 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 i32 retval = ntohl (mp->retval);
1550 if (vam->async_mode)
1552 vam->async_errors += (retval < 0);
1556 vam->retval = retval;
1557 vam->sw_if_index = ntohl (mp->sw_if_index);
1558 vam->result_ready = 1;
1562 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1563 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1565 vat_main_t *vam = &vat_main;
1566 vat_json_node_t node;
1568 vat_json_init_object (&node);
1569 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1570 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1572 vat_json_print (vam->ofp, &node);
1573 vat_json_free (&node);
1575 vam->retval = ntohl (mp->retval);
1576 vam->result_ready = 1;
1579 static void vl_api_gre_add_del_tunnel_reply_t_handler
1580 (vl_api_gre_add_del_tunnel_reply_t * mp)
1582 vat_main_t *vam = &vat_main;
1583 i32 retval = ntohl (mp->retval);
1584 if (vam->async_mode)
1586 vam->async_errors += (retval < 0);
1590 vam->retval = retval;
1591 vam->sw_if_index = ntohl (mp->sw_if_index);
1592 vam->result_ready = 1;
1596 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1597 (vl_api_gre_add_del_tunnel_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 vat_json_node_t node;
1602 vat_json_init_object (&node);
1603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1604 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1606 vat_json_print (vam->ofp, &node);
1607 vat_json_free (&node);
1609 vam->retval = ntohl (mp->retval);
1610 vam->result_ready = 1;
1613 static void vl_api_create_vhost_user_if_reply_t_handler
1614 (vl_api_create_vhost_user_if_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 i32 retval = ntohl (mp->retval);
1618 if (vam->async_mode)
1620 vam->async_errors += (retval < 0);
1624 vam->retval = retval;
1625 vam->sw_if_index = ntohl (mp->sw_if_index);
1626 vam->result_ready = 1;
1630 static void vl_api_create_vhost_user_if_reply_t_handler_json
1631 (vl_api_create_vhost_user_if_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 vat_json_node_t node;
1636 vat_json_init_object (&node);
1637 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1640 vat_json_print (vam->ofp, &node);
1641 vat_json_free (&node);
1643 vam->retval = ntohl (mp->retval);
1644 vam->result_ready = 1;
1647 static void vl_api_ip_address_details_t_handler
1648 (vl_api_ip_address_details_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 static ip_address_details_t empty_ip_address_details = { {0} };
1652 ip_address_details_t *address = NULL;
1653 ip_details_t *current_ip_details = NULL;
1654 ip_details_t *details = NULL;
1656 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1658 if (!details || vam->current_sw_if_index >= vec_len (details)
1659 || !details[vam->current_sw_if_index].present)
1661 errmsg ("ip address details arrived but not stored\n");
1662 errmsg ("ip_dump should be called first\n");
1666 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1668 #define addresses (current_ip_details->addr)
1670 vec_validate_init_empty (addresses, vec_len (addresses),
1671 empty_ip_address_details);
1673 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1675 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1676 address->prefix_length = mp->prefix_length;
1680 static void vl_api_ip_address_details_t_handler_json
1681 (vl_api_ip_address_details_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t *node = NULL;
1685 struct in6_addr ip6;
1688 if (VAT_JSON_ARRAY != vam->json_tree.type)
1690 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1691 vat_json_init_array (&vam->json_tree);
1693 node = vat_json_array_add (&vam->json_tree);
1695 vat_json_init_object (node);
1698 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1699 vat_json_object_add_ip6 (node, "ip", ip6);
1703 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1704 vat_json_object_add_ip4 (node, "ip", ip4);
1706 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1710 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1712 vat_main_t *vam = &vat_main;
1713 static ip_details_t empty_ip_details = { 0 };
1714 ip_details_t *ip = NULL;
1715 u32 sw_if_index = ~0;
1717 sw_if_index = ntohl (mp->sw_if_index);
1719 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1720 sw_if_index, empty_ip_details);
1722 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1729 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1731 vat_main_t *vam = &vat_main;
1733 if (VAT_JSON_ARRAY != vam->json_tree.type)
1735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1736 vat_json_init_array (&vam->json_tree);
1738 vat_json_array_add_uint (&vam->json_tree,
1739 clib_net_to_host_u32 (mp->sw_if_index));
1742 static void vl_api_map_domain_details_t_handler_json
1743 (vl_api_map_domain_details_t * mp)
1745 vat_json_node_t *node = NULL;
1746 vat_main_t *vam = &vat_main;
1747 struct in6_addr ip6;
1750 if (VAT_JSON_ARRAY != vam->json_tree.type)
1752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1753 vat_json_init_array (&vam->json_tree);
1756 node = vat_json_array_add (&vam->json_tree);
1757 vat_json_init_object (node);
1759 vat_json_object_add_uint (node, "domain_index",
1760 clib_net_to_host_u32 (mp->domain_index));
1761 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1762 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1763 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1764 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1765 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1766 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1767 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1768 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1769 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1770 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1771 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1772 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1773 vat_json_object_add_uint (node, "flags", mp->flags);
1774 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1775 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1778 static void vl_api_map_domain_details_t_handler
1779 (vl_api_map_domain_details_t * mp)
1781 vat_main_t *vam = &vat_main;
1783 if (mp->is_translation)
1786 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1787 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1788 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1789 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1790 clib_net_to_host_u32 (mp->domain_index));
1795 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1796 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1797 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1798 format_ip6_address, mp->ip6_src,
1799 clib_net_to_host_u32 (mp->domain_index));
1801 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1802 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1803 mp->is_translation ? "map-t" : "");
1806 static void vl_api_map_rule_details_t_handler_json
1807 (vl_api_map_rule_details_t * mp)
1809 struct in6_addr ip6;
1810 vat_json_node_t *node = NULL;
1811 vat_main_t *vam = &vat_main;
1813 if (VAT_JSON_ARRAY != vam->json_tree.type)
1815 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1816 vat_json_init_array (&vam->json_tree);
1819 node = vat_json_array_add (&vam->json_tree);
1820 vat_json_init_object (node);
1822 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1823 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1824 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1828 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1832 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1836 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1838 vat_main_t *vam = &vat_main;
1839 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1840 "router_addr %U host_mac %U\n",
1841 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1842 format_ip4_address, &mp->host_address,
1843 format_ip4_address, &mp->router_address,
1844 format_ethernet_address, mp->host_mac);
1847 static void vl_api_dhcp_compl_event_t_handler_json
1848 (vl_api_dhcp_compl_event_t * mp)
1850 /* JSON output not supported */
1854 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1857 vat_main_t *vam = &vat_main;
1858 static u64 default_counter = 0;
1860 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1862 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1863 sw_if_index, default_counter);
1864 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1868 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1869 interface_counter_t counter)
1871 vat_main_t *vam = &vat_main;
1872 static interface_counter_t default_counter = { 0, };
1874 vec_validate_init_empty (vam->combined_interface_counters,
1875 vnet_counter_type, NULL);
1876 vec_validate_init_empty (vam->combined_interface_counters
1877 [vnet_counter_type], sw_if_index, default_counter);
1878 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1881 static void vl_api_vnet_interface_counters_t_handler
1882 (vl_api_vnet_interface_counters_t * mp)
1887 static void vl_api_vnet_interface_counters_t_handler_json
1888 (vl_api_vnet_interface_counters_t * mp)
1890 interface_counter_t counter;
1895 u32 first_sw_if_index;
1898 count = ntohl (mp->count);
1899 first_sw_if_index = ntohl (mp->first_sw_if_index);
1901 if (!mp->is_combined)
1903 v_packets = (u64 *) & mp->data;
1904 for (i = 0; i < count; i++)
1907 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1908 set_simple_interface_counter (mp->vnet_counter_type,
1909 first_sw_if_index + i, packets);
1915 v = (vlib_counter_t *) & mp->data;
1916 for (i = 0; i < count; i++)
1919 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1921 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1922 set_combined_interface_counter (mp->vnet_counter_type,
1923 first_sw_if_index + i, counter);
1930 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1932 vat_main_t *vam = &vat_main;
1935 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1937 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1946 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1948 vat_main_t *vam = &vat_main;
1951 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1953 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
1961 static void vl_api_vnet_ip4_fib_counters_t_handler
1962 (vl_api_vnet_ip4_fib_counters_t * mp)
1967 static void vl_api_vnet_ip4_fib_counters_t_handler_json
1968 (vl_api_vnet_ip4_fib_counters_t * mp)
1970 vat_main_t *vam = &vat_main;
1971 vl_api_ip4_fib_counter_t *v;
1972 ip4_fib_counter_t *counter;
1979 vrf_id = ntohl (mp->vrf_id);
1980 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
1981 if (~0 == vrf_index)
1983 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
1984 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
1985 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
1986 vec_validate (vam->ip4_fib_counters, vrf_index);
1987 vam->ip4_fib_counters[vrf_index] = NULL;
1990 vec_free (vam->ip4_fib_counters[vrf_index]);
1991 v = (vl_api_ip4_fib_counter_t *) & mp->c;
1992 count = ntohl (mp->count);
1993 for (i = 0; i < count; i++)
1995 vec_validate (vam->ip4_fib_counters[vrf_index], i);
1996 counter = &vam->ip4_fib_counters[vrf_index][i];
1997 clib_memcpy (&ip4, &v->address, sizeof (ip4));
1998 counter->address = ip4;
1999 counter->address_length = v->address_length;
2000 counter->packets = clib_net_to_host_u64 (v->packets);
2001 counter->bytes = clib_net_to_host_u64 (v->bytes);
2006 static void vl_api_vnet_ip6_fib_counters_t_handler
2007 (vl_api_vnet_ip6_fib_counters_t * mp)
2012 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2013 (vl_api_vnet_ip6_fib_counters_t * mp)
2015 vat_main_t *vam = &vat_main;
2016 vl_api_ip6_fib_counter_t *v;
2017 ip6_fib_counter_t *counter;
2018 struct in6_addr ip6;
2024 vrf_id = ntohl (mp->vrf_id);
2025 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2026 if (~0 == vrf_index)
2028 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2029 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2030 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2031 vec_validate (vam->ip6_fib_counters, vrf_index);
2032 vam->ip6_fib_counters[vrf_index] = NULL;
2035 vec_free (vam->ip6_fib_counters[vrf_index]);
2036 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2037 count = ntohl (mp->count);
2038 for (i = 0; i < count; i++)
2040 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2041 counter = &vam->ip6_fib_counters[vrf_index][i];
2042 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2043 counter->address = ip6;
2044 counter->address_length = v->address_length;
2045 counter->packets = clib_net_to_host_u64 (v->packets);
2046 counter->bytes = clib_net_to_host_u64 (v->bytes);
2051 static void vl_api_get_first_msg_id_reply_t_handler
2052 (vl_api_get_first_msg_id_reply_t * mp)
2054 vat_main_t *vam = &vat_main;
2055 i32 retval = ntohl (mp->retval);
2057 if (vam->async_mode)
2059 vam->async_errors += (retval < 0);
2063 vam->retval = retval;
2064 vam->result_ready = 1;
2068 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2072 static void vl_api_get_first_msg_id_reply_t_handler_json
2073 (vl_api_get_first_msg_id_reply_t * mp)
2075 vat_main_t *vam = &vat_main;
2076 vat_json_node_t node;
2078 vat_json_init_object (&node);
2079 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2080 vat_json_object_add_uint (&node, "first_msg_id",
2081 (uint) ntohs (mp->first_msg_id));
2083 vat_json_print (vam->ofp, &node);
2084 vat_json_free (&node);
2086 vam->retval = ntohl (mp->retval);
2087 vam->result_ready = 1;
2090 static void vl_api_get_node_graph_reply_t_handler
2091 (vl_api_get_node_graph_reply_t * mp)
2093 vat_main_t *vam = &vat_main;
2094 api_main_t *am = &api_main;
2095 i32 retval = ntohl (mp->retval);
2096 u8 *pvt_copy, *reply;
2101 if (vam->async_mode)
2103 vam->async_errors += (retval < 0);
2107 vam->retval = retval;
2108 vam->result_ready = 1;
2111 /* "Should never happen..." */
2115 reply = (u8 *) (mp->reply_in_shmem);
2116 pvt_copy = vec_dup (reply);
2118 /* Toss the shared-memory original... */
2119 pthread_mutex_lock (&am->vlib_rp->mutex);
2120 oldheap = svm_push_data_heap (am->vlib_rp);
2124 svm_pop_heap (oldheap);
2125 pthread_mutex_unlock (&am->vlib_rp->mutex);
2127 if (vam->graph_nodes)
2129 hash_free (vam->graph_node_index_by_name);
2131 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2133 node = vam->graph_nodes[i];
2134 vec_free (node->name);
2135 vec_free (node->next_nodes);
2138 vec_free (vam->graph_nodes);
2141 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2142 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2143 vec_free (pvt_copy);
2145 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2147 node = vam->graph_nodes[i];
2148 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2152 static void vl_api_get_node_graph_reply_t_handler_json
2153 (vl_api_get_node_graph_reply_t * mp)
2155 vat_main_t *vam = &vat_main;
2156 api_main_t *am = &api_main;
2158 vat_json_node_t node;
2161 /* $$$$ make this real? */
2162 vat_json_init_object (&node);
2163 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2164 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2166 reply = (u8 *) (mp->reply_in_shmem);
2168 /* Toss the shared-memory original... */
2169 pthread_mutex_lock (&am->vlib_rp->mutex);
2170 oldheap = svm_push_data_heap (am->vlib_rp);
2174 svm_pop_heap (oldheap);
2175 pthread_mutex_unlock (&am->vlib_rp->mutex);
2177 vat_json_print (vam->ofp, &node);
2178 vat_json_free (&node);
2180 vam->retval = ntohl (mp->retval);
2181 vam->result_ready = 1;
2185 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2187 vat_main_t *vam = &vat_main;
2192 s = format (s, "%=16d%=16d%=16d\n",
2193 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2197 s = format (s, "%=16U%=16d%=16d\n",
2198 mp->is_ipv6 ? format_ip6_address :
2200 mp->ip_address, mp->priority, mp->weight);
2203 fformat (vam->ofp, "%v", s);
2208 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2211 vat_main_t *vam = &vat_main;
2212 vat_json_node_t *node = NULL;
2213 struct in6_addr ip6;
2216 if (VAT_JSON_ARRAY != vam->json_tree.type)
2218 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2219 vat_json_init_array (&vam->json_tree);
2221 node = vat_json_array_add (&vam->json_tree);
2222 vat_json_init_object (node);
2224 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2225 vat_json_object_add_uint (node, "priority", mp->priority);
2226 vat_json_object_add_uint (node, "weight", mp->weight);
2229 vat_json_object_add_uint (node, "sw_if_index",
2230 clib_net_to_host_u32 (mp->sw_if_index));
2235 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2236 vat_json_object_add_ip6 (node, "address", ip6);
2240 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2241 vat_json_object_add_ip4 (node, "address", ip4);
2247 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2250 vat_main_t *vam = &vat_main;
2253 ls_name = format (0, "%s", mp->ls_name);
2255 fformat (vam->ofp, "%=10d%=15v\n", clib_net_to_host_u32 (mp->ls_index),
2261 vl_api_lisp_locator_set_details_t_handler_json
2262 (vl_api_lisp_locator_set_details_t * mp)
2264 vat_main_t *vam = &vat_main;
2265 vat_json_node_t *node = 0;
2268 ls_name = format (0, "%s", mp->ls_name);
2269 vec_add1 (ls_name, 0);
2271 if (VAT_JSON_ARRAY != vam->json_tree.type)
2273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2274 vat_json_init_array (&vam->json_tree);
2276 node = vat_json_array_add (&vam->json_tree);
2278 vat_json_init_object (node);
2279 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2280 vat_json_object_add_uint (node, "ls_index",
2281 clib_net_to_host_u32 (mp->ls_index));
2286 format_lisp_flat_eid (u8 * s, va_list * args)
2288 u32 type = va_arg (*args, u32);
2289 u8 *eid = va_arg (*args, u8 *);
2290 u32 eid_len = va_arg (*args, u32);
2295 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2297 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2299 return format (s, "%U", format_ethernet_address, eid);
2305 format_lisp_eid_vat (u8 * s, va_list * args)
2307 u32 type = va_arg (*args, u32);
2308 u8 *eid = va_arg (*args, u8 *);
2309 u32 eid_len = va_arg (*args, u32);
2310 u8 *seid = va_arg (*args, u8 *);
2311 u32 seid_len = va_arg (*args, u32);
2312 u32 is_src_dst = va_arg (*args, u32);
2315 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2317 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2323 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2325 vat_main_t *vam = &vat_main;
2326 u8 *s = 0, *eid = 0;
2328 if (~0 == mp->locator_set_index)
2329 s = format (0, "action: %d", mp->action);
2331 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2333 eid = format (0, "%U", format_lisp_eid_vat,
2337 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2340 fformat (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s\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,
2345 clib_net_to_host_u16 (mp->key_id), mp->key);
2352 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2355 vat_main_t *vam = &vat_main;
2356 vat_json_node_t *node = 0;
2359 if (VAT_JSON_ARRAY != vam->json_tree.type)
2361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2362 vat_json_init_array (&vam->json_tree);
2364 node = vat_json_array_add (&vam->json_tree);
2366 vat_json_init_object (node);
2367 if (~0 == mp->locator_set_index)
2368 vat_json_object_add_uint (node, "action", mp->action);
2370 vat_json_object_add_uint (node, "locator_set_index",
2371 clib_net_to_host_u32 (mp->locator_set_index));
2373 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2374 eid = format (0, "%U", format_lisp_eid_vat,
2378 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2380 vat_json_object_add_string_copy (node, "eid", eid);
2381 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2382 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2383 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2387 vat_json_object_add_uint (node, "key_id",
2388 clib_net_to_host_u16 (mp->key_id));
2389 vat_json_object_add_string_copy (node, "key", mp->key);
2395 vl_api_lisp_eid_table_map_details_t_handler
2396 (vl_api_lisp_eid_table_map_details_t * mp)
2398 vat_main_t *vam = &vat_main;
2400 u8 *line = format (0, "%=10d%=10d",
2401 clib_net_to_host_u32 (mp->vni),
2402 clib_net_to_host_u32 (mp->dp_table));
2403 fformat (vam->ofp, "%v\n", line);
2408 vl_api_lisp_eid_table_map_details_t_handler_json
2409 (vl_api_lisp_eid_table_map_details_t * mp)
2411 vat_main_t *vam = &vat_main;
2412 vat_json_node_t *node = NULL;
2414 if (VAT_JSON_ARRAY != vam->json_tree.type)
2416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2417 vat_json_init_array (&vam->json_tree);
2419 node = vat_json_array_add (&vam->json_tree);
2420 vat_json_init_object (node);
2421 vat_json_object_add_uint (node, "dp_table",
2422 clib_net_to_host_u32 (mp->dp_table));
2423 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2427 vl_api_lisp_eid_table_vni_details_t_handler
2428 (vl_api_lisp_eid_table_vni_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2432 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2433 fformat (vam->ofp, "%v\n", line);
2438 vl_api_lisp_eid_table_vni_details_t_handler_json
2439 (vl_api_lisp_eid_table_vni_details_t * mp)
2441 vat_main_t *vam = &vat_main;
2442 vat_json_node_t *node = NULL;
2444 if (VAT_JSON_ARRAY != vam->json_tree.type)
2446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2447 vat_json_init_array (&vam->json_tree);
2449 node = vat_json_array_add (&vam->json_tree);
2450 vat_json_init_object (node);
2451 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2455 format_decap_next (u8 * s, va_list * args)
2457 u32 next_index = va_arg (*args, u32);
2461 case LISP_GPE_INPUT_NEXT_DROP:
2462 return format (s, "drop");
2463 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2464 return format (s, "ip4");
2465 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2466 return format (s, "ip6");
2468 return format (s, "unknown %d", next_index);
2474 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2477 vat_main_t *vam = &vat_main;
2479 u8 *flag_str = NULL;
2481 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2483 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2484 foreach_lisp_gpe_flag_bit;
2487 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2488 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2490 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2492 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2494 ntohl (mp->encap_fib_id),
2495 ntohl (mp->decap_fib_id),
2496 format_decap_next, ntohl (mp->dcap_next),
2498 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2504 vl_api_lisp_gpe_tunnel_details_t_handler_json
2505 (vl_api_lisp_gpe_tunnel_details_t * mp)
2507 vat_main_t *vam = &vat_main;
2508 vat_json_node_t *node = NULL;
2509 struct in6_addr ip6;
2513 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2515 if (VAT_JSON_ARRAY != vam->json_tree.type)
2517 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2518 vat_json_init_array (&vam->json_tree);
2520 node = vat_json_array_add (&vam->json_tree);
2522 vat_json_init_object (node);
2523 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2526 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2527 vat_json_object_add_ip6 (node, "source address", ip6);
2528 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2529 vat_json_object_add_ip6 (node, "destination address", ip6);
2533 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2534 vat_json_object_add_ip4 (node, "source address", ip4);
2535 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2536 vat_json_object_add_ip4 (node, "destination address", ip4);
2538 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2539 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2540 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2541 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2542 vat_json_object_add_uint (node, "flags", mp->flags);
2543 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2544 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2545 vat_json_object_add_uint (node, "res", mp->res);
2546 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2548 vec_free (next_decap_str);
2552 vl_api_show_lisp_map_register_state_reply_t_handler
2553 (vl_api_show_lisp_map_register_state_reply_t * mp)
2555 vat_main_t *vam = &vat_main;
2556 int retval = clib_net_to_host_u32 (mp->retval);
2558 fformat (vam->ofp, "%s\n", mp->is_enabled ? "enabled" : "disabled");
2560 vam->retval = retval;
2561 vam->result_ready = 1;
2565 vl_api_show_lisp_map_register_state_reply_t_handler_json
2566 (vl_api_show_lisp_map_register_state_reply_t * mp)
2568 vat_main_t *vam = &vat_main;
2569 vat_json_node_t _node, *node = &_node;
2570 int retval = clib_net_to_host_u32 (mp->retval);
2572 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2574 vat_json_init_object (node);
2575 vat_json_object_add_string_copy (node, "state", s);
2577 vat_json_print (vam->ofp, node);
2578 vat_json_free (node);
2580 vam->retval = retval;
2581 vam->result_ready = 1;
2586 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2587 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2589 vat_main_t *vam = &vat_main;
2590 int retval = clib_net_to_host_u32 (mp->retval);
2595 fformat (vam->ofp, "%s\n", mp->is_enabled ? "enabled" : "disabled");
2597 vam->retval = retval;
2598 vam->result_ready = 1;
2602 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2603 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2605 vat_main_t *vam = &vat_main;
2606 vat_json_node_t _node, *node = &_node;
2607 int retval = clib_net_to_host_u32 (mp->retval);
2609 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2610 vat_json_init_object (node);
2611 vat_json_object_add_string_copy (node, "state", s);
2613 vat_json_print (vam->ofp, node);
2614 vat_json_free (node);
2616 vam->retval = retval;
2617 vam->result_ready = 1;
2622 vl_api_lisp_adjacencies_get_reply_t_handler
2623 (vl_api_lisp_adjacencies_get_reply_t * mp)
2625 vat_main_t *vam = &vat_main;
2627 int retval = clib_net_to_host_u32 (mp->retval);
2628 vl_api_lisp_adjacency_t *a;
2633 n = clib_net_to_host_u32 (mp->count);
2635 for (i = 0; i < n; i++)
2637 a = &mp->adjacencies[i];
2638 fformat (vam->ofp, "%U %40U\n",
2639 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2640 format_lisp_flat_eid, a->eid_type, a->reid,
2641 a->reid_prefix_len);
2645 vam->retval = retval;
2646 vam->result_ready = 1;
2650 vl_api_lisp_adjacencies_get_reply_t_handler_json
2651 (vl_api_lisp_adjacencies_get_reply_t * mp)
2654 vat_main_t *vam = &vat_main;
2655 vat_json_node_t *e = 0, root;
2657 int retval = clib_net_to_host_u32 (mp->retval);
2658 vl_api_lisp_adjacency_t *a;
2663 n = clib_net_to_host_u32 (mp->count);
2664 vat_json_init_array (&root);
2666 for (i = 0; i < n; i++)
2668 e = vat_json_array_add (&root);
2669 a = &mp->adjacencies[i];
2671 vat_json_init_object (e);
2672 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2673 a->leid_prefix_len);
2675 vat_json_object_add_string_copy (e, "leid", s);
2678 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2679 a->reid_prefix_len);
2681 vat_json_object_add_string_copy (e, "reid", s);
2685 vat_json_print (vam->ofp, &root);
2686 vat_json_free (&root);
2689 vam->retval = retval;
2690 vam->result_ready = 1;
2694 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2697 vat_main_t *vam = &vat_main;
2699 fformat (vam->ofp, "%=20U\n",
2700 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2705 vl_api_lisp_map_server_details_t_handler_json
2706 (vl_api_lisp_map_server_details_t * mp)
2708 vat_main_t *vam = &vat_main;
2709 vat_json_node_t *node = NULL;
2710 struct in6_addr ip6;
2713 if (VAT_JSON_ARRAY != vam->json_tree.type)
2715 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2716 vat_json_init_array (&vam->json_tree);
2718 node = vat_json_array_add (&vam->json_tree);
2720 vat_json_init_object (node);
2723 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2724 vat_json_object_add_ip6 (node, "map-server", ip6);
2728 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2729 vat_json_object_add_ip4 (node, "map-server", ip4);
2734 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2737 vat_main_t *vam = &vat_main;
2739 fformat (vam->ofp, "%=20U\n",
2740 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2745 vl_api_lisp_map_resolver_details_t_handler_json
2746 (vl_api_lisp_map_resolver_details_t * mp)
2748 vat_main_t *vam = &vat_main;
2749 vat_json_node_t *node = NULL;
2750 struct in6_addr ip6;
2753 if (VAT_JSON_ARRAY != vam->json_tree.type)
2755 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2756 vat_json_init_array (&vam->json_tree);
2758 node = vat_json_array_add (&vam->json_tree);
2760 vat_json_init_object (node);
2763 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2764 vat_json_object_add_ip6 (node, "map resolver", ip6);
2768 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2769 vat_json_object_add_ip4 (node, "map resolver", ip4);
2774 vl_api_show_lisp_status_reply_t_handler
2775 (vl_api_show_lisp_status_reply_t * mp)
2777 vat_main_t *vam = &vat_main;
2778 i32 retval = ntohl (mp->retval);
2782 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2783 mp->feature_status ? "enabled" : "disabled",
2784 mp->gpe_status ? "enabled" : "disabled");
2787 vam->retval = retval;
2788 vam->result_ready = 1;
2792 vl_api_show_lisp_status_reply_t_handler_json
2793 (vl_api_show_lisp_status_reply_t * mp)
2795 vat_main_t *vam = &vat_main;
2796 vat_json_node_t node;
2797 u8 *gpe_status = NULL;
2798 u8 *feature_status = NULL;
2800 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2801 feature_status = format (0, "%s",
2802 mp->feature_status ? "enabled" : "disabled");
2803 vec_add1 (gpe_status, 0);
2804 vec_add1 (feature_status, 0);
2806 vat_json_init_object (&node);
2807 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2808 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2810 vec_free (gpe_status);
2811 vec_free (feature_status);
2813 vat_json_print (vam->ofp, &node);
2814 vat_json_free (&node);
2816 vam->retval = ntohl (mp->retval);
2817 vam->result_ready = 1;
2821 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2822 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2824 vat_main_t *vam = &vat_main;
2825 i32 retval = ntohl (mp->retval);
2829 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2832 vam->retval = retval;
2833 vam->result_ready = 1;
2837 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2838 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2840 vat_main_t *vam = &vat_main;
2841 vat_json_node_t *node = NULL;
2843 if (VAT_JSON_ARRAY != vam->json_tree.type)
2845 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2846 vat_json_init_array (&vam->json_tree);
2848 node = vat_json_array_add (&vam->json_tree);
2850 vat_json_init_object (node);
2851 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2853 vat_json_print (vam->ofp, node);
2854 vat_json_free (node);
2856 vam->retval = ntohl (mp->retval);
2857 vam->result_ready = 1;
2861 format_lisp_map_request_mode (u8 * s, va_list * args)
2863 u32 mode = va_arg (*args, u32);
2868 return format (0, "dst-only");
2870 return format (0, "src-dst");
2876 vl_api_show_lisp_map_request_mode_reply_t_handler
2877 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2879 vat_main_t *vam = &vat_main;
2880 i32 retval = ntohl (mp->retval);
2884 u32 mode = mp->mode;
2885 fformat (vam->ofp, "map_request_mode: %U\n",
2886 format_lisp_map_request_mode, mode);
2889 vam->retval = retval;
2890 vam->result_ready = 1;
2894 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2895 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2897 vat_main_t *vam = &vat_main;
2898 vat_json_node_t node;
2903 s = format (0, "%U", format_lisp_map_request_mode, mode);
2906 vat_json_init_object (&node);
2907 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2908 vat_json_print (vam->ofp, &node);
2909 vat_json_free (&node);
2912 vam->retval = ntohl (mp->retval);
2913 vam->result_ready = 1;
2917 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2919 vat_main_t *vam = &vat_main;
2920 i32 retval = ntohl (mp->retval);
2924 fformat (vam->ofp, "%-20s%-16s\n",
2925 mp->status ? "enabled" : "disabled",
2926 mp->status ? (char *) mp->locator_set_name : "");
2929 vam->retval = retval;
2930 vam->result_ready = 1;
2934 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2937 vat_main_t *vam = &vat_main;
2938 vat_json_node_t node;
2941 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2942 vec_add1 (status, 0);
2944 vat_json_init_object (&node);
2945 vat_json_object_add_string_copy (&node, "status", status);
2948 vat_json_object_add_string_copy (&node, "locator_set",
2949 mp->locator_set_name);
2954 vat_json_print (vam->ofp, &node);
2955 vat_json_free (&node);
2957 vam->retval = ntohl (mp->retval);
2958 vam->result_ready = 1;
2962 format_policer_type (u8 * s, va_list * va)
2964 u32 i = va_arg (*va, u32);
2966 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2967 s = format (s, "1r2c");
2968 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2969 s = format (s, "1r3c");
2970 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2971 s = format (s, "2r3c-2698");
2972 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2973 s = format (s, "2r3c-4115");
2974 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2975 s = format (s, "2r3c-mef5cf1");
2977 s = format (s, "ILLEGAL");
2982 format_policer_rate_type (u8 * s, va_list * va)
2984 u32 i = va_arg (*va, u32);
2986 if (i == SSE2_QOS_RATE_KBPS)
2987 s = format (s, "kbps");
2988 else if (i == SSE2_QOS_RATE_PPS)
2989 s = format (s, "pps");
2991 s = format (s, "ILLEGAL");
2996 format_policer_round_type (u8 * s, va_list * va)
2998 u32 i = va_arg (*va, u32);
3000 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3001 s = format (s, "closest");
3002 else if (i == SSE2_QOS_ROUND_TO_UP)
3003 s = format (s, "up");
3004 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3005 s = format (s, "down");
3007 s = format (s, "ILLEGAL");
3012 format_policer_action_type (u8 * s, va_list * va)
3014 u32 i = va_arg (*va, u32);
3016 if (i == SSE2_QOS_ACTION_DROP)
3017 s = format (s, "drop");
3018 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3019 s = format (s, "transmit");
3020 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3021 s = format (s, "mark-and-transmit");
3023 s = format (s, "ILLEGAL");
3028 format_dscp (u8 * s, va_list * va)
3030 u32 i = va_arg (*va, u32);
3035 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3039 return format (s, "ILLEGAL");
3041 s = format (s, "%s", t);
3046 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3048 vat_main_t *vam = &vat_main;
3049 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3051 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3052 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3054 conform_dscp_str = format (0, "");
3056 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3057 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3059 exceed_dscp_str = format (0, "");
3061 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3062 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3064 violate_dscp_str = format (0, "");
3066 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3067 "rate type %U, round type %U, %s rate, %s color-aware, "
3068 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3069 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3070 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
3072 format_policer_type, mp->type,
3075 clib_net_to_host_u64 (mp->cb),
3076 clib_net_to_host_u64 (mp->eb),
3077 format_policer_rate_type, mp->rate_type,
3078 format_policer_round_type, mp->round_type,
3079 mp->single_rate ? "single" : "dual",
3080 mp->color_aware ? "is" : "not",
3081 ntohl (mp->cir_tokens_per_period),
3082 ntohl (mp->pir_tokens_per_period),
3084 ntohl (mp->current_limit),
3085 ntohl (mp->current_bucket),
3086 ntohl (mp->extended_limit),
3087 ntohl (mp->extended_bucket),
3088 clib_net_to_host_u64 (mp->last_update_time),
3089 format_policer_action_type, mp->conform_action_type,
3091 format_policer_action_type, mp->exceed_action_type,
3093 format_policer_action_type, mp->violate_action_type,
3096 vec_free (conform_dscp_str);
3097 vec_free (exceed_dscp_str);
3098 vec_free (violate_dscp_str);
3101 static void vl_api_policer_details_t_handler_json
3102 (vl_api_policer_details_t * mp)
3104 vat_main_t *vam = &vat_main;
3105 vat_json_node_t *node;
3106 u8 *rate_type_str, *round_type_str, *type_str;
3107 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3109 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3111 format (0, "%U", format_policer_round_type, mp->round_type);
3112 type_str = format (0, "%U", format_policer_type, mp->type);
3113 conform_action_str = format (0, "%U", format_policer_action_type,
3114 mp->conform_action_type);
3115 exceed_action_str = format (0, "%U", format_policer_action_type,
3116 mp->exceed_action_type);
3117 violate_action_str = format (0, "%U", format_policer_action_type,
3118 mp->violate_action_type);
3120 if (VAT_JSON_ARRAY != vam->json_tree.type)
3122 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3123 vat_json_init_array (&vam->json_tree);
3125 node = vat_json_array_add (&vam->json_tree);
3127 vat_json_init_object (node);
3128 vat_json_object_add_string_copy (node, "name", mp->name);
3129 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3130 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3131 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3132 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3133 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3134 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3135 vat_json_object_add_string_copy (node, "type", type_str);
3136 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3137 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3138 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3139 vat_json_object_add_uint (node, "cir_tokens_per_period",
3140 ntohl (mp->cir_tokens_per_period));
3141 vat_json_object_add_uint (node, "eir_tokens_per_period",
3142 ntohl (mp->pir_tokens_per_period));
3143 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3144 vat_json_object_add_uint (node, "current_bucket",
3145 ntohl (mp->current_bucket));
3146 vat_json_object_add_uint (node, "extended_limit",
3147 ntohl (mp->extended_limit));
3148 vat_json_object_add_uint (node, "extended_bucket",
3149 ntohl (mp->extended_bucket));
3150 vat_json_object_add_uint (node, "last_update_time",
3151 ntohl (mp->last_update_time));
3152 vat_json_object_add_string_copy (node, "conform_action",
3153 conform_action_str);
3154 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3156 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3157 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3158 vec_free (dscp_str);
3160 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3161 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3163 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3164 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3165 vec_free (dscp_str);
3167 vat_json_object_add_string_copy (node, "violate_action",
3168 violate_action_str);
3169 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3171 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3172 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3173 vec_free (dscp_str);
3176 vec_free (rate_type_str);
3177 vec_free (round_type_str);
3178 vec_free (type_str);
3179 vec_free (conform_action_str);
3180 vec_free (exceed_action_str);
3181 vec_free (violate_action_str);
3185 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3188 vat_main_t *vam = &vat_main;
3189 int i, count = ntohl (mp->count);
3192 fformat (vam->ofp, "classify table ids (%d) : ", count);
3193 for (i = 0; i < count; i++)
3195 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3196 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3198 vam->retval = ntohl (mp->retval);
3199 vam->result_ready = 1;
3203 vl_api_classify_table_ids_reply_t_handler_json
3204 (vl_api_classify_table_ids_reply_t * mp)
3206 vat_main_t *vam = &vat_main;
3207 int i, count = ntohl (mp->count);
3211 vat_json_node_t node;
3213 vat_json_init_object (&node);
3214 for (i = 0; i < count; i++)
3216 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3218 vat_json_print (vam->ofp, &node);
3219 vat_json_free (&node);
3221 vam->retval = ntohl (mp->retval);
3222 vam->result_ready = 1;
3226 vl_api_classify_table_by_interface_reply_t_handler
3227 (vl_api_classify_table_by_interface_reply_t * mp)
3229 vat_main_t *vam = &vat_main;
3232 table_id = ntohl (mp->l2_table_id);
3234 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3236 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3237 table_id = ntohl (mp->ip4_table_id);
3239 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3241 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3242 table_id = ntohl (mp->ip6_table_id);
3244 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3246 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3247 vam->retval = ntohl (mp->retval);
3248 vam->result_ready = 1;
3252 vl_api_classify_table_by_interface_reply_t_handler_json
3253 (vl_api_classify_table_by_interface_reply_t * mp)
3255 vat_main_t *vam = &vat_main;
3256 vat_json_node_t node;
3258 vat_json_init_object (&node);
3260 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3261 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3262 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3264 vat_json_print (vam->ofp, &node);
3265 vat_json_free (&node);
3267 vam->retval = ntohl (mp->retval);
3268 vam->result_ready = 1;
3271 static void vl_api_policer_add_del_reply_t_handler
3272 (vl_api_policer_add_del_reply_t * mp)
3274 vat_main_t *vam = &vat_main;
3275 i32 retval = ntohl (mp->retval);
3276 if (vam->async_mode)
3278 vam->async_errors += (retval < 0);
3282 vam->retval = retval;
3283 vam->result_ready = 1;
3284 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3286 * Note: this is just barely thread-safe, depends on
3287 * the main thread spinning waiting for an answer...
3289 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3293 static void vl_api_policer_add_del_reply_t_handler_json
3294 (vl_api_policer_add_del_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 vat_json_node_t node;
3299 vat_json_init_object (&node);
3300 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3301 vat_json_object_add_uint (&node, "policer_index",
3302 ntohl (mp->policer_index));
3304 vat_json_print (vam->ofp, &node);
3305 vat_json_free (&node);
3307 vam->retval = ntohl (mp->retval);
3308 vam->result_ready = 1;
3311 /* Format hex dump. */
3313 format_hex_bytes (u8 * s, va_list * va)
3315 u8 *bytes = va_arg (*va, u8 *);
3316 int n_bytes = va_arg (*va, int);
3319 /* Print short or long form depending on byte count. */
3320 uword short_form = n_bytes <= 32;
3321 uword indent = format_get_indent (s);
3326 for (i = 0; i < n_bytes; i++)
3328 if (!short_form && (i % 32) == 0)
3329 s = format (s, "%08x: ", i);
3330 s = format (s, "%02x", bytes[i]);
3331 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3332 s = format (s, "\n%U", format_white_space, indent);
3339 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3342 vat_main_t *vam = &vat_main;
3343 i32 retval = ntohl (mp->retval);
3346 fformat (vam->ofp, "classify table info :\n");
3347 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3348 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3349 ntohl (mp->miss_next_index));
3350 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3351 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3352 ntohl (mp->match_n_vectors));
3353 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3354 ntohl (mp->mask_length));
3356 vam->retval = retval;
3357 vam->result_ready = 1;
3361 vl_api_classify_table_info_reply_t_handler_json
3362 (vl_api_classify_table_info_reply_t * mp)
3364 vat_main_t *vam = &vat_main;
3365 vat_json_node_t node;
3367 i32 retval = ntohl (mp->retval);
3370 vat_json_init_object (&node);
3372 vat_json_object_add_int (&node, "sessions",
3373 ntohl (mp->active_sessions));
3374 vat_json_object_add_int (&node, "nexttbl",
3375 ntohl (mp->next_table_index));
3376 vat_json_object_add_int (&node, "nextnode",
3377 ntohl (mp->miss_next_index));
3378 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3379 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3380 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3381 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3382 ntohl (mp->mask_length), 0);
3383 vat_json_object_add_string_copy (&node, "mask", s);
3385 vat_json_print (vam->ofp, &node);
3386 vat_json_free (&node);
3388 vam->retval = ntohl (mp->retval);
3389 vam->result_ready = 1;
3393 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3396 vat_main_t *vam = &vat_main;
3398 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3399 ntohl (mp->hit_next_index), ntohl (mp->advance),
3400 ntohl (mp->opaque_index));
3401 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3402 ntohl (mp->match_length));
3406 vl_api_classify_session_details_t_handler_json
3407 (vl_api_classify_session_details_t * mp)
3409 vat_main_t *vam = &vat_main;
3410 vat_json_node_t *node = NULL;
3412 if (VAT_JSON_ARRAY != vam->json_tree.type)
3414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3415 vat_json_init_array (&vam->json_tree);
3417 node = vat_json_array_add (&vam->json_tree);
3419 vat_json_init_object (node);
3420 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3421 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3422 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3424 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3426 vat_json_object_add_string_copy (node, "match", s);
3429 static void vl_api_pg_create_interface_reply_t_handler
3430 (vl_api_pg_create_interface_reply_t * mp)
3432 vat_main_t *vam = &vat_main;
3434 vam->retval = ntohl (mp->retval);
3435 vam->result_ready = 1;
3438 static void vl_api_pg_create_interface_reply_t_handler_json
3439 (vl_api_pg_create_interface_reply_t * mp)
3441 vat_main_t *vam = &vat_main;
3442 vat_json_node_t node;
3444 i32 retval = ntohl (mp->retval);
3447 vat_json_init_object (&node);
3449 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3451 vat_json_print (vam->ofp, &node);
3452 vat_json_free (&node);
3454 vam->retval = ntohl (mp->retval);
3455 vam->result_ready = 1;
3458 static void vl_api_policer_classify_details_t_handler
3459 (vl_api_policer_classify_details_t * mp)
3461 vat_main_t *vam = &vat_main;
3463 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3464 ntohl (mp->table_index));
3467 static void vl_api_policer_classify_details_t_handler_json
3468 (vl_api_policer_classify_details_t * mp)
3470 vat_main_t *vam = &vat_main;
3471 vat_json_node_t *node;
3473 if (VAT_JSON_ARRAY != vam->json_tree.type)
3475 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3476 vat_json_init_array (&vam->json_tree);
3478 node = vat_json_array_add (&vam->json_tree);
3480 vat_json_init_object (node);
3481 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3482 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3485 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3486 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3488 vat_main_t *vam = &vat_main;
3489 i32 retval = ntohl (mp->retval);
3490 if (vam->async_mode)
3492 vam->async_errors += (retval < 0);
3496 vam->retval = retval;
3497 vam->sw_if_index = ntohl (mp->sw_if_index);
3498 vam->result_ready = 1;
3502 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3503 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3505 vat_main_t *vam = &vat_main;
3506 vat_json_node_t node;
3508 vat_json_init_object (&node);
3509 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3510 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3512 vat_json_print (vam->ofp, &node);
3513 vat_json_free (&node);
3515 vam->retval = ntohl (mp->retval);
3516 vam->result_ready = 1;
3519 static void vl_api_flow_classify_details_t_handler
3520 (vl_api_flow_classify_details_t * mp)
3522 vat_main_t *vam = &vat_main;
3524 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3525 ntohl (mp->table_index));
3528 static void vl_api_flow_classify_details_t_handler_json
3529 (vl_api_flow_classify_details_t * mp)
3531 vat_main_t *vam = &vat_main;
3532 vat_json_node_t *node;
3534 if (VAT_JSON_ARRAY != vam->json_tree.type)
3536 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3537 vat_json_init_array (&vam->json_tree);
3539 node = vat_json_array_add (&vam->json_tree);
3541 vat_json_init_object (node);
3542 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3543 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3548 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3549 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3550 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3551 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3552 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3553 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3556 * Generate boilerplate reply handlers, which
3557 * dig the return value out of the xxx_reply_t API message,
3558 * stick it into vam->retval, and set vam->result_ready
3560 * Could also do this by pointing N message decode slots at
3561 * a single function, but that could break in subtle ways.
3564 #define foreach_standard_reply_retval_handler \
3565 _(sw_interface_set_flags_reply) \
3566 _(sw_interface_add_del_address_reply) \
3567 _(sw_interface_set_table_reply) \
3568 _(sw_interface_set_mpls_enable_reply) \
3569 _(sw_interface_set_vpath_reply) \
3570 _(sw_interface_set_vxlan_bypass_reply) \
3571 _(sw_interface_set_l2_bridge_reply) \
3572 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3573 _(sw_interface_set_dpdk_hqos_subport_reply) \
3574 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3575 _(bridge_domain_add_del_reply) \
3576 _(sw_interface_set_l2_xconnect_reply) \
3577 _(l2fib_add_del_reply) \
3578 _(ip_add_del_route_reply) \
3579 _(mpls_route_add_del_reply) \
3580 _(mpls_ip_bind_unbind_reply) \
3581 _(proxy_arp_add_del_reply) \
3582 _(proxy_arp_intfc_enable_disable_reply) \
3583 _(sw_interface_set_unnumbered_reply) \
3584 _(ip_neighbor_add_del_reply) \
3585 _(reset_vrf_reply) \
3586 _(oam_add_del_reply) \
3587 _(reset_fib_reply) \
3588 _(dhcp_proxy_config_reply) \
3589 _(dhcp_proxy_config_2_reply) \
3590 _(dhcp_proxy_set_vss_reply) \
3591 _(dhcp_client_config_reply) \
3592 _(set_ip_flow_hash_reply) \
3593 _(sw_interface_ip6_enable_disable_reply) \
3594 _(sw_interface_ip6_set_link_local_address_reply) \
3595 _(sw_interface_ip6nd_ra_prefix_reply) \
3596 _(sw_interface_ip6nd_ra_config_reply) \
3597 _(set_arp_neighbor_limit_reply) \
3598 _(l2_patch_add_del_reply) \
3599 _(sr_tunnel_add_del_reply) \
3600 _(sr_policy_add_del_reply) \
3601 _(sr_multicast_map_add_del_reply) \
3602 _(classify_add_del_session_reply) \
3603 _(classify_set_interface_ip_table_reply) \
3604 _(classify_set_interface_l2_tables_reply) \
3605 _(l2tpv3_set_tunnel_cookies_reply) \
3606 _(l2tpv3_interface_enable_disable_reply) \
3607 _(l2tpv3_set_lookup_key_reply) \
3608 _(l2_fib_clear_table_reply) \
3609 _(l2_interface_efp_filter_reply) \
3610 _(l2_interface_vlan_tag_rewrite_reply) \
3611 _(modify_vhost_user_if_reply) \
3612 _(delete_vhost_user_if_reply) \
3613 _(want_ip4_arp_events_reply) \
3614 _(want_ip6_nd_events_reply) \
3615 _(input_acl_set_interface_reply) \
3616 _(ipsec_spd_add_del_reply) \
3617 _(ipsec_interface_add_del_spd_reply) \
3618 _(ipsec_spd_add_del_entry_reply) \
3619 _(ipsec_sad_add_del_entry_reply) \
3620 _(ipsec_sa_set_key_reply) \
3621 _(ikev2_profile_add_del_reply) \
3622 _(ikev2_profile_set_auth_reply) \
3623 _(ikev2_profile_set_id_reply) \
3624 _(ikev2_profile_set_ts_reply) \
3625 _(ikev2_set_local_key_reply) \
3626 _(delete_loopback_reply) \
3627 _(bd_ip_mac_add_del_reply) \
3628 _(map_del_domain_reply) \
3629 _(map_add_del_rule_reply) \
3630 _(want_interface_events_reply) \
3631 _(want_stats_reply) \
3632 _(cop_interface_enable_disable_reply) \
3633 _(cop_whitelist_enable_disable_reply) \
3634 _(sw_interface_clear_stats_reply) \
3635 _(ioam_enable_reply) \
3636 _(ioam_disable_reply) \
3637 _(lisp_add_del_locator_reply) \
3638 _(lisp_add_del_local_eid_reply) \
3639 _(lisp_add_del_remote_mapping_reply) \
3640 _(lisp_add_del_adjacency_reply) \
3641 _(lisp_gpe_add_del_fwd_entry_reply) \
3642 _(lisp_add_del_map_resolver_reply) \
3643 _(lisp_add_del_map_server_reply) \
3644 _(lisp_gpe_enable_disable_reply) \
3645 _(lisp_gpe_add_del_iface_reply) \
3646 _(lisp_enable_disable_reply) \
3647 _(lisp_rloc_probe_enable_disable_reply) \
3648 _(lisp_map_register_enable_disable_reply) \
3649 _(lisp_pitr_set_locator_set_reply) \
3650 _(lisp_map_request_mode_reply) \
3651 _(lisp_add_del_map_request_itr_rlocs_reply) \
3652 _(lisp_eid_table_add_del_map_reply) \
3653 _(vxlan_gpe_add_del_tunnel_reply) \
3654 _(af_packet_delete_reply) \
3655 _(policer_classify_set_interface_reply) \
3656 _(netmap_create_reply) \
3657 _(netmap_delete_reply) \
3658 _(set_ipfix_exporter_reply) \
3659 _(set_ipfix_classify_stream_reply) \
3660 _(ipfix_classify_table_add_del_reply) \
3661 _(flow_classify_set_interface_reply) \
3662 _(sw_interface_span_enable_disable_reply) \
3663 _(pg_capture_reply) \
3664 _(pg_enable_disable_reply) \
3665 _(ip_source_and_port_range_check_add_del_reply) \
3666 _(ip_source_and_port_range_check_interface_add_del_reply)\
3667 _(delete_subif_reply) \
3668 _(l2_interface_pbb_tag_rewrite_reply) \
3670 _(feature_enable_disable_reply) \
3671 _(sw_interface_tag_add_del_reply) \
3672 _(sw_interface_set_mtu_reply)
3675 static void vl_api_##n##_t_handler \
3676 (vl_api_##n##_t * mp) \
3678 vat_main_t * vam = &vat_main; \
3679 i32 retval = ntohl(mp->retval); \
3680 if (vam->async_mode) { \
3681 vam->async_errors += (retval < 0); \
3683 vam->retval = retval; \
3684 vam->result_ready = 1; \
3687 foreach_standard_reply_retval_handler;
3691 static void vl_api_##n##_t_handler_json \
3692 (vl_api_##n##_t * mp) \
3694 vat_main_t * vam = &vat_main; \
3695 vat_json_node_t node; \
3696 vat_json_init_object(&node); \
3697 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3698 vat_json_print(vam->ofp, &node); \
3699 vam->retval = ntohl(mp->retval); \
3700 vam->result_ready = 1; \
3702 foreach_standard_reply_retval_handler;
3706 * Table of message reply handlers, must include boilerplate handlers
3710 #define foreach_vpe_api_reply_msg \
3711 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3712 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3713 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3714 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3715 _(CONTROL_PING_REPLY, control_ping_reply) \
3716 _(CLI_REPLY, cli_reply) \
3717 _(CLI_INBAND_REPLY, cli_inband_reply) \
3718 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3719 sw_interface_add_del_address_reply) \
3720 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3721 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3722 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3723 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3724 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3725 sw_interface_set_l2_xconnect_reply) \
3726 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3727 sw_interface_set_l2_bridge_reply) \
3728 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3729 sw_interface_set_dpdk_hqos_pipe_reply) \
3730 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3731 sw_interface_set_dpdk_hqos_subport_reply) \
3732 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3733 sw_interface_set_dpdk_hqos_tctbl_reply) \
3734 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3735 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3736 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3737 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3738 _(L2_FLAGS_REPLY, l2_flags_reply) \
3739 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3740 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3741 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3742 _(TAP_DELETE_REPLY, tap_delete_reply) \
3743 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3744 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3745 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3746 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3747 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3748 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3749 proxy_arp_intfc_enable_disable_reply) \
3750 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3751 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3752 sw_interface_set_unnumbered_reply) \
3753 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3754 _(RESET_VRF_REPLY, reset_vrf_reply) \
3755 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3756 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3757 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3758 _(RESET_FIB_REPLY, reset_fib_reply) \
3759 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3760 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3761 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3762 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3763 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3764 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3765 sw_interface_ip6_enable_disable_reply) \
3766 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3767 sw_interface_ip6_set_link_local_address_reply) \
3768 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3769 sw_interface_ip6nd_ra_prefix_reply) \
3770 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3771 sw_interface_ip6nd_ra_config_reply) \
3772 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3773 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3774 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3775 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3776 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3777 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3778 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3779 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3780 classify_set_interface_ip_table_reply) \
3781 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3782 classify_set_interface_l2_tables_reply) \
3783 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3784 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3785 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3786 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3787 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3788 l2tpv3_interface_enable_disable_reply) \
3789 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3790 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3791 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3792 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3793 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3794 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3795 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3796 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3797 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3798 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3799 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3800 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3801 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3802 _(SHOW_VERSION_REPLY, show_version_reply) \
3803 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3804 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3805 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3806 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3807 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3808 _(IP4_ARP_EVENT, ip4_arp_event) \
3809 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3810 _(IP6_ND_EVENT, ip6_nd_event) \
3811 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3812 _(IP_ADDRESS_DETAILS, ip_address_details) \
3813 _(IP_DETAILS, ip_details) \
3814 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3815 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3816 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3817 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3818 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3819 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3820 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3821 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3822 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3823 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3824 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3825 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3826 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3827 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3828 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3829 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3830 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3831 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3832 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3833 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3834 _(MAP_RULE_DETAILS, map_rule_details) \
3835 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3836 _(WANT_STATS_REPLY, want_stats_reply) \
3837 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3838 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3839 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3840 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3841 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3842 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3843 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3844 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3845 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3846 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3847 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3848 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3849 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3850 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3851 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3852 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3853 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3854 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3855 lisp_map_register_enable_disable_reply) \
3856 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3857 lisp_rloc_probe_enable_disable_reply) \
3858 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3859 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3860 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3861 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3862 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3863 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3864 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3865 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3866 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3867 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3868 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3869 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3870 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3871 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3872 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3873 lisp_add_del_map_request_itr_rlocs_reply) \
3874 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3875 lisp_get_map_request_itr_rlocs_reply) \
3876 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3877 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3878 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3879 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3880 show_lisp_map_register_state_reply) \
3881 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3882 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3883 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3884 _(POLICER_DETAILS, policer_details) \
3885 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3886 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3887 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3888 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3889 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3890 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3891 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3892 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3893 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3894 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3895 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3896 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3897 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3898 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3899 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3900 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3901 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3902 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3903 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3904 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3905 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3906 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3907 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3908 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3909 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3910 ip_source_and_port_range_check_add_del_reply) \
3911 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3912 ip_source_and_port_range_check_interface_add_del_reply) \
3913 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3914 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3915 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3916 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3917 _(PUNT_REPLY, punt_reply) \
3918 _(IP_FIB_DETAILS, ip_fib_details) \
3919 _(IP6_FIB_DETAILS, ip6_fib_details) \
3920 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3921 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3922 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3923 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply)
3925 /* M: construct, but don't yet send a message */
3929 vam->result_ready = 0; \
3930 mp = vl_msg_api_alloc(sizeof(*mp)); \
3931 memset (mp, 0, sizeof (*mp)); \
3932 mp->_vl_msg_id = ntohs (VL_API_##T); \
3933 mp->client_index = vam->my_client_index; \
3938 vam->result_ready = 0; \
3939 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3940 memset (mp, 0, sizeof (*mp)); \
3941 mp->_vl_msg_id = ntohs (VL_API_##T); \
3942 mp->client_index = vam->my_client_index; \
3946 /* S: send a message */
3947 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3949 /* W: wait for results, with timeout */
3952 timeout = vat_time_now (vam) + 1.0; \
3954 while (vat_time_now (vam) < timeout) { \
3955 if (vam->result_ready == 1) { \
3956 return (vam->retval); \
3962 /* W2: wait for results, with timeout */
3965 timeout = vat_time_now (vam) + 1.0; \
3967 while (vat_time_now (vam) < timeout) { \
3968 if (vam->result_ready == 1) { \
3970 return (vam->retval); \
3983 #define STR_VTR_OP_CASE(op) \
3984 case L2_VTR_ ## op: \
3988 str_vtr_op (u32 vtr_op)
3992 STR_VTR_OP_CASE (DISABLED);
3993 STR_VTR_OP_CASE (PUSH_1);
3994 STR_VTR_OP_CASE (PUSH_2);
3995 STR_VTR_OP_CASE (POP_1);
3996 STR_VTR_OP_CASE (POP_2);
3997 STR_VTR_OP_CASE (TRANSLATE_1_1);
3998 STR_VTR_OP_CASE (TRANSLATE_1_2);
3999 STR_VTR_OP_CASE (TRANSLATE_2_1);
4000 STR_VTR_OP_CASE (TRANSLATE_2_2);
4007 dump_sub_interface_table (vat_main_t * vam)
4009 const sw_interface_subif_t *sub = NULL;
4011 if (vam->json_output)
4014 ("JSON output supported only for VPE API calls and dump_stats_table");
4019 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
4020 "Interface", "sw_if_index",
4021 "sub id", "dot1ad", "tags", "outer id",
4022 "inner id", "exact", "default", "outer any", "inner any");
4024 vec_foreach (sub, vam->sw_if_subif_table)
4027 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
4028 sub->interface_name,
4030 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4031 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4032 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4033 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4034 if (sub->vtr_op != L2_VTR_DISABLED)
4037 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4038 "tag1: %d tag2: %d ]\n",
4039 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4040 sub->vtr_tag1, sub->vtr_tag2);
4048 name_sort_cmp (void *a1, void *a2)
4050 name_sort_t *n1 = a1;
4051 name_sort_t *n2 = a2;
4053 return strcmp ((char *) n1->name, (char *) n2->name);
4057 dump_interface_table (vat_main_t * vam)
4060 name_sort_t *nses = 0, *ns;
4062 if (vam->json_output)
4065 ("JSON output supported only for VPE API calls and dump_stats_table");
4070 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4072 vec_add2 (nses, ns, 1);
4073 ns->name = (u8 *)(p->key);
4074 ns->value = (u32) p->value[0];
4078 vec_sort_with_function (nses, name_sort_cmp);
4080 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
4081 vec_foreach (ns, nses)
4083 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
4090 dump_ip_table (vat_main_t * vam, int is_ipv6)
4092 const ip_details_t *det = NULL;
4093 const ip_address_details_t *address = NULL;
4096 fformat (vam->ofp, "%-12s\n", "sw_if_index");
4098 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4105 fformat (vam->ofp, "%-12d\n", i);
4107 " %-30s%-13s\n", "Address", "Prefix length");
4112 vec_foreach (address, det->addr)
4116 is_ipv6 ? format_ip6_address : format_ip4_address,
4117 address->ip, address->prefix_length);
4125 dump_ipv4_table (vat_main_t * vam)
4127 if (vam->json_output)
4130 ("JSON output supported only for VPE API calls and dump_stats_table");
4134 return dump_ip_table (vam, 0);
4138 dump_ipv6_table (vat_main_t * vam)
4140 if (vam->json_output)
4143 ("JSON output supported only for VPE API calls and dump_stats_table");
4147 return dump_ip_table (vam, 1);
4151 counter_type_to_str (u8 counter_type, u8 is_combined)
4155 switch (counter_type)
4157 case VNET_INTERFACE_COUNTER_DROP:
4159 case VNET_INTERFACE_COUNTER_PUNT:
4161 case VNET_INTERFACE_COUNTER_IP4:
4163 case VNET_INTERFACE_COUNTER_IP6:
4165 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4167 case VNET_INTERFACE_COUNTER_RX_MISS:
4169 case VNET_INTERFACE_COUNTER_RX_ERROR:
4171 case VNET_INTERFACE_COUNTER_TX_ERROR:
4174 return "INVALID-COUNTER-TYPE";
4179 switch (counter_type)
4181 case VNET_INTERFACE_COUNTER_RX:
4183 case VNET_INTERFACE_COUNTER_TX:
4186 return "INVALID-COUNTER-TYPE";
4192 dump_stats_table (vat_main_t * vam)
4194 vat_json_node_t node;
4195 vat_json_node_t *msg_array;
4196 vat_json_node_t *msg;
4197 vat_json_node_t *counter_array;
4198 vat_json_node_t *counter;
4199 interface_counter_t c;
4201 ip4_fib_counter_t *c4;
4202 ip6_fib_counter_t *c6;
4205 if (!vam->json_output)
4207 clib_warning ("dump_stats_table supported only in JSON format");
4211 vat_json_init_object (&node);
4213 /* interface counters */
4214 msg_array = vat_json_object_add (&node, "interface_counters");
4215 vat_json_init_array (msg_array);
4216 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4218 msg = vat_json_array_add (msg_array);
4219 vat_json_init_object (msg);
4220 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4221 (u8 *) counter_type_to_str (i, 0));
4222 vat_json_object_add_int (msg, "is_combined", 0);
4223 counter_array = vat_json_object_add (msg, "data");
4224 vat_json_init_array (counter_array);
4225 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4227 packets = vam->simple_interface_counters[i][j];
4228 vat_json_array_add_uint (counter_array, packets);
4231 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4233 msg = vat_json_array_add (msg_array);
4234 vat_json_init_object (msg);
4235 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4236 (u8 *) counter_type_to_str (i, 1));
4237 vat_json_object_add_int (msg, "is_combined", 1);
4238 counter_array = vat_json_object_add (msg, "data");
4239 vat_json_init_array (counter_array);
4240 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4242 c = vam->combined_interface_counters[i][j];
4243 counter = vat_json_array_add (counter_array);
4244 vat_json_init_object (counter);
4245 vat_json_object_add_uint (counter, "packets", c.packets);
4246 vat_json_object_add_uint (counter, "bytes", c.bytes);
4250 /* ip4 fib counters */
4251 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4252 vat_json_init_array (msg_array);
4253 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4255 msg = vat_json_array_add (msg_array);
4256 vat_json_init_object (msg);
4257 vat_json_object_add_uint (msg, "vrf_id",
4258 vam->ip4_fib_counters_vrf_id_by_index[i]);
4259 counter_array = vat_json_object_add (msg, "c");
4260 vat_json_init_array (counter_array);
4261 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4263 counter = vat_json_array_add (counter_array);
4264 vat_json_init_object (counter);
4265 c4 = &vam->ip4_fib_counters[i][j];
4266 vat_json_object_add_ip4 (counter, "address", c4->address);
4267 vat_json_object_add_uint (counter, "address_length",
4268 c4->address_length);
4269 vat_json_object_add_uint (counter, "packets", c4->packets);
4270 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4274 /* ip6 fib counters */
4275 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4276 vat_json_init_array (msg_array);
4277 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4279 msg = vat_json_array_add (msg_array);
4280 vat_json_init_object (msg);
4281 vat_json_object_add_uint (msg, "vrf_id",
4282 vam->ip6_fib_counters_vrf_id_by_index[i]);
4283 counter_array = vat_json_object_add (msg, "c");
4284 vat_json_init_array (counter_array);
4285 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4287 counter = vat_json_array_add (counter_array);
4288 vat_json_init_object (counter);
4289 c6 = &vam->ip6_fib_counters[i][j];
4290 vat_json_object_add_ip6 (counter, "address", c6->address);
4291 vat_json_object_add_uint (counter, "address_length",
4292 c6->address_length);
4293 vat_json_object_add_uint (counter, "packets", c6->packets);
4294 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4298 vat_json_print (vam->ofp, &node);
4299 vat_json_free (&node);
4305 exec (vat_main_t * vam)
4307 api_main_t *am = &api_main;
4308 vl_api_cli_request_t *mp;
4312 unformat_input_t *i = vam->input;
4314 if (vec_len (i->buffer) == 0)
4317 if (vam->exec_mode == 0 && unformat (i, "mode"))
4322 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4329 M (CLI_REQUEST, cli_request);
4332 * Copy cmd into shared memory.
4333 * In order for the CLI command to work, it
4334 * must be a vector ending in \n, not a C-string ending
4337 pthread_mutex_lock (&am->vlib_rp->mutex);
4338 oldheap = svm_push_data_heap (am->vlib_rp);
4340 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4341 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4343 svm_pop_heap (oldheap);
4344 pthread_mutex_unlock (&am->vlib_rp->mutex);
4346 mp->cmd_in_shmem = (u64) cmd;
4348 timeout = vat_time_now (vam) + 10.0;
4350 while (vat_time_now (vam) < timeout)
4352 if (vam->result_ready == 1)
4355 if (vam->shmem_result != NULL)
4356 fformat (vam->ofp, "%s", vam->shmem_result);
4357 pthread_mutex_lock (&am->vlib_rp->mutex);
4358 oldheap = svm_push_data_heap (am->vlib_rp);
4360 free_me = (u8 *) vam->shmem_result;
4363 svm_pop_heap (oldheap);
4364 pthread_mutex_unlock (&am->vlib_rp->mutex);
4372 * Future replacement of exec() that passes CLI buffers directly in
4373 * the API messages instead of an additional shared memory area.
4376 exec_inband (vat_main_t * vam)
4378 vl_api_cli_inband_t *mp;
4380 unformat_input_t *i = vam->input;
4382 if (vec_len (i->buffer) == 0)
4385 if (vam->exec_mode == 0 && unformat (i, "mode"))
4390 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4397 * In order for the CLI command to work, it
4398 * must be a vector ending in \n, not a C-string ending
4401 u32 len = vec_len (vam->input->buffer);
4402 M2 (CLI_INBAND, cli_inband, len);
4403 clib_memcpy (mp->cmd, vam->input->buffer, len);
4404 mp->length = htonl (len);
4407 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4411 api_create_loopback (vat_main_t * vam)
4413 unformat_input_t *i = vam->input;
4414 vl_api_create_loopback_t *mp;
4419 memset (mac_address, 0, sizeof (mac_address));
4421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4423 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4429 /* Construct the API message */
4430 M (CREATE_LOOPBACK, create_loopback);
4432 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4439 api_delete_loopback (vat_main_t * vam)
4441 unformat_input_t *i = vam->input;
4442 vl_api_delete_loopback_t *mp;
4444 u32 sw_if_index = ~0;
4446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4448 if (unformat (i, "sw_if_index %d", &sw_if_index))
4454 if (sw_if_index == ~0)
4456 errmsg ("missing sw_if_index\n");
4460 /* Construct the API message */
4461 M (DELETE_LOOPBACK, delete_loopback);
4462 mp->sw_if_index = ntohl (sw_if_index);
4469 api_want_stats (vat_main_t * vam)
4471 unformat_input_t *i = vam->input;
4472 vl_api_want_stats_t *mp;
4476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4478 if (unformat (i, "enable"))
4480 else if (unformat (i, "disable"))
4488 errmsg ("missing enable|disable\n");
4492 M (WANT_STATS, want_stats);
4493 mp->enable_disable = enable;
4500 api_want_interface_events (vat_main_t * vam)
4502 unformat_input_t *i = vam->input;
4503 vl_api_want_interface_events_t *mp;
4507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4509 if (unformat (i, "enable"))
4511 else if (unformat (i, "disable"))
4519 errmsg ("missing enable|disable\n");
4523 M (WANT_INTERFACE_EVENTS, want_interface_events);
4524 mp->enable_disable = enable;
4526 vam->interface_event_display = enable;
4533 /* Note: non-static, called once to set up the initial intfc table */
4535 api_sw_interface_dump (vat_main_t * vam)
4537 vl_api_sw_interface_dump_t *mp;
4540 name_sort_t *nses = 0, *ns;
4541 sw_interface_subif_t *sub = NULL;
4543 /* Toss the old name table */
4545 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4547 vec_add2 (nses, ns, 1);
4548 ns->name = (u8 *)(p->key);
4549 ns->value = (u32) p->value[0];
4553 hash_free (vam->sw_if_index_by_interface_name);
4555 vec_foreach (ns, nses) vec_free (ns->name);
4559 vec_foreach (sub, vam->sw_if_subif_table)
4561 vec_free (sub->interface_name);
4563 vec_free (vam->sw_if_subif_table);
4565 /* recreate the interface name hash table */
4566 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4568 /* Get list of ethernets */
4569 M (SW_INTERFACE_DUMP, sw_interface_dump);
4570 mp->name_filter_valid = 1;
4571 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4574 /* and local / loopback interfaces */
4575 M (SW_INTERFACE_DUMP, sw_interface_dump);
4576 mp->name_filter_valid = 1;
4577 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4580 /* and packet-generator interfaces */
4581 M (SW_INTERFACE_DUMP, sw_interface_dump);
4582 mp->name_filter_valid = 1;
4583 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4586 /* and vxlan-gpe tunnel interfaces */
4587 M (SW_INTERFACE_DUMP, sw_interface_dump);
4588 mp->name_filter_valid = 1;
4589 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4590 sizeof (mp->name_filter) - 1);
4593 /* and vxlan tunnel interfaces */
4594 M (SW_INTERFACE_DUMP, sw_interface_dump);
4595 mp->name_filter_valid = 1;
4596 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4599 /* and host (af_packet) interfaces */
4600 M (SW_INTERFACE_DUMP, sw_interface_dump);
4601 mp->name_filter_valid = 1;
4602 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4605 /* and l2tpv3 tunnel interfaces */
4606 M (SW_INTERFACE_DUMP, sw_interface_dump);
4607 mp->name_filter_valid = 1;
4608 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4609 sizeof (mp->name_filter) - 1);
4612 /* and GRE tunnel interfaces */
4613 M (SW_INTERFACE_DUMP, sw_interface_dump);
4614 mp->name_filter_valid = 1;
4615 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4618 /* and LISP-GPE interfaces */
4619 M (SW_INTERFACE_DUMP, sw_interface_dump);
4620 mp->name_filter_valid = 1;
4621 strncpy ((char *) mp->name_filter, "lisp_gpe",
4622 sizeof (mp->name_filter) - 1);
4625 /* and IPSEC tunnel interfaces */
4626 M (SW_INTERFACE_DUMP, sw_interface_dump);
4627 mp->name_filter_valid = 1;
4628 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4631 /* Use a control ping for synchronization */
4633 vl_api_control_ping_t *mp;
4634 M (CONTROL_PING, control_ping);
4641 api_sw_interface_set_flags (vat_main_t * vam)
4643 unformat_input_t *i = vam->input;
4644 vl_api_sw_interface_set_flags_t *mp;
4647 u8 sw_if_index_set = 0;
4648 u8 admin_up = 0, link_up = 0;
4650 /* Parse args required to build the message */
4651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4653 if (unformat (i, "admin-up"))
4655 else if (unformat (i, "admin-down"))
4657 else if (unformat (i, "link-up"))
4659 else if (unformat (i, "link-down"))
4661 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4662 sw_if_index_set = 1;
4663 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4664 sw_if_index_set = 1;
4669 if (sw_if_index_set == 0)
4671 errmsg ("missing interface name or sw_if_index\n");
4675 /* Construct the API message */
4676 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4677 mp->sw_if_index = ntohl (sw_if_index);
4678 mp->admin_up_down = admin_up;
4679 mp->link_up_down = link_up;
4684 /* Wait for a reply, return the good/bad news... */
4689 api_sw_interface_clear_stats (vat_main_t * vam)
4691 unformat_input_t *i = vam->input;
4692 vl_api_sw_interface_clear_stats_t *mp;
4695 u8 sw_if_index_set = 0;
4697 /* Parse args required to build the message */
4698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4700 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4701 sw_if_index_set = 1;
4702 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4703 sw_if_index_set = 1;
4708 /* Construct the API message */
4709 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4711 if (sw_if_index_set == 1)
4712 mp->sw_if_index = ntohl (sw_if_index);
4714 mp->sw_if_index = ~0;
4719 /* Wait for a reply, return the good/bad news... */
4724 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4726 unformat_input_t *i = vam->input;
4727 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4730 u8 sw_if_index_set = 0;
4738 /* Parse args required to build the message */
4739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4741 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4742 sw_if_index_set = 1;
4743 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4744 sw_if_index_set = 1;
4745 else if (unformat (i, "subport %u", &subport))
4747 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4748 sw_if_index_set = 1;
4749 else if (unformat (i, "pipe %u", &pipe))
4751 else if (unformat (i, "profile %u", &profile))
4757 if (sw_if_index_set == 0)
4759 errmsg ("missing interface name or sw_if_index\n");
4763 if (subport_set == 0)
4765 errmsg ("missing subport \n");
4771 errmsg ("missing pipe\n");
4775 if (profile_set == 0)
4777 errmsg ("missing profile\n");
4781 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4783 mp->sw_if_index = ntohl (sw_if_index);
4784 mp->subport = ntohl (subport);
4785 mp->pipe = ntohl (pipe);
4786 mp->profile = ntohl (profile);
4796 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4798 unformat_input_t *i = vam->input;
4799 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4802 u8 sw_if_index_set = 0;
4805 u32 tb_rate = 1250000000; /* 10GbE */
4806 u32 tb_size = 1000000;
4807 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4810 /* Parse args required to build the message */
4811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4813 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4814 sw_if_index_set = 1;
4815 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4816 sw_if_index_set = 1;
4817 else if (unformat (i, "subport %u", &subport))
4819 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4820 sw_if_index_set = 1;
4821 else if (unformat (i, "rate %u", &tb_rate))
4825 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4827 tc_rate[tc_id] = tb_rate;
4829 else if (unformat (i, "bktsize %u", &tb_size))
4831 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4833 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4835 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4837 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4839 else if (unformat (i, "period %u", &tc_period))
4845 if (sw_if_index_set == 0)
4847 errmsg ("missing interface name or sw_if_index\n");
4851 if (subport_set == 0)
4853 errmsg ("missing subport \n");
4857 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4859 mp->sw_if_index = ntohl (sw_if_index);
4860 mp->subport = ntohl (subport);
4861 mp->tb_rate = ntohl (tb_rate);
4862 mp->tb_size = ntohl (tb_size);
4863 mp->tc_rate[0] = ntohl (tc_rate[0]);
4864 mp->tc_rate[1] = ntohl (tc_rate[1]);
4865 mp->tc_rate[2] = ntohl (tc_rate[2]);
4866 mp->tc_rate[3] = ntohl (tc_rate[3]);
4867 mp->tc_period = ntohl (tc_period);
4876 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4878 unformat_input_t *i = vam->input;
4879 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4882 u8 sw_if_index_set = 0;
4886 u32 entry, tc, queue;
4888 /* Parse args required to build the message */
4889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4891 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4892 sw_if_index_set = 1;
4893 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4894 sw_if_index_set = 1;
4895 else if (unformat (i, "entry %d", &entry))
4897 else if (unformat (i, "tc %d", &tc))
4899 else if (unformat (i, "queue %d", &queue))
4905 if (sw_if_index_set == 0)
4907 errmsg ("missing interface name or sw_if_index\n");
4913 errmsg ("missing entry \n");
4919 errmsg ("missing traffic class \n");
4925 errmsg ("missing queue \n");
4929 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4931 mp->sw_if_index = ntohl (sw_if_index);
4932 mp->entry = ntohl (entry);
4933 mp->tc = ntohl (tc);
4934 mp->queue = ntohl (queue);
4943 api_sw_interface_add_del_address (vat_main_t * vam)
4945 unformat_input_t *i = vam->input;
4946 vl_api_sw_interface_add_del_address_t *mp;
4949 u8 sw_if_index_set = 0;
4950 u8 is_add = 1, del_all = 0;
4951 u32 address_length = 0;
4952 u8 v4_address_set = 0;
4953 u8 v6_address_set = 0;
4954 ip4_address_t v4address;
4955 ip6_address_t v6address;
4957 /* Parse args required to build the message */
4958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4960 if (unformat (i, "del-all"))
4962 else if (unformat (i, "del"))
4964 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4965 sw_if_index_set = 1;
4966 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4967 sw_if_index_set = 1;
4968 else if (unformat (i, "%U/%d",
4969 unformat_ip4_address, &v4address, &address_length))
4971 else if (unformat (i, "%U/%d",
4972 unformat_ip6_address, &v6address, &address_length))
4978 if (sw_if_index_set == 0)
4980 errmsg ("missing interface name or sw_if_index\n");
4983 if (v4_address_set && v6_address_set)
4985 errmsg ("both v4 and v6 addresses set\n");
4988 if (!v4_address_set && !v6_address_set && !del_all)
4990 errmsg ("no addresses set\n");
4994 /* Construct the API message */
4995 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4997 mp->sw_if_index = ntohl (sw_if_index);
4998 mp->is_add = is_add;
4999 mp->del_all = del_all;
5003 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5007 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5009 mp->address_length = address_length;
5014 /* Wait for a reply, return good/bad news */
5019 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5021 unformat_input_t *i = vam->input;
5022 vl_api_sw_interface_set_mpls_enable_t *mp;
5025 u8 sw_if_index_set = 0;
5028 /* Parse args required to build the message */
5029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5031 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5032 sw_if_index_set = 1;
5033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5034 sw_if_index_set = 1;
5035 else if (unformat (i, "disable"))
5037 else if (unformat (i, "dis"))
5043 if (sw_if_index_set == 0)
5045 errmsg ("missing interface name or sw_if_index\n");
5049 /* Construct the API message */
5050 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5052 mp->sw_if_index = ntohl (sw_if_index);
5053 mp->enable = enable;
5058 /* Wait for a reply... */
5063 api_sw_interface_set_table (vat_main_t * vam)
5065 unformat_input_t *i = vam->input;
5066 vl_api_sw_interface_set_table_t *mp;
5068 u32 sw_if_index, vrf_id = 0;
5069 u8 sw_if_index_set = 0;
5072 /* Parse args required to build the message */
5073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5075 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5076 sw_if_index_set = 1;
5077 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5078 sw_if_index_set = 1;
5079 else if (unformat (i, "vrf %d", &vrf_id))
5081 else if (unformat (i, "ipv6"))
5087 if (sw_if_index_set == 0)
5089 errmsg ("missing interface name or sw_if_index\n");
5093 /* Construct the API message */
5094 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5096 mp->sw_if_index = ntohl (sw_if_index);
5097 mp->is_ipv6 = is_ipv6;
5098 mp->vrf_id = ntohl (vrf_id);
5103 /* Wait for a reply... */
5108 api_sw_interface_set_vpath (vat_main_t * vam)
5110 unformat_input_t *i = vam->input;
5111 vl_api_sw_interface_set_vpath_t *mp;
5113 u32 sw_if_index = 0;
5114 u8 sw_if_index_set = 0;
5117 /* Parse args required to build the message */
5118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5120 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5121 sw_if_index_set = 1;
5122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5123 sw_if_index_set = 1;
5124 else if (unformat (i, "enable"))
5126 else if (unformat (i, "disable"))
5132 if (sw_if_index_set == 0)
5134 errmsg ("missing interface name or sw_if_index\n");
5138 /* Construct the API message */
5139 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5141 mp->sw_if_index = ntohl (sw_if_index);
5142 mp->enable = is_enable;
5147 /* Wait for a reply... */
5152 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5154 unformat_input_t *i = vam->input;
5155 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5157 u32 sw_if_index = 0;
5158 u8 sw_if_index_set = 0;
5162 /* Parse args required to build the message */
5163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5165 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5166 sw_if_index_set = 1;
5167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5168 sw_if_index_set = 1;
5169 else if (unformat (i, "enable"))
5171 else if (unformat (i, "disable"))
5173 else if (unformat (i, "ip4"))
5175 else if (unformat (i, "ip6"))
5181 if (sw_if_index_set == 0)
5183 errmsg ("missing interface name or sw_if_index\n");
5187 /* Construct the API message */
5188 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5190 mp->sw_if_index = ntohl (sw_if_index);
5191 mp->enable = is_enable;
5192 mp->is_ipv6 = is_ipv6;
5197 /* Wait for a reply... */
5202 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5204 unformat_input_t *i = vam->input;
5205 vl_api_sw_interface_set_l2_xconnect_t *mp;
5208 u8 rx_sw_if_index_set = 0;
5210 u8 tx_sw_if_index_set = 0;
5213 /* Parse args required to build the message */
5214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5216 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5217 rx_sw_if_index_set = 1;
5218 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5219 tx_sw_if_index_set = 1;
5220 else if (unformat (i, "rx"))
5222 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5224 if (unformat (i, "%U", unformat_sw_if_index, vam,
5226 rx_sw_if_index_set = 1;
5231 else if (unformat (i, "tx"))
5233 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5235 if (unformat (i, "%U", unformat_sw_if_index, vam,
5237 tx_sw_if_index_set = 1;
5242 else if (unformat (i, "enable"))
5244 else if (unformat (i, "disable"))
5250 if (rx_sw_if_index_set == 0)
5252 errmsg ("missing rx interface name or rx_sw_if_index\n");
5256 if (enable && (tx_sw_if_index_set == 0))
5258 errmsg ("missing tx interface name or tx_sw_if_index\n");
5262 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5264 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5265 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5266 mp->enable = enable;
5275 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5277 unformat_input_t *i = vam->input;
5278 vl_api_sw_interface_set_l2_bridge_t *mp;
5281 u8 rx_sw_if_index_set = 0;
5288 /* Parse args required to build the message */
5289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5291 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5292 rx_sw_if_index_set = 1;
5293 else if (unformat (i, "bd_id %d", &bd_id))
5295 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5296 rx_sw_if_index_set = 1;
5297 else if (unformat (i, "shg %d", &shg))
5299 else if (unformat (i, "bvi"))
5301 else if (unformat (i, "enable"))
5303 else if (unformat (i, "disable"))
5309 if (rx_sw_if_index_set == 0)
5311 errmsg ("missing rx interface name or sw_if_index\n");
5315 if (enable && (bd_id_set == 0))
5317 errmsg ("missing bridge domain\n");
5321 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5323 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5324 mp->bd_id = ntohl (bd_id);
5327 mp->enable = enable;
5336 api_bridge_domain_dump (vat_main_t * vam)
5338 unformat_input_t *i = vam->input;
5339 vl_api_bridge_domain_dump_t *mp;
5343 /* Parse args required to build the message */
5344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5346 if (unformat (i, "bd_id %d", &bd_id))
5352 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5353 mp->bd_id = ntohl (bd_id);
5356 /* Use a control ping for synchronization */
5358 vl_api_control_ping_t *mp;
5359 M (CONTROL_PING, control_ping);
5369 api_bridge_domain_add_del (vat_main_t * vam)
5371 unformat_input_t *i = vam->input;
5372 vl_api_bridge_domain_add_del_t *mp;
5376 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5378 /* Parse args required to build the message */
5379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5381 if (unformat (i, "bd_id %d", &bd_id))
5383 else if (unformat (i, "flood %d", &flood))
5385 else if (unformat (i, "uu-flood %d", &uu_flood))
5387 else if (unformat (i, "forward %d", &forward))
5389 else if (unformat (i, "learn %d", &learn))
5391 else if (unformat (i, "arp-term %d", &arp_term))
5393 else if (unformat (i, "del"))
5396 flood = uu_flood = forward = learn = 0;
5404 errmsg ("missing bridge domain\n");
5408 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5410 mp->bd_id = ntohl (bd_id);
5412 mp->uu_flood = uu_flood;
5413 mp->forward = forward;
5415 mp->arp_term = arp_term;
5416 mp->is_add = is_add;
5425 api_l2fib_add_del (vat_main_t * vam)
5427 unformat_input_t *i = vam->input;
5428 vl_api_l2fib_add_del_t *mp;
5434 u32 sw_if_index = ~0;
5435 u8 sw_if_index_set = 0;
5444 /* Parse args required to build the message */
5445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5447 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5449 else if (unformat (i, "bd_id %d", &bd_id))
5451 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5452 sw_if_index_set = 1;
5453 else if (unformat (i, "sw_if"))
5455 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5457 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5458 sw_if_index_set = 1;
5463 else if (unformat (i, "static"))
5465 else if (unformat (i, "filter"))
5470 else if (unformat (i, "bvi"))
5475 else if (unformat (i, "del"))
5477 else if (unformat (i, "count %d", &count))
5485 errmsg ("missing mac address\n");
5491 errmsg ("missing bridge domain\n");
5495 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5497 errmsg ("missing interface name or sw_if_index\n");
5503 /* Turn on async mode */
5504 vam->async_mode = 1;
5505 vam->async_errors = 0;
5506 before = vat_time_now (vam);
5509 for (j = 0; j < count; j++)
5511 M (L2FIB_ADD_DEL, l2fib_add_del);
5514 mp->bd_id = ntohl (bd_id);
5515 mp->is_add = is_add;
5519 mp->sw_if_index = ntohl (sw_if_index);
5520 mp->static_mac = static_mac;
5521 mp->filter_mac = filter_mac;
5522 mp->bvi_mac = bvi_mac;
5524 increment_mac_address (&mac);
5531 vl_api_control_ping_t *mp;
5534 /* Shut off async mode */
5535 vam->async_mode = 0;
5537 M (CONTROL_PING, control_ping);
5540 timeout = vat_time_now (vam) + 1.0;
5541 while (vat_time_now (vam) < timeout)
5542 if (vam->result_ready == 1)
5547 if (vam->retval == -99)
5548 errmsg ("timeout\n");
5550 if (vam->async_errors > 0)
5552 errmsg ("%d asynchronous errors\n", vam->async_errors);
5555 vam->async_errors = 0;
5556 after = vat_time_now (vam);
5558 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5559 count, after - before, count / (after - before));
5563 /* Wait for a reply... */
5566 /* Return the good/bad news */
5567 return (vam->retval);
5571 api_l2_flags (vat_main_t * vam)
5573 unformat_input_t *i = vam->input;
5574 vl_api_l2_flags_t *mp;
5577 u32 feature_bitmap = 0;
5578 u8 sw_if_index_set = 0;
5580 /* Parse args required to build the message */
5581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5583 if (unformat (i, "sw_if_index %d", &sw_if_index))
5584 sw_if_index_set = 1;
5585 else if (unformat (i, "sw_if"))
5587 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5589 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5590 sw_if_index_set = 1;
5595 else if (unformat (i, "learn"))
5596 feature_bitmap |= L2INPUT_FEAT_LEARN;
5597 else if (unformat (i, "forward"))
5598 feature_bitmap |= L2INPUT_FEAT_FWD;
5599 else if (unformat (i, "flood"))
5600 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5601 else if (unformat (i, "uu-flood"))
5602 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5607 if (sw_if_index_set == 0)
5609 errmsg ("missing interface name or sw_if_index\n");
5613 M (L2_FLAGS, l2_flags);
5615 mp->sw_if_index = ntohl (sw_if_index);
5616 mp->feature_bitmap = ntohl (feature_bitmap);
5625 api_bridge_flags (vat_main_t * vam)
5627 unformat_input_t *i = vam->input;
5628 vl_api_bridge_flags_t *mp;
5635 /* Parse args required to build the message */
5636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5638 if (unformat (i, "bd_id %d", &bd_id))
5640 else if (unformat (i, "learn"))
5642 else if (unformat (i, "forward"))
5644 else if (unformat (i, "flood"))
5646 else if (unformat (i, "uu-flood"))
5647 flags |= L2_UU_FLOOD;
5648 else if (unformat (i, "arp-term"))
5649 flags |= L2_ARP_TERM;
5650 else if (unformat (i, "off"))
5652 else if (unformat (i, "disable"))
5660 errmsg ("missing bridge domain\n");
5664 M (BRIDGE_FLAGS, bridge_flags);
5666 mp->bd_id = ntohl (bd_id);
5667 mp->feature_bitmap = ntohl (flags);
5668 mp->is_set = is_set;
5677 api_bd_ip_mac_add_del (vat_main_t * vam)
5679 unformat_input_t *i = vam->input;
5680 vl_api_bd_ip_mac_add_del_t *mp;
5688 ip4_address_t v4addr;
5689 ip6_address_t v6addr;
5693 /* Parse args required to build the message */
5694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5696 if (unformat (i, "bd_id %d", &bd_id))
5700 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5704 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5709 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5713 else if (unformat (i, "del"))
5721 errmsg ("missing bridge domain\n");
5724 else if (ip_set == 0)
5726 errmsg ("missing IP address\n");
5729 else if (mac_set == 0)
5731 errmsg ("missing MAC address\n");
5735 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5737 mp->bd_id = ntohl (bd_id);
5738 mp->is_ipv6 = is_ipv6;
5739 mp->is_add = is_add;
5741 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5743 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5744 clib_memcpy (mp->mac_address, macaddr, 6);
5752 api_tap_connect (vat_main_t * vam)
5754 unformat_input_t *i = vam->input;
5755 vl_api_tap_connect_t *mp;
5763 memset (mac_address, 0, sizeof (mac_address));
5765 /* Parse args required to build the message */
5766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5768 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5772 else if (unformat (i, "random-mac"))
5774 else if (unformat (i, "tapname %s", &tap_name))
5776 else if (unformat (i, "tag %s", &tag))
5784 errmsg ("missing tap name\n");
5787 if (vec_len (tap_name) > 63)
5789 errmsg ("tap name too long\n");
5792 vec_add1 (tap_name, 0);
5794 if (vec_len (tag) > 63)
5796 errmsg ("tag too long\n");
5800 /* Construct the API message */
5801 M (TAP_CONNECT, tap_connect);
5803 mp->use_random_mac = random_mac;
5804 clib_memcpy (mp->mac_address, mac_address, 6);
5805 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5807 clib_memcpy (mp->tag, tag, vec_len (tag));
5809 vec_free (tap_name);
5815 /* Wait for a reply... */
5820 api_tap_modify (vat_main_t * vam)
5822 unformat_input_t *i = vam->input;
5823 vl_api_tap_modify_t *mp;
5829 u32 sw_if_index = ~0;
5830 u8 sw_if_index_set = 0;
5832 memset (mac_address, 0, sizeof (mac_address));
5834 /* Parse args required to build the message */
5835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5837 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5838 sw_if_index_set = 1;
5839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5840 sw_if_index_set = 1;
5841 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5845 else if (unformat (i, "random-mac"))
5847 else if (unformat (i, "tapname %s", &tap_name))
5853 if (sw_if_index_set == 0)
5855 errmsg ("missing vpp interface name");
5860 errmsg ("missing tap name\n");
5863 if (vec_len (tap_name) > 63)
5865 errmsg ("tap name too long\n");
5867 vec_add1 (tap_name, 0);
5869 /* Construct the API message */
5870 M (TAP_MODIFY, tap_modify);
5872 mp->use_random_mac = random_mac;
5873 mp->sw_if_index = ntohl (sw_if_index);
5874 clib_memcpy (mp->mac_address, mac_address, 6);
5875 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5876 vec_free (tap_name);
5881 /* Wait for a reply... */
5886 api_tap_delete (vat_main_t * vam)
5888 unformat_input_t *i = vam->input;
5889 vl_api_tap_delete_t *mp;
5891 u32 sw_if_index = ~0;
5892 u8 sw_if_index_set = 0;
5894 /* Parse args required to build the message */
5895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5897 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5898 sw_if_index_set = 1;
5899 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5900 sw_if_index_set = 1;
5905 if (sw_if_index_set == 0)
5907 errmsg ("missing vpp interface name");
5911 /* Construct the API message */
5912 M (TAP_DELETE, tap_delete);
5914 mp->sw_if_index = ntohl (sw_if_index);
5919 /* Wait for a reply... */
5924 api_ip_add_del_route (vat_main_t * vam)
5926 unformat_input_t *i = vam->input;
5927 vl_api_ip_add_del_route_t *mp;
5929 u32 sw_if_index = ~0, vrf_id = 0;
5931 u8 is_local = 0, is_drop = 0;
5932 u8 is_unreach = 0, is_prohibit = 0;
5933 u8 create_vrf_if_needed = 0;
5935 u32 next_hop_weight = 1;
5937 u8 is_multipath = 0;
5939 u8 address_length_set = 0;
5940 u32 next_hop_table_id = 0;
5941 u32 resolve_attempts = 0;
5942 u32 dst_address_length = 0;
5943 u8 next_hop_set = 0;
5944 ip4_address_t v4_dst_address, v4_next_hop_address;
5945 ip6_address_t v6_dst_address, v6_next_hop_address;
5949 u32 random_add_del = 0;
5950 u32 *random_vector = 0;
5952 u32 random_seed = 0xdeaddabe;
5953 u32 classify_table_index = ~0;
5955 u8 resolve_host = 0, resolve_attached = 0;
5956 mpls_label_t *next_hop_out_label_stack = NULL;
5957 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
5958 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
5960 /* Parse args required to build the message */
5961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5963 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5965 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5967 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5972 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5977 else if (unformat (i, "/%d", &dst_address_length))
5979 address_length_set = 1;
5982 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5983 &v4_next_hop_address))
5987 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5988 &v6_next_hop_address))
5992 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5994 else if (unformat (i, "weight %d", &next_hop_weight))
5996 else if (unformat (i, "drop"))
6000 else if (unformat (i, "null-send-unreach"))
6004 else if (unformat (i, "null-send-prohibit"))
6008 else if (unformat (i, "local"))
6012 else if (unformat (i, "classify %d", &classify_table_index))
6016 else if (unformat (i, "del"))
6018 else if (unformat (i, "add"))
6020 else if (unformat (i, "not-last"))
6022 else if (unformat (i, "resolve-via-host"))
6024 else if (unformat (i, "resolve-via-attached"))
6025 resolve_attached = 1;
6026 else if (unformat (i, "multipath"))
6028 else if (unformat (i, "vrf %d", &vrf_id))
6030 else if (unformat (i, "create-vrf"))
6031 create_vrf_if_needed = 1;
6032 else if (unformat (i, "count %d", &count))
6034 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6036 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6038 else if (unformat (i, "out-label %d", &next_hop_out_label))
6039 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6040 else if (unformat (i, "via-label %d", &next_hop_via_label))
6042 else if (unformat (i, "random"))
6044 else if (unformat (i, "seed %d", &random_seed))
6048 clib_warning ("parse error '%U'", format_unformat_error, i);
6053 if (!next_hop_set && !is_drop && !is_local &&
6054 !is_classify && !is_unreach && !is_prohibit &&
6055 MPLS_LABEL_INVALID == next_hop_via_label)
6058 ("next hop / local / drop / unreach / prohibit / classify not set\n");
6062 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6064 errmsg ("next hop and next-hop via label set\n");
6067 if (address_set == 0)
6069 errmsg ("missing addresses\n");
6073 if (address_length_set == 0)
6075 errmsg ("missing address length\n");
6079 /* Generate a pile of unique, random routes */
6082 u32 this_random_address;
6083 random_hash = hash_create (count, sizeof (uword));
6085 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6086 for (j = 0; j <= count; j++)
6090 this_random_address = random_u32 (&random_seed);
6091 this_random_address =
6092 clib_host_to_net_u32 (this_random_address);
6094 while (hash_get (random_hash, this_random_address));
6095 vec_add1 (random_vector, this_random_address);
6096 hash_set (random_hash, this_random_address, 1);
6098 hash_free (random_hash);
6099 v4_dst_address.as_u32 = random_vector[0];
6104 /* Turn on async mode */
6105 vam->async_mode = 1;
6106 vam->async_errors = 0;
6107 before = vat_time_now (vam);
6110 for (j = 0; j < count; j++)
6112 /* Construct the API message */
6113 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6114 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6116 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6117 mp->table_id = ntohl (vrf_id);
6118 mp->create_vrf_if_needed = create_vrf_if_needed;
6120 mp->is_add = is_add;
6121 mp->is_drop = is_drop;
6122 mp->is_unreach = is_unreach;
6123 mp->is_prohibit = is_prohibit;
6124 mp->is_ipv6 = is_ipv6;
6125 mp->is_local = is_local;
6126 mp->is_classify = is_classify;
6127 mp->is_multipath = is_multipath;
6128 mp->is_resolve_host = resolve_host;
6129 mp->is_resolve_attached = resolve_attached;
6130 mp->not_last = not_last;
6131 mp->next_hop_weight = next_hop_weight;
6132 mp->dst_address_length = dst_address_length;
6133 mp->next_hop_table_id = ntohl (next_hop_table_id);
6134 mp->classify_table_index = ntohl (classify_table_index);
6135 mp->next_hop_via_label = ntohl (next_hop_via_label);
6136 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6137 if (0 != mp->next_hop_n_out_labels)
6139 memcpy (mp->next_hop_out_label_stack,
6140 next_hop_out_label_stack,
6141 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6142 vec_free (next_hop_out_label_stack);
6147 clib_memcpy (mp->dst_address, &v6_dst_address,
6148 sizeof (v6_dst_address));
6150 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6151 sizeof (v6_next_hop_address));
6152 increment_v6_address (&v6_dst_address);
6156 clib_memcpy (mp->dst_address, &v4_dst_address,
6157 sizeof (v4_dst_address));
6159 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6160 sizeof (v4_next_hop_address));
6162 v4_dst_address.as_u32 = random_vector[j + 1];
6164 increment_v4_address (&v4_dst_address);
6168 /* If we receive SIGTERM, stop now... */
6173 /* When testing multiple add/del ops, use a control-ping to sync */
6176 vl_api_control_ping_t *mp;
6179 /* Shut off async mode */
6180 vam->async_mode = 0;
6182 M (CONTROL_PING, control_ping);
6185 timeout = vat_time_now (vam) + 1.0;
6186 while (vat_time_now (vam) < timeout)
6187 if (vam->result_ready == 1)
6192 if (vam->retval == -99)
6193 errmsg ("timeout\n");
6195 if (vam->async_errors > 0)
6197 errmsg ("%d asynchronous errors\n", vam->async_errors);
6200 vam->async_errors = 0;
6201 after = vat_time_now (vam);
6203 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6207 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6208 count, after - before, count / (after - before));
6212 /* Wait for a reply... */
6216 /* Return the good/bad news */
6217 return (vam->retval);
6221 api_mpls_route_add_del (vat_main_t * vam)
6223 unformat_input_t *i = vam->input;
6224 vl_api_mpls_route_add_del_t *mp;
6226 u32 sw_if_index = ~0, table_id = 0;
6227 u8 create_table_if_needed = 0;
6229 u32 next_hop_weight = 1;
6230 u8 is_multipath = 0;
6231 u32 next_hop_table_id = 0;
6232 u8 next_hop_set = 0;
6233 ip4_address_t v4_next_hop_address = {
6236 ip6_address_t v6_next_hop_address = { {0} };
6240 u32 classify_table_index = ~0;
6242 u8 resolve_host = 0, resolve_attached = 0;
6243 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6244 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6245 mpls_label_t *next_hop_out_label_stack = NULL;
6246 mpls_label_t local_label = MPLS_LABEL_INVALID;
6248 u8 next_hop_proto_is_ip4 = 1;
6250 /* Parse args required to build the message */
6251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6253 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6255 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6257 else if (unformat (i, "%d", &local_label))
6259 else if (unformat (i, "eos"))
6261 else if (unformat (i, "non-eos"))
6263 else if (unformat (i, "via %U", unformat_ip4_address,
6264 &v4_next_hop_address))
6267 next_hop_proto_is_ip4 = 1;
6269 else if (unformat (i, "via %U", unformat_ip6_address,
6270 &v6_next_hop_address))
6273 next_hop_proto_is_ip4 = 0;
6275 else if (unformat (i, "weight %d", &next_hop_weight))
6277 else if (unformat (i, "create-table"))
6278 create_table_if_needed = 1;
6279 else if (unformat (i, "classify %d", &classify_table_index))
6283 else if (unformat (i, "del"))
6285 else if (unformat (i, "add"))
6287 else if (unformat (i, "resolve-via-host"))
6289 else if (unformat (i, "resolve-via-attached"))
6290 resolve_attached = 1;
6291 else if (unformat (i, "multipath"))
6293 else if (unformat (i, "count %d", &count))
6295 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6298 next_hop_proto_is_ip4 = 1;
6300 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6303 next_hop_proto_is_ip4 = 0;
6305 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6307 else if (unformat (i, "via-label %d", &next_hop_via_label))
6309 else if (unformat (i, "out-label %d", &next_hop_out_label))
6310 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6313 clib_warning ("parse error '%U'", format_unformat_error, i);
6318 if (!next_hop_set && !is_classify)
6320 errmsg ("next hop / classify not set\n");
6324 if (MPLS_LABEL_INVALID == local_label)
6326 errmsg ("missing label\n");
6332 /* Turn on async mode */
6333 vam->async_mode = 1;
6334 vam->async_errors = 0;
6335 before = vat_time_now (vam);
6338 for (j = 0; j < count; j++)
6340 /* Construct the API message */
6341 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6342 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6344 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6345 mp->mr_table_id = ntohl (table_id);
6346 mp->mr_create_table_if_needed = create_table_if_needed;
6348 mp->mr_is_add = is_add;
6349 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6350 mp->mr_is_classify = is_classify;
6351 mp->mr_is_multipath = is_multipath;
6352 mp->mr_is_resolve_host = resolve_host;
6353 mp->mr_is_resolve_attached = resolve_attached;
6354 mp->mr_next_hop_weight = next_hop_weight;
6355 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6356 mp->mr_classify_table_index = ntohl (classify_table_index);
6357 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6358 mp->mr_label = ntohl (local_label);
6359 mp->mr_eos = is_eos;
6361 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6362 if (0 != mp->mr_next_hop_n_out_labels)
6364 memcpy (mp->mr_next_hop_out_label_stack,
6365 next_hop_out_label_stack,
6366 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6367 vec_free (next_hop_out_label_stack);
6372 if (next_hop_proto_is_ip4)
6374 clib_memcpy (mp->mr_next_hop,
6375 &v4_next_hop_address,
6376 sizeof (v4_next_hop_address));
6380 clib_memcpy (mp->mr_next_hop,
6381 &v6_next_hop_address,
6382 sizeof (v6_next_hop_address));
6389 /* If we receive SIGTERM, stop now... */
6394 /* When testing multiple add/del ops, use a control-ping to sync */
6397 vl_api_control_ping_t *mp;
6400 /* Shut off async mode */
6401 vam->async_mode = 0;
6403 M (CONTROL_PING, control_ping);
6406 timeout = vat_time_now (vam) + 1.0;
6407 while (vat_time_now (vam) < timeout)
6408 if (vam->result_ready == 1)
6413 if (vam->retval == -99)
6414 errmsg ("timeout\n");
6416 if (vam->async_errors > 0)
6418 errmsg ("%d asynchronous errors\n", vam->async_errors);
6421 vam->async_errors = 0;
6422 after = vat_time_now (vam);
6424 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6428 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6429 count, after - before, count / (after - before));
6433 /* Wait for a reply... */
6437 /* Return the good/bad news */
6438 return (vam->retval);
6442 api_mpls_ip_bind_unbind (vat_main_t * vam)
6444 unformat_input_t *i = vam->input;
6445 vl_api_mpls_ip_bind_unbind_t *mp;
6447 u32 ip_table_id = 0;
6448 u8 create_table_if_needed = 0;
6451 ip4_address_t v4_address;
6452 ip6_address_t v6_address;
6455 mpls_label_t local_label = MPLS_LABEL_INVALID;
6457 /* Parse args required to build the message */
6458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6460 if (unformat (i, "%U/%d", unformat_ip4_address,
6461 &v4_address, &address_length))
6466 else if (unformat (i, "%U/%d", unformat_ip6_address,
6467 &v6_address, &address_length))
6472 else if (unformat (i, "%d", &local_label))
6474 else if (unformat (i, "create-table"))
6475 create_table_if_needed = 1;
6476 else if (unformat (i, "table-id %d", &ip_table_id))
6478 else if (unformat (i, "unbind"))
6480 else if (unformat (i, "bind"))
6484 clib_warning ("parse error '%U'", format_unformat_error, i);
6491 errmsg ("IP addres not set\n");
6495 if (MPLS_LABEL_INVALID == local_label)
6497 errmsg ("missing label\n");
6501 /* Construct the API message */
6502 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6504 mp->mb_create_table_if_needed = create_table_if_needed;
6505 mp->mb_is_bind = is_bind;
6506 mp->mb_is_ip4 = is_ip4;
6507 mp->mb_ip_table_id = ntohl (ip_table_id);
6508 mp->mb_mpls_table_id = 0;
6509 mp->mb_label = ntohl (local_label);
6510 mp->mb_address_length = address_length;
6513 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6515 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6520 /* Wait for a reply... */
6525 api_proxy_arp_add_del (vat_main_t * vam)
6527 unformat_input_t *i = vam->input;
6528 vl_api_proxy_arp_add_del_t *mp;
6532 ip4_address_t lo, hi;
6535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6537 if (unformat (i, "vrf %d", &vrf_id))
6539 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6540 unformat_ip4_address, &hi))
6542 else if (unformat (i, "del"))
6546 clib_warning ("parse error '%U'", format_unformat_error, i);
6553 errmsg ("address range not set\n");
6557 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6559 mp->vrf_id = ntohl (vrf_id);
6560 mp->is_add = is_add;
6561 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6562 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6571 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6573 unformat_input_t *i = vam->input;
6574 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6578 u8 sw_if_index_set = 0;
6580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6582 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6583 sw_if_index_set = 1;
6584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6585 sw_if_index_set = 1;
6586 else if (unformat (i, "enable"))
6588 else if (unformat (i, "disable"))
6592 clib_warning ("parse error '%U'", format_unformat_error, i);
6597 if (sw_if_index_set == 0)
6599 errmsg ("missing interface name or sw_if_index\n");
6603 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6605 mp->sw_if_index = ntohl (sw_if_index);
6606 mp->enable_disable = enable;
6615 api_mpls_tunnel_add_del (vat_main_t * vam)
6617 unformat_input_t *i = vam->input;
6618 vl_api_mpls_tunnel_add_del_t *mp;
6623 u32 sw_if_index = ~0;
6624 u32 next_hop_sw_if_index = ~0;
6625 u32 next_hop_proto_is_ip4 = 1;
6627 u32 next_hop_table_id = 0;
6628 ip4_address_t v4_next_hop_address = {
6631 ip6_address_t v6_next_hop_address = { {0} };
6632 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6636 if (unformat (i, "add"))
6638 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6640 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6642 else if (unformat (i, "via %U",
6643 unformat_ip4_address, &v4_next_hop_address))
6645 next_hop_proto_is_ip4 = 1;
6647 else if (unformat (i, "via %U",
6648 unformat_ip6_address, &v6_next_hop_address))
6650 next_hop_proto_is_ip4 = 0;
6652 else if (unformat (i, "l2-only"))
6654 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6656 else if (unformat (i, "out-label %d", &next_hop_out_label))
6657 vec_add1 (labels, ntohl (next_hop_out_label));
6660 clib_warning ("parse error '%U'", format_unformat_error, i);
6665 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6666 sizeof (mpls_label_t) * vec_len (labels));
6668 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6669 mp->mt_sw_if_index = ntohl (sw_if_index);
6670 mp->mt_is_add = is_add;
6671 mp->mt_l2_only = l2_only;
6672 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6673 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6675 mp->mt_next_hop_n_out_labels = vec_len (labels);
6677 if (0 != mp->mt_next_hop_n_out_labels)
6679 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6680 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6684 if (next_hop_proto_is_ip4)
6686 clib_memcpy (mp->mt_next_hop,
6687 &v4_next_hop_address, sizeof (v4_next_hop_address));
6691 clib_memcpy (mp->mt_next_hop,
6692 &v6_next_hop_address, sizeof (v6_next_hop_address));
6702 api_sw_interface_set_unnumbered (vat_main_t * vam)
6704 unformat_input_t *i = vam->input;
6705 vl_api_sw_interface_set_unnumbered_t *mp;
6708 u32 unnum_sw_index = ~0;
6710 u8 sw_if_index_set = 0;
6712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6714 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6715 sw_if_index_set = 1;
6716 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6717 sw_if_index_set = 1;
6718 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6720 else if (unformat (i, "del"))
6724 clib_warning ("parse error '%U'", format_unformat_error, i);
6729 if (sw_if_index_set == 0)
6731 errmsg ("missing interface name or sw_if_index\n");
6735 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6737 mp->sw_if_index = ntohl (sw_if_index);
6738 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6739 mp->is_add = is_add;
6748 api_ip_neighbor_add_del (vat_main_t * vam)
6750 unformat_input_t *i = vam->input;
6751 vl_api_ip_neighbor_add_del_t *mp;
6754 u8 sw_if_index_set = 0;
6760 u8 v4_address_set = 0;
6761 u8 v6_address_set = 0;
6762 ip4_address_t v4address;
6763 ip6_address_t v6address;
6765 memset (mac_address, 0, sizeof (mac_address));
6767 /* Parse args required to build the message */
6768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6770 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6774 else if (unformat (i, "del"))
6776 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6777 sw_if_index_set = 1;
6778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6779 sw_if_index_set = 1;
6780 else if (unformat (i, "is_static"))
6782 else if (unformat (i, "vrf %d", &vrf_id))
6784 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6786 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6790 clib_warning ("parse error '%U'", format_unformat_error, i);
6795 if (sw_if_index_set == 0)
6797 errmsg ("missing interface name or sw_if_index\n");
6800 if (v4_address_set && v6_address_set)
6802 errmsg ("both v4 and v6 addresses set\n");
6805 if (!v4_address_set && !v6_address_set)
6807 errmsg ("no address set\n");
6811 /* Construct the API message */
6812 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6814 mp->sw_if_index = ntohl (sw_if_index);
6815 mp->is_add = is_add;
6816 mp->vrf_id = ntohl (vrf_id);
6817 mp->is_static = is_static;
6819 clib_memcpy (mp->mac_address, mac_address, 6);
6823 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6827 /* mp->is_ipv6 = 0; via memset in M macro above */
6828 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6834 /* Wait for a reply, return good/bad news */
6842 api_reset_vrf (vat_main_t * vam)
6844 unformat_input_t *i = vam->input;
6845 vl_api_reset_vrf_t *mp;
6851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6853 if (unformat (i, "vrf %d", &vrf_id))
6855 else if (unformat (i, "ipv6"))
6859 clib_warning ("parse error '%U'", format_unformat_error, i);
6864 if (vrf_id_set == 0)
6866 errmsg ("missing vrf id\n");
6870 M (RESET_VRF, reset_vrf);
6872 mp->vrf_id = ntohl (vrf_id);
6873 mp->is_ipv6 = is_ipv6;
6882 api_create_vlan_subif (vat_main_t * vam)
6884 unformat_input_t *i = vam->input;
6885 vl_api_create_vlan_subif_t *mp;
6888 u8 sw_if_index_set = 0;
6892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6894 if (unformat (i, "sw_if_index %d", &sw_if_index))
6895 sw_if_index_set = 1;
6896 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6897 sw_if_index_set = 1;
6898 else if (unformat (i, "vlan %d", &vlan_id))
6902 clib_warning ("parse error '%U'", format_unformat_error, i);
6907 if (sw_if_index_set == 0)
6909 errmsg ("missing interface name or sw_if_index\n");
6913 if (vlan_id_set == 0)
6915 errmsg ("missing vlan_id\n");
6918 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6920 mp->sw_if_index = ntohl (sw_if_index);
6921 mp->vlan_id = ntohl (vlan_id);
6929 #define foreach_create_subif_bit \
6936 _(outer_vlan_id_any) \
6937 _(inner_vlan_id_any)
6940 api_create_subif (vat_main_t * vam)
6942 unformat_input_t *i = vam->input;
6943 vl_api_create_subif_t *mp;
6946 u8 sw_if_index_set = 0;
6953 u32 exact_match = 0;
6954 u32 default_sub = 0;
6955 u32 outer_vlan_id_any = 0;
6956 u32 inner_vlan_id_any = 0;
6958 u16 outer_vlan_id = 0;
6959 u16 inner_vlan_id = 0;
6961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6963 if (unformat (i, "sw_if_index %d", &sw_if_index))
6964 sw_if_index_set = 1;
6965 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6966 sw_if_index_set = 1;
6967 else if (unformat (i, "sub_id %d", &sub_id))
6969 else if (unformat (i, "outer_vlan_id %d", &tmp))
6970 outer_vlan_id = tmp;
6971 else if (unformat (i, "inner_vlan_id %d", &tmp))
6972 inner_vlan_id = tmp;
6974 #define _(a) else if (unformat (i, #a)) a = 1 ;
6975 foreach_create_subif_bit
6979 clib_warning ("parse error '%U'", format_unformat_error, i);
6984 if (sw_if_index_set == 0)
6986 errmsg ("missing interface name or sw_if_index\n");
6990 if (sub_id_set == 0)
6992 errmsg ("missing sub_id\n");
6995 M (CREATE_SUBIF, create_subif);
6997 mp->sw_if_index = ntohl (sw_if_index);
6998 mp->sub_id = ntohl (sub_id);
7000 #define _(a) mp->a = a;
7001 foreach_create_subif_bit;
7004 mp->outer_vlan_id = ntohs (outer_vlan_id);
7005 mp->inner_vlan_id = ntohs (inner_vlan_id);
7014 api_oam_add_del (vat_main_t * vam)
7016 unformat_input_t *i = vam->input;
7017 vl_api_oam_add_del_t *mp;
7021 ip4_address_t src, dst;
7025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7027 if (unformat (i, "vrf %d", &vrf_id))
7029 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7031 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7033 else if (unformat (i, "del"))
7037 clib_warning ("parse error '%U'", format_unformat_error, i);
7044 errmsg ("missing src addr\n");
7050 errmsg ("missing dst addr\n");
7054 M (OAM_ADD_DEL, oam_add_del);
7056 mp->vrf_id = ntohl (vrf_id);
7057 mp->is_add = is_add;
7058 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7059 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7068 api_reset_fib (vat_main_t * vam)
7070 unformat_input_t *i = vam->input;
7071 vl_api_reset_fib_t *mp;
7077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7079 if (unformat (i, "vrf %d", &vrf_id))
7081 else if (unformat (i, "ipv6"))
7085 clib_warning ("parse error '%U'", format_unformat_error, i);
7090 if (vrf_id_set == 0)
7092 errmsg ("missing vrf id\n");
7096 M (RESET_FIB, reset_fib);
7098 mp->vrf_id = ntohl (vrf_id);
7099 mp->is_ipv6 = is_ipv6;
7108 api_dhcp_proxy_config (vat_main_t * vam)
7110 unformat_input_t *i = vam->input;
7111 vl_api_dhcp_proxy_config_t *mp;
7116 u8 v4_address_set = 0;
7117 u8 v6_address_set = 0;
7118 ip4_address_t v4address;
7119 ip6_address_t v6address;
7120 u8 v4_src_address_set = 0;
7121 u8 v6_src_address_set = 0;
7122 ip4_address_t v4srcaddress;
7123 ip6_address_t v6srcaddress;
7125 /* Parse args required to build the message */
7126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7128 if (unformat (i, "del"))
7130 else if (unformat (i, "vrf %d", &vrf_id))
7132 else if (unformat (i, "insert-cid %d", &insert_cid))
7134 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7136 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7138 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7139 v4_src_address_set = 1;
7140 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7141 v6_src_address_set = 1;
7146 if (v4_address_set && v6_address_set)
7148 errmsg ("both v4 and v6 server addresses set\n");
7151 if (!v4_address_set && !v6_address_set)
7153 errmsg ("no server addresses set\n");
7157 if (v4_src_address_set && v6_src_address_set)
7159 errmsg ("both v4 and v6 src addresses set\n");
7162 if (!v4_src_address_set && !v6_src_address_set)
7164 errmsg ("no src addresses set\n");
7168 if (!(v4_src_address_set && v4_address_set) &&
7169 !(v6_src_address_set && v6_address_set))
7171 errmsg ("no matching server and src addresses set\n");
7175 /* Construct the API message */
7176 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7178 mp->insert_circuit_id = insert_cid;
7179 mp->is_add = is_add;
7180 mp->vrf_id = ntohl (vrf_id);
7184 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7185 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7189 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7190 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7196 /* Wait for a reply, return good/bad news */
7203 api_dhcp_proxy_config_2 (vat_main_t * vam)
7205 unformat_input_t *i = vam->input;
7206 vl_api_dhcp_proxy_config_2_t *mp;
7209 u32 server_vrf_id = 0;
7212 u8 v4_address_set = 0;
7213 u8 v6_address_set = 0;
7214 ip4_address_t v4address;
7215 ip6_address_t v6address;
7216 u8 v4_src_address_set = 0;
7217 u8 v6_src_address_set = 0;
7218 ip4_address_t v4srcaddress;
7219 ip6_address_t v6srcaddress;
7221 /* Parse args required to build the message */
7222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7224 if (unformat (i, "del"))
7226 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7228 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7230 else if (unformat (i, "insert-cid %d", &insert_cid))
7232 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7234 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7236 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7237 v4_src_address_set = 1;
7238 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7239 v6_src_address_set = 1;
7244 if (v4_address_set && v6_address_set)
7246 errmsg ("both v4 and v6 server addresses set\n");
7249 if (!v4_address_set && !v6_address_set)
7251 errmsg ("no server addresses set\n");
7255 if (v4_src_address_set && v6_src_address_set)
7257 errmsg ("both v4 and v6 src addresses set\n");
7260 if (!v4_src_address_set && !v6_src_address_set)
7262 errmsg ("no src addresses set\n");
7266 if (!(v4_src_address_set && v4_address_set) &&
7267 !(v6_src_address_set && v6_address_set))
7269 errmsg ("no matching server and src addresses set\n");
7273 /* Construct the API message */
7274 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7276 mp->insert_circuit_id = insert_cid;
7277 mp->is_add = is_add;
7278 mp->rx_vrf_id = ntohl (rx_vrf_id);
7279 mp->server_vrf_id = ntohl (server_vrf_id);
7283 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7284 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7288 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7289 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7295 /* Wait for a reply, return good/bad news */
7302 api_dhcp_proxy_set_vss (vat_main_t * vam)
7304 unformat_input_t *i = vam->input;
7305 vl_api_dhcp_proxy_set_vss_t *mp;
7316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7318 if (unformat (i, "tbl_id %d", &tbl_id))
7320 if (unformat (i, "fib_id %d", &fib_id))
7322 if (unformat (i, "oui %d", &oui))
7324 else if (unformat (i, "ipv6"))
7326 else if (unformat (i, "del"))
7330 clib_warning ("parse error '%U'", format_unformat_error, i);
7335 if (tbl_id_set == 0)
7337 errmsg ("missing tbl id\n");
7341 if (fib_id_set == 0)
7343 errmsg ("missing fib id\n");
7348 errmsg ("missing oui\n");
7352 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7353 mp->tbl_id = ntohl (tbl_id);
7354 mp->fib_id = ntohl (fib_id);
7355 mp->oui = ntohl (oui);
7356 mp->is_ipv6 = is_ipv6;
7357 mp->is_add = is_add;
7366 api_dhcp_client_config (vat_main_t * vam)
7368 unformat_input_t *i = vam->input;
7369 vl_api_dhcp_client_config_t *mp;
7372 u8 sw_if_index_set = 0;
7375 u8 disable_event = 0;
7377 /* Parse args required to build the message */
7378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7380 if (unformat (i, "del"))
7382 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7383 sw_if_index_set = 1;
7384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7385 sw_if_index_set = 1;
7386 else if (unformat (i, "hostname %s", &hostname))
7388 else if (unformat (i, "disable_event"))
7394 if (sw_if_index_set == 0)
7396 errmsg ("missing interface name or sw_if_index\n");
7400 if (vec_len (hostname) > 63)
7402 errmsg ("hostname too long\n");
7404 vec_add1 (hostname, 0);
7406 /* Construct the API message */
7407 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7409 mp->sw_if_index = ntohl (sw_if_index);
7410 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7411 vec_free (hostname);
7412 mp->is_add = is_add;
7413 mp->want_dhcp_event = disable_event ? 0 : 1;
7414 mp->pid = getpid ();
7419 /* Wait for a reply, return good/bad news */
7426 api_set_ip_flow_hash (vat_main_t * vam)
7428 unformat_input_t *i = vam->input;
7429 vl_api_set_ip_flow_hash_t *mp;
7441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7443 if (unformat (i, "vrf %d", &vrf_id))
7445 else if (unformat (i, "ipv6"))
7447 else if (unformat (i, "src"))
7449 else if (unformat (i, "dst"))
7451 else if (unformat (i, "sport"))
7453 else if (unformat (i, "dport"))
7455 else if (unformat (i, "proto"))
7457 else if (unformat (i, "reverse"))
7462 clib_warning ("parse error '%U'", format_unformat_error, i);
7467 if (vrf_id_set == 0)
7469 errmsg ("missing vrf id\n");
7473 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7479 mp->reverse = reverse;
7480 mp->vrf_id = ntohl (vrf_id);
7481 mp->is_ipv6 = is_ipv6;
7490 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7492 unformat_input_t *i = vam->input;
7493 vl_api_sw_interface_ip6_enable_disable_t *mp;
7496 u8 sw_if_index_set = 0;
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, "enable"))
7507 else if (unformat (i, "disable"))
7511 clib_warning ("parse error '%U'", format_unformat_error, i);
7516 if (sw_if_index_set == 0)
7518 errmsg ("missing interface name or sw_if_index\n");
7522 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7524 mp->sw_if_index = ntohl (sw_if_index);
7525 mp->enable = enable;
7534 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7536 unformat_input_t *i = vam->input;
7537 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7540 u8 sw_if_index_set = 0;
7541 u32 address_length = 0;
7542 u8 v6_address_set = 0;
7543 ip6_address_t v6address;
7545 /* Parse args required to build the message */
7546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7548 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7549 sw_if_index_set = 1;
7550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7551 sw_if_index_set = 1;
7552 else if (unformat (i, "%U/%d",
7553 unformat_ip6_address, &v6address, &address_length))
7559 if (sw_if_index_set == 0)
7561 errmsg ("missing interface name or sw_if_index\n");
7564 if (!v6_address_set)
7566 errmsg ("no address set\n");
7570 /* Construct the API message */
7571 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7572 sw_interface_ip6_set_link_local_address);
7574 mp->sw_if_index = ntohl (sw_if_index);
7575 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7576 mp->address_length = address_length;
7581 /* Wait for a reply, return good/bad news */
7590 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7592 unformat_input_t *i = vam->input;
7593 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7596 u8 sw_if_index_set = 0;
7597 u32 address_length = 0;
7598 u8 v6_address_set = 0;
7599 ip6_address_t v6address;
7601 u8 no_advertise = 0;
7603 u8 no_autoconfig = 0;
7606 u32 val_lifetime = 0;
7607 u32 pref_lifetime = 0;
7609 /* Parse args required to build the message */
7610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7612 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7613 sw_if_index_set = 1;
7614 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7615 sw_if_index_set = 1;
7616 else if (unformat (i, "%U/%d",
7617 unformat_ip6_address, &v6address, &address_length))
7619 else if (unformat (i, "val_life %d", &val_lifetime))
7621 else if (unformat (i, "pref_life %d", &pref_lifetime))
7623 else if (unformat (i, "def"))
7625 else if (unformat (i, "noadv"))
7627 else if (unformat (i, "offl"))
7629 else if (unformat (i, "noauto"))
7631 else if (unformat (i, "nolink"))
7633 else if (unformat (i, "isno"))
7637 clib_warning ("parse error '%U'", format_unformat_error, i);
7642 if (sw_if_index_set == 0)
7644 errmsg ("missing interface name or sw_if_index\n");
7647 if (!v6_address_set)
7649 errmsg ("no address set\n");
7653 /* Construct the API message */
7654 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7656 mp->sw_if_index = ntohl (sw_if_index);
7657 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7658 mp->address_length = address_length;
7659 mp->use_default = use_default;
7660 mp->no_advertise = no_advertise;
7661 mp->off_link = off_link;
7662 mp->no_autoconfig = no_autoconfig;
7663 mp->no_onlink = no_onlink;
7665 mp->val_lifetime = ntohl (val_lifetime);
7666 mp->pref_lifetime = ntohl (pref_lifetime);
7671 /* Wait for a reply, return good/bad news */
7679 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7681 unformat_input_t *i = vam->input;
7682 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7685 u8 sw_if_index_set = 0;
7690 u8 send_unicast = 0;
7693 u8 default_router = 0;
7694 u32 max_interval = 0;
7695 u32 min_interval = 0;
7697 u32 initial_count = 0;
7698 u32 initial_interval = 0;
7701 /* Parse args required to build the message */
7702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7704 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7705 sw_if_index_set = 1;
7706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7707 sw_if_index_set = 1;
7708 else if (unformat (i, "maxint %d", &max_interval))
7710 else if (unformat (i, "minint %d", &min_interval))
7712 else if (unformat (i, "life %d", &lifetime))
7714 else if (unformat (i, "count %d", &initial_count))
7716 else if (unformat (i, "interval %d", &initial_interval))
7718 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7720 else if (unformat (i, "managed"))
7722 else if (unformat (i, "other"))
7724 else if (unformat (i, "ll"))
7726 else if (unformat (i, "send"))
7728 else if (unformat (i, "cease"))
7730 else if (unformat (i, "isno"))
7732 else if (unformat (i, "def"))
7736 clib_warning ("parse error '%U'", format_unformat_error, i);
7741 if (sw_if_index_set == 0)
7743 errmsg ("missing interface name or sw_if_index\n");
7747 /* Construct the API message */
7748 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7750 mp->sw_if_index = ntohl (sw_if_index);
7751 mp->max_interval = ntohl (max_interval);
7752 mp->min_interval = ntohl (min_interval);
7753 mp->lifetime = ntohl (lifetime);
7754 mp->initial_count = ntohl (initial_count);
7755 mp->initial_interval = ntohl (initial_interval);
7756 mp->suppress = suppress;
7757 mp->managed = managed;
7759 mp->ll_option = ll_option;
7760 mp->send_unicast = send_unicast;
7763 mp->default_router = default_router;
7768 /* Wait for a reply, return good/bad news */
7776 api_set_arp_neighbor_limit (vat_main_t * vam)
7778 unformat_input_t *i = vam->input;
7779 vl_api_set_arp_neighbor_limit_t *mp;
7785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7787 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7789 else if (unformat (i, "ipv6"))
7793 clib_warning ("parse error '%U'", format_unformat_error, i);
7800 errmsg ("missing limit value\n");
7804 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7806 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7807 mp->is_ipv6 = is_ipv6;
7816 api_l2_patch_add_del (vat_main_t * vam)
7818 unformat_input_t *i = vam->input;
7819 vl_api_l2_patch_add_del_t *mp;
7822 u8 rx_sw_if_index_set = 0;
7824 u8 tx_sw_if_index_set = 0;
7827 /* Parse args required to build the message */
7828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7830 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7831 rx_sw_if_index_set = 1;
7832 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7833 tx_sw_if_index_set = 1;
7834 else if (unformat (i, "rx"))
7836 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7838 if (unformat (i, "%U", unformat_sw_if_index, vam,
7840 rx_sw_if_index_set = 1;
7845 else if (unformat (i, "tx"))
7847 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7849 if (unformat (i, "%U", unformat_sw_if_index, vam,
7851 tx_sw_if_index_set = 1;
7856 else if (unformat (i, "del"))
7862 if (rx_sw_if_index_set == 0)
7864 errmsg ("missing rx interface name or rx_sw_if_index\n");
7868 if (tx_sw_if_index_set == 0)
7870 errmsg ("missing tx interface name or tx_sw_if_index\n");
7874 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7876 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7877 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7878 mp->is_add = is_add;
7887 api_ioam_enable (vat_main_t * vam)
7889 unformat_input_t *input = vam->input;
7890 vl_api_ioam_enable_t *mp;
7893 int has_trace_option = 0;
7894 int has_pot_option = 0;
7895 int has_seqno_option = 0;
7896 int has_analyse_option = 0;
7898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7900 if (unformat (input, "trace"))
7901 has_trace_option = 1;
7902 else if (unformat (input, "pot"))
7904 else if (unformat (input, "seqno"))
7905 has_seqno_option = 1;
7906 else if (unformat (input, "analyse"))
7907 has_analyse_option = 1;
7911 M (IOAM_ENABLE, ioam_enable);
7912 mp->id = htons (id);
7913 mp->seqno = has_seqno_option;
7914 mp->analyse = has_analyse_option;
7915 mp->pot_enable = has_pot_option;
7916 mp->trace_enable = has_trace_option;
7927 api_ioam_disable (vat_main_t * vam)
7929 vl_api_ioam_disable_t *mp;
7932 M (IOAM_DISABLE, ioam_disable);
7939 api_sr_tunnel_add_del (vat_main_t * vam)
7941 unformat_input_t *i = vam->input;
7942 vl_api_sr_tunnel_add_del_t *mp;
7946 ip6_address_t src_address;
7947 int src_address_set = 0;
7948 ip6_address_t dst_address;
7950 int dst_address_set = 0;
7952 u32 rx_table_id = 0;
7953 u32 tx_table_id = 0;
7954 ip6_address_t *segments = 0;
7955 ip6_address_t *this_seg;
7956 ip6_address_t *tags = 0;
7957 ip6_address_t *this_tag;
7958 ip6_address_t next_address, tag;
7960 u8 *policy_name = 0;
7962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7964 if (unformat (i, "del"))
7966 else if (unformat (i, "name %s", &name))
7968 else if (unformat (i, "policy %s", &policy_name))
7970 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7972 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7974 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7975 src_address_set = 1;
7976 else if (unformat (i, "dst %U/%d",
7977 unformat_ip6_address, &dst_address, &dst_mask_width))
7978 dst_address_set = 1;
7979 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7981 vec_add2 (segments, this_seg, 1);
7982 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7983 sizeof (*this_seg));
7985 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7987 vec_add2 (tags, this_tag, 1);
7988 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7990 else if (unformat (i, "clean"))
7991 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7992 else if (unformat (i, "protected"))
7993 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7994 else if (unformat (i, "InPE %d", &pl_index))
7996 if (pl_index <= 0 || pl_index > 4)
7998 pl_index_range_error:
7999 errmsg ("pl index %d out of range\n", pl_index);
8003 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8005 else if (unformat (i, "EgPE %d", &pl_index))
8007 if (pl_index <= 0 || pl_index > 4)
8008 goto pl_index_range_error;
8010 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8012 else if (unformat (i, "OrgSrc %d", &pl_index))
8014 if (pl_index <= 0 || pl_index > 4)
8015 goto pl_index_range_error;
8017 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8023 if (!src_address_set)
8025 errmsg ("src address required\n");
8029 if (!dst_address_set)
8031 errmsg ("dst address required\n");
8037 errmsg ("at least one sr segment required\n");
8041 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8042 vec_len (segments) * sizeof (ip6_address_t)
8043 + vec_len (tags) * sizeof (ip6_address_t));
8045 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8046 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8047 mp->dst_mask_width = dst_mask_width;
8048 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8049 mp->n_segments = vec_len (segments);
8050 mp->n_tags = vec_len (tags);
8051 mp->is_add = is_del == 0;
8052 clib_memcpy (mp->segs_and_tags, segments,
8053 vec_len (segments) * sizeof (ip6_address_t));
8054 clib_memcpy (mp->segs_and_tags +
8055 vec_len (segments) * sizeof (ip6_address_t), tags,
8056 vec_len (tags) * sizeof (ip6_address_t));
8058 mp->outer_vrf_id = ntohl (rx_table_id);
8059 mp->inner_vrf_id = ntohl (tx_table_id);
8060 memcpy (mp->name, name, vec_len (name));
8061 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8063 vec_free (segments);
8072 api_sr_policy_add_del (vat_main_t * vam)
8074 unformat_input_t *input = vam->input;
8075 vl_api_sr_policy_add_del_t *mp;
8079 u8 *tunnel_name = 0;
8080 u8 **tunnel_names = 0;
8085 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8086 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8090 if (unformat (input, "del"))
8092 else if (unformat (input, "name %s", &name))
8094 else if (unformat (input, "tunnel %s", &tunnel_name))
8098 vec_add1 (tunnel_names, tunnel_name);
8100 - length = #bytes to store in serial vector
8101 - +1 = byte to store that length
8103 tunnel_names_length += (vec_len (tunnel_name) + 1);
8114 errmsg ("policy name required\n");
8118 if ((!tunnel_set) && (!is_del))
8120 errmsg ("tunnel name required\n");
8124 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8128 mp->is_add = !is_del;
8130 memcpy (mp->name, name, vec_len (name));
8131 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8132 u8 *serial_orig = 0;
8133 vec_validate (serial_orig, tunnel_names_length);
8134 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8135 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8137 for (j = 0; j < vec_len (tunnel_names); j++)
8139 tun_name_len = vec_len (tunnel_names[j]);
8140 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8141 serial_orig += 1; // Move along one byte to store the actual tunnel name
8142 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8143 serial_orig += tun_name_len; // Advance past the copy
8145 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8147 vec_free (tunnel_names);
8148 vec_free (tunnel_name);
8156 api_sr_multicast_map_add_del (vat_main_t * vam)
8158 unformat_input_t *input = vam->input;
8159 vl_api_sr_multicast_map_add_del_t *mp;
8162 ip6_address_t multicast_address;
8163 u8 *policy_name = 0;
8164 int multicast_address_set = 0;
8166 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8168 if (unformat (input, "del"))
8172 (input, "address %U", unformat_ip6_address, &multicast_address))
8173 multicast_address_set = 1;
8174 else if (unformat (input, "sr-policy %s", &policy_name))
8180 if (!is_del && !policy_name)
8182 errmsg ("sr-policy name required\n");
8187 if (!multicast_address_set)
8189 errmsg ("address required\n");
8193 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8195 mp->is_add = !is_del;
8196 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8197 clib_memcpy (mp->multicast_address, &multicast_address,
8198 sizeof (mp->multicast_address));
8201 vec_free (policy_name);
8209 #define foreach_tcp_proto_field \
8213 #define foreach_udp_proto_field \
8217 #define foreach_ip4_proto_field \
8228 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8230 u8 **maskp = va_arg (*args, u8 **);
8232 u8 found_something = 0;
8235 #define _(a) u8 a=0;
8236 foreach_tcp_proto_field;
8239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8242 #define _(a) else if (unformat (input, #a)) a=1;
8243 foreach_tcp_proto_field
8249 #define _(a) found_something += a;
8250 foreach_tcp_proto_field;
8253 if (found_something == 0)
8256 vec_validate (mask, sizeof (*tcp) - 1);
8258 tcp = (tcp_header_t *) mask;
8260 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8261 foreach_tcp_proto_field;
8269 unformat_udp_mask (unformat_input_t * input, va_list * args)
8271 u8 **maskp = va_arg (*args, u8 **);
8273 u8 found_something = 0;
8276 #define _(a) u8 a=0;
8277 foreach_udp_proto_field;
8280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8283 #define _(a) else if (unformat (input, #a)) a=1;
8284 foreach_udp_proto_field
8290 #define _(a) found_something += a;
8291 foreach_udp_proto_field;
8294 if (found_something == 0)
8297 vec_validate (mask, sizeof (*udp) - 1);
8299 udp = (udp_header_t *) mask;
8301 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8302 foreach_udp_proto_field;
8311 u16 src_port, dst_port;
8315 unformat_l4_mask (unformat_input_t * input, va_list * args)
8317 u8 **maskp = va_arg (*args, u8 **);
8318 u16 src_port = 0, dst_port = 0;
8319 tcpudp_header_t *tcpudp;
8321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8323 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8325 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8327 else if (unformat (input, "src_port"))
8329 else if (unformat (input, "dst_port"))
8335 if (!src_port && !dst_port)
8339 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8341 tcpudp = (tcpudp_header_t *) mask;
8342 tcpudp->src_port = src_port;
8343 tcpudp->dst_port = dst_port;
8351 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8353 u8 **maskp = va_arg (*args, u8 **);
8355 u8 found_something = 0;
8358 #define _(a) u8 a=0;
8359 foreach_ip4_proto_field;
8365 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8367 if (unformat (input, "version"))
8369 else if (unformat (input, "hdr_length"))
8371 else if (unformat (input, "src"))
8373 else if (unformat (input, "dst"))
8375 else if (unformat (input, "proto"))
8378 #define _(a) else if (unformat (input, #a)) a=1;
8379 foreach_ip4_proto_field
8385 #define _(a) found_something += a;
8386 foreach_ip4_proto_field;
8389 if (found_something == 0)
8392 vec_validate (mask, sizeof (*ip) - 1);
8394 ip = (ip4_header_t *) mask;
8396 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8397 foreach_ip4_proto_field;
8400 ip->ip_version_and_header_length = 0;
8403 ip->ip_version_and_header_length |= 0xF0;
8406 ip->ip_version_and_header_length |= 0x0F;
8412 #define foreach_ip6_proto_field \
8420 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8422 u8 **maskp = va_arg (*args, u8 **);
8424 u8 found_something = 0;
8426 u32 ip_version_traffic_class_and_flow_label;
8428 #define _(a) u8 a=0;
8429 foreach_ip6_proto_field;
8432 u8 traffic_class = 0;
8435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8437 if (unformat (input, "version"))
8439 else if (unformat (input, "traffic-class"))
8441 else if (unformat (input, "flow-label"))
8443 else if (unformat (input, "src"))
8445 else if (unformat (input, "dst"))
8447 else if (unformat (input, "proto"))
8450 #define _(a) else if (unformat (input, #a)) a=1;
8451 foreach_ip6_proto_field
8457 #define _(a) found_something += a;
8458 foreach_ip6_proto_field;
8461 if (found_something == 0)
8464 vec_validate (mask, sizeof (*ip) - 1);
8466 ip = (ip6_header_t *) mask;
8468 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8469 foreach_ip6_proto_field;
8472 ip_version_traffic_class_and_flow_label = 0;
8475 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8478 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8481 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8483 ip->ip_version_traffic_class_and_flow_label =
8484 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8491 unformat_l3_mask (unformat_input_t * input, va_list * args)
8493 u8 **maskp = va_arg (*args, u8 **);
8495 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8497 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8499 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8508 unformat_l2_mask (unformat_input_t * input, va_list * args)
8510 u8 **maskp = va_arg (*args, u8 **);
8525 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8527 if (unformat (input, "src"))
8529 else if (unformat (input, "dst"))
8531 else if (unformat (input, "proto"))
8533 else if (unformat (input, "tag1"))
8535 else if (unformat (input, "tag2"))
8537 else if (unformat (input, "ignore-tag1"))
8539 else if (unformat (input, "ignore-tag2"))
8541 else if (unformat (input, "cos1"))
8543 else if (unformat (input, "cos2"))
8545 else if (unformat (input, "dot1q"))
8547 else if (unformat (input, "dot1ad"))
8552 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8553 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8556 if (tag1 || ignore_tag1 || cos1 || dot1q)
8558 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8561 vec_validate (mask, len - 1);
8564 memset (mask, 0xff, 6);
8567 memset (mask + 6, 0xff, 6);
8571 /* inner vlan tag */
8580 mask[21] = mask[20] = 0xff;
8601 mask[16] = mask[17] = 0xff;
8611 mask[12] = mask[13] = 0xff;
8618 unformat_classify_mask (unformat_input_t * input, va_list * args)
8620 u8 **maskp = va_arg (*args, u8 **);
8621 u32 *skipp = va_arg (*args, u32 *);
8622 u32 *matchp = va_arg (*args, u32 *);
8630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8632 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8634 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8636 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8638 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8652 if (mask || l2 || l3 || l4)
8656 /* "With a free Ethernet header in every package" */
8658 vec_validate (l2, 13);
8662 vec_append (mask, l3);
8667 vec_append (mask, l4);
8672 /* Scan forward looking for the first significant mask octet */
8673 for (i = 0; i < vec_len (mask); i++)
8677 /* compute (skip, match) params */
8678 *skipp = i / sizeof (u32x4);
8679 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8681 /* Pad mask to an even multiple of the vector size */
8682 while (vec_len (mask) % sizeof (u32x4))
8685 match = vec_len (mask) / sizeof (u32x4);
8687 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8689 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8690 if (*tmp || *(tmp + 1))
8695 clib_warning ("BUG: match 0");
8697 _vec_len (mask) = match * sizeof (u32x4);
8708 #define foreach_l2_next \
8710 _(ethernet, ETHERNET_INPUT) \
8715 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8717 u32 *miss_next_indexp = va_arg (*args, u32 *);
8722 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8726 if (unformat (input, "%d", &tmp))
8735 *miss_next_indexp = next_index;
8739 #define foreach_ip_next \
8745 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8747 u32 *miss_next_indexp = va_arg (*args, u32 *);
8752 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8756 if (unformat (input, "%d", &tmp))
8765 *miss_next_indexp = next_index;
8769 #define foreach_acl_next \
8773 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8775 u32 *miss_next_indexp = va_arg (*args, u32 *);
8780 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8784 if (unformat (input, "permit"))
8789 else if (unformat (input, "%d", &tmp))
8798 *miss_next_indexp = next_index;
8803 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8805 u32 *r = va_arg (*args, u32 *);
8807 if (unformat (input, "conform-color"))
8808 *r = POLICE_CONFORM;
8809 else if (unformat (input, "exceed-color"))
8818 api_classify_add_del_table (vat_main_t * vam)
8820 unformat_input_t *i = vam->input;
8821 vl_api_classify_add_del_table_t *mp;
8827 u32 table_index = ~0;
8828 u32 next_table_index = ~0;
8829 u32 miss_next_index = ~0;
8830 u32 memory_size = 32 << 20;
8833 u32 current_data_flag = 0;
8834 int current_data_offset = 0;
8836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8838 if (unformat (i, "del"))
8840 else if (unformat (i, "buckets %d", &nbuckets))
8842 else if (unformat (i, "memory_size %d", &memory_size))
8844 else if (unformat (i, "skip %d", &skip))
8846 else if (unformat (i, "match %d", &match))
8848 else if (unformat (i, "table %d", &table_index))
8850 else if (unformat (i, "mask %U", unformat_classify_mask,
8851 &mask, &skip, &match))
8853 else if (unformat (i, "next-table %d", &next_table_index))
8855 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8858 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8861 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8864 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8866 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8872 if (is_add && mask == 0)
8874 errmsg ("Mask required\n");
8878 if (is_add && skip == ~0)
8880 errmsg ("skip count required\n");
8884 if (is_add && match == ~0)
8886 errmsg ("match count required\n");
8890 if (!is_add && table_index == ~0)
8892 errmsg ("table index required for delete\n");
8896 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8898 mp->is_add = is_add;
8899 mp->table_index = ntohl (table_index);
8900 mp->nbuckets = ntohl (nbuckets);
8901 mp->memory_size = ntohl (memory_size);
8902 mp->skip_n_vectors = ntohl (skip);
8903 mp->match_n_vectors = ntohl (match);
8904 mp->next_table_index = ntohl (next_table_index);
8905 mp->miss_next_index = ntohl (miss_next_index);
8906 mp->current_data_flag = ntohl (current_data_flag);
8907 mp->current_data_offset = ntohl (current_data_offset);
8908 clib_memcpy (mp->mask, mask, vec_len (mask));
8918 unformat_l4_match (unformat_input_t * input, va_list * args)
8920 u8 **matchp = va_arg (*args, u8 **);
8922 u8 *proto_header = 0;
8928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8930 if (unformat (input, "src_port %d", &src_port))
8932 else if (unformat (input, "dst_port %d", &dst_port))
8938 h.src_port = clib_host_to_net_u16 (src_port);
8939 h.dst_port = clib_host_to_net_u16 (dst_port);
8940 vec_validate (proto_header, sizeof (h) - 1);
8941 memcpy (proto_header, &h, sizeof (h));
8943 *matchp = proto_header;
8949 unformat_ip4_match (unformat_input_t * input, va_list * args)
8951 u8 **matchp = va_arg (*args, u8 **);
8958 int src = 0, dst = 0;
8959 ip4_address_t src_val, dst_val;
8966 int fragment_id = 0;
8967 u32 fragment_id_val;
8973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8975 if (unformat (input, "version %d", &version_val))
8977 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8979 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8981 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8983 else if (unformat (input, "proto %d", &proto_val))
8985 else if (unformat (input, "tos %d", &tos_val))
8987 else if (unformat (input, "length %d", &length_val))
8989 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8991 else if (unformat (input, "ttl %d", &ttl_val))
8993 else if (unformat (input, "checksum %d", &checksum_val))
8999 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9000 + ttl + checksum == 0)
9004 * Aligned because we use the real comparison functions
9006 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9008 ip = (ip4_header_t *) match;
9010 /* These are realistically matched in practice */
9012 ip->src_address.as_u32 = src_val.as_u32;
9015 ip->dst_address.as_u32 = dst_val.as_u32;
9018 ip->protocol = proto_val;
9021 /* These are not, but they're included for completeness */
9023 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9026 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9032 ip->length = clib_host_to_net_u16 (length_val);
9038 ip->checksum = clib_host_to_net_u16 (checksum_val);
9045 unformat_ip6_match (unformat_input_t * input, va_list * args)
9047 u8 **matchp = va_arg (*args, u8 **);
9052 u8 traffic_class = 0;
9053 u32 traffic_class_val = 0;
9056 int src = 0, dst = 0;
9057 ip6_address_t src_val, dst_val;
9060 int payload_length = 0;
9061 u32 payload_length_val;
9064 u32 ip_version_traffic_class_and_flow_label;
9066 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9068 if (unformat (input, "version %d", &version_val))
9070 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9072 else if (unformat (input, "flow_label %d", &flow_label_val))
9074 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9076 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9078 else if (unformat (input, "proto %d", &proto_val))
9080 else if (unformat (input, "payload_length %d", &payload_length_val))
9082 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9088 if (version + traffic_class + flow_label + src + dst + proto +
9089 payload_length + hop_limit == 0)
9093 * Aligned because we use the real comparison functions
9095 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9097 ip = (ip6_header_t *) match;
9100 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9103 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9106 ip->protocol = proto_val;
9108 ip_version_traffic_class_and_flow_label = 0;
9111 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9114 ip_version_traffic_class_and_flow_label |=
9115 (traffic_class_val & 0xFF) << 20;
9118 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9120 ip->ip_version_traffic_class_and_flow_label =
9121 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9124 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9127 ip->hop_limit = hop_limit_val;
9134 unformat_l3_match (unformat_input_t * input, va_list * args)
9136 u8 **matchp = va_arg (*args, u8 **);
9138 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9140 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9142 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9151 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9153 u8 *tagp = va_arg (*args, u8 *);
9156 if (unformat (input, "%d", &tag))
9158 tagp[0] = (tag >> 8) & 0x0F;
9159 tagp[1] = tag & 0xFF;
9167 unformat_l2_match (unformat_input_t * input, va_list * args)
9169 u8 **matchp = va_arg (*args, u8 **);
9189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9191 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9194 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9196 else if (unformat (input, "proto %U",
9197 unformat_ethernet_type_host_byte_order, &proto_val))
9199 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9201 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9203 else if (unformat (input, "ignore-tag1"))
9205 else if (unformat (input, "ignore-tag2"))
9207 else if (unformat (input, "cos1 %d", &cos1_val))
9209 else if (unformat (input, "cos2 %d", &cos2_val))
9214 if ((src + dst + proto + tag1 + tag2 +
9215 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9218 if (tag1 || ignore_tag1 || cos1)
9220 if (tag2 || ignore_tag2 || cos2)
9223 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9226 clib_memcpy (match, dst_val, 6);
9229 clib_memcpy (match + 6, src_val, 6);
9233 /* inner vlan tag */
9234 match[19] = tag2_val[1];
9235 match[18] = tag2_val[0];
9237 match[18] |= (cos2_val & 0x7) << 5;
9240 match[21] = proto_val & 0xff;
9241 match[20] = proto_val >> 8;
9245 match[15] = tag1_val[1];
9246 match[14] = tag1_val[0];
9249 match[14] |= (cos1_val & 0x7) << 5;
9255 match[15] = tag1_val[1];
9256 match[14] = tag1_val[0];
9259 match[17] = proto_val & 0xff;
9260 match[16] = proto_val >> 8;
9263 match[14] |= (cos1_val & 0x7) << 5;
9269 match[18] |= (cos2_val & 0x7) << 5;
9271 match[14] |= (cos1_val & 0x7) << 5;
9274 match[13] = proto_val & 0xff;
9275 match[12] = proto_val >> 8;
9284 unformat_classify_match (unformat_input_t * input, va_list * args)
9286 u8 **matchp = va_arg (*args, u8 **);
9287 u32 skip_n_vectors = va_arg (*args, u32);
9288 u32 match_n_vectors = va_arg (*args, u32);
9295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9297 if (unformat (input, "hex %U", unformat_hex_string, &match))
9299 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9301 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9303 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9317 if (match || l2 || l3 || l4)
9321 /* "Win a free Ethernet header in every packet" */
9323 vec_validate_aligned (l2, 13, sizeof (u32x4));
9327 vec_append_aligned (match, l3, sizeof (u32x4));
9332 vec_append_aligned (match, l4, sizeof (u32x4));
9337 /* Make sure the vector is big enough even if key is all 0's */
9338 vec_validate_aligned
9339 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9342 /* Set size, include skipped vectors */
9343 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9354 api_classify_add_del_session (vat_main_t * vam)
9356 unformat_input_t *i = vam->input;
9357 vl_api_classify_add_del_session_t *mp;
9359 u32 table_index = ~0;
9360 u32 hit_next_index = ~0;
9361 u32 opaque_index = ~0;
9365 u32 skip_n_vectors = 0;
9366 u32 match_n_vectors = 0;
9371 * Warning: you have to supply skip_n and match_n
9372 * because the API client cant simply look at the classify
9376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9378 if (unformat (i, "del"))
9380 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9383 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9386 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9389 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9391 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9393 else if (unformat (i, "opaque-index %d", &opaque_index))
9395 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9397 else if (unformat (i, "match_n %d", &match_n_vectors))
9399 else if (unformat (i, "match %U", unformat_classify_match,
9400 &match, skip_n_vectors, match_n_vectors))
9402 else if (unformat (i, "advance %d", &advance))
9404 else if (unformat (i, "table-index %d", &table_index))
9406 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9408 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9410 else if (unformat (i, "action %d", &action))
9412 else if (unformat (i, "metadata %d", &metadata))
9418 if (table_index == ~0)
9420 errmsg ("Table index required\n");
9424 if (is_add && match == 0)
9426 errmsg ("Match value required\n");
9430 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9432 mp->is_add = is_add;
9433 mp->table_index = ntohl (table_index);
9434 mp->hit_next_index = ntohl (hit_next_index);
9435 mp->opaque_index = ntohl (opaque_index);
9436 mp->advance = ntohl (advance);
9437 mp->action = action;
9438 mp->metadata = ntohl (metadata);
9439 clib_memcpy (mp->match, match, vec_len (match));
9448 api_classify_set_interface_ip_table (vat_main_t * vam)
9450 unformat_input_t *i = vam->input;
9451 vl_api_classify_set_interface_ip_table_t *mp;
9454 int sw_if_index_set;
9455 u32 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, "table %d", &table_index))
9468 clib_warning ("parse error '%U'", format_unformat_error, i);
9473 if (sw_if_index_set == 0)
9475 errmsg ("missing interface name or sw_if_index\n");
9480 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9482 mp->sw_if_index = ntohl (sw_if_index);
9483 mp->table_index = ntohl (table_index);
9484 mp->is_ipv6 = is_ipv6;
9493 api_classify_set_interface_l2_tables (vat_main_t * vam)
9495 unformat_input_t *i = vam->input;
9496 vl_api_classify_set_interface_l2_tables_t *mp;
9499 int sw_if_index_set;
9500 u32 ip4_table_index = ~0;
9501 u32 ip6_table_index = ~0;
9502 u32 other_table_index = ~0;
9505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9507 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9508 sw_if_index_set = 1;
9509 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9510 sw_if_index_set = 1;
9511 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9513 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9515 else if (unformat (i, "other-table %d", &other_table_index))
9517 else if (unformat (i, "is-input %d", &is_input))
9521 clib_warning ("parse error '%U'", format_unformat_error, i);
9526 if (sw_if_index_set == 0)
9528 errmsg ("missing interface name or sw_if_index\n");
9533 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9535 mp->sw_if_index = ntohl (sw_if_index);
9536 mp->ip4_table_index = ntohl (ip4_table_index);
9537 mp->ip6_table_index = ntohl (ip6_table_index);
9538 mp->other_table_index = ntohl (other_table_index);
9539 mp->is_input = (u8) is_input;
9548 api_set_ipfix_exporter (vat_main_t * vam)
9550 unformat_input_t *i = vam->input;
9551 vl_api_set_ipfix_exporter_t *mp;
9552 ip4_address_t collector_address;
9553 u8 collector_address_set = 0;
9554 u32 collector_port = ~0;
9555 ip4_address_t src_address;
9556 u8 src_address_set = 0;
9559 u32 template_interval = ~0;
9560 u8 udp_checksum = 0;
9563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9565 if (unformat (i, "collector_address %U", unformat_ip4_address,
9566 &collector_address))
9567 collector_address_set = 1;
9568 else if (unformat (i, "collector_port %d", &collector_port))
9570 else if (unformat (i, "src_address %U", unformat_ip4_address,
9572 src_address_set = 1;
9573 else if (unformat (i, "vrf_id %d", &vrf_id))
9575 else if (unformat (i, "path_mtu %d", &path_mtu))
9577 else if (unformat (i, "template_interval %d", &template_interval))
9579 else if (unformat (i, "udp_checksum"))
9585 if (collector_address_set == 0)
9587 errmsg ("collector_address required\n");
9591 if (src_address_set == 0)
9593 errmsg ("src_address required\n");
9597 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9599 memcpy (mp->collector_address, collector_address.data,
9600 sizeof (collector_address.data));
9601 mp->collector_port = htons ((u16) collector_port);
9602 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9603 mp->vrf_id = htonl (vrf_id);
9604 mp->path_mtu = htonl (path_mtu);
9605 mp->template_interval = htonl (template_interval);
9606 mp->udp_checksum = udp_checksum;
9614 api_set_ipfix_classify_stream (vat_main_t * vam)
9616 unformat_input_t *i = vam->input;
9617 vl_api_set_ipfix_classify_stream_t *mp;
9619 u32 src_port = UDP_DST_PORT_ipfix;
9622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9624 if (unformat (i, "domain %d", &domain_id))
9626 else if (unformat (i, "src_port %d", &src_port))
9630 errmsg ("unknown input `%U'", format_unformat_error, i);
9635 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9637 mp->domain_id = htonl (domain_id);
9638 mp->src_port = htons ((u16) src_port);
9646 api_ipfix_classify_table_add_del (vat_main_t * vam)
9648 unformat_input_t *i = vam->input;
9649 vl_api_ipfix_classify_table_add_del_t *mp;
9651 u32 classify_table_index = ~0;
9653 u8 transport_protocol = 255;
9656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9658 if (unformat (i, "add"))
9660 else if (unformat (i, "del"))
9662 else if (unformat (i, "table %d", &classify_table_index))
9664 else if (unformat (i, "ip4"))
9666 else if (unformat (i, "ip6"))
9668 else if (unformat (i, "tcp"))
9669 transport_protocol = 6;
9670 else if (unformat (i, "udp"))
9671 transport_protocol = 17;
9674 errmsg ("unknown input `%U'", format_unformat_error, i);
9681 errmsg ("expecting: add|del");
9684 if (classify_table_index == ~0)
9686 errmsg ("classifier table not specified");
9689 if (ip_version == 0)
9691 errmsg ("IP version not specified");
9695 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9697 mp->is_add = is_add;
9698 mp->table_id = htonl (classify_table_index);
9699 mp->ip_version = ip_version;
9700 mp->transport_protocol = transport_protocol;
9708 api_get_node_index (vat_main_t * vam)
9710 unformat_input_t *i = vam->input;
9711 vl_api_get_node_index_t *mp;
9715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9717 if (unformat (i, "node %s", &name))
9724 errmsg ("node name required\n");
9727 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9729 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9733 M (GET_NODE_INDEX, get_node_index);
9734 clib_memcpy (mp->node_name, name, vec_len (name));
9744 api_get_next_index (vat_main_t * vam)
9746 unformat_input_t *i = vam->input;
9747 vl_api_get_next_index_t *mp;
9749 u8 *node_name = 0, *next_node_name = 0;
9751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9753 if (unformat (i, "node-name %s", &node_name))
9755 else if (unformat (i, "next-node-name %s", &next_node_name))
9761 errmsg ("node name required\n");
9764 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9766 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9770 if (next_node_name == 0)
9772 errmsg ("next node name required\n");
9775 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9777 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9781 M (GET_NEXT_INDEX, get_next_index);
9782 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9783 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9784 vec_free (node_name);
9785 vec_free (next_node_name);
9794 api_add_node_next (vat_main_t * vam)
9796 unformat_input_t *i = vam->input;
9797 vl_api_add_node_next_t *mp;
9802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9804 if (unformat (i, "node %s", &name))
9806 else if (unformat (i, "next %s", &next))
9813 errmsg ("node name required\n");
9816 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9818 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9823 errmsg ("next node required\n");
9826 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9828 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9832 M (ADD_NODE_NEXT, add_node_next);
9833 clib_memcpy (mp->node_name, name, vec_len (name));
9834 clib_memcpy (mp->next_name, next, vec_len (next));
9845 api_l2tpv3_create_tunnel (vat_main_t * vam)
9847 unformat_input_t *i = vam->input;
9848 ip6_address_t client_address, our_address;
9849 int client_address_set = 0;
9850 int our_address_set = 0;
9851 u32 local_session_id = 0;
9852 u32 remote_session_id = 0;
9853 u64 local_cookie = 0;
9854 u64 remote_cookie = 0;
9855 u8 l2_sublayer_present = 0;
9856 vl_api_l2tpv3_create_tunnel_t *mp;
9859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9861 if (unformat (i, "client_address %U", unformat_ip6_address,
9863 client_address_set = 1;
9864 else if (unformat (i, "our_address %U", unformat_ip6_address,
9866 our_address_set = 1;
9867 else if (unformat (i, "local_session_id %d", &local_session_id))
9869 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9871 else if (unformat (i, "local_cookie %lld", &local_cookie))
9873 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9875 else if (unformat (i, "l2-sublayer-present"))
9876 l2_sublayer_present = 1;
9881 if (client_address_set == 0)
9883 errmsg ("client_address required\n");
9887 if (our_address_set == 0)
9889 errmsg ("our_address required\n");
9893 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9895 clib_memcpy (mp->client_address, client_address.as_u8,
9896 sizeof (mp->client_address));
9898 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9900 mp->local_session_id = ntohl (local_session_id);
9901 mp->remote_session_id = ntohl (remote_session_id);
9902 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9903 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9904 mp->l2_sublayer_present = l2_sublayer_present;
9914 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9916 unformat_input_t *i = vam->input;
9918 u8 sw_if_index_set = 0;
9919 u64 new_local_cookie = 0;
9920 u64 new_remote_cookie = 0;
9921 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9926 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9927 sw_if_index_set = 1;
9928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9929 sw_if_index_set = 1;
9930 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9932 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9938 if (sw_if_index_set == 0)
9940 errmsg ("missing interface name or sw_if_index\n");
9944 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9946 mp->sw_if_index = ntohl (sw_if_index);
9947 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9948 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9957 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9959 unformat_input_t *i = vam->input;
9960 vl_api_l2tpv3_interface_enable_disable_t *mp;
9963 u8 sw_if_index_set = 0;
9964 u8 enable_disable = 1;
9966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9968 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9969 sw_if_index_set = 1;
9970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9971 sw_if_index_set = 1;
9972 else if (unformat (i, "enable"))
9974 else if (unformat (i, "disable"))
9980 if (sw_if_index_set == 0)
9982 errmsg ("missing interface name or sw_if_index\n");
9986 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9988 mp->sw_if_index = ntohl (sw_if_index);
9989 mp->enable_disable = enable_disable;
9998 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10000 unformat_input_t *i = vam->input;
10001 vl_api_l2tpv3_set_lookup_key_t *mp;
10005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10007 if (unformat (i, "lookup_v6_src"))
10008 key = L2T_LOOKUP_SRC_ADDRESS;
10009 else if (unformat (i, "lookup_v6_dst"))
10010 key = L2T_LOOKUP_DST_ADDRESS;
10011 else if (unformat (i, "lookup_session_id"))
10012 key = L2T_LOOKUP_SESSION_ID;
10017 if (key == (u8) ~ 0)
10019 errmsg ("l2tp session lookup key unset\n");
10023 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10033 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10034 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10036 vat_main_t *vam = &vat_main;
10038 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
10039 format_ip6_address, mp->our_address,
10040 format_ip6_address, mp->client_address,
10041 clib_net_to_host_u32 (mp->sw_if_index));
10044 " local cookies %016llx %016llx remote cookie %016llx\n",
10045 clib_net_to_host_u64 (mp->local_cookie[0]),
10046 clib_net_to_host_u64 (mp->local_cookie[1]),
10047 clib_net_to_host_u64 (mp->remote_cookie));
10049 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
10050 clib_net_to_host_u32 (mp->local_session_id),
10051 clib_net_to_host_u32 (mp->remote_session_id));
10053 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
10054 mp->l2_sublayer_present ? "preset" : "absent");
10058 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10059 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10061 vat_main_t *vam = &vat_main;
10062 vat_json_node_t *node = NULL;
10063 struct in6_addr addr;
10065 if (VAT_JSON_ARRAY != vam->json_tree.type)
10067 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10068 vat_json_init_array (&vam->json_tree);
10070 node = vat_json_array_add (&vam->json_tree);
10072 vat_json_init_object (node);
10074 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10075 vat_json_object_add_ip6 (node, "our_address", addr);
10076 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10077 vat_json_object_add_ip6 (node, "client_address", addr);
10079 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10080 vat_json_init_array (lc);
10081 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10082 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10083 vat_json_object_add_uint (node, "remote_cookie",
10084 clib_net_to_host_u64 (mp->remote_cookie));
10086 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10087 vat_json_object_add_uint (node, "local_session_id",
10088 clib_net_to_host_u32 (mp->local_session_id));
10089 vat_json_object_add_uint (node, "remote_session_id",
10090 clib_net_to_host_u32 (mp->remote_session_id));
10091 vat_json_object_add_string_copy (node, "l2_sublayer",
10092 mp->l2_sublayer_present ? (u8 *) "present"
10093 : (u8 *) "absent");
10097 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10099 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10102 /* Get list of l2tpv3-tunnel interfaces */
10103 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10106 /* Use a control ping for synchronization */
10108 vl_api_control_ping_t *mp;
10109 M (CONTROL_PING, control_ping);
10116 static void vl_api_sw_interface_tap_details_t_handler
10117 (vl_api_sw_interface_tap_details_t * mp)
10119 vat_main_t *vam = &vat_main;
10121 fformat (vam->ofp, "%-16s %d\n",
10122 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10125 static void vl_api_sw_interface_tap_details_t_handler_json
10126 (vl_api_sw_interface_tap_details_t * mp)
10128 vat_main_t *vam = &vat_main;
10129 vat_json_node_t *node = NULL;
10131 if (VAT_JSON_ARRAY != vam->json_tree.type)
10133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10134 vat_json_init_array (&vam->json_tree);
10136 node = vat_json_array_add (&vam->json_tree);
10138 vat_json_init_object (node);
10139 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10140 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10144 api_sw_interface_tap_dump (vat_main_t * vam)
10146 vl_api_sw_interface_tap_dump_t *mp;
10149 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
10150 /* Get list of tap interfaces */
10151 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10154 /* Use a control ping for synchronization */
10156 vl_api_control_ping_t *mp;
10157 M (CONTROL_PING, control_ping);
10163 static uword unformat_vxlan_decap_next
10164 (unformat_input_t * input, va_list * args)
10166 u32 *result = va_arg (*args, u32 *);
10169 if (unformat (input, "l2"))
10170 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10171 else if (unformat (input, "%d", &tmp))
10179 api_vxlan_add_del_tunnel (vat_main_t * vam)
10181 unformat_input_t *line_input = vam->input;
10182 vl_api_vxlan_add_del_tunnel_t *mp;
10184 ip46_address_t src, dst;
10186 u8 ipv4_set = 0, ipv6_set = 0;
10190 u32 mcast_sw_if_index = ~0;
10191 u32 encap_vrf_id = 0;
10192 u32 decap_next_index = ~0;
10195 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10196 memset (&src, 0, sizeof src);
10197 memset (&dst, 0, sizeof dst);
10199 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10201 if (unformat (line_input, "del"))
10204 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10210 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10216 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10222 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10227 else if (unformat (line_input, "group %U %U",
10228 unformat_ip4_address, &dst.ip4,
10229 unformat_sw_if_index, vam, &mcast_sw_if_index))
10231 grp_set = dst_set = 1;
10234 else if (unformat (line_input, "group %U",
10235 unformat_ip4_address, &dst.ip4))
10237 grp_set = dst_set = 1;
10240 else if (unformat (line_input, "group %U %U",
10241 unformat_ip6_address, &dst.ip6,
10242 unformat_sw_if_index, vam, &mcast_sw_if_index))
10244 grp_set = dst_set = 1;
10247 else if (unformat (line_input, "group %U",
10248 unformat_ip6_address, &dst.ip6))
10250 grp_set = dst_set = 1;
10254 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10256 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10258 else if (unformat (line_input, "decap-next %U",
10259 unformat_vxlan_decap_next, &decap_next_index))
10261 else if (unformat (line_input, "vni %d", &vni))
10265 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10272 errmsg ("tunnel src address not specified\n");
10277 errmsg ("tunnel dst address not specified\n");
10281 if (grp_set && !ip46_address_is_multicast (&dst))
10283 errmsg ("tunnel group address not multicast\n");
10286 if (grp_set && mcast_sw_if_index == ~0)
10288 errmsg ("tunnel nonexistent multicast device\n");
10293 if (ipv4_set && ipv6_set)
10295 errmsg ("both IPv4 and IPv6 addresses specified");
10299 if ((vni == 0) || (vni >> 24))
10301 errmsg ("vni not specified or out of range\n");
10305 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10309 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10310 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10314 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10315 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10317 mp->encap_vrf_id = ntohl (encap_vrf_id);
10318 mp->decap_next_index = ntohl (decap_next_index);
10319 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10320 mp->vni = ntohl (vni);
10321 mp->is_add = is_add;
10322 mp->is_ipv6 = ipv6_set;
10330 static void vl_api_vxlan_tunnel_details_t_handler
10331 (vl_api_vxlan_tunnel_details_t * mp)
10333 vat_main_t *vam = &vat_main;
10334 ip46_address_t src, dst;
10336 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10337 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10339 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d\n",
10340 ntohl (mp->sw_if_index),
10341 format_ip46_address, &src, IP46_TYPE_ANY,
10342 format_ip46_address, &dst, IP46_TYPE_ANY,
10343 ntohl (mp->encap_vrf_id),
10344 ntohl (mp->decap_next_index), ntohl (mp->vni),
10345 ntohl (mp->mcast_sw_if_index));
10348 static void vl_api_vxlan_tunnel_details_t_handler_json
10349 (vl_api_vxlan_tunnel_details_t * mp)
10351 vat_main_t *vam = &vat_main;
10352 vat_json_node_t *node = NULL;
10354 if (VAT_JSON_ARRAY != vam->json_tree.type)
10356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10357 vat_json_init_array (&vam->json_tree);
10359 node = vat_json_array_add (&vam->json_tree);
10361 vat_json_init_object (node);
10362 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10365 struct in6_addr ip6;
10367 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10368 vat_json_object_add_ip6 (node, "src_address", ip6);
10369 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10370 vat_json_object_add_ip6 (node, "dst_address", ip6);
10374 struct in_addr ip4;
10376 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10377 vat_json_object_add_ip4 (node, "src_address", ip4);
10378 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10379 vat_json_object_add_ip4 (node, "dst_address", ip4);
10381 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10382 vat_json_object_add_uint (node, "decap_next_index",
10383 ntohl (mp->decap_next_index));
10384 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10385 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10386 vat_json_object_add_uint (node, "mcast_sw_if_index",
10387 ntohl (mp->mcast_sw_if_index));
10391 api_vxlan_tunnel_dump (vat_main_t * vam)
10393 unformat_input_t *i = vam->input;
10394 vl_api_vxlan_tunnel_dump_t *mp;
10397 u8 sw_if_index_set = 0;
10399 /* Parse args required to build the message */
10400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10402 if (unformat (i, "sw_if_index %d", &sw_if_index))
10403 sw_if_index_set = 1;
10408 if (sw_if_index_set == 0)
10413 if (!vam->json_output)
10415 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s\n",
10416 "sw_if_index", "src_address", "dst_address",
10417 "encap_vrf_id", "decap_next_index", "vni",
10418 "mcast_sw_if_index");
10421 /* Get list of vxlan-tunnel interfaces */
10422 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10424 mp->sw_if_index = htonl (sw_if_index);
10428 /* Use a control ping for synchronization */
10430 vl_api_control_ping_t *mp;
10431 M (CONTROL_PING, control_ping);
10438 api_gre_add_del_tunnel (vat_main_t * vam)
10440 unformat_input_t *line_input = vam->input;
10441 vl_api_gre_add_del_tunnel_t *mp;
10443 ip4_address_t src4, dst4;
10448 u32 outer_fib_id = 0;
10450 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10452 if (unformat (line_input, "del"))
10454 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10456 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10458 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10460 else if (unformat (line_input, "teb"))
10464 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10471 errmsg ("tunnel src address not specified\n");
10476 errmsg ("tunnel dst address not specified\n");
10481 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10483 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10484 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10485 mp->outer_fib_id = ntohl (outer_fib_id);
10486 mp->is_add = is_add;
10495 static void vl_api_gre_tunnel_details_t_handler
10496 (vl_api_gre_tunnel_details_t * mp)
10498 vat_main_t *vam = &vat_main;
10500 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
10501 ntohl (mp->sw_if_index),
10502 format_ip4_address, &mp->src_address,
10503 format_ip4_address, &mp->dst_address,
10504 mp->teb, ntohl (mp->outer_fib_id));
10507 static void vl_api_gre_tunnel_details_t_handler_json
10508 (vl_api_gre_tunnel_details_t * mp)
10510 vat_main_t *vam = &vat_main;
10511 vat_json_node_t *node = NULL;
10512 struct in_addr ip4;
10514 if (VAT_JSON_ARRAY != vam->json_tree.type)
10516 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10517 vat_json_init_array (&vam->json_tree);
10519 node = vat_json_array_add (&vam->json_tree);
10521 vat_json_init_object (node);
10522 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10523 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10524 vat_json_object_add_ip4 (node, "src_address", ip4);
10525 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10526 vat_json_object_add_ip4 (node, "dst_address", ip4);
10527 vat_json_object_add_uint (node, "teb", mp->teb);
10528 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10532 api_gre_tunnel_dump (vat_main_t * vam)
10534 unformat_input_t *i = vam->input;
10535 vl_api_gre_tunnel_dump_t *mp;
10538 u8 sw_if_index_set = 0;
10540 /* Parse args required to build the message */
10541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10543 if (unformat (i, "sw_if_index %d", &sw_if_index))
10544 sw_if_index_set = 1;
10549 if (sw_if_index_set == 0)
10554 if (!vam->json_output)
10556 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
10557 "sw_if_index", "src_address", "dst_address", "teb",
10561 /* Get list of gre-tunnel interfaces */
10562 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10564 mp->sw_if_index = htonl (sw_if_index);
10568 /* Use a control ping for synchronization */
10570 vl_api_control_ping_t *mp;
10571 M (CONTROL_PING, control_ping);
10578 api_l2_fib_clear_table (vat_main_t * vam)
10580 // unformat_input_t * i = vam->input;
10581 vl_api_l2_fib_clear_table_t *mp;
10584 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10593 api_l2_interface_efp_filter (vat_main_t * vam)
10595 unformat_input_t *i = vam->input;
10596 vl_api_l2_interface_efp_filter_t *mp;
10600 u8 sw_if_index_set = 0;
10602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10604 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10605 sw_if_index_set = 1;
10606 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10607 sw_if_index_set = 1;
10608 else if (unformat (i, "enable"))
10610 else if (unformat (i, "disable"))
10614 clib_warning ("parse error '%U'", format_unformat_error, i);
10619 if (sw_if_index_set == 0)
10621 errmsg ("missing sw_if_index\n");
10625 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10627 mp->sw_if_index = ntohl (sw_if_index);
10628 mp->enable_disable = enable;
10636 #define foreach_vtr_op \
10637 _("disable", L2_VTR_DISABLED) \
10638 _("push-1", L2_VTR_PUSH_1) \
10639 _("push-2", L2_VTR_PUSH_2) \
10640 _("pop-1", L2_VTR_POP_1) \
10641 _("pop-2", L2_VTR_POP_2) \
10642 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10643 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10644 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10645 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10648 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10650 unformat_input_t *i = vam->input;
10651 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10654 u8 sw_if_index_set = 0;
10657 u32 push_dot1q = 1;
10661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10663 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10664 sw_if_index_set = 1;
10665 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10666 sw_if_index_set = 1;
10667 else if (unformat (i, "vtr_op %d", &vtr_op))
10669 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10672 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10674 else if (unformat (i, "tag1 %d", &tag1))
10676 else if (unformat (i, "tag2 %d", &tag2))
10680 clib_warning ("parse error '%U'", format_unformat_error, i);
10685 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10687 errmsg ("missing vtr operation or sw_if_index\n");
10691 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10692 mp->sw_if_index = ntohl (sw_if_index);
10693 mp->vtr_op = ntohl (vtr_op);
10694 mp->push_dot1q = ntohl (push_dot1q);
10695 mp->tag1 = ntohl (tag1);
10696 mp->tag2 = ntohl (tag2);
10705 api_create_vhost_user_if (vat_main_t * vam)
10707 unformat_input_t *i = vam->input;
10708 vl_api_create_vhost_user_if_t *mp;
10712 u8 file_name_set = 0;
10713 u32 custom_dev_instance = ~0;
10715 u8 use_custom_mac = 0;
10718 /* Shut up coverity */
10719 memset (hwaddr, 0, sizeof (hwaddr));
10721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10723 if (unformat (i, "socket %s", &file_name))
10727 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10729 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10730 use_custom_mac = 1;
10731 else if (unformat (i, "server"))
10733 else if (unformat (i, "tag %s", &tag))
10739 if (file_name_set == 0)
10741 errmsg ("missing socket file name\n");
10745 if (vec_len (file_name) > 255)
10747 errmsg ("socket file name too long\n");
10750 vec_add1 (file_name, 0);
10752 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10754 mp->is_server = is_server;
10755 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10756 vec_free (file_name);
10757 if (custom_dev_instance != ~0)
10760 mp->custom_dev_instance = ntohl (custom_dev_instance);
10762 mp->use_custom_mac = use_custom_mac;
10763 clib_memcpy (mp->mac_address, hwaddr, 6);
10765 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10775 api_modify_vhost_user_if (vat_main_t * vam)
10777 unformat_input_t *i = vam->input;
10778 vl_api_modify_vhost_user_if_t *mp;
10782 u8 file_name_set = 0;
10783 u32 custom_dev_instance = ~0;
10784 u8 sw_if_index_set = 0;
10785 u32 sw_if_index = (u32) ~ 0;
10787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10789 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10790 sw_if_index_set = 1;
10791 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10792 sw_if_index_set = 1;
10793 else if (unformat (i, "socket %s", &file_name))
10797 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10799 else if (unformat (i, "server"))
10805 if (sw_if_index_set == 0)
10807 errmsg ("missing sw_if_index or interface name\n");
10811 if (file_name_set == 0)
10813 errmsg ("missing socket file name\n");
10817 if (vec_len (file_name) > 255)
10819 errmsg ("socket file name too long\n");
10822 vec_add1 (file_name, 0);
10824 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10826 mp->sw_if_index = ntohl (sw_if_index);
10827 mp->is_server = is_server;
10828 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10829 vec_free (file_name);
10830 if (custom_dev_instance != ~0)
10833 mp->custom_dev_instance = ntohl (custom_dev_instance);
10843 api_delete_vhost_user_if (vat_main_t * vam)
10845 unformat_input_t *i = vam->input;
10846 vl_api_delete_vhost_user_if_t *mp;
10848 u32 sw_if_index = ~0;
10849 u8 sw_if_index_set = 0;
10851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10853 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10854 sw_if_index_set = 1;
10855 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10856 sw_if_index_set = 1;
10861 if (sw_if_index_set == 0)
10863 errmsg ("missing sw_if_index or interface name\n");
10868 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10870 mp->sw_if_index = ntohl (sw_if_index);
10878 static void vl_api_sw_interface_vhost_user_details_t_handler
10879 (vl_api_sw_interface_vhost_user_details_t * mp)
10881 vat_main_t *vam = &vat_main;
10883 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10884 (char *) mp->interface_name,
10885 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10886 clib_net_to_host_u64 (mp->features), mp->is_server,
10887 ntohl (mp->num_regions), (char *) mp->sock_filename);
10888 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10891 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10892 (vl_api_sw_interface_vhost_user_details_t * mp)
10894 vat_main_t *vam = &vat_main;
10895 vat_json_node_t *node = NULL;
10897 if (VAT_JSON_ARRAY != vam->json_tree.type)
10899 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10900 vat_json_init_array (&vam->json_tree);
10902 node = vat_json_array_add (&vam->json_tree);
10904 vat_json_init_object (node);
10905 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10906 vat_json_object_add_string_copy (node, "interface_name",
10907 mp->interface_name);
10908 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10909 ntohl (mp->virtio_net_hdr_sz));
10910 vat_json_object_add_uint (node, "features",
10911 clib_net_to_host_u64 (mp->features));
10912 vat_json_object_add_uint (node, "is_server", mp->is_server);
10913 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10914 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10915 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10919 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10921 vl_api_sw_interface_vhost_user_dump_t *mp;
10924 "Interface name idx hdr_sz features server regions filename\n");
10926 /* Get list of vhost-user interfaces */
10927 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10930 /* Use a control ping for synchronization */
10932 vl_api_control_ping_t *mp;
10933 M (CONTROL_PING, control_ping);
10940 api_show_version (vat_main_t * vam)
10942 vl_api_show_version_t *mp;
10945 M (SHOW_VERSION, show_version);
10955 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10957 unformat_input_t *line_input = vam->input;
10958 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10960 ip4_address_t local4, remote4;
10961 ip6_address_t local6, remote6;
10963 u8 ipv4_set = 0, ipv6_set = 0;
10966 u32 encap_vrf_id = 0;
10967 u32 decap_vrf_id = 0;
10972 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10974 if (unformat (line_input, "del"))
10976 else if (unformat (line_input, "local %U",
10977 unformat_ip4_address, &local4))
10982 else if (unformat (line_input, "remote %U",
10983 unformat_ip4_address, &remote4))
10988 else if (unformat (line_input, "local %U",
10989 unformat_ip6_address, &local6))
10994 else if (unformat (line_input, "remote %U",
10995 unformat_ip6_address, &remote6))
11000 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11002 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11004 else if (unformat (line_input, "vni %d", &vni))
11006 else if (unformat (line_input, "next-ip4"))
11008 else if (unformat (line_input, "next-ip6"))
11010 else if (unformat (line_input, "next-ethernet"))
11012 else if (unformat (line_input, "next-nsh"))
11016 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
11021 if (local_set == 0)
11023 errmsg ("tunnel local address not specified\n");
11026 if (remote_set == 0)
11028 errmsg ("tunnel remote address not specified\n");
11031 if (ipv4_set && ipv6_set)
11033 errmsg ("both IPv4 and IPv6 addresses specified");
11039 errmsg ("vni not specified\n");
11043 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11048 clib_memcpy (&mp->local, &local6, sizeof (local6));
11049 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11053 clib_memcpy (&mp->local, &local4, sizeof (local4));
11054 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11057 mp->encap_vrf_id = ntohl (encap_vrf_id);
11058 mp->decap_vrf_id = ntohl (decap_vrf_id);
11059 mp->protocol = ntohl (protocol);
11060 mp->vni = ntohl (vni);
11061 mp->is_add = is_add;
11062 mp->is_ipv6 = ipv6_set;
11070 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11071 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11073 vat_main_t *vam = &vat_main;
11075 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
11076 ntohl (mp->sw_if_index),
11077 format_ip46_address, &(mp->local[0]),
11078 format_ip46_address, &(mp->remote[0]),
11080 ntohl (mp->protocol),
11081 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11084 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11085 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11087 vat_main_t *vam = &vat_main;
11088 vat_json_node_t *node = NULL;
11089 struct in_addr ip4;
11090 struct in6_addr ip6;
11092 if (VAT_JSON_ARRAY != vam->json_tree.type)
11094 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11095 vat_json_init_array (&vam->json_tree);
11097 node = vat_json_array_add (&vam->json_tree);
11099 vat_json_init_object (node);
11100 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11103 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11104 vat_json_object_add_ip6 (node, "local", ip6);
11105 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11106 vat_json_object_add_ip6 (node, "remote", ip6);
11110 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11111 vat_json_object_add_ip4 (node, "local", ip4);
11112 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11113 vat_json_object_add_ip4 (node, "remote", ip4);
11115 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11116 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11117 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11118 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11119 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11123 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11125 unformat_input_t *i = vam->input;
11126 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11129 u8 sw_if_index_set = 0;
11131 /* Parse args required to build the message */
11132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11134 if (unformat (i, "sw_if_index %d", &sw_if_index))
11135 sw_if_index_set = 1;
11140 if (sw_if_index_set == 0)
11145 if (!vam->json_output)
11147 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
11148 "sw_if_index", "local", "remote", "vni",
11149 "protocol", "encap_vrf_id", "decap_vrf_id");
11152 /* Get list of vxlan-tunnel interfaces */
11153 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11155 mp->sw_if_index = htonl (sw_if_index);
11159 /* Use a control ping for synchronization */
11161 vl_api_control_ping_t *mp;
11162 M (CONTROL_PING, control_ping);
11169 format_l2_fib_mac_address (u8 * s, va_list * args)
11171 u8 *a = va_arg (*args, u8 *);
11173 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11174 a[2], a[3], a[4], a[5], a[6], a[7]);
11177 static void vl_api_l2_fib_table_entry_t_handler
11178 (vl_api_l2_fib_table_entry_t * mp)
11180 vat_main_t *vam = &vat_main;
11182 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11184 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11185 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11189 static void vl_api_l2_fib_table_entry_t_handler_json
11190 (vl_api_l2_fib_table_entry_t * mp)
11192 vat_main_t *vam = &vat_main;
11193 vat_json_node_t *node = NULL;
11195 if (VAT_JSON_ARRAY != vam->json_tree.type)
11197 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11198 vat_json_init_array (&vam->json_tree);
11200 node = vat_json_array_add (&vam->json_tree);
11202 vat_json_init_object (node);
11203 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11204 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11205 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11206 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11207 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11208 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11212 api_l2_fib_table_dump (vat_main_t * vam)
11214 unformat_input_t *i = vam->input;
11215 vl_api_l2_fib_table_dump_t *mp;
11220 /* Parse args required to build the message */
11221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11223 if (unformat (i, "bd_id %d", &bd_id))
11229 if (bd_id_set == 0)
11231 errmsg ("missing bridge domain\n");
11236 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
11238 /* Get list of l2 fib entries */
11239 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11241 mp->bd_id = ntohl (bd_id);
11244 /* Use a control ping for synchronization */
11246 vl_api_control_ping_t *mp;
11247 M (CONTROL_PING, control_ping);
11255 api_interface_name_renumber (vat_main_t * vam)
11257 unformat_input_t *line_input = vam->input;
11258 vl_api_interface_name_renumber_t *mp;
11259 u32 sw_if_index = ~0;
11261 u32 new_show_dev_instance = ~0;
11263 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11265 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
11268 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11270 else if (unformat (line_input, "new_show_dev_instance %d",
11271 &new_show_dev_instance))
11277 if (sw_if_index == ~0)
11279 errmsg ("missing interface name or sw_if_index\n");
11283 if (new_show_dev_instance == ~0)
11285 errmsg ("missing new_show_dev_instance\n");
11289 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11291 mp->sw_if_index = ntohl (sw_if_index);
11292 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11299 api_want_ip4_arp_events (vat_main_t * vam)
11301 unformat_input_t *line_input = vam->input;
11302 vl_api_want_ip4_arp_events_t *mp;
11304 ip4_address_t address;
11305 int address_set = 0;
11306 u32 enable_disable = 1;
11308 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11310 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11312 else if (unformat (line_input, "del"))
11313 enable_disable = 0;
11318 if (address_set == 0)
11320 errmsg ("missing addresses\n");
11324 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11325 mp->enable_disable = enable_disable;
11326 mp->pid = getpid ();
11327 mp->address = address.as_u32;
11334 api_want_ip6_nd_events (vat_main_t * vam)
11336 unformat_input_t *line_input = vam->input;
11337 vl_api_want_ip6_nd_events_t *mp;
11339 ip6_address_t address;
11340 int address_set = 0;
11341 u32 enable_disable = 1;
11343 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11345 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11347 else if (unformat (line_input, "del"))
11348 enable_disable = 0;
11353 if (address_set == 0)
11355 errmsg ("missing addresses\n");
11359 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11360 mp->enable_disable = enable_disable;
11361 mp->pid = getpid ();
11362 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11369 api_input_acl_set_interface (vat_main_t * vam)
11371 unformat_input_t *i = vam->input;
11372 vl_api_input_acl_set_interface_t *mp;
11375 int sw_if_index_set;
11376 u32 ip4_table_index = ~0;
11377 u32 ip6_table_index = ~0;
11378 u32 l2_table_index = ~0;
11381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11383 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11384 sw_if_index_set = 1;
11385 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11386 sw_if_index_set = 1;
11387 else if (unformat (i, "del"))
11389 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11391 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11393 else if (unformat (i, "l2-table %d", &l2_table_index))
11397 clib_warning ("parse error '%U'", format_unformat_error, i);
11402 if (sw_if_index_set == 0)
11404 errmsg ("missing interface name or sw_if_index\n");
11408 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11410 mp->sw_if_index = ntohl (sw_if_index);
11411 mp->ip4_table_index = ntohl (ip4_table_index);
11412 mp->ip6_table_index = ntohl (ip6_table_index);
11413 mp->l2_table_index = ntohl (l2_table_index);
11414 mp->is_add = is_add;
11423 api_ip_address_dump (vat_main_t * vam)
11425 unformat_input_t *i = vam->input;
11426 vl_api_ip_address_dump_t *mp;
11427 u32 sw_if_index = ~0;
11428 u8 sw_if_index_set = 0;
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "sw_if_index %d", &sw_if_index))
11436 sw_if_index_set = 1;
11437 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11438 sw_if_index_set = 1;
11439 else if (unformat (i, "ipv4"))
11441 else if (unformat (i, "ipv6"))
11447 if (ipv4_set && ipv6_set)
11449 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11453 if ((!ipv4_set) && (!ipv6_set))
11455 errmsg ("no ipv4 nor ipv6 flag set\n");
11459 if (sw_if_index_set == 0)
11461 errmsg ("missing interface name or sw_if_index\n");
11465 vam->current_sw_if_index = sw_if_index;
11466 vam->is_ipv6 = ipv6_set;
11468 M (IP_ADDRESS_DUMP, ip_address_dump);
11469 mp->sw_if_index = ntohl (sw_if_index);
11470 mp->is_ipv6 = ipv6_set;
11473 /* Use a control ping for synchronization */
11475 vl_api_control_ping_t *mp;
11476 M (CONTROL_PING, control_ping);
11483 api_ip_dump (vat_main_t * vam)
11485 vl_api_ip_dump_t *mp;
11486 unformat_input_t *in = vam->input;
11493 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11495 if (unformat (in, "ipv4"))
11497 else if (unformat (in, "ipv6"))
11503 if (ipv4_set && ipv6_set)
11505 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11509 if ((!ipv4_set) && (!ipv6_set))
11511 errmsg ("no ipv4 nor ipv6 flag set\n");
11515 is_ipv6 = ipv6_set;
11516 vam->is_ipv6 = is_ipv6;
11518 /* free old data */
11519 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11521 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11523 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11525 M (IP_DUMP, ip_dump);
11526 mp->is_ipv6 = ipv6_set;
11529 /* Use a control ping for synchronization */
11531 vl_api_control_ping_t *mp;
11532 M (CONTROL_PING, control_ping);
11539 api_ipsec_spd_add_del (vat_main_t * vam)
11541 unformat_input_t *i = vam->input;
11542 vl_api_ipsec_spd_add_del_t *mp;
11547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11549 if (unformat (i, "spd_id %d", &spd_id))
11551 else if (unformat (i, "del"))
11555 clib_warning ("parse error '%U'", format_unformat_error, i);
11561 errmsg ("spd_id must be set\n");
11565 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11567 mp->spd_id = ntohl (spd_id);
11568 mp->is_add = is_add;
11577 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11579 unformat_input_t *i = vam->input;
11580 vl_api_ipsec_interface_add_del_spd_t *mp;
11583 u8 sw_if_index_set = 0;
11584 u32 spd_id = (u32) ~ 0;
11587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11589 if (unformat (i, "del"))
11591 else if (unformat (i, "spd_id %d", &spd_id))
11593 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11594 sw_if_index_set = 1;
11595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11596 sw_if_index_set = 1;
11599 clib_warning ("parse error '%U'", format_unformat_error, i);
11605 if (spd_id == (u32) ~ 0)
11607 errmsg ("spd_id must be set\n");
11611 if (sw_if_index_set == 0)
11613 errmsg ("missing interface name or sw_if_index\n");
11617 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11619 mp->spd_id = ntohl (spd_id);
11620 mp->sw_if_index = ntohl (sw_if_index);
11621 mp->is_add = is_add;
11630 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11632 unformat_input_t *i = vam->input;
11633 vl_api_ipsec_spd_add_del_entry_t *mp;
11635 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11636 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11638 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11639 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11640 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11641 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11643 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11644 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11645 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11646 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11647 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11648 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11652 if (unformat (i, "del"))
11654 if (unformat (i, "outbound"))
11656 if (unformat (i, "inbound"))
11658 else if (unformat (i, "spd_id %d", &spd_id))
11660 else if (unformat (i, "sa_id %d", &sa_id))
11662 else if (unformat (i, "priority %d", &priority))
11664 else if (unformat (i, "protocol %d", &protocol))
11666 else if (unformat (i, "lport_start %d", &lport_start))
11668 else if (unformat (i, "lport_stop %d", &lport_stop))
11670 else if (unformat (i, "rport_start %d", &rport_start))
11672 else if (unformat (i, "rport_stop %d", &rport_stop))
11676 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11682 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11689 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11695 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11702 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11708 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11715 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11721 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11727 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11729 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11731 clib_warning ("unsupported action: 'resolve'");
11737 clib_warning ("parse error '%U'", format_unformat_error, i);
11743 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11745 mp->spd_id = ntohl (spd_id);
11746 mp->priority = ntohl (priority);
11747 mp->is_outbound = is_outbound;
11749 mp->is_ipv6 = is_ipv6;
11750 if (is_ipv6 || is_ip_any)
11752 clib_memcpy (mp->remote_address_start, &raddr6_start,
11753 sizeof (ip6_address_t));
11754 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11755 sizeof (ip6_address_t));
11756 clib_memcpy (mp->local_address_start, &laddr6_start,
11757 sizeof (ip6_address_t));
11758 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11759 sizeof (ip6_address_t));
11763 clib_memcpy (mp->remote_address_start, &raddr4_start,
11764 sizeof (ip4_address_t));
11765 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11766 sizeof (ip4_address_t));
11767 clib_memcpy (mp->local_address_start, &laddr4_start,
11768 sizeof (ip4_address_t));
11769 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11770 sizeof (ip4_address_t));
11772 mp->protocol = (u8) protocol;
11773 mp->local_port_start = ntohs ((u16) lport_start);
11774 mp->local_port_stop = ntohs ((u16) lport_stop);
11775 mp->remote_port_start = ntohs ((u16) rport_start);
11776 mp->remote_port_stop = ntohs ((u16) rport_stop);
11777 mp->policy = (u8) policy;
11778 mp->sa_id = ntohl (sa_id);
11779 mp->is_add = is_add;
11780 mp->is_ip_any = is_ip_any;
11788 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11790 unformat_input_t *i = vam->input;
11791 vl_api_ipsec_sad_add_del_entry_t *mp;
11793 u32 sad_id = 0, spi = 0;
11794 u8 *ck = 0, *ik = 0;
11797 u8 protocol = IPSEC_PROTOCOL_AH;
11798 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11799 u32 crypto_alg = 0, integ_alg = 0;
11800 ip4_address_t tun_src4;
11801 ip4_address_t tun_dst4;
11802 ip6_address_t tun_src6;
11803 ip6_address_t tun_dst6;
11805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11807 if (unformat (i, "del"))
11809 else if (unformat (i, "sad_id %d", &sad_id))
11811 else if (unformat (i, "spi %d", &spi))
11813 else if (unformat (i, "esp"))
11814 protocol = IPSEC_PROTOCOL_ESP;
11815 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11818 is_tunnel_ipv6 = 0;
11820 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11823 is_tunnel_ipv6 = 0;
11825 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11828 is_tunnel_ipv6 = 1;
11830 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11833 is_tunnel_ipv6 = 1;
11837 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11839 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11840 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11842 clib_warning ("unsupported crypto-alg: '%U'",
11843 format_ipsec_crypto_alg, crypto_alg);
11847 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11851 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11854 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11856 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11858 integ_alg >= IPSEC_INTEG_N_ALG)
11860 clib_warning ("unsupported integ-alg: '%U'",
11861 format_ipsec_integ_alg, integ_alg);
11865 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11869 clib_warning ("parse error '%U'", format_unformat_error, i);
11876 /*Special cases, aes-gcm-128 encryption */
11877 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11879 if (integ_alg != IPSEC_INTEG_ALG_NONE
11880 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11883 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11886 else /*set integ-alg internally to aes-gcm-128 */
11887 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11889 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11891 clib_warning ("unsupported integ-alg: aes-gcm-128");
11894 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11896 clib_warning ("unsupported integ-alg: none");
11902 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11904 mp->sad_id = ntohl (sad_id);
11905 mp->is_add = is_add;
11906 mp->protocol = protocol;
11907 mp->spi = ntohl (spi);
11908 mp->is_tunnel = is_tunnel;
11909 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11910 mp->crypto_algorithm = crypto_alg;
11911 mp->integrity_algorithm = integ_alg;
11912 mp->crypto_key_length = vec_len (ck);
11913 mp->integrity_key_length = vec_len (ik);
11915 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11916 mp->crypto_key_length = sizeof (mp->crypto_key);
11918 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11919 mp->integrity_key_length = sizeof (mp->integrity_key);
11922 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11924 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11928 if (is_tunnel_ipv6)
11930 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11931 sizeof (ip6_address_t));
11932 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11933 sizeof (ip6_address_t));
11937 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11938 sizeof (ip4_address_t));
11939 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11940 sizeof (ip4_address_t));
11951 api_ipsec_sa_set_key (vat_main_t * vam)
11953 unformat_input_t *i = vam->input;
11954 vl_api_ipsec_sa_set_key_t *mp;
11957 u8 *ck = 0, *ik = 0;
11959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11961 if (unformat (i, "sa_id %d", &sa_id))
11963 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11965 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11969 clib_warning ("parse error '%U'", format_unformat_error, i);
11974 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11976 mp->sa_id = ntohl (sa_id);
11977 mp->crypto_key_length = vec_len (ck);
11978 mp->integrity_key_length = vec_len (ik);
11980 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11981 mp->crypto_key_length = sizeof (mp->crypto_key);
11983 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11984 mp->integrity_key_length = sizeof (mp->integrity_key);
11987 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11989 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11998 api_ikev2_profile_add_del (vat_main_t * vam)
12000 unformat_input_t *i = vam->input;
12001 vl_api_ikev2_profile_add_del_t *mp;
12006 const char *valid_chars = "a-zA-Z0-9_";
12008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12010 if (unformat (i, "del"))
12012 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12013 vec_add1 (name, 0);
12016 errmsg ("parse error '%U'", format_unformat_error, i);
12021 if (!vec_len (name))
12023 errmsg ("profile name must be specified");
12027 if (vec_len (name) > 64)
12029 errmsg ("profile name too long");
12033 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12035 clib_memcpy (mp->name, name, vec_len (name));
12036 mp->is_add = is_add;
12046 api_ikev2_profile_set_auth (vat_main_t * vam)
12048 unformat_input_t *i = vam->input;
12049 vl_api_ikev2_profile_set_auth_t *mp;
12053 u32 auth_method = 0;
12056 const char *valid_chars = "a-zA-Z0-9_";
12058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12060 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12061 vec_add1 (name, 0);
12062 else if (unformat (i, "auth_method %U",
12063 unformat_ikev2_auth_method, &auth_method))
12065 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12067 else if (unformat (i, "auth_data %v", &data))
12071 errmsg ("parse error '%U'", format_unformat_error, i);
12076 if (!vec_len (name))
12078 errmsg ("profile name must be specified");
12082 if (vec_len (name) > 64)
12084 errmsg ("profile name too long");
12088 if (!vec_len (data))
12090 errmsg ("auth_data must be specified");
12096 errmsg ("auth_method must be specified");
12100 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12102 mp->is_hex = is_hex;
12103 mp->auth_method = (u8) auth_method;
12104 mp->data_len = vec_len (data);
12105 clib_memcpy (mp->name, name, vec_len (name));
12106 clib_memcpy (mp->data, data, vec_len (data));
12117 api_ikev2_profile_set_id (vat_main_t * vam)
12119 unformat_input_t *i = vam->input;
12120 vl_api_ikev2_profile_set_id_t *mp;
12128 const char *valid_chars = "a-zA-Z0-9_";
12130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12132 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12133 vec_add1 (name, 0);
12134 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12136 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12138 data = vec_new (u8, 4);
12139 clib_memcpy (data, ip4.as_u8, 4);
12141 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12143 else if (unformat (i, "id_data %v", &data))
12145 else if (unformat (i, "local"))
12147 else if (unformat (i, "remote"))
12151 errmsg ("parse error '%U'", format_unformat_error, i);
12156 if (!vec_len (name))
12158 errmsg ("profile name must be specified");
12162 if (vec_len (name) > 64)
12164 errmsg ("profile name too long");
12168 if (!vec_len (data))
12170 errmsg ("id_data must be specified");
12176 errmsg ("id_type must be specified");
12180 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12182 mp->is_local = is_local;
12183 mp->id_type = (u8) id_type;
12184 mp->data_len = vec_len (data);
12185 clib_memcpy (mp->name, name, vec_len (name));
12186 clib_memcpy (mp->data, data, vec_len (data));
12197 api_ikev2_profile_set_ts (vat_main_t * vam)
12199 unformat_input_t *i = vam->input;
12200 vl_api_ikev2_profile_set_ts_t *mp;
12204 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12205 ip4_address_t start_addr, end_addr;
12207 const char *valid_chars = "a-zA-Z0-9_";
12209 start_addr.as_u32 = 0;
12210 end_addr.as_u32 = (u32) ~ 0;
12212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12214 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12215 vec_add1 (name, 0);
12216 else if (unformat (i, "protocol %d", &proto))
12218 else if (unformat (i, "start_port %d", &start_port))
12220 else if (unformat (i, "end_port %d", &end_port))
12223 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12225 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12227 else if (unformat (i, "local"))
12229 else if (unformat (i, "remote"))
12233 errmsg ("parse error '%U'", format_unformat_error, i);
12238 if (!vec_len (name))
12240 errmsg ("profile name must be specified");
12244 if (vec_len (name) > 64)
12246 errmsg ("profile name too long");
12250 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12252 mp->is_local = is_local;
12253 mp->proto = (u8) proto;
12254 mp->start_port = (u16) start_port;
12255 mp->end_port = (u16) end_port;
12256 mp->start_addr = start_addr.as_u32;
12257 mp->end_addr = end_addr.as_u32;
12258 clib_memcpy (mp->name, name, vec_len (name));
12268 api_ikev2_set_local_key (vat_main_t * vam)
12270 unformat_input_t *i = vam->input;
12271 vl_api_ikev2_set_local_key_t *mp;
12275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12277 if (unformat (i, "file %v", &file))
12278 vec_add1 (file, 0);
12281 errmsg ("parse error '%U'", format_unformat_error, i);
12286 if (!vec_len (file))
12288 errmsg ("RSA key file must be specified");
12292 if (vec_len (file) > 256)
12294 errmsg ("file name too long");
12298 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12300 clib_memcpy (mp->key_file, file, vec_len (file));
12313 api_map_add_domain (vat_main_t * vam)
12315 unformat_input_t *i = vam->input;
12316 vl_api_map_add_domain_t *mp;
12319 ip4_address_t ip4_prefix;
12320 ip6_address_t ip6_prefix;
12321 ip6_address_t ip6_src;
12322 u32 num_m_args = 0;
12323 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12324 0, psid_length = 0;
12325 u8 is_translation = 0;
12327 u32 ip6_src_len = 128;
12329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12331 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12332 &ip4_prefix, &ip4_prefix_len))
12334 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12335 &ip6_prefix, &ip6_prefix_len))
12339 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12342 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12344 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12346 else if (unformat (i, "psid-offset %d", &psid_offset))
12348 else if (unformat (i, "psid-len %d", &psid_length))
12350 else if (unformat (i, "mtu %d", &mtu))
12352 else if (unformat (i, "map-t"))
12353 is_translation = 1;
12356 clib_warning ("parse error '%U'", format_unformat_error, i);
12361 if (num_m_args < 3)
12363 errmsg ("mandatory argument(s) missing\n");
12367 /* Construct the API message */
12368 M (MAP_ADD_DOMAIN, map_add_domain);
12370 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12371 mp->ip4_prefix_len = ip4_prefix_len;
12373 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12374 mp->ip6_prefix_len = ip6_prefix_len;
12376 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12377 mp->ip6_src_prefix_len = ip6_src_len;
12379 mp->ea_bits_len = ea_bits_len;
12380 mp->psid_offset = psid_offset;
12381 mp->psid_length = psid_length;
12382 mp->is_translation = is_translation;
12383 mp->mtu = htons (mtu);
12388 /* Wait for a reply, return good/bad news */
12393 api_map_del_domain (vat_main_t * vam)
12395 unformat_input_t *i = vam->input;
12396 vl_api_map_del_domain_t *mp;
12399 u32 num_m_args = 0;
12402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12404 if (unformat (i, "index %d", &index))
12408 clib_warning ("parse error '%U'", format_unformat_error, i);
12413 if (num_m_args != 1)
12415 errmsg ("mandatory argument(s) missing\n");
12419 /* Construct the API message */
12420 M (MAP_DEL_DOMAIN, map_del_domain);
12422 mp->index = ntohl (index);
12427 /* Wait for a reply, return good/bad news */
12432 api_map_add_del_rule (vat_main_t * vam)
12434 unformat_input_t *i = vam->input;
12435 vl_api_map_add_del_rule_t *mp;
12438 ip6_address_t ip6_dst;
12439 u32 num_m_args = 0, index, psid = 0;
12441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12443 if (unformat (i, "index %d", &index))
12445 else if (unformat (i, "psid %d", &psid))
12447 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12449 else if (unformat (i, "del"))
12455 clib_warning ("parse error '%U'", format_unformat_error, i);
12460 /* Construct the API message */
12461 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12463 mp->index = ntohl (index);
12464 mp->is_add = is_add;
12465 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12466 mp->psid = ntohs (psid);
12471 /* Wait for a reply, return good/bad news */
12476 api_map_domain_dump (vat_main_t * vam)
12478 vl_api_map_domain_dump_t *mp;
12481 /* Construct the API message */
12482 M (MAP_DOMAIN_DUMP, map_domain_dump);
12487 /* Use a control ping for synchronization */
12489 vl_api_control_ping_t *mp;
12490 M (CONTROL_PING, control_ping);
12497 api_map_rule_dump (vat_main_t * vam)
12499 unformat_input_t *i = vam->input;
12500 vl_api_map_rule_dump_t *mp;
12502 u32 domain_index = ~0;
12504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12506 if (unformat (i, "index %u", &domain_index))
12512 if (domain_index == ~0)
12514 clib_warning ("parse error: domain index expected");
12518 /* Construct the API message */
12519 M (MAP_RULE_DUMP, map_rule_dump);
12521 mp->domain_index = htonl (domain_index);
12526 /* Use a control ping for synchronization */
12528 vl_api_control_ping_t *mp;
12529 M (CONTROL_PING, control_ping);
12535 static void vl_api_map_add_domain_reply_t_handler
12536 (vl_api_map_add_domain_reply_t * mp)
12538 vat_main_t *vam = &vat_main;
12539 i32 retval = ntohl (mp->retval);
12541 if (vam->async_mode)
12543 vam->async_errors += (retval < 0);
12547 vam->retval = retval;
12548 vam->result_ready = 1;
12552 static void vl_api_map_add_domain_reply_t_handler_json
12553 (vl_api_map_add_domain_reply_t * mp)
12555 vat_main_t *vam = &vat_main;
12556 vat_json_node_t node;
12558 vat_json_init_object (&node);
12559 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12560 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12562 vat_json_print (vam->ofp, &node);
12563 vat_json_free (&node);
12565 vam->retval = ntohl (mp->retval);
12566 vam->result_ready = 1;
12570 api_get_first_msg_id (vat_main_t * vam)
12572 vl_api_get_first_msg_id_t *mp;
12574 unformat_input_t *i = vam->input;
12578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12580 if (unformat (i, "client %s", &name))
12588 errmsg ("missing client name\n");
12591 vec_add1 (name, 0);
12593 if (vec_len (name) > 63)
12595 errmsg ("client name too long\n");
12599 M (GET_FIRST_MSG_ID, get_first_msg_id);
12600 clib_memcpy (mp->name, name, vec_len (name));
12608 api_cop_interface_enable_disable (vat_main_t * vam)
12610 unformat_input_t *line_input = vam->input;
12611 vl_api_cop_interface_enable_disable_t *mp;
12613 u32 sw_if_index = ~0;
12614 u8 enable_disable = 1;
12616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12618 if (unformat (line_input, "disable"))
12619 enable_disable = 0;
12620 if (unformat (line_input, "enable"))
12621 enable_disable = 1;
12622 else if (unformat (line_input, "%U", unformat_sw_if_index,
12623 vam, &sw_if_index))
12625 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12631 if (sw_if_index == ~0)
12633 errmsg ("missing interface name or sw_if_index\n");
12637 /* Construct the API message */
12638 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12639 mp->sw_if_index = ntohl (sw_if_index);
12640 mp->enable_disable = enable_disable;
12644 /* Wait for the reply */
12649 api_cop_whitelist_enable_disable (vat_main_t * vam)
12651 unformat_input_t *line_input = vam->input;
12652 vl_api_cop_whitelist_enable_disable_t *mp;
12654 u32 sw_if_index = ~0;
12655 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12658 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12660 if (unformat (line_input, "ip4"))
12662 else if (unformat (line_input, "ip6"))
12664 else if (unformat (line_input, "default"))
12666 else if (unformat (line_input, "%U", unformat_sw_if_index,
12667 vam, &sw_if_index))
12669 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12671 else if (unformat (line_input, "fib-id %d", &fib_id))
12677 if (sw_if_index == ~0)
12679 errmsg ("missing interface name or sw_if_index\n");
12683 /* Construct the API message */
12684 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12685 mp->sw_if_index = ntohl (sw_if_index);
12686 mp->fib_id = ntohl (fib_id);
12689 mp->default_cop = default_cop;
12693 /* Wait for the reply */
12698 api_get_node_graph (vat_main_t * vam)
12700 vl_api_get_node_graph_t *mp;
12703 M (GET_NODE_GRAPH, get_node_graph);
12707 /* Wait for the reply */
12712 /** Used for parsing LISP eids */
12713 typedef CLIB_PACKED(struct{
12714 u8 addr[16]; /**< eid address */
12715 u32 len; /**< prefix length if IP */
12716 u8 type; /**< type of eid */
12721 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12723 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12725 memset (a, 0, sizeof (a[0]));
12727 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12729 a->type = 0; /* ipv4 type */
12731 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12733 a->type = 1; /* ipv6 type */
12735 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12737 a->type = 2; /* mac type */
12744 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12753 lisp_eid_size_vat (u8 type)
12768 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12770 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12774 /** Used for transferring locators via VPP API */
12775 typedef CLIB_PACKED(struct
12777 u32 sw_if_index; /**< locator sw_if_index */
12778 u8 priority; /**< locator priority */
12779 u8 weight; /**< locator weight */
12784 api_lisp_add_del_locator_set (vat_main_t * vam)
12786 unformat_input_t *input = vam->input;
12787 vl_api_lisp_add_del_locator_set_t *mp;
12790 u8 *locator_set_name = NULL;
12791 u8 locator_set_name_set = 0;
12792 ls_locator_t locator, *locators = 0;
12793 u32 sw_if_index, priority, weight;
12796 /* Parse args required to build the message */
12797 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12799 if (unformat (input, "del"))
12803 else if (unformat (input, "locator-set %s", &locator_set_name))
12805 locator_set_name_set = 1;
12807 else if (unformat (input, "sw_if_index %u p %u w %u",
12808 &sw_if_index, &priority, &weight))
12810 locator.sw_if_index = htonl (sw_if_index);
12811 locator.priority = priority;
12812 locator.weight = weight;
12813 vec_add1 (locators, locator);
12815 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12816 vam, &sw_if_index, &priority, &weight))
12818 locator.sw_if_index = htonl (sw_if_index);
12819 locator.priority = priority;
12820 locator.weight = weight;
12821 vec_add1 (locators, locator);
12827 if (locator_set_name_set == 0)
12829 errmsg ("missing locator-set name");
12830 vec_free (locators);
12834 if (vec_len (locator_set_name) > 64)
12836 errmsg ("locator-set name too long\n");
12837 vec_free (locator_set_name);
12838 vec_free (locators);
12841 vec_add1 (locator_set_name, 0);
12843 data_len = sizeof (ls_locator_t) * vec_len (locators);
12845 /* Construct the API message */
12846 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12848 mp->is_add = is_add;
12849 clib_memcpy (mp->locator_set_name, locator_set_name,
12850 vec_len (locator_set_name));
12851 vec_free (locator_set_name);
12853 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12855 clib_memcpy (mp->locators, locators, data_len);
12856 vec_free (locators);
12861 /* Wait for a reply... */
12869 api_lisp_add_del_locator (vat_main_t * vam)
12871 unformat_input_t *input = vam->input;
12872 vl_api_lisp_add_del_locator_t *mp;
12874 u32 tmp_if_index = ~0;
12875 u32 sw_if_index = ~0;
12876 u8 sw_if_index_set = 0;
12877 u8 sw_if_index_if_name_set = 0;
12879 u8 priority_set = 0;
12883 u8 *locator_set_name = NULL;
12884 u8 locator_set_name_set = 0;
12886 /* Parse args required to build the message */
12887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12889 if (unformat (input, "del"))
12893 else if (unformat (input, "locator-set %s", &locator_set_name))
12895 locator_set_name_set = 1;
12897 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12900 sw_if_index_if_name_set = 1;
12901 sw_if_index = tmp_if_index;
12903 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12905 sw_if_index_set = 1;
12906 sw_if_index = tmp_if_index;
12908 else if (unformat (input, "p %d", &priority))
12912 else if (unformat (input, "w %d", &weight))
12920 if (locator_set_name_set == 0)
12922 errmsg ("missing locator-set name");
12926 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12928 errmsg ("missing sw_if_index");
12929 vec_free (locator_set_name);
12933 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12935 errmsg ("cannot use both params interface name and sw_if_index");
12936 vec_free (locator_set_name);
12940 if (priority_set == 0)
12942 errmsg ("missing locator-set priority\n");
12943 vec_free (locator_set_name);
12947 if (weight_set == 0)
12949 errmsg ("missing locator-set weight\n");
12950 vec_free (locator_set_name);
12954 if (vec_len (locator_set_name) > 64)
12956 errmsg ("locator-set name too long\n");
12957 vec_free (locator_set_name);
12960 vec_add1 (locator_set_name, 0);
12962 /* Construct the API message */
12963 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12965 mp->is_add = is_add;
12966 mp->sw_if_index = ntohl (sw_if_index);
12967 mp->priority = priority;
12968 mp->weight = weight;
12969 clib_memcpy (mp->locator_set_name, locator_set_name,
12970 vec_len (locator_set_name));
12971 vec_free (locator_set_name);
12976 /* Wait for a reply... */
12984 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
12986 u32 *key_id = va_arg (*args, u32 *);
12989 if (unformat (input, "%s", &s))
12991 if (!strcmp ((char *) s, "sha1"))
12992 key_id[0] = HMAC_SHA_1_96;
12993 else if (!strcmp ((char *) s, "sha256"))
12994 key_id[0] = HMAC_SHA_256_128;
12997 clib_warning ("invalid key_id: '%s'", s);
12998 key_id[0] = HMAC_NO_KEY;
13009 api_lisp_add_del_local_eid (vat_main_t * vam)
13011 unformat_input_t *input = vam->input;
13012 vl_api_lisp_add_del_local_eid_t *mp;
13016 lisp_eid_vat_t _eid, *eid = &_eid;
13017 u8 *locator_set_name = 0;
13018 u8 locator_set_name_set = 0;
13023 /* Parse args required to build the message */
13024 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13026 if (unformat (input, "del"))
13030 else if (unformat (input, "vni %d", &vni))
13034 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13038 else if (unformat (input, "locator-set %s", &locator_set_name))
13040 locator_set_name_set = 1;
13042 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13044 else if (unformat (input, "secret-key %_%v%_", &key))
13050 if (locator_set_name_set == 0)
13052 errmsg ("missing locator-set name\n");
13058 errmsg ("EID address not set!");
13059 vec_free (locator_set_name);
13063 if (key && (0 == key_id))
13065 errmsg ("invalid key_id!");
13069 if (vec_len (key) > 64)
13071 errmsg ("key too long");
13076 if (vec_len (locator_set_name) > 64)
13078 errmsg ("locator-set name too long\n");
13079 vec_free (locator_set_name);
13082 vec_add1 (locator_set_name, 0);
13084 /* Construct the API message */
13085 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13087 mp->is_add = is_add;
13088 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13089 mp->eid_type = eid->type;
13090 mp->prefix_len = eid->len;
13091 mp->vni = clib_host_to_net_u32 (vni);
13092 mp->key_id = clib_host_to_net_u16 (key_id);
13093 clib_memcpy (mp->locator_set_name, locator_set_name,
13094 vec_len (locator_set_name));
13095 clib_memcpy (mp->key, key, vec_len (key));
13097 vec_free (locator_set_name);
13103 /* Wait for a reply... */
13111 /** Used for transferring locators via VPP API */
13112 typedef CLIB_PACKED(struct
13114 u8 is_ip4; /**< is locator an IPv4 address? */
13115 u8 priority; /**< locator priority */
13116 u8 weight; /**< locator weight */
13117 u8 addr[16]; /**< IPv4/IPv6 address */
13122 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13124 unformat_input_t *input = vam->input;
13125 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13128 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13129 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13130 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13131 u32 action = ~0, p, w;
13132 ip4_address_t rmt_rloc4, lcl_rloc4;
13133 ip6_address_t rmt_rloc6, lcl_rloc6;
13134 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13136 memset (&rloc, 0, sizeof (rloc));
13138 /* Parse args required to build the message */
13139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13141 if (unformat (input, "del"))
13145 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
13149 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
13153 else if (unformat (input, "p %d w %d", &p, &w))
13157 errmsg ("No RLOC configured for setting priority/weight!");
13160 curr_rloc->priority = p;
13161 curr_rloc->weight = w;
13163 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13164 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13168 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13169 rloc.priority = rloc.weight = 0;
13170 vec_add1 (lcl_locs, rloc);
13172 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13173 vec_add1 (rmt_locs, rloc);
13174 /* priority and weight saved in rmt loc */
13175 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13177 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13178 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13181 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13182 rloc.priority = rloc.weight = 0;
13183 vec_add1 (lcl_locs, rloc);
13185 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13186 vec_add1 (rmt_locs, rloc);
13187 /* priority and weight saved in rmt loc */
13188 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13190 else if (unformat (input, "action %d", &action))
13196 clib_warning ("parse error '%U'", format_unformat_error, input);
13203 errmsg ("remote eid addresses not set\n");
13207 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13209 errmsg ("eid types don't match\n");
13213 if (0 == rmt_locs && (u32) ~ 0 == action)
13215 errmsg ("action not set for negative mapping\n");
13219 /* Construct the API message */
13220 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13222 mp->is_add = is_add;
13223 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13224 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13225 mp->eid_type = rmt_eid->type;
13226 mp->rmt_len = rmt_eid->len;
13227 mp->lcl_len = lcl_eid->len;
13228 mp->action = action;
13230 if (0 != rmt_locs && 0 != lcl_locs)
13232 mp->loc_num = vec_len (rmt_locs);
13233 clib_memcpy (mp->lcl_locs, lcl_locs,
13234 (sizeof (rloc_t) * vec_len (lcl_locs)));
13235 clib_memcpy (mp->rmt_locs, rmt_locs,
13236 (sizeof (rloc_t) * vec_len (rmt_locs)));
13238 vec_free (lcl_locs);
13239 vec_free (rmt_locs);
13244 /* Wait for a reply... */
13252 api_lisp_add_del_map_server (vat_main_t * vam)
13254 unformat_input_t *input = vam->input;
13255 vl_api_lisp_add_del_map_server_t *mp;
13260 ip4_address_t ipv4;
13261 ip6_address_t ipv6;
13263 /* Parse args required to build the message */
13264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13266 if (unformat (input, "del"))
13270 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13274 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13282 if (ipv4_set && ipv6_set)
13284 errmsg ("both eid v4 and v6 addresses set\n");
13288 if (!ipv4_set && !ipv6_set)
13290 errmsg ("eid addresses not set\n");
13294 /* Construct the API message */
13295 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13297 mp->is_add = is_add;
13301 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13306 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13312 /* Wait for a reply... */
13320 api_lisp_add_del_map_resolver (vat_main_t * vam)
13322 unformat_input_t *input = vam->input;
13323 vl_api_lisp_add_del_map_resolver_t *mp;
13328 ip4_address_t ipv4;
13329 ip6_address_t ipv6;
13331 /* Parse args required to build the message */
13332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13334 if (unformat (input, "del"))
13338 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13342 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13350 if (ipv4_set && ipv6_set)
13352 errmsg ("both eid v4 and v6 addresses set\n");
13356 if (!ipv4_set && !ipv6_set)
13358 errmsg ("eid addresses not set\n");
13362 /* Construct the API message */
13363 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13365 mp->is_add = is_add;
13369 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13374 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13380 /* Wait for a reply... */
13388 api_lisp_gpe_enable_disable (vat_main_t * vam)
13390 unformat_input_t *input = vam->input;
13391 vl_api_lisp_gpe_enable_disable_t *mp;
13396 /* Parse args required to build the message */
13397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13399 if (unformat (input, "enable"))
13404 else if (unformat (input, "disable"))
13415 errmsg ("Value not set\n");
13419 /* Construct the API message */
13420 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13427 /* Wait for a reply... */
13435 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13437 unformat_input_t *input = vam->input;
13438 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13443 /* Parse args required to build the message */
13444 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13446 if (unformat (input, "enable"))
13451 else if (unformat (input, "disable"))
13459 errmsg ("Value not set\n");
13463 /* Construct the API message */
13464 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13466 mp->is_enabled = is_en;
13471 /* Wait for a reply... */
13479 api_lisp_map_register_enable_disable (vat_main_t * vam)
13481 unformat_input_t *input = vam->input;
13482 vl_api_lisp_map_register_enable_disable_t *mp;
13487 /* Parse args required to build the message */
13488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13490 if (unformat (input, "enable"))
13495 else if (unformat (input, "disable"))
13503 errmsg ("Value not set\n");
13507 /* Construct the API message */
13508 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13510 mp->is_enabled = is_en;
13515 /* Wait for a reply... */
13523 api_lisp_enable_disable (vat_main_t * vam)
13525 unformat_input_t *input = vam->input;
13526 vl_api_lisp_enable_disable_t *mp;
13531 /* Parse args required to build the message */
13532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13534 if (unformat (input, "enable"))
13539 else if (unformat (input, "disable"))
13549 errmsg ("Value not set\n");
13553 /* Construct the API message */
13554 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13561 /* Wait for a reply... */
13569 api_show_lisp_map_register_state (vat_main_t * vam)
13572 vl_api_show_lisp_map_register_state_t *mp;
13574 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13579 /* wait for reply */
13586 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13589 vl_api_show_lisp_rloc_probe_state_t *mp;
13591 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13596 /* wait for reply */
13603 api_show_lisp_map_request_mode (vat_main_t * vam)
13606 vl_api_show_lisp_map_request_mode_t *mp;
13608 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13613 /* wait for reply */
13620 api_lisp_map_request_mode (vat_main_t * vam)
13623 unformat_input_t *input = vam->input;
13624 vl_api_lisp_map_request_mode_t *mp;
13627 /* Parse args required to build the message */
13628 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13630 if (unformat (input, "dst-only"))
13632 else if (unformat (input, "src-dst"))
13636 errmsg ("parse error '%U'", format_unformat_error, input);
13641 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13648 /* wait for reply */
13656 * Enable/disable LISP proxy ITR.
13658 * @param vam vpp API test context
13659 * @return return code
13662 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13665 u8 ls_name_set = 0;
13666 unformat_input_t *input = vam->input;
13667 vl_api_lisp_pitr_set_locator_set_t *mp;
13671 /* Parse args required to build the message */
13672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13674 if (unformat (input, "del"))
13676 else if (unformat (input, "locator-set %s", &ls_name))
13680 errmsg ("parse error '%U'", format_unformat_error, input);
13687 errmsg ("locator-set name not set!");
13691 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13693 mp->is_add = is_add;
13694 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13695 vec_free (ls_name);
13700 /* wait for reply */
13708 api_show_lisp_pitr (vat_main_t * vam)
13710 vl_api_show_lisp_pitr_t *mp;
13713 if (!vam->json_output)
13715 fformat (vam->ofp, "%=20s\n", "lisp status:");
13718 M (SHOW_LISP_PITR, show_lisp_pitr);
13722 /* Wait for a reply... */
13730 * Add/delete mapping between vni and vrf
13733 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13736 unformat_input_t *input = vam->input;
13737 vl_api_lisp_eid_table_add_del_map_t *mp;
13738 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13739 u32 vni, vrf, bd_index;
13741 /* Parse args required to build the message */
13742 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13744 if (unformat (input, "del"))
13746 else if (unformat (input, "vrf %d", &vrf))
13748 else if (unformat (input, "bd_index %d", &bd_index))
13750 else if (unformat (input, "vni %d", &vni))
13756 if (!vni_set || (!vrf_set && !bd_index_set))
13758 errmsg ("missing arguments!");
13762 if (vrf_set && bd_index_set)
13764 errmsg ("error: both vrf and bd entered!");
13768 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13770 mp->is_add = is_add;
13771 mp->vni = htonl (vni);
13772 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13773 mp->is_l2 = bd_index_set;
13778 /* wait for reply */
13786 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13788 u32 *action = va_arg (*args, u32 *);
13791 if (unformat (input, "%s", &s))
13793 if (!strcmp ((char *) s, "no-action"))
13795 else if (!strcmp ((char *) s, "natively-forward"))
13797 else if (!strcmp ((char *) s, "send-map-request"))
13799 else if (!strcmp ((char *) s, "drop"))
13803 clib_warning ("invalid action: '%s'", s);
13815 * Add/del remote mapping to/from LISP control plane
13817 * @param vam vpp API test context
13818 * @return return code
13821 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13823 unformat_input_t *input = vam->input;
13824 vl_api_lisp_add_del_remote_mapping_t *mp;
13827 lisp_eid_vat_t _eid, *eid = &_eid;
13828 lisp_eid_vat_t _seid, *seid = &_seid;
13829 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13830 u32 action = ~0, p, w, data_len;
13831 ip4_address_t rloc4;
13832 ip6_address_t rloc6;
13833 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13835 memset (&rloc, 0, sizeof (rloc));
13837 /* Parse args required to build the message */
13838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13840 if (unformat (input, "del-all"))
13844 else if (unformat (input, "del"))
13848 else if (unformat (input, "add"))
13852 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13856 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13860 else if (unformat (input, "vni %d", &vni))
13864 else if (unformat (input, "p %d w %d", &p, &w))
13868 errmsg ("No RLOC configured for setting priority/weight!");
13871 curr_rloc->priority = p;
13872 curr_rloc->weight = w;
13874 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13877 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13878 vec_add1 (rlocs, rloc);
13879 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13881 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13884 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13885 vec_add1 (rlocs, rloc);
13886 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13888 else if (unformat (input, "action %U",
13889 unformat_negative_mapping_action, &action))
13895 clib_warning ("parse error '%U'", format_unformat_error, input);
13902 errmsg ("missing params!");
13906 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13908 errmsg ("no action set for negative map-reply!");
13912 data_len = vec_len (rlocs) * sizeof (rloc_t);
13914 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13915 mp->is_add = is_add;
13916 mp->vni = htonl (vni);
13917 mp->action = (u8) action;
13918 mp->is_src_dst = seid_set;
13919 mp->eid_len = eid->len;
13920 mp->seid_len = seid->len;
13921 mp->del_all = del_all;
13922 mp->eid_type = eid->type;
13923 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13924 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13926 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13927 clib_memcpy (mp->rlocs, rlocs, data_len);
13933 /* Wait for a reply... */
13941 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13942 * forwarding entries in data-plane accordingly.
13944 * @param vam vpp API test context
13945 * @return return code
13948 api_lisp_add_del_adjacency (vat_main_t * vam)
13950 unformat_input_t *input = vam->input;
13951 vl_api_lisp_add_del_adjacency_t *mp;
13954 ip4_address_t leid4, reid4;
13955 ip6_address_t leid6, reid6;
13956 u8 reid_mac[6] = { 0 };
13957 u8 leid_mac[6] = { 0 };
13958 u8 reid_type, leid_type;
13959 u32 leid_len = 0, reid_len = 0, len;
13962 leid_type = reid_type = (u8) ~ 0;
13964 /* Parse args required to build the message */
13965 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13967 if (unformat (input, "del"))
13971 else if (unformat (input, "add"))
13975 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13978 reid_type = 0; /* ipv4 */
13981 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13984 reid_type = 1; /* ipv6 */
13987 else if (unformat (input, "reid %U", unformat_ethernet_address,
13990 reid_type = 2; /* mac */
13992 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13995 leid_type = 0; /* ipv4 */
13998 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14001 leid_type = 1; /* ipv6 */
14004 else if (unformat (input, "leid %U", unformat_ethernet_address,
14007 leid_type = 2; /* mac */
14009 else if (unformat (input, "vni %d", &vni))
14015 errmsg ("parse error '%U'", format_unformat_error, input);
14020 if ((u8) ~ 0 == reid_type)
14022 errmsg ("missing params!");
14026 if (leid_type != reid_type)
14028 errmsg ("remote and local EIDs are of different types!");
14032 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14033 mp->is_add = is_add;
14034 mp->vni = htonl (vni);
14035 mp->leid_len = leid_len;
14036 mp->reid_len = reid_len;
14037 mp->eid_type = reid_type;
14039 switch (mp->eid_type)
14042 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14043 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14046 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14047 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14050 clib_memcpy (mp->leid, leid_mac, 6);
14051 clib_memcpy (mp->reid, reid_mac, 6);
14054 errmsg ("unknown EID type %d!", mp->eid_type);
14061 /* Wait for a reply... */
14069 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14071 unformat_input_t *input = vam->input;
14072 vl_api_lisp_gpe_add_del_iface_t *mp;
14074 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14075 u32 dp_table = 0, vni = 0;
14077 /* Parse args required to build the message */
14078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14080 if (unformat (input, "up"))
14085 else if (unformat (input, "down"))
14090 else if (unformat (input, "table_id %d", &dp_table))
14094 else if (unformat (input, "bd_id %d", &dp_table))
14099 else if (unformat (input, "vni %d", &vni))
14107 if (action_set == 0)
14109 errmsg ("Action not set\n");
14112 if (dp_table_set == 0 || vni_set == 0)
14114 errmsg ("vni and dp_table must be set\n");
14118 /* Construct the API message */
14119 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14121 mp->is_add = is_add;
14122 mp->dp_table = dp_table;
14129 /* Wait for a reply... */
14137 * Add/del map request itr rlocs from LISP control plane and updates
14139 * @param vam vpp API test context
14140 * @return return code
14143 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14145 unformat_input_t *input = vam->input;
14146 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14148 u8 *locator_set_name = 0;
14149 u8 locator_set_name_set = 0;
14152 /* Parse args required to build the message */
14153 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14155 if (unformat (input, "del"))
14159 else if (unformat (input, "%_%v%_", &locator_set_name))
14161 locator_set_name_set = 1;
14165 clib_warning ("parse error '%U'", format_unformat_error, input);
14170 if (is_add && !locator_set_name_set)
14172 errmsg ("itr-rloc is not set!");
14176 if (is_add && vec_len (locator_set_name) > 64)
14178 errmsg ("itr-rloc locator-set name too long\n");
14179 vec_free (locator_set_name);
14183 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14184 mp->is_add = is_add;
14187 clib_memcpy (mp->locator_set_name, locator_set_name,
14188 vec_len (locator_set_name));
14192 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14194 vec_free (locator_set_name);
14199 /* Wait for a reply... */
14207 api_lisp_locator_dump (vat_main_t * vam)
14209 unformat_input_t *input = vam->input;
14210 vl_api_lisp_locator_dump_t *mp;
14212 u8 is_index_set = 0, is_name_set = 0;
14216 /* Parse args required to build the message */
14217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14219 if (unformat (input, "ls_name %_%v%_", &ls_name))
14223 else if (unformat (input, "ls_index %d", &ls_index))
14229 errmsg ("parse error '%U'", format_unformat_error, input);
14234 if (!is_index_set && !is_name_set)
14236 errmsg ("error: expected one of index or name!\n");
14240 if (is_index_set && is_name_set)
14242 errmsg ("error: only one param expected!\n");
14246 if (vec_len (ls_name) > 62)
14248 errmsg ("error: locator set name too long!");
14252 if (!vam->json_output)
14254 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
14258 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14259 mp->is_index_set = is_index_set;
14262 mp->ls_index = clib_host_to_net_u32 (ls_index);
14265 vec_add1 (ls_name, 0);
14266 strncpy ((char *) mp->ls_name, (char *) ls_name,
14267 sizeof (mp->ls_name) - 1);
14273 /* Use a control ping for synchronization */
14275 vl_api_control_ping_t *mp;
14276 M (CONTROL_PING, control_ping);
14279 /* Wait for a reply... */
14287 api_lisp_locator_set_dump (vat_main_t * vam)
14289 vl_api_lisp_locator_set_dump_t *mp;
14290 unformat_input_t *input = vam->input;
14294 /* Parse args required to build the message */
14295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14297 if (unformat (input, "local"))
14301 else if (unformat (input, "remote"))
14307 errmsg ("parse error '%U'", format_unformat_error, input);
14312 if (!vam->json_output)
14314 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
14317 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14319 mp->filter = filter;
14324 /* Use a control ping for synchronization */
14326 vl_api_control_ping_t *mp;
14327 M (CONTROL_PING, control_ping);
14330 /* Wait for a reply... */
14338 api_lisp_eid_table_map_dump (vat_main_t * vam)
14342 unformat_input_t *input = vam->input;
14343 vl_api_lisp_eid_table_map_dump_t *mp;
14346 /* Parse args required to build the message */
14347 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14349 if (unformat (input, "l2"))
14354 else if (unformat (input, "l3"))
14361 errmsg ("parse error '%U'", format_unformat_error, input);
14368 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
14372 if (!vam->json_output)
14374 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
14377 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14383 /* Use a control ping for synchronization */
14385 vl_api_control_ping_t *mp;
14386 M (CONTROL_PING, control_ping);
14389 /* Wait for a reply... */
14397 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14399 vl_api_lisp_eid_table_vni_dump_t *mp;
14402 if (!vam->json_output)
14404 fformat (vam->ofp, "VNI\n");
14407 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14412 /* Use a control ping for synchronization */
14414 vl_api_control_ping_t *mp;
14415 M (CONTROL_PING, control_ping);
14418 /* Wait for a reply... */
14426 api_lisp_eid_table_dump (vat_main_t * vam)
14428 unformat_input_t *i = vam->input;
14429 vl_api_lisp_eid_table_dump_t *mp;
14431 struct in_addr ip4;
14432 struct in6_addr ip6;
14434 u8 eid_type = ~0, eid_set = 0;
14435 u32 prefix_length = ~0, t, vni = 0;
14438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14440 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14446 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14452 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14457 else if (unformat (i, "vni %d", &t))
14461 else if (unformat (i, "local"))
14465 else if (unformat (i, "remote"))
14471 errmsg ("parse error '%U'", format_unformat_error, i);
14476 if (!vam->json_output)
14478 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s\n", "EID",
14479 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14482 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14484 mp->filter = filter;
14488 mp->vni = htonl (vni);
14489 mp->eid_type = eid_type;
14493 mp->prefix_length = prefix_length;
14494 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14497 mp->prefix_length = prefix_length;
14498 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14501 clib_memcpy (mp->eid, mac, sizeof (mac));
14504 errmsg ("unknown EID type %d!", eid_type);
14512 /* Use a control ping for synchronization */
14514 vl_api_control_ping_t *mp;
14515 M (CONTROL_PING, control_ping);
14519 /* Wait for a reply... */
14527 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14529 vl_api_lisp_gpe_tunnel_dump_t *mp;
14532 if (!vam->json_output)
14534 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14535 "%=16s%=16s%=16s%=16s%=16s\n",
14536 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14537 "Decap next", "Lisp version", "Flags", "Next protocol",
14538 "ver_res", "res", "iid");
14541 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14545 /* Use a control ping for synchronization */
14547 vl_api_control_ping_t *mp;
14548 M (CONTROL_PING, control_ping);
14551 /* Wait for a reply... */
14559 api_lisp_adjacencies_get (vat_main_t * vam)
14561 unformat_input_t *i = vam->input;
14562 vl_api_lisp_adjacencies_get_t *mp;
14567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14569 if (unformat (i, "vni %d", &vni))
14575 errmsg ("parse error '%U'\n", format_unformat_error, i);
14582 errmsg ("vni not set!\n");
14586 if (!vam->json_output)
14588 fformat (vam->ofp, "%s %40s\n", "leid", "reid");
14591 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14592 mp->vni = clib_host_to_net_u32 (vni);
14597 /* Wait for a reply... */
14605 api_lisp_map_server_dump (vat_main_t * vam)
14607 vl_api_lisp_map_server_dump_t *mp;
14610 if (!vam->json_output)
14612 fformat (vam->ofp, "%=20s\n", "Map server");
14615 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14619 /* Use a control ping for synchronization */
14621 vl_api_control_ping_t *mp;
14622 M (CONTROL_PING, control_ping);
14625 /* Wait for a reply... */
14633 api_lisp_map_resolver_dump (vat_main_t * vam)
14635 vl_api_lisp_map_resolver_dump_t *mp;
14638 if (!vam->json_output)
14640 fformat (vam->ofp, "%=20s\n", "Map resolver");
14643 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14647 /* Use a control ping for synchronization */
14649 vl_api_control_ping_t *mp;
14650 M (CONTROL_PING, control_ping);
14653 /* Wait for a reply... */
14661 api_show_lisp_status (vat_main_t * vam)
14663 vl_api_show_lisp_status_t *mp;
14666 if (!vam->json_output)
14668 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
14671 M (SHOW_LISP_STATUS, show_lisp_status);
14674 /* Wait for a reply... */
14682 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14684 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14687 if (!vam->json_output)
14689 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
14692 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14695 /* Wait for a reply... */
14703 api_af_packet_create (vat_main_t * vam)
14705 unformat_input_t *i = vam->input;
14706 vl_api_af_packet_create_t *mp;
14708 u8 *host_if_name = 0;
14710 u8 random_hw_addr = 1;
14712 memset (hw_addr, 0, sizeof (hw_addr));
14714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14716 if (unformat (i, "name %s", &host_if_name))
14717 vec_add1 (host_if_name, 0);
14718 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14719 random_hw_addr = 0;
14724 if (!vec_len (host_if_name))
14726 errmsg ("host-interface name must be specified");
14730 if (vec_len (host_if_name) > 64)
14732 errmsg ("host-interface name too long");
14736 M (AF_PACKET_CREATE, af_packet_create);
14738 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14739 clib_memcpy (mp->hw_addr, hw_addr, 6);
14740 mp->use_random_hw_addr = random_hw_addr;
14741 vec_free (host_if_name);
14744 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14750 api_af_packet_delete (vat_main_t * vam)
14752 unformat_input_t *i = vam->input;
14753 vl_api_af_packet_delete_t *mp;
14755 u8 *host_if_name = 0;
14757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14759 if (unformat (i, "name %s", &host_if_name))
14760 vec_add1 (host_if_name, 0);
14765 if (!vec_len (host_if_name))
14767 errmsg ("host-interface name must be specified");
14771 if (vec_len (host_if_name) > 64)
14773 errmsg ("host-interface name too long");
14777 M (AF_PACKET_DELETE, af_packet_delete);
14779 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14780 vec_free (host_if_name);
14789 api_policer_add_del (vat_main_t * vam)
14791 unformat_input_t *i = vam->input;
14792 vl_api_policer_add_del_t *mp;
14803 u8 color_aware = 0;
14804 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14806 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14807 conform_action.dscp = 0;
14808 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14809 exceed_action.dscp = 0;
14810 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14811 violate_action.dscp = 0;
14813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14815 if (unformat (i, "del"))
14817 else if (unformat (i, "name %s", &name))
14818 vec_add1 (name, 0);
14819 else if (unformat (i, "cir %u", &cir))
14821 else if (unformat (i, "eir %u", &eir))
14823 else if (unformat (i, "cb %u", &cb))
14825 else if (unformat (i, "eb %u", &eb))
14827 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14830 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14833 else if (unformat (i, "type %U", unformat_policer_type, &type))
14835 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14838 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14841 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14844 else if (unformat (i, "color-aware"))
14850 if (!vec_len (name))
14852 errmsg ("policer name must be specified");
14856 if (vec_len (name) > 64)
14858 errmsg ("policer name too long");
14862 M (POLICER_ADD_DEL, policer_add_del);
14864 clib_memcpy (mp->name, name, vec_len (name));
14866 mp->is_add = is_add;
14871 mp->rate_type = rate_type;
14872 mp->round_type = round_type;
14874 mp->conform_action_type = conform_action.action_type;
14875 mp->conform_dscp = conform_action.dscp;
14876 mp->exceed_action_type = exceed_action.action_type;
14877 mp->exceed_dscp = exceed_action.dscp;
14878 mp->violate_action_type = violate_action.action_type;
14879 mp->violate_dscp = violate_action.dscp;
14880 mp->color_aware = color_aware;
14889 api_policer_dump (vat_main_t * vam)
14891 unformat_input_t *i = vam->input;
14892 vl_api_policer_dump_t *mp;
14894 u8 *match_name = 0;
14895 u8 match_name_valid = 0;
14897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14899 if (unformat (i, "name %s", &match_name))
14901 vec_add1 (match_name, 0);
14902 match_name_valid = 1;
14908 M (POLICER_DUMP, policer_dump);
14909 mp->match_name_valid = match_name_valid;
14910 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14911 vec_free (match_name);
14915 /* Use a control ping for synchronization */
14917 vl_api_control_ping_t *mp;
14918 M (CONTROL_PING, control_ping);
14921 /* Wait for a reply... */
14929 api_policer_classify_set_interface (vat_main_t * vam)
14931 unformat_input_t *i = vam->input;
14932 vl_api_policer_classify_set_interface_t *mp;
14935 int sw_if_index_set;
14936 u32 ip4_table_index = ~0;
14937 u32 ip6_table_index = ~0;
14938 u32 l2_table_index = ~0;
14941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14943 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14944 sw_if_index_set = 1;
14945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14946 sw_if_index_set = 1;
14947 else if (unformat (i, "del"))
14949 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14951 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14953 else if (unformat (i, "l2-table %d", &l2_table_index))
14957 clib_warning ("parse error '%U'", format_unformat_error, i);
14962 if (sw_if_index_set == 0)
14964 errmsg ("missing interface name or sw_if_index\n");
14968 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14970 mp->sw_if_index = ntohl (sw_if_index);
14971 mp->ip4_table_index = ntohl (ip4_table_index);
14972 mp->ip6_table_index = ntohl (ip6_table_index);
14973 mp->l2_table_index = ntohl (l2_table_index);
14974 mp->is_add = is_add;
14983 api_policer_classify_dump (vat_main_t * vam)
14985 unformat_input_t *i = vam->input;
14986 vl_api_policer_classify_dump_t *mp;
14988 u8 type = POLICER_CLASSIFY_N_TABLES;
14990 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
14994 errmsg ("classify table type must be specified\n");
14998 if (!vam->json_output)
15000 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
15003 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15008 /* Use a control ping for synchronization */
15010 vl_api_control_ping_t *mp;
15011 M (CONTROL_PING, control_ping);
15014 /* Wait for a reply... */
15022 api_netmap_create (vat_main_t * vam)
15024 unformat_input_t *i = vam->input;
15025 vl_api_netmap_create_t *mp;
15029 u8 random_hw_addr = 1;
15033 memset (hw_addr, 0, sizeof (hw_addr));
15035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15037 if (unformat (i, "name %s", &if_name))
15038 vec_add1 (if_name, 0);
15039 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15040 random_hw_addr = 0;
15041 else if (unformat (i, "pipe"))
15043 else if (unformat (i, "master"))
15045 else if (unformat (i, "slave"))
15051 if (!vec_len (if_name))
15053 errmsg ("interface name must be specified");
15057 if (vec_len (if_name) > 64)
15059 errmsg ("interface name too long");
15063 M (NETMAP_CREATE, netmap_create);
15065 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15066 clib_memcpy (mp->hw_addr, hw_addr, 6);
15067 mp->use_random_hw_addr = random_hw_addr;
15068 mp->is_pipe = is_pipe;
15069 mp->is_master = is_master;
15070 vec_free (if_name);
15079 api_netmap_delete (vat_main_t * vam)
15081 unformat_input_t *i = vam->input;
15082 vl_api_netmap_delete_t *mp;
15086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15088 if (unformat (i, "name %s", &if_name))
15089 vec_add1 (if_name, 0);
15094 if (!vec_len (if_name))
15096 errmsg ("interface name must be specified");
15100 if (vec_len (if_name) > 64)
15102 errmsg ("interface name too long");
15106 M (NETMAP_DELETE, netmap_delete);
15108 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15109 vec_free (if_name);
15117 static void vl_api_mpls_tunnel_details_t_handler
15118 (vl_api_mpls_tunnel_details_t * mp)
15120 vat_main_t *vam = &vat_main;
15121 i32 len = mp->mt_next_hop_n_labels;
15124 fformat (vam->ofp, "[%d]: via %U %d labels ",
15126 format_ip4_address, mp->mt_next_hop,
15127 ntohl (mp->mt_next_hop_sw_if_index));
15128 for (i = 0; i < len; i++)
15130 fformat (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15132 fformat (vam->ofp, "\n");
15135 static void vl_api_mpls_tunnel_details_t_handler_json
15136 (vl_api_mpls_tunnel_details_t * mp)
15138 vat_main_t *vam = &vat_main;
15139 vat_json_node_t *node = NULL;
15140 struct in_addr ip4;
15142 i32 len = mp->mt_next_hop_n_labels;
15144 if (VAT_JSON_ARRAY != vam->json_tree.type)
15146 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15147 vat_json_init_array (&vam->json_tree);
15149 node = vat_json_array_add (&vam->json_tree);
15151 vat_json_init_object (node);
15152 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15153 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15154 vat_json_object_add_ip4 (node, "next_hop", ip4);
15155 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15156 ntohl (mp->mt_next_hop_sw_if_index));
15157 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15158 vat_json_object_add_uint (node, "label_count", len);
15159 for (i = 0; i < len; i++)
15161 vat_json_object_add_uint (node, "label",
15162 ntohl (mp->mt_next_hop_out_labels[i]));
15167 api_mpls_tunnel_dump (vat_main_t * vam)
15169 vl_api_mpls_tunnel_dump_t *mp;
15173 /* Parse args required to build the message */
15174 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15176 if (!unformat (vam->input, "tunnel_index %d", &index))
15183 fformat (vam->ofp, " tunnel_index %d\n", index);
15185 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15186 mp->tunnel_index = htonl (index);
15189 /* Use a control ping for synchronization */
15191 vl_api_control_ping_t *mp;
15192 M (CONTROL_PING, control_ping);
15198 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15199 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15202 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15204 vat_main_t *vam = &vat_main;
15205 int count = ntohl (mp->count);
15206 vl_api_fib_path_t *fp;
15210 "table-id %d, label %u, ess_bit %u\n",
15211 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15213 for (i = 0; i < count; i++)
15215 if (fp->afi == IP46_TYPE_IP6)
15217 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15218 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15219 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15220 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15221 format_ip6_address, fp->next_hop);
15222 else if (fp->afi == IP46_TYPE_IP4)
15224 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15225 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15226 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15227 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15228 format_ip4_address, fp->next_hop);
15233 static void vl_api_mpls_fib_details_t_handler_json
15234 (vl_api_mpls_fib_details_t * mp)
15236 vat_main_t *vam = &vat_main;
15237 int count = ntohl (mp->count);
15238 vat_json_node_t *node = NULL;
15239 struct in_addr ip4;
15240 struct in6_addr ip6;
15241 vl_api_fib_path_t *fp;
15244 if (VAT_JSON_ARRAY != vam->json_tree.type)
15246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15247 vat_json_init_array (&vam->json_tree);
15249 node = vat_json_array_add (&vam->json_tree);
15251 vat_json_init_object (node);
15252 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15253 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15254 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15255 vat_json_object_add_uint (node, "path_count", count);
15257 for (i = 0; i < count; i++)
15259 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15260 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15261 vat_json_object_add_uint (node, "is_local", fp->is_local);
15262 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15263 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15264 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15265 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15266 if (fp->afi == IP46_TYPE_IP4)
15268 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15269 vat_json_object_add_ip4 (node, "next_hop", ip4);
15271 else if (fp->afi == IP46_TYPE_IP6)
15273 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15274 vat_json_object_add_ip6 (node, "next_hop", ip6);
15280 api_mpls_fib_dump (vat_main_t * vam)
15282 vl_api_mpls_fib_dump_t *mp;
15285 M (MPLS_FIB_DUMP, mpls_fib_dump);
15288 /* Use a control ping for synchronization */
15290 vl_api_control_ping_t *mp;
15291 M (CONTROL_PING, control_ping);
15297 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15298 #define vl_api_ip_fib_details_t_print vl_noop_handler
15301 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15303 vat_main_t *vam = &vat_main;
15304 int count = ntohl (mp->count);
15305 vl_api_fib_path_t *fp;
15309 "table-id %d, prefix %U/%d\n",
15310 ntohl (mp->table_id), format_ip4_address, mp->address,
15311 mp->address_length);
15313 for (i = 0; i < count; i++)
15315 if (fp->afi == IP46_TYPE_IP6)
15317 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15318 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15319 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15320 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15321 format_ip6_address, fp->next_hop);
15322 else if (fp->afi == IP46_TYPE_IP4)
15324 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15325 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15326 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15327 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15328 format_ip4_address, fp->next_hop);
15333 static void vl_api_ip_fib_details_t_handler_json
15334 (vl_api_ip_fib_details_t * mp)
15336 vat_main_t *vam = &vat_main;
15337 int count = ntohl (mp->count);
15338 vat_json_node_t *node = NULL;
15339 struct in_addr ip4;
15340 struct in6_addr ip6;
15341 vl_api_fib_path_t *fp;
15344 if (VAT_JSON_ARRAY != vam->json_tree.type)
15346 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15347 vat_json_init_array (&vam->json_tree);
15349 node = vat_json_array_add (&vam->json_tree);
15351 vat_json_init_object (node);
15352 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15353 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15354 vat_json_object_add_ip4 (node, "prefix", ip4);
15355 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15356 vat_json_object_add_uint (node, "path_count", count);
15358 for (i = 0; i < count; i++)
15360 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15361 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15362 vat_json_object_add_uint (node, "is_local", fp->is_local);
15363 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15364 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15365 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15366 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15367 if (fp->afi == IP46_TYPE_IP4)
15369 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15370 vat_json_object_add_ip4 (node, "next_hop", ip4);
15372 else if (fp->afi == IP46_TYPE_IP6)
15374 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15375 vat_json_object_add_ip6 (node, "next_hop", ip6);
15381 api_ip_fib_dump (vat_main_t * vam)
15383 vl_api_ip_fib_dump_t *mp;
15386 M (IP_FIB_DUMP, ip_fib_dump);
15389 /* Use a control ping for synchronization */
15391 vl_api_control_ping_t *mp;
15392 M (CONTROL_PING, control_ping);
15398 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15399 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15402 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15404 vat_main_t *vam = &vat_main;
15405 int count = ntohl (mp->count);
15406 vl_api_fib_path_t *fp;
15410 "table-id %d, prefix %U/%d\n",
15411 ntohl (mp->table_id), format_ip6_address, mp->address,
15412 mp->address_length);
15414 for (i = 0; i < count; i++)
15416 if (fp->afi == IP46_TYPE_IP6)
15418 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15419 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15420 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15421 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15422 format_ip6_address, fp->next_hop);
15423 else if (fp->afi == IP46_TYPE_IP4)
15425 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15426 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15427 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15428 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15429 format_ip4_address, fp->next_hop);
15434 static void vl_api_ip6_fib_details_t_handler_json
15435 (vl_api_ip6_fib_details_t * mp)
15437 vat_main_t *vam = &vat_main;
15438 int count = ntohl (mp->count);
15439 vat_json_node_t *node = NULL;
15440 struct in_addr ip4;
15441 struct in6_addr ip6;
15442 vl_api_fib_path_t *fp;
15445 if (VAT_JSON_ARRAY != vam->json_tree.type)
15447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15448 vat_json_init_array (&vam->json_tree);
15450 node = vat_json_array_add (&vam->json_tree);
15452 vat_json_init_object (node);
15453 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15454 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15455 vat_json_object_add_ip6 (node, "prefix", ip6);
15456 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15457 vat_json_object_add_uint (node, "path_count", count);
15459 for (i = 0; i < count; i++)
15461 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15462 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15463 vat_json_object_add_uint (node, "is_local", fp->is_local);
15464 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15465 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15466 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15467 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15468 if (fp->afi == IP46_TYPE_IP4)
15470 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15471 vat_json_object_add_ip4 (node, "next_hop", ip4);
15473 else if (fp->afi == IP46_TYPE_IP6)
15475 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15476 vat_json_object_add_ip6 (node, "next_hop", ip6);
15482 api_ip6_fib_dump (vat_main_t * vam)
15484 vl_api_ip6_fib_dump_t *mp;
15487 M (IP6_FIB_DUMP, ip6_fib_dump);
15490 /* Use a control ping for synchronization */
15492 vl_api_control_ping_t *mp;
15493 M (CONTROL_PING, control_ping);
15500 api_classify_table_ids (vat_main_t * vam)
15502 vl_api_classify_table_ids_t *mp;
15505 /* Construct the API message */
15506 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15516 api_classify_table_by_interface (vat_main_t * vam)
15518 unformat_input_t *input = vam->input;
15519 vl_api_classify_table_by_interface_t *mp;
15522 u32 sw_if_index = ~0;
15523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15525 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15527 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15532 if (sw_if_index == ~0)
15534 errmsg ("missing interface name or sw_if_index\n");
15538 /* Construct the API message */
15539 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15541 mp->sw_if_index = ntohl (sw_if_index);
15550 api_classify_table_info (vat_main_t * vam)
15552 unformat_input_t *input = vam->input;
15553 vl_api_classify_table_info_t *mp;
15557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15559 if (unformat (input, "table_id %d", &table_id))
15564 if (table_id == ~0)
15566 errmsg ("missing table id\n");
15570 /* Construct the API message */
15571 M (CLASSIFY_TABLE_INFO, classify_table_info);
15573 mp->table_id = ntohl (table_id);
15582 api_classify_session_dump (vat_main_t * vam)
15584 unformat_input_t *input = vam->input;
15585 vl_api_classify_session_dump_t *mp;
15589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15591 if (unformat (input, "table_id %d", &table_id))
15596 if (table_id == ~0)
15598 errmsg ("missing table id\n");
15602 /* Construct the API message */
15603 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15605 mp->table_id = ntohl (table_id);
15608 /* Use a control ping for synchronization */
15610 vl_api_control_ping_t *mp;
15611 M (CONTROL_PING, control_ping);
15620 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15622 vat_main_t *vam = &vat_main;
15624 fformat (vam->ofp, "collector_address %U, collector_port %d, "
15625 "src_address %U, vrf_id %d, path_mtu %u, "
15626 "template_interval %u, udp_checksum %d\n",
15627 format_ip4_address, mp->collector_address,
15628 ntohs (mp->collector_port),
15629 format_ip4_address, mp->src_address,
15630 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15631 ntohl (mp->template_interval), mp->udp_checksum);
15634 vam->result_ready = 1;
15638 vl_api_ipfix_exporter_details_t_handler_json
15639 (vl_api_ipfix_exporter_details_t * mp)
15641 vat_main_t *vam = &vat_main;
15642 vat_json_node_t node;
15643 struct in_addr collector_address;
15644 struct in_addr src_address;
15646 vat_json_init_object (&node);
15647 clib_memcpy (&collector_address, &mp->collector_address,
15648 sizeof (collector_address));
15649 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15650 vat_json_object_add_uint (&node, "collector_port",
15651 ntohs (mp->collector_port));
15652 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15653 vat_json_object_add_ip4 (&node, "src_address", src_address);
15654 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15655 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15656 vat_json_object_add_uint (&node, "template_interval",
15657 ntohl (mp->template_interval));
15658 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15660 vat_json_print (vam->ofp, &node);
15661 vat_json_free (&node);
15663 vam->result_ready = 1;
15667 api_ipfix_exporter_dump (vat_main_t * vam)
15669 vl_api_ipfix_exporter_dump_t *mp;
15672 /* Construct the API message */
15673 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15683 api_ipfix_classify_stream_dump (vat_main_t * vam)
15685 vl_api_ipfix_classify_stream_dump_t *mp;
15688 /* Construct the API message */
15689 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15699 vl_api_ipfix_classify_stream_details_t_handler
15700 (vl_api_ipfix_classify_stream_details_t * mp)
15702 vat_main_t *vam = &vat_main;
15703 fformat (vam->ofp, "domain_id %d, src_port %d\n",
15704 ntohl (mp->domain_id), ntohs (mp->src_port));
15706 vam->result_ready = 1;
15710 vl_api_ipfix_classify_stream_details_t_handler_json
15711 (vl_api_ipfix_classify_stream_details_t * mp)
15713 vat_main_t *vam = &vat_main;
15714 vat_json_node_t node;
15716 vat_json_init_object (&node);
15717 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15718 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15720 vat_json_print (vam->ofp, &node);
15721 vat_json_free (&node);
15723 vam->result_ready = 1;
15727 api_ipfix_classify_table_dump (vat_main_t * vam)
15729 vl_api_ipfix_classify_table_dump_t *mp;
15732 if (!vam->json_output)
15734 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
15735 "transport_protocol");
15738 /* Construct the API message */
15739 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15744 /* Use a control ping for synchronization */
15746 vl_api_control_ping_t *mp;
15747 M (CONTROL_PING, control_ping);
15754 vl_api_ipfix_classify_table_details_t_handler
15755 (vl_api_ipfix_classify_table_details_t * mp)
15757 vat_main_t *vam = &vat_main;
15758 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
15759 mp->transport_protocol);
15763 vl_api_ipfix_classify_table_details_t_handler_json
15764 (vl_api_ipfix_classify_table_details_t * mp)
15766 vat_json_node_t *node = NULL;
15767 vat_main_t *vam = &vat_main;
15769 if (VAT_JSON_ARRAY != vam->json_tree.type)
15771 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15772 vat_json_init_array (&vam->json_tree);
15775 node = vat_json_array_add (&vam->json_tree);
15776 vat_json_init_object (node);
15778 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15779 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15780 vat_json_object_add_uint (node, "transport_protocol",
15781 mp->transport_protocol);
15785 api_sw_interface_span_enable_disable (vat_main_t * vam)
15787 unformat_input_t *i = vam->input;
15788 vl_api_sw_interface_span_enable_disable_t *mp;
15790 u32 src_sw_if_index = ~0;
15791 u32 dst_sw_if_index = ~0;
15794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15796 if (unformat (i, "src %U", unformat_sw_if_index, vam, &src_sw_if_index))
15798 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15802 (i, "dst %U", unformat_sw_if_index, vam, &dst_sw_if_index))
15804 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15806 else if (unformat (i, "disable"))
15812 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
15814 mp->sw_if_index_from = htonl (src_sw_if_index);
15815 mp->sw_if_index_to = htonl (dst_sw_if_index);
15816 mp->enable = enable;
15825 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
15828 vat_main_t *vam = &vat_main;
15830 fformat (vam->ofp, "%u => %u\n",
15831 ntohl (mp->sw_if_index_from), ntohl (mp->sw_if_index_to));
15835 vl_api_sw_interface_span_details_t_handler_json
15836 (vl_api_sw_interface_span_details_t * mp)
15838 vat_main_t *vam = &vat_main;
15839 vat_json_node_t *node = NULL;
15841 if (VAT_JSON_ARRAY != vam->json_tree.type)
15843 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15844 vat_json_init_array (&vam->json_tree);
15846 node = vat_json_array_add (&vam->json_tree);
15848 vat_json_init_object (node);
15849 vat_json_object_add_uint (node, "src-if-index",
15850 ntohl (mp->sw_if_index_from));
15851 vat_json_object_add_uint (node, "dst-if-index", ntohl (mp->sw_if_index_to));
15855 api_sw_interface_span_dump (vat_main_t * vam)
15857 vl_api_sw_interface_span_dump_t *mp;
15860 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
15863 /* Use a control ping for synchronization */
15865 vl_api_control_ping_t *mp;
15866 M (CONTROL_PING, control_ping);
15873 api_pg_create_interface (vat_main_t * vam)
15875 unformat_input_t *input = vam->input;
15876 vl_api_pg_create_interface_t *mp;
15880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15882 if (unformat (input, "if_id %d", &if_id))
15889 errmsg ("missing pg interface index\n");
15893 /* Construct the API message */
15894 M (PG_CREATE_INTERFACE, pg_create_interface);
15896 mp->interface_id = ntohl (if_id);
15905 api_pg_capture (vat_main_t * vam)
15907 unformat_input_t *input = vam->input;
15908 vl_api_pg_capture_t *mp;
15914 u8 pcap_file_set = 0;
15916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15918 if (unformat (input, "if_id %d", &if_id))
15920 else if (unformat (input, "pcap %s", &pcap_file))
15922 else if (unformat (input, "count %d", &count))
15924 else if (unformat (input, "disable"))
15931 errmsg ("missing pg interface index\n");
15934 if (pcap_file_set > 0)
15936 if (vec_len (pcap_file) > 255)
15938 errmsg ("pcap file name is too long\n");
15943 u32 name_len = vec_len (pcap_file);
15944 /* Construct the API message */
15945 M (PG_CAPTURE, pg_capture);
15947 mp->interface_id = ntohl (if_id);
15948 mp->is_enabled = enable;
15949 mp->count = ntohl (count);
15950 mp->pcap_name_length = ntohl (name_len);
15951 if (pcap_file_set != 0)
15953 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
15955 vec_free (pcap_file);
15964 api_pg_enable_disable (vat_main_t * vam)
15966 unformat_input_t *input = vam->input;
15967 vl_api_pg_enable_disable_t *mp;
15971 u8 stream_name_set = 0;
15972 u8 *stream_name = 0;
15973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15975 if (unformat (input, "stream %s", &stream_name))
15976 stream_name_set = 1;
15977 else if (unformat (input, "disable"))
15983 if (stream_name_set > 0)
15985 if (vec_len (stream_name) > 255)
15987 errmsg ("stream name too long\n");
15992 u32 name_len = vec_len (stream_name);
15993 /* Construct the API message */
15994 M (PG_ENABLE_DISABLE, pg_enable_disable);
15996 mp->is_enabled = enable;
15997 if (stream_name_set != 0)
15999 mp->stream_name_length = ntohl (name_len);
16000 clib_memcpy (mp->stream_name, stream_name, name_len);
16002 vec_free (stream_name);
16011 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16013 unformat_input_t *input = vam->input;
16014 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16017 u16 *low_ports = 0;
16018 u16 *high_ports = 0;
16021 ip4_address_t ip4_addr;
16022 ip6_address_t ip6_addr;
16030 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16032 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16038 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16043 else if (unformat (input, "vrf %d", &vrf_id))
16045 else if (unformat (input, "del"))
16047 else if (unformat (input, "port %d", &tmp))
16049 if (tmp == 0 || tmp > 65535)
16051 errmsg ("port %d out of range", tmp);
16055 this_hi = this_low + 1;
16056 vec_add1 (low_ports, this_low);
16057 vec_add1 (high_ports, this_hi);
16059 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16061 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16063 errmsg ("incorrect range parameters\n");
16067 /* Note: in debug CLI +1 is added to high before
16068 passing to real fn that does "the work"
16069 (ip_source_and_port_range_check_add_del).
16070 This fn is a wrapper around the binary API fn a
16071 control plane will call, which expects this increment
16072 to have occurred. Hence letting the binary API control
16073 plane fn do the increment for consistency between VAT
16074 and other control planes.
16077 vec_add1 (low_ports, this_low);
16078 vec_add1 (high_ports, this_hi);
16084 if (prefix_set == 0)
16086 errmsg ("<address>/<mask> not specified\n");
16092 errmsg ("VRF ID required, not specified\n");
16099 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
16103 if (vec_len (low_ports) == 0)
16105 errmsg ("At least one port or port range required\n");
16109 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16110 ip_source_and_port_range_check_add_del);
16112 mp->is_add = is_add;
16117 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16122 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16125 mp->mask_length = length;
16126 mp->number_of_ranges = vec_len (low_ports);
16128 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16129 vec_free (low_ports);
16131 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16132 vec_free (high_ports);
16134 mp->vrf_id = ntohl (vrf_id);
16143 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16145 unformat_input_t *input = vam->input;
16146 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16148 u32 sw_if_index = ~0;
16150 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16151 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16154 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16156 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
16158 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16160 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16162 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16164 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16166 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16168 else if (unformat (input, "del"))
16174 if (sw_if_index == ~0)
16176 errmsg ("Interface required but not specified\n");
16182 errmsg ("VRF ID required but not specified\n");
16186 if (tcp_out_vrf_id == 0
16187 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16190 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
16194 /* Construct the API message */
16195 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16196 ip_source_and_port_range_check_interface_add_del);
16198 mp->sw_if_index = ntohl (sw_if_index);
16199 mp->is_add = is_add;
16200 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16201 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16202 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16203 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16208 /* Wait for a reply... */
16213 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16215 unformat_input_t *i = vam->input;
16216 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16218 u32 local_sa_id = 0;
16219 u32 remote_sa_id = 0;
16220 ip4_address_t src_address;
16221 ip4_address_t dst_address;
16224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16226 if (unformat (i, "local_sa %d", &local_sa_id))
16228 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16230 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16232 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16234 else if (unformat (i, "del"))
16238 clib_warning ("parse error '%U'", format_unformat_error, i);
16243 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16245 mp->local_sa_id = ntohl (local_sa_id);
16246 mp->remote_sa_id = ntohl (remote_sa_id);
16247 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16248 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16249 mp->is_add = is_add;
16258 api_punt (vat_main_t * vam)
16260 unformat_input_t *i = vam->input;
16268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16270 if (unformat (i, "ip %d", &ipv))
16272 else if (unformat (i, "protocol %d", &protocol))
16274 else if (unformat (i, "port %d", &port))
16276 else if (unformat (i, "del"))
16280 clib_warning ("parse error '%U'", format_unformat_error, i);
16287 mp->is_add = (u8) is_add;
16288 mp->ipv = (u8) ipv;
16289 mp->l4_protocol = (u8) protocol;
16290 mp->l4_port = htons ((u16) port);
16298 static void vl_api_ipsec_gre_tunnel_details_t_handler
16299 (vl_api_ipsec_gre_tunnel_details_t * mp)
16301 vat_main_t *vam = &vat_main;
16303 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
16304 ntohl (mp->sw_if_index),
16305 format_ip4_address, &mp->src_address,
16306 format_ip4_address, &mp->dst_address,
16307 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16310 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16311 (vl_api_ipsec_gre_tunnel_details_t * mp)
16313 vat_main_t *vam = &vat_main;
16314 vat_json_node_t *node = NULL;
16315 struct in_addr ip4;
16317 if (VAT_JSON_ARRAY != vam->json_tree.type)
16319 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16320 vat_json_init_array (&vam->json_tree);
16322 node = vat_json_array_add (&vam->json_tree);
16324 vat_json_init_object (node);
16325 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16326 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16327 vat_json_object_add_ip4 (node, "src_address", ip4);
16328 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16329 vat_json_object_add_ip4 (node, "dst_address", ip4);
16330 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16331 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16335 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16337 unformat_input_t *i = vam->input;
16338 vl_api_ipsec_gre_tunnel_dump_t *mp;
16341 u8 sw_if_index_set = 0;
16343 /* Parse args required to build the message */
16344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16346 if (unformat (i, "sw_if_index %d", &sw_if_index))
16347 sw_if_index_set = 1;
16352 if (sw_if_index_set == 0)
16357 if (!vam->json_output)
16359 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
16360 "sw_if_index", "src_address", "dst_address",
16361 "local_sa_id", "remote_sa_id");
16364 /* Get list of gre-tunnel interfaces */
16365 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16367 mp->sw_if_index = htonl (sw_if_index);
16371 /* Use a control ping for synchronization */
16373 vl_api_control_ping_t *mp;
16374 M (CONTROL_PING, control_ping);
16381 api_delete_subif (vat_main_t * vam)
16383 unformat_input_t *i = vam->input;
16384 vl_api_delete_subif_t *mp;
16386 u32 sw_if_index = ~0;
16388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16390 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16392 if (unformat (i, "sw_if_index %d", &sw_if_index))
16398 if (sw_if_index == ~0)
16400 errmsg ("missing sw_if_index\n");
16404 /* Construct the API message */
16405 M (DELETE_SUBIF, delete_subif);
16406 mp->sw_if_index = ntohl (sw_if_index);
16412 #define foreach_pbb_vtr_op \
16413 _("disable", L2_VTR_DISABLED) \
16414 _("pop", L2_VTR_POP_2) \
16415 _("push", L2_VTR_PUSH_2)
16418 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16420 unformat_input_t *i = vam->input;
16421 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16423 u32 sw_if_index = ~0, vtr_op = ~0;
16424 u16 outer_tag = ~0;
16425 u8 dmac[6], smac[6];
16426 u8 dmac_set = 0, smac_set = 0;
16431 /* Shut up coverity */
16432 memset (dmac, 0, sizeof (dmac));
16433 memset (smac, 0, sizeof (smac));
16435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16437 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16441 else if (unformat (i, "vtr_op %d", &vtr_op))
16443 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16446 else if (unformat (i, "translate_pbb_stag"))
16448 if (unformat (i, "%d", &tmp))
16450 vtr_op = L2_VTR_TRANSLATE_2_1;
16456 ("translate_pbb_stag operation requires outer tag definition\n");
16460 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16462 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16464 else if (unformat (i, "sid %d", &sid))
16466 else if (unformat (i, "vlanid %d", &tmp))
16470 clib_warning ("parse error '%U'", format_unformat_error, i);
16475 if ((sw_if_index == ~0) || (vtr_op == ~0))
16477 errmsg ("missing sw_if_index or vtr operation\n");
16480 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16481 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16484 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
16488 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16489 mp->sw_if_index = ntohl (sw_if_index);
16490 mp->vtr_op = ntohl (vtr_op);
16491 mp->outer_tag = ntohs (outer_tag);
16492 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16493 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16494 mp->b_vlanid = ntohs (vlanid);
16495 mp->i_sid = ntohl (sid);
16504 api_flow_classify_set_interface (vat_main_t * vam)
16506 unformat_input_t *i = vam->input;
16507 vl_api_flow_classify_set_interface_t *mp;
16510 int sw_if_index_set;
16511 u32 ip4_table_index = ~0;
16512 u32 ip6_table_index = ~0;
16515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16517 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16518 sw_if_index_set = 1;
16519 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16520 sw_if_index_set = 1;
16521 else if (unformat (i, "del"))
16523 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16525 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16529 clib_warning ("parse error '%U'", format_unformat_error, i);
16534 if (sw_if_index_set == 0)
16536 errmsg ("missing interface name or sw_if_index\n");
16540 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16542 mp->sw_if_index = ntohl (sw_if_index);
16543 mp->ip4_table_index = ntohl (ip4_table_index);
16544 mp->ip6_table_index = ntohl (ip6_table_index);
16545 mp->is_add = is_add;
16554 api_flow_classify_dump (vat_main_t * vam)
16556 unformat_input_t *i = vam->input;
16557 vl_api_flow_classify_dump_t *mp;
16559 u8 type = FLOW_CLASSIFY_N_TABLES;
16561 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16565 errmsg ("classify table type must be specified\n");
16569 if (!vam->json_output)
16571 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
16574 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16579 /* Use a control ping for synchronization */
16581 vl_api_control_ping_t *mp;
16582 M (CONTROL_PING, control_ping);
16585 /* Wait for a reply... */
16593 api_feature_enable_disable (vat_main_t * vam)
16595 unformat_input_t *i = vam->input;
16596 vl_api_feature_enable_disable_t *mp;
16599 u8 *feature_name = 0;
16600 u32 sw_if_index = ~0;
16603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16605 if (unformat (i, "arc_name %s", &arc_name))
16607 else if (unformat (i, "feature_name %s", &feature_name))
16609 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16611 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16613 else if (unformat (i, "disable"))
16621 errmsg ("missing arc name\n");
16624 if (vec_len (arc_name) > 63)
16626 errmsg ("arc name too long\n");
16629 if (feature_name == 0)
16631 errmsg ("missing feature name\n");
16634 if (vec_len (feature_name) > 63)
16636 errmsg ("feature name too long\n");
16639 if (sw_if_index == ~0)
16641 errmsg ("missing interface name or sw_if_index\n");
16645 /* Construct the API message */
16646 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16647 mp->sw_if_index = ntohl (sw_if_index);
16648 mp->enable = enable;
16649 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16650 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16651 vec_free (arc_name);
16652 vec_free (feature_name);
16659 api_sw_interface_tag_add_del (vat_main_t * vam)
16661 unformat_input_t *i = vam->input;
16662 vl_api_sw_interface_tag_add_del_t *mp;
16664 u32 sw_if_index = ~0;
16668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16670 if (unformat (i, "tag %s", &tag))
16672 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16676 else if (unformat (i, "del"))
16682 if (sw_if_index == ~0)
16684 errmsg ("missing interface name or sw_if_index\n");
16688 if (enable && (tag == 0))
16690 errmsg ("no tag specified\n");
16694 /* Construct the API message */
16695 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16696 mp->sw_if_index = ntohl (sw_if_index);
16697 mp->is_add = enable;
16699 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16706 static void vl_api_l2_xconnect_details_t_handler
16707 (vl_api_l2_xconnect_details_t * mp)
16709 vat_main_t *vam = &vat_main;
16711 fformat (vam->ofp, "%15d%15d\n",
16712 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16715 static void vl_api_l2_xconnect_details_t_handler_json
16716 (vl_api_l2_xconnect_details_t * mp)
16718 vat_main_t *vam = &vat_main;
16719 vat_json_node_t *node = NULL;
16721 if (VAT_JSON_ARRAY != vam->json_tree.type)
16723 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16724 vat_json_init_array (&vam->json_tree);
16726 node = vat_json_array_add (&vam->json_tree);
16728 vat_json_init_object (node);
16729 vat_json_object_add_uint (node, "rx_sw_if_index",
16730 ntohl (mp->rx_sw_if_index));
16731 vat_json_object_add_uint (node, "tx_sw_if_index",
16732 ntohl (mp->tx_sw_if_index));
16736 api_l2_xconnect_dump (vat_main_t * vam)
16738 vl_api_l2_xconnect_dump_t *mp;
16741 if (!vam->json_output)
16743 fformat (vam->ofp, "%15s%15s\n", "rx_sw_if_index", "tx_sw_if_index");
16746 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
16750 /* Use a control ping for synchronization */
16752 vl_api_control_ping_t *mp;
16753 M (CONTROL_PING, control_ping);
16760 api_sw_interface_set_mtu (vat_main_t * vam)
16762 unformat_input_t *i = vam->input;
16763 vl_api_sw_interface_set_mtu_t *mp;
16765 u32 sw_if_index = ~0;
16768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16770 if (unformat (i, "mtu %d", &mtu))
16772 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16774 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16780 if (sw_if_index == ~0)
16782 errmsg ("missing interface name or sw_if_index\n");
16788 errmsg ("no mtu specified\n");
16792 /* Construct the API message */
16793 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
16794 mp->sw_if_index = ntohl (sw_if_index);
16795 mp->mtu = ntohs ((u16) mtu);
16803 q_or_quit (vat_main_t * vam)
16805 longjmp (vam->jump_buf, 1);
16806 return 0; /* not so much */
16810 q (vat_main_t * vam)
16812 return q_or_quit (vam);
16816 quit (vat_main_t * vam)
16818 return q_or_quit (vam);
16822 comment (vat_main_t * vam)
16828 cmd_cmp (void *a1, void *a2)
16833 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
16837 help (vat_main_t * vam)
16842 unformat_input_t *i = vam->input;
16845 if (unformat (i, "%s", &name))
16849 vec_add1 (name, 0);
16851 hs = hash_get_mem (vam->help_by_name, name);
16853 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
16855 fformat (vam->ofp, "No such msg / command '%s'\n", name);
16860 fformat (vam->ofp, "Help is available for the following:\n");
16863 hash_foreach_pair (p, vam->function_by_name,
16865 vec_add1 (cmds, (u8 *)(p->key));
16869 vec_sort_with_function (cmds, cmd_cmp);
16871 for (j = 0; j < vec_len (cmds); j++)
16872 fformat (vam->ofp, "%s\n", cmds[j]);
16879 set (vat_main_t * vam)
16881 u8 *name = 0, *value = 0;
16882 unformat_input_t *i = vam->input;
16884 if (unformat (i, "%s", &name))
16886 /* The input buffer is a vector, not a string. */
16887 value = vec_dup (i->buffer);
16888 vec_delete (value, i->index, 0);
16889 /* Almost certainly has a trailing newline */
16890 if (value[vec_len (value) - 1] == '\n')
16891 value[vec_len (value) - 1] = 0;
16892 /* Make sure it's a proper string, one way or the other */
16893 vec_add1 (value, 0);
16894 (void) clib_macro_set_value (&vam->macro_main,
16895 (char *) name, (char *) value);
16898 errmsg ("usage: set <name> <value>\n");
16906 unset (vat_main_t * vam)
16910 if (unformat (vam->input, "%s", &name))
16911 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
16912 errmsg ("unset: %s wasn't set\n", name);
16925 macro_sort_cmp (void *a1, void *a2)
16927 macro_sort_t *s1 = a1;
16928 macro_sort_t *s2 = a2;
16930 return strcmp ((char *) (s1->name), (char *) (s2->name));
16934 dump_macro_table (vat_main_t * vam)
16936 macro_sort_t *sort_me = 0, *sm;
16941 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
16943 vec_add2 (sort_me, sm, 1);
16944 sm->name = (u8 *)(p->key);
16945 sm->value = (u8 *) (p->value[0]);
16949 vec_sort_with_function (sort_me, macro_sort_cmp);
16951 if (vec_len (sort_me))
16952 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
16954 fformat (vam->ofp, "The macro table is empty...\n");
16956 for (i = 0; i < vec_len (sort_me); i++)
16957 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
16962 dump_node_table (vat_main_t * vam)
16965 vlib_node_t *node, *next_node;
16967 if (vec_len (vam->graph_nodes) == 0)
16969 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16973 for (i = 0; i < vec_len (vam->graph_nodes); i++)
16975 node = vam->graph_nodes[i];
16976 fformat (vam->ofp, "[%d] %s\n", i, node->name);
16977 for (j = 0; j < vec_len (node->next_nodes); j++)
16979 if (node->next_nodes[j] != ~0)
16981 next_node = vam->graph_nodes[node->next_nodes[j]];
16982 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16990 value_sort_cmp (void *a1, void *a2)
16992 name_sort_t *n1 = a1;
16993 name_sort_t *n2 = a2;
16995 if (n1->value < n2->value)
16997 if (n1->value > n2->value)
17004 dump_msg_api_table (vat_main_t * vam)
17006 api_main_t *am = &api_main;
17007 name_sort_t *nses = 0, *ns;
17012 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17014 vec_add2 (nses, ns, 1);
17015 ns->name = (u8 *)(hp->key);
17016 ns->value = (u32) hp->value[0];
17020 vec_sort_with_function (nses, value_sort_cmp);
17022 for (i = 0; i < vec_len (nses); i++)
17023 fformat (vam->ofp, " [%d]: %s\n", nses[i].value, nses[i].name);
17029 get_msg_id (vat_main_t * vam)
17034 if (unformat (vam->input, "%s", &name_and_crc))
17036 message_index = vl_api_get_msg_index (name_and_crc);
17037 if (message_index == ~0)
17039 fformat (vam->ofp, " '%s' not found\n", name_and_crc);
17042 fformat (vam->ofp, " '%s' has message index %d\n",
17043 name_and_crc, message_index);
17046 errmsg ("name_and_crc required...\n");
17051 search_node_table (vat_main_t * vam)
17053 unformat_input_t *line_input = vam->input;
17056 vlib_node_t *node, *next_node;
17059 if (vam->graph_node_index_by_name == 0)
17061 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
17065 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17067 if (unformat (line_input, "%s", &node_to_find))
17069 vec_add1 (node_to_find, 0);
17070 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17073 fformat (vam->ofp, "%s not found...\n", node_to_find);
17076 node = vam->graph_nodes[p[0]];
17077 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
17078 for (j = 0; j < vec_len (node->next_nodes); j++)
17080 if (node->next_nodes[j] != ~0)
17082 next_node = vam->graph_nodes[node->next_nodes[j]];
17083 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
17090 clib_warning ("parse error '%U'", format_unformat_error,
17096 vec_free (node_to_find);
17105 script (vat_main_t * vam)
17108 char *save_current_file;
17109 unformat_input_t save_input;
17110 jmp_buf save_jump_buf;
17111 u32 save_line_number;
17113 FILE *new_fp, *save_ifp;
17115 if (unformat (vam->input, "%s", &s))
17117 new_fp = fopen ((char *) s, "r");
17120 errmsg ("Couldn't open script file %s\n", s);
17127 errmsg ("Missing script name\n");
17131 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17132 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17133 save_ifp = vam->ifp;
17134 save_line_number = vam->input_line_number;
17135 save_current_file = (char *) vam->current_file;
17137 vam->input_line_number = 0;
17139 vam->current_file = s;
17142 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17143 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17144 vam->ifp = save_ifp;
17145 vam->input_line_number = save_line_number;
17146 vam->current_file = (u8 *) save_current_file;
17153 echo (vat_main_t * vam)
17155 fformat (vam->ofp, "%v", vam->input->buffer);
17159 /* List of API message constructors, CLI names map to api_xxx */
17160 #define foreach_vpe_api_msg \
17161 _(create_loopback,"[mac <mac-addr>]") \
17162 _(sw_interface_dump,"") \
17163 _(sw_interface_set_flags, \
17164 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17165 _(sw_interface_add_del_address, \
17166 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17167 _(sw_interface_set_table, \
17168 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17169 _(sw_interface_set_mpls_enable, \
17170 "<intfc> | sw_if_index [disable | dis]") \
17171 _(sw_interface_set_vpath, \
17172 "<intfc> | sw_if_index <id> enable | disable") \
17173 _(sw_interface_set_vxlan_bypass, \
17174 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17175 _(sw_interface_set_l2_xconnect, \
17176 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17177 "enable | disable") \
17178 _(sw_interface_set_l2_bridge, \
17179 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17180 "[shg <split-horizon-group>] [bvi]\n" \
17181 "enable | disable") \
17182 _(sw_interface_set_dpdk_hqos_pipe, \
17183 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17184 "profile <profile-id>\n") \
17185 _(sw_interface_set_dpdk_hqos_subport, \
17186 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17187 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17188 _(sw_interface_set_dpdk_hqos_tctbl, \
17189 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
17190 _(bridge_domain_add_del, \
17191 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
17192 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17194 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17196 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17198 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17200 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17202 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17204 "<vpp-if-name> | sw_if_index <id>") \
17205 _(sw_interface_tap_dump, "") \
17206 _(ip_add_del_route, \
17207 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17208 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17209 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17210 "[multipath] [count <n>]") \
17211 _(mpls_route_add_del, \
17212 "<label> <eos> via <addr> [table-id <n>]\n" \
17213 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17214 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17215 "[multipath] [count <n>]") \
17216 _(mpls_ip_bind_unbind, \
17217 "<label> <addr/len>") \
17218 _(mpls_tunnel_add_del, \
17219 " via <addr> [table-id <n>]\n" \
17220 "sw_if_index <id>] [l2] [del]") \
17221 _(proxy_arp_add_del, \
17222 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17223 _(proxy_arp_intfc_enable_disable, \
17224 "<intfc> | sw_if_index <id> enable | disable") \
17225 _(sw_interface_set_unnumbered, \
17226 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17227 _(ip_neighbor_add_del, \
17228 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17229 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17230 _(reset_vrf, "vrf <id> [ipv6]") \
17231 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17232 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17233 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17234 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17235 "[outer_vlan_id_any][inner_vlan_id_any]") \
17236 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17237 _(reset_fib, "vrf <n> [ipv6]") \
17238 _(dhcp_proxy_config, \
17239 "svr <v46-address> src <v46-address>\n" \
17240 "insert-cid <n> [del]") \
17241 _(dhcp_proxy_config_2, \
17242 "svr <v46-address> src <v46-address>\n" \
17243 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17244 _(dhcp_proxy_set_vss, \
17245 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17246 _(dhcp_client_config, \
17247 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17248 _(set_ip_flow_hash, \
17249 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17250 _(sw_interface_ip6_enable_disable, \
17251 "<intfc> | sw_if_index <id> enable | disable") \
17252 _(sw_interface_ip6_set_link_local_address, \
17253 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17254 _(sw_interface_ip6nd_ra_prefix, \
17255 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17256 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17257 "[nolink] [isno]") \
17258 _(sw_interface_ip6nd_ra_config, \
17259 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17260 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17261 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17262 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17263 _(l2_patch_add_del, \
17264 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17265 "enable | disable") \
17266 _(sr_tunnel_add_del, \
17267 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17268 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17269 "[policy <policy_name>]") \
17270 _(sr_policy_add_del, \
17271 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17272 _(sr_multicast_map_add_del, \
17273 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17274 _(classify_add_del_table, \
17275 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17276 " [del] mask <mask-value>\n" \
17277 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17278 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17279 _(classify_add_del_session, \
17280 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17281 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17282 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17283 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17284 _(classify_set_interface_ip_table, \
17285 "<intfc> | sw_if_index <nn> table <nn>") \
17286 _(classify_set_interface_l2_tables, \
17287 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17288 " [other-table <nn>]") \
17289 _(get_node_index, "node <node-name") \
17290 _(add_node_next, "node <node-name> next <next-node-name>") \
17291 _(l2tpv3_create_tunnel, \
17292 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17293 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
17294 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17295 _(l2tpv3_set_tunnel_cookies, \
17296 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17297 "[new_remote_cookie <nn>]\n") \
17298 _(l2tpv3_interface_enable_disable, \
17299 "<intfc> | sw_if_index <nn> enable | disable") \
17300 _(l2tpv3_set_lookup_key, \
17301 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17302 _(sw_if_l2tpv3_tunnel_dump, "") \
17303 _(vxlan_add_del_tunnel, \
17304 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17305 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17306 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17307 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17308 _(gre_add_del_tunnel, \
17309 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17310 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17311 _(l2_fib_clear_table, "") \
17312 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17313 _(l2_interface_vlan_tag_rewrite, \
17314 "<intfc> | sw_if_index <nn> \n" \
17315 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17316 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17317 _(create_vhost_user_if, \
17318 "socket <filename> [server] [renumber <dev_instance>] " \
17319 "[mac <mac_address>]") \
17320 _(modify_vhost_user_if, \
17321 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17322 "[server] [renumber <dev_instance>]") \
17323 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17324 _(sw_interface_vhost_user_dump, "") \
17325 _(show_version, "") \
17326 _(vxlan_gpe_add_del_tunnel, \
17327 "local <addr> remote <addr> vni <nn>\n" \
17328 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17329 "[next-ethernet] [next-nsh]\n") \
17330 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17331 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17332 _(interface_name_renumber, \
17333 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17334 _(input_acl_set_interface, \
17335 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17336 " [l2-table <nn>] [del]") \
17337 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17338 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17339 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17340 _(ip_dump, "ipv4 | ipv6") \
17341 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17342 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17344 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17345 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17346 " integ_alg <alg> integ_key <hex>") \
17347 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17348 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17349 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17350 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
17351 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17352 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17353 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17354 "(auth_data 0x<data> | auth_data <data>)") \
17355 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17356 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17357 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17358 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17359 "(local|remote)") \
17360 _(ikev2_set_local_key, "file <absolute_file_path>") \
17361 _(delete_loopback,"sw_if_index <nn>") \
17362 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17363 _(map_add_domain, \
17364 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17365 "ip6-src <ip6addr> " \
17366 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17367 _(map_del_domain, "index <n>") \
17368 _(map_add_del_rule, \
17369 "index <n> psid <n> dst <ip6addr> [del]") \
17370 _(map_domain_dump, "") \
17371 _(map_rule_dump, "index <map-domain>") \
17372 _(want_interface_events, "enable|disable") \
17373 _(want_stats,"enable|disable") \
17374 _(get_first_msg_id, "client <name>") \
17375 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17376 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17377 "fib-id <nn> [ip4][ip6][default]") \
17378 _(get_node_graph, " ") \
17379 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17380 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17381 _(ioam_disable, "") \
17382 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
17383 " sw_if_index <sw_if_index> p <priority> " \
17384 "w <weight>] [del]") \
17385 _(lisp_add_del_locator, "locator-set <locator_name> " \
17386 "iface <intf> | sw_if_index <sw_if_index> " \
17387 "p <priority> w <weight> [del]") \
17388 _(lisp_add_del_local_eid,"vni <vni> eid " \
17389 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17390 "locator-set <locator_name> [del]" \
17391 "[key-id sha1|sha256 secret-key <secret-key>]")\
17392 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
17393 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
17394 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17395 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17396 _(lisp_gpe_enable_disable, "enable|disable") \
17397 _(lisp_enable_disable, "enable|disable") \
17398 _(lisp_map_register_enable_disable, "enable|disable") \
17399 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17400 _(lisp_gpe_add_del_iface, "up|down") \
17401 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17403 "rloc <locator> p <prio> " \
17404 "w <weight> [rloc <loc> ... ] " \
17405 "action <action> [del-all]") \
17406 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17408 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17409 _(lisp_map_request_mode, "src-dst|dst-only") \
17410 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17411 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17412 _(lisp_locator_set_dump, "[local | remote]") \
17413 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17414 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17415 "[local] | [remote]") \
17416 _(lisp_eid_table_vni_dump, "") \
17417 _(lisp_eid_table_map_dump, "l2|l3") \
17418 _(lisp_gpe_tunnel_dump, "") \
17419 _(lisp_map_resolver_dump, "") \
17420 _(lisp_map_server_dump, "") \
17421 _(lisp_adjacencies_get, "vni <vni>") \
17422 _(show_lisp_rloc_probe_state, "") \
17423 _(show_lisp_map_register_state, "") \
17424 _(show_lisp_status, "") \
17425 _(lisp_get_map_request_itr_rlocs, "") \
17426 _(show_lisp_pitr, "") \
17427 _(show_lisp_map_request_mode, "") \
17428 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17429 _(af_packet_delete, "name <host interface name>") \
17430 _(policer_add_del, "name <policer name> <params> [del]") \
17431 _(policer_dump, "[name <policer name>]") \
17432 _(policer_classify_set_interface, \
17433 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17434 " [l2-table <nn>] [del]") \
17435 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17436 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17437 "[master|slave]") \
17438 _(netmap_delete, "name <interface name>") \
17439 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17440 _(mpls_fib_dump, "") \
17441 _(classify_table_ids, "") \
17442 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17443 _(classify_table_info, "table_id <nn>") \
17444 _(classify_session_dump, "table_id <nn>") \
17445 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17446 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17447 "[template_interval <nn>] [udp_checksum]") \
17448 _(ipfix_exporter_dump, "") \
17449 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17450 _(ipfix_classify_stream_dump, "") \
17451 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
17452 _(ipfix_classify_table_dump, "") \
17453 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [[dst <intfc> | dst_sw_if_index <id>] | disable]") \
17454 _(sw_interface_span_dump, "") \
17455 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17456 _(pg_create_interface, "if_id <nn>") \
17457 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17458 _(pg_enable_disable, "[stream <id>] disable") \
17459 _(ip_source_and_port_range_check_add_del, \
17460 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17461 _(ip_source_and_port_range_check_interface_add_del, \
17462 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17463 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17464 _(ipsec_gre_add_del_tunnel, \
17465 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17466 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17467 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17468 _(l2_interface_pbb_tag_rewrite, \
17469 "<intfc> | sw_if_index <nn> \n" \
17470 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17471 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17472 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17473 _(flow_classify_set_interface, \
17474 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17475 _(flow_classify_dump, "type [ip4|ip6]") \
17476 _(ip_fib_dump, "") \
17477 _(ip6_fib_dump, "") \
17478 _(feature_enable_disable, "arc_name <arc_name> " \
17479 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17480 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17482 _(l2_xconnect_dump, "") \
17483 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>")
17485 /* List of command functions, CLI names map directly to functions */
17486 #define foreach_cli_function \
17487 _(comment, "usage: comment <ignore-rest-of-line>") \
17488 _(dump_interface_table, "usage: dump_interface_table") \
17489 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17490 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17491 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17492 _(dump_stats_table, "usage: dump_stats_table") \
17493 _(dump_macro_table, "usage: dump_macro_table ") \
17494 _(dump_node_table, "usage: dump_node_table") \
17495 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17496 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17497 _(echo, "usage: echo <message>") \
17498 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17499 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17500 _(help, "usage: help") \
17501 _(q, "usage: quit") \
17502 _(quit, "usage: quit") \
17503 _(search_node_table, "usage: search_node_table <name>...") \
17504 _(set, "usage: set <variable-name> <value>") \
17505 _(script, "usage: script <file-name>") \
17506 _(unset, "usage: unset <variable-name>")
17509 static void vl_api_##n##_t_handler_uni \
17510 (vl_api_##n##_t * mp) \
17512 vat_main_t * vam = &vat_main; \
17513 if (vam->json_output) { \
17514 vl_api_##n##_t_handler_json(mp); \
17516 vl_api_##n##_t_handler(mp); \
17519 foreach_vpe_api_reply_msg;
17523 vat_api_hookup (vat_main_t * vam)
17526 vl_msg_api_set_handlers(VL_API_##N, #n, \
17527 vl_api_##n##_t_handler_uni, \
17529 vl_api_##n##_t_endian, \
17530 vl_api_##n##_t_print, \
17531 sizeof(vl_api_##n##_t), 1);
17532 foreach_vpe_api_reply_msg;
17535 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17537 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17539 vam->function_by_name = hash_create_string (0, sizeof (uword));
17541 vam->help_by_name = hash_create_string (0, sizeof (uword));
17543 /* API messages we can send */
17544 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17545 foreach_vpe_api_msg;
17549 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17550 foreach_vpe_api_msg;
17553 /* CLI functions */
17554 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17555 foreach_cli_function;
17559 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17560 foreach_cli_function;
17564 #undef vl_api_version
17565 #define vl_api_version(n,v) static u32 memory_api_version = v;
17566 #include <vlibmemory/vl_memory_api_h.h>
17567 #undef vl_api_version
17569 #undef vl_api_version
17570 #define vl_api_version(n,v) static u32 vnet_interface_api_version = v;
17571 #include <vnet/interface.api.h>
17572 #undef vl_api_version
17574 #undef vl_api_version
17575 #define vl_api_version(n,v) static u32 vpp_api_version = v;
17576 #include <vpp-api/vpe.api.h>
17577 #undef vl_api_version
17579 static u32 *api_versions[] = {
17580 &memory_api_version,
17581 &vnet_interface_api_version,
17586 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
17590 ASSERT (ARRAY_LEN (mp->api_versions) >= ARRAY_LEN (api_versions));
17593 * Send the API signatures. This bit of code must
17594 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
17597 for (i = 0; i < ARRAY_LEN (api_versions); i++)
17598 mp->api_versions[i] = clib_host_to_net_u32 (*api_versions[i]);
17602 * fd.io coding-style-patch-verification: ON
17605 * eval: (c-set-style "gnu")