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) \
3924 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
3925 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
3927 /* M: construct, but don't yet send a message */
3931 vam->result_ready = 0; \
3932 mp = vl_msg_api_alloc(sizeof(*mp)); \
3933 memset (mp, 0, sizeof (*mp)); \
3934 mp->_vl_msg_id = ntohs (VL_API_##T); \
3935 mp->client_index = vam->my_client_index; \
3940 vam->result_ready = 0; \
3941 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3942 memset (mp, 0, sizeof (*mp)); \
3943 mp->_vl_msg_id = ntohs (VL_API_##T); \
3944 mp->client_index = vam->my_client_index; \
3948 /* S: send a message */
3949 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3951 /* W: wait for results, with timeout */
3954 timeout = vat_time_now (vam) + 1.0; \
3956 while (vat_time_now (vam) < timeout) { \
3957 if (vam->result_ready == 1) { \
3958 return (vam->retval); \
3964 /* W2: wait for results, with timeout */
3967 timeout = vat_time_now (vam) + 1.0; \
3969 while (vat_time_now (vam) < timeout) { \
3970 if (vam->result_ready == 1) { \
3972 return (vam->retval); \
3985 #define STR_VTR_OP_CASE(op) \
3986 case L2_VTR_ ## op: \
3990 str_vtr_op (u32 vtr_op)
3994 STR_VTR_OP_CASE (DISABLED);
3995 STR_VTR_OP_CASE (PUSH_1);
3996 STR_VTR_OP_CASE (PUSH_2);
3997 STR_VTR_OP_CASE (POP_1);
3998 STR_VTR_OP_CASE (POP_2);
3999 STR_VTR_OP_CASE (TRANSLATE_1_1);
4000 STR_VTR_OP_CASE (TRANSLATE_1_2);
4001 STR_VTR_OP_CASE (TRANSLATE_2_1);
4002 STR_VTR_OP_CASE (TRANSLATE_2_2);
4009 dump_sub_interface_table (vat_main_t * vam)
4011 const sw_interface_subif_t *sub = NULL;
4013 if (vam->json_output)
4016 ("JSON output supported only for VPE API calls and dump_stats_table");
4021 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
4022 "Interface", "sw_if_index",
4023 "sub id", "dot1ad", "tags", "outer id",
4024 "inner id", "exact", "default", "outer any", "inner any");
4026 vec_foreach (sub, vam->sw_if_subif_table)
4029 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
4030 sub->interface_name,
4032 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4033 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4034 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4035 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4036 if (sub->vtr_op != L2_VTR_DISABLED)
4039 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4040 "tag1: %d tag2: %d ]\n",
4041 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4042 sub->vtr_tag1, sub->vtr_tag2);
4050 name_sort_cmp (void *a1, void *a2)
4052 name_sort_t *n1 = a1;
4053 name_sort_t *n2 = a2;
4055 return strcmp ((char *) n1->name, (char *) n2->name);
4059 dump_interface_table (vat_main_t * vam)
4062 name_sort_t *nses = 0, *ns;
4064 if (vam->json_output)
4067 ("JSON output supported only for VPE API calls and dump_stats_table");
4072 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4074 vec_add2 (nses, ns, 1);
4075 ns->name = (u8 *)(p->key);
4076 ns->value = (u32) p->value[0];
4080 vec_sort_with_function (nses, name_sort_cmp);
4082 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
4083 vec_foreach (ns, nses)
4085 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
4092 dump_ip_table (vat_main_t * vam, int is_ipv6)
4094 const ip_details_t *det = NULL;
4095 const ip_address_details_t *address = NULL;
4098 fformat (vam->ofp, "%-12s\n", "sw_if_index");
4100 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4107 fformat (vam->ofp, "%-12d\n", i);
4109 " %-30s%-13s\n", "Address", "Prefix length");
4114 vec_foreach (address, det->addr)
4118 is_ipv6 ? format_ip6_address : format_ip4_address,
4119 address->ip, address->prefix_length);
4127 dump_ipv4_table (vat_main_t * vam)
4129 if (vam->json_output)
4132 ("JSON output supported only for VPE API calls and dump_stats_table");
4136 return dump_ip_table (vam, 0);
4140 dump_ipv6_table (vat_main_t * vam)
4142 if (vam->json_output)
4145 ("JSON output supported only for VPE API calls and dump_stats_table");
4149 return dump_ip_table (vam, 1);
4153 counter_type_to_str (u8 counter_type, u8 is_combined)
4157 switch (counter_type)
4159 case VNET_INTERFACE_COUNTER_DROP:
4161 case VNET_INTERFACE_COUNTER_PUNT:
4163 case VNET_INTERFACE_COUNTER_IP4:
4165 case VNET_INTERFACE_COUNTER_IP6:
4167 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4169 case VNET_INTERFACE_COUNTER_RX_MISS:
4171 case VNET_INTERFACE_COUNTER_RX_ERROR:
4173 case VNET_INTERFACE_COUNTER_TX_ERROR:
4176 return "INVALID-COUNTER-TYPE";
4181 switch (counter_type)
4183 case VNET_INTERFACE_COUNTER_RX:
4185 case VNET_INTERFACE_COUNTER_TX:
4188 return "INVALID-COUNTER-TYPE";
4194 dump_stats_table (vat_main_t * vam)
4196 vat_json_node_t node;
4197 vat_json_node_t *msg_array;
4198 vat_json_node_t *msg;
4199 vat_json_node_t *counter_array;
4200 vat_json_node_t *counter;
4201 interface_counter_t c;
4203 ip4_fib_counter_t *c4;
4204 ip6_fib_counter_t *c6;
4207 if (!vam->json_output)
4209 clib_warning ("dump_stats_table supported only in JSON format");
4213 vat_json_init_object (&node);
4215 /* interface counters */
4216 msg_array = vat_json_object_add (&node, "interface_counters");
4217 vat_json_init_array (msg_array);
4218 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4220 msg = vat_json_array_add (msg_array);
4221 vat_json_init_object (msg);
4222 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4223 (u8 *) counter_type_to_str (i, 0));
4224 vat_json_object_add_int (msg, "is_combined", 0);
4225 counter_array = vat_json_object_add (msg, "data");
4226 vat_json_init_array (counter_array);
4227 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4229 packets = vam->simple_interface_counters[i][j];
4230 vat_json_array_add_uint (counter_array, packets);
4233 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4235 msg = vat_json_array_add (msg_array);
4236 vat_json_init_object (msg);
4237 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4238 (u8 *) counter_type_to_str (i, 1));
4239 vat_json_object_add_int (msg, "is_combined", 1);
4240 counter_array = vat_json_object_add (msg, "data");
4241 vat_json_init_array (counter_array);
4242 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4244 c = vam->combined_interface_counters[i][j];
4245 counter = vat_json_array_add (counter_array);
4246 vat_json_init_object (counter);
4247 vat_json_object_add_uint (counter, "packets", c.packets);
4248 vat_json_object_add_uint (counter, "bytes", c.bytes);
4252 /* ip4 fib counters */
4253 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4254 vat_json_init_array (msg_array);
4255 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4257 msg = vat_json_array_add (msg_array);
4258 vat_json_init_object (msg);
4259 vat_json_object_add_uint (msg, "vrf_id",
4260 vam->ip4_fib_counters_vrf_id_by_index[i]);
4261 counter_array = vat_json_object_add (msg, "c");
4262 vat_json_init_array (counter_array);
4263 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4265 counter = vat_json_array_add (counter_array);
4266 vat_json_init_object (counter);
4267 c4 = &vam->ip4_fib_counters[i][j];
4268 vat_json_object_add_ip4 (counter, "address", c4->address);
4269 vat_json_object_add_uint (counter, "address_length",
4270 c4->address_length);
4271 vat_json_object_add_uint (counter, "packets", c4->packets);
4272 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4276 /* ip6 fib counters */
4277 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4278 vat_json_init_array (msg_array);
4279 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4281 msg = vat_json_array_add (msg_array);
4282 vat_json_init_object (msg);
4283 vat_json_object_add_uint (msg, "vrf_id",
4284 vam->ip6_fib_counters_vrf_id_by_index[i]);
4285 counter_array = vat_json_object_add (msg, "c");
4286 vat_json_init_array (counter_array);
4287 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4289 counter = vat_json_array_add (counter_array);
4290 vat_json_init_object (counter);
4291 c6 = &vam->ip6_fib_counters[i][j];
4292 vat_json_object_add_ip6 (counter, "address", c6->address);
4293 vat_json_object_add_uint (counter, "address_length",
4294 c6->address_length);
4295 vat_json_object_add_uint (counter, "packets", c6->packets);
4296 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4300 vat_json_print (vam->ofp, &node);
4301 vat_json_free (&node);
4307 exec (vat_main_t * vam)
4309 api_main_t *am = &api_main;
4310 vl_api_cli_request_t *mp;
4314 unformat_input_t *i = vam->input;
4316 if (vec_len (i->buffer) == 0)
4319 if (vam->exec_mode == 0 && unformat (i, "mode"))
4324 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4331 M (CLI_REQUEST, cli_request);
4334 * Copy cmd into shared memory.
4335 * In order for the CLI command to work, it
4336 * must be a vector ending in \n, not a C-string ending
4339 pthread_mutex_lock (&am->vlib_rp->mutex);
4340 oldheap = svm_push_data_heap (am->vlib_rp);
4342 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4343 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4345 svm_pop_heap (oldheap);
4346 pthread_mutex_unlock (&am->vlib_rp->mutex);
4348 mp->cmd_in_shmem = (u64) cmd;
4350 timeout = vat_time_now (vam) + 10.0;
4352 while (vat_time_now (vam) < timeout)
4354 if (vam->result_ready == 1)
4357 if (vam->shmem_result != NULL)
4358 fformat (vam->ofp, "%s", vam->shmem_result);
4359 pthread_mutex_lock (&am->vlib_rp->mutex);
4360 oldheap = svm_push_data_heap (am->vlib_rp);
4362 free_me = (u8 *) vam->shmem_result;
4365 svm_pop_heap (oldheap);
4366 pthread_mutex_unlock (&am->vlib_rp->mutex);
4374 * Future replacement of exec() that passes CLI buffers directly in
4375 * the API messages instead of an additional shared memory area.
4378 exec_inband (vat_main_t * vam)
4380 vl_api_cli_inband_t *mp;
4382 unformat_input_t *i = vam->input;
4384 if (vec_len (i->buffer) == 0)
4387 if (vam->exec_mode == 0 && unformat (i, "mode"))
4392 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4399 * In order for the CLI command to work, it
4400 * must be a vector ending in \n, not a C-string ending
4403 u32 len = vec_len (vam->input->buffer);
4404 M2 (CLI_INBAND, cli_inband, len);
4405 clib_memcpy (mp->cmd, vam->input->buffer, len);
4406 mp->length = htonl (len);
4409 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4413 api_create_loopback (vat_main_t * vam)
4415 unformat_input_t *i = vam->input;
4416 vl_api_create_loopback_t *mp;
4421 memset (mac_address, 0, sizeof (mac_address));
4423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4425 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4431 /* Construct the API message */
4432 M (CREATE_LOOPBACK, create_loopback);
4434 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4441 api_delete_loopback (vat_main_t * vam)
4443 unformat_input_t *i = vam->input;
4444 vl_api_delete_loopback_t *mp;
4446 u32 sw_if_index = ~0;
4448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4450 if (unformat (i, "sw_if_index %d", &sw_if_index))
4456 if (sw_if_index == ~0)
4458 errmsg ("missing sw_if_index\n");
4462 /* Construct the API message */
4463 M (DELETE_LOOPBACK, delete_loopback);
4464 mp->sw_if_index = ntohl (sw_if_index);
4471 api_want_stats (vat_main_t * vam)
4473 unformat_input_t *i = vam->input;
4474 vl_api_want_stats_t *mp;
4478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4480 if (unformat (i, "enable"))
4482 else if (unformat (i, "disable"))
4490 errmsg ("missing enable|disable\n");
4494 M (WANT_STATS, want_stats);
4495 mp->enable_disable = enable;
4502 api_want_interface_events (vat_main_t * vam)
4504 unformat_input_t *i = vam->input;
4505 vl_api_want_interface_events_t *mp;
4509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4511 if (unformat (i, "enable"))
4513 else if (unformat (i, "disable"))
4521 errmsg ("missing enable|disable\n");
4525 M (WANT_INTERFACE_EVENTS, want_interface_events);
4526 mp->enable_disable = enable;
4528 vam->interface_event_display = enable;
4535 /* Note: non-static, called once to set up the initial intfc table */
4537 api_sw_interface_dump (vat_main_t * vam)
4539 vl_api_sw_interface_dump_t *mp;
4542 name_sort_t *nses = 0, *ns;
4543 sw_interface_subif_t *sub = NULL;
4545 /* Toss the old name table */
4547 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4549 vec_add2 (nses, ns, 1);
4550 ns->name = (u8 *)(p->key);
4551 ns->value = (u32) p->value[0];
4555 hash_free (vam->sw_if_index_by_interface_name);
4557 vec_foreach (ns, nses) vec_free (ns->name);
4561 vec_foreach (sub, vam->sw_if_subif_table)
4563 vec_free (sub->interface_name);
4565 vec_free (vam->sw_if_subif_table);
4567 /* recreate the interface name hash table */
4568 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4570 /* Get list of ethernets */
4571 M (SW_INTERFACE_DUMP, sw_interface_dump);
4572 mp->name_filter_valid = 1;
4573 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4576 /* and local / loopback interfaces */
4577 M (SW_INTERFACE_DUMP, sw_interface_dump);
4578 mp->name_filter_valid = 1;
4579 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4582 /* and packet-generator interfaces */
4583 M (SW_INTERFACE_DUMP, sw_interface_dump);
4584 mp->name_filter_valid = 1;
4585 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4588 /* and vxlan-gpe tunnel interfaces */
4589 M (SW_INTERFACE_DUMP, sw_interface_dump);
4590 mp->name_filter_valid = 1;
4591 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4592 sizeof (mp->name_filter) - 1);
4595 /* and vxlan tunnel interfaces */
4596 M (SW_INTERFACE_DUMP, sw_interface_dump);
4597 mp->name_filter_valid = 1;
4598 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4601 /* and host (af_packet) interfaces */
4602 M (SW_INTERFACE_DUMP, sw_interface_dump);
4603 mp->name_filter_valid = 1;
4604 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4607 /* and l2tpv3 tunnel interfaces */
4608 M (SW_INTERFACE_DUMP, sw_interface_dump);
4609 mp->name_filter_valid = 1;
4610 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4611 sizeof (mp->name_filter) - 1);
4614 /* and GRE tunnel interfaces */
4615 M (SW_INTERFACE_DUMP, sw_interface_dump);
4616 mp->name_filter_valid = 1;
4617 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4620 /* and LISP-GPE interfaces */
4621 M (SW_INTERFACE_DUMP, sw_interface_dump);
4622 mp->name_filter_valid = 1;
4623 strncpy ((char *) mp->name_filter, "lisp_gpe",
4624 sizeof (mp->name_filter) - 1);
4627 /* and IPSEC tunnel interfaces */
4628 M (SW_INTERFACE_DUMP, sw_interface_dump);
4629 mp->name_filter_valid = 1;
4630 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4633 /* Use a control ping for synchronization */
4635 vl_api_control_ping_t *mp;
4636 M (CONTROL_PING, control_ping);
4643 api_sw_interface_set_flags (vat_main_t * vam)
4645 unformat_input_t *i = vam->input;
4646 vl_api_sw_interface_set_flags_t *mp;
4649 u8 sw_if_index_set = 0;
4650 u8 admin_up = 0, link_up = 0;
4652 /* Parse args required to build the message */
4653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4655 if (unformat (i, "admin-up"))
4657 else if (unformat (i, "admin-down"))
4659 else if (unformat (i, "link-up"))
4661 else if (unformat (i, "link-down"))
4663 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4664 sw_if_index_set = 1;
4665 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4666 sw_if_index_set = 1;
4671 if (sw_if_index_set == 0)
4673 errmsg ("missing interface name or sw_if_index\n");
4677 /* Construct the API message */
4678 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4679 mp->sw_if_index = ntohl (sw_if_index);
4680 mp->admin_up_down = admin_up;
4681 mp->link_up_down = link_up;
4686 /* Wait for a reply, return the good/bad news... */
4691 api_sw_interface_clear_stats (vat_main_t * vam)
4693 unformat_input_t *i = vam->input;
4694 vl_api_sw_interface_clear_stats_t *mp;
4697 u8 sw_if_index_set = 0;
4699 /* Parse args required to build the message */
4700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4702 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4703 sw_if_index_set = 1;
4704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4705 sw_if_index_set = 1;
4710 /* Construct the API message */
4711 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4713 if (sw_if_index_set == 1)
4714 mp->sw_if_index = ntohl (sw_if_index);
4716 mp->sw_if_index = ~0;
4721 /* Wait for a reply, return the good/bad news... */
4726 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4728 unformat_input_t *i = vam->input;
4729 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4732 u8 sw_if_index_set = 0;
4740 /* Parse args required to build the message */
4741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4743 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4744 sw_if_index_set = 1;
4745 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4746 sw_if_index_set = 1;
4747 else if (unformat (i, "subport %u", &subport))
4749 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4750 sw_if_index_set = 1;
4751 else if (unformat (i, "pipe %u", &pipe))
4753 else if (unformat (i, "profile %u", &profile))
4759 if (sw_if_index_set == 0)
4761 errmsg ("missing interface name or sw_if_index\n");
4765 if (subport_set == 0)
4767 errmsg ("missing subport \n");
4773 errmsg ("missing pipe\n");
4777 if (profile_set == 0)
4779 errmsg ("missing profile\n");
4783 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4785 mp->sw_if_index = ntohl (sw_if_index);
4786 mp->subport = ntohl (subport);
4787 mp->pipe = ntohl (pipe);
4788 mp->profile = ntohl (profile);
4798 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4800 unformat_input_t *i = vam->input;
4801 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4804 u8 sw_if_index_set = 0;
4807 u32 tb_rate = 1250000000; /* 10GbE */
4808 u32 tb_size = 1000000;
4809 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4812 /* Parse args required to build the message */
4813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4815 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4816 sw_if_index_set = 1;
4817 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4818 sw_if_index_set = 1;
4819 else if (unformat (i, "subport %u", &subport))
4821 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4822 sw_if_index_set = 1;
4823 else if (unformat (i, "rate %u", &tb_rate))
4827 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4829 tc_rate[tc_id] = tb_rate;
4831 else if (unformat (i, "bktsize %u", &tb_size))
4833 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4835 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4837 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4839 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4841 else if (unformat (i, "period %u", &tc_period))
4847 if (sw_if_index_set == 0)
4849 errmsg ("missing interface name or sw_if_index\n");
4853 if (subport_set == 0)
4855 errmsg ("missing subport \n");
4859 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4861 mp->sw_if_index = ntohl (sw_if_index);
4862 mp->subport = ntohl (subport);
4863 mp->tb_rate = ntohl (tb_rate);
4864 mp->tb_size = ntohl (tb_size);
4865 mp->tc_rate[0] = ntohl (tc_rate[0]);
4866 mp->tc_rate[1] = ntohl (tc_rate[1]);
4867 mp->tc_rate[2] = ntohl (tc_rate[2]);
4868 mp->tc_rate[3] = ntohl (tc_rate[3]);
4869 mp->tc_period = ntohl (tc_period);
4878 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4880 unformat_input_t *i = vam->input;
4881 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4884 u8 sw_if_index_set = 0;
4888 u32 entry, tc, queue;
4890 /* Parse args required to build the message */
4891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4893 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4894 sw_if_index_set = 1;
4895 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4896 sw_if_index_set = 1;
4897 else if (unformat (i, "entry %d", &entry))
4899 else if (unformat (i, "tc %d", &tc))
4901 else if (unformat (i, "queue %d", &queue))
4907 if (sw_if_index_set == 0)
4909 errmsg ("missing interface name or sw_if_index\n");
4915 errmsg ("missing entry \n");
4921 errmsg ("missing traffic class \n");
4927 errmsg ("missing queue \n");
4931 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4933 mp->sw_if_index = ntohl (sw_if_index);
4934 mp->entry = ntohl (entry);
4935 mp->tc = ntohl (tc);
4936 mp->queue = ntohl (queue);
4945 api_sw_interface_add_del_address (vat_main_t * vam)
4947 unformat_input_t *i = vam->input;
4948 vl_api_sw_interface_add_del_address_t *mp;
4951 u8 sw_if_index_set = 0;
4952 u8 is_add = 1, del_all = 0;
4953 u32 address_length = 0;
4954 u8 v4_address_set = 0;
4955 u8 v6_address_set = 0;
4956 ip4_address_t v4address;
4957 ip6_address_t v6address;
4959 /* Parse args required to build the message */
4960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4962 if (unformat (i, "del-all"))
4964 else if (unformat (i, "del"))
4966 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4967 sw_if_index_set = 1;
4968 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4969 sw_if_index_set = 1;
4970 else if (unformat (i, "%U/%d",
4971 unformat_ip4_address, &v4address, &address_length))
4973 else if (unformat (i, "%U/%d",
4974 unformat_ip6_address, &v6address, &address_length))
4980 if (sw_if_index_set == 0)
4982 errmsg ("missing interface name or sw_if_index\n");
4985 if (v4_address_set && v6_address_set)
4987 errmsg ("both v4 and v6 addresses set\n");
4990 if (!v4_address_set && !v6_address_set && !del_all)
4992 errmsg ("no addresses set\n");
4996 /* Construct the API message */
4997 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4999 mp->sw_if_index = ntohl (sw_if_index);
5000 mp->is_add = is_add;
5001 mp->del_all = del_all;
5005 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5009 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5011 mp->address_length = address_length;
5016 /* Wait for a reply, return good/bad news */
5021 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5023 unformat_input_t *i = vam->input;
5024 vl_api_sw_interface_set_mpls_enable_t *mp;
5027 u8 sw_if_index_set = 0;
5030 /* Parse args required to build the message */
5031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5033 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5034 sw_if_index_set = 1;
5035 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5036 sw_if_index_set = 1;
5037 else if (unformat (i, "disable"))
5039 else if (unformat (i, "dis"))
5045 if (sw_if_index_set == 0)
5047 errmsg ("missing interface name or sw_if_index\n");
5051 /* Construct the API message */
5052 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5054 mp->sw_if_index = ntohl (sw_if_index);
5055 mp->enable = enable;
5060 /* Wait for a reply... */
5065 api_sw_interface_set_table (vat_main_t * vam)
5067 unformat_input_t *i = vam->input;
5068 vl_api_sw_interface_set_table_t *mp;
5070 u32 sw_if_index, vrf_id = 0;
5071 u8 sw_if_index_set = 0;
5074 /* Parse args required to build the message */
5075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5077 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5078 sw_if_index_set = 1;
5079 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5080 sw_if_index_set = 1;
5081 else if (unformat (i, "vrf %d", &vrf_id))
5083 else if (unformat (i, "ipv6"))
5089 if (sw_if_index_set == 0)
5091 errmsg ("missing interface name or sw_if_index\n");
5095 /* Construct the API message */
5096 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5098 mp->sw_if_index = ntohl (sw_if_index);
5099 mp->is_ipv6 = is_ipv6;
5100 mp->vrf_id = ntohl (vrf_id);
5105 /* Wait for a reply... */
5109 static void vl_api_sw_interface_get_table_reply_t_handler
5110 (vl_api_sw_interface_get_table_reply_t * mp)
5112 vat_main_t *vam = &vat_main;
5114 fformat (vam->ofp, "%d\n", ntohl (mp->vrf_id));
5116 vam->retval = ntohl (mp->retval);
5117 vam->result_ready = 1;
5121 static void vl_api_sw_interface_get_table_reply_t_handler_json
5122 (vl_api_sw_interface_get_table_reply_t * mp)
5124 vat_main_t *vam = &vat_main;
5125 vat_json_node_t node;
5127 vat_json_init_object (&node);
5128 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5129 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5131 vat_json_print (vam->ofp, &node);
5132 vat_json_free (&node);
5134 vam->retval = ntohl (mp->retval);
5135 vam->result_ready = 1;
5139 api_sw_interface_get_table (vat_main_t * vam)
5141 unformat_input_t *i = vam->input;
5142 vl_api_sw_interface_get_table_t *mp;
5144 u8 sw_if_index_set = 0;
5148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5150 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5151 sw_if_index_set = 1;
5152 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5153 sw_if_index_set = 1;
5154 else if (unformat (i, "ipv6"))
5160 if (sw_if_index_set == 0)
5162 errmsg ("missing interface name or sw_if_index\n");
5166 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5167 mp->sw_if_index = htonl (sw_if_index);
5168 mp->is_ipv6 = is_ipv6;
5175 api_sw_interface_set_vpath (vat_main_t * vam)
5177 unformat_input_t *i = vam->input;
5178 vl_api_sw_interface_set_vpath_t *mp;
5180 u32 sw_if_index = 0;
5181 u8 sw_if_index_set = 0;
5184 /* Parse args required to build the message */
5185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5187 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5188 sw_if_index_set = 1;
5189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5190 sw_if_index_set = 1;
5191 else if (unformat (i, "enable"))
5193 else if (unformat (i, "disable"))
5199 if (sw_if_index_set == 0)
5201 errmsg ("missing interface name or sw_if_index\n");
5205 /* Construct the API message */
5206 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5208 mp->sw_if_index = ntohl (sw_if_index);
5209 mp->enable = is_enable;
5214 /* Wait for a reply... */
5219 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5221 unformat_input_t *i = vam->input;
5222 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5224 u32 sw_if_index = 0;
5225 u8 sw_if_index_set = 0;
5229 /* Parse args required to build the message */
5230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5232 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5233 sw_if_index_set = 1;
5234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5235 sw_if_index_set = 1;
5236 else if (unformat (i, "enable"))
5238 else if (unformat (i, "disable"))
5240 else if (unformat (i, "ip4"))
5242 else if (unformat (i, "ip6"))
5248 if (sw_if_index_set == 0)
5250 errmsg ("missing interface name or sw_if_index\n");
5254 /* Construct the API message */
5255 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5257 mp->sw_if_index = ntohl (sw_if_index);
5258 mp->enable = is_enable;
5259 mp->is_ipv6 = is_ipv6;
5264 /* Wait for a reply... */
5269 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5271 unformat_input_t *i = vam->input;
5272 vl_api_sw_interface_set_l2_xconnect_t *mp;
5275 u8 rx_sw_if_index_set = 0;
5277 u8 tx_sw_if_index_set = 0;
5280 /* Parse args required to build the message */
5281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5283 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5284 rx_sw_if_index_set = 1;
5285 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5286 tx_sw_if_index_set = 1;
5287 else if (unformat (i, "rx"))
5289 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5291 if (unformat (i, "%U", unformat_sw_if_index, vam,
5293 rx_sw_if_index_set = 1;
5298 else if (unformat (i, "tx"))
5300 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5302 if (unformat (i, "%U", unformat_sw_if_index, vam,
5304 tx_sw_if_index_set = 1;
5309 else if (unformat (i, "enable"))
5311 else if (unformat (i, "disable"))
5317 if (rx_sw_if_index_set == 0)
5319 errmsg ("missing rx interface name or rx_sw_if_index\n");
5323 if (enable && (tx_sw_if_index_set == 0))
5325 errmsg ("missing tx interface name or tx_sw_if_index\n");
5329 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5331 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5332 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5333 mp->enable = enable;
5342 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5344 unformat_input_t *i = vam->input;
5345 vl_api_sw_interface_set_l2_bridge_t *mp;
5348 u8 rx_sw_if_index_set = 0;
5355 /* Parse args required to build the message */
5356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5358 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5359 rx_sw_if_index_set = 1;
5360 else if (unformat (i, "bd_id %d", &bd_id))
5362 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5363 rx_sw_if_index_set = 1;
5364 else if (unformat (i, "shg %d", &shg))
5366 else if (unformat (i, "bvi"))
5368 else if (unformat (i, "enable"))
5370 else if (unformat (i, "disable"))
5376 if (rx_sw_if_index_set == 0)
5378 errmsg ("missing rx interface name or sw_if_index\n");
5382 if (enable && (bd_id_set == 0))
5384 errmsg ("missing bridge domain\n");
5388 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5390 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5391 mp->bd_id = ntohl (bd_id);
5394 mp->enable = enable;
5403 api_bridge_domain_dump (vat_main_t * vam)
5405 unformat_input_t *i = vam->input;
5406 vl_api_bridge_domain_dump_t *mp;
5410 /* Parse args required to build the message */
5411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5413 if (unformat (i, "bd_id %d", &bd_id))
5419 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5420 mp->bd_id = ntohl (bd_id);
5423 /* Use a control ping for synchronization */
5425 vl_api_control_ping_t *mp;
5426 M (CONTROL_PING, control_ping);
5436 api_bridge_domain_add_del (vat_main_t * vam)
5438 unformat_input_t *i = vam->input;
5439 vl_api_bridge_domain_add_del_t *mp;
5443 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5446 /* Parse args required to build the message */
5447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5449 if (unformat (i, "bd_id %d", &bd_id))
5451 else if (unformat (i, "flood %d", &flood))
5453 else if (unformat (i, "uu-flood %d", &uu_flood))
5455 else if (unformat (i, "forward %d", &forward))
5457 else if (unformat (i, "learn %d", &learn))
5459 else if (unformat (i, "arp-term %d", &arp_term))
5461 else if (unformat (i, "mac-age %d", &mac_age))
5463 else if (unformat (i, "del"))
5466 flood = uu_flood = forward = learn = 0;
5474 errmsg ("missing bridge domain\n");
5480 errmsg ("mac age must be less than 256 \n");
5484 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5486 mp->bd_id = ntohl (bd_id);
5488 mp->uu_flood = uu_flood;
5489 mp->forward = forward;
5491 mp->arp_term = arp_term;
5492 mp->is_add = is_add;
5493 mp->mac_age = (u8) mac_age;
5502 api_l2fib_add_del (vat_main_t * vam)
5504 unformat_input_t *i = vam->input;
5505 vl_api_l2fib_add_del_t *mp;
5511 u32 sw_if_index = ~0;
5512 u8 sw_if_index_set = 0;
5521 /* Parse args required to build the message */
5522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5524 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5526 else if (unformat (i, "bd_id %d", &bd_id))
5528 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5529 sw_if_index_set = 1;
5530 else if (unformat (i, "sw_if"))
5532 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5534 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5535 sw_if_index_set = 1;
5540 else if (unformat (i, "static"))
5542 else if (unformat (i, "filter"))
5547 else if (unformat (i, "bvi"))
5552 else if (unformat (i, "del"))
5554 else if (unformat (i, "count %d", &count))
5562 errmsg ("missing mac address\n");
5568 errmsg ("missing bridge domain\n");
5572 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5574 errmsg ("missing interface name or sw_if_index\n");
5580 /* Turn on async mode */
5581 vam->async_mode = 1;
5582 vam->async_errors = 0;
5583 before = vat_time_now (vam);
5586 for (j = 0; j < count; j++)
5588 M (L2FIB_ADD_DEL, l2fib_add_del);
5591 mp->bd_id = ntohl (bd_id);
5592 mp->is_add = is_add;
5596 mp->sw_if_index = ntohl (sw_if_index);
5597 mp->static_mac = static_mac;
5598 mp->filter_mac = filter_mac;
5599 mp->bvi_mac = bvi_mac;
5601 increment_mac_address (&mac);
5608 vl_api_control_ping_t *mp;
5611 /* Shut off async mode */
5612 vam->async_mode = 0;
5614 M (CONTROL_PING, control_ping);
5617 timeout = vat_time_now (vam) + 1.0;
5618 while (vat_time_now (vam) < timeout)
5619 if (vam->result_ready == 1)
5624 if (vam->retval == -99)
5625 errmsg ("timeout\n");
5627 if (vam->async_errors > 0)
5629 errmsg ("%d asynchronous errors\n", vam->async_errors);
5632 vam->async_errors = 0;
5633 after = vat_time_now (vam);
5635 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5636 count, after - before, count / (after - before));
5640 /* Wait for a reply... */
5643 /* Return the good/bad news */
5644 return (vam->retval);
5648 api_l2_flags (vat_main_t * vam)
5650 unformat_input_t *i = vam->input;
5651 vl_api_l2_flags_t *mp;
5654 u32 feature_bitmap = 0;
5655 u8 sw_if_index_set = 0;
5657 /* Parse args required to build the message */
5658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5660 if (unformat (i, "sw_if_index %d", &sw_if_index))
5661 sw_if_index_set = 1;
5662 else if (unformat (i, "sw_if"))
5664 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5666 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5667 sw_if_index_set = 1;
5672 else if (unformat (i, "learn"))
5673 feature_bitmap |= L2INPUT_FEAT_LEARN;
5674 else if (unformat (i, "forward"))
5675 feature_bitmap |= L2INPUT_FEAT_FWD;
5676 else if (unformat (i, "flood"))
5677 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5678 else if (unformat (i, "uu-flood"))
5679 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5684 if (sw_if_index_set == 0)
5686 errmsg ("missing interface name or sw_if_index\n");
5690 M (L2_FLAGS, l2_flags);
5692 mp->sw_if_index = ntohl (sw_if_index);
5693 mp->feature_bitmap = ntohl (feature_bitmap);
5702 api_bridge_flags (vat_main_t * vam)
5704 unformat_input_t *i = vam->input;
5705 vl_api_bridge_flags_t *mp;
5712 /* Parse args required to build the message */
5713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5715 if (unformat (i, "bd_id %d", &bd_id))
5717 else if (unformat (i, "learn"))
5719 else if (unformat (i, "forward"))
5721 else if (unformat (i, "flood"))
5723 else if (unformat (i, "uu-flood"))
5724 flags |= L2_UU_FLOOD;
5725 else if (unformat (i, "arp-term"))
5726 flags |= L2_ARP_TERM;
5727 else if (unformat (i, "off"))
5729 else if (unformat (i, "disable"))
5737 errmsg ("missing bridge domain\n");
5741 M (BRIDGE_FLAGS, bridge_flags);
5743 mp->bd_id = ntohl (bd_id);
5744 mp->feature_bitmap = ntohl (flags);
5745 mp->is_set = is_set;
5754 api_bd_ip_mac_add_del (vat_main_t * vam)
5756 unformat_input_t *i = vam->input;
5757 vl_api_bd_ip_mac_add_del_t *mp;
5765 ip4_address_t v4addr;
5766 ip6_address_t v6addr;
5770 /* Parse args required to build the message */
5771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5773 if (unformat (i, "bd_id %d", &bd_id))
5777 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5781 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5786 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5790 else if (unformat (i, "del"))
5798 errmsg ("missing bridge domain\n");
5801 else if (ip_set == 0)
5803 errmsg ("missing IP address\n");
5806 else if (mac_set == 0)
5808 errmsg ("missing MAC address\n");
5812 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5814 mp->bd_id = ntohl (bd_id);
5815 mp->is_ipv6 = is_ipv6;
5816 mp->is_add = is_add;
5818 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5820 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5821 clib_memcpy (mp->mac_address, macaddr, 6);
5829 api_tap_connect (vat_main_t * vam)
5831 unformat_input_t *i = vam->input;
5832 vl_api_tap_connect_t *mp;
5840 memset (mac_address, 0, sizeof (mac_address));
5842 /* Parse args required to build the message */
5843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5845 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5849 else if (unformat (i, "random-mac"))
5851 else if (unformat (i, "tapname %s", &tap_name))
5853 else if (unformat (i, "tag %s", &tag))
5861 errmsg ("missing tap name\n");
5864 if (vec_len (tap_name) > 63)
5866 errmsg ("tap name too long\n");
5869 vec_add1 (tap_name, 0);
5871 if (vec_len (tag) > 63)
5873 errmsg ("tag too long\n");
5877 /* Construct the API message */
5878 M (TAP_CONNECT, tap_connect);
5880 mp->use_random_mac = random_mac;
5881 clib_memcpy (mp->mac_address, mac_address, 6);
5882 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5884 clib_memcpy (mp->tag, tag, vec_len (tag));
5886 vec_free (tap_name);
5892 /* Wait for a reply... */
5897 api_tap_modify (vat_main_t * vam)
5899 unformat_input_t *i = vam->input;
5900 vl_api_tap_modify_t *mp;
5906 u32 sw_if_index = ~0;
5907 u8 sw_if_index_set = 0;
5909 memset (mac_address, 0, sizeof (mac_address));
5911 /* Parse args required to build the message */
5912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5914 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5915 sw_if_index_set = 1;
5916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5917 sw_if_index_set = 1;
5918 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5922 else if (unformat (i, "random-mac"))
5924 else if (unformat (i, "tapname %s", &tap_name))
5930 if (sw_if_index_set == 0)
5932 errmsg ("missing vpp interface name");
5937 errmsg ("missing tap name\n");
5940 if (vec_len (tap_name) > 63)
5942 errmsg ("tap name too long\n");
5944 vec_add1 (tap_name, 0);
5946 /* Construct the API message */
5947 M (TAP_MODIFY, tap_modify);
5949 mp->use_random_mac = random_mac;
5950 mp->sw_if_index = ntohl (sw_if_index);
5951 clib_memcpy (mp->mac_address, mac_address, 6);
5952 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5953 vec_free (tap_name);
5958 /* Wait for a reply... */
5963 api_tap_delete (vat_main_t * vam)
5965 unformat_input_t *i = vam->input;
5966 vl_api_tap_delete_t *mp;
5968 u32 sw_if_index = ~0;
5969 u8 sw_if_index_set = 0;
5971 /* Parse args required to build the message */
5972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5974 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5975 sw_if_index_set = 1;
5976 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5977 sw_if_index_set = 1;
5982 if (sw_if_index_set == 0)
5984 errmsg ("missing vpp interface name");
5988 /* Construct the API message */
5989 M (TAP_DELETE, tap_delete);
5991 mp->sw_if_index = ntohl (sw_if_index);
5996 /* Wait for a reply... */
6001 api_ip_add_del_route (vat_main_t * vam)
6003 unformat_input_t *i = vam->input;
6004 vl_api_ip_add_del_route_t *mp;
6006 u32 sw_if_index = ~0, vrf_id = 0;
6008 u8 is_local = 0, is_drop = 0;
6009 u8 is_unreach = 0, is_prohibit = 0;
6010 u8 create_vrf_if_needed = 0;
6012 u32 next_hop_weight = 1;
6014 u8 is_multipath = 0;
6016 u8 address_length_set = 0;
6017 u32 next_hop_table_id = 0;
6018 u32 resolve_attempts = 0;
6019 u32 dst_address_length = 0;
6020 u8 next_hop_set = 0;
6021 ip4_address_t v4_dst_address, v4_next_hop_address;
6022 ip6_address_t v6_dst_address, v6_next_hop_address;
6026 u32 random_add_del = 0;
6027 u32 *random_vector = 0;
6029 u32 random_seed = 0xdeaddabe;
6030 u32 classify_table_index = ~0;
6032 u8 resolve_host = 0, resolve_attached = 0;
6033 mpls_label_t *next_hop_out_label_stack = NULL;
6034 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6035 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6037 /* Parse args required to build the message */
6038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6040 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6042 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6044 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6049 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6054 else if (unformat (i, "/%d", &dst_address_length))
6056 address_length_set = 1;
6059 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6060 &v4_next_hop_address))
6064 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6065 &v6_next_hop_address))
6069 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6071 else if (unformat (i, "weight %d", &next_hop_weight))
6073 else if (unformat (i, "drop"))
6077 else if (unformat (i, "null-send-unreach"))
6081 else if (unformat (i, "null-send-prohibit"))
6085 else if (unformat (i, "local"))
6089 else if (unformat (i, "classify %d", &classify_table_index))
6093 else if (unformat (i, "del"))
6095 else if (unformat (i, "add"))
6097 else if (unformat (i, "not-last"))
6099 else if (unformat (i, "resolve-via-host"))
6101 else if (unformat (i, "resolve-via-attached"))
6102 resolve_attached = 1;
6103 else if (unformat (i, "multipath"))
6105 else if (unformat (i, "vrf %d", &vrf_id))
6107 else if (unformat (i, "create-vrf"))
6108 create_vrf_if_needed = 1;
6109 else if (unformat (i, "count %d", &count))
6111 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6113 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6115 else if (unformat (i, "out-label %d", &next_hop_out_label))
6116 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6117 else if (unformat (i, "via-label %d", &next_hop_via_label))
6119 else if (unformat (i, "random"))
6121 else if (unformat (i, "seed %d", &random_seed))
6125 clib_warning ("parse error '%U'", format_unformat_error, i);
6130 if (!next_hop_set && !is_drop && !is_local &&
6131 !is_classify && !is_unreach && !is_prohibit &&
6132 MPLS_LABEL_INVALID == next_hop_via_label)
6135 ("next hop / local / drop / unreach / prohibit / classify not set\n");
6139 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6141 errmsg ("next hop and next-hop via label set\n");
6144 if (address_set == 0)
6146 errmsg ("missing addresses\n");
6150 if (address_length_set == 0)
6152 errmsg ("missing address length\n");
6156 /* Generate a pile of unique, random routes */
6159 u32 this_random_address;
6160 random_hash = hash_create (count, sizeof (uword));
6162 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6163 for (j = 0; j <= count; j++)
6167 this_random_address = random_u32 (&random_seed);
6168 this_random_address =
6169 clib_host_to_net_u32 (this_random_address);
6171 while (hash_get (random_hash, this_random_address));
6172 vec_add1 (random_vector, this_random_address);
6173 hash_set (random_hash, this_random_address, 1);
6175 hash_free (random_hash);
6176 v4_dst_address.as_u32 = random_vector[0];
6181 /* Turn on async mode */
6182 vam->async_mode = 1;
6183 vam->async_errors = 0;
6184 before = vat_time_now (vam);
6187 for (j = 0; j < count; j++)
6189 /* Construct the API message */
6190 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6191 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6193 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6194 mp->table_id = ntohl (vrf_id);
6195 mp->create_vrf_if_needed = create_vrf_if_needed;
6197 mp->is_add = is_add;
6198 mp->is_drop = is_drop;
6199 mp->is_unreach = is_unreach;
6200 mp->is_prohibit = is_prohibit;
6201 mp->is_ipv6 = is_ipv6;
6202 mp->is_local = is_local;
6203 mp->is_classify = is_classify;
6204 mp->is_multipath = is_multipath;
6205 mp->is_resolve_host = resolve_host;
6206 mp->is_resolve_attached = resolve_attached;
6207 mp->not_last = not_last;
6208 mp->next_hop_weight = next_hop_weight;
6209 mp->dst_address_length = dst_address_length;
6210 mp->next_hop_table_id = ntohl (next_hop_table_id);
6211 mp->classify_table_index = ntohl (classify_table_index);
6212 mp->next_hop_via_label = ntohl (next_hop_via_label);
6213 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6214 if (0 != mp->next_hop_n_out_labels)
6216 memcpy (mp->next_hop_out_label_stack,
6217 next_hop_out_label_stack,
6218 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6219 vec_free (next_hop_out_label_stack);
6224 clib_memcpy (mp->dst_address, &v6_dst_address,
6225 sizeof (v6_dst_address));
6227 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6228 sizeof (v6_next_hop_address));
6229 increment_v6_address (&v6_dst_address);
6233 clib_memcpy (mp->dst_address, &v4_dst_address,
6234 sizeof (v4_dst_address));
6236 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6237 sizeof (v4_next_hop_address));
6239 v4_dst_address.as_u32 = random_vector[j + 1];
6241 increment_v4_address (&v4_dst_address);
6245 /* If we receive SIGTERM, stop now... */
6250 /* When testing multiple add/del ops, use a control-ping to sync */
6253 vl_api_control_ping_t *mp;
6256 /* Shut off async mode */
6257 vam->async_mode = 0;
6259 M (CONTROL_PING, control_ping);
6262 timeout = vat_time_now (vam) + 1.0;
6263 while (vat_time_now (vam) < timeout)
6264 if (vam->result_ready == 1)
6269 if (vam->retval == -99)
6270 errmsg ("timeout\n");
6272 if (vam->async_errors > 0)
6274 errmsg ("%d asynchronous errors\n", vam->async_errors);
6277 vam->async_errors = 0;
6278 after = vat_time_now (vam);
6280 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6284 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6285 count, after - before, count / (after - before));
6289 /* Wait for a reply... */
6293 /* Return the good/bad news */
6294 return (vam->retval);
6298 api_mpls_route_add_del (vat_main_t * vam)
6300 unformat_input_t *i = vam->input;
6301 vl_api_mpls_route_add_del_t *mp;
6303 u32 sw_if_index = ~0, table_id = 0;
6304 u8 create_table_if_needed = 0;
6306 u32 next_hop_weight = 1;
6307 u8 is_multipath = 0;
6308 u32 next_hop_table_id = 0;
6309 u8 next_hop_set = 0;
6310 ip4_address_t v4_next_hop_address = {
6313 ip6_address_t v6_next_hop_address = { {0} };
6317 u32 classify_table_index = ~0;
6319 u8 resolve_host = 0, resolve_attached = 0;
6320 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6321 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6322 mpls_label_t *next_hop_out_label_stack = NULL;
6323 mpls_label_t local_label = MPLS_LABEL_INVALID;
6325 u8 next_hop_proto_is_ip4 = 1;
6327 /* Parse args required to build the message */
6328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6330 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6332 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6334 else if (unformat (i, "%d", &local_label))
6336 else if (unformat (i, "eos"))
6338 else if (unformat (i, "non-eos"))
6340 else if (unformat (i, "via %U", unformat_ip4_address,
6341 &v4_next_hop_address))
6344 next_hop_proto_is_ip4 = 1;
6346 else if (unformat (i, "via %U", unformat_ip6_address,
6347 &v6_next_hop_address))
6350 next_hop_proto_is_ip4 = 0;
6352 else if (unformat (i, "weight %d", &next_hop_weight))
6354 else if (unformat (i, "create-table"))
6355 create_table_if_needed = 1;
6356 else if (unformat (i, "classify %d", &classify_table_index))
6360 else if (unformat (i, "del"))
6362 else if (unformat (i, "add"))
6364 else if (unformat (i, "resolve-via-host"))
6366 else if (unformat (i, "resolve-via-attached"))
6367 resolve_attached = 1;
6368 else if (unformat (i, "multipath"))
6370 else if (unformat (i, "count %d", &count))
6372 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6375 next_hop_proto_is_ip4 = 1;
6377 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6380 next_hop_proto_is_ip4 = 0;
6382 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6384 else if (unformat (i, "via-label %d", &next_hop_via_label))
6386 else if (unformat (i, "out-label %d", &next_hop_out_label))
6387 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6390 clib_warning ("parse error '%U'", format_unformat_error, i);
6395 if (!next_hop_set && !is_classify)
6397 errmsg ("next hop / classify not set\n");
6401 if (MPLS_LABEL_INVALID == local_label)
6403 errmsg ("missing label\n");
6409 /* Turn on async mode */
6410 vam->async_mode = 1;
6411 vam->async_errors = 0;
6412 before = vat_time_now (vam);
6415 for (j = 0; j < count; j++)
6417 /* Construct the API message */
6418 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6419 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6421 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6422 mp->mr_table_id = ntohl (table_id);
6423 mp->mr_create_table_if_needed = create_table_if_needed;
6425 mp->mr_is_add = is_add;
6426 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6427 mp->mr_is_classify = is_classify;
6428 mp->mr_is_multipath = is_multipath;
6429 mp->mr_is_resolve_host = resolve_host;
6430 mp->mr_is_resolve_attached = resolve_attached;
6431 mp->mr_next_hop_weight = next_hop_weight;
6432 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6433 mp->mr_classify_table_index = ntohl (classify_table_index);
6434 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6435 mp->mr_label = ntohl (local_label);
6436 mp->mr_eos = is_eos;
6438 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6439 if (0 != mp->mr_next_hop_n_out_labels)
6441 memcpy (mp->mr_next_hop_out_label_stack,
6442 next_hop_out_label_stack,
6443 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6444 vec_free (next_hop_out_label_stack);
6449 if (next_hop_proto_is_ip4)
6451 clib_memcpy (mp->mr_next_hop,
6452 &v4_next_hop_address,
6453 sizeof (v4_next_hop_address));
6457 clib_memcpy (mp->mr_next_hop,
6458 &v6_next_hop_address,
6459 sizeof (v6_next_hop_address));
6466 /* If we receive SIGTERM, stop now... */
6471 /* When testing multiple add/del ops, use a control-ping to sync */
6474 vl_api_control_ping_t *mp;
6477 /* Shut off async mode */
6478 vam->async_mode = 0;
6480 M (CONTROL_PING, control_ping);
6483 timeout = vat_time_now (vam) + 1.0;
6484 while (vat_time_now (vam) < timeout)
6485 if (vam->result_ready == 1)
6490 if (vam->retval == -99)
6491 errmsg ("timeout\n");
6493 if (vam->async_errors > 0)
6495 errmsg ("%d asynchronous errors\n", vam->async_errors);
6498 vam->async_errors = 0;
6499 after = vat_time_now (vam);
6501 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6505 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6506 count, after - before, count / (after - before));
6510 /* Wait for a reply... */
6514 /* Return the good/bad news */
6515 return (vam->retval);
6519 api_mpls_ip_bind_unbind (vat_main_t * vam)
6521 unformat_input_t *i = vam->input;
6522 vl_api_mpls_ip_bind_unbind_t *mp;
6524 u32 ip_table_id = 0;
6525 u8 create_table_if_needed = 0;
6528 ip4_address_t v4_address;
6529 ip6_address_t v6_address;
6532 mpls_label_t local_label = MPLS_LABEL_INVALID;
6534 /* Parse args required to build the message */
6535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6537 if (unformat (i, "%U/%d", unformat_ip4_address,
6538 &v4_address, &address_length))
6543 else if (unformat (i, "%U/%d", unformat_ip6_address,
6544 &v6_address, &address_length))
6549 else if (unformat (i, "%d", &local_label))
6551 else if (unformat (i, "create-table"))
6552 create_table_if_needed = 1;
6553 else if (unformat (i, "table-id %d", &ip_table_id))
6555 else if (unformat (i, "unbind"))
6557 else if (unformat (i, "bind"))
6561 clib_warning ("parse error '%U'", format_unformat_error, i);
6568 errmsg ("IP addres not set\n");
6572 if (MPLS_LABEL_INVALID == local_label)
6574 errmsg ("missing label\n");
6578 /* Construct the API message */
6579 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6581 mp->mb_create_table_if_needed = create_table_if_needed;
6582 mp->mb_is_bind = is_bind;
6583 mp->mb_is_ip4 = is_ip4;
6584 mp->mb_ip_table_id = ntohl (ip_table_id);
6585 mp->mb_mpls_table_id = 0;
6586 mp->mb_label = ntohl (local_label);
6587 mp->mb_address_length = address_length;
6590 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6592 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6597 /* Wait for a reply... */
6602 api_proxy_arp_add_del (vat_main_t * vam)
6604 unformat_input_t *i = vam->input;
6605 vl_api_proxy_arp_add_del_t *mp;
6609 ip4_address_t lo, hi;
6612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6614 if (unformat (i, "vrf %d", &vrf_id))
6616 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6617 unformat_ip4_address, &hi))
6619 else if (unformat (i, "del"))
6623 clib_warning ("parse error '%U'", format_unformat_error, i);
6630 errmsg ("address range not set\n");
6634 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6636 mp->vrf_id = ntohl (vrf_id);
6637 mp->is_add = is_add;
6638 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6639 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6648 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6650 unformat_input_t *i = vam->input;
6651 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6655 u8 sw_if_index_set = 0;
6657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6659 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6660 sw_if_index_set = 1;
6661 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6662 sw_if_index_set = 1;
6663 else if (unformat (i, "enable"))
6665 else if (unformat (i, "disable"))
6669 clib_warning ("parse error '%U'", format_unformat_error, i);
6674 if (sw_if_index_set == 0)
6676 errmsg ("missing interface name or sw_if_index\n");
6680 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6682 mp->sw_if_index = ntohl (sw_if_index);
6683 mp->enable_disable = enable;
6692 api_mpls_tunnel_add_del (vat_main_t * vam)
6694 unformat_input_t *i = vam->input;
6695 vl_api_mpls_tunnel_add_del_t *mp;
6700 u32 sw_if_index = ~0;
6701 u32 next_hop_sw_if_index = ~0;
6702 u32 next_hop_proto_is_ip4 = 1;
6704 u32 next_hop_table_id = 0;
6705 ip4_address_t v4_next_hop_address = {
6708 ip6_address_t v6_next_hop_address = { {0} };
6709 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6713 if (unformat (i, "add"))
6715 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6717 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6719 else if (unformat (i, "via %U",
6720 unformat_ip4_address, &v4_next_hop_address))
6722 next_hop_proto_is_ip4 = 1;
6724 else if (unformat (i, "via %U",
6725 unformat_ip6_address, &v6_next_hop_address))
6727 next_hop_proto_is_ip4 = 0;
6729 else if (unformat (i, "l2-only"))
6731 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6733 else if (unformat (i, "out-label %d", &next_hop_out_label))
6734 vec_add1 (labels, ntohl (next_hop_out_label));
6737 clib_warning ("parse error '%U'", format_unformat_error, i);
6742 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6743 sizeof (mpls_label_t) * vec_len (labels));
6745 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6746 mp->mt_sw_if_index = ntohl (sw_if_index);
6747 mp->mt_is_add = is_add;
6748 mp->mt_l2_only = l2_only;
6749 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6750 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6752 mp->mt_next_hop_n_out_labels = vec_len (labels);
6754 if (0 != mp->mt_next_hop_n_out_labels)
6756 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6757 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6761 if (next_hop_proto_is_ip4)
6763 clib_memcpy (mp->mt_next_hop,
6764 &v4_next_hop_address, sizeof (v4_next_hop_address));
6768 clib_memcpy (mp->mt_next_hop,
6769 &v6_next_hop_address, sizeof (v6_next_hop_address));
6779 api_sw_interface_set_unnumbered (vat_main_t * vam)
6781 unformat_input_t *i = vam->input;
6782 vl_api_sw_interface_set_unnumbered_t *mp;
6785 u32 unnum_sw_index = ~0;
6787 u8 sw_if_index_set = 0;
6789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6791 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6792 sw_if_index_set = 1;
6793 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6794 sw_if_index_set = 1;
6795 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6797 else if (unformat (i, "del"))
6801 clib_warning ("parse error '%U'", format_unformat_error, i);
6806 if (sw_if_index_set == 0)
6808 errmsg ("missing interface name or sw_if_index\n");
6812 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6814 mp->sw_if_index = ntohl (sw_if_index);
6815 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6816 mp->is_add = is_add;
6825 api_ip_neighbor_add_del (vat_main_t * vam)
6827 unformat_input_t *i = vam->input;
6828 vl_api_ip_neighbor_add_del_t *mp;
6831 u8 sw_if_index_set = 0;
6837 u8 v4_address_set = 0;
6838 u8 v6_address_set = 0;
6839 ip4_address_t v4address;
6840 ip6_address_t v6address;
6842 memset (mac_address, 0, sizeof (mac_address));
6844 /* Parse args required to build the message */
6845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6847 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6851 else if (unformat (i, "del"))
6853 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6854 sw_if_index_set = 1;
6855 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6856 sw_if_index_set = 1;
6857 else if (unformat (i, "is_static"))
6859 else if (unformat (i, "vrf %d", &vrf_id))
6861 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6863 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6867 clib_warning ("parse error '%U'", format_unformat_error, i);
6872 if (sw_if_index_set == 0)
6874 errmsg ("missing interface name or sw_if_index\n");
6877 if (v4_address_set && v6_address_set)
6879 errmsg ("both v4 and v6 addresses set\n");
6882 if (!v4_address_set && !v6_address_set)
6884 errmsg ("no address set\n");
6888 /* Construct the API message */
6889 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6891 mp->sw_if_index = ntohl (sw_if_index);
6892 mp->is_add = is_add;
6893 mp->vrf_id = ntohl (vrf_id);
6894 mp->is_static = is_static;
6896 clib_memcpy (mp->mac_address, mac_address, 6);
6900 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6904 /* mp->is_ipv6 = 0; via memset in M macro above */
6905 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6911 /* Wait for a reply, return good/bad news */
6919 api_reset_vrf (vat_main_t * vam)
6921 unformat_input_t *i = vam->input;
6922 vl_api_reset_vrf_t *mp;
6928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6930 if (unformat (i, "vrf %d", &vrf_id))
6932 else if (unformat (i, "ipv6"))
6936 clib_warning ("parse error '%U'", format_unformat_error, i);
6941 if (vrf_id_set == 0)
6943 errmsg ("missing vrf id\n");
6947 M (RESET_VRF, reset_vrf);
6949 mp->vrf_id = ntohl (vrf_id);
6950 mp->is_ipv6 = is_ipv6;
6959 api_create_vlan_subif (vat_main_t * vam)
6961 unformat_input_t *i = vam->input;
6962 vl_api_create_vlan_subif_t *mp;
6965 u8 sw_if_index_set = 0;
6969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6971 if (unformat (i, "sw_if_index %d", &sw_if_index))
6972 sw_if_index_set = 1;
6973 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6974 sw_if_index_set = 1;
6975 else if (unformat (i, "vlan %d", &vlan_id))
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 (vlan_id_set == 0)
6992 errmsg ("missing vlan_id\n");
6995 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6997 mp->sw_if_index = ntohl (sw_if_index);
6998 mp->vlan_id = ntohl (vlan_id);
7006 #define foreach_create_subif_bit \
7013 _(outer_vlan_id_any) \
7014 _(inner_vlan_id_any)
7017 api_create_subif (vat_main_t * vam)
7019 unformat_input_t *i = vam->input;
7020 vl_api_create_subif_t *mp;
7023 u8 sw_if_index_set = 0;
7030 u32 exact_match = 0;
7031 u32 default_sub = 0;
7032 u32 outer_vlan_id_any = 0;
7033 u32 inner_vlan_id_any = 0;
7035 u16 outer_vlan_id = 0;
7036 u16 inner_vlan_id = 0;
7038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7040 if (unformat (i, "sw_if_index %d", &sw_if_index))
7041 sw_if_index_set = 1;
7042 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7043 sw_if_index_set = 1;
7044 else if (unformat (i, "sub_id %d", &sub_id))
7046 else if (unformat (i, "outer_vlan_id %d", &tmp))
7047 outer_vlan_id = tmp;
7048 else if (unformat (i, "inner_vlan_id %d", &tmp))
7049 inner_vlan_id = tmp;
7051 #define _(a) else if (unformat (i, #a)) a = 1 ;
7052 foreach_create_subif_bit
7056 clib_warning ("parse error '%U'", format_unformat_error, i);
7061 if (sw_if_index_set == 0)
7063 errmsg ("missing interface name or sw_if_index\n");
7067 if (sub_id_set == 0)
7069 errmsg ("missing sub_id\n");
7072 M (CREATE_SUBIF, create_subif);
7074 mp->sw_if_index = ntohl (sw_if_index);
7075 mp->sub_id = ntohl (sub_id);
7077 #define _(a) mp->a = a;
7078 foreach_create_subif_bit;
7081 mp->outer_vlan_id = ntohs (outer_vlan_id);
7082 mp->inner_vlan_id = ntohs (inner_vlan_id);
7091 api_oam_add_del (vat_main_t * vam)
7093 unformat_input_t *i = vam->input;
7094 vl_api_oam_add_del_t *mp;
7098 ip4_address_t src, dst;
7102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7104 if (unformat (i, "vrf %d", &vrf_id))
7106 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7108 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7110 else if (unformat (i, "del"))
7114 clib_warning ("parse error '%U'", format_unformat_error, i);
7121 errmsg ("missing src addr\n");
7127 errmsg ("missing dst addr\n");
7131 M (OAM_ADD_DEL, oam_add_del);
7133 mp->vrf_id = ntohl (vrf_id);
7134 mp->is_add = is_add;
7135 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7136 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7145 api_reset_fib (vat_main_t * vam)
7147 unformat_input_t *i = vam->input;
7148 vl_api_reset_fib_t *mp;
7154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7156 if (unformat (i, "vrf %d", &vrf_id))
7158 else if (unformat (i, "ipv6"))
7162 clib_warning ("parse error '%U'", format_unformat_error, i);
7167 if (vrf_id_set == 0)
7169 errmsg ("missing vrf id\n");
7173 M (RESET_FIB, reset_fib);
7175 mp->vrf_id = ntohl (vrf_id);
7176 mp->is_ipv6 = is_ipv6;
7185 api_dhcp_proxy_config (vat_main_t * vam)
7187 unformat_input_t *i = vam->input;
7188 vl_api_dhcp_proxy_config_t *mp;
7193 u8 v4_address_set = 0;
7194 u8 v6_address_set = 0;
7195 ip4_address_t v4address;
7196 ip6_address_t v6address;
7197 u8 v4_src_address_set = 0;
7198 u8 v6_src_address_set = 0;
7199 ip4_address_t v4srcaddress;
7200 ip6_address_t v6srcaddress;
7202 /* Parse args required to build the message */
7203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7205 if (unformat (i, "del"))
7207 else if (unformat (i, "vrf %d", &vrf_id))
7209 else if (unformat (i, "insert-cid %d", &insert_cid))
7211 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7213 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7215 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7216 v4_src_address_set = 1;
7217 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7218 v6_src_address_set = 1;
7223 if (v4_address_set && v6_address_set)
7225 errmsg ("both v4 and v6 server addresses set\n");
7228 if (!v4_address_set && !v6_address_set)
7230 errmsg ("no server addresses set\n");
7234 if (v4_src_address_set && v6_src_address_set)
7236 errmsg ("both v4 and v6 src addresses set\n");
7239 if (!v4_src_address_set && !v6_src_address_set)
7241 errmsg ("no src addresses set\n");
7245 if (!(v4_src_address_set && v4_address_set) &&
7246 !(v6_src_address_set && v6_address_set))
7248 errmsg ("no matching server and src addresses set\n");
7252 /* Construct the API message */
7253 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7255 mp->insert_circuit_id = insert_cid;
7256 mp->is_add = is_add;
7257 mp->vrf_id = ntohl (vrf_id);
7261 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7262 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7266 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7267 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7273 /* Wait for a reply, return good/bad news */
7280 api_dhcp_proxy_config_2 (vat_main_t * vam)
7282 unformat_input_t *i = vam->input;
7283 vl_api_dhcp_proxy_config_2_t *mp;
7286 u32 server_vrf_id = 0;
7289 u8 v4_address_set = 0;
7290 u8 v6_address_set = 0;
7291 ip4_address_t v4address;
7292 ip6_address_t v6address;
7293 u8 v4_src_address_set = 0;
7294 u8 v6_src_address_set = 0;
7295 ip4_address_t v4srcaddress;
7296 ip6_address_t v6srcaddress;
7298 /* Parse args required to build the message */
7299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7301 if (unformat (i, "del"))
7303 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7305 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7307 else if (unformat (i, "insert-cid %d", &insert_cid))
7309 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7311 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7313 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7314 v4_src_address_set = 1;
7315 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7316 v6_src_address_set = 1;
7321 if (v4_address_set && v6_address_set)
7323 errmsg ("both v4 and v6 server addresses set\n");
7326 if (!v4_address_set && !v6_address_set)
7328 errmsg ("no server addresses set\n");
7332 if (v4_src_address_set && v6_src_address_set)
7334 errmsg ("both v4 and v6 src addresses set\n");
7337 if (!v4_src_address_set && !v6_src_address_set)
7339 errmsg ("no src addresses set\n");
7343 if (!(v4_src_address_set && v4_address_set) &&
7344 !(v6_src_address_set && v6_address_set))
7346 errmsg ("no matching server and src addresses set\n");
7350 /* Construct the API message */
7351 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7353 mp->insert_circuit_id = insert_cid;
7354 mp->is_add = is_add;
7355 mp->rx_vrf_id = ntohl (rx_vrf_id);
7356 mp->server_vrf_id = ntohl (server_vrf_id);
7360 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7361 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7365 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7366 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7372 /* Wait for a reply, return good/bad news */
7379 api_dhcp_proxy_set_vss (vat_main_t * vam)
7381 unformat_input_t *i = vam->input;
7382 vl_api_dhcp_proxy_set_vss_t *mp;
7393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7395 if (unformat (i, "tbl_id %d", &tbl_id))
7397 if (unformat (i, "fib_id %d", &fib_id))
7399 if (unformat (i, "oui %d", &oui))
7401 else if (unformat (i, "ipv6"))
7403 else if (unformat (i, "del"))
7407 clib_warning ("parse error '%U'", format_unformat_error, i);
7412 if (tbl_id_set == 0)
7414 errmsg ("missing tbl id\n");
7418 if (fib_id_set == 0)
7420 errmsg ("missing fib id\n");
7425 errmsg ("missing oui\n");
7429 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7430 mp->tbl_id = ntohl (tbl_id);
7431 mp->fib_id = ntohl (fib_id);
7432 mp->oui = ntohl (oui);
7433 mp->is_ipv6 = is_ipv6;
7434 mp->is_add = is_add;
7443 api_dhcp_client_config (vat_main_t * vam)
7445 unformat_input_t *i = vam->input;
7446 vl_api_dhcp_client_config_t *mp;
7449 u8 sw_if_index_set = 0;
7452 u8 disable_event = 0;
7454 /* Parse args required to build the message */
7455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7457 if (unformat (i, "del"))
7459 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7460 sw_if_index_set = 1;
7461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7462 sw_if_index_set = 1;
7463 else if (unformat (i, "hostname %s", &hostname))
7465 else if (unformat (i, "disable_event"))
7471 if (sw_if_index_set == 0)
7473 errmsg ("missing interface name or sw_if_index\n");
7477 if (vec_len (hostname) > 63)
7479 errmsg ("hostname too long\n");
7481 vec_add1 (hostname, 0);
7483 /* Construct the API message */
7484 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7486 mp->sw_if_index = ntohl (sw_if_index);
7487 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7488 vec_free (hostname);
7489 mp->is_add = is_add;
7490 mp->want_dhcp_event = disable_event ? 0 : 1;
7491 mp->pid = getpid ();
7496 /* Wait for a reply, return good/bad news */
7503 api_set_ip_flow_hash (vat_main_t * vam)
7505 unformat_input_t *i = vam->input;
7506 vl_api_set_ip_flow_hash_t *mp;
7518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7520 if (unformat (i, "vrf %d", &vrf_id))
7522 else if (unformat (i, "ipv6"))
7524 else if (unformat (i, "src"))
7526 else if (unformat (i, "dst"))
7528 else if (unformat (i, "sport"))
7530 else if (unformat (i, "dport"))
7532 else if (unformat (i, "proto"))
7534 else if (unformat (i, "reverse"))
7539 clib_warning ("parse error '%U'", format_unformat_error, i);
7544 if (vrf_id_set == 0)
7546 errmsg ("missing vrf id\n");
7550 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7556 mp->reverse = reverse;
7557 mp->vrf_id = ntohl (vrf_id);
7558 mp->is_ipv6 = is_ipv6;
7567 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7569 unformat_input_t *i = vam->input;
7570 vl_api_sw_interface_ip6_enable_disable_t *mp;
7573 u8 sw_if_index_set = 0;
7576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7578 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7579 sw_if_index_set = 1;
7580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7581 sw_if_index_set = 1;
7582 else if (unformat (i, "enable"))
7584 else if (unformat (i, "disable"))
7588 clib_warning ("parse error '%U'", format_unformat_error, i);
7593 if (sw_if_index_set == 0)
7595 errmsg ("missing interface name or sw_if_index\n");
7599 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7601 mp->sw_if_index = ntohl (sw_if_index);
7602 mp->enable = enable;
7611 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7613 unformat_input_t *i = vam->input;
7614 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7617 u8 sw_if_index_set = 0;
7618 u32 address_length = 0;
7619 u8 v6_address_set = 0;
7620 ip6_address_t v6address;
7622 /* Parse args required to build the message */
7623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7625 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7626 sw_if_index_set = 1;
7627 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7628 sw_if_index_set = 1;
7629 else if (unformat (i, "%U/%d",
7630 unformat_ip6_address, &v6address, &address_length))
7636 if (sw_if_index_set == 0)
7638 errmsg ("missing interface name or sw_if_index\n");
7641 if (!v6_address_set)
7643 errmsg ("no address set\n");
7647 /* Construct the API message */
7648 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7649 sw_interface_ip6_set_link_local_address);
7651 mp->sw_if_index = ntohl (sw_if_index);
7652 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7653 mp->address_length = address_length;
7658 /* Wait for a reply, return good/bad news */
7667 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7669 unformat_input_t *i = vam->input;
7670 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7673 u8 sw_if_index_set = 0;
7674 u32 address_length = 0;
7675 u8 v6_address_set = 0;
7676 ip6_address_t v6address;
7678 u8 no_advertise = 0;
7680 u8 no_autoconfig = 0;
7683 u32 val_lifetime = 0;
7684 u32 pref_lifetime = 0;
7686 /* Parse args required to build the message */
7687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7689 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7690 sw_if_index_set = 1;
7691 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7692 sw_if_index_set = 1;
7693 else if (unformat (i, "%U/%d",
7694 unformat_ip6_address, &v6address, &address_length))
7696 else if (unformat (i, "val_life %d", &val_lifetime))
7698 else if (unformat (i, "pref_life %d", &pref_lifetime))
7700 else if (unformat (i, "def"))
7702 else if (unformat (i, "noadv"))
7704 else if (unformat (i, "offl"))
7706 else if (unformat (i, "noauto"))
7708 else if (unformat (i, "nolink"))
7710 else if (unformat (i, "isno"))
7714 clib_warning ("parse error '%U'", format_unformat_error, i);
7719 if (sw_if_index_set == 0)
7721 errmsg ("missing interface name or sw_if_index\n");
7724 if (!v6_address_set)
7726 errmsg ("no address set\n");
7730 /* Construct the API message */
7731 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7733 mp->sw_if_index = ntohl (sw_if_index);
7734 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7735 mp->address_length = address_length;
7736 mp->use_default = use_default;
7737 mp->no_advertise = no_advertise;
7738 mp->off_link = off_link;
7739 mp->no_autoconfig = no_autoconfig;
7740 mp->no_onlink = no_onlink;
7742 mp->val_lifetime = ntohl (val_lifetime);
7743 mp->pref_lifetime = ntohl (pref_lifetime);
7748 /* Wait for a reply, return good/bad news */
7756 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7758 unformat_input_t *i = vam->input;
7759 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7762 u8 sw_if_index_set = 0;
7767 u8 send_unicast = 0;
7770 u8 default_router = 0;
7771 u32 max_interval = 0;
7772 u32 min_interval = 0;
7774 u32 initial_count = 0;
7775 u32 initial_interval = 0;
7778 /* Parse args required to build the message */
7779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7781 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7782 sw_if_index_set = 1;
7783 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7784 sw_if_index_set = 1;
7785 else if (unformat (i, "maxint %d", &max_interval))
7787 else if (unformat (i, "minint %d", &min_interval))
7789 else if (unformat (i, "life %d", &lifetime))
7791 else if (unformat (i, "count %d", &initial_count))
7793 else if (unformat (i, "interval %d", &initial_interval))
7795 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7797 else if (unformat (i, "managed"))
7799 else if (unformat (i, "other"))
7801 else if (unformat (i, "ll"))
7803 else if (unformat (i, "send"))
7805 else if (unformat (i, "cease"))
7807 else if (unformat (i, "isno"))
7809 else if (unformat (i, "def"))
7813 clib_warning ("parse error '%U'", format_unformat_error, i);
7818 if (sw_if_index_set == 0)
7820 errmsg ("missing interface name or sw_if_index\n");
7824 /* Construct the API message */
7825 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7827 mp->sw_if_index = ntohl (sw_if_index);
7828 mp->max_interval = ntohl (max_interval);
7829 mp->min_interval = ntohl (min_interval);
7830 mp->lifetime = ntohl (lifetime);
7831 mp->initial_count = ntohl (initial_count);
7832 mp->initial_interval = ntohl (initial_interval);
7833 mp->suppress = suppress;
7834 mp->managed = managed;
7836 mp->ll_option = ll_option;
7837 mp->send_unicast = send_unicast;
7840 mp->default_router = default_router;
7845 /* Wait for a reply, return good/bad news */
7853 api_set_arp_neighbor_limit (vat_main_t * vam)
7855 unformat_input_t *i = vam->input;
7856 vl_api_set_arp_neighbor_limit_t *mp;
7862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7864 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7866 else if (unformat (i, "ipv6"))
7870 clib_warning ("parse error '%U'", format_unformat_error, i);
7877 errmsg ("missing limit value\n");
7881 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7883 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7884 mp->is_ipv6 = is_ipv6;
7893 api_l2_patch_add_del (vat_main_t * vam)
7895 unformat_input_t *i = vam->input;
7896 vl_api_l2_patch_add_del_t *mp;
7899 u8 rx_sw_if_index_set = 0;
7901 u8 tx_sw_if_index_set = 0;
7904 /* Parse args required to build the message */
7905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7907 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7908 rx_sw_if_index_set = 1;
7909 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7910 tx_sw_if_index_set = 1;
7911 else if (unformat (i, "rx"))
7913 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7915 if (unformat (i, "%U", unformat_sw_if_index, vam,
7917 rx_sw_if_index_set = 1;
7922 else if (unformat (i, "tx"))
7924 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7926 if (unformat (i, "%U", unformat_sw_if_index, vam,
7928 tx_sw_if_index_set = 1;
7933 else if (unformat (i, "del"))
7939 if (rx_sw_if_index_set == 0)
7941 errmsg ("missing rx interface name or rx_sw_if_index\n");
7945 if (tx_sw_if_index_set == 0)
7947 errmsg ("missing tx interface name or tx_sw_if_index\n");
7951 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7953 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7954 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7955 mp->is_add = is_add;
7964 api_ioam_enable (vat_main_t * vam)
7966 unformat_input_t *input = vam->input;
7967 vl_api_ioam_enable_t *mp;
7970 int has_trace_option = 0;
7971 int has_pot_option = 0;
7972 int has_seqno_option = 0;
7973 int has_analyse_option = 0;
7975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7977 if (unformat (input, "trace"))
7978 has_trace_option = 1;
7979 else if (unformat (input, "pot"))
7981 else if (unformat (input, "seqno"))
7982 has_seqno_option = 1;
7983 else if (unformat (input, "analyse"))
7984 has_analyse_option = 1;
7988 M (IOAM_ENABLE, ioam_enable);
7989 mp->id = htons (id);
7990 mp->seqno = has_seqno_option;
7991 mp->analyse = has_analyse_option;
7992 mp->pot_enable = has_pot_option;
7993 mp->trace_enable = has_trace_option;
8004 api_ioam_disable (vat_main_t * vam)
8006 vl_api_ioam_disable_t *mp;
8009 M (IOAM_DISABLE, ioam_disable);
8016 api_sr_tunnel_add_del (vat_main_t * vam)
8018 unformat_input_t *i = vam->input;
8019 vl_api_sr_tunnel_add_del_t *mp;
8023 ip6_address_t src_address;
8024 int src_address_set = 0;
8025 ip6_address_t dst_address;
8027 int dst_address_set = 0;
8029 u32 rx_table_id = 0;
8030 u32 tx_table_id = 0;
8031 ip6_address_t *segments = 0;
8032 ip6_address_t *this_seg;
8033 ip6_address_t *tags = 0;
8034 ip6_address_t *this_tag;
8035 ip6_address_t next_address, tag;
8037 u8 *policy_name = 0;
8039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8041 if (unformat (i, "del"))
8043 else if (unformat (i, "name %s", &name))
8045 else if (unformat (i, "policy %s", &policy_name))
8047 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8049 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8051 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8052 src_address_set = 1;
8053 else if (unformat (i, "dst %U/%d",
8054 unformat_ip6_address, &dst_address, &dst_mask_width))
8055 dst_address_set = 1;
8056 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8058 vec_add2 (segments, this_seg, 1);
8059 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8060 sizeof (*this_seg));
8062 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8064 vec_add2 (tags, this_tag, 1);
8065 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8067 else if (unformat (i, "clean"))
8068 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8069 else if (unformat (i, "protected"))
8070 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8071 else if (unformat (i, "InPE %d", &pl_index))
8073 if (pl_index <= 0 || pl_index > 4)
8075 pl_index_range_error:
8076 errmsg ("pl index %d out of range\n", pl_index);
8080 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8082 else if (unformat (i, "EgPE %d", &pl_index))
8084 if (pl_index <= 0 || pl_index > 4)
8085 goto pl_index_range_error;
8087 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8089 else if (unformat (i, "OrgSrc %d", &pl_index))
8091 if (pl_index <= 0 || pl_index > 4)
8092 goto pl_index_range_error;
8094 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8100 if (!src_address_set)
8102 errmsg ("src address required\n");
8106 if (!dst_address_set)
8108 errmsg ("dst address required\n");
8114 errmsg ("at least one sr segment required\n");
8118 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8119 vec_len (segments) * sizeof (ip6_address_t)
8120 + vec_len (tags) * sizeof (ip6_address_t));
8122 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8123 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8124 mp->dst_mask_width = dst_mask_width;
8125 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8126 mp->n_segments = vec_len (segments);
8127 mp->n_tags = vec_len (tags);
8128 mp->is_add = is_del == 0;
8129 clib_memcpy (mp->segs_and_tags, segments,
8130 vec_len (segments) * sizeof (ip6_address_t));
8131 clib_memcpy (mp->segs_and_tags +
8132 vec_len (segments) * sizeof (ip6_address_t), tags,
8133 vec_len (tags) * sizeof (ip6_address_t));
8135 mp->outer_vrf_id = ntohl (rx_table_id);
8136 mp->inner_vrf_id = ntohl (tx_table_id);
8137 memcpy (mp->name, name, vec_len (name));
8138 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8140 vec_free (segments);
8149 api_sr_policy_add_del (vat_main_t * vam)
8151 unformat_input_t *input = vam->input;
8152 vl_api_sr_policy_add_del_t *mp;
8156 u8 *tunnel_name = 0;
8157 u8 **tunnel_names = 0;
8162 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8163 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8167 if (unformat (input, "del"))
8169 else if (unformat (input, "name %s", &name))
8171 else if (unformat (input, "tunnel %s", &tunnel_name))
8175 vec_add1 (tunnel_names, tunnel_name);
8177 - length = #bytes to store in serial vector
8178 - +1 = byte to store that length
8180 tunnel_names_length += (vec_len (tunnel_name) + 1);
8191 errmsg ("policy name required\n");
8195 if ((!tunnel_set) && (!is_del))
8197 errmsg ("tunnel name required\n");
8201 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8205 mp->is_add = !is_del;
8207 memcpy (mp->name, name, vec_len (name));
8208 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8209 u8 *serial_orig = 0;
8210 vec_validate (serial_orig, tunnel_names_length);
8211 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8212 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8214 for (j = 0; j < vec_len (tunnel_names); j++)
8216 tun_name_len = vec_len (tunnel_names[j]);
8217 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8218 serial_orig += 1; // Move along one byte to store the actual tunnel name
8219 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8220 serial_orig += tun_name_len; // Advance past the copy
8222 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8224 vec_free (tunnel_names);
8225 vec_free (tunnel_name);
8233 api_sr_multicast_map_add_del (vat_main_t * vam)
8235 unformat_input_t *input = vam->input;
8236 vl_api_sr_multicast_map_add_del_t *mp;
8239 ip6_address_t multicast_address;
8240 u8 *policy_name = 0;
8241 int multicast_address_set = 0;
8243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8245 if (unformat (input, "del"))
8249 (input, "address %U", unformat_ip6_address, &multicast_address))
8250 multicast_address_set = 1;
8251 else if (unformat (input, "sr-policy %s", &policy_name))
8257 if (!is_del && !policy_name)
8259 errmsg ("sr-policy name required\n");
8264 if (!multicast_address_set)
8266 errmsg ("address required\n");
8270 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8272 mp->is_add = !is_del;
8273 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8274 clib_memcpy (mp->multicast_address, &multicast_address,
8275 sizeof (mp->multicast_address));
8278 vec_free (policy_name);
8286 #define foreach_tcp_proto_field \
8290 #define foreach_udp_proto_field \
8294 #define foreach_ip4_proto_field \
8305 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8307 u8 **maskp = va_arg (*args, u8 **);
8309 u8 found_something = 0;
8312 #define _(a) u8 a=0;
8313 foreach_tcp_proto_field;
8316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8319 #define _(a) else if (unformat (input, #a)) a=1;
8320 foreach_tcp_proto_field
8326 #define _(a) found_something += a;
8327 foreach_tcp_proto_field;
8330 if (found_something == 0)
8333 vec_validate (mask, sizeof (*tcp) - 1);
8335 tcp = (tcp_header_t *) mask;
8337 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8338 foreach_tcp_proto_field;
8346 unformat_udp_mask (unformat_input_t * input, va_list * args)
8348 u8 **maskp = va_arg (*args, u8 **);
8350 u8 found_something = 0;
8353 #define _(a) u8 a=0;
8354 foreach_udp_proto_field;
8357 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8360 #define _(a) else if (unformat (input, #a)) a=1;
8361 foreach_udp_proto_field
8367 #define _(a) found_something += a;
8368 foreach_udp_proto_field;
8371 if (found_something == 0)
8374 vec_validate (mask, sizeof (*udp) - 1);
8376 udp = (udp_header_t *) mask;
8378 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8379 foreach_udp_proto_field;
8388 u16 src_port, dst_port;
8392 unformat_l4_mask (unformat_input_t * input, va_list * args)
8394 u8 **maskp = va_arg (*args, u8 **);
8395 u16 src_port = 0, dst_port = 0;
8396 tcpudp_header_t *tcpudp;
8398 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8400 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8402 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8404 else if (unformat (input, "src_port"))
8406 else if (unformat (input, "dst_port"))
8412 if (!src_port && !dst_port)
8416 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8418 tcpudp = (tcpudp_header_t *) mask;
8419 tcpudp->src_port = src_port;
8420 tcpudp->dst_port = dst_port;
8428 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8430 u8 **maskp = va_arg (*args, u8 **);
8432 u8 found_something = 0;
8435 #define _(a) u8 a=0;
8436 foreach_ip4_proto_field;
8442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8444 if (unformat (input, "version"))
8446 else if (unformat (input, "hdr_length"))
8448 else if (unformat (input, "src"))
8450 else if (unformat (input, "dst"))
8452 else if (unformat (input, "proto"))
8455 #define _(a) else if (unformat (input, #a)) a=1;
8456 foreach_ip4_proto_field
8462 #define _(a) found_something += a;
8463 foreach_ip4_proto_field;
8466 if (found_something == 0)
8469 vec_validate (mask, sizeof (*ip) - 1);
8471 ip = (ip4_header_t *) mask;
8473 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8474 foreach_ip4_proto_field;
8477 ip->ip_version_and_header_length = 0;
8480 ip->ip_version_and_header_length |= 0xF0;
8483 ip->ip_version_and_header_length |= 0x0F;
8489 #define foreach_ip6_proto_field \
8497 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8499 u8 **maskp = va_arg (*args, u8 **);
8501 u8 found_something = 0;
8503 u32 ip_version_traffic_class_and_flow_label;
8505 #define _(a) u8 a=0;
8506 foreach_ip6_proto_field;
8509 u8 traffic_class = 0;
8512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8514 if (unformat (input, "version"))
8516 else if (unformat (input, "traffic-class"))
8518 else if (unformat (input, "flow-label"))
8520 else if (unformat (input, "src"))
8522 else if (unformat (input, "dst"))
8524 else if (unformat (input, "proto"))
8527 #define _(a) else if (unformat (input, #a)) a=1;
8528 foreach_ip6_proto_field
8534 #define _(a) found_something += a;
8535 foreach_ip6_proto_field;
8538 if (found_something == 0)
8541 vec_validate (mask, sizeof (*ip) - 1);
8543 ip = (ip6_header_t *) mask;
8545 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8546 foreach_ip6_proto_field;
8549 ip_version_traffic_class_and_flow_label = 0;
8552 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8555 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8558 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8560 ip->ip_version_traffic_class_and_flow_label =
8561 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8568 unformat_l3_mask (unformat_input_t * input, va_list * args)
8570 u8 **maskp = va_arg (*args, u8 **);
8572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8574 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8576 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8585 unformat_l2_mask (unformat_input_t * input, va_list * args)
8587 u8 **maskp = va_arg (*args, u8 **);
8602 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8604 if (unformat (input, "src"))
8606 else if (unformat (input, "dst"))
8608 else if (unformat (input, "proto"))
8610 else if (unformat (input, "tag1"))
8612 else if (unformat (input, "tag2"))
8614 else if (unformat (input, "ignore-tag1"))
8616 else if (unformat (input, "ignore-tag2"))
8618 else if (unformat (input, "cos1"))
8620 else if (unformat (input, "cos2"))
8622 else if (unformat (input, "dot1q"))
8624 else if (unformat (input, "dot1ad"))
8629 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8630 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8633 if (tag1 || ignore_tag1 || cos1 || dot1q)
8635 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8638 vec_validate (mask, len - 1);
8641 memset (mask, 0xff, 6);
8644 memset (mask + 6, 0xff, 6);
8648 /* inner vlan tag */
8657 mask[21] = mask[20] = 0xff;
8678 mask[16] = mask[17] = 0xff;
8688 mask[12] = mask[13] = 0xff;
8695 unformat_classify_mask (unformat_input_t * input, va_list * args)
8697 u8 **maskp = va_arg (*args, u8 **);
8698 u32 *skipp = va_arg (*args, u32 *);
8699 u32 *matchp = va_arg (*args, u32 *);
8707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8709 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8711 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8713 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8715 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8729 if (mask || l2 || l3 || l4)
8733 /* "With a free Ethernet header in every package" */
8735 vec_validate (l2, 13);
8739 vec_append (mask, l3);
8744 vec_append (mask, l4);
8749 /* Scan forward looking for the first significant mask octet */
8750 for (i = 0; i < vec_len (mask); i++)
8754 /* compute (skip, match) params */
8755 *skipp = i / sizeof (u32x4);
8756 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8758 /* Pad mask to an even multiple of the vector size */
8759 while (vec_len (mask) % sizeof (u32x4))
8762 match = vec_len (mask) / sizeof (u32x4);
8764 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8766 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8767 if (*tmp || *(tmp + 1))
8772 clib_warning ("BUG: match 0");
8774 _vec_len (mask) = match * sizeof (u32x4);
8785 #define foreach_l2_next \
8787 _(ethernet, ETHERNET_INPUT) \
8792 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8794 u32 *miss_next_indexp = va_arg (*args, u32 *);
8799 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8803 if (unformat (input, "%d", &tmp))
8812 *miss_next_indexp = next_index;
8816 #define foreach_ip_next \
8822 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8824 u32 *miss_next_indexp = va_arg (*args, u32 *);
8829 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8833 if (unformat (input, "%d", &tmp))
8842 *miss_next_indexp = next_index;
8846 #define foreach_acl_next \
8850 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8852 u32 *miss_next_indexp = va_arg (*args, u32 *);
8857 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8861 if (unformat (input, "permit"))
8866 else if (unformat (input, "%d", &tmp))
8875 *miss_next_indexp = next_index;
8880 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8882 u32 *r = va_arg (*args, u32 *);
8884 if (unformat (input, "conform-color"))
8885 *r = POLICE_CONFORM;
8886 else if (unformat (input, "exceed-color"))
8895 api_classify_add_del_table (vat_main_t * vam)
8897 unformat_input_t *i = vam->input;
8898 vl_api_classify_add_del_table_t *mp;
8905 u32 table_index = ~0;
8906 u32 next_table_index = ~0;
8907 u32 miss_next_index = ~0;
8908 u32 memory_size = 32 << 20;
8911 u32 current_data_flag = 0;
8912 int current_data_offset = 0;
8914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8916 if (unformat (i, "del"))
8918 else if (unformat (i, "del-chain"))
8923 else if (unformat (i, "buckets %d", &nbuckets))
8925 else if (unformat (i, "memory_size %d", &memory_size))
8927 else if (unformat (i, "skip %d", &skip))
8929 else if (unformat (i, "match %d", &match))
8931 else if (unformat (i, "table %d", &table_index))
8933 else if (unformat (i, "mask %U", unformat_classify_mask,
8934 &mask, &skip, &match))
8936 else if (unformat (i, "next-table %d", &next_table_index))
8938 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8941 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8944 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8947 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8949 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8955 if (is_add && mask == 0)
8957 errmsg ("Mask required\n");
8961 if (is_add && skip == ~0)
8963 errmsg ("skip count required\n");
8967 if (is_add && match == ~0)
8969 errmsg ("match count required\n");
8973 if (!is_add && table_index == ~0)
8975 errmsg ("table index required for delete\n");
8979 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8981 mp->is_add = is_add;
8982 mp->del_chain = del_chain;
8983 mp->table_index = ntohl (table_index);
8984 mp->nbuckets = ntohl (nbuckets);
8985 mp->memory_size = ntohl (memory_size);
8986 mp->skip_n_vectors = ntohl (skip);
8987 mp->match_n_vectors = ntohl (match);
8988 mp->next_table_index = ntohl (next_table_index);
8989 mp->miss_next_index = ntohl (miss_next_index);
8990 mp->current_data_flag = ntohl (current_data_flag);
8991 mp->current_data_offset = ntohl (current_data_offset);
8992 clib_memcpy (mp->mask, mask, vec_len (mask));
9002 unformat_l4_match (unformat_input_t * input, va_list * args)
9004 u8 **matchp = va_arg (*args, u8 **);
9006 u8 *proto_header = 0;
9012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9014 if (unformat (input, "src_port %d", &src_port))
9016 else if (unformat (input, "dst_port %d", &dst_port))
9022 h.src_port = clib_host_to_net_u16 (src_port);
9023 h.dst_port = clib_host_to_net_u16 (dst_port);
9024 vec_validate (proto_header, sizeof (h) - 1);
9025 memcpy (proto_header, &h, sizeof (h));
9027 *matchp = proto_header;
9033 unformat_ip4_match (unformat_input_t * input, va_list * args)
9035 u8 **matchp = va_arg (*args, u8 **);
9042 int src = 0, dst = 0;
9043 ip4_address_t src_val, dst_val;
9050 int fragment_id = 0;
9051 u32 fragment_id_val;
9057 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9059 if (unformat (input, "version %d", &version_val))
9061 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9063 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9065 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9067 else if (unformat (input, "proto %d", &proto_val))
9069 else if (unformat (input, "tos %d", &tos_val))
9071 else if (unformat (input, "length %d", &length_val))
9073 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9075 else if (unformat (input, "ttl %d", &ttl_val))
9077 else if (unformat (input, "checksum %d", &checksum_val))
9083 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9084 + ttl + checksum == 0)
9088 * Aligned because we use the real comparison functions
9090 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9092 ip = (ip4_header_t *) match;
9094 /* These are realistically matched in practice */
9096 ip->src_address.as_u32 = src_val.as_u32;
9099 ip->dst_address.as_u32 = dst_val.as_u32;
9102 ip->protocol = proto_val;
9105 /* These are not, but they're included for completeness */
9107 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9110 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9116 ip->length = clib_host_to_net_u16 (length_val);
9122 ip->checksum = clib_host_to_net_u16 (checksum_val);
9129 unformat_ip6_match (unformat_input_t * input, va_list * args)
9131 u8 **matchp = va_arg (*args, u8 **);
9136 u8 traffic_class = 0;
9137 u32 traffic_class_val = 0;
9140 int src = 0, dst = 0;
9141 ip6_address_t src_val, dst_val;
9144 int payload_length = 0;
9145 u32 payload_length_val;
9148 u32 ip_version_traffic_class_and_flow_label;
9150 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9152 if (unformat (input, "version %d", &version_val))
9154 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9156 else if (unformat (input, "flow_label %d", &flow_label_val))
9158 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9160 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9162 else if (unformat (input, "proto %d", &proto_val))
9164 else if (unformat (input, "payload_length %d", &payload_length_val))
9166 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9172 if (version + traffic_class + flow_label + src + dst + proto +
9173 payload_length + hop_limit == 0)
9177 * Aligned because we use the real comparison functions
9179 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9181 ip = (ip6_header_t *) match;
9184 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9187 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9190 ip->protocol = proto_val;
9192 ip_version_traffic_class_and_flow_label = 0;
9195 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9198 ip_version_traffic_class_and_flow_label |=
9199 (traffic_class_val & 0xFF) << 20;
9202 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9204 ip->ip_version_traffic_class_and_flow_label =
9205 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9208 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9211 ip->hop_limit = hop_limit_val;
9218 unformat_l3_match (unformat_input_t * input, va_list * args)
9220 u8 **matchp = va_arg (*args, u8 **);
9222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9224 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9226 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9235 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9237 u8 *tagp = va_arg (*args, u8 *);
9240 if (unformat (input, "%d", &tag))
9242 tagp[0] = (tag >> 8) & 0x0F;
9243 tagp[1] = tag & 0xFF;
9251 unformat_l2_match (unformat_input_t * input, va_list * args)
9253 u8 **matchp = va_arg (*args, u8 **);
9273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9275 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9278 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9280 else if (unformat (input, "proto %U",
9281 unformat_ethernet_type_host_byte_order, &proto_val))
9283 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9285 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9287 else if (unformat (input, "ignore-tag1"))
9289 else if (unformat (input, "ignore-tag2"))
9291 else if (unformat (input, "cos1 %d", &cos1_val))
9293 else if (unformat (input, "cos2 %d", &cos2_val))
9298 if ((src + dst + proto + tag1 + tag2 +
9299 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9302 if (tag1 || ignore_tag1 || cos1)
9304 if (tag2 || ignore_tag2 || cos2)
9307 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9310 clib_memcpy (match, dst_val, 6);
9313 clib_memcpy (match + 6, src_val, 6);
9317 /* inner vlan tag */
9318 match[19] = tag2_val[1];
9319 match[18] = tag2_val[0];
9321 match[18] |= (cos2_val & 0x7) << 5;
9324 match[21] = proto_val & 0xff;
9325 match[20] = proto_val >> 8;
9329 match[15] = tag1_val[1];
9330 match[14] = tag1_val[0];
9333 match[14] |= (cos1_val & 0x7) << 5;
9339 match[15] = tag1_val[1];
9340 match[14] = tag1_val[0];
9343 match[17] = proto_val & 0xff;
9344 match[16] = proto_val >> 8;
9347 match[14] |= (cos1_val & 0x7) << 5;
9353 match[18] |= (cos2_val & 0x7) << 5;
9355 match[14] |= (cos1_val & 0x7) << 5;
9358 match[13] = proto_val & 0xff;
9359 match[12] = proto_val >> 8;
9368 unformat_classify_match (unformat_input_t * input, va_list * args)
9370 u8 **matchp = va_arg (*args, u8 **);
9371 u32 skip_n_vectors = va_arg (*args, u32);
9372 u32 match_n_vectors = va_arg (*args, u32);
9379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9381 if (unformat (input, "hex %U", unformat_hex_string, &match))
9383 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9385 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9387 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9401 if (match || l2 || l3 || l4)
9405 /* "Win a free Ethernet header in every packet" */
9407 vec_validate_aligned (l2, 13, sizeof (u32x4));
9411 vec_append_aligned (match, l3, sizeof (u32x4));
9416 vec_append_aligned (match, l4, sizeof (u32x4));
9421 /* Make sure the vector is big enough even if key is all 0's */
9422 vec_validate_aligned
9423 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9426 /* Set size, include skipped vectors */
9427 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9438 api_classify_add_del_session (vat_main_t * vam)
9440 unformat_input_t *i = vam->input;
9441 vl_api_classify_add_del_session_t *mp;
9443 u32 table_index = ~0;
9444 u32 hit_next_index = ~0;
9445 u32 opaque_index = ~0;
9449 u32 skip_n_vectors = 0;
9450 u32 match_n_vectors = 0;
9455 * Warning: you have to supply skip_n and match_n
9456 * because the API client cant simply look at the classify
9460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9462 if (unformat (i, "del"))
9464 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9467 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9470 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9473 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9475 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9477 else if (unformat (i, "opaque-index %d", &opaque_index))
9479 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9481 else if (unformat (i, "match_n %d", &match_n_vectors))
9483 else if (unformat (i, "match %U", unformat_classify_match,
9484 &match, skip_n_vectors, match_n_vectors))
9486 else if (unformat (i, "advance %d", &advance))
9488 else if (unformat (i, "table-index %d", &table_index))
9490 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9492 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9494 else if (unformat (i, "action %d", &action))
9496 else if (unformat (i, "metadata %d", &metadata))
9502 if (table_index == ~0)
9504 errmsg ("Table index required\n");
9508 if (is_add && match == 0)
9510 errmsg ("Match value required\n");
9514 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9516 mp->is_add = is_add;
9517 mp->table_index = ntohl (table_index);
9518 mp->hit_next_index = ntohl (hit_next_index);
9519 mp->opaque_index = ntohl (opaque_index);
9520 mp->advance = ntohl (advance);
9521 mp->action = action;
9522 mp->metadata = ntohl (metadata);
9523 clib_memcpy (mp->match, match, vec_len (match));
9532 api_classify_set_interface_ip_table (vat_main_t * vam)
9534 unformat_input_t *i = vam->input;
9535 vl_api_classify_set_interface_ip_table_t *mp;
9538 int sw_if_index_set;
9539 u32 table_index = ~0;
9542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9544 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9545 sw_if_index_set = 1;
9546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9547 sw_if_index_set = 1;
9548 else if (unformat (i, "table %d", &table_index))
9552 clib_warning ("parse error '%U'", format_unformat_error, i);
9557 if (sw_if_index_set == 0)
9559 errmsg ("missing interface name or sw_if_index\n");
9564 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9566 mp->sw_if_index = ntohl (sw_if_index);
9567 mp->table_index = ntohl (table_index);
9568 mp->is_ipv6 = is_ipv6;
9577 api_classify_set_interface_l2_tables (vat_main_t * vam)
9579 unformat_input_t *i = vam->input;
9580 vl_api_classify_set_interface_l2_tables_t *mp;
9583 int sw_if_index_set;
9584 u32 ip4_table_index = ~0;
9585 u32 ip6_table_index = ~0;
9586 u32 other_table_index = ~0;
9589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9591 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9592 sw_if_index_set = 1;
9593 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9594 sw_if_index_set = 1;
9595 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9597 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9599 else if (unformat (i, "other-table %d", &other_table_index))
9601 else if (unformat (i, "is-input %d", &is_input))
9605 clib_warning ("parse error '%U'", format_unformat_error, i);
9610 if (sw_if_index_set == 0)
9612 errmsg ("missing interface name or sw_if_index\n");
9617 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9619 mp->sw_if_index = ntohl (sw_if_index);
9620 mp->ip4_table_index = ntohl (ip4_table_index);
9621 mp->ip6_table_index = ntohl (ip6_table_index);
9622 mp->other_table_index = ntohl (other_table_index);
9623 mp->is_input = (u8) is_input;
9632 api_set_ipfix_exporter (vat_main_t * vam)
9634 unformat_input_t *i = vam->input;
9635 vl_api_set_ipfix_exporter_t *mp;
9636 ip4_address_t collector_address;
9637 u8 collector_address_set = 0;
9638 u32 collector_port = ~0;
9639 ip4_address_t src_address;
9640 u8 src_address_set = 0;
9643 u32 template_interval = ~0;
9644 u8 udp_checksum = 0;
9647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9649 if (unformat (i, "collector_address %U", unformat_ip4_address,
9650 &collector_address))
9651 collector_address_set = 1;
9652 else if (unformat (i, "collector_port %d", &collector_port))
9654 else if (unformat (i, "src_address %U", unformat_ip4_address,
9656 src_address_set = 1;
9657 else if (unformat (i, "vrf_id %d", &vrf_id))
9659 else if (unformat (i, "path_mtu %d", &path_mtu))
9661 else if (unformat (i, "template_interval %d", &template_interval))
9663 else if (unformat (i, "udp_checksum"))
9669 if (collector_address_set == 0)
9671 errmsg ("collector_address required\n");
9675 if (src_address_set == 0)
9677 errmsg ("src_address required\n");
9681 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9683 memcpy (mp->collector_address, collector_address.data,
9684 sizeof (collector_address.data));
9685 mp->collector_port = htons ((u16) collector_port);
9686 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9687 mp->vrf_id = htonl (vrf_id);
9688 mp->path_mtu = htonl (path_mtu);
9689 mp->template_interval = htonl (template_interval);
9690 mp->udp_checksum = udp_checksum;
9698 api_set_ipfix_classify_stream (vat_main_t * vam)
9700 unformat_input_t *i = vam->input;
9701 vl_api_set_ipfix_classify_stream_t *mp;
9703 u32 src_port = UDP_DST_PORT_ipfix;
9706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9708 if (unformat (i, "domain %d", &domain_id))
9710 else if (unformat (i, "src_port %d", &src_port))
9714 errmsg ("unknown input `%U'", format_unformat_error, i);
9719 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9721 mp->domain_id = htonl (domain_id);
9722 mp->src_port = htons ((u16) src_port);
9730 api_ipfix_classify_table_add_del (vat_main_t * vam)
9732 unformat_input_t *i = vam->input;
9733 vl_api_ipfix_classify_table_add_del_t *mp;
9735 u32 classify_table_index = ~0;
9737 u8 transport_protocol = 255;
9740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9742 if (unformat (i, "add"))
9744 else if (unformat (i, "del"))
9746 else if (unformat (i, "table %d", &classify_table_index))
9748 else if (unformat (i, "ip4"))
9750 else if (unformat (i, "ip6"))
9752 else if (unformat (i, "tcp"))
9753 transport_protocol = 6;
9754 else if (unformat (i, "udp"))
9755 transport_protocol = 17;
9758 errmsg ("unknown input `%U'", format_unformat_error, i);
9765 errmsg ("expecting: add|del");
9768 if (classify_table_index == ~0)
9770 errmsg ("classifier table not specified");
9773 if (ip_version == 0)
9775 errmsg ("IP version not specified");
9779 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9781 mp->is_add = is_add;
9782 mp->table_id = htonl (classify_table_index);
9783 mp->ip_version = ip_version;
9784 mp->transport_protocol = transport_protocol;
9792 api_get_node_index (vat_main_t * vam)
9794 unformat_input_t *i = vam->input;
9795 vl_api_get_node_index_t *mp;
9799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9801 if (unformat (i, "node %s", &name))
9808 errmsg ("node name required\n");
9811 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9813 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9817 M (GET_NODE_INDEX, get_node_index);
9818 clib_memcpy (mp->node_name, name, vec_len (name));
9828 api_get_next_index (vat_main_t * vam)
9830 unformat_input_t *i = vam->input;
9831 vl_api_get_next_index_t *mp;
9833 u8 *node_name = 0, *next_node_name = 0;
9835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9837 if (unformat (i, "node-name %s", &node_name))
9839 else if (unformat (i, "next-node-name %s", &next_node_name))
9845 errmsg ("node name required\n");
9848 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9850 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9854 if (next_node_name == 0)
9856 errmsg ("next node name required\n");
9859 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9861 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9865 M (GET_NEXT_INDEX, get_next_index);
9866 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9867 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9868 vec_free (node_name);
9869 vec_free (next_node_name);
9878 api_add_node_next (vat_main_t * vam)
9880 unformat_input_t *i = vam->input;
9881 vl_api_add_node_next_t *mp;
9886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9888 if (unformat (i, "node %s", &name))
9890 else if (unformat (i, "next %s", &next))
9897 errmsg ("node name required\n");
9900 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9902 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9907 errmsg ("next node required\n");
9910 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9912 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9916 M (ADD_NODE_NEXT, add_node_next);
9917 clib_memcpy (mp->node_name, name, vec_len (name));
9918 clib_memcpy (mp->next_name, next, vec_len (next));
9929 api_l2tpv3_create_tunnel (vat_main_t * vam)
9931 unformat_input_t *i = vam->input;
9932 ip6_address_t client_address, our_address;
9933 int client_address_set = 0;
9934 int our_address_set = 0;
9935 u32 local_session_id = 0;
9936 u32 remote_session_id = 0;
9937 u64 local_cookie = 0;
9938 u64 remote_cookie = 0;
9939 u8 l2_sublayer_present = 0;
9940 vl_api_l2tpv3_create_tunnel_t *mp;
9943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9945 if (unformat (i, "client_address %U", unformat_ip6_address,
9947 client_address_set = 1;
9948 else if (unformat (i, "our_address %U", unformat_ip6_address,
9950 our_address_set = 1;
9951 else if (unformat (i, "local_session_id %d", &local_session_id))
9953 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9955 else if (unformat (i, "local_cookie %lld", &local_cookie))
9957 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9959 else if (unformat (i, "l2-sublayer-present"))
9960 l2_sublayer_present = 1;
9965 if (client_address_set == 0)
9967 errmsg ("client_address required\n");
9971 if (our_address_set == 0)
9973 errmsg ("our_address required\n");
9977 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9979 clib_memcpy (mp->client_address, client_address.as_u8,
9980 sizeof (mp->client_address));
9982 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9984 mp->local_session_id = ntohl (local_session_id);
9985 mp->remote_session_id = ntohl (remote_session_id);
9986 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9987 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9988 mp->l2_sublayer_present = l2_sublayer_present;
9998 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10000 unformat_input_t *i = vam->input;
10002 u8 sw_if_index_set = 0;
10003 u64 new_local_cookie = 0;
10004 u64 new_remote_cookie = 0;
10005 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10010 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10011 sw_if_index_set = 1;
10012 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10013 sw_if_index_set = 1;
10014 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10016 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10022 if (sw_if_index_set == 0)
10024 errmsg ("missing interface name or sw_if_index\n");
10028 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
10030 mp->sw_if_index = ntohl (sw_if_index);
10031 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10032 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10041 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10043 unformat_input_t *i = vam->input;
10044 vl_api_l2tpv3_interface_enable_disable_t *mp;
10047 u8 sw_if_index_set = 0;
10048 u8 enable_disable = 1;
10050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10052 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10053 sw_if_index_set = 1;
10054 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10055 sw_if_index_set = 1;
10056 else if (unformat (i, "enable"))
10057 enable_disable = 1;
10058 else if (unformat (i, "disable"))
10059 enable_disable = 0;
10064 if (sw_if_index_set == 0)
10066 errmsg ("missing interface name or sw_if_index\n");
10070 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10072 mp->sw_if_index = ntohl (sw_if_index);
10073 mp->enable_disable = enable_disable;
10082 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10084 unformat_input_t *i = vam->input;
10085 vl_api_l2tpv3_set_lookup_key_t *mp;
10089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10091 if (unformat (i, "lookup_v6_src"))
10092 key = L2T_LOOKUP_SRC_ADDRESS;
10093 else if (unformat (i, "lookup_v6_dst"))
10094 key = L2T_LOOKUP_DST_ADDRESS;
10095 else if (unformat (i, "lookup_session_id"))
10096 key = L2T_LOOKUP_SESSION_ID;
10101 if (key == (u8) ~ 0)
10103 errmsg ("l2tp session lookup key unset\n");
10107 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10117 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10118 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10120 vat_main_t *vam = &vat_main;
10122 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
10123 format_ip6_address, mp->our_address,
10124 format_ip6_address, mp->client_address,
10125 clib_net_to_host_u32 (mp->sw_if_index));
10128 " local cookies %016llx %016llx remote cookie %016llx\n",
10129 clib_net_to_host_u64 (mp->local_cookie[0]),
10130 clib_net_to_host_u64 (mp->local_cookie[1]),
10131 clib_net_to_host_u64 (mp->remote_cookie));
10133 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
10134 clib_net_to_host_u32 (mp->local_session_id),
10135 clib_net_to_host_u32 (mp->remote_session_id));
10137 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
10138 mp->l2_sublayer_present ? "preset" : "absent");
10142 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10143 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10145 vat_main_t *vam = &vat_main;
10146 vat_json_node_t *node = NULL;
10147 struct in6_addr addr;
10149 if (VAT_JSON_ARRAY != vam->json_tree.type)
10151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10152 vat_json_init_array (&vam->json_tree);
10154 node = vat_json_array_add (&vam->json_tree);
10156 vat_json_init_object (node);
10158 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10159 vat_json_object_add_ip6 (node, "our_address", addr);
10160 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10161 vat_json_object_add_ip6 (node, "client_address", addr);
10163 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10164 vat_json_init_array (lc);
10165 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10166 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10167 vat_json_object_add_uint (node, "remote_cookie",
10168 clib_net_to_host_u64 (mp->remote_cookie));
10170 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10171 vat_json_object_add_uint (node, "local_session_id",
10172 clib_net_to_host_u32 (mp->local_session_id));
10173 vat_json_object_add_uint (node, "remote_session_id",
10174 clib_net_to_host_u32 (mp->remote_session_id));
10175 vat_json_object_add_string_copy (node, "l2_sublayer",
10176 mp->l2_sublayer_present ? (u8 *) "present"
10177 : (u8 *) "absent");
10181 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10183 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10186 /* Get list of l2tpv3-tunnel interfaces */
10187 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10190 /* Use a control ping for synchronization */
10192 vl_api_control_ping_t *mp;
10193 M (CONTROL_PING, control_ping);
10200 static void vl_api_sw_interface_tap_details_t_handler
10201 (vl_api_sw_interface_tap_details_t * mp)
10203 vat_main_t *vam = &vat_main;
10205 fformat (vam->ofp, "%-16s %d\n",
10206 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10209 static void vl_api_sw_interface_tap_details_t_handler_json
10210 (vl_api_sw_interface_tap_details_t * mp)
10212 vat_main_t *vam = &vat_main;
10213 vat_json_node_t *node = NULL;
10215 if (VAT_JSON_ARRAY != vam->json_tree.type)
10217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10218 vat_json_init_array (&vam->json_tree);
10220 node = vat_json_array_add (&vam->json_tree);
10222 vat_json_init_object (node);
10223 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10224 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10228 api_sw_interface_tap_dump (vat_main_t * vam)
10230 vl_api_sw_interface_tap_dump_t *mp;
10233 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
10234 /* Get list of tap interfaces */
10235 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10238 /* Use a control ping for synchronization */
10240 vl_api_control_ping_t *mp;
10241 M (CONTROL_PING, control_ping);
10247 static uword unformat_vxlan_decap_next
10248 (unformat_input_t * input, va_list * args)
10250 u32 *result = va_arg (*args, u32 *);
10253 if (unformat (input, "l2"))
10254 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10255 else if (unformat (input, "%d", &tmp))
10263 api_vxlan_add_del_tunnel (vat_main_t * vam)
10265 unformat_input_t *line_input = vam->input;
10266 vl_api_vxlan_add_del_tunnel_t *mp;
10268 ip46_address_t src, dst;
10270 u8 ipv4_set = 0, ipv6_set = 0;
10274 u32 mcast_sw_if_index = ~0;
10275 u32 encap_vrf_id = 0;
10276 u32 decap_next_index = ~0;
10279 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10280 memset (&src, 0, sizeof src);
10281 memset (&dst, 0, sizeof dst);
10283 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10285 if (unformat (line_input, "del"))
10288 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10294 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10300 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10306 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10311 else if (unformat (line_input, "group %U %U",
10312 unformat_ip4_address, &dst.ip4,
10313 unformat_sw_if_index, vam, &mcast_sw_if_index))
10315 grp_set = dst_set = 1;
10318 else if (unformat (line_input, "group %U",
10319 unformat_ip4_address, &dst.ip4))
10321 grp_set = dst_set = 1;
10324 else if (unformat (line_input, "group %U %U",
10325 unformat_ip6_address, &dst.ip6,
10326 unformat_sw_if_index, vam, &mcast_sw_if_index))
10328 grp_set = dst_set = 1;
10331 else if (unformat (line_input, "group %U",
10332 unformat_ip6_address, &dst.ip6))
10334 grp_set = dst_set = 1;
10338 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10340 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10342 else if (unformat (line_input, "decap-next %U",
10343 unformat_vxlan_decap_next, &decap_next_index))
10345 else if (unformat (line_input, "vni %d", &vni))
10349 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10356 errmsg ("tunnel src address not specified\n");
10361 errmsg ("tunnel dst address not specified\n");
10365 if (grp_set && !ip46_address_is_multicast (&dst))
10367 errmsg ("tunnel group address not multicast\n");
10370 if (grp_set && mcast_sw_if_index == ~0)
10372 errmsg ("tunnel nonexistent multicast device\n");
10375 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10377 errmsg ("tunnel dst address must be unicast\n");
10382 if (ipv4_set && ipv6_set)
10384 errmsg ("both IPv4 and IPv6 addresses specified");
10388 if ((vni == 0) || (vni >> 24))
10390 errmsg ("vni not specified or out of range\n");
10394 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10398 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10399 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10403 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10404 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10406 mp->encap_vrf_id = ntohl (encap_vrf_id);
10407 mp->decap_next_index = ntohl (decap_next_index);
10408 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10409 mp->vni = ntohl (vni);
10410 mp->is_add = is_add;
10411 mp->is_ipv6 = ipv6_set;
10419 static void vl_api_vxlan_tunnel_details_t_handler
10420 (vl_api_vxlan_tunnel_details_t * mp)
10422 vat_main_t *vam = &vat_main;
10423 ip46_address_t src, dst;
10425 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10426 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10428 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d\n",
10429 ntohl (mp->sw_if_index),
10430 format_ip46_address, &src, IP46_TYPE_ANY,
10431 format_ip46_address, &dst, IP46_TYPE_ANY,
10432 ntohl (mp->encap_vrf_id),
10433 ntohl (mp->decap_next_index), ntohl (mp->vni),
10434 ntohl (mp->mcast_sw_if_index));
10437 static void vl_api_vxlan_tunnel_details_t_handler_json
10438 (vl_api_vxlan_tunnel_details_t * mp)
10440 vat_main_t *vam = &vat_main;
10441 vat_json_node_t *node = NULL;
10443 if (VAT_JSON_ARRAY != vam->json_tree.type)
10445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10446 vat_json_init_array (&vam->json_tree);
10448 node = vat_json_array_add (&vam->json_tree);
10450 vat_json_init_object (node);
10451 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10454 struct in6_addr ip6;
10456 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10457 vat_json_object_add_ip6 (node, "src_address", ip6);
10458 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10459 vat_json_object_add_ip6 (node, "dst_address", ip6);
10463 struct in_addr ip4;
10465 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10466 vat_json_object_add_ip4 (node, "src_address", ip4);
10467 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10468 vat_json_object_add_ip4 (node, "dst_address", ip4);
10470 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10471 vat_json_object_add_uint (node, "decap_next_index",
10472 ntohl (mp->decap_next_index));
10473 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10474 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10475 vat_json_object_add_uint (node, "mcast_sw_if_index",
10476 ntohl (mp->mcast_sw_if_index));
10480 api_vxlan_tunnel_dump (vat_main_t * vam)
10482 unformat_input_t *i = vam->input;
10483 vl_api_vxlan_tunnel_dump_t *mp;
10486 u8 sw_if_index_set = 0;
10488 /* Parse args required to build the message */
10489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10491 if (unformat (i, "sw_if_index %d", &sw_if_index))
10492 sw_if_index_set = 1;
10497 if (sw_if_index_set == 0)
10502 if (!vam->json_output)
10504 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s\n",
10505 "sw_if_index", "src_address", "dst_address",
10506 "encap_vrf_id", "decap_next_index", "vni",
10507 "mcast_sw_if_index");
10510 /* Get list of vxlan-tunnel interfaces */
10511 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10513 mp->sw_if_index = htonl (sw_if_index);
10517 /* Use a control ping for synchronization */
10519 vl_api_control_ping_t *mp;
10520 M (CONTROL_PING, control_ping);
10527 api_gre_add_del_tunnel (vat_main_t * vam)
10529 unformat_input_t *line_input = vam->input;
10530 vl_api_gre_add_del_tunnel_t *mp;
10532 ip4_address_t src4, dst4;
10537 u32 outer_fib_id = 0;
10539 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10541 if (unformat (line_input, "del"))
10543 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10545 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10547 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10549 else if (unformat (line_input, "teb"))
10553 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10560 errmsg ("tunnel src address not specified\n");
10565 errmsg ("tunnel dst address not specified\n");
10570 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10572 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10573 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10574 mp->outer_fib_id = ntohl (outer_fib_id);
10575 mp->is_add = is_add;
10584 static void vl_api_gre_tunnel_details_t_handler
10585 (vl_api_gre_tunnel_details_t * mp)
10587 vat_main_t *vam = &vat_main;
10589 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
10590 ntohl (mp->sw_if_index),
10591 format_ip4_address, &mp->src_address,
10592 format_ip4_address, &mp->dst_address,
10593 mp->teb, ntohl (mp->outer_fib_id));
10596 static void vl_api_gre_tunnel_details_t_handler_json
10597 (vl_api_gre_tunnel_details_t * mp)
10599 vat_main_t *vam = &vat_main;
10600 vat_json_node_t *node = NULL;
10601 struct in_addr ip4;
10603 if (VAT_JSON_ARRAY != vam->json_tree.type)
10605 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10606 vat_json_init_array (&vam->json_tree);
10608 node = vat_json_array_add (&vam->json_tree);
10610 vat_json_init_object (node);
10611 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10612 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10613 vat_json_object_add_ip4 (node, "src_address", ip4);
10614 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10615 vat_json_object_add_ip4 (node, "dst_address", ip4);
10616 vat_json_object_add_uint (node, "teb", mp->teb);
10617 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10621 api_gre_tunnel_dump (vat_main_t * vam)
10623 unformat_input_t *i = vam->input;
10624 vl_api_gre_tunnel_dump_t *mp;
10627 u8 sw_if_index_set = 0;
10629 /* Parse args required to build the message */
10630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10632 if (unformat (i, "sw_if_index %d", &sw_if_index))
10633 sw_if_index_set = 1;
10638 if (sw_if_index_set == 0)
10643 if (!vam->json_output)
10645 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
10646 "sw_if_index", "src_address", "dst_address", "teb",
10650 /* Get list of gre-tunnel interfaces */
10651 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10653 mp->sw_if_index = htonl (sw_if_index);
10657 /* Use a control ping for synchronization */
10659 vl_api_control_ping_t *mp;
10660 M (CONTROL_PING, control_ping);
10667 api_l2_fib_clear_table (vat_main_t * vam)
10669 // unformat_input_t * i = vam->input;
10670 vl_api_l2_fib_clear_table_t *mp;
10673 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10682 api_l2_interface_efp_filter (vat_main_t * vam)
10684 unformat_input_t *i = vam->input;
10685 vl_api_l2_interface_efp_filter_t *mp;
10689 u8 sw_if_index_set = 0;
10691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10693 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10694 sw_if_index_set = 1;
10695 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10696 sw_if_index_set = 1;
10697 else if (unformat (i, "enable"))
10699 else if (unformat (i, "disable"))
10703 clib_warning ("parse error '%U'", format_unformat_error, i);
10708 if (sw_if_index_set == 0)
10710 errmsg ("missing sw_if_index\n");
10714 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10716 mp->sw_if_index = ntohl (sw_if_index);
10717 mp->enable_disable = enable;
10725 #define foreach_vtr_op \
10726 _("disable", L2_VTR_DISABLED) \
10727 _("push-1", L2_VTR_PUSH_1) \
10728 _("push-2", L2_VTR_PUSH_2) \
10729 _("pop-1", L2_VTR_POP_1) \
10730 _("pop-2", L2_VTR_POP_2) \
10731 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10732 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10733 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10734 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10737 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10739 unformat_input_t *i = vam->input;
10740 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10743 u8 sw_if_index_set = 0;
10746 u32 push_dot1q = 1;
10750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10752 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10753 sw_if_index_set = 1;
10754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10755 sw_if_index_set = 1;
10756 else if (unformat (i, "vtr_op %d", &vtr_op))
10758 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10761 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10763 else if (unformat (i, "tag1 %d", &tag1))
10765 else if (unformat (i, "tag2 %d", &tag2))
10769 clib_warning ("parse error '%U'", format_unformat_error, i);
10774 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10776 errmsg ("missing vtr operation or sw_if_index\n");
10780 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10781 mp->sw_if_index = ntohl (sw_if_index);
10782 mp->vtr_op = ntohl (vtr_op);
10783 mp->push_dot1q = ntohl (push_dot1q);
10784 mp->tag1 = ntohl (tag1);
10785 mp->tag2 = ntohl (tag2);
10794 api_create_vhost_user_if (vat_main_t * vam)
10796 unformat_input_t *i = vam->input;
10797 vl_api_create_vhost_user_if_t *mp;
10801 u8 file_name_set = 0;
10802 u32 custom_dev_instance = ~0;
10804 u8 use_custom_mac = 0;
10807 /* Shut up coverity */
10808 memset (hwaddr, 0, sizeof (hwaddr));
10810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10812 if (unformat (i, "socket %s", &file_name))
10816 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10818 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10819 use_custom_mac = 1;
10820 else if (unformat (i, "server"))
10822 else if (unformat (i, "tag %s", &tag))
10828 if (file_name_set == 0)
10830 errmsg ("missing socket file name\n");
10834 if (vec_len (file_name) > 255)
10836 errmsg ("socket file name too long\n");
10839 vec_add1 (file_name, 0);
10841 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10843 mp->is_server = is_server;
10844 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10845 vec_free (file_name);
10846 if (custom_dev_instance != ~0)
10849 mp->custom_dev_instance = ntohl (custom_dev_instance);
10851 mp->use_custom_mac = use_custom_mac;
10852 clib_memcpy (mp->mac_address, hwaddr, 6);
10854 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10864 api_modify_vhost_user_if (vat_main_t * vam)
10866 unformat_input_t *i = vam->input;
10867 vl_api_modify_vhost_user_if_t *mp;
10871 u8 file_name_set = 0;
10872 u32 custom_dev_instance = ~0;
10873 u8 sw_if_index_set = 0;
10874 u32 sw_if_index = (u32) ~ 0;
10876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10878 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10879 sw_if_index_set = 1;
10880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10881 sw_if_index_set = 1;
10882 else if (unformat (i, "socket %s", &file_name))
10886 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10888 else if (unformat (i, "server"))
10894 if (sw_if_index_set == 0)
10896 errmsg ("missing sw_if_index or interface name\n");
10900 if (file_name_set == 0)
10902 errmsg ("missing socket file name\n");
10906 if (vec_len (file_name) > 255)
10908 errmsg ("socket file name too long\n");
10911 vec_add1 (file_name, 0);
10913 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10915 mp->sw_if_index = ntohl (sw_if_index);
10916 mp->is_server = is_server;
10917 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10918 vec_free (file_name);
10919 if (custom_dev_instance != ~0)
10922 mp->custom_dev_instance = ntohl (custom_dev_instance);
10932 api_delete_vhost_user_if (vat_main_t * vam)
10934 unformat_input_t *i = vam->input;
10935 vl_api_delete_vhost_user_if_t *mp;
10937 u32 sw_if_index = ~0;
10938 u8 sw_if_index_set = 0;
10940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10942 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10943 sw_if_index_set = 1;
10944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10945 sw_if_index_set = 1;
10950 if (sw_if_index_set == 0)
10952 errmsg ("missing sw_if_index or interface name\n");
10957 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10959 mp->sw_if_index = ntohl (sw_if_index);
10967 static void vl_api_sw_interface_vhost_user_details_t_handler
10968 (vl_api_sw_interface_vhost_user_details_t * mp)
10970 vat_main_t *vam = &vat_main;
10972 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10973 (char *) mp->interface_name,
10974 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10975 clib_net_to_host_u64 (mp->features), mp->is_server,
10976 ntohl (mp->num_regions), (char *) mp->sock_filename);
10977 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10980 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10981 (vl_api_sw_interface_vhost_user_details_t * mp)
10983 vat_main_t *vam = &vat_main;
10984 vat_json_node_t *node = NULL;
10986 if (VAT_JSON_ARRAY != vam->json_tree.type)
10988 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10989 vat_json_init_array (&vam->json_tree);
10991 node = vat_json_array_add (&vam->json_tree);
10993 vat_json_init_object (node);
10994 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10995 vat_json_object_add_string_copy (node, "interface_name",
10996 mp->interface_name);
10997 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10998 ntohl (mp->virtio_net_hdr_sz));
10999 vat_json_object_add_uint (node, "features",
11000 clib_net_to_host_u64 (mp->features));
11001 vat_json_object_add_uint (node, "is_server", mp->is_server);
11002 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11003 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11004 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11008 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11010 vl_api_sw_interface_vhost_user_dump_t *mp;
11013 "Interface name idx hdr_sz features server regions filename\n");
11015 /* Get list of vhost-user interfaces */
11016 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
11019 /* Use a control ping for synchronization */
11021 vl_api_control_ping_t *mp;
11022 M (CONTROL_PING, control_ping);
11029 api_show_version (vat_main_t * vam)
11031 vl_api_show_version_t *mp;
11034 M (SHOW_VERSION, show_version);
11044 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11046 unformat_input_t *line_input = vam->input;
11047 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11049 ip4_address_t local4, remote4;
11050 ip6_address_t local6, remote6;
11052 u8 ipv4_set = 0, ipv6_set = 0;
11055 u32 encap_vrf_id = 0;
11056 u32 decap_vrf_id = 0;
11061 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11063 if (unformat (line_input, "del"))
11065 else if (unformat (line_input, "local %U",
11066 unformat_ip4_address, &local4))
11071 else if (unformat (line_input, "remote %U",
11072 unformat_ip4_address, &remote4))
11077 else if (unformat (line_input, "local %U",
11078 unformat_ip6_address, &local6))
11083 else if (unformat (line_input, "remote %U",
11084 unformat_ip6_address, &remote6))
11089 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11091 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11093 else if (unformat (line_input, "vni %d", &vni))
11095 else if (unformat (line_input, "next-ip4"))
11097 else if (unformat (line_input, "next-ip6"))
11099 else if (unformat (line_input, "next-ethernet"))
11101 else if (unformat (line_input, "next-nsh"))
11105 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
11110 if (local_set == 0)
11112 errmsg ("tunnel local address not specified\n");
11115 if (remote_set == 0)
11117 errmsg ("tunnel remote address not specified\n");
11120 if (ipv4_set && ipv6_set)
11122 errmsg ("both IPv4 and IPv6 addresses specified");
11128 errmsg ("vni not specified\n");
11132 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11137 clib_memcpy (&mp->local, &local6, sizeof (local6));
11138 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11142 clib_memcpy (&mp->local, &local4, sizeof (local4));
11143 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11146 mp->encap_vrf_id = ntohl (encap_vrf_id);
11147 mp->decap_vrf_id = ntohl (decap_vrf_id);
11148 mp->protocol = protocol;
11149 mp->vni = ntohl (vni);
11150 mp->is_add = is_add;
11151 mp->is_ipv6 = ipv6_set;
11159 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11160 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11162 vat_main_t *vam = &vat_main;
11164 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
11165 ntohl (mp->sw_if_index),
11166 format_ip46_address, &(mp->local[0]),
11167 format_ip46_address, &(mp->remote[0]),
11169 ntohl (mp->protocol),
11170 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11173 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11174 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11176 vat_main_t *vam = &vat_main;
11177 vat_json_node_t *node = NULL;
11178 struct in_addr ip4;
11179 struct in6_addr ip6;
11181 if (VAT_JSON_ARRAY != vam->json_tree.type)
11183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11184 vat_json_init_array (&vam->json_tree);
11186 node = vat_json_array_add (&vam->json_tree);
11188 vat_json_init_object (node);
11189 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11192 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11193 vat_json_object_add_ip6 (node, "local", ip6);
11194 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11195 vat_json_object_add_ip6 (node, "remote", ip6);
11199 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11200 vat_json_object_add_ip4 (node, "local", ip4);
11201 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11202 vat_json_object_add_ip4 (node, "remote", ip4);
11204 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11205 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11206 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11207 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11208 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11212 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11214 unformat_input_t *i = vam->input;
11215 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11218 u8 sw_if_index_set = 0;
11220 /* Parse args required to build the message */
11221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11223 if (unformat (i, "sw_if_index %d", &sw_if_index))
11224 sw_if_index_set = 1;
11229 if (sw_if_index_set == 0)
11234 if (!vam->json_output)
11236 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
11237 "sw_if_index", "local", "remote", "vni",
11238 "protocol", "encap_vrf_id", "decap_vrf_id");
11241 /* Get list of vxlan-tunnel interfaces */
11242 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11244 mp->sw_if_index = htonl (sw_if_index);
11248 /* Use a control ping for synchronization */
11250 vl_api_control_ping_t *mp;
11251 M (CONTROL_PING, control_ping);
11258 format_l2_fib_mac_address (u8 * s, va_list * args)
11260 u8 *a = va_arg (*args, u8 *);
11262 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11263 a[2], a[3], a[4], a[5], a[6], a[7]);
11266 static void vl_api_l2_fib_table_entry_t_handler
11267 (vl_api_l2_fib_table_entry_t * mp)
11269 vat_main_t *vam = &vat_main;
11271 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11273 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11274 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11278 static void vl_api_l2_fib_table_entry_t_handler_json
11279 (vl_api_l2_fib_table_entry_t * mp)
11281 vat_main_t *vam = &vat_main;
11282 vat_json_node_t *node = NULL;
11284 if (VAT_JSON_ARRAY != vam->json_tree.type)
11286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11287 vat_json_init_array (&vam->json_tree);
11289 node = vat_json_array_add (&vam->json_tree);
11291 vat_json_init_object (node);
11292 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11293 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11294 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11295 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11296 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11297 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11301 api_l2_fib_table_dump (vat_main_t * vam)
11303 unformat_input_t *i = vam->input;
11304 vl_api_l2_fib_table_dump_t *mp;
11309 /* Parse args required to build the message */
11310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11312 if (unformat (i, "bd_id %d", &bd_id))
11318 if (bd_id_set == 0)
11320 errmsg ("missing bridge domain\n");
11325 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
11327 /* Get list of l2 fib entries */
11328 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11330 mp->bd_id = ntohl (bd_id);
11333 /* Use a control ping for synchronization */
11335 vl_api_control_ping_t *mp;
11336 M (CONTROL_PING, control_ping);
11344 api_interface_name_renumber (vat_main_t * vam)
11346 unformat_input_t *line_input = vam->input;
11347 vl_api_interface_name_renumber_t *mp;
11348 u32 sw_if_index = ~0;
11350 u32 new_show_dev_instance = ~0;
11352 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11354 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
11357 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11359 else if (unformat (line_input, "new_show_dev_instance %d",
11360 &new_show_dev_instance))
11366 if (sw_if_index == ~0)
11368 errmsg ("missing interface name or sw_if_index\n");
11372 if (new_show_dev_instance == ~0)
11374 errmsg ("missing new_show_dev_instance\n");
11378 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11380 mp->sw_if_index = ntohl (sw_if_index);
11381 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11388 api_want_ip4_arp_events (vat_main_t * vam)
11390 unformat_input_t *line_input = vam->input;
11391 vl_api_want_ip4_arp_events_t *mp;
11393 ip4_address_t address;
11394 int address_set = 0;
11395 u32 enable_disable = 1;
11397 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11399 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11401 else if (unformat (line_input, "del"))
11402 enable_disable = 0;
11407 if (address_set == 0)
11409 errmsg ("missing addresses\n");
11413 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11414 mp->enable_disable = enable_disable;
11415 mp->pid = getpid ();
11416 mp->address = address.as_u32;
11423 api_want_ip6_nd_events (vat_main_t * vam)
11425 unformat_input_t *line_input = vam->input;
11426 vl_api_want_ip6_nd_events_t *mp;
11428 ip6_address_t address;
11429 int address_set = 0;
11430 u32 enable_disable = 1;
11432 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11434 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11436 else if (unformat (line_input, "del"))
11437 enable_disable = 0;
11442 if (address_set == 0)
11444 errmsg ("missing addresses\n");
11448 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11449 mp->enable_disable = enable_disable;
11450 mp->pid = getpid ();
11451 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11458 api_input_acl_set_interface (vat_main_t * vam)
11460 unformat_input_t *i = vam->input;
11461 vl_api_input_acl_set_interface_t *mp;
11464 int sw_if_index_set;
11465 u32 ip4_table_index = ~0;
11466 u32 ip6_table_index = ~0;
11467 u32 l2_table_index = ~0;
11470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11472 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11473 sw_if_index_set = 1;
11474 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11475 sw_if_index_set = 1;
11476 else if (unformat (i, "del"))
11478 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11480 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11482 else if (unformat (i, "l2-table %d", &l2_table_index))
11486 clib_warning ("parse error '%U'", format_unformat_error, i);
11491 if (sw_if_index_set == 0)
11493 errmsg ("missing interface name or sw_if_index\n");
11497 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11499 mp->sw_if_index = ntohl (sw_if_index);
11500 mp->ip4_table_index = ntohl (ip4_table_index);
11501 mp->ip6_table_index = ntohl (ip6_table_index);
11502 mp->l2_table_index = ntohl (l2_table_index);
11503 mp->is_add = is_add;
11512 api_ip_address_dump (vat_main_t * vam)
11514 unformat_input_t *i = vam->input;
11515 vl_api_ip_address_dump_t *mp;
11516 u32 sw_if_index = ~0;
11517 u8 sw_if_index_set = 0;
11522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11524 if (unformat (i, "sw_if_index %d", &sw_if_index))
11525 sw_if_index_set = 1;
11526 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11527 sw_if_index_set = 1;
11528 else if (unformat (i, "ipv4"))
11530 else if (unformat (i, "ipv6"))
11536 if (ipv4_set && ipv6_set)
11538 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11542 if ((!ipv4_set) && (!ipv6_set))
11544 errmsg ("no ipv4 nor ipv6 flag set\n");
11548 if (sw_if_index_set == 0)
11550 errmsg ("missing interface name or sw_if_index\n");
11554 vam->current_sw_if_index = sw_if_index;
11555 vam->is_ipv6 = ipv6_set;
11557 M (IP_ADDRESS_DUMP, ip_address_dump);
11558 mp->sw_if_index = ntohl (sw_if_index);
11559 mp->is_ipv6 = ipv6_set;
11562 /* Use a control ping for synchronization */
11564 vl_api_control_ping_t *mp;
11565 M (CONTROL_PING, control_ping);
11572 api_ip_dump (vat_main_t * vam)
11574 vl_api_ip_dump_t *mp;
11575 unformat_input_t *in = vam->input;
11582 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11584 if (unformat (in, "ipv4"))
11586 else if (unformat (in, "ipv6"))
11592 if (ipv4_set && ipv6_set)
11594 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11598 if ((!ipv4_set) && (!ipv6_set))
11600 errmsg ("no ipv4 nor ipv6 flag set\n");
11604 is_ipv6 = ipv6_set;
11605 vam->is_ipv6 = is_ipv6;
11607 /* free old data */
11608 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11610 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11612 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11614 M (IP_DUMP, ip_dump);
11615 mp->is_ipv6 = ipv6_set;
11618 /* Use a control ping for synchronization */
11620 vl_api_control_ping_t *mp;
11621 M (CONTROL_PING, control_ping);
11628 api_ipsec_spd_add_del (vat_main_t * vam)
11630 unformat_input_t *i = vam->input;
11631 vl_api_ipsec_spd_add_del_t *mp;
11636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11638 if (unformat (i, "spd_id %d", &spd_id))
11640 else if (unformat (i, "del"))
11644 clib_warning ("parse error '%U'", format_unformat_error, i);
11650 errmsg ("spd_id must be set\n");
11654 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11656 mp->spd_id = ntohl (spd_id);
11657 mp->is_add = is_add;
11666 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11668 unformat_input_t *i = vam->input;
11669 vl_api_ipsec_interface_add_del_spd_t *mp;
11672 u8 sw_if_index_set = 0;
11673 u32 spd_id = (u32) ~ 0;
11676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11678 if (unformat (i, "del"))
11680 else if (unformat (i, "spd_id %d", &spd_id))
11682 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11683 sw_if_index_set = 1;
11684 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11685 sw_if_index_set = 1;
11688 clib_warning ("parse error '%U'", format_unformat_error, i);
11694 if (spd_id == (u32) ~ 0)
11696 errmsg ("spd_id must be set\n");
11700 if (sw_if_index_set == 0)
11702 errmsg ("missing interface name or sw_if_index\n");
11706 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11708 mp->spd_id = ntohl (spd_id);
11709 mp->sw_if_index = ntohl (sw_if_index);
11710 mp->is_add = is_add;
11719 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11721 unformat_input_t *i = vam->input;
11722 vl_api_ipsec_spd_add_del_entry_t *mp;
11724 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11725 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11727 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11728 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11729 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11730 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11732 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11733 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11734 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11735 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11736 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11737 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11741 if (unformat (i, "del"))
11743 if (unformat (i, "outbound"))
11745 if (unformat (i, "inbound"))
11747 else if (unformat (i, "spd_id %d", &spd_id))
11749 else if (unformat (i, "sa_id %d", &sa_id))
11751 else if (unformat (i, "priority %d", &priority))
11753 else if (unformat (i, "protocol %d", &protocol))
11755 else if (unformat (i, "lport_start %d", &lport_start))
11757 else if (unformat (i, "lport_stop %d", &lport_stop))
11759 else if (unformat (i, "rport_start %d", &rport_start))
11761 else if (unformat (i, "rport_stop %d", &rport_stop))
11765 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11771 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11778 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11784 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11791 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11797 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11804 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11810 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11816 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11818 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11820 clib_warning ("unsupported action: 'resolve'");
11826 clib_warning ("parse error '%U'", format_unformat_error, i);
11832 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11834 mp->spd_id = ntohl (spd_id);
11835 mp->priority = ntohl (priority);
11836 mp->is_outbound = is_outbound;
11838 mp->is_ipv6 = is_ipv6;
11839 if (is_ipv6 || is_ip_any)
11841 clib_memcpy (mp->remote_address_start, &raddr6_start,
11842 sizeof (ip6_address_t));
11843 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11844 sizeof (ip6_address_t));
11845 clib_memcpy (mp->local_address_start, &laddr6_start,
11846 sizeof (ip6_address_t));
11847 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11848 sizeof (ip6_address_t));
11852 clib_memcpy (mp->remote_address_start, &raddr4_start,
11853 sizeof (ip4_address_t));
11854 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11855 sizeof (ip4_address_t));
11856 clib_memcpy (mp->local_address_start, &laddr4_start,
11857 sizeof (ip4_address_t));
11858 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11859 sizeof (ip4_address_t));
11861 mp->protocol = (u8) protocol;
11862 mp->local_port_start = ntohs ((u16) lport_start);
11863 mp->local_port_stop = ntohs ((u16) lport_stop);
11864 mp->remote_port_start = ntohs ((u16) rport_start);
11865 mp->remote_port_stop = ntohs ((u16) rport_stop);
11866 mp->policy = (u8) policy;
11867 mp->sa_id = ntohl (sa_id);
11868 mp->is_add = is_add;
11869 mp->is_ip_any = is_ip_any;
11877 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11879 unformat_input_t *i = vam->input;
11880 vl_api_ipsec_sad_add_del_entry_t *mp;
11882 u32 sad_id = 0, spi = 0;
11883 u8 *ck = 0, *ik = 0;
11886 u8 protocol = IPSEC_PROTOCOL_AH;
11887 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11888 u32 crypto_alg = 0, integ_alg = 0;
11889 ip4_address_t tun_src4;
11890 ip4_address_t tun_dst4;
11891 ip6_address_t tun_src6;
11892 ip6_address_t tun_dst6;
11894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11896 if (unformat (i, "del"))
11898 else if (unformat (i, "sad_id %d", &sad_id))
11900 else if (unformat (i, "spi %d", &spi))
11902 else if (unformat (i, "esp"))
11903 protocol = IPSEC_PROTOCOL_ESP;
11904 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11907 is_tunnel_ipv6 = 0;
11909 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11912 is_tunnel_ipv6 = 0;
11914 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11917 is_tunnel_ipv6 = 1;
11919 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11922 is_tunnel_ipv6 = 1;
11926 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11928 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11929 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11931 clib_warning ("unsupported crypto-alg: '%U'",
11932 format_ipsec_crypto_alg, crypto_alg);
11936 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11940 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11943 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11945 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11947 integ_alg >= IPSEC_INTEG_N_ALG)
11949 clib_warning ("unsupported integ-alg: '%U'",
11950 format_ipsec_integ_alg, integ_alg);
11954 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11958 clib_warning ("parse error '%U'", format_unformat_error, i);
11965 /*Special cases, aes-gcm-128 encryption */
11966 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11968 if (integ_alg != IPSEC_INTEG_ALG_NONE
11969 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11972 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11975 else /*set integ-alg internally to aes-gcm-128 */
11976 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11978 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11980 clib_warning ("unsupported integ-alg: aes-gcm-128");
11983 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11985 clib_warning ("unsupported integ-alg: none");
11991 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11993 mp->sad_id = ntohl (sad_id);
11994 mp->is_add = is_add;
11995 mp->protocol = protocol;
11996 mp->spi = ntohl (spi);
11997 mp->is_tunnel = is_tunnel;
11998 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11999 mp->crypto_algorithm = crypto_alg;
12000 mp->integrity_algorithm = integ_alg;
12001 mp->crypto_key_length = vec_len (ck);
12002 mp->integrity_key_length = vec_len (ik);
12004 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12005 mp->crypto_key_length = sizeof (mp->crypto_key);
12007 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12008 mp->integrity_key_length = sizeof (mp->integrity_key);
12011 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12013 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12017 if (is_tunnel_ipv6)
12019 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12020 sizeof (ip6_address_t));
12021 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12022 sizeof (ip6_address_t));
12026 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12027 sizeof (ip4_address_t));
12028 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12029 sizeof (ip4_address_t));
12040 api_ipsec_sa_set_key (vat_main_t * vam)
12042 unformat_input_t *i = vam->input;
12043 vl_api_ipsec_sa_set_key_t *mp;
12046 u8 *ck = 0, *ik = 0;
12048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12050 if (unformat (i, "sa_id %d", &sa_id))
12052 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12054 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12058 clib_warning ("parse error '%U'", format_unformat_error, i);
12063 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12065 mp->sa_id = ntohl (sa_id);
12066 mp->crypto_key_length = vec_len (ck);
12067 mp->integrity_key_length = vec_len (ik);
12069 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12070 mp->crypto_key_length = sizeof (mp->crypto_key);
12072 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12073 mp->integrity_key_length = sizeof (mp->integrity_key);
12076 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12078 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12087 api_ikev2_profile_add_del (vat_main_t * vam)
12089 unformat_input_t *i = vam->input;
12090 vl_api_ikev2_profile_add_del_t *mp;
12095 const char *valid_chars = "a-zA-Z0-9_";
12097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12099 if (unformat (i, "del"))
12101 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12102 vec_add1 (name, 0);
12105 errmsg ("parse error '%U'", format_unformat_error, i);
12110 if (!vec_len (name))
12112 errmsg ("profile name must be specified");
12116 if (vec_len (name) > 64)
12118 errmsg ("profile name too long");
12122 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12124 clib_memcpy (mp->name, name, vec_len (name));
12125 mp->is_add = is_add;
12135 api_ikev2_profile_set_auth (vat_main_t * vam)
12137 unformat_input_t *i = vam->input;
12138 vl_api_ikev2_profile_set_auth_t *mp;
12142 u32 auth_method = 0;
12145 const char *valid_chars = "a-zA-Z0-9_";
12147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12149 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12150 vec_add1 (name, 0);
12151 else if (unformat (i, "auth_method %U",
12152 unformat_ikev2_auth_method, &auth_method))
12154 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12156 else if (unformat (i, "auth_data %v", &data))
12160 errmsg ("parse error '%U'", format_unformat_error, i);
12165 if (!vec_len (name))
12167 errmsg ("profile name must be specified");
12171 if (vec_len (name) > 64)
12173 errmsg ("profile name too long");
12177 if (!vec_len (data))
12179 errmsg ("auth_data must be specified");
12185 errmsg ("auth_method must be specified");
12189 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12191 mp->is_hex = is_hex;
12192 mp->auth_method = (u8) auth_method;
12193 mp->data_len = vec_len (data);
12194 clib_memcpy (mp->name, name, vec_len (name));
12195 clib_memcpy (mp->data, data, vec_len (data));
12206 api_ikev2_profile_set_id (vat_main_t * vam)
12208 unformat_input_t *i = vam->input;
12209 vl_api_ikev2_profile_set_id_t *mp;
12217 const char *valid_chars = "a-zA-Z0-9_";
12219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12221 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12222 vec_add1 (name, 0);
12223 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12225 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12227 data = vec_new (u8, 4);
12228 clib_memcpy (data, ip4.as_u8, 4);
12230 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12232 else if (unformat (i, "id_data %v", &data))
12234 else if (unformat (i, "local"))
12236 else if (unformat (i, "remote"))
12240 errmsg ("parse error '%U'", format_unformat_error, i);
12245 if (!vec_len (name))
12247 errmsg ("profile name must be specified");
12251 if (vec_len (name) > 64)
12253 errmsg ("profile name too long");
12257 if (!vec_len (data))
12259 errmsg ("id_data must be specified");
12265 errmsg ("id_type must be specified");
12269 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12271 mp->is_local = is_local;
12272 mp->id_type = (u8) id_type;
12273 mp->data_len = vec_len (data);
12274 clib_memcpy (mp->name, name, vec_len (name));
12275 clib_memcpy (mp->data, data, vec_len (data));
12286 api_ikev2_profile_set_ts (vat_main_t * vam)
12288 unformat_input_t *i = vam->input;
12289 vl_api_ikev2_profile_set_ts_t *mp;
12293 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12294 ip4_address_t start_addr, end_addr;
12296 const char *valid_chars = "a-zA-Z0-9_";
12298 start_addr.as_u32 = 0;
12299 end_addr.as_u32 = (u32) ~ 0;
12301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12303 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12304 vec_add1 (name, 0);
12305 else if (unformat (i, "protocol %d", &proto))
12307 else if (unformat (i, "start_port %d", &start_port))
12309 else if (unformat (i, "end_port %d", &end_port))
12312 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12314 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12316 else if (unformat (i, "local"))
12318 else if (unformat (i, "remote"))
12322 errmsg ("parse error '%U'", format_unformat_error, i);
12327 if (!vec_len (name))
12329 errmsg ("profile name must be specified");
12333 if (vec_len (name) > 64)
12335 errmsg ("profile name too long");
12339 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12341 mp->is_local = is_local;
12342 mp->proto = (u8) proto;
12343 mp->start_port = (u16) start_port;
12344 mp->end_port = (u16) end_port;
12345 mp->start_addr = start_addr.as_u32;
12346 mp->end_addr = end_addr.as_u32;
12347 clib_memcpy (mp->name, name, vec_len (name));
12357 api_ikev2_set_local_key (vat_main_t * vam)
12359 unformat_input_t *i = vam->input;
12360 vl_api_ikev2_set_local_key_t *mp;
12364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12366 if (unformat (i, "file %v", &file))
12367 vec_add1 (file, 0);
12370 errmsg ("parse error '%U'", format_unformat_error, i);
12375 if (!vec_len (file))
12377 errmsg ("RSA key file must be specified");
12381 if (vec_len (file) > 256)
12383 errmsg ("file name too long");
12387 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12389 clib_memcpy (mp->key_file, file, vec_len (file));
12402 api_map_add_domain (vat_main_t * vam)
12404 unformat_input_t *i = vam->input;
12405 vl_api_map_add_domain_t *mp;
12408 ip4_address_t ip4_prefix;
12409 ip6_address_t ip6_prefix;
12410 ip6_address_t ip6_src;
12411 u32 num_m_args = 0;
12412 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12413 0, psid_length = 0;
12414 u8 is_translation = 0;
12416 u32 ip6_src_len = 128;
12418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12420 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12421 &ip4_prefix, &ip4_prefix_len))
12423 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12424 &ip6_prefix, &ip6_prefix_len))
12428 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12431 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12433 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12435 else if (unformat (i, "psid-offset %d", &psid_offset))
12437 else if (unformat (i, "psid-len %d", &psid_length))
12439 else if (unformat (i, "mtu %d", &mtu))
12441 else if (unformat (i, "map-t"))
12442 is_translation = 1;
12445 clib_warning ("parse error '%U'", format_unformat_error, i);
12450 if (num_m_args < 3)
12452 errmsg ("mandatory argument(s) missing\n");
12456 /* Construct the API message */
12457 M (MAP_ADD_DOMAIN, map_add_domain);
12459 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12460 mp->ip4_prefix_len = ip4_prefix_len;
12462 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12463 mp->ip6_prefix_len = ip6_prefix_len;
12465 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12466 mp->ip6_src_prefix_len = ip6_src_len;
12468 mp->ea_bits_len = ea_bits_len;
12469 mp->psid_offset = psid_offset;
12470 mp->psid_length = psid_length;
12471 mp->is_translation = is_translation;
12472 mp->mtu = htons (mtu);
12477 /* Wait for a reply, return good/bad news */
12482 api_map_del_domain (vat_main_t * vam)
12484 unformat_input_t *i = vam->input;
12485 vl_api_map_del_domain_t *mp;
12488 u32 num_m_args = 0;
12491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12493 if (unformat (i, "index %d", &index))
12497 clib_warning ("parse error '%U'", format_unformat_error, i);
12502 if (num_m_args != 1)
12504 errmsg ("mandatory argument(s) missing\n");
12508 /* Construct the API message */
12509 M (MAP_DEL_DOMAIN, map_del_domain);
12511 mp->index = ntohl (index);
12516 /* Wait for a reply, return good/bad news */
12521 api_map_add_del_rule (vat_main_t * vam)
12523 unformat_input_t *i = vam->input;
12524 vl_api_map_add_del_rule_t *mp;
12527 ip6_address_t ip6_dst;
12528 u32 num_m_args = 0, index, psid = 0;
12530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12532 if (unformat (i, "index %d", &index))
12534 else if (unformat (i, "psid %d", &psid))
12536 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12538 else if (unformat (i, "del"))
12544 clib_warning ("parse error '%U'", format_unformat_error, i);
12549 /* Construct the API message */
12550 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12552 mp->index = ntohl (index);
12553 mp->is_add = is_add;
12554 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12555 mp->psid = ntohs (psid);
12560 /* Wait for a reply, return good/bad news */
12565 api_map_domain_dump (vat_main_t * vam)
12567 vl_api_map_domain_dump_t *mp;
12570 /* Construct the API message */
12571 M (MAP_DOMAIN_DUMP, map_domain_dump);
12576 /* Use a control ping for synchronization */
12578 vl_api_control_ping_t *mp;
12579 M (CONTROL_PING, control_ping);
12586 api_map_rule_dump (vat_main_t * vam)
12588 unformat_input_t *i = vam->input;
12589 vl_api_map_rule_dump_t *mp;
12591 u32 domain_index = ~0;
12593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12595 if (unformat (i, "index %u", &domain_index))
12601 if (domain_index == ~0)
12603 clib_warning ("parse error: domain index expected");
12607 /* Construct the API message */
12608 M (MAP_RULE_DUMP, map_rule_dump);
12610 mp->domain_index = htonl (domain_index);
12615 /* Use a control ping for synchronization */
12617 vl_api_control_ping_t *mp;
12618 M (CONTROL_PING, control_ping);
12624 static void vl_api_map_add_domain_reply_t_handler
12625 (vl_api_map_add_domain_reply_t * mp)
12627 vat_main_t *vam = &vat_main;
12628 i32 retval = ntohl (mp->retval);
12630 if (vam->async_mode)
12632 vam->async_errors += (retval < 0);
12636 vam->retval = retval;
12637 vam->result_ready = 1;
12641 static void vl_api_map_add_domain_reply_t_handler_json
12642 (vl_api_map_add_domain_reply_t * mp)
12644 vat_main_t *vam = &vat_main;
12645 vat_json_node_t node;
12647 vat_json_init_object (&node);
12648 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12649 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12651 vat_json_print (vam->ofp, &node);
12652 vat_json_free (&node);
12654 vam->retval = ntohl (mp->retval);
12655 vam->result_ready = 1;
12659 api_get_first_msg_id (vat_main_t * vam)
12661 vl_api_get_first_msg_id_t *mp;
12663 unformat_input_t *i = vam->input;
12667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12669 if (unformat (i, "client %s", &name))
12677 errmsg ("missing client name\n");
12680 vec_add1 (name, 0);
12682 if (vec_len (name) > 63)
12684 errmsg ("client name too long\n");
12688 M (GET_FIRST_MSG_ID, get_first_msg_id);
12689 clib_memcpy (mp->name, name, vec_len (name));
12697 api_cop_interface_enable_disable (vat_main_t * vam)
12699 unformat_input_t *line_input = vam->input;
12700 vl_api_cop_interface_enable_disable_t *mp;
12702 u32 sw_if_index = ~0;
12703 u8 enable_disable = 1;
12705 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12707 if (unformat (line_input, "disable"))
12708 enable_disable = 0;
12709 if (unformat (line_input, "enable"))
12710 enable_disable = 1;
12711 else if (unformat (line_input, "%U", unformat_sw_if_index,
12712 vam, &sw_if_index))
12714 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12720 if (sw_if_index == ~0)
12722 errmsg ("missing interface name or sw_if_index\n");
12726 /* Construct the API message */
12727 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12728 mp->sw_if_index = ntohl (sw_if_index);
12729 mp->enable_disable = enable_disable;
12733 /* Wait for the reply */
12738 api_cop_whitelist_enable_disable (vat_main_t * vam)
12740 unformat_input_t *line_input = vam->input;
12741 vl_api_cop_whitelist_enable_disable_t *mp;
12743 u32 sw_if_index = ~0;
12744 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12747 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12749 if (unformat (line_input, "ip4"))
12751 else if (unformat (line_input, "ip6"))
12753 else if (unformat (line_input, "default"))
12755 else if (unformat (line_input, "%U", unformat_sw_if_index,
12756 vam, &sw_if_index))
12758 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12760 else if (unformat (line_input, "fib-id %d", &fib_id))
12766 if (sw_if_index == ~0)
12768 errmsg ("missing interface name or sw_if_index\n");
12772 /* Construct the API message */
12773 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12774 mp->sw_if_index = ntohl (sw_if_index);
12775 mp->fib_id = ntohl (fib_id);
12778 mp->default_cop = default_cop;
12782 /* Wait for the reply */
12787 api_get_node_graph (vat_main_t * vam)
12789 vl_api_get_node_graph_t *mp;
12792 M (GET_NODE_GRAPH, get_node_graph);
12796 /* Wait for the reply */
12801 /** Used for parsing LISP eids */
12802 typedef CLIB_PACKED(struct{
12803 u8 addr[16]; /**< eid address */
12804 u32 len; /**< prefix length if IP */
12805 u8 type; /**< type of eid */
12810 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12812 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12814 memset (a, 0, sizeof (a[0]));
12816 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12818 a->type = 0; /* ipv4 type */
12820 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12822 a->type = 1; /* ipv6 type */
12824 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12826 a->type = 2; /* mac type */
12833 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12842 lisp_eid_size_vat (u8 type)
12857 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12859 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12863 /** Used for transferring locators via VPP API */
12864 typedef CLIB_PACKED(struct
12866 u32 sw_if_index; /**< locator sw_if_index */
12867 u8 priority; /**< locator priority */
12868 u8 weight; /**< locator weight */
12873 api_lisp_add_del_locator_set (vat_main_t * vam)
12875 unformat_input_t *input = vam->input;
12876 vl_api_lisp_add_del_locator_set_t *mp;
12879 u8 *locator_set_name = NULL;
12880 u8 locator_set_name_set = 0;
12881 ls_locator_t locator, *locators = 0;
12882 u32 sw_if_index, priority, weight;
12885 /* Parse args required to build the message */
12886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12888 if (unformat (input, "del"))
12892 else if (unformat (input, "locator-set %s", &locator_set_name))
12894 locator_set_name_set = 1;
12896 else if (unformat (input, "sw_if_index %u p %u w %u",
12897 &sw_if_index, &priority, &weight))
12899 locator.sw_if_index = htonl (sw_if_index);
12900 locator.priority = priority;
12901 locator.weight = weight;
12902 vec_add1 (locators, locator);
12904 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12905 vam, &sw_if_index, &priority, &weight))
12907 locator.sw_if_index = htonl (sw_if_index);
12908 locator.priority = priority;
12909 locator.weight = weight;
12910 vec_add1 (locators, locator);
12916 if (locator_set_name_set == 0)
12918 errmsg ("missing locator-set name");
12919 vec_free (locators);
12923 if (vec_len (locator_set_name) > 64)
12925 errmsg ("locator-set name too long\n");
12926 vec_free (locator_set_name);
12927 vec_free (locators);
12930 vec_add1 (locator_set_name, 0);
12932 data_len = sizeof (ls_locator_t) * vec_len (locators);
12934 /* Construct the API message */
12935 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12937 mp->is_add = is_add;
12938 clib_memcpy (mp->locator_set_name, locator_set_name,
12939 vec_len (locator_set_name));
12940 vec_free (locator_set_name);
12942 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12944 clib_memcpy (mp->locators, locators, data_len);
12945 vec_free (locators);
12950 /* Wait for a reply... */
12958 api_lisp_add_del_locator (vat_main_t * vam)
12960 unformat_input_t *input = vam->input;
12961 vl_api_lisp_add_del_locator_t *mp;
12963 u32 tmp_if_index = ~0;
12964 u32 sw_if_index = ~0;
12965 u8 sw_if_index_set = 0;
12966 u8 sw_if_index_if_name_set = 0;
12968 u8 priority_set = 0;
12972 u8 *locator_set_name = NULL;
12973 u8 locator_set_name_set = 0;
12975 /* Parse args required to build the message */
12976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12978 if (unformat (input, "del"))
12982 else if (unformat (input, "locator-set %s", &locator_set_name))
12984 locator_set_name_set = 1;
12986 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12989 sw_if_index_if_name_set = 1;
12990 sw_if_index = tmp_if_index;
12992 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12994 sw_if_index_set = 1;
12995 sw_if_index = tmp_if_index;
12997 else if (unformat (input, "p %d", &priority))
13001 else if (unformat (input, "w %d", &weight))
13009 if (locator_set_name_set == 0)
13011 errmsg ("missing locator-set name");
13015 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13017 errmsg ("missing sw_if_index");
13018 vec_free (locator_set_name);
13022 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13024 errmsg ("cannot use both params interface name and sw_if_index");
13025 vec_free (locator_set_name);
13029 if (priority_set == 0)
13031 errmsg ("missing locator-set priority\n");
13032 vec_free (locator_set_name);
13036 if (weight_set == 0)
13038 errmsg ("missing locator-set weight\n");
13039 vec_free (locator_set_name);
13043 if (vec_len (locator_set_name) > 64)
13045 errmsg ("locator-set name too long\n");
13046 vec_free (locator_set_name);
13049 vec_add1 (locator_set_name, 0);
13051 /* Construct the API message */
13052 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13054 mp->is_add = is_add;
13055 mp->sw_if_index = ntohl (sw_if_index);
13056 mp->priority = priority;
13057 mp->weight = weight;
13058 clib_memcpy (mp->locator_set_name, locator_set_name,
13059 vec_len (locator_set_name));
13060 vec_free (locator_set_name);
13065 /* Wait for a reply... */
13073 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13075 u32 *key_id = va_arg (*args, u32 *);
13078 if (unformat (input, "%s", &s))
13080 if (!strcmp ((char *) s, "sha1"))
13081 key_id[0] = HMAC_SHA_1_96;
13082 else if (!strcmp ((char *) s, "sha256"))
13083 key_id[0] = HMAC_SHA_256_128;
13086 clib_warning ("invalid key_id: '%s'", s);
13087 key_id[0] = HMAC_NO_KEY;
13098 api_lisp_add_del_local_eid (vat_main_t * vam)
13100 unformat_input_t *input = vam->input;
13101 vl_api_lisp_add_del_local_eid_t *mp;
13105 lisp_eid_vat_t _eid, *eid = &_eid;
13106 u8 *locator_set_name = 0;
13107 u8 locator_set_name_set = 0;
13112 /* Parse args required to build the message */
13113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13115 if (unformat (input, "del"))
13119 else if (unformat (input, "vni %d", &vni))
13123 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13127 else if (unformat (input, "locator-set %s", &locator_set_name))
13129 locator_set_name_set = 1;
13131 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13133 else if (unformat (input, "secret-key %_%v%_", &key))
13139 if (locator_set_name_set == 0)
13141 errmsg ("missing locator-set name\n");
13147 errmsg ("EID address not set!");
13148 vec_free (locator_set_name);
13152 if (key && (0 == key_id))
13154 errmsg ("invalid key_id!");
13158 if (vec_len (key) > 64)
13160 errmsg ("key too long");
13165 if (vec_len (locator_set_name) > 64)
13167 errmsg ("locator-set name too long\n");
13168 vec_free (locator_set_name);
13171 vec_add1 (locator_set_name, 0);
13173 /* Construct the API message */
13174 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13176 mp->is_add = is_add;
13177 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13178 mp->eid_type = eid->type;
13179 mp->prefix_len = eid->len;
13180 mp->vni = clib_host_to_net_u32 (vni);
13181 mp->key_id = clib_host_to_net_u16 (key_id);
13182 clib_memcpy (mp->locator_set_name, locator_set_name,
13183 vec_len (locator_set_name));
13184 clib_memcpy (mp->key, key, vec_len (key));
13186 vec_free (locator_set_name);
13192 /* Wait for a reply... */
13200 /** Used for transferring locators via VPP API */
13201 typedef CLIB_PACKED(struct
13203 u8 is_ip4; /**< is locator an IPv4 address? */
13204 u8 priority; /**< locator priority */
13205 u8 weight; /**< locator weight */
13206 u8 addr[16]; /**< IPv4/IPv6 address */
13211 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13213 unformat_input_t *input = vam->input;
13214 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13217 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13218 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13219 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13220 u32 action = ~0, p, w;
13221 ip4_address_t rmt_rloc4, lcl_rloc4;
13222 ip6_address_t rmt_rloc6, lcl_rloc6;
13223 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13225 memset (&rloc, 0, sizeof (rloc));
13227 /* Parse args required to build the message */
13228 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13230 if (unformat (input, "del"))
13234 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
13238 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
13242 else if (unformat (input, "p %d w %d", &p, &w))
13246 errmsg ("No RLOC configured for setting priority/weight!");
13249 curr_rloc->priority = p;
13250 curr_rloc->weight = w;
13252 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13253 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13257 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13258 rloc.priority = rloc.weight = 0;
13259 vec_add1 (lcl_locs, rloc);
13261 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13262 vec_add1 (rmt_locs, rloc);
13263 /* priority and weight saved in rmt loc */
13264 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13266 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13267 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13270 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13271 rloc.priority = rloc.weight = 0;
13272 vec_add1 (lcl_locs, rloc);
13274 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13275 vec_add1 (rmt_locs, rloc);
13276 /* priority and weight saved in rmt loc */
13277 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13279 else if (unformat (input, "action %d", &action))
13285 clib_warning ("parse error '%U'", format_unformat_error, input);
13292 errmsg ("remote eid addresses not set\n");
13296 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13298 errmsg ("eid types don't match\n");
13302 if (0 == rmt_locs && (u32) ~ 0 == action)
13304 errmsg ("action not set for negative mapping\n");
13308 /* Construct the API message */
13309 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13311 mp->is_add = is_add;
13312 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13313 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13314 mp->eid_type = rmt_eid->type;
13315 mp->rmt_len = rmt_eid->len;
13316 mp->lcl_len = lcl_eid->len;
13317 mp->action = action;
13319 if (0 != rmt_locs && 0 != lcl_locs)
13321 mp->loc_num = vec_len (rmt_locs);
13322 clib_memcpy (mp->lcl_locs, lcl_locs,
13323 (sizeof (rloc_t) * vec_len (lcl_locs)));
13324 clib_memcpy (mp->rmt_locs, rmt_locs,
13325 (sizeof (rloc_t) * vec_len (rmt_locs)));
13327 vec_free (lcl_locs);
13328 vec_free (rmt_locs);
13333 /* Wait for a reply... */
13341 api_lisp_add_del_map_server (vat_main_t * vam)
13343 unformat_input_t *input = vam->input;
13344 vl_api_lisp_add_del_map_server_t *mp;
13349 ip4_address_t ipv4;
13350 ip6_address_t ipv6;
13352 /* Parse args required to build the message */
13353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13355 if (unformat (input, "del"))
13359 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13363 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13371 if (ipv4_set && ipv6_set)
13373 errmsg ("both eid v4 and v6 addresses set\n");
13377 if (!ipv4_set && !ipv6_set)
13379 errmsg ("eid addresses not set\n");
13383 /* Construct the API message */
13384 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13386 mp->is_add = is_add;
13390 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13395 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13401 /* Wait for a reply... */
13409 api_lisp_add_del_map_resolver (vat_main_t * vam)
13411 unformat_input_t *input = vam->input;
13412 vl_api_lisp_add_del_map_resolver_t *mp;
13417 ip4_address_t ipv4;
13418 ip6_address_t ipv6;
13420 /* Parse args required to build the message */
13421 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13423 if (unformat (input, "del"))
13427 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13431 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13439 if (ipv4_set && ipv6_set)
13441 errmsg ("both eid v4 and v6 addresses set\n");
13445 if (!ipv4_set && !ipv6_set)
13447 errmsg ("eid addresses not set\n");
13451 /* Construct the API message */
13452 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13454 mp->is_add = is_add;
13458 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13463 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13469 /* Wait for a reply... */
13477 api_lisp_gpe_enable_disable (vat_main_t * vam)
13479 unformat_input_t *input = vam->input;
13480 vl_api_lisp_gpe_enable_disable_t *mp;
13485 /* Parse args required to build the message */
13486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13488 if (unformat (input, "enable"))
13493 else if (unformat (input, "disable"))
13504 errmsg ("Value not set\n");
13508 /* Construct the API message */
13509 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13516 /* Wait for a reply... */
13524 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13526 unformat_input_t *input = vam->input;
13527 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13532 /* Parse args required to build the message */
13533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13535 if (unformat (input, "enable"))
13540 else if (unformat (input, "disable"))
13548 errmsg ("Value not set\n");
13552 /* Construct the API message */
13553 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13555 mp->is_enabled = is_en;
13560 /* Wait for a reply... */
13568 api_lisp_map_register_enable_disable (vat_main_t * vam)
13570 unformat_input_t *input = vam->input;
13571 vl_api_lisp_map_register_enable_disable_t *mp;
13576 /* Parse args required to build the message */
13577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13579 if (unformat (input, "enable"))
13584 else if (unformat (input, "disable"))
13592 errmsg ("Value not set\n");
13596 /* Construct the API message */
13597 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13599 mp->is_enabled = is_en;
13604 /* Wait for a reply... */
13612 api_lisp_enable_disable (vat_main_t * vam)
13614 unformat_input_t *input = vam->input;
13615 vl_api_lisp_enable_disable_t *mp;
13620 /* Parse args required to build the message */
13621 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13623 if (unformat (input, "enable"))
13628 else if (unformat (input, "disable"))
13638 errmsg ("Value not set\n");
13642 /* Construct the API message */
13643 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13650 /* Wait for a reply... */
13658 api_show_lisp_map_register_state (vat_main_t * vam)
13661 vl_api_show_lisp_map_register_state_t *mp;
13663 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13668 /* wait for reply */
13675 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13678 vl_api_show_lisp_rloc_probe_state_t *mp;
13680 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13685 /* wait for reply */
13692 api_show_lisp_map_request_mode (vat_main_t * vam)
13695 vl_api_show_lisp_map_request_mode_t *mp;
13697 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13702 /* wait for reply */
13709 api_lisp_map_request_mode (vat_main_t * vam)
13712 unformat_input_t *input = vam->input;
13713 vl_api_lisp_map_request_mode_t *mp;
13716 /* Parse args required to build the message */
13717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13719 if (unformat (input, "dst-only"))
13721 else if (unformat (input, "src-dst"))
13725 errmsg ("parse error '%U'", format_unformat_error, input);
13730 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13737 /* wait for reply */
13745 * Enable/disable LISP proxy ITR.
13747 * @param vam vpp API test context
13748 * @return return code
13751 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13754 u8 ls_name_set = 0;
13755 unformat_input_t *input = vam->input;
13756 vl_api_lisp_pitr_set_locator_set_t *mp;
13760 /* Parse args required to build the message */
13761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13763 if (unformat (input, "del"))
13765 else if (unformat (input, "locator-set %s", &ls_name))
13769 errmsg ("parse error '%U'", format_unformat_error, input);
13776 errmsg ("locator-set name not set!");
13780 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13782 mp->is_add = is_add;
13783 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13784 vec_free (ls_name);
13789 /* wait for reply */
13797 api_show_lisp_pitr (vat_main_t * vam)
13799 vl_api_show_lisp_pitr_t *mp;
13802 if (!vam->json_output)
13804 fformat (vam->ofp, "%=20s\n", "lisp status:");
13807 M (SHOW_LISP_PITR, show_lisp_pitr);
13811 /* Wait for a reply... */
13819 * Add/delete mapping between vni and vrf
13822 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13825 unformat_input_t *input = vam->input;
13826 vl_api_lisp_eid_table_add_del_map_t *mp;
13827 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13828 u32 vni, vrf, bd_index;
13830 /* Parse args required to build the message */
13831 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13833 if (unformat (input, "del"))
13835 else if (unformat (input, "vrf %d", &vrf))
13837 else if (unformat (input, "bd_index %d", &bd_index))
13839 else if (unformat (input, "vni %d", &vni))
13845 if (!vni_set || (!vrf_set && !bd_index_set))
13847 errmsg ("missing arguments!");
13851 if (vrf_set && bd_index_set)
13853 errmsg ("error: both vrf and bd entered!");
13857 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13859 mp->is_add = is_add;
13860 mp->vni = htonl (vni);
13861 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13862 mp->is_l2 = bd_index_set;
13867 /* wait for reply */
13875 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13877 u32 *action = va_arg (*args, u32 *);
13880 if (unformat (input, "%s", &s))
13882 if (!strcmp ((char *) s, "no-action"))
13884 else if (!strcmp ((char *) s, "natively-forward"))
13886 else if (!strcmp ((char *) s, "send-map-request"))
13888 else if (!strcmp ((char *) s, "drop"))
13892 clib_warning ("invalid action: '%s'", s);
13904 * Add/del remote mapping to/from LISP control plane
13906 * @param vam vpp API test context
13907 * @return return code
13910 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13912 unformat_input_t *input = vam->input;
13913 vl_api_lisp_add_del_remote_mapping_t *mp;
13916 lisp_eid_vat_t _eid, *eid = &_eid;
13917 lisp_eid_vat_t _seid, *seid = &_seid;
13918 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13919 u32 action = ~0, p, w, data_len;
13920 ip4_address_t rloc4;
13921 ip6_address_t rloc6;
13922 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13924 memset (&rloc, 0, sizeof (rloc));
13926 /* Parse args required to build the message */
13927 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13929 if (unformat (input, "del-all"))
13933 else if (unformat (input, "del"))
13937 else if (unformat (input, "add"))
13941 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13945 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13949 else if (unformat (input, "vni %d", &vni))
13953 else if (unformat (input, "p %d w %d", &p, &w))
13957 errmsg ("No RLOC configured for setting priority/weight!");
13960 curr_rloc->priority = p;
13961 curr_rloc->weight = w;
13963 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13966 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13967 vec_add1 (rlocs, rloc);
13968 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13970 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13973 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13974 vec_add1 (rlocs, rloc);
13975 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13977 else if (unformat (input, "action %U",
13978 unformat_negative_mapping_action, &action))
13984 clib_warning ("parse error '%U'", format_unformat_error, input);
13991 errmsg ("missing params!");
13995 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13997 errmsg ("no action set for negative map-reply!");
14001 data_len = vec_len (rlocs) * sizeof (rloc_t);
14003 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14004 mp->is_add = is_add;
14005 mp->vni = htonl (vni);
14006 mp->action = (u8) action;
14007 mp->is_src_dst = seid_set;
14008 mp->eid_len = eid->len;
14009 mp->seid_len = seid->len;
14010 mp->del_all = del_all;
14011 mp->eid_type = eid->type;
14012 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14013 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14015 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14016 clib_memcpy (mp->rlocs, rlocs, data_len);
14022 /* Wait for a reply... */
14030 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14031 * forwarding entries in data-plane accordingly.
14033 * @param vam vpp API test context
14034 * @return return code
14037 api_lisp_add_del_adjacency (vat_main_t * vam)
14039 unformat_input_t *input = vam->input;
14040 vl_api_lisp_add_del_adjacency_t *mp;
14043 ip4_address_t leid4, reid4;
14044 ip6_address_t leid6, reid6;
14045 u8 reid_mac[6] = { 0 };
14046 u8 leid_mac[6] = { 0 };
14047 u8 reid_type, leid_type;
14048 u32 leid_len = 0, reid_len = 0, len;
14051 leid_type = reid_type = (u8) ~ 0;
14053 /* Parse args required to build the message */
14054 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14056 if (unformat (input, "del"))
14060 else if (unformat (input, "add"))
14064 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14067 reid_type = 0; /* ipv4 */
14070 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14073 reid_type = 1; /* ipv6 */
14076 else if (unformat (input, "reid %U", unformat_ethernet_address,
14079 reid_type = 2; /* mac */
14081 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14084 leid_type = 0; /* ipv4 */
14087 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14090 leid_type = 1; /* ipv6 */
14093 else if (unformat (input, "leid %U", unformat_ethernet_address,
14096 leid_type = 2; /* mac */
14098 else if (unformat (input, "vni %d", &vni))
14104 errmsg ("parse error '%U'", format_unformat_error, input);
14109 if ((u8) ~ 0 == reid_type)
14111 errmsg ("missing params!");
14115 if (leid_type != reid_type)
14117 errmsg ("remote and local EIDs are of different types!");
14121 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14122 mp->is_add = is_add;
14123 mp->vni = htonl (vni);
14124 mp->leid_len = leid_len;
14125 mp->reid_len = reid_len;
14126 mp->eid_type = reid_type;
14128 switch (mp->eid_type)
14131 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14132 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14135 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14136 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14139 clib_memcpy (mp->leid, leid_mac, 6);
14140 clib_memcpy (mp->reid, reid_mac, 6);
14143 errmsg ("unknown EID type %d!", mp->eid_type);
14150 /* Wait for a reply... */
14158 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14160 unformat_input_t *input = vam->input;
14161 vl_api_lisp_gpe_add_del_iface_t *mp;
14163 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14164 u32 dp_table = 0, vni = 0;
14166 /* Parse args required to build the message */
14167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14169 if (unformat (input, "up"))
14174 else if (unformat (input, "down"))
14179 else if (unformat (input, "table_id %d", &dp_table))
14183 else if (unformat (input, "bd_id %d", &dp_table))
14188 else if (unformat (input, "vni %d", &vni))
14196 if (action_set == 0)
14198 errmsg ("Action not set\n");
14201 if (dp_table_set == 0 || vni_set == 0)
14203 errmsg ("vni and dp_table must be set\n");
14207 /* Construct the API message */
14208 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14210 mp->is_add = is_add;
14211 mp->dp_table = dp_table;
14218 /* Wait for a reply... */
14226 * Add/del map request itr rlocs from LISP control plane and updates
14228 * @param vam vpp API test context
14229 * @return return code
14232 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14234 unformat_input_t *input = vam->input;
14235 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14237 u8 *locator_set_name = 0;
14238 u8 locator_set_name_set = 0;
14241 /* Parse args required to build the message */
14242 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14244 if (unformat (input, "del"))
14248 else if (unformat (input, "%_%v%_", &locator_set_name))
14250 locator_set_name_set = 1;
14254 clib_warning ("parse error '%U'", format_unformat_error, input);
14259 if (is_add && !locator_set_name_set)
14261 errmsg ("itr-rloc is not set!");
14265 if (is_add && vec_len (locator_set_name) > 64)
14267 errmsg ("itr-rloc locator-set name too long\n");
14268 vec_free (locator_set_name);
14272 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14273 mp->is_add = is_add;
14276 clib_memcpy (mp->locator_set_name, locator_set_name,
14277 vec_len (locator_set_name));
14281 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14283 vec_free (locator_set_name);
14288 /* Wait for a reply... */
14296 api_lisp_locator_dump (vat_main_t * vam)
14298 unformat_input_t *input = vam->input;
14299 vl_api_lisp_locator_dump_t *mp;
14301 u8 is_index_set = 0, is_name_set = 0;
14305 /* Parse args required to build the message */
14306 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14308 if (unformat (input, "ls_name %_%v%_", &ls_name))
14312 else if (unformat (input, "ls_index %d", &ls_index))
14318 errmsg ("parse error '%U'", format_unformat_error, input);
14323 if (!is_index_set && !is_name_set)
14325 errmsg ("error: expected one of index or name!\n");
14329 if (is_index_set && is_name_set)
14331 errmsg ("error: only one param expected!\n");
14335 if (vec_len (ls_name) > 62)
14337 errmsg ("error: locator set name too long!");
14341 if (!vam->json_output)
14343 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
14347 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14348 mp->is_index_set = is_index_set;
14351 mp->ls_index = clib_host_to_net_u32 (ls_index);
14354 vec_add1 (ls_name, 0);
14355 strncpy ((char *) mp->ls_name, (char *) ls_name,
14356 sizeof (mp->ls_name) - 1);
14362 /* Use a control ping for synchronization */
14364 vl_api_control_ping_t *mp;
14365 M (CONTROL_PING, control_ping);
14368 /* Wait for a reply... */
14376 api_lisp_locator_set_dump (vat_main_t * vam)
14378 vl_api_lisp_locator_set_dump_t *mp;
14379 unformat_input_t *input = vam->input;
14383 /* Parse args required to build the message */
14384 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14386 if (unformat (input, "local"))
14390 else if (unformat (input, "remote"))
14396 errmsg ("parse error '%U'", format_unformat_error, input);
14401 if (!vam->json_output)
14403 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
14406 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14408 mp->filter = filter;
14413 /* Use a control ping for synchronization */
14415 vl_api_control_ping_t *mp;
14416 M (CONTROL_PING, control_ping);
14419 /* Wait for a reply... */
14427 api_lisp_eid_table_map_dump (vat_main_t * vam)
14431 unformat_input_t *input = vam->input;
14432 vl_api_lisp_eid_table_map_dump_t *mp;
14435 /* Parse args required to build the message */
14436 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14438 if (unformat (input, "l2"))
14443 else if (unformat (input, "l3"))
14450 errmsg ("parse error '%U'", format_unformat_error, input);
14457 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
14461 if (!vam->json_output)
14463 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
14466 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14472 /* Use a control ping for synchronization */
14474 vl_api_control_ping_t *mp;
14475 M (CONTROL_PING, control_ping);
14478 /* Wait for a reply... */
14486 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14488 vl_api_lisp_eid_table_vni_dump_t *mp;
14491 if (!vam->json_output)
14493 fformat (vam->ofp, "VNI\n");
14496 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14501 /* Use a control ping for synchronization */
14503 vl_api_control_ping_t *mp;
14504 M (CONTROL_PING, control_ping);
14507 /* Wait for a reply... */
14515 api_lisp_eid_table_dump (vat_main_t * vam)
14517 unformat_input_t *i = vam->input;
14518 vl_api_lisp_eid_table_dump_t *mp;
14520 struct in_addr ip4;
14521 struct in6_addr ip6;
14523 u8 eid_type = ~0, eid_set = 0;
14524 u32 prefix_length = ~0, t, vni = 0;
14527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14529 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14535 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14541 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14546 else if (unformat (i, "vni %d", &t))
14550 else if (unformat (i, "local"))
14554 else if (unformat (i, "remote"))
14560 errmsg ("parse error '%U'", format_unformat_error, i);
14565 if (!vam->json_output)
14567 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s\n", "EID",
14568 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14571 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14573 mp->filter = filter;
14577 mp->vni = htonl (vni);
14578 mp->eid_type = eid_type;
14582 mp->prefix_length = prefix_length;
14583 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14586 mp->prefix_length = prefix_length;
14587 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14590 clib_memcpy (mp->eid, mac, sizeof (mac));
14593 errmsg ("unknown EID type %d!", eid_type);
14601 /* Use a control ping for synchronization */
14603 vl_api_control_ping_t *mp;
14604 M (CONTROL_PING, control_ping);
14608 /* Wait for a reply... */
14616 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14618 vl_api_lisp_gpe_tunnel_dump_t *mp;
14621 if (!vam->json_output)
14623 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14624 "%=16s%=16s%=16s%=16s%=16s\n",
14625 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14626 "Decap next", "Lisp version", "Flags", "Next protocol",
14627 "ver_res", "res", "iid");
14630 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14634 /* Use a control ping for synchronization */
14636 vl_api_control_ping_t *mp;
14637 M (CONTROL_PING, control_ping);
14640 /* Wait for a reply... */
14648 api_lisp_adjacencies_get (vat_main_t * vam)
14650 unformat_input_t *i = vam->input;
14651 vl_api_lisp_adjacencies_get_t *mp;
14656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14658 if (unformat (i, "vni %d", &vni))
14664 errmsg ("parse error '%U'\n", format_unformat_error, i);
14671 errmsg ("vni not set!\n");
14675 if (!vam->json_output)
14677 fformat (vam->ofp, "%s %40s\n", "leid", "reid");
14680 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14681 mp->vni = clib_host_to_net_u32 (vni);
14686 /* Wait for a reply... */
14694 api_lisp_map_server_dump (vat_main_t * vam)
14696 vl_api_lisp_map_server_dump_t *mp;
14699 if (!vam->json_output)
14701 fformat (vam->ofp, "%=20s\n", "Map server");
14704 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14708 /* Use a control ping for synchronization */
14710 vl_api_control_ping_t *mp;
14711 M (CONTROL_PING, control_ping);
14714 /* Wait for a reply... */
14722 api_lisp_map_resolver_dump (vat_main_t * vam)
14724 vl_api_lisp_map_resolver_dump_t *mp;
14727 if (!vam->json_output)
14729 fformat (vam->ofp, "%=20s\n", "Map resolver");
14732 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14736 /* Use a control ping for synchronization */
14738 vl_api_control_ping_t *mp;
14739 M (CONTROL_PING, control_ping);
14742 /* Wait for a reply... */
14750 api_show_lisp_status (vat_main_t * vam)
14752 vl_api_show_lisp_status_t *mp;
14755 if (!vam->json_output)
14757 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
14760 M (SHOW_LISP_STATUS, show_lisp_status);
14763 /* Wait for a reply... */
14771 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14773 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14776 if (!vam->json_output)
14778 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
14781 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14784 /* Wait for a reply... */
14792 api_af_packet_create (vat_main_t * vam)
14794 unformat_input_t *i = vam->input;
14795 vl_api_af_packet_create_t *mp;
14797 u8 *host_if_name = 0;
14799 u8 random_hw_addr = 1;
14801 memset (hw_addr, 0, sizeof (hw_addr));
14803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14805 if (unformat (i, "name %s", &host_if_name))
14806 vec_add1 (host_if_name, 0);
14807 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14808 random_hw_addr = 0;
14813 if (!vec_len (host_if_name))
14815 errmsg ("host-interface name must be specified");
14819 if (vec_len (host_if_name) > 64)
14821 errmsg ("host-interface name too long");
14825 M (AF_PACKET_CREATE, af_packet_create);
14827 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14828 clib_memcpy (mp->hw_addr, hw_addr, 6);
14829 mp->use_random_hw_addr = random_hw_addr;
14830 vec_free (host_if_name);
14833 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14839 api_af_packet_delete (vat_main_t * vam)
14841 unformat_input_t *i = vam->input;
14842 vl_api_af_packet_delete_t *mp;
14844 u8 *host_if_name = 0;
14846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14848 if (unformat (i, "name %s", &host_if_name))
14849 vec_add1 (host_if_name, 0);
14854 if (!vec_len (host_if_name))
14856 errmsg ("host-interface name must be specified");
14860 if (vec_len (host_if_name) > 64)
14862 errmsg ("host-interface name too long");
14866 M (AF_PACKET_DELETE, af_packet_delete);
14868 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14869 vec_free (host_if_name);
14878 api_policer_add_del (vat_main_t * vam)
14880 unformat_input_t *i = vam->input;
14881 vl_api_policer_add_del_t *mp;
14892 u8 color_aware = 0;
14893 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14895 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14896 conform_action.dscp = 0;
14897 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14898 exceed_action.dscp = 0;
14899 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14900 violate_action.dscp = 0;
14902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14904 if (unformat (i, "del"))
14906 else if (unformat (i, "name %s", &name))
14907 vec_add1 (name, 0);
14908 else if (unformat (i, "cir %u", &cir))
14910 else if (unformat (i, "eir %u", &eir))
14912 else if (unformat (i, "cb %u", &cb))
14914 else if (unformat (i, "eb %u", &eb))
14916 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14919 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14922 else if (unformat (i, "type %U", unformat_policer_type, &type))
14924 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14927 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14930 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14933 else if (unformat (i, "color-aware"))
14939 if (!vec_len (name))
14941 errmsg ("policer name must be specified");
14945 if (vec_len (name) > 64)
14947 errmsg ("policer name too long");
14951 M (POLICER_ADD_DEL, policer_add_del);
14953 clib_memcpy (mp->name, name, vec_len (name));
14955 mp->is_add = is_add;
14960 mp->rate_type = rate_type;
14961 mp->round_type = round_type;
14963 mp->conform_action_type = conform_action.action_type;
14964 mp->conform_dscp = conform_action.dscp;
14965 mp->exceed_action_type = exceed_action.action_type;
14966 mp->exceed_dscp = exceed_action.dscp;
14967 mp->violate_action_type = violate_action.action_type;
14968 mp->violate_dscp = violate_action.dscp;
14969 mp->color_aware = color_aware;
14978 api_policer_dump (vat_main_t * vam)
14980 unformat_input_t *i = vam->input;
14981 vl_api_policer_dump_t *mp;
14983 u8 *match_name = 0;
14984 u8 match_name_valid = 0;
14986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14988 if (unformat (i, "name %s", &match_name))
14990 vec_add1 (match_name, 0);
14991 match_name_valid = 1;
14997 M (POLICER_DUMP, policer_dump);
14998 mp->match_name_valid = match_name_valid;
14999 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15000 vec_free (match_name);
15004 /* Use a control ping for synchronization */
15006 vl_api_control_ping_t *mp;
15007 M (CONTROL_PING, control_ping);
15010 /* Wait for a reply... */
15018 api_policer_classify_set_interface (vat_main_t * vam)
15020 unformat_input_t *i = vam->input;
15021 vl_api_policer_classify_set_interface_t *mp;
15024 int sw_if_index_set;
15025 u32 ip4_table_index = ~0;
15026 u32 ip6_table_index = ~0;
15027 u32 l2_table_index = ~0;
15030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15032 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15033 sw_if_index_set = 1;
15034 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15035 sw_if_index_set = 1;
15036 else if (unformat (i, "del"))
15038 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15040 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15042 else if (unformat (i, "l2-table %d", &l2_table_index))
15046 clib_warning ("parse error '%U'", format_unformat_error, i);
15051 if (sw_if_index_set == 0)
15053 errmsg ("missing interface name or sw_if_index\n");
15057 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15059 mp->sw_if_index = ntohl (sw_if_index);
15060 mp->ip4_table_index = ntohl (ip4_table_index);
15061 mp->ip6_table_index = ntohl (ip6_table_index);
15062 mp->l2_table_index = ntohl (l2_table_index);
15063 mp->is_add = is_add;
15072 api_policer_classify_dump (vat_main_t * vam)
15074 unformat_input_t *i = vam->input;
15075 vl_api_policer_classify_dump_t *mp;
15077 u8 type = POLICER_CLASSIFY_N_TABLES;
15079 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15083 errmsg ("classify table type must be specified\n");
15087 if (!vam->json_output)
15089 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
15092 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15097 /* Use a control ping for synchronization */
15099 vl_api_control_ping_t *mp;
15100 M (CONTROL_PING, control_ping);
15103 /* Wait for a reply... */
15111 api_netmap_create (vat_main_t * vam)
15113 unformat_input_t *i = vam->input;
15114 vl_api_netmap_create_t *mp;
15118 u8 random_hw_addr = 1;
15122 memset (hw_addr, 0, sizeof (hw_addr));
15124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15126 if (unformat (i, "name %s", &if_name))
15127 vec_add1 (if_name, 0);
15128 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15129 random_hw_addr = 0;
15130 else if (unformat (i, "pipe"))
15132 else if (unformat (i, "master"))
15134 else if (unformat (i, "slave"))
15140 if (!vec_len (if_name))
15142 errmsg ("interface name must be specified");
15146 if (vec_len (if_name) > 64)
15148 errmsg ("interface name too long");
15152 M (NETMAP_CREATE, netmap_create);
15154 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15155 clib_memcpy (mp->hw_addr, hw_addr, 6);
15156 mp->use_random_hw_addr = random_hw_addr;
15157 mp->is_pipe = is_pipe;
15158 mp->is_master = is_master;
15159 vec_free (if_name);
15168 api_netmap_delete (vat_main_t * vam)
15170 unformat_input_t *i = vam->input;
15171 vl_api_netmap_delete_t *mp;
15175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15177 if (unformat (i, "name %s", &if_name))
15178 vec_add1 (if_name, 0);
15183 if (!vec_len (if_name))
15185 errmsg ("interface name must be specified");
15189 if (vec_len (if_name) > 64)
15191 errmsg ("interface name too long");
15195 M (NETMAP_DELETE, netmap_delete);
15197 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15198 vec_free (if_name);
15206 static void vl_api_mpls_tunnel_details_t_handler
15207 (vl_api_mpls_tunnel_details_t * mp)
15209 vat_main_t *vam = &vat_main;
15210 i32 len = mp->mt_next_hop_n_labels;
15213 fformat (vam->ofp, "[%d]: via %U %d labels ",
15215 format_ip4_address, mp->mt_next_hop,
15216 ntohl (mp->mt_next_hop_sw_if_index));
15217 for (i = 0; i < len; i++)
15219 fformat (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15221 fformat (vam->ofp, "\n");
15224 static void vl_api_mpls_tunnel_details_t_handler_json
15225 (vl_api_mpls_tunnel_details_t * mp)
15227 vat_main_t *vam = &vat_main;
15228 vat_json_node_t *node = NULL;
15229 struct in_addr ip4;
15231 i32 len = mp->mt_next_hop_n_labels;
15233 if (VAT_JSON_ARRAY != vam->json_tree.type)
15235 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15236 vat_json_init_array (&vam->json_tree);
15238 node = vat_json_array_add (&vam->json_tree);
15240 vat_json_init_object (node);
15241 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15242 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15243 vat_json_object_add_ip4 (node, "next_hop", ip4);
15244 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15245 ntohl (mp->mt_next_hop_sw_if_index));
15246 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15247 vat_json_object_add_uint (node, "label_count", len);
15248 for (i = 0; i < len; i++)
15250 vat_json_object_add_uint (node, "label",
15251 ntohl (mp->mt_next_hop_out_labels[i]));
15256 api_mpls_tunnel_dump (vat_main_t * vam)
15258 vl_api_mpls_tunnel_dump_t *mp;
15262 /* Parse args required to build the message */
15263 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15265 if (!unformat (vam->input, "tunnel_index %d", &index))
15272 fformat (vam->ofp, " tunnel_index %d\n", index);
15274 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15275 mp->tunnel_index = htonl (index);
15278 /* Use a control ping for synchronization */
15280 vl_api_control_ping_t *mp;
15281 M (CONTROL_PING, control_ping);
15287 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15288 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15291 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15293 vat_main_t *vam = &vat_main;
15294 int count = ntohl (mp->count);
15295 vl_api_fib_path2_t *fp;
15299 "table-id %d, label %u, ess_bit %u\n",
15300 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15302 for (i = 0; i < count; i++)
15304 if (fp->afi == IP46_TYPE_IP6)
15306 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15307 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15308 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15309 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15310 format_ip6_address, fp->next_hop);
15311 else if (fp->afi == IP46_TYPE_IP4)
15313 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15314 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15315 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15316 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15317 format_ip4_address, fp->next_hop);
15322 static void vl_api_mpls_fib_details_t_handler_json
15323 (vl_api_mpls_fib_details_t * mp)
15325 vat_main_t *vam = &vat_main;
15326 int count = ntohl (mp->count);
15327 vat_json_node_t *node = NULL;
15328 struct in_addr ip4;
15329 struct in6_addr ip6;
15330 vl_api_fib_path2_t *fp;
15333 if (VAT_JSON_ARRAY != vam->json_tree.type)
15335 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15336 vat_json_init_array (&vam->json_tree);
15338 node = vat_json_array_add (&vam->json_tree);
15340 vat_json_init_object (node);
15341 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15342 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15343 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15344 vat_json_object_add_uint (node, "path_count", count);
15346 for (i = 0; i < count; i++)
15348 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15349 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15350 vat_json_object_add_uint (node, "is_local", fp->is_local);
15351 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15352 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15353 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15354 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15355 if (fp->afi == IP46_TYPE_IP4)
15357 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15358 vat_json_object_add_ip4 (node, "next_hop", ip4);
15360 else if (fp->afi == IP46_TYPE_IP6)
15362 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15363 vat_json_object_add_ip6 (node, "next_hop", ip6);
15369 api_mpls_fib_dump (vat_main_t * vam)
15371 vl_api_mpls_fib_dump_t *mp;
15374 M (MPLS_FIB_DUMP, mpls_fib_dump);
15377 /* Use a control ping for synchronization */
15379 vl_api_control_ping_t *mp;
15380 M (CONTROL_PING, control_ping);
15386 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15387 #define vl_api_ip_fib_details_t_print vl_noop_handler
15390 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15392 vat_main_t *vam = &vat_main;
15393 int count = ntohl (mp->count);
15394 vl_api_fib_path_t *fp;
15398 "table-id %d, prefix %U/%d\n",
15399 ntohl (mp->table_id), format_ip4_address, mp->address,
15400 mp->address_length);
15402 for (i = 0; i < count; i++)
15404 if (fp->afi == IP46_TYPE_IP6)
15406 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15407 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15408 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15409 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15410 format_ip6_address, fp->next_hop);
15411 else if (fp->afi == IP46_TYPE_IP4)
15413 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15414 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15415 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15416 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15417 format_ip4_address, fp->next_hop);
15422 static void vl_api_ip_fib_details_t_handler_json
15423 (vl_api_ip_fib_details_t * mp)
15425 vat_main_t *vam = &vat_main;
15426 int count = ntohl (mp->count);
15427 vat_json_node_t *node = NULL;
15428 struct in_addr ip4;
15429 struct in6_addr ip6;
15430 vl_api_fib_path_t *fp;
15433 if (VAT_JSON_ARRAY != vam->json_tree.type)
15435 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15436 vat_json_init_array (&vam->json_tree);
15438 node = vat_json_array_add (&vam->json_tree);
15440 vat_json_init_object (node);
15441 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15442 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15443 vat_json_object_add_ip4 (node, "prefix", ip4);
15444 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15445 vat_json_object_add_uint (node, "path_count", count);
15447 for (i = 0; i < count; i++)
15449 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15450 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15451 vat_json_object_add_uint (node, "is_local", fp->is_local);
15452 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15453 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15454 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15455 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15456 if (fp->afi == IP46_TYPE_IP4)
15458 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15459 vat_json_object_add_ip4 (node, "next_hop", ip4);
15461 else if (fp->afi == IP46_TYPE_IP6)
15463 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15464 vat_json_object_add_ip6 (node, "next_hop", ip6);
15470 api_ip_fib_dump (vat_main_t * vam)
15472 vl_api_ip_fib_dump_t *mp;
15475 M (IP_FIB_DUMP, ip_fib_dump);
15478 /* Use a control ping for synchronization */
15480 vl_api_control_ping_t *mp;
15481 M (CONTROL_PING, control_ping);
15487 static void vl_api_ip_neighbor_details_t_handler
15488 (vl_api_ip_neighbor_details_t * mp)
15490 vat_main_t *vam = &vat_main;
15492 fformat (vam->ofp, "%c %U %U\n",
15493 (mp->is_static) ? 'S' : 'D',
15494 format_ethernet_address, &mp->mac_address,
15495 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15499 static void vl_api_ip_neighbor_details_t_handler_json
15500 (vl_api_ip_neighbor_details_t * mp)
15503 vat_main_t *vam = &vat_main;
15504 vat_json_node_t *node;
15505 struct in_addr ip4;
15506 struct in6_addr ip6;
15508 if (VAT_JSON_ARRAY != vam->json_tree.type)
15510 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15511 vat_json_init_array (&vam->json_tree);
15513 node = vat_json_array_add (&vam->json_tree);
15515 vat_json_init_object (node);
15516 vat_json_object_add_string_copy (node, "flag",
15517 (mp->is_static) ? (u8 *) "static" : (u8 *)
15520 vat_json_object_add_string_copy (node, "link_layer",
15521 format (0, "%U", format_ethernet_address,
15522 &mp->mac_address));
15526 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15527 vat_json_object_add_ip6 (node, "ip_address", ip6);
15531 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15532 vat_json_object_add_ip4 (node, "ip_address", ip4);
15537 api_ip_neighbor_dump (vat_main_t * vam)
15539 unformat_input_t *i = vam->input;
15540 vl_api_ip_neighbor_dump_t *mp;
15543 u32 sw_if_index = ~0;
15545 /* Parse args required to build the message */
15546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15548 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15552 else if (unformat (i, "ip6"))
15558 if (sw_if_index == ~0)
15560 errmsg ("missing interface name or sw_if_index\n");
15564 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15565 mp->is_ipv6 = (u8) is_ipv6;
15566 mp->sw_if_index = ntohl (sw_if_index);
15569 /* Use a control ping for synchronization */
15571 vl_api_control_ping_t *mp;
15572 M (CONTROL_PING, control_ping);
15578 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15579 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15582 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15584 vat_main_t *vam = &vat_main;
15585 int count = ntohl (mp->count);
15586 vl_api_fib_path_t *fp;
15590 "table-id %d, prefix %U/%d\n",
15591 ntohl (mp->table_id), format_ip6_address, mp->address,
15592 mp->address_length);
15594 for (i = 0; i < count; i++)
15596 if (fp->afi == IP46_TYPE_IP6)
15598 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15599 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15600 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15601 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15602 format_ip6_address, fp->next_hop);
15603 else if (fp->afi == IP46_TYPE_IP4)
15605 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15606 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15607 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15608 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15609 format_ip4_address, fp->next_hop);
15614 static void vl_api_ip6_fib_details_t_handler_json
15615 (vl_api_ip6_fib_details_t * mp)
15617 vat_main_t *vam = &vat_main;
15618 int count = ntohl (mp->count);
15619 vat_json_node_t *node = NULL;
15620 struct in_addr ip4;
15621 struct in6_addr ip6;
15622 vl_api_fib_path_t *fp;
15625 if (VAT_JSON_ARRAY != vam->json_tree.type)
15627 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15628 vat_json_init_array (&vam->json_tree);
15630 node = vat_json_array_add (&vam->json_tree);
15632 vat_json_init_object (node);
15633 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15634 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15635 vat_json_object_add_ip6 (node, "prefix", ip6);
15636 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15637 vat_json_object_add_uint (node, "path_count", count);
15639 for (i = 0; i < count; i++)
15641 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15642 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15643 vat_json_object_add_uint (node, "is_local", fp->is_local);
15644 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15645 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15646 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15647 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15648 if (fp->afi == IP46_TYPE_IP4)
15650 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15651 vat_json_object_add_ip4 (node, "next_hop", ip4);
15653 else if (fp->afi == IP46_TYPE_IP6)
15655 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15656 vat_json_object_add_ip6 (node, "next_hop", ip6);
15662 api_ip6_fib_dump (vat_main_t * vam)
15664 vl_api_ip6_fib_dump_t *mp;
15667 M (IP6_FIB_DUMP, ip6_fib_dump);
15670 /* Use a control ping for synchronization */
15672 vl_api_control_ping_t *mp;
15673 M (CONTROL_PING, control_ping);
15680 api_classify_table_ids (vat_main_t * vam)
15682 vl_api_classify_table_ids_t *mp;
15685 /* Construct the API message */
15686 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15696 api_classify_table_by_interface (vat_main_t * vam)
15698 unformat_input_t *input = vam->input;
15699 vl_api_classify_table_by_interface_t *mp;
15702 u32 sw_if_index = ~0;
15703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15705 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15707 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15712 if (sw_if_index == ~0)
15714 errmsg ("missing interface name or sw_if_index\n");
15718 /* Construct the API message */
15719 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15721 mp->sw_if_index = ntohl (sw_if_index);
15730 api_classify_table_info (vat_main_t * vam)
15732 unformat_input_t *input = vam->input;
15733 vl_api_classify_table_info_t *mp;
15737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (input, "table_id %d", &table_id))
15744 if (table_id == ~0)
15746 errmsg ("missing table id\n");
15750 /* Construct the API message */
15751 M (CLASSIFY_TABLE_INFO, classify_table_info);
15753 mp->table_id = ntohl (table_id);
15762 api_classify_session_dump (vat_main_t * vam)
15764 unformat_input_t *input = vam->input;
15765 vl_api_classify_session_dump_t *mp;
15769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15771 if (unformat (input, "table_id %d", &table_id))
15776 if (table_id == ~0)
15778 errmsg ("missing table id\n");
15782 /* Construct the API message */
15783 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15785 mp->table_id = ntohl (table_id);
15788 /* Use a control ping for synchronization */
15790 vl_api_control_ping_t *mp;
15791 M (CONTROL_PING, control_ping);
15800 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15802 vat_main_t *vam = &vat_main;
15804 fformat (vam->ofp, "collector_address %U, collector_port %d, "
15805 "src_address %U, vrf_id %d, path_mtu %u, "
15806 "template_interval %u, udp_checksum %d\n",
15807 format_ip4_address, mp->collector_address,
15808 ntohs (mp->collector_port),
15809 format_ip4_address, mp->src_address,
15810 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15811 ntohl (mp->template_interval), mp->udp_checksum);
15814 vam->result_ready = 1;
15818 vl_api_ipfix_exporter_details_t_handler_json
15819 (vl_api_ipfix_exporter_details_t * mp)
15821 vat_main_t *vam = &vat_main;
15822 vat_json_node_t node;
15823 struct in_addr collector_address;
15824 struct in_addr src_address;
15826 vat_json_init_object (&node);
15827 clib_memcpy (&collector_address, &mp->collector_address,
15828 sizeof (collector_address));
15829 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15830 vat_json_object_add_uint (&node, "collector_port",
15831 ntohs (mp->collector_port));
15832 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15833 vat_json_object_add_ip4 (&node, "src_address", src_address);
15834 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15835 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15836 vat_json_object_add_uint (&node, "template_interval",
15837 ntohl (mp->template_interval));
15838 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15840 vat_json_print (vam->ofp, &node);
15841 vat_json_free (&node);
15843 vam->result_ready = 1;
15847 api_ipfix_exporter_dump (vat_main_t * vam)
15849 vl_api_ipfix_exporter_dump_t *mp;
15852 /* Construct the API message */
15853 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15863 api_ipfix_classify_stream_dump (vat_main_t * vam)
15865 vl_api_ipfix_classify_stream_dump_t *mp;
15868 /* Construct the API message */
15869 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15879 vl_api_ipfix_classify_stream_details_t_handler
15880 (vl_api_ipfix_classify_stream_details_t * mp)
15882 vat_main_t *vam = &vat_main;
15883 fformat (vam->ofp, "domain_id %d, src_port %d\n",
15884 ntohl (mp->domain_id), ntohs (mp->src_port));
15886 vam->result_ready = 1;
15890 vl_api_ipfix_classify_stream_details_t_handler_json
15891 (vl_api_ipfix_classify_stream_details_t * mp)
15893 vat_main_t *vam = &vat_main;
15894 vat_json_node_t node;
15896 vat_json_init_object (&node);
15897 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15898 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15900 vat_json_print (vam->ofp, &node);
15901 vat_json_free (&node);
15903 vam->result_ready = 1;
15907 api_ipfix_classify_table_dump (vat_main_t * vam)
15909 vl_api_ipfix_classify_table_dump_t *mp;
15912 if (!vam->json_output)
15914 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
15915 "transport_protocol");
15918 /* Construct the API message */
15919 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15924 /* Use a control ping for synchronization */
15926 vl_api_control_ping_t *mp;
15927 M (CONTROL_PING, control_ping);
15934 vl_api_ipfix_classify_table_details_t_handler
15935 (vl_api_ipfix_classify_table_details_t * mp)
15937 vat_main_t *vam = &vat_main;
15938 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
15939 mp->transport_protocol);
15943 vl_api_ipfix_classify_table_details_t_handler_json
15944 (vl_api_ipfix_classify_table_details_t * mp)
15946 vat_json_node_t *node = NULL;
15947 vat_main_t *vam = &vat_main;
15949 if (VAT_JSON_ARRAY != vam->json_tree.type)
15951 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15952 vat_json_init_array (&vam->json_tree);
15955 node = vat_json_array_add (&vam->json_tree);
15956 vat_json_init_object (node);
15958 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15959 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15960 vat_json_object_add_uint (node, "transport_protocol",
15961 mp->transport_protocol);
15965 api_sw_interface_span_enable_disable (vat_main_t * vam)
15967 unformat_input_t *i = vam->input;
15968 vl_api_sw_interface_span_enable_disable_t *mp;
15970 u32 src_sw_if_index = ~0;
15971 u32 dst_sw_if_index = ~0;
15974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15976 if (unformat (i, "src %U", unformat_sw_if_index, vam, &src_sw_if_index))
15978 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15982 (i, "dst %U", unformat_sw_if_index, vam, &dst_sw_if_index))
15984 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15986 else if (unformat (i, "disable"))
15988 else if (unformat (i, "rx"))
15990 else if (unformat (i, "tx"))
15992 else if (unformat (i, "both"))
15998 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16000 mp->sw_if_index_from = htonl (src_sw_if_index);
16001 mp->sw_if_index_to = htonl (dst_sw_if_index);
16011 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16014 vat_main_t *vam = &vat_main;
16015 u8 *sw_if_from_name = 0;
16016 u8 *sw_if_to_name = 0;
16017 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16018 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16019 char *states[] = { "none", "rx", "tx", "both" };
16023 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16025 if ((u32) p->value[0] == sw_if_index_from)
16027 sw_if_from_name = (u8 *)(p->key);
16031 if ((u32) p->value[0] == sw_if_index_to)
16033 sw_if_to_name = (u8 *)(p->key);
16034 if (sw_if_from_name)
16039 fformat (vam->ofp, "%20s => %20s (%s)\n",
16040 sw_if_from_name, sw_if_to_name, states[mp->state]);
16044 vl_api_sw_interface_span_details_t_handler_json
16045 (vl_api_sw_interface_span_details_t * mp)
16047 vat_main_t *vam = &vat_main;
16048 vat_json_node_t *node = NULL;
16049 u8 *sw_if_from_name = 0;
16050 u8 *sw_if_to_name = 0;
16051 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16052 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16056 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16058 if ((u32) p->value[0] == sw_if_index_from)
16060 sw_if_from_name = (u8 *)(p->key);
16064 if ((u32) p->value[0] == sw_if_index_to)
16066 sw_if_to_name = (u8 *)(p->key);
16067 if (sw_if_from_name)
16073 if (VAT_JSON_ARRAY != vam->json_tree.type)
16075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16076 vat_json_init_array (&vam->json_tree);
16078 node = vat_json_array_add (&vam->json_tree);
16080 vat_json_init_object (node);
16081 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16082 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16083 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16084 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16085 vat_json_object_add_uint (node, "state", mp->state);
16089 api_sw_interface_span_dump (vat_main_t * vam)
16091 vl_api_sw_interface_span_dump_t *mp;
16094 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16097 /* Use a control ping for synchronization */
16099 vl_api_control_ping_t *mp;
16100 M (CONTROL_PING, control_ping);
16107 api_pg_create_interface (vat_main_t * vam)
16109 unformat_input_t *input = vam->input;
16110 vl_api_pg_create_interface_t *mp;
16114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16116 if (unformat (input, "if_id %d", &if_id))
16123 errmsg ("missing pg interface index\n");
16127 /* Construct the API message */
16128 M (PG_CREATE_INTERFACE, pg_create_interface);
16130 mp->interface_id = ntohl (if_id);
16139 api_pg_capture (vat_main_t * vam)
16141 unformat_input_t *input = vam->input;
16142 vl_api_pg_capture_t *mp;
16148 u8 pcap_file_set = 0;
16150 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16152 if (unformat (input, "if_id %d", &if_id))
16154 else if (unformat (input, "pcap %s", &pcap_file))
16156 else if (unformat (input, "count %d", &count))
16158 else if (unformat (input, "disable"))
16165 errmsg ("missing pg interface index\n");
16168 if (pcap_file_set > 0)
16170 if (vec_len (pcap_file) > 255)
16172 errmsg ("pcap file name is too long\n");
16177 u32 name_len = vec_len (pcap_file);
16178 /* Construct the API message */
16179 M (PG_CAPTURE, pg_capture);
16181 mp->interface_id = ntohl (if_id);
16182 mp->is_enabled = enable;
16183 mp->count = ntohl (count);
16184 mp->pcap_name_length = ntohl (name_len);
16185 if (pcap_file_set != 0)
16187 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16189 vec_free (pcap_file);
16198 api_pg_enable_disable (vat_main_t * vam)
16200 unformat_input_t *input = vam->input;
16201 vl_api_pg_enable_disable_t *mp;
16205 u8 stream_name_set = 0;
16206 u8 *stream_name = 0;
16207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16209 if (unformat (input, "stream %s", &stream_name))
16210 stream_name_set = 1;
16211 else if (unformat (input, "disable"))
16217 if (stream_name_set > 0)
16219 if (vec_len (stream_name) > 255)
16221 errmsg ("stream name too long\n");
16226 u32 name_len = vec_len (stream_name);
16227 /* Construct the API message */
16228 M (PG_ENABLE_DISABLE, pg_enable_disable);
16230 mp->is_enabled = enable;
16231 if (stream_name_set != 0)
16233 mp->stream_name_length = ntohl (name_len);
16234 clib_memcpy (mp->stream_name, stream_name, name_len);
16236 vec_free (stream_name);
16245 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16247 unformat_input_t *input = vam->input;
16248 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16251 u16 *low_ports = 0;
16252 u16 *high_ports = 0;
16255 ip4_address_t ip4_addr;
16256 ip6_address_t ip6_addr;
16264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16266 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16272 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16277 else if (unformat (input, "vrf %d", &vrf_id))
16279 else if (unformat (input, "del"))
16281 else if (unformat (input, "port %d", &tmp))
16283 if (tmp == 0 || tmp > 65535)
16285 errmsg ("port %d out of range", tmp);
16289 this_hi = this_low + 1;
16290 vec_add1 (low_ports, this_low);
16291 vec_add1 (high_ports, this_hi);
16293 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16295 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16297 errmsg ("incorrect range parameters\n");
16301 /* Note: in debug CLI +1 is added to high before
16302 passing to real fn that does "the work"
16303 (ip_source_and_port_range_check_add_del).
16304 This fn is a wrapper around the binary API fn a
16305 control plane will call, which expects this increment
16306 to have occurred. Hence letting the binary API control
16307 plane fn do the increment for consistency between VAT
16308 and other control planes.
16311 vec_add1 (low_ports, this_low);
16312 vec_add1 (high_ports, this_hi);
16318 if (prefix_set == 0)
16320 errmsg ("<address>/<mask> not specified\n");
16326 errmsg ("VRF ID required, not specified\n");
16333 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
16337 if (vec_len (low_ports) == 0)
16339 errmsg ("At least one port or port range required\n");
16343 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16344 ip_source_and_port_range_check_add_del);
16346 mp->is_add = is_add;
16351 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16356 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16359 mp->mask_length = length;
16360 mp->number_of_ranges = vec_len (low_ports);
16362 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16363 vec_free (low_ports);
16365 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16366 vec_free (high_ports);
16368 mp->vrf_id = ntohl (vrf_id);
16377 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16379 unformat_input_t *input = vam->input;
16380 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16382 u32 sw_if_index = ~0;
16384 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16385 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16388 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16390 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
16392 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16394 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16396 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16398 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16400 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16402 else if (unformat (input, "del"))
16408 if (sw_if_index == ~0)
16410 errmsg ("Interface required but not specified\n");
16416 errmsg ("VRF ID required but not specified\n");
16420 if (tcp_out_vrf_id == 0
16421 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16424 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
16428 /* Construct the API message */
16429 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16430 ip_source_and_port_range_check_interface_add_del);
16432 mp->sw_if_index = ntohl (sw_if_index);
16433 mp->is_add = is_add;
16434 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16435 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16436 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16437 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16442 /* Wait for a reply... */
16447 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16449 unformat_input_t *i = vam->input;
16450 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16452 u32 local_sa_id = 0;
16453 u32 remote_sa_id = 0;
16454 ip4_address_t src_address;
16455 ip4_address_t dst_address;
16458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16460 if (unformat (i, "local_sa %d", &local_sa_id))
16462 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16464 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16466 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16468 else if (unformat (i, "del"))
16472 clib_warning ("parse error '%U'", format_unformat_error, i);
16477 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16479 mp->local_sa_id = ntohl (local_sa_id);
16480 mp->remote_sa_id = ntohl (remote_sa_id);
16481 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16482 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16483 mp->is_add = is_add;
16492 api_punt (vat_main_t * vam)
16494 unformat_input_t *i = vam->input;
16502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16504 if (unformat (i, "ip %d", &ipv))
16506 else if (unformat (i, "protocol %d", &protocol))
16508 else if (unformat (i, "port %d", &port))
16510 else if (unformat (i, "del"))
16514 clib_warning ("parse error '%U'", format_unformat_error, i);
16521 mp->is_add = (u8) is_add;
16522 mp->ipv = (u8) ipv;
16523 mp->l4_protocol = (u8) protocol;
16524 mp->l4_port = htons ((u16) port);
16532 static void vl_api_ipsec_gre_tunnel_details_t_handler
16533 (vl_api_ipsec_gre_tunnel_details_t * mp)
16535 vat_main_t *vam = &vat_main;
16537 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
16538 ntohl (mp->sw_if_index),
16539 format_ip4_address, &mp->src_address,
16540 format_ip4_address, &mp->dst_address,
16541 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16544 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16545 (vl_api_ipsec_gre_tunnel_details_t * mp)
16547 vat_main_t *vam = &vat_main;
16548 vat_json_node_t *node = NULL;
16549 struct in_addr ip4;
16551 if (VAT_JSON_ARRAY != vam->json_tree.type)
16553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16554 vat_json_init_array (&vam->json_tree);
16556 node = vat_json_array_add (&vam->json_tree);
16558 vat_json_init_object (node);
16559 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16560 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16561 vat_json_object_add_ip4 (node, "src_address", ip4);
16562 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16563 vat_json_object_add_ip4 (node, "dst_address", ip4);
16564 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16565 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16569 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16571 unformat_input_t *i = vam->input;
16572 vl_api_ipsec_gre_tunnel_dump_t *mp;
16575 u8 sw_if_index_set = 0;
16577 /* Parse args required to build the message */
16578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16580 if (unformat (i, "sw_if_index %d", &sw_if_index))
16581 sw_if_index_set = 1;
16586 if (sw_if_index_set == 0)
16591 if (!vam->json_output)
16593 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
16594 "sw_if_index", "src_address", "dst_address",
16595 "local_sa_id", "remote_sa_id");
16598 /* Get list of gre-tunnel interfaces */
16599 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16601 mp->sw_if_index = htonl (sw_if_index);
16605 /* Use a control ping for synchronization */
16607 vl_api_control_ping_t *mp;
16608 M (CONTROL_PING, control_ping);
16615 api_delete_subif (vat_main_t * vam)
16617 unformat_input_t *i = vam->input;
16618 vl_api_delete_subif_t *mp;
16620 u32 sw_if_index = ~0;
16622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16624 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16626 if (unformat (i, "sw_if_index %d", &sw_if_index))
16632 if (sw_if_index == ~0)
16634 errmsg ("missing sw_if_index\n");
16638 /* Construct the API message */
16639 M (DELETE_SUBIF, delete_subif);
16640 mp->sw_if_index = ntohl (sw_if_index);
16646 #define foreach_pbb_vtr_op \
16647 _("disable", L2_VTR_DISABLED) \
16648 _("pop", L2_VTR_POP_2) \
16649 _("push", L2_VTR_PUSH_2)
16652 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16654 unformat_input_t *i = vam->input;
16655 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16657 u32 sw_if_index = ~0, vtr_op = ~0;
16658 u16 outer_tag = ~0;
16659 u8 dmac[6], smac[6];
16660 u8 dmac_set = 0, smac_set = 0;
16665 /* Shut up coverity */
16666 memset (dmac, 0, sizeof (dmac));
16667 memset (smac, 0, sizeof (smac));
16669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16671 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16675 else if (unformat (i, "vtr_op %d", &vtr_op))
16677 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16680 else if (unformat (i, "translate_pbb_stag"))
16682 if (unformat (i, "%d", &tmp))
16684 vtr_op = L2_VTR_TRANSLATE_2_1;
16690 ("translate_pbb_stag operation requires outer tag definition\n");
16694 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16696 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16698 else if (unformat (i, "sid %d", &sid))
16700 else if (unformat (i, "vlanid %d", &tmp))
16704 clib_warning ("parse error '%U'", format_unformat_error, i);
16709 if ((sw_if_index == ~0) || (vtr_op == ~0))
16711 errmsg ("missing sw_if_index or vtr operation\n");
16714 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16715 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16718 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
16722 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16723 mp->sw_if_index = ntohl (sw_if_index);
16724 mp->vtr_op = ntohl (vtr_op);
16725 mp->outer_tag = ntohs (outer_tag);
16726 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16727 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16728 mp->b_vlanid = ntohs (vlanid);
16729 mp->i_sid = ntohl (sid);
16738 api_flow_classify_set_interface (vat_main_t * vam)
16740 unformat_input_t *i = vam->input;
16741 vl_api_flow_classify_set_interface_t *mp;
16744 int sw_if_index_set;
16745 u32 ip4_table_index = ~0;
16746 u32 ip6_table_index = ~0;
16749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16751 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16752 sw_if_index_set = 1;
16753 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16754 sw_if_index_set = 1;
16755 else if (unformat (i, "del"))
16757 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16759 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16763 clib_warning ("parse error '%U'", format_unformat_error, i);
16768 if (sw_if_index_set == 0)
16770 errmsg ("missing interface name or sw_if_index\n");
16774 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16776 mp->sw_if_index = ntohl (sw_if_index);
16777 mp->ip4_table_index = ntohl (ip4_table_index);
16778 mp->ip6_table_index = ntohl (ip6_table_index);
16779 mp->is_add = is_add;
16788 api_flow_classify_dump (vat_main_t * vam)
16790 unformat_input_t *i = vam->input;
16791 vl_api_flow_classify_dump_t *mp;
16793 u8 type = FLOW_CLASSIFY_N_TABLES;
16795 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16799 errmsg ("classify table type must be specified\n");
16803 if (!vam->json_output)
16805 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
16808 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16813 /* Use a control ping for synchronization */
16815 vl_api_control_ping_t *mp;
16816 M (CONTROL_PING, control_ping);
16819 /* Wait for a reply... */
16827 api_feature_enable_disable (vat_main_t * vam)
16829 unformat_input_t *i = vam->input;
16830 vl_api_feature_enable_disable_t *mp;
16833 u8 *feature_name = 0;
16834 u32 sw_if_index = ~0;
16837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16839 if (unformat (i, "arc_name %s", &arc_name))
16841 else if (unformat (i, "feature_name %s", &feature_name))
16843 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16845 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16847 else if (unformat (i, "disable"))
16855 errmsg ("missing arc name\n");
16858 if (vec_len (arc_name) > 63)
16860 errmsg ("arc name too long\n");
16863 if (feature_name == 0)
16865 errmsg ("missing feature name\n");
16868 if (vec_len (feature_name) > 63)
16870 errmsg ("feature name too long\n");
16873 if (sw_if_index == ~0)
16875 errmsg ("missing interface name or sw_if_index\n");
16879 /* Construct the API message */
16880 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16881 mp->sw_if_index = ntohl (sw_if_index);
16882 mp->enable = enable;
16883 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16884 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16885 vec_free (arc_name);
16886 vec_free (feature_name);
16893 api_sw_interface_tag_add_del (vat_main_t * vam)
16895 unformat_input_t *i = vam->input;
16896 vl_api_sw_interface_tag_add_del_t *mp;
16898 u32 sw_if_index = ~0;
16902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16904 if (unformat (i, "tag %s", &tag))
16906 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16910 else if (unformat (i, "del"))
16916 if (sw_if_index == ~0)
16918 errmsg ("missing interface name or sw_if_index\n");
16922 if (enable && (tag == 0))
16924 errmsg ("no tag specified\n");
16928 /* Construct the API message */
16929 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16930 mp->sw_if_index = ntohl (sw_if_index);
16931 mp->is_add = enable;
16933 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16940 static void vl_api_l2_xconnect_details_t_handler
16941 (vl_api_l2_xconnect_details_t * mp)
16943 vat_main_t *vam = &vat_main;
16945 fformat (vam->ofp, "%15d%15d\n",
16946 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16949 static void vl_api_l2_xconnect_details_t_handler_json
16950 (vl_api_l2_xconnect_details_t * mp)
16952 vat_main_t *vam = &vat_main;
16953 vat_json_node_t *node = NULL;
16955 if (VAT_JSON_ARRAY != vam->json_tree.type)
16957 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16958 vat_json_init_array (&vam->json_tree);
16960 node = vat_json_array_add (&vam->json_tree);
16962 vat_json_init_object (node);
16963 vat_json_object_add_uint (node, "rx_sw_if_index",
16964 ntohl (mp->rx_sw_if_index));
16965 vat_json_object_add_uint (node, "tx_sw_if_index",
16966 ntohl (mp->tx_sw_if_index));
16970 api_l2_xconnect_dump (vat_main_t * vam)
16972 vl_api_l2_xconnect_dump_t *mp;
16975 if (!vam->json_output)
16977 fformat (vam->ofp, "%15s%15s\n", "rx_sw_if_index", "tx_sw_if_index");
16980 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
16984 /* Use a control ping for synchronization */
16986 vl_api_control_ping_t *mp;
16987 M (CONTROL_PING, control_ping);
16994 api_sw_interface_set_mtu (vat_main_t * vam)
16996 unformat_input_t *i = vam->input;
16997 vl_api_sw_interface_set_mtu_t *mp;
16999 u32 sw_if_index = ~0;
17002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17004 if (unformat (i, "mtu %d", &mtu))
17006 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
17008 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17014 if (sw_if_index == ~0)
17016 errmsg ("missing interface name or sw_if_index\n");
17022 errmsg ("no mtu specified\n");
17026 /* Construct the API message */
17027 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17028 mp->sw_if_index = ntohl (sw_if_index);
17029 mp->mtu = ntohs ((u16) mtu);
17037 q_or_quit (vat_main_t * vam)
17039 longjmp (vam->jump_buf, 1);
17040 return 0; /* not so much */
17044 q (vat_main_t * vam)
17046 return q_or_quit (vam);
17050 quit (vat_main_t * vam)
17052 return q_or_quit (vam);
17056 comment (vat_main_t * vam)
17062 cmd_cmp (void *a1, void *a2)
17067 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17071 help (vat_main_t * vam)
17076 unformat_input_t *i = vam->input;
17079 if (unformat (i, "%s", &name))
17083 vec_add1 (name, 0);
17085 hs = hash_get_mem (vam->help_by_name, name);
17087 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
17089 fformat (vam->ofp, "No such msg / command '%s'\n", name);
17094 fformat (vam->ofp, "Help is available for the following:\n");
17097 hash_foreach_pair (p, vam->function_by_name,
17099 vec_add1 (cmds, (u8 *)(p->key));
17103 vec_sort_with_function (cmds, cmd_cmp);
17105 for (j = 0; j < vec_len (cmds); j++)
17106 fformat (vam->ofp, "%s\n", cmds[j]);
17113 set (vat_main_t * vam)
17115 u8 *name = 0, *value = 0;
17116 unformat_input_t *i = vam->input;
17118 if (unformat (i, "%s", &name))
17120 /* The input buffer is a vector, not a string. */
17121 value = vec_dup (i->buffer);
17122 vec_delete (value, i->index, 0);
17123 /* Almost certainly has a trailing newline */
17124 if (value[vec_len (value) - 1] == '\n')
17125 value[vec_len (value) - 1] = 0;
17126 /* Make sure it's a proper string, one way or the other */
17127 vec_add1 (value, 0);
17128 (void) clib_macro_set_value (&vam->macro_main,
17129 (char *) name, (char *) value);
17132 errmsg ("usage: set <name> <value>\n");
17140 unset (vat_main_t * vam)
17144 if (unformat (vam->input, "%s", &name))
17145 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17146 errmsg ("unset: %s wasn't set\n", name);
17159 macro_sort_cmp (void *a1, void *a2)
17161 macro_sort_t *s1 = a1;
17162 macro_sort_t *s2 = a2;
17164 return strcmp ((char *) (s1->name), (char *) (s2->name));
17168 dump_macro_table (vat_main_t * vam)
17170 macro_sort_t *sort_me = 0, *sm;
17175 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17177 vec_add2 (sort_me, sm, 1);
17178 sm->name = (u8 *)(p->key);
17179 sm->value = (u8 *) (p->value[0]);
17183 vec_sort_with_function (sort_me, macro_sort_cmp);
17185 if (vec_len (sort_me))
17186 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
17188 fformat (vam->ofp, "The macro table is empty...\n");
17190 for (i = 0; i < vec_len (sort_me); i++)
17191 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
17196 dump_node_table (vat_main_t * vam)
17199 vlib_node_t *node, *next_node;
17201 if (vec_len (vam->graph_nodes) == 0)
17203 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
17207 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17209 node = vam->graph_nodes[i];
17210 fformat (vam->ofp, "[%d] %s\n", i, node->name);
17211 for (j = 0; j < vec_len (node->next_nodes); j++)
17213 if (node->next_nodes[j] != ~0)
17215 next_node = vam->graph_nodes[node->next_nodes[j]];
17216 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
17224 value_sort_cmp (void *a1, void *a2)
17226 name_sort_t *n1 = a1;
17227 name_sort_t *n2 = a2;
17229 if (n1->value < n2->value)
17231 if (n1->value > n2->value)
17238 dump_msg_api_table (vat_main_t * vam)
17240 api_main_t *am = &api_main;
17241 name_sort_t *nses = 0, *ns;
17246 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17248 vec_add2 (nses, ns, 1);
17249 ns->name = (u8 *)(hp->key);
17250 ns->value = (u32) hp->value[0];
17254 vec_sort_with_function (nses, value_sort_cmp);
17256 for (i = 0; i < vec_len (nses); i++)
17257 fformat (vam->ofp, " [%d]: %s\n", nses[i].value, nses[i].name);
17263 get_msg_id (vat_main_t * vam)
17268 if (unformat (vam->input, "%s", &name_and_crc))
17270 message_index = vl_api_get_msg_index (name_and_crc);
17271 if (message_index == ~0)
17273 fformat (vam->ofp, " '%s' not found\n", name_and_crc);
17276 fformat (vam->ofp, " '%s' has message index %d\n",
17277 name_and_crc, message_index);
17280 errmsg ("name_and_crc required...\n");
17285 search_node_table (vat_main_t * vam)
17287 unformat_input_t *line_input = vam->input;
17290 vlib_node_t *node, *next_node;
17293 if (vam->graph_node_index_by_name == 0)
17295 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
17299 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17301 if (unformat (line_input, "%s", &node_to_find))
17303 vec_add1 (node_to_find, 0);
17304 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17307 fformat (vam->ofp, "%s not found...\n", node_to_find);
17310 node = vam->graph_nodes[p[0]];
17311 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
17312 for (j = 0; j < vec_len (node->next_nodes); j++)
17314 if (node->next_nodes[j] != ~0)
17316 next_node = vam->graph_nodes[node->next_nodes[j]];
17317 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
17324 clib_warning ("parse error '%U'", format_unformat_error,
17330 vec_free (node_to_find);
17339 script (vat_main_t * vam)
17342 char *save_current_file;
17343 unformat_input_t save_input;
17344 jmp_buf save_jump_buf;
17345 u32 save_line_number;
17347 FILE *new_fp, *save_ifp;
17349 if (unformat (vam->input, "%s", &s))
17351 new_fp = fopen ((char *) s, "r");
17354 errmsg ("Couldn't open script file %s\n", s);
17361 errmsg ("Missing script name\n");
17365 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17366 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17367 save_ifp = vam->ifp;
17368 save_line_number = vam->input_line_number;
17369 save_current_file = (char *) vam->current_file;
17371 vam->input_line_number = 0;
17373 vam->current_file = s;
17376 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17377 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17378 vam->ifp = save_ifp;
17379 vam->input_line_number = save_line_number;
17380 vam->current_file = (u8 *) save_current_file;
17387 echo (vat_main_t * vam)
17389 fformat (vam->ofp, "%v", vam->input->buffer);
17393 /* List of API message constructors, CLI names map to api_xxx */
17394 #define foreach_vpe_api_msg \
17395 _(create_loopback,"[mac <mac-addr>]") \
17396 _(sw_interface_dump,"") \
17397 _(sw_interface_set_flags, \
17398 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17399 _(sw_interface_add_del_address, \
17400 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17401 _(sw_interface_set_table, \
17402 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17403 _(sw_interface_set_mpls_enable, \
17404 "<intfc> | sw_if_index [disable | dis]") \
17405 _(sw_interface_set_vpath, \
17406 "<intfc> | sw_if_index <id> enable | disable") \
17407 _(sw_interface_set_vxlan_bypass, \
17408 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17409 _(sw_interface_set_l2_xconnect, \
17410 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17411 "enable | disable") \
17412 _(sw_interface_set_l2_bridge, \
17413 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17414 "[shg <split-horizon-group>] [bvi]\n" \
17415 "enable | disable") \
17416 _(sw_interface_set_dpdk_hqos_pipe, \
17417 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17418 "profile <profile-id>\n") \
17419 _(sw_interface_set_dpdk_hqos_subport, \
17420 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17421 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17422 _(sw_interface_set_dpdk_hqos_tctbl, \
17423 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
17424 _(bridge_domain_add_del, \
17425 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
17426 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17428 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17430 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17432 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17434 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17436 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17438 "<vpp-if-name> | sw_if_index <id>") \
17439 _(sw_interface_tap_dump, "") \
17440 _(ip_add_del_route, \
17441 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17442 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17443 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17444 "[multipath] [count <n>]") \
17445 _(mpls_route_add_del, \
17446 "<label> <eos> via <addr> [table-id <n>]\n" \
17447 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17448 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17449 "[multipath] [count <n>]") \
17450 _(mpls_ip_bind_unbind, \
17451 "<label> <addr/len>") \
17452 _(mpls_tunnel_add_del, \
17453 " via <addr> [table-id <n>]\n" \
17454 "sw_if_index <id>] [l2] [del]") \
17455 _(proxy_arp_add_del, \
17456 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17457 _(proxy_arp_intfc_enable_disable, \
17458 "<intfc> | sw_if_index <id> enable | disable") \
17459 _(sw_interface_set_unnumbered, \
17460 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17461 _(ip_neighbor_add_del, \
17462 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17463 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17464 _(reset_vrf, "vrf <id> [ipv6]") \
17465 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17466 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17467 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17468 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17469 "[outer_vlan_id_any][inner_vlan_id_any]") \
17470 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17471 _(reset_fib, "vrf <n> [ipv6]") \
17472 _(dhcp_proxy_config, \
17473 "svr <v46-address> src <v46-address>\n" \
17474 "insert-cid <n> [del]") \
17475 _(dhcp_proxy_config_2, \
17476 "svr <v46-address> src <v46-address>\n" \
17477 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17478 _(dhcp_proxy_set_vss, \
17479 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17480 _(dhcp_client_config, \
17481 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17482 _(set_ip_flow_hash, \
17483 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17484 _(sw_interface_ip6_enable_disable, \
17485 "<intfc> | sw_if_index <id> enable | disable") \
17486 _(sw_interface_ip6_set_link_local_address, \
17487 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17488 _(sw_interface_ip6nd_ra_prefix, \
17489 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17490 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17491 "[nolink] [isno]") \
17492 _(sw_interface_ip6nd_ra_config, \
17493 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17494 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17495 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17496 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17497 _(l2_patch_add_del, \
17498 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17499 "enable | disable") \
17500 _(sr_tunnel_add_del, \
17501 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17502 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17503 "[policy <policy_name>]") \
17504 _(sr_policy_add_del, \
17505 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17506 _(sr_multicast_map_add_del, \
17507 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17508 _(classify_add_del_table, \
17509 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17510 " [del] [del-chain] mask <mask-value>\n" \
17511 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17512 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17513 _(classify_add_del_session, \
17514 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17515 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17516 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17517 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17518 _(classify_set_interface_ip_table, \
17519 "<intfc> | sw_if_index <nn> table <nn>") \
17520 _(classify_set_interface_l2_tables, \
17521 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17522 " [other-table <nn>]") \
17523 _(get_node_index, "node <node-name") \
17524 _(add_node_next, "node <node-name> next <next-node-name>") \
17525 _(l2tpv3_create_tunnel, \
17526 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17527 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
17528 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17529 _(l2tpv3_set_tunnel_cookies, \
17530 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17531 "[new_remote_cookie <nn>]\n") \
17532 _(l2tpv3_interface_enable_disable, \
17533 "<intfc> | sw_if_index <nn> enable | disable") \
17534 _(l2tpv3_set_lookup_key, \
17535 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17536 _(sw_if_l2tpv3_tunnel_dump, "") \
17537 _(vxlan_add_del_tunnel, \
17538 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17539 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17540 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17541 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17542 _(gre_add_del_tunnel, \
17543 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17544 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17545 _(l2_fib_clear_table, "") \
17546 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17547 _(l2_interface_vlan_tag_rewrite, \
17548 "<intfc> | sw_if_index <nn> \n" \
17549 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17550 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17551 _(create_vhost_user_if, \
17552 "socket <filename> [server] [renumber <dev_instance>] " \
17553 "[mac <mac_address>]") \
17554 _(modify_vhost_user_if, \
17555 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17556 "[server] [renumber <dev_instance>]") \
17557 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17558 _(sw_interface_vhost_user_dump, "") \
17559 _(show_version, "") \
17560 _(vxlan_gpe_add_del_tunnel, \
17561 "local <addr> remote <addr> vni <nn>\n" \
17562 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17563 "[next-ethernet] [next-nsh]\n") \
17564 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17565 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17566 _(interface_name_renumber, \
17567 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17568 _(input_acl_set_interface, \
17569 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17570 " [l2-table <nn>] [del]") \
17571 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17572 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17573 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17574 _(ip_dump, "ipv4 | ipv6") \
17575 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17576 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17578 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17579 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17580 " integ_alg <alg> integ_key <hex>") \
17581 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17582 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17583 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17584 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
17585 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17586 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17587 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17588 "(auth_data 0x<data> | auth_data <data>)") \
17589 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17590 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17591 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17592 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17593 "(local|remote)") \
17594 _(ikev2_set_local_key, "file <absolute_file_path>") \
17595 _(delete_loopback,"sw_if_index <nn>") \
17596 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17597 _(map_add_domain, \
17598 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17599 "ip6-src <ip6addr> " \
17600 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17601 _(map_del_domain, "index <n>") \
17602 _(map_add_del_rule, \
17603 "index <n> psid <n> dst <ip6addr> [del]") \
17604 _(map_domain_dump, "") \
17605 _(map_rule_dump, "index <map-domain>") \
17606 _(want_interface_events, "enable|disable") \
17607 _(want_stats,"enable|disable") \
17608 _(get_first_msg_id, "client <name>") \
17609 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17610 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17611 "fib-id <nn> [ip4][ip6][default]") \
17612 _(get_node_graph, " ") \
17613 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17614 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17615 _(ioam_disable, "") \
17616 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
17617 " sw_if_index <sw_if_index> p <priority> " \
17618 "w <weight>] [del]") \
17619 _(lisp_add_del_locator, "locator-set <locator_name> " \
17620 "iface <intf> | sw_if_index <sw_if_index> " \
17621 "p <priority> w <weight> [del]") \
17622 _(lisp_add_del_local_eid,"vni <vni> eid " \
17623 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17624 "locator-set <locator_name> [del]" \
17625 "[key-id sha1|sha256 secret-key <secret-key>]")\
17626 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
17627 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
17628 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17629 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17630 _(lisp_gpe_enable_disable, "enable|disable") \
17631 _(lisp_enable_disable, "enable|disable") \
17632 _(lisp_map_register_enable_disable, "enable|disable") \
17633 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17634 _(lisp_gpe_add_del_iface, "up|down") \
17635 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17637 "rloc <locator> p <prio> " \
17638 "w <weight> [rloc <loc> ... ] " \
17639 "action <action> [del-all]") \
17640 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17642 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17643 _(lisp_map_request_mode, "src-dst|dst-only") \
17644 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17645 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17646 _(lisp_locator_set_dump, "[local | remote]") \
17647 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17648 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17649 "[local] | [remote]") \
17650 _(lisp_eid_table_vni_dump, "") \
17651 _(lisp_eid_table_map_dump, "l2|l3") \
17652 _(lisp_gpe_tunnel_dump, "") \
17653 _(lisp_map_resolver_dump, "") \
17654 _(lisp_map_server_dump, "") \
17655 _(lisp_adjacencies_get, "vni <vni>") \
17656 _(show_lisp_rloc_probe_state, "") \
17657 _(show_lisp_map_register_state, "") \
17658 _(show_lisp_status, "") \
17659 _(lisp_get_map_request_itr_rlocs, "") \
17660 _(show_lisp_pitr, "") \
17661 _(show_lisp_map_request_mode, "") \
17662 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17663 _(af_packet_delete, "name <host interface name>") \
17664 _(policer_add_del, "name <policer name> <params> [del]") \
17665 _(policer_dump, "[name <policer name>]") \
17666 _(policer_classify_set_interface, \
17667 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17668 " [l2-table <nn>] [del]") \
17669 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17670 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17671 "[master|slave]") \
17672 _(netmap_delete, "name <interface name>") \
17673 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17674 _(mpls_fib_dump, "") \
17675 _(classify_table_ids, "") \
17676 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17677 _(classify_table_info, "table_id <nn>") \
17678 _(classify_session_dump, "table_id <nn>") \
17679 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17680 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17681 "[template_interval <nn>] [udp_checksum]") \
17682 _(ipfix_exporter_dump, "") \
17683 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17684 _(ipfix_classify_stream_dump, "") \
17685 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
17686 _(ipfix_classify_table_dump, "") \
17687 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17688 _(sw_interface_span_dump, "") \
17689 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17690 _(pg_create_interface, "if_id <nn>") \
17691 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17692 _(pg_enable_disable, "[stream <id>] disable") \
17693 _(ip_source_and_port_range_check_add_del, \
17694 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17695 _(ip_source_and_port_range_check_interface_add_del, \
17696 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17697 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17698 _(ipsec_gre_add_del_tunnel, \
17699 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17700 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17701 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17702 _(l2_interface_pbb_tag_rewrite, \
17703 "<intfc> | sw_if_index <nn> \n" \
17704 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17705 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17706 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17707 _(flow_classify_set_interface, \
17708 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17709 _(flow_classify_dump, "type [ip4|ip6]") \
17710 _(ip_fib_dump, "") \
17711 _(ip6_fib_dump, "") \
17712 _(feature_enable_disable, "arc_name <arc_name> " \
17713 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17714 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17716 _(l2_xconnect_dump, "") \
17717 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17718 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17719 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17721 /* List of command functions, CLI names map directly to functions */
17722 #define foreach_cli_function \
17723 _(comment, "usage: comment <ignore-rest-of-line>") \
17724 _(dump_interface_table, "usage: dump_interface_table") \
17725 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17726 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17727 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17728 _(dump_stats_table, "usage: dump_stats_table") \
17729 _(dump_macro_table, "usage: dump_macro_table ") \
17730 _(dump_node_table, "usage: dump_node_table") \
17731 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17732 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17733 _(echo, "usage: echo <message>") \
17734 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17735 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17736 _(help, "usage: help") \
17737 _(q, "usage: quit") \
17738 _(quit, "usage: quit") \
17739 _(search_node_table, "usage: search_node_table <name>...") \
17740 _(set, "usage: set <variable-name> <value>") \
17741 _(script, "usage: script <file-name>") \
17742 _(unset, "usage: unset <variable-name>")
17745 static void vl_api_##n##_t_handler_uni \
17746 (vl_api_##n##_t * mp) \
17748 vat_main_t * vam = &vat_main; \
17749 if (vam->json_output) { \
17750 vl_api_##n##_t_handler_json(mp); \
17752 vl_api_##n##_t_handler(mp); \
17755 foreach_vpe_api_reply_msg;
17759 vat_api_hookup (vat_main_t * vam)
17762 vl_msg_api_set_handlers(VL_API_##N, #n, \
17763 vl_api_##n##_t_handler_uni, \
17765 vl_api_##n##_t_endian, \
17766 vl_api_##n##_t_print, \
17767 sizeof(vl_api_##n##_t), 1);
17768 foreach_vpe_api_reply_msg;
17771 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17773 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17775 vam->function_by_name = hash_create_string (0, sizeof (uword));
17777 vam->help_by_name = hash_create_string (0, sizeof (uword));
17779 /* API messages we can send */
17780 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17781 foreach_vpe_api_msg;
17785 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17786 foreach_vpe_api_msg;
17789 /* CLI functions */
17790 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17791 foreach_cli_function;
17795 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17796 foreach_cli_function;
17801 * fd.io coding-style-patch-verification: ON
17804 * eval: (c-set-style "gnu")