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 api_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 void vat_suspend (vlib_main_t * vm, f64 interval);
93 #if VPP_API_TEST_BUILTIN == 0
94 /* Parse an IP4 address %d.%d.%d.%d. */
96 unformat_ip4_address (unformat_input_t * input, va_list * args)
98 u8 *result = va_arg (*args, u8 *);
101 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
104 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
116 unformat_ethernet_address (unformat_input_t * input, va_list * args)
118 u8 *result = va_arg (*args, u8 *);
121 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
122 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
126 for (i = 0; i < 6; i++)
127 if (a[i] >= (1 << 8))
130 for (i = 0; i < 6; i++)
136 /* Returns ethernet type as an int in host byte order. */
138 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
141 u16 *result = va_arg (*args, u16 *);
145 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
147 if (type >= (1 << 16))
155 /* Parse an IP6 address. */
157 unformat_ip6_address (unformat_input_t * input, va_list * args)
159 ip6_address_t *result = va_arg (*args, ip6_address_t *);
161 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
162 uword c, n_colon, double_colon_index;
164 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
165 double_colon_index = ARRAY_LEN (hex_quads);
166 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
169 if (c >= '0' && c <= '9')
171 else if (c >= 'a' && c <= 'f')
172 hex_digit = c + 10 - 'a';
173 else if (c >= 'A' && c <= 'F')
174 hex_digit = c + 10 - 'A';
175 else if (c == ':' && n_colon < 2)
179 unformat_put_input (input);
183 /* Too many hex quads. */
184 if (n_hex_quads >= ARRAY_LEN (hex_quads))
189 hex_quad = (hex_quad << 4) | hex_digit;
191 /* Hex quad must fit in 16 bits. */
192 if (n_hex_digits >= 4)
199 /* Save position of :: */
202 /* More than one :: ? */
203 if (double_colon_index < ARRAY_LEN (hex_quads))
205 double_colon_index = n_hex_quads;
208 if (n_colon > 0 && n_hex_digits > 0)
210 hex_quads[n_hex_quads++] = hex_quad;
216 if (n_hex_digits > 0)
217 hex_quads[n_hex_quads++] = hex_quad;
222 /* Expand :: to appropriate number of zero hex quads. */
223 if (double_colon_index < ARRAY_LEN (hex_quads))
225 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
227 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
228 hex_quads[n_zero + i] = hex_quads[i];
230 for (i = 0; i < n_zero; i++)
231 hex_quads[double_colon_index + i] = 0;
233 n_hex_quads = ARRAY_LEN (hex_quads);
236 /* Too few hex quads given. */
237 if (n_hex_quads < ARRAY_LEN (hex_quads))
240 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
241 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
248 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
250 u32 *r = va_arg (*args, u32 *);
253 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
254 foreach_ipsec_policy_action
262 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
264 u32 *r = va_arg (*args, u32 *);
267 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
268 foreach_ipsec_crypto_alg
276 format_ipsec_crypto_alg (u8 * s, va_list * args)
278 u32 i = va_arg (*args, u32);
283 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
284 foreach_ipsec_crypto_alg
287 return format (s, "unknown");
289 return format (s, "%s", t);
293 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
295 u32 *r = va_arg (*args, u32 *);
298 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
299 foreach_ipsec_integ_alg
307 format_ipsec_integ_alg (u8 * s, va_list * args)
309 u32 i = va_arg (*args, u32);
314 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
315 foreach_ipsec_integ_alg
318 return format (s, "unknown");
320 return format (s, "%s", t);
324 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
326 u32 *r = va_arg (*args, u32 *);
329 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
330 foreach_ikev2_auth_method
338 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
340 u32 *r = va_arg (*args, u32 *);
343 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
344 foreach_ikev2_id_type
350 #endif /* VPP_API_TEST_BUILTIN */
353 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
355 u8 *r = va_arg (*args, u8 *);
357 if (unformat (input, "kbps"))
358 *r = SSE2_QOS_RATE_KBPS;
359 else if (unformat (input, "pps"))
360 *r = SSE2_QOS_RATE_PPS;
367 unformat_policer_round_type (unformat_input_t * input, va_list * args)
369 u8 *r = va_arg (*args, u8 *);
371 if (unformat (input, "closest"))
372 *r = SSE2_QOS_ROUND_TO_CLOSEST;
373 else if (unformat (input, "up"))
374 *r = SSE2_QOS_ROUND_TO_UP;
375 else if (unformat (input, "down"))
376 *r = SSE2_QOS_ROUND_TO_DOWN;
383 unformat_policer_type (unformat_input_t * input, va_list * args)
385 u8 *r = va_arg (*args, u8 *);
387 if (unformat (input, "1r2c"))
388 *r = SSE2_QOS_POLICER_TYPE_1R2C;
389 else if (unformat (input, "1r3c"))
390 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
391 else if (unformat (input, "2r3c-2698"))
392 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
393 else if (unformat (input, "2r3c-4115"))
394 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
395 else if (unformat (input, "2r3c-mef5cf1"))
396 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
403 unformat_dscp (unformat_input_t * input, va_list * va)
405 u8 *r = va_arg (*va, u8 *);
408 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
417 unformat_policer_action_type (unformat_input_t * input, va_list * va)
419 sse2_qos_pol_action_params_st *a
420 = va_arg (*va, sse2_qos_pol_action_params_st *);
422 if (unformat (input, "drop"))
423 a->action_type = SSE2_QOS_ACTION_DROP;
424 else if (unformat (input, "transmit"))
425 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
426 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
427 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
434 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
436 u32 *r = va_arg (*va, u32 *);
439 if (unformat (input, "ip4"))
440 tid = POLICER_CLASSIFY_TABLE_IP4;
441 else if (unformat (input, "ip6"))
442 tid = POLICER_CLASSIFY_TABLE_IP6;
443 else if (unformat (input, "l2"))
444 tid = POLICER_CLASSIFY_TABLE_L2;
453 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
455 u32 *r = va_arg (*va, u32 *);
458 if (unformat (input, "ip4"))
459 tid = FLOW_CLASSIFY_TABLE_IP4;
460 else if (unformat (input, "ip6"))
461 tid = FLOW_CLASSIFY_TABLE_IP6;
469 #if (VPP_API_TEST_BUILTIN==0)
471 format_ip4_address (u8 * s, va_list * args)
473 u8 *a = va_arg (*args, u8 *);
474 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
478 format_ip6_address (u8 * s, va_list * args)
480 ip6_address_t *a = va_arg (*args, ip6_address_t *);
481 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
483 i_max_n_zero = ARRAY_LEN (a->as_u16);
485 i_first_zero = i_max_n_zero;
487 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
489 u32 is_zero = a->as_u16[i] == 0;
490 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
496 if ((!is_zero && n_zeros > max_n_zeros)
497 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
499 i_max_n_zero = i_first_zero;
500 max_n_zeros = n_zeros;
501 i_first_zero = ARRAY_LEN (a->as_u16);
506 last_double_colon = 0;
507 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
509 if (i == i_max_n_zero && max_n_zeros > 1)
511 s = format (s, "::");
512 i += max_n_zeros - 1;
513 last_double_colon = 1;
517 s = format (s, "%s%x",
518 (last_double_colon || i == 0) ? "" : ":",
519 clib_net_to_host_u16 (a->as_u16[i]));
520 last_double_colon = 0;
527 /* Format an IP46 address. */
529 format_ip46_address (u8 * s, va_list * args)
531 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
532 ip46_type_t type = va_arg (*args, ip46_type_t);
538 is_ip4 = ip46_address_is_ip4 (ip46);
549 format (s, "%U", format_ip4_address, &ip46->ip4) :
550 format (s, "%U", format_ip6_address, &ip46->ip6);
554 format_ethernet_address (u8 * s, va_list * args)
556 u8 *a = va_arg (*args, u8 *);
558 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
559 a[0], a[1], a[2], a[3], a[4], a[5]);
564 increment_v4_address (ip4_address_t * a)
568 v = ntohl (a->as_u32) + 1;
569 a->as_u32 = ntohl (v);
573 increment_v6_address (ip6_address_t * a)
577 v0 = clib_net_to_host_u64 (a->as_u64[0]);
578 v1 = clib_net_to_host_u64 (a->as_u64[1]);
583 a->as_u64[0] = clib_net_to_host_u64 (v0);
584 a->as_u64[1] = clib_net_to_host_u64 (v1);
588 increment_mac_address (u64 * mac)
592 tmp = clib_net_to_host_u64 (tmp);
593 tmp += 1 << 16; /* skip unused (least significant) octets */
594 tmp = clib_host_to_net_u64 (tmp);
598 static void vl_api_create_loopback_reply_t_handler
599 (vl_api_create_loopback_reply_t * mp)
601 vat_main_t *vam = &vat_main;
602 i32 retval = ntohl (mp->retval);
604 vam->retval = retval;
605 vam->regenerate_interface_table = 1;
606 vam->sw_if_index = ntohl (mp->sw_if_index);
607 vam->result_ready = 1;
610 static void vl_api_create_loopback_reply_t_handler_json
611 (vl_api_create_loopback_reply_t * mp)
613 vat_main_t *vam = &vat_main;
614 vat_json_node_t node;
616 vat_json_init_object (&node);
617 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
618 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
620 vat_json_print (vam->ofp, &node);
621 vat_json_free (&node);
622 vam->retval = ntohl (mp->retval);
623 vam->result_ready = 1;
626 static void vl_api_af_packet_create_reply_t_handler
627 (vl_api_af_packet_create_reply_t * mp)
629 vat_main_t *vam = &vat_main;
630 i32 retval = ntohl (mp->retval);
632 vam->retval = retval;
633 vam->regenerate_interface_table = 1;
634 vam->sw_if_index = ntohl (mp->sw_if_index);
635 vam->result_ready = 1;
638 static void vl_api_af_packet_create_reply_t_handler_json
639 (vl_api_af_packet_create_reply_t * mp)
641 vat_main_t *vam = &vat_main;
642 vat_json_node_t node;
644 vat_json_init_object (&node);
645 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
646 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
648 vat_json_print (vam->ofp, &node);
649 vat_json_free (&node);
651 vam->retval = ntohl (mp->retval);
652 vam->result_ready = 1;
655 static void vl_api_create_vlan_subif_reply_t_handler
656 (vl_api_create_vlan_subif_reply_t * mp)
658 vat_main_t *vam = &vat_main;
659 i32 retval = ntohl (mp->retval);
661 vam->retval = retval;
662 vam->regenerate_interface_table = 1;
663 vam->sw_if_index = ntohl (mp->sw_if_index);
664 vam->result_ready = 1;
667 static void vl_api_create_vlan_subif_reply_t_handler_json
668 (vl_api_create_vlan_subif_reply_t * mp)
670 vat_main_t *vam = &vat_main;
671 vat_json_node_t node;
673 vat_json_init_object (&node);
674 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
675 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
677 vat_json_print (vam->ofp, &node);
678 vat_json_free (&node);
680 vam->retval = ntohl (mp->retval);
681 vam->result_ready = 1;
684 static void vl_api_create_subif_reply_t_handler
685 (vl_api_create_subif_reply_t * mp)
687 vat_main_t *vam = &vat_main;
688 i32 retval = ntohl (mp->retval);
690 vam->retval = retval;
691 vam->regenerate_interface_table = 1;
692 vam->sw_if_index = ntohl (mp->sw_if_index);
693 vam->result_ready = 1;
696 static void vl_api_create_subif_reply_t_handler_json
697 (vl_api_create_subif_reply_t * mp)
699 vat_main_t *vam = &vat_main;
700 vat_json_node_t node;
702 vat_json_init_object (&node);
703 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
704 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
706 vat_json_print (vam->ofp, &node);
707 vat_json_free (&node);
709 vam->retval = ntohl (mp->retval);
710 vam->result_ready = 1;
713 static void vl_api_interface_name_renumber_reply_t_handler
714 (vl_api_interface_name_renumber_reply_t * mp)
716 vat_main_t *vam = &vat_main;
717 i32 retval = ntohl (mp->retval);
719 vam->retval = retval;
720 vam->regenerate_interface_table = 1;
721 vam->result_ready = 1;
724 static void vl_api_interface_name_renumber_reply_t_handler_json
725 (vl_api_interface_name_renumber_reply_t * mp)
727 vat_main_t *vam = &vat_main;
728 vat_json_node_t node;
730 vat_json_init_object (&node);
731 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
733 vat_json_print (vam->ofp, &node);
734 vat_json_free (&node);
736 vam->retval = ntohl (mp->retval);
737 vam->result_ready = 1;
741 * Special-case: build the interface table, maintain
742 * the next loopback sw_if_index vbl.
744 static void vl_api_sw_interface_details_t_handler
745 (vl_api_sw_interface_details_t * mp)
747 vat_main_t *vam = &vat_main;
748 u8 *s = format (0, "%s%c", mp->interface_name, 0);
750 hash_set_mem (vam->sw_if_index_by_interface_name, s,
751 ntohl (mp->sw_if_index));
753 /* In sub interface case, fill the sub interface table entry */
754 if (mp->sw_if_index != mp->sup_sw_if_index)
756 sw_interface_subif_t *sub = NULL;
758 vec_add2 (vam->sw_if_subif_table, sub, 1);
760 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
761 strncpy ((char *) sub->interface_name, (char *) s,
762 vec_len (sub->interface_name));
763 sub->sw_if_index = ntohl (mp->sw_if_index);
764 sub->sub_id = ntohl (mp->sub_id);
766 sub->sub_dot1ad = mp->sub_dot1ad;
767 sub->sub_number_of_tags = mp->sub_number_of_tags;
768 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
769 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
770 sub->sub_exact_match = mp->sub_exact_match;
771 sub->sub_default = mp->sub_default;
772 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
773 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
775 /* vlan tag rewrite */
776 sub->vtr_op = ntohl (mp->vtr_op);
777 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
778 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
779 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
783 static void vl_api_sw_interface_details_t_handler_json
784 (vl_api_sw_interface_details_t * mp)
786 vat_main_t *vam = &vat_main;
787 vat_json_node_t *node = NULL;
789 if (VAT_JSON_ARRAY != vam->json_tree.type)
791 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
792 vat_json_init_array (&vam->json_tree);
794 node = vat_json_array_add (&vam->json_tree);
796 vat_json_init_object (node);
797 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
798 vat_json_object_add_uint (node, "sup_sw_if_index",
799 ntohl (mp->sup_sw_if_index));
800 vat_json_object_add_uint (node, "l2_address_length",
801 ntohl (mp->l2_address_length));
802 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
803 sizeof (mp->l2_address));
804 vat_json_object_add_string_copy (node, "interface_name",
806 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
807 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
808 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
809 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
810 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
811 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
812 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
813 vat_json_object_add_uint (node, "sub_number_of_tags",
814 mp->sub_number_of_tags);
815 vat_json_object_add_uint (node, "sub_outer_vlan_id",
816 ntohs (mp->sub_outer_vlan_id));
817 vat_json_object_add_uint (node, "sub_inner_vlan_id",
818 ntohs (mp->sub_inner_vlan_id));
819 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
820 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
821 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
822 mp->sub_outer_vlan_id_any);
823 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
824 mp->sub_inner_vlan_id_any);
825 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
826 vat_json_object_add_uint (node, "vtr_push_dot1q",
827 ntohl (mp->vtr_push_dot1q));
828 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
829 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
832 static void vl_api_sw_interface_set_flags_t_handler
833 (vl_api_sw_interface_set_flags_t * mp)
835 vat_main_t *vam = &vat_main;
836 if (vam->interface_event_display)
837 errmsg ("interface flags: sw_if_index %d %s %s",
838 ntohl (mp->sw_if_index),
839 mp->admin_up_down ? "admin-up" : "admin-down",
840 mp->link_up_down ? "link-up" : "link-down");
843 static void vl_api_sw_interface_set_flags_t_handler_json
844 (vl_api_sw_interface_set_flags_t * mp)
846 /* JSON output not supported */
850 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
852 vat_main_t *vam = &vat_main;
853 i32 retval = ntohl (mp->retval);
855 vam->retval = retval;
856 vam->shmem_result = (u8 *) mp->reply_in_shmem;
857 vam->result_ready = 1;
861 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
863 vat_main_t *vam = &vat_main;
864 vat_json_node_t node;
865 api_main_t *am = &api_main;
869 vat_json_init_object (&node);
870 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
871 vat_json_object_add_uint (&node, "reply_in_shmem",
872 ntohl (mp->reply_in_shmem));
873 /* Toss the shared-memory original... */
874 pthread_mutex_lock (&am->vlib_rp->mutex);
875 oldheap = svm_push_data_heap (am->vlib_rp);
877 reply = (u8 *) (mp->reply_in_shmem);
880 svm_pop_heap (oldheap);
881 pthread_mutex_unlock (&am->vlib_rp->mutex);
883 vat_json_print (vam->ofp, &node);
884 vat_json_free (&node);
886 vam->retval = ntohl (mp->retval);
887 vam->result_ready = 1;
891 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
893 vat_main_t *vam = &vat_main;
894 i32 retval = ntohl (mp->retval);
896 vam->retval = retval;
897 vam->cmd_reply = mp->reply;
898 vam->result_ready = 1;
902 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
904 vat_main_t *vam = &vat_main;
905 vat_json_node_t node;
907 vat_json_init_object (&node);
908 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
909 vat_json_object_add_string_copy (&node, "reply", mp->reply);
911 vat_json_print (vam->ofp, &node);
912 vat_json_free (&node);
914 vam->retval = ntohl (mp->retval);
915 vam->result_ready = 1;
918 static void vl_api_classify_add_del_table_reply_t_handler
919 (vl_api_classify_add_del_table_reply_t * mp)
921 vat_main_t *vam = &vat_main;
922 i32 retval = ntohl (mp->retval);
925 vam->async_errors += (retval < 0);
929 vam->retval = retval;
931 ((mp->new_table_index != 0xFFFFFFFF) ||
932 (mp->skip_n_vectors != 0xFFFFFFFF) ||
933 (mp->match_n_vectors != 0xFFFFFFFF)))
935 * Note: this is just barely thread-safe, depends on
936 * the main thread spinning waiting for an answer...
938 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
939 ntohl (mp->new_table_index),
940 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
941 vam->result_ready = 1;
945 static void vl_api_classify_add_del_table_reply_t_handler_json
946 (vl_api_classify_add_del_table_reply_t * mp)
948 vat_main_t *vam = &vat_main;
949 vat_json_node_t node;
951 vat_json_init_object (&node);
952 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
953 vat_json_object_add_uint (&node, "new_table_index",
954 ntohl (mp->new_table_index));
955 vat_json_object_add_uint (&node, "skip_n_vectors",
956 ntohl (mp->skip_n_vectors));
957 vat_json_object_add_uint (&node, "match_n_vectors",
958 ntohl (mp->match_n_vectors));
960 vat_json_print (vam->ofp, &node);
961 vat_json_free (&node);
963 vam->retval = ntohl (mp->retval);
964 vam->result_ready = 1;
967 static void vl_api_get_node_index_reply_t_handler
968 (vl_api_get_node_index_reply_t * mp)
970 vat_main_t *vam = &vat_main;
971 i32 retval = ntohl (mp->retval);
974 vam->async_errors += (retval < 0);
978 vam->retval = retval;
980 errmsg ("node index %d", ntohl (mp->node_index));
981 vam->result_ready = 1;
985 static void vl_api_get_node_index_reply_t_handler_json
986 (vl_api_get_node_index_reply_t * mp)
988 vat_main_t *vam = &vat_main;
989 vat_json_node_t node;
991 vat_json_init_object (&node);
992 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
993 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
995 vat_json_print (vam->ofp, &node);
996 vat_json_free (&node);
998 vam->retval = ntohl (mp->retval);
999 vam->result_ready = 1;
1002 static void vl_api_get_next_index_reply_t_handler
1003 (vl_api_get_next_index_reply_t * mp)
1005 vat_main_t *vam = &vat_main;
1006 i32 retval = ntohl (mp->retval);
1007 if (vam->async_mode)
1009 vam->async_errors += (retval < 0);
1013 vam->retval = retval;
1015 errmsg ("next node index %d", ntohl (mp->next_index));
1016 vam->result_ready = 1;
1020 static void vl_api_get_next_index_reply_t_handler_json
1021 (vl_api_get_next_index_reply_t * mp)
1023 vat_main_t *vam = &vat_main;
1024 vat_json_node_t node;
1026 vat_json_init_object (&node);
1027 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1028 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1030 vat_json_print (vam->ofp, &node);
1031 vat_json_free (&node);
1033 vam->retval = ntohl (mp->retval);
1034 vam->result_ready = 1;
1037 static void vl_api_add_node_next_reply_t_handler
1038 (vl_api_add_node_next_reply_t * mp)
1040 vat_main_t *vam = &vat_main;
1041 i32 retval = ntohl (mp->retval);
1042 if (vam->async_mode)
1044 vam->async_errors += (retval < 0);
1048 vam->retval = retval;
1050 errmsg ("next index %d", ntohl (mp->next_index));
1051 vam->result_ready = 1;
1055 static void vl_api_add_node_next_reply_t_handler_json
1056 (vl_api_add_node_next_reply_t * mp)
1058 vat_main_t *vam = &vat_main;
1059 vat_json_node_t node;
1061 vat_json_init_object (&node);
1062 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1063 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1065 vat_json_print (vam->ofp, &node);
1066 vat_json_free (&node);
1068 vam->retval = ntohl (mp->retval);
1069 vam->result_ready = 1;
1072 static void vl_api_show_version_reply_t_handler
1073 (vl_api_show_version_reply_t * mp)
1075 vat_main_t *vam = &vat_main;
1076 i32 retval = ntohl (mp->retval);
1080 errmsg (" program: %s", mp->program);
1081 errmsg (" version: %s", mp->version);
1082 errmsg (" build date: %s", mp->build_date);
1083 errmsg ("build directory: %s", mp->build_directory);
1085 vam->retval = retval;
1086 vam->result_ready = 1;
1089 static void vl_api_show_version_reply_t_handler_json
1090 (vl_api_show_version_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_string_copy (&node, "program", mp->program);
1098 vat_json_object_add_string_copy (&node, "version", mp->version);
1099 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1100 vat_json_object_add_string_copy (&node, "build_directory",
1101 mp->build_directory);
1103 vat_json_print (vam->ofp, &node);
1104 vat_json_free (&node);
1106 vam->retval = ntohl (mp->retval);
1107 vam->result_ready = 1;
1111 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1113 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1114 mp->mac_ip ? "mac/ip binding" : "address resolution",
1115 format_ip4_address, &mp->address,
1116 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1120 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1122 /* JSON output not supported */
1126 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1128 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1129 mp->mac_ip ? "mac/ip binding" : "address resolution",
1130 format_ip6_address, mp->address,
1131 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1135 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1137 /* JSON output not supported */
1141 * Special-case: build the bridge domain table, maintain
1142 * the next bd id vbl.
1144 static void vl_api_bridge_domain_details_t_handler
1145 (vl_api_bridge_domain_details_t * mp)
1147 vat_main_t *vam = &vat_main;
1148 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1150 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1151 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1153 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1154 ntohl (mp->bd_id), mp->learn, mp->forward,
1155 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1158 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1161 static void vl_api_bridge_domain_details_t_handler_json
1162 (vl_api_bridge_domain_details_t * mp)
1164 vat_main_t *vam = &vat_main;
1165 vat_json_node_t *node, *array = NULL;
1167 if (VAT_JSON_ARRAY != vam->json_tree.type)
1169 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1170 vat_json_init_array (&vam->json_tree);
1172 node = vat_json_array_add (&vam->json_tree);
1174 vat_json_init_object (node);
1175 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1176 vat_json_object_add_uint (node, "flood", mp->flood);
1177 vat_json_object_add_uint (node, "forward", mp->forward);
1178 vat_json_object_add_uint (node, "learn", mp->learn);
1179 vat_json_object_add_uint (node, "bvi_sw_if_index",
1180 ntohl (mp->bvi_sw_if_index));
1181 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1182 array = vat_json_object_add (node, "sw_if");
1183 vat_json_init_array (array);
1187 * Special-case: build the bridge domain sw if table.
1189 static void vl_api_bridge_domain_sw_if_details_t_handler
1190 (vl_api_bridge_domain_sw_if_details_t * mp)
1192 vat_main_t *vam = &vat_main;
1197 sw_if_index = ntohl (mp->sw_if_index);
1199 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1201 if ((u32) p->value[0] == sw_if_index)
1203 sw_if_name = (u8 *)(p->key);
1209 print (vam->ofp, "%7d %3d %s", sw_if_index,
1210 mp->shg, sw_if_name ? (char *) sw_if_name :
1211 "sw_if_index not found!");
1214 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1215 (vl_api_bridge_domain_sw_if_details_t * mp)
1217 vat_main_t *vam = &vat_main;
1218 vat_json_node_t *node = NULL;
1219 uword last_index = 0;
1221 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1222 ASSERT (vec_len (vam->json_tree.array) >= 1);
1223 last_index = vec_len (vam->json_tree.array) - 1;
1224 node = &vam->json_tree.array[last_index];
1225 node = vat_json_object_get_element (node, "sw_if");
1226 ASSERT (NULL != node);
1227 node = vat_json_array_add (node);
1229 vat_json_init_object (node);
1230 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1231 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1232 vat_json_object_add_uint (node, "shg", mp->shg);
1235 static void vl_api_control_ping_reply_t_handler
1236 (vl_api_control_ping_reply_t * mp)
1238 vat_main_t *vam = &vat_main;
1239 i32 retval = ntohl (mp->retval);
1240 if (vam->async_mode)
1242 vam->async_errors += (retval < 0);
1246 vam->retval = retval;
1247 vam->result_ready = 1;
1251 static void vl_api_control_ping_reply_t_handler_json
1252 (vl_api_control_ping_reply_t * mp)
1254 vat_main_t *vam = &vat_main;
1255 i32 retval = ntohl (mp->retval);
1257 if (VAT_JSON_NONE != vam->json_tree.type)
1259 vat_json_print (vam->ofp, &vam->json_tree);
1260 vat_json_free (&vam->json_tree);
1261 vam->json_tree.type = VAT_JSON_NONE;
1266 vat_json_init_array (&vam->json_tree);
1267 vat_json_print (vam->ofp, &vam->json_tree);
1268 vam->json_tree.type = VAT_JSON_NONE;
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1276 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 i32 retval = ntohl (mp->retval);
1280 if (vam->async_mode)
1282 vam->async_errors += (retval < 0);
1286 vam->retval = retval;
1287 vam->result_ready = 1;
1291 static void vl_api_l2_flags_reply_t_handler_json
1292 (vl_api_l2_flags_reply_t * mp)
1294 vat_main_t *vam = &vat_main;
1295 vat_json_node_t node;
1297 vat_json_init_object (&node);
1298 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1299 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1300 ntohl (mp->resulting_feature_bitmap));
1302 vat_json_print (vam->ofp, &node);
1303 vat_json_free (&node);
1305 vam->retval = ntohl (mp->retval);
1306 vam->result_ready = 1;
1309 static void vl_api_bridge_flags_reply_t_handler
1310 (vl_api_bridge_flags_reply_t * mp)
1312 vat_main_t *vam = &vat_main;
1313 i32 retval = ntohl (mp->retval);
1314 if (vam->async_mode)
1316 vam->async_errors += (retval < 0);
1320 vam->retval = retval;
1321 vam->result_ready = 1;
1325 static void vl_api_bridge_flags_reply_t_handler_json
1326 (vl_api_bridge_flags_reply_t * mp)
1328 vat_main_t *vam = &vat_main;
1329 vat_json_node_t node;
1331 vat_json_init_object (&node);
1332 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1333 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1334 ntohl (mp->resulting_feature_bitmap));
1336 vat_json_print (vam->ofp, &node);
1337 vat_json_free (&node);
1339 vam->retval = ntohl (mp->retval);
1340 vam->result_ready = 1;
1343 static void vl_api_tap_connect_reply_t_handler
1344 (vl_api_tap_connect_reply_t * mp)
1346 vat_main_t *vam = &vat_main;
1347 i32 retval = ntohl (mp->retval);
1348 if (vam->async_mode)
1350 vam->async_errors += (retval < 0);
1354 vam->retval = retval;
1355 vam->sw_if_index = ntohl (mp->sw_if_index);
1356 vam->result_ready = 1;
1361 static void vl_api_tap_connect_reply_t_handler_json
1362 (vl_api_tap_connect_reply_t * mp)
1364 vat_main_t *vam = &vat_main;
1365 vat_json_node_t node;
1367 vat_json_init_object (&node);
1368 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1369 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1371 vat_json_print (vam->ofp, &node);
1372 vat_json_free (&node);
1374 vam->retval = ntohl (mp->retval);
1375 vam->result_ready = 1;
1380 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1382 vat_main_t *vam = &vat_main;
1383 i32 retval = ntohl (mp->retval);
1384 if (vam->async_mode)
1386 vam->async_errors += (retval < 0);
1390 vam->retval = retval;
1391 vam->sw_if_index = ntohl (mp->sw_if_index);
1392 vam->result_ready = 1;
1396 static void vl_api_tap_modify_reply_t_handler_json
1397 (vl_api_tap_modify_reply_t * mp)
1399 vat_main_t *vam = &vat_main;
1400 vat_json_node_t node;
1402 vat_json_init_object (&node);
1403 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1404 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1406 vat_json_print (vam->ofp, &node);
1407 vat_json_free (&node);
1409 vam->retval = ntohl (mp->retval);
1410 vam->result_ready = 1;
1414 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1416 vat_main_t *vam = &vat_main;
1417 i32 retval = ntohl (mp->retval);
1418 if (vam->async_mode)
1420 vam->async_errors += (retval < 0);
1424 vam->retval = retval;
1425 vam->result_ready = 1;
1429 static void vl_api_tap_delete_reply_t_handler_json
1430 (vl_api_tap_delete_reply_t * mp)
1432 vat_main_t *vam = &vat_main;
1433 vat_json_node_t node;
1435 vat_json_init_object (&node);
1436 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1438 vat_json_print (vam->ofp, &node);
1439 vat_json_free (&node);
1441 vam->retval = ntohl (mp->retval);
1442 vam->result_ready = 1;
1445 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1446 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1448 vat_main_t *vam = &vat_main;
1449 i32 retval = ntohl (mp->retval);
1450 if (vam->async_mode)
1452 vam->async_errors += (retval < 0);
1456 vam->retval = retval;
1457 vam->result_ready = 1;
1461 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1462 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1464 vat_main_t *vam = &vat_main;
1465 vat_json_node_t node;
1467 vat_json_init_object (&node);
1468 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1469 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1470 ntohl (mp->sw_if_index));
1472 vat_json_print (vam->ofp, &node);
1473 vat_json_free (&node);
1475 vam->retval = ntohl (mp->retval);
1476 vam->result_ready = 1;
1479 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1480 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->sw_if_index = ntohl (mp->sw_if_index);
1492 vam->result_ready = 1;
1496 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1497 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 vat_json_node_t node;
1502 vat_json_init_object (&node);
1503 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1504 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1506 vat_json_print (vam->ofp, &node);
1507 vat_json_free (&node);
1509 vam->retval = ntohl (mp->retval);
1510 vam->result_ready = 1;
1514 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1515 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1517 vat_main_t *vam = &vat_main;
1518 i32 retval = ntohl (mp->retval);
1519 if (vam->async_mode)
1521 vam->async_errors += (retval < 0);
1525 vam->retval = retval;
1526 vam->result_ready = 1;
1530 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1531 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1533 vat_main_t *vam = &vat_main;
1534 vat_json_node_t node;
1536 vat_json_init_object (&node);
1537 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1538 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1540 vat_json_print (vam->ofp, &node);
1541 vat_json_free (&node);
1543 vam->retval = ntohl (mp->retval);
1544 vam->result_ready = 1;
1547 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1548 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1550 vat_main_t *vam = &vat_main;
1551 i32 retval = ntohl (mp->retval);
1552 if (vam->async_mode)
1554 vam->async_errors += (retval < 0);
1558 vam->retval = retval;
1559 vam->sw_if_index = ntohl (mp->sw_if_index);
1560 vam->result_ready = 1;
1564 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1565 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1567 vat_main_t *vam = &vat_main;
1568 vat_json_node_t node;
1570 vat_json_init_object (&node);
1571 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1572 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1574 vat_json_print (vam->ofp, &node);
1575 vat_json_free (&node);
1577 vam->retval = ntohl (mp->retval);
1578 vam->result_ready = 1;
1581 static void vl_api_gre_add_del_tunnel_reply_t_handler
1582 (vl_api_gre_add_del_tunnel_reply_t * mp)
1584 vat_main_t *vam = &vat_main;
1585 i32 retval = ntohl (mp->retval);
1586 if (vam->async_mode)
1588 vam->async_errors += (retval < 0);
1592 vam->retval = retval;
1593 vam->sw_if_index = ntohl (mp->sw_if_index);
1594 vam->result_ready = 1;
1598 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1599 (vl_api_gre_add_del_tunnel_reply_t * mp)
1601 vat_main_t *vam = &vat_main;
1602 vat_json_node_t node;
1604 vat_json_init_object (&node);
1605 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1606 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1608 vat_json_print (vam->ofp, &node);
1609 vat_json_free (&node);
1611 vam->retval = ntohl (mp->retval);
1612 vam->result_ready = 1;
1615 static void vl_api_create_vhost_user_if_reply_t_handler
1616 (vl_api_create_vhost_user_if_reply_t * mp)
1618 vat_main_t *vam = &vat_main;
1619 i32 retval = ntohl (mp->retval);
1620 if (vam->async_mode)
1622 vam->async_errors += (retval < 0);
1626 vam->retval = retval;
1627 vam->sw_if_index = ntohl (mp->sw_if_index);
1628 vam->result_ready = 1;
1632 static void vl_api_create_vhost_user_if_reply_t_handler_json
1633 (vl_api_create_vhost_user_if_reply_t * mp)
1635 vat_main_t *vam = &vat_main;
1636 vat_json_node_t node;
1638 vat_json_init_object (&node);
1639 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1640 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1642 vat_json_print (vam->ofp, &node);
1643 vat_json_free (&node);
1645 vam->retval = ntohl (mp->retval);
1646 vam->result_ready = 1;
1649 static void vl_api_ip_address_details_t_handler
1650 (vl_api_ip_address_details_t * mp)
1652 vat_main_t *vam = &vat_main;
1653 static ip_address_details_t empty_ip_address_details = { {0} };
1654 ip_address_details_t *address = NULL;
1655 ip_details_t *current_ip_details = NULL;
1656 ip_details_t *details = NULL;
1658 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1660 if (!details || vam->current_sw_if_index >= vec_len (details)
1661 || !details[vam->current_sw_if_index].present)
1663 errmsg ("ip address details arrived but not stored");
1664 errmsg ("ip_dump should be called first");
1668 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1670 #define addresses (current_ip_details->addr)
1672 vec_validate_init_empty (addresses, vec_len (addresses),
1673 empty_ip_address_details);
1675 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1677 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1678 address->prefix_length = mp->prefix_length;
1682 static void vl_api_ip_address_details_t_handler_json
1683 (vl_api_ip_address_details_t * mp)
1685 vat_main_t *vam = &vat_main;
1686 vat_json_node_t *node = NULL;
1687 struct in6_addr ip6;
1690 if (VAT_JSON_ARRAY != vam->json_tree.type)
1692 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1693 vat_json_init_array (&vam->json_tree);
1695 node = vat_json_array_add (&vam->json_tree);
1697 vat_json_init_object (node);
1700 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1701 vat_json_object_add_ip6 (node, "ip", ip6);
1705 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1706 vat_json_object_add_ip4 (node, "ip", ip4);
1708 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1712 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1714 vat_main_t *vam = &vat_main;
1715 static ip_details_t empty_ip_details = { 0 };
1716 ip_details_t *ip = NULL;
1717 u32 sw_if_index = ~0;
1719 sw_if_index = ntohl (mp->sw_if_index);
1721 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1722 sw_if_index, empty_ip_details);
1724 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1731 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1733 vat_main_t *vam = &vat_main;
1735 if (VAT_JSON_ARRAY != vam->json_tree.type)
1737 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1738 vat_json_init_array (&vam->json_tree);
1740 vat_json_array_add_uint (&vam->json_tree,
1741 clib_net_to_host_u32 (mp->sw_if_index));
1744 static void vl_api_map_domain_details_t_handler_json
1745 (vl_api_map_domain_details_t * mp)
1747 vat_json_node_t *node = NULL;
1748 vat_main_t *vam = &vat_main;
1749 struct in6_addr ip6;
1752 if (VAT_JSON_ARRAY != vam->json_tree.type)
1754 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1755 vat_json_init_array (&vam->json_tree);
1758 node = vat_json_array_add (&vam->json_tree);
1759 vat_json_init_object (node);
1761 vat_json_object_add_uint (node, "domain_index",
1762 clib_net_to_host_u32 (mp->domain_index));
1763 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1764 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1765 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1766 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1767 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1768 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1769 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1770 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1771 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1772 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1773 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1774 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1775 vat_json_object_add_uint (node, "flags", mp->flags);
1776 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1777 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1780 static void vl_api_map_domain_details_t_handler
1781 (vl_api_map_domain_details_t * mp)
1783 vat_main_t *vam = &vat_main;
1785 if (mp->is_translation)
1788 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1789 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1790 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1791 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1792 clib_net_to_host_u32 (mp->domain_index));
1797 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1798 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1799 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1800 format_ip6_address, mp->ip6_src,
1801 clib_net_to_host_u32 (mp->domain_index));
1803 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1804 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1805 mp->is_translation ? "map-t" : "");
1808 static void vl_api_map_rule_details_t_handler_json
1809 (vl_api_map_rule_details_t * mp)
1811 struct in6_addr ip6;
1812 vat_json_node_t *node = NULL;
1813 vat_main_t *vam = &vat_main;
1815 if (VAT_JSON_ARRAY != vam->json_tree.type)
1817 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1818 vat_json_init_array (&vam->json_tree);
1821 node = vat_json_array_add (&vam->json_tree);
1822 vat_json_init_object (node);
1824 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1825 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1826 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1830 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1832 vat_main_t *vam = &vat_main;
1833 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1834 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1838 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1840 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1841 "router_addr %U host_mac %U",
1842 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1843 format_ip4_address, &mp->host_address,
1844 format_ip4_address, &mp->router_address,
1845 format_ethernet_address, mp->host_mac);
1848 static void vl_api_dhcp_compl_event_t_handler_json
1849 (vl_api_dhcp_compl_event_t * mp)
1851 /* JSON output not supported */
1855 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1858 vat_main_t *vam = &vat_main;
1859 static u64 default_counter = 0;
1861 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1863 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1864 sw_if_index, default_counter);
1865 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1869 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1870 interface_counter_t counter)
1872 vat_main_t *vam = &vat_main;
1873 static interface_counter_t default_counter = { 0, };
1875 vec_validate_init_empty (vam->combined_interface_counters,
1876 vnet_counter_type, NULL);
1877 vec_validate_init_empty (vam->combined_interface_counters
1878 [vnet_counter_type], sw_if_index, default_counter);
1879 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1882 static void vl_api_vnet_interface_counters_t_handler
1883 (vl_api_vnet_interface_counters_t * mp)
1888 static void vl_api_vnet_interface_counters_t_handler_json
1889 (vl_api_vnet_interface_counters_t * mp)
1891 interface_counter_t counter;
1896 u32 first_sw_if_index;
1899 count = ntohl (mp->count);
1900 first_sw_if_index = ntohl (mp->first_sw_if_index);
1902 if (!mp->is_combined)
1904 v_packets = (u64 *) & mp->data;
1905 for (i = 0; i < count; i++)
1908 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1909 set_simple_interface_counter (mp->vnet_counter_type,
1910 first_sw_if_index + i, packets);
1916 v = (vlib_counter_t *) & mp->data;
1917 for (i = 0; i < count; i++)
1920 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1922 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1923 set_combined_interface_counter (mp->vnet_counter_type,
1924 first_sw_if_index + i, counter);
1931 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1933 vat_main_t *vam = &vat_main;
1936 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1938 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1947 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1949 vat_main_t *vam = &vat_main;
1952 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1954 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
1962 static void vl_api_vnet_ip4_fib_counters_t_handler
1963 (vl_api_vnet_ip4_fib_counters_t * mp)
1968 static void vl_api_vnet_ip4_fib_counters_t_handler_json
1969 (vl_api_vnet_ip4_fib_counters_t * mp)
1971 vat_main_t *vam = &vat_main;
1972 vl_api_ip4_fib_counter_t *v;
1973 ip4_fib_counter_t *counter;
1980 vrf_id = ntohl (mp->vrf_id);
1981 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
1982 if (~0 == vrf_index)
1984 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
1985 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
1986 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
1987 vec_validate (vam->ip4_fib_counters, vrf_index);
1988 vam->ip4_fib_counters[vrf_index] = NULL;
1991 vec_free (vam->ip4_fib_counters[vrf_index]);
1992 v = (vl_api_ip4_fib_counter_t *) & mp->c;
1993 count = ntohl (mp->count);
1994 for (i = 0; i < count; i++)
1996 vec_validate (vam->ip4_fib_counters[vrf_index], i);
1997 counter = &vam->ip4_fib_counters[vrf_index][i];
1998 clib_memcpy (&ip4, &v->address, sizeof (ip4));
1999 counter->address = ip4;
2000 counter->address_length = v->address_length;
2001 counter->packets = clib_net_to_host_u64 (v->packets);
2002 counter->bytes = clib_net_to_host_u64 (v->bytes);
2007 static void vl_api_vnet_ip6_fib_counters_t_handler
2008 (vl_api_vnet_ip6_fib_counters_t * mp)
2013 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2014 (vl_api_vnet_ip6_fib_counters_t * mp)
2016 vat_main_t *vam = &vat_main;
2017 vl_api_ip6_fib_counter_t *v;
2018 ip6_fib_counter_t *counter;
2019 struct in6_addr ip6;
2025 vrf_id = ntohl (mp->vrf_id);
2026 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2027 if (~0 == vrf_index)
2029 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2030 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2031 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2032 vec_validate (vam->ip6_fib_counters, vrf_index);
2033 vam->ip6_fib_counters[vrf_index] = NULL;
2036 vec_free (vam->ip6_fib_counters[vrf_index]);
2037 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2038 count = ntohl (mp->count);
2039 for (i = 0; i < count; i++)
2041 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2042 counter = &vam->ip6_fib_counters[vrf_index][i];
2043 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2044 counter->address = ip6;
2045 counter->address_length = v->address_length;
2046 counter->packets = clib_net_to_host_u64 (v->packets);
2047 counter->bytes = clib_net_to_host_u64 (v->bytes);
2052 static void vl_api_get_first_msg_id_reply_t_handler
2053 (vl_api_get_first_msg_id_reply_t * mp)
2055 vat_main_t *vam = &vat_main;
2056 i32 retval = ntohl (mp->retval);
2058 if (vam->async_mode)
2060 vam->async_errors += (retval < 0);
2064 vam->retval = retval;
2065 vam->result_ready = 1;
2069 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2073 static void vl_api_get_first_msg_id_reply_t_handler_json
2074 (vl_api_get_first_msg_id_reply_t * mp)
2076 vat_main_t *vam = &vat_main;
2077 vat_json_node_t node;
2079 vat_json_init_object (&node);
2080 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2081 vat_json_object_add_uint (&node, "first_msg_id",
2082 (uint) ntohs (mp->first_msg_id));
2084 vat_json_print (vam->ofp, &node);
2085 vat_json_free (&node);
2087 vam->retval = ntohl (mp->retval);
2088 vam->result_ready = 1;
2091 static void vl_api_get_node_graph_reply_t_handler
2092 (vl_api_get_node_graph_reply_t * mp)
2094 vat_main_t *vam = &vat_main;
2095 api_main_t *am = &api_main;
2096 i32 retval = ntohl (mp->retval);
2097 u8 *pvt_copy, *reply;
2102 if (vam->async_mode)
2104 vam->async_errors += (retval < 0);
2108 vam->retval = retval;
2109 vam->result_ready = 1;
2112 /* "Should never happen..." */
2116 reply = (u8 *) (mp->reply_in_shmem);
2117 pvt_copy = vec_dup (reply);
2119 /* Toss the shared-memory original... */
2120 pthread_mutex_lock (&am->vlib_rp->mutex);
2121 oldheap = svm_push_data_heap (am->vlib_rp);
2125 svm_pop_heap (oldheap);
2126 pthread_mutex_unlock (&am->vlib_rp->mutex);
2128 if (vam->graph_nodes)
2130 hash_free (vam->graph_node_index_by_name);
2132 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2134 node = vam->graph_nodes[i];
2135 vec_free (node->name);
2136 vec_free (node->next_nodes);
2139 vec_free (vam->graph_nodes);
2142 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2143 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2144 vec_free (pvt_copy);
2146 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2148 node = vam->graph_nodes[i];
2149 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2153 static void vl_api_get_node_graph_reply_t_handler_json
2154 (vl_api_get_node_graph_reply_t * mp)
2156 vat_main_t *vam = &vat_main;
2157 api_main_t *am = &api_main;
2159 vat_json_node_t node;
2162 /* $$$$ make this real? */
2163 vat_json_init_object (&node);
2164 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2165 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2167 reply = (u8 *) (mp->reply_in_shmem);
2169 /* Toss the shared-memory original... */
2170 pthread_mutex_lock (&am->vlib_rp->mutex);
2171 oldheap = svm_push_data_heap (am->vlib_rp);
2175 svm_pop_heap (oldheap);
2176 pthread_mutex_unlock (&am->vlib_rp->mutex);
2178 vat_json_print (vam->ofp, &node);
2179 vat_json_free (&node);
2181 vam->retval = ntohl (mp->retval);
2182 vam->result_ready = 1;
2186 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2188 vat_main_t *vam = &vat_main;
2193 s = format (s, "%=16d%=16d%=16d",
2194 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2198 s = format (s, "%=16U%=16d%=16d",
2199 mp->is_ipv6 ? format_ip6_address :
2201 mp->ip_address, mp->priority, mp->weight);
2204 print (vam->ofp, "%v", s);
2209 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2212 vat_main_t *vam = &vat_main;
2213 vat_json_node_t *node = NULL;
2214 struct in6_addr ip6;
2217 if (VAT_JSON_ARRAY != vam->json_tree.type)
2219 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2220 vat_json_init_array (&vam->json_tree);
2222 node = vat_json_array_add (&vam->json_tree);
2223 vat_json_init_object (node);
2225 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2226 vat_json_object_add_uint (node, "priority", mp->priority);
2227 vat_json_object_add_uint (node, "weight", mp->weight);
2230 vat_json_object_add_uint (node, "sw_if_index",
2231 clib_net_to_host_u32 (mp->sw_if_index));
2236 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2237 vat_json_object_add_ip6 (node, "address", ip6);
2241 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2242 vat_json_object_add_ip4 (node, "address", ip4);
2248 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2251 vat_main_t *vam = &vat_main;
2254 ls_name = format (0, "%s", mp->ls_name);
2256 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2262 vl_api_lisp_locator_set_details_t_handler_json
2263 (vl_api_lisp_locator_set_details_t * mp)
2265 vat_main_t *vam = &vat_main;
2266 vat_json_node_t *node = 0;
2269 ls_name = format (0, "%s", mp->ls_name);
2270 vec_add1 (ls_name, 0);
2272 if (VAT_JSON_ARRAY != vam->json_tree.type)
2274 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2275 vat_json_init_array (&vam->json_tree);
2277 node = vat_json_array_add (&vam->json_tree);
2279 vat_json_init_object (node);
2280 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2281 vat_json_object_add_uint (node, "ls_index",
2282 clib_net_to_host_u32 (mp->ls_index));
2287 format_lisp_flat_eid (u8 * s, va_list * args)
2289 u32 type = va_arg (*args, u32);
2290 u8 *eid = va_arg (*args, u8 *);
2291 u32 eid_len = va_arg (*args, u32);
2296 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2298 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2300 return format (s, "%U", format_ethernet_address, eid);
2306 format_lisp_eid_vat (u8 * s, va_list * args)
2308 u32 type = va_arg (*args, u32);
2309 u8 *eid = va_arg (*args, u8 *);
2310 u32 eid_len = va_arg (*args, u32);
2311 u8 *seid = va_arg (*args, u8 *);
2312 u32 seid_len = va_arg (*args, u32);
2313 u32 is_src_dst = va_arg (*args, u32);
2316 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2318 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2324 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2326 vat_main_t *vam = &vat_main;
2327 u8 *s = 0, *eid = 0;
2329 if (~0 == mp->locator_set_index)
2330 s = format (0, "action: %d", mp->action);
2332 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2334 eid = format (0, "%U", format_lisp_eid_vat,
2338 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2341 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2342 clib_net_to_host_u32 (mp->vni),
2344 mp->is_local ? "local" : "remote",
2345 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2346 clib_net_to_host_u16 (mp->key_id), mp->key);
2353 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2356 vat_main_t *vam = &vat_main;
2357 vat_json_node_t *node = 0;
2360 if (VAT_JSON_ARRAY != vam->json_tree.type)
2362 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2363 vat_json_init_array (&vam->json_tree);
2365 node = vat_json_array_add (&vam->json_tree);
2367 vat_json_init_object (node);
2368 if (~0 == mp->locator_set_index)
2369 vat_json_object_add_uint (node, "action", mp->action);
2371 vat_json_object_add_uint (node, "locator_set_index",
2372 clib_net_to_host_u32 (mp->locator_set_index));
2374 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2375 eid = format (0, "%U", format_lisp_eid_vat,
2379 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2381 vat_json_object_add_string_copy (node, "eid", eid);
2382 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2383 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2384 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2388 vat_json_object_add_uint (node, "key_id",
2389 clib_net_to_host_u16 (mp->key_id));
2390 vat_json_object_add_string_copy (node, "key", mp->key);
2396 vl_api_lisp_eid_table_map_details_t_handler
2397 (vl_api_lisp_eid_table_map_details_t * mp)
2399 vat_main_t *vam = &vat_main;
2401 u8 *line = format (0, "%=10d%=10d",
2402 clib_net_to_host_u32 (mp->vni),
2403 clib_net_to_host_u32 (mp->dp_table));
2404 print (vam->ofp, "%v", line);
2409 vl_api_lisp_eid_table_map_details_t_handler_json
2410 (vl_api_lisp_eid_table_map_details_t * mp)
2412 vat_main_t *vam = &vat_main;
2413 vat_json_node_t *node = NULL;
2415 if (VAT_JSON_ARRAY != vam->json_tree.type)
2417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2418 vat_json_init_array (&vam->json_tree);
2420 node = vat_json_array_add (&vam->json_tree);
2421 vat_json_init_object (node);
2422 vat_json_object_add_uint (node, "dp_table",
2423 clib_net_to_host_u32 (mp->dp_table));
2424 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2428 vl_api_lisp_eid_table_vni_details_t_handler
2429 (vl_api_lisp_eid_table_vni_details_t * mp)
2431 vat_main_t *vam = &vat_main;
2433 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2434 print (vam->ofp, "%v", line);
2439 vl_api_lisp_eid_table_vni_details_t_handler_json
2440 (vl_api_lisp_eid_table_vni_details_t * mp)
2442 vat_main_t *vam = &vat_main;
2443 vat_json_node_t *node = NULL;
2445 if (VAT_JSON_ARRAY != vam->json_tree.type)
2447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2448 vat_json_init_array (&vam->json_tree);
2450 node = vat_json_array_add (&vam->json_tree);
2451 vat_json_init_object (node);
2452 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2456 format_decap_next (u8 * s, va_list * args)
2458 u32 next_index = va_arg (*args, u32);
2462 case LISP_GPE_INPUT_NEXT_DROP:
2463 return format (s, "drop");
2464 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2465 return format (s, "ip4");
2466 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2467 return format (s, "ip6");
2469 return format (s, "unknown %d", next_index);
2475 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2478 vat_main_t *vam = &vat_main;
2480 u8 *flag_str = NULL;
2482 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2484 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2485 foreach_lisp_gpe_flag_bit;
2488 print (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2489 "%=16d%=16d%=16sd=16d%=16s%=16s",
2491 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2493 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2495 ntohl (mp->encap_fib_id),
2496 ntohl (mp->decap_fib_id),
2497 format_decap_next, ntohl (mp->dcap_next),
2499 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2505 vl_api_lisp_gpe_tunnel_details_t_handler_json
2506 (vl_api_lisp_gpe_tunnel_details_t * mp)
2508 vat_main_t *vam = &vat_main;
2509 vat_json_node_t *node = NULL;
2510 struct in6_addr ip6;
2514 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2516 if (VAT_JSON_ARRAY != vam->json_tree.type)
2518 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2519 vat_json_init_array (&vam->json_tree);
2521 node = vat_json_array_add (&vam->json_tree);
2523 vat_json_init_object (node);
2524 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2527 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2528 vat_json_object_add_ip6 (node, "source address", ip6);
2529 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2530 vat_json_object_add_ip6 (node, "destination address", ip6);
2534 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2535 vat_json_object_add_ip4 (node, "source address", ip4);
2536 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2537 vat_json_object_add_ip4 (node, "destination address", ip4);
2539 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2540 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2541 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2542 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2543 vat_json_object_add_uint (node, "flags", mp->flags);
2544 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2545 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2546 vat_json_object_add_uint (node, "res", mp->res);
2547 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2549 vec_free (next_decap_str);
2553 vl_api_show_lisp_map_register_state_reply_t_handler
2554 (vl_api_show_lisp_map_register_state_reply_t * mp)
2556 vat_main_t *vam = &vat_main;
2557 int retval = clib_net_to_host_u32 (mp->retval);
2559 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2561 vam->retval = retval;
2562 vam->result_ready = 1;
2566 vl_api_show_lisp_map_register_state_reply_t_handler_json
2567 (vl_api_show_lisp_map_register_state_reply_t * mp)
2569 vat_main_t *vam = &vat_main;
2570 vat_json_node_t _node, *node = &_node;
2571 int retval = clib_net_to_host_u32 (mp->retval);
2573 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2575 vat_json_init_object (node);
2576 vat_json_object_add_string_copy (node, "state", s);
2578 vat_json_print (vam->ofp, node);
2579 vat_json_free (node);
2581 vam->retval = retval;
2582 vam->result_ready = 1;
2587 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2588 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2590 vat_main_t *vam = &vat_main;
2591 int retval = clib_net_to_host_u32 (mp->retval);
2596 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2598 vam->retval = retval;
2599 vam->result_ready = 1;
2603 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2604 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2606 vat_main_t *vam = &vat_main;
2607 vat_json_node_t _node, *node = &_node;
2608 int retval = clib_net_to_host_u32 (mp->retval);
2610 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2611 vat_json_init_object (node);
2612 vat_json_object_add_string_copy (node, "state", s);
2614 vat_json_print (vam->ofp, node);
2615 vat_json_free (node);
2617 vam->retval = retval;
2618 vam->result_ready = 1;
2623 vl_api_lisp_adjacencies_get_reply_t_handler
2624 (vl_api_lisp_adjacencies_get_reply_t * mp)
2626 vat_main_t *vam = &vat_main;
2628 int retval = clib_net_to_host_u32 (mp->retval);
2629 vl_api_lisp_adjacency_t *a;
2634 n = clib_net_to_host_u32 (mp->count);
2636 for (i = 0; i < n; i++)
2638 a = &mp->adjacencies[i];
2639 print (vam->ofp, "%U %40U",
2640 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2641 format_lisp_flat_eid, a->eid_type, a->reid, 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 print (vam->ofp, "%=20U",
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 print (vam->ofp, "%=20U",
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 print (vam->ofp, "feature: %s\ngpe: %s",
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 print (vam->ofp, "%=20s", 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 print (vam->ofp, "map_request_mode: %U",
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 print (vam->ofp, "%-20s%-16s",
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 print (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",
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 print (vam->ofp, "classify table ids (%d) : ", count);
3193 for (i = 0; i < count; i++)
3195 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3196 print (vam->ofp, (i < count - 1) ? "," : "");
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 print (vam->ofp, "l2 table id : %d", table_id);
3236 print (vam->ofp, "l2 table id : No input ACL tables configured");
3237 table_id = ntohl (mp->ip4_table_id);
3239 print (vam->ofp, "ip4 table id : %d", table_id);
3241 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3242 table_id = ntohl (mp->ip6_table_id);
3244 print (vam->ofp, "ip6 table id : %d", table_id);
3246 print (vam->ofp, "ip6 table id : No input ACL tables configured");
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", 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 print (vam->ofp, "classify table info :");
3347 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3348 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3349 ntohl (mp->miss_next_index));
3350 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3351 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3352 ntohl (mp->match_n_vectors));
3353 print (vam->ofp, "mask: %U", 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 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3399 ntohl (mp->hit_next_index), ntohl (mp->advance),
3400 ntohl (mp->opaque_index));
3401 print (vam->ofp, "mask: %U", 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 print (vam->ofp, "%10d%20d", 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 print (vam->ofp, "%10d%20d", 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_as_if_client(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_as_if_client(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); \
3960 vat_suspend (vam->vlib_main, 1e-3); \
3965 /* W2: wait for results, with timeout */
3968 timeout = vat_time_now (vam) + 1.0; \
3970 while (vat_time_now (vam) < timeout) { \
3971 if (vam->result_ready == 1) { \
3973 return (vam->retval); \
3975 vat_suspend (vam->vlib_main, 1e-3); \
3987 #define STR_VTR_OP_CASE(op) \
3988 case L2_VTR_ ## op: \
3992 str_vtr_op (u32 vtr_op)
3996 STR_VTR_OP_CASE (DISABLED);
3997 STR_VTR_OP_CASE (PUSH_1);
3998 STR_VTR_OP_CASE (PUSH_2);
3999 STR_VTR_OP_CASE (POP_1);
4000 STR_VTR_OP_CASE (POP_2);
4001 STR_VTR_OP_CASE (TRANSLATE_1_1);
4002 STR_VTR_OP_CASE (TRANSLATE_1_2);
4003 STR_VTR_OP_CASE (TRANSLATE_2_1);
4004 STR_VTR_OP_CASE (TRANSLATE_2_2);
4011 dump_sub_interface_table (vat_main_t * vam)
4013 const sw_interface_subif_t *sub = NULL;
4015 if (vam->json_output)
4018 ("JSON output supported only for VPE API calls and dump_stats_table");
4023 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4024 "Interface", "sw_if_index",
4025 "sub id", "dot1ad", "tags", "outer id",
4026 "inner id", "exact", "default", "outer any", "inner any");
4028 vec_foreach (sub, vam->sw_if_subif_table)
4031 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4032 sub->interface_name,
4034 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4035 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4036 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4037 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4038 if (sub->vtr_op != L2_VTR_DISABLED)
4041 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4042 "tag1: %d tag2: %d ]",
4043 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4044 sub->vtr_tag1, sub->vtr_tag2);
4052 name_sort_cmp (void *a1, void *a2)
4054 name_sort_t *n1 = a1;
4055 name_sort_t *n2 = a2;
4057 return strcmp ((char *) n1->name, (char *) n2->name);
4061 dump_interface_table (vat_main_t * vam)
4064 name_sort_t *nses = 0, *ns;
4066 if (vam->json_output)
4069 ("JSON output supported only for VPE API calls and dump_stats_table");
4074 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4076 vec_add2 (nses, ns, 1);
4077 ns->name = (u8 *)(p->key);
4078 ns->value = (u32) p->value[0];
4082 vec_sort_with_function (nses, name_sort_cmp);
4084 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4085 vec_foreach (ns, nses)
4087 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4094 dump_ip_table (vat_main_t * vam, int is_ipv6)
4096 const ip_details_t *det = NULL;
4097 const ip_address_details_t *address = NULL;
4100 print (vam->ofp, "%-12s", "sw_if_index");
4102 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4109 print (vam->ofp, "%-12d", i);
4110 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4115 vec_foreach (address, det->addr)
4119 is_ipv6 ? format_ip6_address : format_ip4_address,
4120 address->ip, address->prefix_length);
4128 dump_ipv4_table (vat_main_t * vam)
4130 if (vam->json_output)
4133 ("JSON output supported only for VPE API calls and dump_stats_table");
4137 return dump_ip_table (vam, 0);
4141 dump_ipv6_table (vat_main_t * vam)
4143 if (vam->json_output)
4146 ("JSON output supported only for VPE API calls and dump_stats_table");
4150 return dump_ip_table (vam, 1);
4154 counter_type_to_str (u8 counter_type, u8 is_combined)
4158 switch (counter_type)
4160 case VNET_INTERFACE_COUNTER_DROP:
4162 case VNET_INTERFACE_COUNTER_PUNT:
4164 case VNET_INTERFACE_COUNTER_IP4:
4166 case VNET_INTERFACE_COUNTER_IP6:
4168 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4170 case VNET_INTERFACE_COUNTER_RX_MISS:
4172 case VNET_INTERFACE_COUNTER_RX_ERROR:
4174 case VNET_INTERFACE_COUNTER_TX_ERROR:
4177 return "INVALID-COUNTER-TYPE";
4182 switch (counter_type)
4184 case VNET_INTERFACE_COUNTER_RX:
4186 case VNET_INTERFACE_COUNTER_TX:
4189 return "INVALID-COUNTER-TYPE";
4195 dump_stats_table (vat_main_t * vam)
4197 vat_json_node_t node;
4198 vat_json_node_t *msg_array;
4199 vat_json_node_t *msg;
4200 vat_json_node_t *counter_array;
4201 vat_json_node_t *counter;
4202 interface_counter_t c;
4204 ip4_fib_counter_t *c4;
4205 ip6_fib_counter_t *c6;
4208 if (!vam->json_output)
4210 clib_warning ("dump_stats_table supported only in JSON format");
4214 vat_json_init_object (&node);
4216 /* interface counters */
4217 msg_array = vat_json_object_add (&node, "interface_counters");
4218 vat_json_init_array (msg_array);
4219 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4221 msg = vat_json_array_add (msg_array);
4222 vat_json_init_object (msg);
4223 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4224 (u8 *) counter_type_to_str (i, 0));
4225 vat_json_object_add_int (msg, "is_combined", 0);
4226 counter_array = vat_json_object_add (msg, "data");
4227 vat_json_init_array (counter_array);
4228 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4230 packets = vam->simple_interface_counters[i][j];
4231 vat_json_array_add_uint (counter_array, packets);
4234 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4236 msg = vat_json_array_add (msg_array);
4237 vat_json_init_object (msg);
4238 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4239 (u8 *) counter_type_to_str (i, 1));
4240 vat_json_object_add_int (msg, "is_combined", 1);
4241 counter_array = vat_json_object_add (msg, "data");
4242 vat_json_init_array (counter_array);
4243 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4245 c = vam->combined_interface_counters[i][j];
4246 counter = vat_json_array_add (counter_array);
4247 vat_json_init_object (counter);
4248 vat_json_object_add_uint (counter, "packets", c.packets);
4249 vat_json_object_add_uint (counter, "bytes", c.bytes);
4253 /* ip4 fib counters */
4254 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4255 vat_json_init_array (msg_array);
4256 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4258 msg = vat_json_array_add (msg_array);
4259 vat_json_init_object (msg);
4260 vat_json_object_add_uint (msg, "vrf_id",
4261 vam->ip4_fib_counters_vrf_id_by_index[i]);
4262 counter_array = vat_json_object_add (msg, "c");
4263 vat_json_init_array (counter_array);
4264 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4266 counter = vat_json_array_add (counter_array);
4267 vat_json_init_object (counter);
4268 c4 = &vam->ip4_fib_counters[i][j];
4269 vat_json_object_add_ip4 (counter, "address", c4->address);
4270 vat_json_object_add_uint (counter, "address_length",
4271 c4->address_length);
4272 vat_json_object_add_uint (counter, "packets", c4->packets);
4273 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4277 /* ip6 fib counters */
4278 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4279 vat_json_init_array (msg_array);
4280 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4282 msg = vat_json_array_add (msg_array);
4283 vat_json_init_object (msg);
4284 vat_json_object_add_uint (msg, "vrf_id",
4285 vam->ip6_fib_counters_vrf_id_by_index[i]);
4286 counter_array = vat_json_object_add (msg, "c");
4287 vat_json_init_array (counter_array);
4288 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4290 counter = vat_json_array_add (counter_array);
4291 vat_json_init_object (counter);
4292 c6 = &vam->ip6_fib_counters[i][j];
4293 vat_json_object_add_ip6 (counter, "address", c6->address);
4294 vat_json_object_add_uint (counter, "address_length",
4295 c6->address_length);
4296 vat_json_object_add_uint (counter, "packets", c6->packets);
4297 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4301 vat_json_print (vam->ofp, &node);
4302 vat_json_free (&node);
4308 exec (vat_main_t * vam)
4310 api_main_t *am = &api_main;
4311 vl_api_cli_request_t *mp;
4315 unformat_input_t *i = vam->input;
4317 if (vec_len (i->buffer) == 0)
4320 if (vam->exec_mode == 0 && unformat (i, "mode"))
4325 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4332 M (CLI_REQUEST, cli_request);
4335 * Copy cmd into shared memory.
4336 * In order for the CLI command to work, it
4337 * must be a vector ending in \n, not a C-string ending
4340 pthread_mutex_lock (&am->vlib_rp->mutex);
4341 oldheap = svm_push_data_heap (am->vlib_rp);
4343 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4344 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4346 svm_pop_heap (oldheap);
4347 pthread_mutex_unlock (&am->vlib_rp->mutex);
4349 mp->cmd_in_shmem = (u64) cmd;
4351 timeout = vat_time_now (vam) + 10.0;
4353 while (vat_time_now (vam) < timeout)
4355 if (vam->result_ready == 1)
4358 if (vam->shmem_result != NULL)
4359 print (vam->ofp, "%s", vam->shmem_result);
4360 pthread_mutex_lock (&am->vlib_rp->mutex);
4361 oldheap = svm_push_data_heap (am->vlib_rp);
4363 free_me = (u8 *) vam->shmem_result;
4366 svm_pop_heap (oldheap);
4367 pthread_mutex_unlock (&am->vlib_rp->mutex);
4375 * Future replacement of exec() that passes CLI buffers directly in
4376 * the API messages instead of an additional shared memory area.
4379 exec_inband (vat_main_t * vam)
4381 vl_api_cli_inband_t *mp;
4383 unformat_input_t *i = vam->input;
4385 if (vec_len (i->buffer) == 0)
4388 if (vam->exec_mode == 0 && unformat (i, "mode"))
4393 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4400 * In order for the CLI command to work, it
4401 * must be a vector ending in \n, not a C-string ending
4404 u32 len = vec_len (vam->input->buffer);
4405 M2 (CLI_INBAND, cli_inband, len);
4406 clib_memcpy (mp->cmd, vam->input->buffer, len);
4407 mp->length = htonl (len);
4410 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4414 api_create_loopback (vat_main_t * vam)
4416 unformat_input_t *i = vam->input;
4417 vl_api_create_loopback_t *mp;
4422 memset (mac_address, 0, sizeof (mac_address));
4424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4426 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4432 /* Construct the API message */
4433 M (CREATE_LOOPBACK, create_loopback);
4435 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4442 api_delete_loopback (vat_main_t * vam)
4444 unformat_input_t *i = vam->input;
4445 vl_api_delete_loopback_t *mp;
4447 u32 sw_if_index = ~0;
4449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4451 if (unformat (i, "sw_if_index %d", &sw_if_index))
4457 if (sw_if_index == ~0)
4459 errmsg ("missing sw_if_index");
4463 /* Construct the API message */
4464 M (DELETE_LOOPBACK, delete_loopback);
4465 mp->sw_if_index = ntohl (sw_if_index);
4472 api_want_stats (vat_main_t * vam)
4474 unformat_input_t *i = vam->input;
4475 vl_api_want_stats_t *mp;
4479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4481 if (unformat (i, "enable"))
4483 else if (unformat (i, "disable"))
4491 errmsg ("missing enable|disable");
4495 M (WANT_STATS, want_stats);
4496 mp->enable_disable = enable;
4503 api_want_interface_events (vat_main_t * vam)
4505 unformat_input_t *i = vam->input;
4506 vl_api_want_interface_events_t *mp;
4510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4512 if (unformat (i, "enable"))
4514 else if (unformat (i, "disable"))
4522 errmsg ("missing enable|disable");
4526 M (WANT_INTERFACE_EVENTS, want_interface_events);
4527 mp->enable_disable = enable;
4529 vam->interface_event_display = enable;
4536 /* Note: non-static, called once to set up the initial intfc table */
4538 api_sw_interface_dump (vat_main_t * vam)
4540 vl_api_sw_interface_dump_t *mp;
4543 name_sort_t *nses = 0, *ns;
4544 sw_interface_subif_t *sub = NULL;
4546 /* Toss the old name table */
4548 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4550 vec_add2 (nses, ns, 1);
4551 ns->name = (u8 *)(p->key);
4552 ns->value = (u32) p->value[0];
4556 hash_free (vam->sw_if_index_by_interface_name);
4558 vec_foreach (ns, nses) vec_free (ns->name);
4562 vec_foreach (sub, vam->sw_if_subif_table)
4564 vec_free (sub->interface_name);
4566 vec_free (vam->sw_if_subif_table);
4568 /* recreate the interface name hash table */
4569 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4571 /* Get list of ethernets */
4572 M (SW_INTERFACE_DUMP, sw_interface_dump);
4573 mp->name_filter_valid = 1;
4574 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4577 /* and local / loopback interfaces */
4578 M (SW_INTERFACE_DUMP, sw_interface_dump);
4579 mp->name_filter_valid = 1;
4580 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4583 /* and packet-generator interfaces */
4584 M (SW_INTERFACE_DUMP, sw_interface_dump);
4585 mp->name_filter_valid = 1;
4586 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4589 /* and vxlan-gpe tunnel interfaces */
4590 M (SW_INTERFACE_DUMP, sw_interface_dump);
4591 mp->name_filter_valid = 1;
4592 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4593 sizeof (mp->name_filter) - 1);
4596 /* and vxlan tunnel interfaces */
4597 M (SW_INTERFACE_DUMP, sw_interface_dump);
4598 mp->name_filter_valid = 1;
4599 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4602 /* and host (af_packet) interfaces */
4603 M (SW_INTERFACE_DUMP, sw_interface_dump);
4604 mp->name_filter_valid = 1;
4605 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4608 /* and l2tpv3 tunnel interfaces */
4609 M (SW_INTERFACE_DUMP, sw_interface_dump);
4610 mp->name_filter_valid = 1;
4611 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4612 sizeof (mp->name_filter) - 1);
4615 /* and GRE tunnel interfaces */
4616 M (SW_INTERFACE_DUMP, sw_interface_dump);
4617 mp->name_filter_valid = 1;
4618 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4621 /* and LISP-GPE interfaces */
4622 M (SW_INTERFACE_DUMP, sw_interface_dump);
4623 mp->name_filter_valid = 1;
4624 strncpy ((char *) mp->name_filter, "lisp_gpe",
4625 sizeof (mp->name_filter) - 1);
4628 /* and IPSEC tunnel interfaces */
4629 M (SW_INTERFACE_DUMP, sw_interface_dump);
4630 mp->name_filter_valid = 1;
4631 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4634 /* Use a control ping for synchronization */
4636 vl_api_control_ping_t *mp;
4637 M (CONTROL_PING, control_ping);
4644 api_sw_interface_set_flags (vat_main_t * vam)
4646 unformat_input_t *i = vam->input;
4647 vl_api_sw_interface_set_flags_t *mp;
4650 u8 sw_if_index_set = 0;
4651 u8 admin_up = 0, link_up = 0;
4653 /* Parse args required to build the message */
4654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4656 if (unformat (i, "admin-up"))
4658 else if (unformat (i, "admin-down"))
4660 else if (unformat (i, "link-up"))
4662 else if (unformat (i, "link-down"))
4665 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4666 sw_if_index_set = 1;
4667 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4668 sw_if_index_set = 1;
4673 if (sw_if_index_set == 0)
4675 errmsg ("missing interface name or sw_if_index");
4679 /* Construct the API message */
4680 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4681 mp->sw_if_index = ntohl (sw_if_index);
4682 mp->admin_up_down = admin_up;
4683 mp->link_up_down = link_up;
4688 /* Wait for a reply, return the good/bad news... */
4693 api_sw_interface_clear_stats (vat_main_t * vam)
4695 unformat_input_t *i = vam->input;
4696 vl_api_sw_interface_clear_stats_t *mp;
4699 u8 sw_if_index_set = 0;
4701 /* Parse args required to build the message */
4702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4704 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4705 sw_if_index_set = 1;
4706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4707 sw_if_index_set = 1;
4712 /* Construct the API message */
4713 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4715 if (sw_if_index_set == 1)
4716 mp->sw_if_index = ntohl (sw_if_index);
4718 mp->sw_if_index = ~0;
4723 /* Wait for a reply, return the good/bad news... */
4728 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4730 unformat_input_t *i = vam->input;
4731 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4734 u8 sw_if_index_set = 0;
4742 /* Parse args required to build the message */
4743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4745 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4746 sw_if_index_set = 1;
4747 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4748 sw_if_index_set = 1;
4749 else if (unformat (i, "subport %u", &subport))
4752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4753 sw_if_index_set = 1;
4754 else if (unformat (i, "pipe %u", &pipe))
4756 else if (unformat (i, "profile %u", &profile))
4762 if (sw_if_index_set == 0)
4764 errmsg ("missing interface name or sw_if_index");
4768 if (subport_set == 0)
4770 errmsg ("missing subport ");
4776 errmsg ("missing pipe");
4780 if (profile_set == 0)
4782 errmsg ("missing profile");
4786 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4788 mp->sw_if_index = ntohl (sw_if_index);
4789 mp->subport = ntohl (subport);
4790 mp->pipe = ntohl (pipe);
4791 mp->profile = ntohl (profile);
4801 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4803 unformat_input_t *i = vam->input;
4804 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4807 u8 sw_if_index_set = 0;
4810 u32 tb_rate = 1250000000; /* 10GbE */
4811 u32 tb_size = 1000000;
4812 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4815 /* Parse args required to build the message */
4816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4818 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4819 sw_if_index_set = 1;
4820 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4821 sw_if_index_set = 1;
4822 else if (unformat (i, "subport %u", &subport))
4825 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4826 sw_if_index_set = 1;
4827 else if (unformat (i, "rate %u", &tb_rate))
4831 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4833 tc_rate[tc_id] = tb_rate;
4835 else if (unformat (i, "bktsize %u", &tb_size))
4837 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4839 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4841 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4843 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4845 else if (unformat (i, "period %u", &tc_period))
4851 if (sw_if_index_set == 0)
4853 errmsg ("missing interface name or sw_if_index");
4857 if (subport_set == 0)
4859 errmsg ("missing subport ");
4863 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4865 mp->sw_if_index = ntohl (sw_if_index);
4866 mp->subport = ntohl (subport);
4867 mp->tb_rate = ntohl (tb_rate);
4868 mp->tb_size = ntohl (tb_size);
4869 mp->tc_rate[0] = ntohl (tc_rate[0]);
4870 mp->tc_rate[1] = ntohl (tc_rate[1]);
4871 mp->tc_rate[2] = ntohl (tc_rate[2]);
4872 mp->tc_rate[3] = ntohl (tc_rate[3]);
4873 mp->tc_period = ntohl (tc_period);
4882 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4884 unformat_input_t *i = vam->input;
4885 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4888 u8 sw_if_index_set = 0;
4892 u32 entry, tc, queue;
4894 /* Parse args required to build the message */
4895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4897 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4898 sw_if_index_set = 1;
4899 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4900 sw_if_index_set = 1;
4901 else if (unformat (i, "entry %d", &entry))
4903 else if (unformat (i, "tc %d", &tc))
4905 else if (unformat (i, "queue %d", &queue))
4911 if (sw_if_index_set == 0)
4913 errmsg ("missing interface name or sw_if_index");
4919 errmsg ("missing entry ");
4925 errmsg ("missing traffic class ");
4931 errmsg ("missing queue ");
4935 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4937 mp->sw_if_index = ntohl (sw_if_index);
4938 mp->entry = ntohl (entry);
4939 mp->tc = ntohl (tc);
4940 mp->queue = ntohl (queue);
4949 api_sw_interface_add_del_address (vat_main_t * vam)
4951 unformat_input_t *i = vam->input;
4952 vl_api_sw_interface_add_del_address_t *mp;
4955 u8 sw_if_index_set = 0;
4956 u8 is_add = 1, del_all = 0;
4957 u32 address_length = 0;
4958 u8 v4_address_set = 0;
4959 u8 v6_address_set = 0;
4960 ip4_address_t v4address;
4961 ip6_address_t v6address;
4963 /* Parse args required to build the message */
4964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4966 if (unformat (i, "del-all"))
4968 else if (unformat (i, "del"))
4971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4972 sw_if_index_set = 1;
4973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4974 sw_if_index_set = 1;
4975 else if (unformat (i, "%U/%d",
4976 unformat_ip4_address, &v4address, &address_length))
4978 else if (unformat (i, "%U/%d",
4979 unformat_ip6_address, &v6address, &address_length))
4985 if (sw_if_index_set == 0)
4987 errmsg ("missing interface name or sw_if_index");
4990 if (v4_address_set && v6_address_set)
4992 errmsg ("both v4 and v6 addresses set");
4995 if (!v4_address_set && !v6_address_set && !del_all)
4997 errmsg ("no addresses set");
5001 /* Construct the API message */
5002 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
5004 mp->sw_if_index = ntohl (sw_if_index);
5005 mp->is_add = is_add;
5006 mp->del_all = del_all;
5010 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5014 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5016 mp->address_length = address_length;
5021 /* Wait for a reply, return good/bad news */
5026 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5028 unformat_input_t *i = vam->input;
5029 vl_api_sw_interface_set_mpls_enable_t *mp;
5032 u8 sw_if_index_set = 0;
5035 /* Parse args required to build the message */
5036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5038 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5039 sw_if_index_set = 1;
5040 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5041 sw_if_index_set = 1;
5042 else if (unformat (i, "disable"))
5044 else if (unformat (i, "dis"))
5050 if (sw_if_index_set == 0)
5052 errmsg ("missing interface name or sw_if_index");
5056 /* Construct the API message */
5057 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5059 mp->sw_if_index = ntohl (sw_if_index);
5060 mp->enable = enable;
5065 /* Wait for a reply... */
5070 api_sw_interface_set_table (vat_main_t * vam)
5072 unformat_input_t *i = vam->input;
5073 vl_api_sw_interface_set_table_t *mp;
5075 u32 sw_if_index, vrf_id = 0;
5076 u8 sw_if_index_set = 0;
5079 /* Parse args required to build the message */
5080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5082 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5083 sw_if_index_set = 1;
5084 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5085 sw_if_index_set = 1;
5086 else if (unformat (i, "vrf %d", &vrf_id))
5088 else if (unformat (i, "ipv6"))
5094 if (sw_if_index_set == 0)
5096 errmsg ("missing interface name or sw_if_index");
5100 /* Construct the API message */
5101 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5103 mp->sw_if_index = ntohl (sw_if_index);
5104 mp->is_ipv6 = is_ipv6;
5105 mp->vrf_id = ntohl (vrf_id);
5110 /* Wait for a reply... */
5114 static void vl_api_sw_interface_get_table_reply_t_handler
5115 (vl_api_sw_interface_get_table_reply_t * mp)
5117 vat_main_t *vam = &vat_main;
5119 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5121 vam->retval = ntohl (mp->retval);
5122 vam->result_ready = 1;
5126 static void vl_api_sw_interface_get_table_reply_t_handler_json
5127 (vl_api_sw_interface_get_table_reply_t * mp)
5129 vat_main_t *vam = &vat_main;
5130 vat_json_node_t node;
5132 vat_json_init_object (&node);
5133 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5134 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5136 vat_json_print (vam->ofp, &node);
5137 vat_json_free (&node);
5139 vam->retval = ntohl (mp->retval);
5140 vam->result_ready = 1;
5144 api_sw_interface_get_table (vat_main_t * vam)
5146 unformat_input_t *i = vam->input;
5147 vl_api_sw_interface_get_table_t *mp;
5149 u8 sw_if_index_set = 0;
5153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5156 sw_if_index_set = 1;
5157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5158 sw_if_index_set = 1;
5159 else if (unformat (i, "ipv6"))
5165 if (sw_if_index_set == 0)
5167 errmsg ("missing interface name or sw_if_index");
5171 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5172 mp->sw_if_index = htonl (sw_if_index);
5173 mp->is_ipv6 = is_ipv6;
5180 api_sw_interface_set_vpath (vat_main_t * vam)
5182 unformat_input_t *i = vam->input;
5183 vl_api_sw_interface_set_vpath_t *mp;
5185 u32 sw_if_index = 0;
5186 u8 sw_if_index_set = 0;
5189 /* Parse args required to build the message */
5190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5192 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5193 sw_if_index_set = 1;
5194 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5195 sw_if_index_set = 1;
5196 else if (unformat (i, "enable"))
5198 else if (unformat (i, "disable"))
5204 if (sw_if_index_set == 0)
5206 errmsg ("missing interface name or sw_if_index");
5210 /* Construct the API message */
5211 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5213 mp->sw_if_index = ntohl (sw_if_index);
5214 mp->enable = is_enable;
5219 /* Wait for a reply... */
5224 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5226 unformat_input_t *i = vam->input;
5227 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5229 u32 sw_if_index = 0;
5230 u8 sw_if_index_set = 0;
5234 /* Parse args required to build the message */
5235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5237 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5238 sw_if_index_set = 1;
5239 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5240 sw_if_index_set = 1;
5241 else if (unformat (i, "enable"))
5243 else if (unformat (i, "disable"))
5245 else if (unformat (i, "ip4"))
5247 else if (unformat (i, "ip6"))
5253 if (sw_if_index_set == 0)
5255 errmsg ("missing interface name or sw_if_index");
5259 /* Construct the API message */
5260 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5262 mp->sw_if_index = ntohl (sw_if_index);
5263 mp->enable = is_enable;
5264 mp->is_ipv6 = is_ipv6;
5269 /* Wait for a reply... */
5274 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5276 unformat_input_t *i = vam->input;
5277 vl_api_sw_interface_set_l2_xconnect_t *mp;
5280 u8 rx_sw_if_index_set = 0;
5282 u8 tx_sw_if_index_set = 0;
5285 /* Parse args required to build the message */
5286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5288 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5289 rx_sw_if_index_set = 1;
5290 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5291 tx_sw_if_index_set = 1;
5292 else if (unformat (i, "rx"))
5294 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5296 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5298 rx_sw_if_index_set = 1;
5303 else if (unformat (i, "tx"))
5305 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5307 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5309 tx_sw_if_index_set = 1;
5314 else if (unformat (i, "enable"))
5316 else if (unformat (i, "disable"))
5322 if (rx_sw_if_index_set == 0)
5324 errmsg ("missing rx interface name or rx_sw_if_index");
5328 if (enable && (tx_sw_if_index_set == 0))
5330 errmsg ("missing tx interface name or tx_sw_if_index");
5334 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5336 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5337 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5338 mp->enable = enable;
5347 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5349 unformat_input_t *i = vam->input;
5350 vl_api_sw_interface_set_l2_bridge_t *mp;
5353 u8 rx_sw_if_index_set = 0;
5360 /* Parse args required to build the message */
5361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5363 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5364 rx_sw_if_index_set = 1;
5365 else if (unformat (i, "bd_id %d", &bd_id))
5369 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5370 rx_sw_if_index_set = 1;
5371 else if (unformat (i, "shg %d", &shg))
5373 else if (unformat (i, "bvi"))
5375 else if (unformat (i, "enable"))
5377 else if (unformat (i, "disable"))
5383 if (rx_sw_if_index_set == 0)
5385 errmsg ("missing rx interface name or sw_if_index");
5389 if (enable && (bd_id_set == 0))
5391 errmsg ("missing bridge domain");
5395 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5397 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5398 mp->bd_id = ntohl (bd_id);
5401 mp->enable = enable;
5410 api_bridge_domain_dump (vat_main_t * vam)
5412 unformat_input_t *i = vam->input;
5413 vl_api_bridge_domain_dump_t *mp;
5417 /* Parse args required to build the message */
5418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5420 if (unformat (i, "bd_id %d", &bd_id))
5426 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5427 mp->bd_id = ntohl (bd_id);
5430 /* Use a control ping for synchronization */
5432 vl_api_control_ping_t *mp;
5433 M (CONTROL_PING, control_ping);
5443 api_bridge_domain_add_del (vat_main_t * vam)
5445 unformat_input_t *i = vam->input;
5446 vl_api_bridge_domain_add_del_t *mp;
5450 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5453 /* Parse args required to build the message */
5454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5456 if (unformat (i, "bd_id %d", &bd_id))
5458 else if (unformat (i, "flood %d", &flood))
5460 else if (unformat (i, "uu-flood %d", &uu_flood))
5462 else if (unformat (i, "forward %d", &forward))
5464 else if (unformat (i, "learn %d", &learn))
5466 else if (unformat (i, "arp-term %d", &arp_term))
5468 else if (unformat (i, "mac-age %d", &mac_age))
5470 else if (unformat (i, "del"))
5473 flood = uu_flood = forward = learn = 0;
5481 errmsg ("missing bridge domain");
5487 errmsg ("mac age must be less than 256 ");
5491 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5493 mp->bd_id = ntohl (bd_id);
5495 mp->uu_flood = uu_flood;
5496 mp->forward = forward;
5498 mp->arp_term = arp_term;
5499 mp->is_add = is_add;
5500 mp->mac_age = (u8) mac_age;
5509 api_l2fib_add_del (vat_main_t * vam)
5511 unformat_input_t *i = vam->input;
5512 vl_api_l2fib_add_del_t *mp;
5518 u32 sw_if_index = ~0;
5519 u8 sw_if_index_set = 0;
5528 /* Parse args required to build the message */
5529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5531 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5533 else if (unformat (i, "bd_id %d", &bd_id))
5535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5536 sw_if_index_set = 1;
5537 else if (unformat (i, "sw_if"))
5539 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5542 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5543 sw_if_index_set = 1;
5548 else if (unformat (i, "static"))
5550 else if (unformat (i, "filter"))
5555 else if (unformat (i, "bvi"))
5560 else if (unformat (i, "del"))
5562 else if (unformat (i, "count %d", &count))
5570 errmsg ("missing mac address");
5576 errmsg ("missing bridge domain");
5580 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5582 errmsg ("missing interface name or sw_if_index");
5588 /* Turn on async mode */
5589 vam->async_mode = 1;
5590 vam->async_errors = 0;
5591 before = vat_time_now (vam);
5594 for (j = 0; j < count; j++)
5596 M (L2FIB_ADD_DEL, l2fib_add_del);
5599 mp->bd_id = ntohl (bd_id);
5600 mp->is_add = is_add;
5604 mp->sw_if_index = ntohl (sw_if_index);
5605 mp->static_mac = static_mac;
5606 mp->filter_mac = filter_mac;
5607 mp->bvi_mac = bvi_mac;
5609 increment_mac_address (&mac);
5616 vl_api_control_ping_t *mp;
5619 /* Shut off async mode */
5620 vam->async_mode = 0;
5622 M (CONTROL_PING, control_ping);
5625 timeout = vat_time_now (vam) + 1.0;
5626 while (vat_time_now (vam) < timeout)
5627 if (vam->result_ready == 1)
5632 if (vam->retval == -99)
5635 if (vam->async_errors > 0)
5637 errmsg ("%d asynchronous errors", vam->async_errors);
5640 vam->async_errors = 0;
5641 after = vat_time_now (vam);
5643 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5644 count, after - before, count / (after - before));
5648 /* Wait for a reply... */
5651 /* Return the good/bad news */
5652 return (vam->retval);
5656 api_l2_flags (vat_main_t * vam)
5658 unformat_input_t *i = vam->input;
5659 vl_api_l2_flags_t *mp;
5662 u32 feature_bitmap = 0;
5663 u8 sw_if_index_set = 0;
5665 /* Parse args required to build the message */
5666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5668 if (unformat (i, "sw_if_index %d", &sw_if_index))
5669 sw_if_index_set = 1;
5670 else if (unformat (i, "sw_if"))
5672 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5675 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5676 sw_if_index_set = 1;
5681 else if (unformat (i, "learn"))
5682 feature_bitmap |= L2INPUT_FEAT_LEARN;
5683 else if (unformat (i, "forward"))
5684 feature_bitmap |= L2INPUT_FEAT_FWD;
5685 else if (unformat (i, "flood"))
5686 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5687 else if (unformat (i, "uu-flood"))
5688 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5693 if (sw_if_index_set == 0)
5695 errmsg ("missing interface name or sw_if_index");
5699 M (L2_FLAGS, l2_flags);
5701 mp->sw_if_index = ntohl (sw_if_index);
5702 mp->feature_bitmap = ntohl (feature_bitmap);
5711 api_bridge_flags (vat_main_t * vam)
5713 unformat_input_t *i = vam->input;
5714 vl_api_bridge_flags_t *mp;
5721 /* Parse args required to build the message */
5722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5724 if (unformat (i, "bd_id %d", &bd_id))
5726 else if (unformat (i, "learn"))
5728 else if (unformat (i, "forward"))
5730 else if (unformat (i, "flood"))
5732 else if (unformat (i, "uu-flood"))
5733 flags |= L2_UU_FLOOD;
5734 else if (unformat (i, "arp-term"))
5735 flags |= L2_ARP_TERM;
5736 else if (unformat (i, "off"))
5738 else if (unformat (i, "disable"))
5746 errmsg ("missing bridge domain");
5750 M (BRIDGE_FLAGS, bridge_flags);
5752 mp->bd_id = ntohl (bd_id);
5753 mp->feature_bitmap = ntohl (flags);
5754 mp->is_set = is_set;
5763 api_bd_ip_mac_add_del (vat_main_t * vam)
5765 unformat_input_t *i = vam->input;
5766 vl_api_bd_ip_mac_add_del_t *mp;
5774 ip4_address_t v4addr;
5775 ip6_address_t v6addr;
5779 /* Parse args required to build the message */
5780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5782 if (unformat (i, "bd_id %d", &bd_id))
5786 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5790 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5795 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5799 else if (unformat (i, "del"))
5807 errmsg ("missing bridge domain");
5810 else if (ip_set == 0)
5812 errmsg ("missing IP address");
5815 else if (mac_set == 0)
5817 errmsg ("missing MAC address");
5821 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5823 mp->bd_id = ntohl (bd_id);
5824 mp->is_ipv6 = is_ipv6;
5825 mp->is_add = is_add;
5827 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5829 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5830 clib_memcpy (mp->mac_address, macaddr, 6);
5838 api_tap_connect (vat_main_t * vam)
5840 unformat_input_t *i = vam->input;
5841 vl_api_tap_connect_t *mp;
5849 memset (mac_address, 0, sizeof (mac_address));
5851 /* Parse args required to build the message */
5852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5854 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5858 else if (unformat (i, "random-mac"))
5860 else if (unformat (i, "tapname %s", &tap_name))
5862 else if (unformat (i, "tag %s", &tag))
5870 errmsg ("missing tap name");
5873 if (vec_len (tap_name) > 63)
5875 errmsg ("tap name too long");
5878 vec_add1 (tap_name, 0);
5880 if (vec_len (tag) > 63)
5882 errmsg ("tag too long");
5886 /* Construct the API message */
5887 M (TAP_CONNECT, tap_connect);
5889 mp->use_random_mac = random_mac;
5890 clib_memcpy (mp->mac_address, mac_address, 6);
5891 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5893 clib_memcpy (mp->tag, tag, vec_len (tag));
5895 vec_free (tap_name);
5901 /* Wait for a reply... */
5906 api_tap_modify (vat_main_t * vam)
5908 unformat_input_t *i = vam->input;
5909 vl_api_tap_modify_t *mp;
5915 u32 sw_if_index = ~0;
5916 u8 sw_if_index_set = 0;
5918 memset (mac_address, 0, sizeof (mac_address));
5920 /* Parse args required to build the message */
5921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5923 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5924 sw_if_index_set = 1;
5925 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5926 sw_if_index_set = 1;
5927 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5931 else if (unformat (i, "random-mac"))
5933 else if (unformat (i, "tapname %s", &tap_name))
5939 if (sw_if_index_set == 0)
5941 errmsg ("missing vpp interface name");
5946 errmsg ("missing tap name");
5949 if (vec_len (tap_name) > 63)
5951 errmsg ("tap name too long");
5953 vec_add1 (tap_name, 0);
5955 /* Construct the API message */
5956 M (TAP_MODIFY, tap_modify);
5958 mp->use_random_mac = random_mac;
5959 mp->sw_if_index = ntohl (sw_if_index);
5960 clib_memcpy (mp->mac_address, mac_address, 6);
5961 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5962 vec_free (tap_name);
5967 /* Wait for a reply... */
5972 api_tap_delete (vat_main_t * vam)
5974 unformat_input_t *i = vam->input;
5975 vl_api_tap_delete_t *mp;
5977 u32 sw_if_index = ~0;
5978 u8 sw_if_index_set = 0;
5980 /* Parse args required to build the message */
5981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5984 sw_if_index_set = 1;
5985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5986 sw_if_index_set = 1;
5991 if (sw_if_index_set == 0)
5993 errmsg ("missing vpp interface name");
5997 /* Construct the API message */
5998 M (TAP_DELETE, tap_delete);
6000 mp->sw_if_index = ntohl (sw_if_index);
6005 /* Wait for a reply... */
6010 api_ip_add_del_route (vat_main_t * vam)
6012 unformat_input_t *i = vam->input;
6013 vl_api_ip_add_del_route_t *mp;
6015 u32 sw_if_index = ~0, vrf_id = 0;
6017 u8 is_local = 0, is_drop = 0;
6018 u8 is_unreach = 0, is_prohibit = 0;
6019 u8 create_vrf_if_needed = 0;
6021 u32 next_hop_weight = 1;
6023 u8 is_multipath = 0;
6025 u8 address_length_set = 0;
6026 u32 next_hop_table_id = 0;
6027 u32 resolve_attempts = 0;
6028 u32 dst_address_length = 0;
6029 u8 next_hop_set = 0;
6030 ip4_address_t v4_dst_address, v4_next_hop_address;
6031 ip6_address_t v6_dst_address, v6_next_hop_address;
6035 u32 random_add_del = 0;
6036 u32 *random_vector = 0;
6038 u32 random_seed = 0xdeaddabe;
6039 u32 classify_table_index = ~0;
6041 u8 resolve_host = 0, resolve_attached = 0;
6042 mpls_label_t *next_hop_out_label_stack = NULL;
6043 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6044 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6046 /* Parse args required to build the message */
6047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6051 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6053 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6058 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6063 else if (unformat (i, "/%d", &dst_address_length))
6065 address_length_set = 1;
6068 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6069 &v4_next_hop_address))
6073 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6074 &v6_next_hop_address))
6078 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6080 else if (unformat (i, "weight %d", &next_hop_weight))
6082 else if (unformat (i, "drop"))
6086 else if (unformat (i, "null-send-unreach"))
6090 else if (unformat (i, "null-send-prohibit"))
6094 else if (unformat (i, "local"))
6098 else if (unformat (i, "classify %d", &classify_table_index))
6102 else if (unformat (i, "del"))
6104 else if (unformat (i, "add"))
6106 else if (unformat (i, "not-last"))
6108 else if (unformat (i, "resolve-via-host"))
6110 else if (unformat (i, "resolve-via-attached"))
6111 resolve_attached = 1;
6112 else if (unformat (i, "multipath"))
6114 else if (unformat (i, "vrf %d", &vrf_id))
6116 else if (unformat (i, "create-vrf"))
6117 create_vrf_if_needed = 1;
6118 else if (unformat (i, "count %d", &count))
6120 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6122 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6124 else if (unformat (i, "out-label %d", &next_hop_out_label))
6125 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6126 else if (unformat (i, "via-label %d", &next_hop_via_label))
6128 else if (unformat (i, "random"))
6130 else if (unformat (i, "seed %d", &random_seed))
6134 clib_warning ("parse error '%U'", format_unformat_error, i);
6139 if (!next_hop_set && !is_drop && !is_local &&
6140 !is_classify && !is_unreach && !is_prohibit &&
6141 MPLS_LABEL_INVALID == next_hop_via_label)
6144 ("next hop / local / drop / unreach / prohibit / classify not set");
6148 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6150 errmsg ("next hop and next-hop via label set");
6153 if (address_set == 0)
6155 errmsg ("missing addresses");
6159 if (address_length_set == 0)
6161 errmsg ("missing address length");
6165 /* Generate a pile of unique, random routes */
6168 u32 this_random_address;
6169 random_hash = hash_create (count, sizeof (uword));
6171 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6172 for (j = 0; j <= count; j++)
6176 this_random_address = random_u32 (&random_seed);
6177 this_random_address =
6178 clib_host_to_net_u32 (this_random_address);
6180 while (hash_get (random_hash, this_random_address));
6181 vec_add1 (random_vector, this_random_address);
6182 hash_set (random_hash, this_random_address, 1);
6184 hash_free (random_hash);
6185 v4_dst_address.as_u32 = random_vector[0];
6190 /* Turn on async mode */
6191 vam->async_mode = 1;
6192 vam->async_errors = 0;
6193 before = vat_time_now (vam);
6196 for (j = 0; j < count; j++)
6198 /* Construct the API message */
6199 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6200 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6202 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6203 mp->table_id = ntohl (vrf_id);
6204 mp->create_vrf_if_needed = create_vrf_if_needed;
6206 mp->is_add = is_add;
6207 mp->is_drop = is_drop;
6208 mp->is_unreach = is_unreach;
6209 mp->is_prohibit = is_prohibit;
6210 mp->is_ipv6 = is_ipv6;
6211 mp->is_local = is_local;
6212 mp->is_classify = is_classify;
6213 mp->is_multipath = is_multipath;
6214 mp->is_resolve_host = resolve_host;
6215 mp->is_resolve_attached = resolve_attached;
6216 mp->not_last = not_last;
6217 mp->next_hop_weight = next_hop_weight;
6218 mp->dst_address_length = dst_address_length;
6219 mp->next_hop_table_id = ntohl (next_hop_table_id);
6220 mp->classify_table_index = ntohl (classify_table_index);
6221 mp->next_hop_via_label = ntohl (next_hop_via_label);
6222 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6223 if (0 != mp->next_hop_n_out_labels)
6225 memcpy (mp->next_hop_out_label_stack,
6226 next_hop_out_label_stack,
6227 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6228 vec_free (next_hop_out_label_stack);
6233 clib_memcpy (mp->dst_address, &v6_dst_address,
6234 sizeof (v6_dst_address));
6236 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6237 sizeof (v6_next_hop_address));
6238 increment_v6_address (&v6_dst_address);
6242 clib_memcpy (mp->dst_address, &v4_dst_address,
6243 sizeof (v4_dst_address));
6245 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6246 sizeof (v4_next_hop_address));
6248 v4_dst_address.as_u32 = random_vector[j + 1];
6250 increment_v4_address (&v4_dst_address);
6254 /* If we receive SIGTERM, stop now... */
6259 /* When testing multiple add/del ops, use a control-ping to sync */
6262 vl_api_control_ping_t *mp;
6265 /* Shut off async mode */
6266 vam->async_mode = 0;
6268 M (CONTROL_PING, control_ping);
6271 timeout = vat_time_now (vam) + 1.0;
6272 while (vat_time_now (vam) < timeout)
6273 if (vam->result_ready == 1)
6278 if (vam->retval == -99)
6281 if (vam->async_errors > 0)
6283 errmsg ("%d asynchronous errors", vam->async_errors);
6286 vam->async_errors = 0;
6287 after = vat_time_now (vam);
6289 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6293 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6294 count, after - before, count / (after - before));
6298 /* Wait for a reply... */
6302 /* Return the good/bad news */
6303 return (vam->retval);
6307 api_mpls_route_add_del (vat_main_t * vam)
6309 unformat_input_t *i = vam->input;
6310 vl_api_mpls_route_add_del_t *mp;
6312 u32 sw_if_index = ~0, table_id = 0;
6313 u8 create_table_if_needed = 0;
6315 u32 next_hop_weight = 1;
6316 u8 is_multipath = 0;
6317 u32 next_hop_table_id = 0;
6318 u8 next_hop_set = 0;
6319 ip4_address_t v4_next_hop_address = {
6322 ip6_address_t v6_next_hop_address = { {0} };
6326 u32 classify_table_index = ~0;
6328 u8 resolve_host = 0, resolve_attached = 0;
6329 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6330 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6331 mpls_label_t *next_hop_out_label_stack = NULL;
6332 mpls_label_t local_label = MPLS_LABEL_INVALID;
6334 u8 next_hop_proto_is_ip4 = 1;
6336 /* Parse args required to build the message */
6337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6339 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6341 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6343 else if (unformat (i, "%d", &local_label))
6345 else if (unformat (i, "eos"))
6347 else if (unformat (i, "non-eos"))
6349 else if (unformat (i, "via %U", unformat_ip4_address,
6350 &v4_next_hop_address))
6353 next_hop_proto_is_ip4 = 1;
6355 else if (unformat (i, "via %U", unformat_ip6_address,
6356 &v6_next_hop_address))
6359 next_hop_proto_is_ip4 = 0;
6361 else if (unformat (i, "weight %d", &next_hop_weight))
6363 else if (unformat (i, "create-table"))
6364 create_table_if_needed = 1;
6365 else if (unformat (i, "classify %d", &classify_table_index))
6369 else if (unformat (i, "del"))
6371 else if (unformat (i, "add"))
6373 else if (unformat (i, "resolve-via-host"))
6375 else if (unformat (i, "resolve-via-attached"))
6376 resolve_attached = 1;
6377 else if (unformat (i, "multipath"))
6379 else if (unformat (i, "count %d", &count))
6381 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6384 next_hop_proto_is_ip4 = 1;
6386 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6389 next_hop_proto_is_ip4 = 0;
6391 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6393 else if (unformat (i, "via-label %d", &next_hop_via_label))
6395 else if (unformat (i, "out-label %d", &next_hop_out_label))
6396 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6399 clib_warning ("parse error '%U'", format_unformat_error, i);
6404 if (!next_hop_set && !is_classify)
6406 errmsg ("next hop / classify not set");
6410 if (MPLS_LABEL_INVALID == local_label)
6412 errmsg ("missing label");
6418 /* Turn on async mode */
6419 vam->async_mode = 1;
6420 vam->async_errors = 0;
6421 before = vat_time_now (vam);
6424 for (j = 0; j < count; j++)
6426 /* Construct the API message */
6427 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6428 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6430 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6431 mp->mr_table_id = ntohl (table_id);
6432 mp->mr_create_table_if_needed = create_table_if_needed;
6434 mp->mr_is_add = is_add;
6435 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6436 mp->mr_is_classify = is_classify;
6437 mp->mr_is_multipath = is_multipath;
6438 mp->mr_is_resolve_host = resolve_host;
6439 mp->mr_is_resolve_attached = resolve_attached;
6440 mp->mr_next_hop_weight = next_hop_weight;
6441 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6442 mp->mr_classify_table_index = ntohl (classify_table_index);
6443 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6444 mp->mr_label = ntohl (local_label);
6445 mp->mr_eos = is_eos;
6447 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6448 if (0 != mp->mr_next_hop_n_out_labels)
6450 memcpy (mp->mr_next_hop_out_label_stack,
6451 next_hop_out_label_stack,
6452 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6453 vec_free (next_hop_out_label_stack);
6458 if (next_hop_proto_is_ip4)
6460 clib_memcpy (mp->mr_next_hop,
6461 &v4_next_hop_address,
6462 sizeof (v4_next_hop_address));
6466 clib_memcpy (mp->mr_next_hop,
6467 &v6_next_hop_address,
6468 sizeof (v6_next_hop_address));
6475 /* If we receive SIGTERM, stop now... */
6480 /* When testing multiple add/del ops, use a control-ping to sync */
6483 vl_api_control_ping_t *mp;
6486 /* Shut off async mode */
6487 vam->async_mode = 0;
6489 M (CONTROL_PING, control_ping);
6492 timeout = vat_time_now (vam) + 1.0;
6493 while (vat_time_now (vam) < timeout)
6494 if (vam->result_ready == 1)
6499 if (vam->retval == -99)
6502 if (vam->async_errors > 0)
6504 errmsg ("%d asynchronous errors", vam->async_errors);
6507 vam->async_errors = 0;
6508 after = vat_time_now (vam);
6510 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6514 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6515 count, after - before, count / (after - before));
6519 /* Wait for a reply... */
6523 /* Return the good/bad news */
6524 return (vam->retval);
6528 api_mpls_ip_bind_unbind (vat_main_t * vam)
6530 unformat_input_t *i = vam->input;
6531 vl_api_mpls_ip_bind_unbind_t *mp;
6533 u32 ip_table_id = 0;
6534 u8 create_table_if_needed = 0;
6537 ip4_address_t v4_address;
6538 ip6_address_t v6_address;
6541 mpls_label_t local_label = MPLS_LABEL_INVALID;
6543 /* Parse args required to build the message */
6544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6546 if (unformat (i, "%U/%d", unformat_ip4_address,
6547 &v4_address, &address_length))
6552 else if (unformat (i, "%U/%d", unformat_ip6_address,
6553 &v6_address, &address_length))
6558 else if (unformat (i, "%d", &local_label))
6560 else if (unformat (i, "create-table"))
6561 create_table_if_needed = 1;
6562 else if (unformat (i, "table-id %d", &ip_table_id))
6564 else if (unformat (i, "unbind"))
6566 else if (unformat (i, "bind"))
6570 clib_warning ("parse error '%U'", format_unformat_error, i);
6577 errmsg ("IP addres not set");
6581 if (MPLS_LABEL_INVALID == local_label)
6583 errmsg ("missing label");
6587 /* Construct the API message */
6588 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6590 mp->mb_create_table_if_needed = create_table_if_needed;
6591 mp->mb_is_bind = is_bind;
6592 mp->mb_is_ip4 = is_ip4;
6593 mp->mb_ip_table_id = ntohl (ip_table_id);
6594 mp->mb_mpls_table_id = 0;
6595 mp->mb_label = ntohl (local_label);
6596 mp->mb_address_length = address_length;
6599 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6601 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6606 /* Wait for a reply... */
6611 api_proxy_arp_add_del (vat_main_t * vam)
6613 unformat_input_t *i = vam->input;
6614 vl_api_proxy_arp_add_del_t *mp;
6618 ip4_address_t lo, hi;
6621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6623 if (unformat (i, "vrf %d", &vrf_id))
6625 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6626 unformat_ip4_address, &hi))
6628 else if (unformat (i, "del"))
6632 clib_warning ("parse error '%U'", format_unformat_error, i);
6639 errmsg ("address range not set");
6643 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6645 mp->vrf_id = ntohl (vrf_id);
6646 mp->is_add = is_add;
6647 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6648 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6657 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6659 unformat_input_t *i = vam->input;
6660 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6664 u8 sw_if_index_set = 0;
6666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6669 sw_if_index_set = 1;
6670 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6671 sw_if_index_set = 1;
6672 else if (unformat (i, "enable"))
6674 else if (unformat (i, "disable"))
6678 clib_warning ("parse error '%U'", format_unformat_error, i);
6683 if (sw_if_index_set == 0)
6685 errmsg ("missing interface name or sw_if_index");
6689 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6691 mp->sw_if_index = ntohl (sw_if_index);
6692 mp->enable_disable = enable;
6701 api_mpls_tunnel_add_del (vat_main_t * vam)
6703 unformat_input_t *i = vam->input;
6704 vl_api_mpls_tunnel_add_del_t *mp;
6709 u32 sw_if_index = ~0;
6710 u32 next_hop_sw_if_index = ~0;
6711 u32 next_hop_proto_is_ip4 = 1;
6713 u32 next_hop_table_id = 0;
6714 ip4_address_t v4_next_hop_address = {
6717 ip6_address_t v6_next_hop_address = { {0} };
6718 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6722 if (unformat (i, "add"))
6724 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6726 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6728 else if (unformat (i, "via %U",
6729 unformat_ip4_address, &v4_next_hop_address))
6731 next_hop_proto_is_ip4 = 1;
6733 else if (unformat (i, "via %U",
6734 unformat_ip6_address, &v6_next_hop_address))
6736 next_hop_proto_is_ip4 = 0;
6738 else if (unformat (i, "l2-only"))
6740 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6742 else if (unformat (i, "out-label %d", &next_hop_out_label))
6743 vec_add1 (labels, ntohl (next_hop_out_label));
6746 clib_warning ("parse error '%U'", format_unformat_error, i);
6751 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6752 sizeof (mpls_label_t) * vec_len (labels));
6754 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6755 mp->mt_sw_if_index = ntohl (sw_if_index);
6756 mp->mt_is_add = is_add;
6757 mp->mt_l2_only = l2_only;
6758 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6759 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6761 mp->mt_next_hop_n_out_labels = vec_len (labels);
6763 if (0 != mp->mt_next_hop_n_out_labels)
6765 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6766 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6770 if (next_hop_proto_is_ip4)
6772 clib_memcpy (mp->mt_next_hop,
6773 &v4_next_hop_address, sizeof (v4_next_hop_address));
6777 clib_memcpy (mp->mt_next_hop,
6778 &v6_next_hop_address, sizeof (v6_next_hop_address));
6788 api_sw_interface_set_unnumbered (vat_main_t * vam)
6790 unformat_input_t *i = vam->input;
6791 vl_api_sw_interface_set_unnumbered_t *mp;
6794 u32 unnum_sw_index = ~0;
6796 u8 sw_if_index_set = 0;
6798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6800 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6801 sw_if_index_set = 1;
6802 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6803 sw_if_index_set = 1;
6804 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6806 else if (unformat (i, "del"))
6810 clib_warning ("parse error '%U'", format_unformat_error, i);
6815 if (sw_if_index_set == 0)
6817 errmsg ("missing interface name or sw_if_index");
6821 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6823 mp->sw_if_index = ntohl (sw_if_index);
6824 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6825 mp->is_add = is_add;
6834 api_ip_neighbor_add_del (vat_main_t * vam)
6836 unformat_input_t *i = vam->input;
6837 vl_api_ip_neighbor_add_del_t *mp;
6840 u8 sw_if_index_set = 0;
6846 u8 v4_address_set = 0;
6847 u8 v6_address_set = 0;
6848 ip4_address_t v4address;
6849 ip6_address_t v6address;
6851 memset (mac_address, 0, sizeof (mac_address));
6853 /* Parse args required to build the message */
6854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6856 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6860 else if (unformat (i, "del"))
6863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6864 sw_if_index_set = 1;
6865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6866 sw_if_index_set = 1;
6867 else if (unformat (i, "is_static"))
6869 else if (unformat (i, "vrf %d", &vrf_id))
6871 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6873 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6877 clib_warning ("parse error '%U'", format_unformat_error, i);
6882 if (sw_if_index_set == 0)
6884 errmsg ("missing interface name or sw_if_index");
6887 if (v4_address_set && v6_address_set)
6889 errmsg ("both v4 and v6 addresses set");
6892 if (!v4_address_set && !v6_address_set)
6894 errmsg ("no address set");
6898 /* Construct the API message */
6899 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6901 mp->sw_if_index = ntohl (sw_if_index);
6902 mp->is_add = is_add;
6903 mp->vrf_id = ntohl (vrf_id);
6904 mp->is_static = is_static;
6906 clib_memcpy (mp->mac_address, mac_address, 6);
6910 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6914 /* mp->is_ipv6 = 0; via memset in M macro above */
6915 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6921 /* Wait for a reply, return good/bad news */
6929 api_reset_vrf (vat_main_t * vam)
6931 unformat_input_t *i = vam->input;
6932 vl_api_reset_vrf_t *mp;
6938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6940 if (unformat (i, "vrf %d", &vrf_id))
6942 else if (unformat (i, "ipv6"))
6946 clib_warning ("parse error '%U'", format_unformat_error, i);
6951 if (vrf_id_set == 0)
6953 errmsg ("missing vrf id");
6957 M (RESET_VRF, reset_vrf);
6959 mp->vrf_id = ntohl (vrf_id);
6960 mp->is_ipv6 = is_ipv6;
6969 api_create_vlan_subif (vat_main_t * vam)
6971 unformat_input_t *i = vam->input;
6972 vl_api_create_vlan_subif_t *mp;
6975 u8 sw_if_index_set = 0;
6979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6981 if (unformat (i, "sw_if_index %d", &sw_if_index))
6982 sw_if_index_set = 1;
6984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6985 sw_if_index_set = 1;
6986 else if (unformat (i, "vlan %d", &vlan_id))
6990 clib_warning ("parse error '%U'", format_unformat_error, i);
6995 if (sw_if_index_set == 0)
6997 errmsg ("missing interface name or sw_if_index");
7001 if (vlan_id_set == 0)
7003 errmsg ("missing vlan_id");
7006 M (CREATE_VLAN_SUBIF, create_vlan_subif);
7008 mp->sw_if_index = ntohl (sw_if_index);
7009 mp->vlan_id = ntohl (vlan_id);
7017 #define foreach_create_subif_bit \
7024 _(outer_vlan_id_any) \
7025 _(inner_vlan_id_any)
7028 api_create_subif (vat_main_t * vam)
7030 unformat_input_t *i = vam->input;
7031 vl_api_create_subif_t *mp;
7034 u8 sw_if_index_set = 0;
7041 u32 exact_match = 0;
7042 u32 default_sub = 0;
7043 u32 outer_vlan_id_any = 0;
7044 u32 inner_vlan_id_any = 0;
7046 u16 outer_vlan_id = 0;
7047 u16 inner_vlan_id = 0;
7049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7051 if (unformat (i, "sw_if_index %d", &sw_if_index))
7052 sw_if_index_set = 1;
7054 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7055 sw_if_index_set = 1;
7056 else if (unformat (i, "sub_id %d", &sub_id))
7058 else if (unformat (i, "outer_vlan_id %d", &tmp))
7059 outer_vlan_id = tmp;
7060 else if (unformat (i, "inner_vlan_id %d", &tmp))
7061 inner_vlan_id = tmp;
7063 #define _(a) else if (unformat (i, #a)) a = 1 ;
7064 foreach_create_subif_bit
7068 clib_warning ("parse error '%U'", format_unformat_error, i);
7073 if (sw_if_index_set == 0)
7075 errmsg ("missing interface name or sw_if_index");
7079 if (sub_id_set == 0)
7081 errmsg ("missing sub_id");
7084 M (CREATE_SUBIF, create_subif);
7086 mp->sw_if_index = ntohl (sw_if_index);
7087 mp->sub_id = ntohl (sub_id);
7089 #define _(a) mp->a = a;
7090 foreach_create_subif_bit;
7093 mp->outer_vlan_id = ntohs (outer_vlan_id);
7094 mp->inner_vlan_id = ntohs (inner_vlan_id);
7103 api_oam_add_del (vat_main_t * vam)
7105 unformat_input_t *i = vam->input;
7106 vl_api_oam_add_del_t *mp;
7110 ip4_address_t src, dst;
7114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7116 if (unformat (i, "vrf %d", &vrf_id))
7118 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7120 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7122 else if (unformat (i, "del"))
7126 clib_warning ("parse error '%U'", format_unformat_error, i);
7133 errmsg ("missing src addr");
7139 errmsg ("missing dst addr");
7143 M (OAM_ADD_DEL, oam_add_del);
7145 mp->vrf_id = ntohl (vrf_id);
7146 mp->is_add = is_add;
7147 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7148 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7157 api_reset_fib (vat_main_t * vam)
7159 unformat_input_t *i = vam->input;
7160 vl_api_reset_fib_t *mp;
7166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7168 if (unformat (i, "vrf %d", &vrf_id))
7170 else if (unformat (i, "ipv6"))
7174 clib_warning ("parse error '%U'", format_unformat_error, i);
7179 if (vrf_id_set == 0)
7181 errmsg ("missing vrf id");
7185 M (RESET_FIB, reset_fib);
7187 mp->vrf_id = ntohl (vrf_id);
7188 mp->is_ipv6 = is_ipv6;
7197 api_dhcp_proxy_config (vat_main_t * vam)
7199 unformat_input_t *i = vam->input;
7200 vl_api_dhcp_proxy_config_t *mp;
7205 u8 v4_address_set = 0;
7206 u8 v6_address_set = 0;
7207 ip4_address_t v4address;
7208 ip6_address_t v6address;
7209 u8 v4_src_address_set = 0;
7210 u8 v6_src_address_set = 0;
7211 ip4_address_t v4srcaddress;
7212 ip6_address_t v6srcaddress;
7214 /* Parse args required to build the message */
7215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7217 if (unformat (i, "del"))
7219 else if (unformat (i, "vrf %d", &vrf_id))
7221 else if (unformat (i, "insert-cid %d", &insert_cid))
7223 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7225 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7227 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7228 v4_src_address_set = 1;
7229 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7230 v6_src_address_set = 1;
7235 if (v4_address_set && v6_address_set)
7237 errmsg ("both v4 and v6 server addresses set");
7240 if (!v4_address_set && !v6_address_set)
7242 errmsg ("no server addresses set");
7246 if (v4_src_address_set && v6_src_address_set)
7248 errmsg ("both v4 and v6 src addresses set");
7251 if (!v4_src_address_set && !v6_src_address_set)
7253 errmsg ("no src addresses set");
7257 if (!(v4_src_address_set && v4_address_set) &&
7258 !(v6_src_address_set && v6_address_set))
7260 errmsg ("no matching server and src addresses set");
7264 /* Construct the API message */
7265 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7267 mp->insert_circuit_id = insert_cid;
7268 mp->is_add = is_add;
7269 mp->vrf_id = ntohl (vrf_id);
7273 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7274 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7278 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7279 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7285 /* Wait for a reply, return good/bad news */
7292 api_dhcp_proxy_config_2 (vat_main_t * vam)
7294 unformat_input_t *i = vam->input;
7295 vl_api_dhcp_proxy_config_2_t *mp;
7298 u32 server_vrf_id = 0;
7301 u8 v4_address_set = 0;
7302 u8 v6_address_set = 0;
7303 ip4_address_t v4address;
7304 ip6_address_t v6address;
7305 u8 v4_src_address_set = 0;
7306 u8 v6_src_address_set = 0;
7307 ip4_address_t v4srcaddress;
7308 ip6_address_t v6srcaddress;
7310 /* Parse args required to build the message */
7311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7313 if (unformat (i, "del"))
7315 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7317 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7319 else if (unformat (i, "insert-cid %d", &insert_cid))
7321 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7323 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7325 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7326 v4_src_address_set = 1;
7327 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7328 v6_src_address_set = 1;
7333 if (v4_address_set && v6_address_set)
7335 errmsg ("both v4 and v6 server addresses set");
7338 if (!v4_address_set && !v6_address_set)
7340 errmsg ("no server addresses set");
7344 if (v4_src_address_set && v6_src_address_set)
7346 errmsg ("both v4 and v6 src addresses set");
7349 if (!v4_src_address_set && !v6_src_address_set)
7351 errmsg ("no src addresses set");
7355 if (!(v4_src_address_set && v4_address_set) &&
7356 !(v6_src_address_set && v6_address_set))
7358 errmsg ("no matching server and src addresses set");
7362 /* Construct the API message */
7363 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7365 mp->insert_circuit_id = insert_cid;
7366 mp->is_add = is_add;
7367 mp->rx_vrf_id = ntohl (rx_vrf_id);
7368 mp->server_vrf_id = ntohl (server_vrf_id);
7372 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7373 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7377 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7378 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7384 /* Wait for a reply, return good/bad news */
7391 api_dhcp_proxy_set_vss (vat_main_t * vam)
7393 unformat_input_t *i = vam->input;
7394 vl_api_dhcp_proxy_set_vss_t *mp;
7405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7407 if (unformat (i, "tbl_id %d", &tbl_id))
7409 if (unformat (i, "fib_id %d", &fib_id))
7411 if (unformat (i, "oui %d", &oui))
7413 else if (unformat (i, "ipv6"))
7415 else if (unformat (i, "del"))
7419 clib_warning ("parse error '%U'", format_unformat_error, i);
7424 if (tbl_id_set == 0)
7426 errmsg ("missing tbl id");
7430 if (fib_id_set == 0)
7432 errmsg ("missing fib id");
7437 errmsg ("missing oui");
7441 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7442 mp->tbl_id = ntohl (tbl_id);
7443 mp->fib_id = ntohl (fib_id);
7444 mp->oui = ntohl (oui);
7445 mp->is_ipv6 = is_ipv6;
7446 mp->is_add = is_add;
7455 api_dhcp_client_config (vat_main_t * vam)
7457 unformat_input_t *i = vam->input;
7458 vl_api_dhcp_client_config_t *mp;
7461 u8 sw_if_index_set = 0;
7464 u8 disable_event = 0;
7466 /* Parse args required to build the message */
7467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7469 if (unformat (i, "del"))
7472 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7473 sw_if_index_set = 1;
7474 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7475 sw_if_index_set = 1;
7476 else if (unformat (i, "hostname %s", &hostname))
7478 else if (unformat (i, "disable_event"))
7484 if (sw_if_index_set == 0)
7486 errmsg ("missing interface name or sw_if_index");
7490 if (vec_len (hostname) > 63)
7492 errmsg ("hostname too long");
7494 vec_add1 (hostname, 0);
7496 /* Construct the API message */
7497 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7499 mp->sw_if_index = ntohl (sw_if_index);
7500 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7501 vec_free (hostname);
7502 mp->is_add = is_add;
7503 mp->want_dhcp_event = disable_event ? 0 : 1;
7504 mp->pid = getpid ();
7509 /* Wait for a reply, return good/bad news */
7516 api_set_ip_flow_hash (vat_main_t * vam)
7518 unformat_input_t *i = vam->input;
7519 vl_api_set_ip_flow_hash_t *mp;
7531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7533 if (unformat (i, "vrf %d", &vrf_id))
7535 else if (unformat (i, "ipv6"))
7537 else if (unformat (i, "src"))
7539 else if (unformat (i, "dst"))
7541 else if (unformat (i, "sport"))
7543 else if (unformat (i, "dport"))
7545 else if (unformat (i, "proto"))
7547 else if (unformat (i, "reverse"))
7552 clib_warning ("parse error '%U'", format_unformat_error, i);
7557 if (vrf_id_set == 0)
7559 errmsg ("missing vrf id");
7563 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7569 mp->reverse = reverse;
7570 mp->vrf_id = ntohl (vrf_id);
7571 mp->is_ipv6 = is_ipv6;
7580 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7582 unformat_input_t *i = vam->input;
7583 vl_api_sw_interface_ip6_enable_disable_t *mp;
7586 u8 sw_if_index_set = 0;
7589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7591 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7592 sw_if_index_set = 1;
7593 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7594 sw_if_index_set = 1;
7595 else if (unformat (i, "enable"))
7597 else if (unformat (i, "disable"))
7601 clib_warning ("parse error '%U'", format_unformat_error, i);
7606 if (sw_if_index_set == 0)
7608 errmsg ("missing interface name or sw_if_index");
7612 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7614 mp->sw_if_index = ntohl (sw_if_index);
7615 mp->enable = enable;
7624 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7626 unformat_input_t *i = vam->input;
7627 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7630 u8 sw_if_index_set = 0;
7631 u32 address_length = 0;
7632 u8 v6_address_set = 0;
7633 ip6_address_t v6address;
7635 /* Parse args required to build the message */
7636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7638 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7639 sw_if_index_set = 1;
7640 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7641 sw_if_index_set = 1;
7642 else if (unformat (i, "%U/%d",
7643 unformat_ip6_address, &v6address, &address_length))
7649 if (sw_if_index_set == 0)
7651 errmsg ("missing interface name or sw_if_index");
7654 if (!v6_address_set)
7656 errmsg ("no address set");
7660 /* Construct the API message */
7661 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7662 sw_interface_ip6_set_link_local_address);
7664 mp->sw_if_index = ntohl (sw_if_index);
7665 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7666 mp->address_length = address_length;
7671 /* Wait for a reply, return good/bad news */
7680 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7682 unformat_input_t *i = vam->input;
7683 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7686 u8 sw_if_index_set = 0;
7687 u32 address_length = 0;
7688 u8 v6_address_set = 0;
7689 ip6_address_t v6address;
7691 u8 no_advertise = 0;
7693 u8 no_autoconfig = 0;
7696 u32 val_lifetime = 0;
7697 u32 pref_lifetime = 0;
7699 /* Parse args required to build the message */
7700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7703 sw_if_index_set = 1;
7704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7705 sw_if_index_set = 1;
7706 else if (unformat (i, "%U/%d",
7707 unformat_ip6_address, &v6address, &address_length))
7709 else if (unformat (i, "val_life %d", &val_lifetime))
7711 else if (unformat (i, "pref_life %d", &pref_lifetime))
7713 else if (unformat (i, "def"))
7715 else if (unformat (i, "noadv"))
7717 else if (unformat (i, "offl"))
7719 else if (unformat (i, "noauto"))
7721 else if (unformat (i, "nolink"))
7723 else if (unformat (i, "isno"))
7727 clib_warning ("parse error '%U'", format_unformat_error, i);
7732 if (sw_if_index_set == 0)
7734 errmsg ("missing interface name or sw_if_index");
7737 if (!v6_address_set)
7739 errmsg ("no address set");
7743 /* Construct the API message */
7744 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7746 mp->sw_if_index = ntohl (sw_if_index);
7747 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7748 mp->address_length = address_length;
7749 mp->use_default = use_default;
7750 mp->no_advertise = no_advertise;
7751 mp->off_link = off_link;
7752 mp->no_autoconfig = no_autoconfig;
7753 mp->no_onlink = no_onlink;
7755 mp->val_lifetime = ntohl (val_lifetime);
7756 mp->pref_lifetime = ntohl (pref_lifetime);
7761 /* Wait for a reply, return good/bad news */
7769 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7771 unformat_input_t *i = vam->input;
7772 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7775 u8 sw_if_index_set = 0;
7780 u8 send_unicast = 0;
7783 u8 default_router = 0;
7784 u32 max_interval = 0;
7785 u32 min_interval = 0;
7787 u32 initial_count = 0;
7788 u32 initial_interval = 0;
7791 /* Parse args required to build the message */
7792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7794 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7795 sw_if_index_set = 1;
7796 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7797 sw_if_index_set = 1;
7798 else if (unformat (i, "maxint %d", &max_interval))
7800 else if (unformat (i, "minint %d", &min_interval))
7802 else if (unformat (i, "life %d", &lifetime))
7804 else if (unformat (i, "count %d", &initial_count))
7806 else if (unformat (i, "interval %d", &initial_interval))
7808 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7810 else if (unformat (i, "managed"))
7812 else if (unformat (i, "other"))
7814 else if (unformat (i, "ll"))
7816 else if (unformat (i, "send"))
7818 else if (unformat (i, "cease"))
7820 else if (unformat (i, "isno"))
7822 else if (unformat (i, "def"))
7826 clib_warning ("parse error '%U'", format_unformat_error, i);
7831 if (sw_if_index_set == 0)
7833 errmsg ("missing interface name or sw_if_index");
7837 /* Construct the API message */
7838 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7840 mp->sw_if_index = ntohl (sw_if_index);
7841 mp->max_interval = ntohl (max_interval);
7842 mp->min_interval = ntohl (min_interval);
7843 mp->lifetime = ntohl (lifetime);
7844 mp->initial_count = ntohl (initial_count);
7845 mp->initial_interval = ntohl (initial_interval);
7846 mp->suppress = suppress;
7847 mp->managed = managed;
7849 mp->ll_option = ll_option;
7850 mp->send_unicast = send_unicast;
7853 mp->default_router = default_router;
7858 /* Wait for a reply, return good/bad news */
7866 api_set_arp_neighbor_limit (vat_main_t * vam)
7868 unformat_input_t *i = vam->input;
7869 vl_api_set_arp_neighbor_limit_t *mp;
7875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7877 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7879 else if (unformat (i, "ipv6"))
7883 clib_warning ("parse error '%U'", format_unformat_error, i);
7890 errmsg ("missing limit value");
7894 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7896 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7897 mp->is_ipv6 = is_ipv6;
7906 api_l2_patch_add_del (vat_main_t * vam)
7908 unformat_input_t *i = vam->input;
7909 vl_api_l2_patch_add_del_t *mp;
7912 u8 rx_sw_if_index_set = 0;
7914 u8 tx_sw_if_index_set = 0;
7917 /* Parse args required to build the message */
7918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7920 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7921 rx_sw_if_index_set = 1;
7922 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7923 tx_sw_if_index_set = 1;
7924 else if (unformat (i, "rx"))
7926 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7928 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7930 rx_sw_if_index_set = 1;
7935 else if (unformat (i, "tx"))
7937 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7939 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7941 tx_sw_if_index_set = 1;
7946 else if (unformat (i, "del"))
7952 if (rx_sw_if_index_set == 0)
7954 errmsg ("missing rx interface name or rx_sw_if_index");
7958 if (tx_sw_if_index_set == 0)
7960 errmsg ("missing tx interface name or tx_sw_if_index");
7964 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7966 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7967 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7968 mp->is_add = is_add;
7977 api_ioam_enable (vat_main_t * vam)
7979 unformat_input_t *input = vam->input;
7980 vl_api_ioam_enable_t *mp;
7983 int has_trace_option = 0;
7984 int has_pot_option = 0;
7985 int has_seqno_option = 0;
7986 int has_analyse_option = 0;
7988 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7990 if (unformat (input, "trace"))
7991 has_trace_option = 1;
7992 else if (unformat (input, "pot"))
7994 else if (unformat (input, "seqno"))
7995 has_seqno_option = 1;
7996 else if (unformat (input, "analyse"))
7997 has_analyse_option = 1;
8001 M (IOAM_ENABLE, ioam_enable);
8002 mp->id = htons (id);
8003 mp->seqno = has_seqno_option;
8004 mp->analyse = has_analyse_option;
8005 mp->pot_enable = has_pot_option;
8006 mp->trace_enable = has_trace_option;
8017 api_ioam_disable (vat_main_t * vam)
8019 vl_api_ioam_disable_t *mp;
8022 M (IOAM_DISABLE, ioam_disable);
8029 api_sr_tunnel_add_del (vat_main_t * vam)
8031 unformat_input_t *i = vam->input;
8032 vl_api_sr_tunnel_add_del_t *mp;
8036 ip6_address_t src_address;
8037 int src_address_set = 0;
8038 ip6_address_t dst_address;
8040 int dst_address_set = 0;
8042 u32 rx_table_id = 0;
8043 u32 tx_table_id = 0;
8044 ip6_address_t *segments = 0;
8045 ip6_address_t *this_seg;
8046 ip6_address_t *tags = 0;
8047 ip6_address_t *this_tag;
8048 ip6_address_t next_address, tag;
8050 u8 *policy_name = 0;
8052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8054 if (unformat (i, "del"))
8056 else if (unformat (i, "name %s", &name))
8058 else if (unformat (i, "policy %s", &policy_name))
8060 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8062 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8064 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8065 src_address_set = 1;
8066 else if (unformat (i, "dst %U/%d",
8067 unformat_ip6_address, &dst_address, &dst_mask_width))
8068 dst_address_set = 1;
8069 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8071 vec_add2 (segments, this_seg, 1);
8072 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8073 sizeof (*this_seg));
8075 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8077 vec_add2 (tags, this_tag, 1);
8078 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8080 else if (unformat (i, "clean"))
8081 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8082 else if (unformat (i, "protected"))
8083 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8084 else if (unformat (i, "InPE %d", &pl_index))
8086 if (pl_index <= 0 || pl_index > 4)
8088 pl_index_range_error:
8089 errmsg ("pl index %d out of range", pl_index);
8093 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8095 else if (unformat (i, "EgPE %d", &pl_index))
8097 if (pl_index <= 0 || pl_index > 4)
8098 goto pl_index_range_error;
8100 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8102 else if (unformat (i, "OrgSrc %d", &pl_index))
8104 if (pl_index <= 0 || pl_index > 4)
8105 goto pl_index_range_error;
8107 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8113 if (!src_address_set)
8115 errmsg ("src address required");
8119 if (!dst_address_set)
8121 errmsg ("dst address required");
8127 errmsg ("at least one sr segment required");
8131 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8132 vec_len (segments) * sizeof (ip6_address_t)
8133 + vec_len (tags) * sizeof (ip6_address_t));
8135 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8136 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8137 mp->dst_mask_width = dst_mask_width;
8138 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8139 mp->n_segments = vec_len (segments);
8140 mp->n_tags = vec_len (tags);
8141 mp->is_add = is_del == 0;
8142 clib_memcpy (mp->segs_and_tags, segments,
8143 vec_len (segments) * sizeof (ip6_address_t));
8144 clib_memcpy (mp->segs_and_tags +
8145 vec_len (segments) * sizeof (ip6_address_t), tags,
8146 vec_len (tags) * sizeof (ip6_address_t));
8148 mp->outer_vrf_id = ntohl (rx_table_id);
8149 mp->inner_vrf_id = ntohl (tx_table_id);
8150 memcpy (mp->name, name, vec_len (name));
8151 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8153 vec_free (segments);
8162 api_sr_policy_add_del (vat_main_t * vam)
8164 unformat_input_t *input = vam->input;
8165 vl_api_sr_policy_add_del_t *mp;
8169 u8 *tunnel_name = 0;
8170 u8 **tunnel_names = 0;
8175 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8176 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8180 if (unformat (input, "del"))
8182 else if (unformat (input, "name %s", &name))
8184 else if (unformat (input, "tunnel %s", &tunnel_name))
8188 vec_add1 (tunnel_names, tunnel_name);
8190 - length = #bytes to store in serial vector
8191 - +1 = byte to store that length
8193 tunnel_names_length += (vec_len (tunnel_name) + 1);
8204 errmsg ("policy name required");
8208 if ((!tunnel_set) && (!is_del))
8210 errmsg ("tunnel name required");
8214 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8218 mp->is_add = !is_del;
8220 memcpy (mp->name, name, vec_len (name));
8221 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8222 u8 *serial_orig = 0;
8223 vec_validate (serial_orig, tunnel_names_length);
8224 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8225 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8227 for (j = 0; j < vec_len (tunnel_names); j++)
8229 tun_name_len = vec_len (tunnel_names[j]);
8230 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8231 serial_orig += 1; // Move along one byte to store the actual tunnel name
8232 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8233 serial_orig += tun_name_len; // Advance past the copy
8235 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8237 vec_free (tunnel_names);
8238 vec_free (tunnel_name);
8246 api_sr_multicast_map_add_del (vat_main_t * vam)
8248 unformat_input_t *input = vam->input;
8249 vl_api_sr_multicast_map_add_del_t *mp;
8252 ip6_address_t multicast_address;
8253 u8 *policy_name = 0;
8254 int multicast_address_set = 0;
8256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8258 if (unformat (input, "del"))
8262 (input, "address %U", unformat_ip6_address, &multicast_address))
8263 multicast_address_set = 1;
8264 else if (unformat (input, "sr-policy %s", &policy_name))
8270 if (!is_del && !policy_name)
8272 errmsg ("sr-policy name required");
8277 if (!multicast_address_set)
8279 errmsg ("address required");
8283 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8285 mp->is_add = !is_del;
8286 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8287 clib_memcpy (mp->multicast_address, &multicast_address,
8288 sizeof (mp->multicast_address));
8291 vec_free (policy_name);
8299 #define foreach_tcp_proto_field \
8303 #define foreach_udp_proto_field \
8307 #define foreach_ip4_proto_field \
8318 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8320 u8 **maskp = va_arg (*args, u8 **);
8322 u8 found_something = 0;
8325 #define _(a) u8 a=0;
8326 foreach_tcp_proto_field;
8329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8332 #define _(a) else if (unformat (input, #a)) a=1;
8333 foreach_tcp_proto_field
8339 #define _(a) found_something += a;
8340 foreach_tcp_proto_field;
8343 if (found_something == 0)
8346 vec_validate (mask, sizeof (*tcp) - 1);
8348 tcp = (tcp_header_t *) mask;
8350 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8351 foreach_tcp_proto_field;
8359 unformat_udp_mask (unformat_input_t * input, va_list * args)
8361 u8 **maskp = va_arg (*args, u8 **);
8363 u8 found_something = 0;
8366 #define _(a) u8 a=0;
8367 foreach_udp_proto_field;
8370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8373 #define _(a) else if (unformat (input, #a)) a=1;
8374 foreach_udp_proto_field
8380 #define _(a) found_something += a;
8381 foreach_udp_proto_field;
8384 if (found_something == 0)
8387 vec_validate (mask, sizeof (*udp) - 1);
8389 udp = (udp_header_t *) mask;
8391 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8392 foreach_udp_proto_field;
8401 u16 src_port, dst_port;
8405 unformat_l4_mask (unformat_input_t * input, va_list * args)
8407 u8 **maskp = va_arg (*args, u8 **);
8408 u16 src_port = 0, dst_port = 0;
8409 tcpudp_header_t *tcpudp;
8411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8413 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8415 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8417 else if (unformat (input, "src_port"))
8419 else if (unformat (input, "dst_port"))
8425 if (!src_port && !dst_port)
8429 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8431 tcpudp = (tcpudp_header_t *) mask;
8432 tcpudp->src_port = src_port;
8433 tcpudp->dst_port = dst_port;
8441 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8443 u8 **maskp = va_arg (*args, u8 **);
8445 u8 found_something = 0;
8448 #define _(a) u8 a=0;
8449 foreach_ip4_proto_field;
8455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8457 if (unformat (input, "version"))
8459 else if (unformat (input, "hdr_length"))
8461 else if (unformat (input, "src"))
8463 else if (unformat (input, "dst"))
8465 else if (unformat (input, "proto"))
8468 #define _(a) else if (unformat (input, #a)) a=1;
8469 foreach_ip4_proto_field
8475 #define _(a) found_something += a;
8476 foreach_ip4_proto_field;
8479 if (found_something == 0)
8482 vec_validate (mask, sizeof (*ip) - 1);
8484 ip = (ip4_header_t *) mask;
8486 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8487 foreach_ip4_proto_field;
8490 ip->ip_version_and_header_length = 0;
8493 ip->ip_version_and_header_length |= 0xF0;
8496 ip->ip_version_and_header_length |= 0x0F;
8502 #define foreach_ip6_proto_field \
8510 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8512 u8 **maskp = va_arg (*args, u8 **);
8514 u8 found_something = 0;
8516 u32 ip_version_traffic_class_and_flow_label;
8518 #define _(a) u8 a=0;
8519 foreach_ip6_proto_field;
8522 u8 traffic_class = 0;
8525 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8527 if (unformat (input, "version"))
8529 else if (unformat (input, "traffic-class"))
8531 else if (unformat (input, "flow-label"))
8533 else if (unformat (input, "src"))
8535 else if (unformat (input, "dst"))
8537 else if (unformat (input, "proto"))
8540 #define _(a) else if (unformat (input, #a)) a=1;
8541 foreach_ip6_proto_field
8547 #define _(a) found_something += a;
8548 foreach_ip6_proto_field;
8551 if (found_something == 0)
8554 vec_validate (mask, sizeof (*ip) - 1);
8556 ip = (ip6_header_t *) mask;
8558 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8559 foreach_ip6_proto_field;
8562 ip_version_traffic_class_and_flow_label = 0;
8565 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8568 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8571 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8573 ip->ip_version_traffic_class_and_flow_label =
8574 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8581 unformat_l3_mask (unformat_input_t * input, va_list * args)
8583 u8 **maskp = va_arg (*args, u8 **);
8585 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8587 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8589 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8598 unformat_l2_mask (unformat_input_t * input, va_list * args)
8600 u8 **maskp = va_arg (*args, u8 **);
8615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8617 if (unformat (input, "src"))
8619 else if (unformat (input, "dst"))
8621 else if (unformat (input, "proto"))
8623 else if (unformat (input, "tag1"))
8625 else if (unformat (input, "tag2"))
8627 else if (unformat (input, "ignore-tag1"))
8629 else if (unformat (input, "ignore-tag2"))
8631 else if (unformat (input, "cos1"))
8633 else if (unformat (input, "cos2"))
8635 else if (unformat (input, "dot1q"))
8637 else if (unformat (input, "dot1ad"))
8642 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8643 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8646 if (tag1 || ignore_tag1 || cos1 || dot1q)
8648 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8651 vec_validate (mask, len - 1);
8654 memset (mask, 0xff, 6);
8657 memset (mask + 6, 0xff, 6);
8661 /* inner vlan tag */
8670 mask[21] = mask[20] = 0xff;
8691 mask[16] = mask[17] = 0xff;
8701 mask[12] = mask[13] = 0xff;
8708 unformat_classify_mask (unformat_input_t * input, va_list * args)
8710 u8 **maskp = va_arg (*args, u8 **);
8711 u32 *skipp = va_arg (*args, u32 *);
8712 u32 *matchp = va_arg (*args, u32 *);
8720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8722 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8724 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8726 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8728 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8742 if (mask || l2 || l3 || l4)
8746 /* "With a free Ethernet header in every package" */
8748 vec_validate (l2, 13);
8752 vec_append (mask, l3);
8757 vec_append (mask, l4);
8762 /* Scan forward looking for the first significant mask octet */
8763 for (i = 0; i < vec_len (mask); i++)
8767 /* compute (skip, match) params */
8768 *skipp = i / sizeof (u32x4);
8769 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8771 /* Pad mask to an even multiple of the vector size */
8772 while (vec_len (mask) % sizeof (u32x4))
8775 match = vec_len (mask) / sizeof (u32x4);
8777 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8779 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8780 if (*tmp || *(tmp + 1))
8785 clib_warning ("BUG: match 0");
8787 _vec_len (mask) = match * sizeof (u32x4);
8798 #define foreach_l2_next \
8800 _(ethernet, ETHERNET_INPUT) \
8805 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8807 u32 *miss_next_indexp = va_arg (*args, u32 *);
8812 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8816 if (unformat (input, "%d", &tmp))
8825 *miss_next_indexp = next_index;
8829 #define foreach_ip_next \
8835 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8837 u32 *miss_next_indexp = va_arg (*args, u32 *);
8842 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8846 if (unformat (input, "%d", &tmp))
8855 *miss_next_indexp = next_index;
8859 #define foreach_acl_next \
8863 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8865 u32 *miss_next_indexp = va_arg (*args, u32 *);
8870 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8874 if (unformat (input, "permit"))
8879 else if (unformat (input, "%d", &tmp))
8888 *miss_next_indexp = next_index;
8893 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8895 u32 *r = va_arg (*args, u32 *);
8897 if (unformat (input, "conform-color"))
8898 *r = POLICE_CONFORM;
8899 else if (unformat (input, "exceed-color"))
8908 api_classify_add_del_table (vat_main_t * vam)
8910 unformat_input_t *i = vam->input;
8911 vl_api_classify_add_del_table_t *mp;
8918 u32 table_index = ~0;
8919 u32 next_table_index = ~0;
8920 u32 miss_next_index = ~0;
8921 u32 memory_size = 32 << 20;
8924 u32 current_data_flag = 0;
8925 int current_data_offset = 0;
8927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8929 if (unformat (i, "del"))
8931 else if (unformat (i, "del-chain"))
8936 else if (unformat (i, "buckets %d", &nbuckets))
8938 else if (unformat (i, "memory_size %d", &memory_size))
8940 else if (unformat (i, "skip %d", &skip))
8942 else if (unformat (i, "match %d", &match))
8944 else if (unformat (i, "table %d", &table_index))
8946 else if (unformat (i, "mask %U", unformat_classify_mask,
8947 &mask, &skip, &match))
8949 else if (unformat (i, "next-table %d", &next_table_index))
8951 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8954 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8957 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8960 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8962 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8968 if (is_add && mask == 0)
8970 errmsg ("Mask required");
8974 if (is_add && skip == ~0)
8976 errmsg ("skip count required");
8980 if (is_add && match == ~0)
8982 errmsg ("match count required");
8986 if (!is_add && table_index == ~0)
8988 errmsg ("table index required for delete");
8992 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8994 mp->is_add = is_add;
8995 mp->del_chain = del_chain;
8996 mp->table_index = ntohl (table_index);
8997 mp->nbuckets = ntohl (nbuckets);
8998 mp->memory_size = ntohl (memory_size);
8999 mp->skip_n_vectors = ntohl (skip);
9000 mp->match_n_vectors = ntohl (match);
9001 mp->next_table_index = ntohl (next_table_index);
9002 mp->miss_next_index = ntohl (miss_next_index);
9003 mp->current_data_flag = ntohl (current_data_flag);
9004 mp->current_data_offset = ntohl (current_data_offset);
9005 clib_memcpy (mp->mask, mask, vec_len (mask));
9015 unformat_l4_match (unformat_input_t * input, va_list * args)
9017 u8 **matchp = va_arg (*args, u8 **);
9019 u8 *proto_header = 0;
9025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9027 if (unformat (input, "src_port %d", &src_port))
9029 else if (unformat (input, "dst_port %d", &dst_port))
9035 h.src_port = clib_host_to_net_u16 (src_port);
9036 h.dst_port = clib_host_to_net_u16 (dst_port);
9037 vec_validate (proto_header, sizeof (h) - 1);
9038 memcpy (proto_header, &h, sizeof (h));
9040 *matchp = proto_header;
9046 unformat_ip4_match (unformat_input_t * input, va_list * args)
9048 u8 **matchp = va_arg (*args, u8 **);
9055 int src = 0, dst = 0;
9056 ip4_address_t src_val, dst_val;
9063 int fragment_id = 0;
9064 u32 fragment_id_val;
9070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9072 if (unformat (input, "version %d", &version_val))
9074 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9076 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9078 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9080 else if (unformat (input, "proto %d", &proto_val))
9082 else if (unformat (input, "tos %d", &tos_val))
9084 else if (unformat (input, "length %d", &length_val))
9086 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9088 else if (unformat (input, "ttl %d", &ttl_val))
9090 else if (unformat (input, "checksum %d", &checksum_val))
9096 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9097 + ttl + checksum == 0)
9101 * Aligned because we use the real comparison functions
9103 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9105 ip = (ip4_header_t *) match;
9107 /* These are realistically matched in practice */
9109 ip->src_address.as_u32 = src_val.as_u32;
9112 ip->dst_address.as_u32 = dst_val.as_u32;
9115 ip->protocol = proto_val;
9118 /* These are not, but they're included for completeness */
9120 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9123 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9129 ip->length = clib_host_to_net_u16 (length_val);
9135 ip->checksum = clib_host_to_net_u16 (checksum_val);
9142 unformat_ip6_match (unformat_input_t * input, va_list * args)
9144 u8 **matchp = va_arg (*args, u8 **);
9149 u8 traffic_class = 0;
9150 u32 traffic_class_val = 0;
9153 int src = 0, dst = 0;
9154 ip6_address_t src_val, dst_val;
9157 int payload_length = 0;
9158 u32 payload_length_val;
9161 u32 ip_version_traffic_class_and_flow_label;
9163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9165 if (unformat (input, "version %d", &version_val))
9167 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9169 else if (unformat (input, "flow_label %d", &flow_label_val))
9171 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9173 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9175 else if (unformat (input, "proto %d", &proto_val))
9177 else if (unformat (input, "payload_length %d", &payload_length_val))
9179 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9185 if (version + traffic_class + flow_label + src + dst + proto +
9186 payload_length + hop_limit == 0)
9190 * Aligned because we use the real comparison functions
9192 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9194 ip = (ip6_header_t *) match;
9197 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9200 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9203 ip->protocol = proto_val;
9205 ip_version_traffic_class_and_flow_label = 0;
9208 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9211 ip_version_traffic_class_and_flow_label |=
9212 (traffic_class_val & 0xFF) << 20;
9215 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9217 ip->ip_version_traffic_class_and_flow_label =
9218 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9221 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9224 ip->hop_limit = hop_limit_val;
9231 unformat_l3_match (unformat_input_t * input, va_list * args)
9233 u8 **matchp = va_arg (*args, u8 **);
9235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9237 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9239 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9248 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9250 u8 *tagp = va_arg (*args, u8 *);
9253 if (unformat (input, "%d", &tag))
9255 tagp[0] = (tag >> 8) & 0x0F;
9256 tagp[1] = tag & 0xFF;
9264 unformat_l2_match (unformat_input_t * input, va_list * args)
9266 u8 **matchp = va_arg (*args, u8 **);
9286 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9288 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9291 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9293 else if (unformat (input, "proto %U",
9294 unformat_ethernet_type_host_byte_order, &proto_val))
9296 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9298 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9300 else if (unformat (input, "ignore-tag1"))
9302 else if (unformat (input, "ignore-tag2"))
9304 else if (unformat (input, "cos1 %d", &cos1_val))
9306 else if (unformat (input, "cos2 %d", &cos2_val))
9311 if ((src + dst + proto + tag1 + tag2 +
9312 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9315 if (tag1 || ignore_tag1 || cos1)
9317 if (tag2 || ignore_tag2 || cos2)
9320 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9323 clib_memcpy (match, dst_val, 6);
9326 clib_memcpy (match + 6, src_val, 6);
9330 /* inner vlan tag */
9331 match[19] = tag2_val[1];
9332 match[18] = tag2_val[0];
9334 match[18] |= (cos2_val & 0x7) << 5;
9337 match[21] = proto_val & 0xff;
9338 match[20] = proto_val >> 8;
9342 match[15] = tag1_val[1];
9343 match[14] = tag1_val[0];
9346 match[14] |= (cos1_val & 0x7) << 5;
9352 match[15] = tag1_val[1];
9353 match[14] = tag1_val[0];
9356 match[17] = proto_val & 0xff;
9357 match[16] = proto_val >> 8;
9360 match[14] |= (cos1_val & 0x7) << 5;
9366 match[18] |= (cos2_val & 0x7) << 5;
9368 match[14] |= (cos1_val & 0x7) << 5;
9371 match[13] = proto_val & 0xff;
9372 match[12] = proto_val >> 8;
9381 unformat_classify_match (unformat_input_t * input, va_list * args)
9383 u8 **matchp = va_arg (*args, u8 **);
9384 u32 skip_n_vectors = va_arg (*args, u32);
9385 u32 match_n_vectors = va_arg (*args, u32);
9392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9394 if (unformat (input, "hex %U", unformat_hex_string, &match))
9396 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9398 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9400 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9414 if (match || l2 || l3 || l4)
9418 /* "Win a free Ethernet header in every packet" */
9420 vec_validate_aligned (l2, 13, sizeof (u32x4));
9424 vec_append_aligned (match, l3, sizeof (u32x4));
9429 vec_append_aligned (match, l4, sizeof (u32x4));
9434 /* Make sure the vector is big enough even if key is all 0's */
9435 vec_validate_aligned
9436 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9439 /* Set size, include skipped vectors */
9440 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9451 api_classify_add_del_session (vat_main_t * vam)
9453 unformat_input_t *i = vam->input;
9454 vl_api_classify_add_del_session_t *mp;
9456 u32 table_index = ~0;
9457 u32 hit_next_index = ~0;
9458 u32 opaque_index = ~0;
9462 u32 skip_n_vectors = 0;
9463 u32 match_n_vectors = 0;
9468 * Warning: you have to supply skip_n and match_n
9469 * because the API client cant simply look at the classify
9473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9475 if (unformat (i, "del"))
9477 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9480 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9483 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9486 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9488 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9490 else if (unformat (i, "opaque-index %d", &opaque_index))
9492 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9494 else if (unformat (i, "match_n %d", &match_n_vectors))
9496 else if (unformat (i, "match %U", unformat_classify_match,
9497 &match, skip_n_vectors, match_n_vectors))
9499 else if (unformat (i, "advance %d", &advance))
9501 else if (unformat (i, "table-index %d", &table_index))
9503 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9505 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9507 else if (unformat (i, "action %d", &action))
9509 else if (unformat (i, "metadata %d", &metadata))
9515 if (table_index == ~0)
9517 errmsg ("Table index required");
9521 if (is_add && match == 0)
9523 errmsg ("Match value required");
9527 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9529 mp->is_add = is_add;
9530 mp->table_index = ntohl (table_index);
9531 mp->hit_next_index = ntohl (hit_next_index);
9532 mp->opaque_index = ntohl (opaque_index);
9533 mp->advance = ntohl (advance);
9534 mp->action = action;
9535 mp->metadata = ntohl (metadata);
9536 clib_memcpy (mp->match, match, vec_len (match));
9545 api_classify_set_interface_ip_table (vat_main_t * vam)
9547 unformat_input_t *i = vam->input;
9548 vl_api_classify_set_interface_ip_table_t *mp;
9551 int sw_if_index_set;
9552 u32 table_index = ~0;
9555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9557 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9558 sw_if_index_set = 1;
9559 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9560 sw_if_index_set = 1;
9561 else if (unformat (i, "table %d", &table_index))
9565 clib_warning ("parse error '%U'", format_unformat_error, i);
9570 if (sw_if_index_set == 0)
9572 errmsg ("missing interface name or sw_if_index");
9577 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9579 mp->sw_if_index = ntohl (sw_if_index);
9580 mp->table_index = ntohl (table_index);
9581 mp->is_ipv6 = is_ipv6;
9590 api_classify_set_interface_l2_tables (vat_main_t * vam)
9592 unformat_input_t *i = vam->input;
9593 vl_api_classify_set_interface_l2_tables_t *mp;
9596 int sw_if_index_set;
9597 u32 ip4_table_index = ~0;
9598 u32 ip6_table_index = ~0;
9599 u32 other_table_index = ~0;
9602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9604 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9605 sw_if_index_set = 1;
9606 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9607 sw_if_index_set = 1;
9608 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9610 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9612 else if (unformat (i, "other-table %d", &other_table_index))
9614 else if (unformat (i, "is-input %d", &is_input))
9618 clib_warning ("parse error '%U'", format_unformat_error, i);
9623 if (sw_if_index_set == 0)
9625 errmsg ("missing interface name or sw_if_index");
9630 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9632 mp->sw_if_index = ntohl (sw_if_index);
9633 mp->ip4_table_index = ntohl (ip4_table_index);
9634 mp->ip6_table_index = ntohl (ip6_table_index);
9635 mp->other_table_index = ntohl (other_table_index);
9636 mp->is_input = (u8) is_input;
9645 api_set_ipfix_exporter (vat_main_t * vam)
9647 unformat_input_t *i = vam->input;
9648 vl_api_set_ipfix_exporter_t *mp;
9649 ip4_address_t collector_address;
9650 u8 collector_address_set = 0;
9651 u32 collector_port = ~0;
9652 ip4_address_t src_address;
9653 u8 src_address_set = 0;
9656 u32 template_interval = ~0;
9657 u8 udp_checksum = 0;
9660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9662 if (unformat (i, "collector_address %U", unformat_ip4_address,
9663 &collector_address))
9664 collector_address_set = 1;
9665 else if (unformat (i, "collector_port %d", &collector_port))
9667 else if (unformat (i, "src_address %U", unformat_ip4_address,
9669 src_address_set = 1;
9670 else if (unformat (i, "vrf_id %d", &vrf_id))
9672 else if (unformat (i, "path_mtu %d", &path_mtu))
9674 else if (unformat (i, "template_interval %d", &template_interval))
9676 else if (unformat (i, "udp_checksum"))
9682 if (collector_address_set == 0)
9684 errmsg ("collector_address required");
9688 if (src_address_set == 0)
9690 errmsg ("src_address required");
9694 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9696 memcpy (mp->collector_address, collector_address.data,
9697 sizeof (collector_address.data));
9698 mp->collector_port = htons ((u16) collector_port);
9699 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9700 mp->vrf_id = htonl (vrf_id);
9701 mp->path_mtu = htonl (path_mtu);
9702 mp->template_interval = htonl (template_interval);
9703 mp->udp_checksum = udp_checksum;
9711 api_set_ipfix_classify_stream (vat_main_t * vam)
9713 unformat_input_t *i = vam->input;
9714 vl_api_set_ipfix_classify_stream_t *mp;
9716 u32 src_port = UDP_DST_PORT_ipfix;
9719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9721 if (unformat (i, "domain %d", &domain_id))
9723 else if (unformat (i, "src_port %d", &src_port))
9727 errmsg ("unknown input `%U'", format_unformat_error, i);
9732 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9734 mp->domain_id = htonl (domain_id);
9735 mp->src_port = htons ((u16) src_port);
9743 api_ipfix_classify_table_add_del (vat_main_t * vam)
9745 unformat_input_t *i = vam->input;
9746 vl_api_ipfix_classify_table_add_del_t *mp;
9748 u32 classify_table_index = ~0;
9750 u8 transport_protocol = 255;
9753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9755 if (unformat (i, "add"))
9757 else if (unformat (i, "del"))
9759 else if (unformat (i, "table %d", &classify_table_index))
9761 else if (unformat (i, "ip4"))
9763 else if (unformat (i, "ip6"))
9765 else if (unformat (i, "tcp"))
9766 transport_protocol = 6;
9767 else if (unformat (i, "udp"))
9768 transport_protocol = 17;
9771 errmsg ("unknown input `%U'", format_unformat_error, i);
9778 errmsg ("expecting: add|del");
9781 if (classify_table_index == ~0)
9783 errmsg ("classifier table not specified");
9786 if (ip_version == 0)
9788 errmsg ("IP version not specified");
9792 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9794 mp->is_add = is_add;
9795 mp->table_id = htonl (classify_table_index);
9796 mp->ip_version = ip_version;
9797 mp->transport_protocol = transport_protocol;
9805 api_get_node_index (vat_main_t * vam)
9807 unformat_input_t *i = vam->input;
9808 vl_api_get_node_index_t *mp;
9812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9814 if (unformat (i, "node %s", &name))
9821 errmsg ("node name required");
9824 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9826 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9830 M (GET_NODE_INDEX, get_node_index);
9831 clib_memcpy (mp->node_name, name, vec_len (name));
9841 api_get_next_index (vat_main_t * vam)
9843 unformat_input_t *i = vam->input;
9844 vl_api_get_next_index_t *mp;
9846 u8 *node_name = 0, *next_node_name = 0;
9848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9850 if (unformat (i, "node-name %s", &node_name))
9852 else if (unformat (i, "next-node-name %s", &next_node_name))
9858 errmsg ("node name required");
9861 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9863 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9867 if (next_node_name == 0)
9869 errmsg ("next node name required");
9872 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9874 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9878 M (GET_NEXT_INDEX, get_next_index);
9879 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9880 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9881 vec_free (node_name);
9882 vec_free (next_node_name);
9891 api_add_node_next (vat_main_t * vam)
9893 unformat_input_t *i = vam->input;
9894 vl_api_add_node_next_t *mp;
9899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9901 if (unformat (i, "node %s", &name))
9903 else if (unformat (i, "next %s", &next))
9910 errmsg ("node name required");
9913 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9915 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9920 errmsg ("next node required");
9923 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9925 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9929 M (ADD_NODE_NEXT, add_node_next);
9930 clib_memcpy (mp->node_name, name, vec_len (name));
9931 clib_memcpy (mp->next_name, next, vec_len (next));
9942 api_l2tpv3_create_tunnel (vat_main_t * vam)
9944 unformat_input_t *i = vam->input;
9945 ip6_address_t client_address, our_address;
9946 int client_address_set = 0;
9947 int our_address_set = 0;
9948 u32 local_session_id = 0;
9949 u32 remote_session_id = 0;
9950 u64 local_cookie = 0;
9951 u64 remote_cookie = 0;
9952 u8 l2_sublayer_present = 0;
9953 vl_api_l2tpv3_create_tunnel_t *mp;
9956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9958 if (unformat (i, "client_address %U", unformat_ip6_address,
9960 client_address_set = 1;
9961 else if (unformat (i, "our_address %U", unformat_ip6_address,
9963 our_address_set = 1;
9964 else if (unformat (i, "local_session_id %d", &local_session_id))
9966 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9968 else if (unformat (i, "local_cookie %lld", &local_cookie))
9970 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9972 else if (unformat (i, "l2-sublayer-present"))
9973 l2_sublayer_present = 1;
9978 if (client_address_set == 0)
9980 errmsg ("client_address required");
9984 if (our_address_set == 0)
9986 errmsg ("our_address required");
9990 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9992 clib_memcpy (mp->client_address, client_address.as_u8,
9993 sizeof (mp->client_address));
9995 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9997 mp->local_session_id = ntohl (local_session_id);
9998 mp->remote_session_id = ntohl (remote_session_id);
9999 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10000 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10001 mp->l2_sublayer_present = l2_sublayer_present;
10011 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10013 unformat_input_t *i = vam->input;
10015 u8 sw_if_index_set = 0;
10016 u64 new_local_cookie = 0;
10017 u64 new_remote_cookie = 0;
10018 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10023 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10024 sw_if_index_set = 1;
10025 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10026 sw_if_index_set = 1;
10027 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10029 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10035 if (sw_if_index_set == 0)
10037 errmsg ("missing interface name or sw_if_index");
10041 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
10043 mp->sw_if_index = ntohl (sw_if_index);
10044 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10045 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10054 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10056 unformat_input_t *i = vam->input;
10057 vl_api_l2tpv3_interface_enable_disable_t *mp;
10060 u8 sw_if_index_set = 0;
10061 u8 enable_disable = 1;
10063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10065 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10066 sw_if_index_set = 1;
10067 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10068 sw_if_index_set = 1;
10069 else if (unformat (i, "enable"))
10070 enable_disable = 1;
10071 else if (unformat (i, "disable"))
10072 enable_disable = 0;
10077 if (sw_if_index_set == 0)
10079 errmsg ("missing interface name or sw_if_index");
10083 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10085 mp->sw_if_index = ntohl (sw_if_index);
10086 mp->enable_disable = enable_disable;
10095 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10097 unformat_input_t *i = vam->input;
10098 vl_api_l2tpv3_set_lookup_key_t *mp;
10102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10104 if (unformat (i, "lookup_v6_src"))
10105 key = L2T_LOOKUP_SRC_ADDRESS;
10106 else if (unformat (i, "lookup_v6_dst"))
10107 key = L2T_LOOKUP_DST_ADDRESS;
10108 else if (unformat (i, "lookup_session_id"))
10109 key = L2T_LOOKUP_SESSION_ID;
10114 if (key == (u8) ~ 0)
10116 errmsg ("l2tp session lookup key unset");
10120 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10130 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10131 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10133 vat_main_t *vam = &vat_main;
10135 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10136 format_ip6_address, mp->our_address,
10137 format_ip6_address, mp->client_address,
10138 clib_net_to_host_u32 (mp->sw_if_index));
10141 " local cookies %016llx %016llx remote cookie %016llx",
10142 clib_net_to_host_u64 (mp->local_cookie[0]),
10143 clib_net_to_host_u64 (mp->local_cookie[1]),
10144 clib_net_to_host_u64 (mp->remote_cookie));
10146 print (vam->ofp, " local session-id %d remote session-id %d",
10147 clib_net_to_host_u32 (mp->local_session_id),
10148 clib_net_to_host_u32 (mp->remote_session_id));
10150 print (vam->ofp, " l2 specific sublayer %s\n",
10151 mp->l2_sublayer_present ? "preset" : "absent");
10155 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10156 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10158 vat_main_t *vam = &vat_main;
10159 vat_json_node_t *node = NULL;
10160 struct in6_addr addr;
10162 if (VAT_JSON_ARRAY != vam->json_tree.type)
10164 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10165 vat_json_init_array (&vam->json_tree);
10167 node = vat_json_array_add (&vam->json_tree);
10169 vat_json_init_object (node);
10171 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10172 vat_json_object_add_ip6 (node, "our_address", addr);
10173 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10174 vat_json_object_add_ip6 (node, "client_address", addr);
10176 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10177 vat_json_init_array (lc);
10178 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10179 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10180 vat_json_object_add_uint (node, "remote_cookie",
10181 clib_net_to_host_u64 (mp->remote_cookie));
10183 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10184 vat_json_object_add_uint (node, "local_session_id",
10185 clib_net_to_host_u32 (mp->local_session_id));
10186 vat_json_object_add_uint (node, "remote_session_id",
10187 clib_net_to_host_u32 (mp->remote_session_id));
10188 vat_json_object_add_string_copy (node, "l2_sublayer",
10189 mp->l2_sublayer_present ? (u8 *) "present"
10190 : (u8 *) "absent");
10194 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10196 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10199 /* Get list of l2tpv3-tunnel interfaces */
10200 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10203 /* Use a control ping for synchronization */
10205 vl_api_control_ping_t *mp;
10206 M (CONTROL_PING, control_ping);
10213 static void vl_api_sw_interface_tap_details_t_handler
10214 (vl_api_sw_interface_tap_details_t * mp)
10216 vat_main_t *vam = &vat_main;
10218 print (vam->ofp, "%-16s %d",
10219 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10222 static void vl_api_sw_interface_tap_details_t_handler_json
10223 (vl_api_sw_interface_tap_details_t * mp)
10225 vat_main_t *vam = &vat_main;
10226 vat_json_node_t *node = NULL;
10228 if (VAT_JSON_ARRAY != vam->json_tree.type)
10230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10231 vat_json_init_array (&vam->json_tree);
10233 node = vat_json_array_add (&vam->json_tree);
10235 vat_json_init_object (node);
10236 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10237 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10241 api_sw_interface_tap_dump (vat_main_t * vam)
10243 vl_api_sw_interface_tap_dump_t *mp;
10246 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10247 /* Get list of tap interfaces */
10248 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10251 /* Use a control ping for synchronization */
10253 vl_api_control_ping_t *mp;
10254 M (CONTROL_PING, control_ping);
10260 static uword unformat_vxlan_decap_next
10261 (unformat_input_t * input, va_list * args)
10263 u32 *result = va_arg (*args, u32 *);
10266 if (unformat (input, "l2"))
10267 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10268 else if (unformat (input, "%d", &tmp))
10276 api_vxlan_add_del_tunnel (vat_main_t * vam)
10278 unformat_input_t *line_input = vam->input;
10279 vl_api_vxlan_add_del_tunnel_t *mp;
10281 ip46_address_t src, dst;
10283 u8 ipv4_set = 0, ipv6_set = 0;
10287 u32 mcast_sw_if_index = ~0;
10288 u32 encap_vrf_id = 0;
10289 u32 decap_next_index = ~0;
10292 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10293 memset (&src, 0, sizeof src);
10294 memset (&dst, 0, sizeof dst);
10296 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10298 if (unformat (line_input, "del"))
10301 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10307 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10313 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10319 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10324 else if (unformat (line_input, "group %U %U",
10325 unformat_ip4_address, &dst.ip4,
10326 api_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_ip4_address, &dst.ip4))
10334 grp_set = dst_set = 1;
10337 else if (unformat (line_input, "group %U %U",
10338 unformat_ip6_address, &dst.ip6,
10339 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10341 grp_set = dst_set = 1;
10344 else if (unformat (line_input, "group %U",
10345 unformat_ip6_address, &dst.ip6))
10347 grp_set = dst_set = 1;
10351 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10353 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10355 else if (unformat (line_input, "decap-next %U",
10356 unformat_vxlan_decap_next, &decap_next_index))
10358 else if (unformat (line_input, "vni %d", &vni))
10362 errmsg ("parse error '%U'", format_unformat_error, line_input);
10369 errmsg ("tunnel src address not specified");
10374 errmsg ("tunnel dst address not specified");
10378 if (grp_set && !ip46_address_is_multicast (&dst))
10380 errmsg ("tunnel group address not multicast");
10383 if (grp_set && mcast_sw_if_index == ~0)
10385 errmsg ("tunnel nonexistent multicast device");
10388 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10390 errmsg ("tunnel dst address must be unicast");
10395 if (ipv4_set && ipv6_set)
10397 errmsg ("both IPv4 and IPv6 addresses specified");
10401 if ((vni == 0) || (vni >> 24))
10403 errmsg ("vni not specified or out of range");
10407 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10411 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10412 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10416 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10417 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10419 mp->encap_vrf_id = ntohl (encap_vrf_id);
10420 mp->decap_next_index = ntohl (decap_next_index);
10421 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10422 mp->vni = ntohl (vni);
10423 mp->is_add = is_add;
10424 mp->is_ipv6 = ipv6_set;
10432 static void vl_api_vxlan_tunnel_details_t_handler
10433 (vl_api_vxlan_tunnel_details_t * mp)
10435 vat_main_t *vam = &vat_main;
10436 ip46_address_t src, dst;
10438 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10439 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10441 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10442 ntohl (mp->sw_if_index),
10443 format_ip46_address, &src, IP46_TYPE_ANY,
10444 format_ip46_address, &dst, IP46_TYPE_ANY,
10445 ntohl (mp->encap_vrf_id),
10446 ntohl (mp->decap_next_index), ntohl (mp->vni),
10447 ntohl (mp->mcast_sw_if_index));
10450 static void vl_api_vxlan_tunnel_details_t_handler_json
10451 (vl_api_vxlan_tunnel_details_t * mp)
10453 vat_main_t *vam = &vat_main;
10454 vat_json_node_t *node = NULL;
10456 if (VAT_JSON_ARRAY != vam->json_tree.type)
10458 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10459 vat_json_init_array (&vam->json_tree);
10461 node = vat_json_array_add (&vam->json_tree);
10463 vat_json_init_object (node);
10464 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10467 struct in6_addr ip6;
10469 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10470 vat_json_object_add_ip6 (node, "src_address", ip6);
10471 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10472 vat_json_object_add_ip6 (node, "dst_address", ip6);
10476 struct in_addr ip4;
10478 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10479 vat_json_object_add_ip4 (node, "src_address", ip4);
10480 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10481 vat_json_object_add_ip4 (node, "dst_address", ip4);
10483 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10484 vat_json_object_add_uint (node, "decap_next_index",
10485 ntohl (mp->decap_next_index));
10486 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10487 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10488 vat_json_object_add_uint (node, "mcast_sw_if_index",
10489 ntohl (mp->mcast_sw_if_index));
10493 api_vxlan_tunnel_dump (vat_main_t * vam)
10495 unformat_input_t *i = vam->input;
10496 vl_api_vxlan_tunnel_dump_t *mp;
10499 u8 sw_if_index_set = 0;
10501 /* Parse args required to build the message */
10502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10504 if (unformat (i, "sw_if_index %d", &sw_if_index))
10505 sw_if_index_set = 1;
10510 if (sw_if_index_set == 0)
10515 if (!vam->json_output)
10517 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10518 "sw_if_index", "src_address", "dst_address",
10519 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10522 /* Get list of vxlan-tunnel interfaces */
10523 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10525 mp->sw_if_index = htonl (sw_if_index);
10529 /* Use a control ping for synchronization */
10531 vl_api_control_ping_t *mp;
10532 M (CONTROL_PING, control_ping);
10539 api_gre_add_del_tunnel (vat_main_t * vam)
10541 unformat_input_t *line_input = vam->input;
10542 vl_api_gre_add_del_tunnel_t *mp;
10544 ip4_address_t src4, dst4;
10549 u32 outer_fib_id = 0;
10551 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10553 if (unformat (line_input, "del"))
10555 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10557 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10559 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10561 else if (unformat (line_input, "teb"))
10565 errmsg ("parse error '%U'", format_unformat_error, line_input);
10572 errmsg ("tunnel src address not specified");
10577 errmsg ("tunnel dst address not specified");
10582 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10584 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10585 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10586 mp->outer_fib_id = ntohl (outer_fib_id);
10587 mp->is_add = is_add;
10596 static void vl_api_gre_tunnel_details_t_handler
10597 (vl_api_gre_tunnel_details_t * mp)
10599 vat_main_t *vam = &vat_main;
10601 print (vam->ofp, "%11d%15U%15U%6d%14d",
10602 ntohl (mp->sw_if_index),
10603 format_ip4_address, &mp->src_address,
10604 format_ip4_address, &mp->dst_address,
10605 mp->teb, ntohl (mp->outer_fib_id));
10608 static void vl_api_gre_tunnel_details_t_handler_json
10609 (vl_api_gre_tunnel_details_t * mp)
10611 vat_main_t *vam = &vat_main;
10612 vat_json_node_t *node = NULL;
10613 struct in_addr ip4;
10615 if (VAT_JSON_ARRAY != vam->json_tree.type)
10617 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10618 vat_json_init_array (&vam->json_tree);
10620 node = vat_json_array_add (&vam->json_tree);
10622 vat_json_init_object (node);
10623 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10624 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10625 vat_json_object_add_ip4 (node, "src_address", ip4);
10626 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10627 vat_json_object_add_ip4 (node, "dst_address", ip4);
10628 vat_json_object_add_uint (node, "teb", mp->teb);
10629 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10633 api_gre_tunnel_dump (vat_main_t * vam)
10635 unformat_input_t *i = vam->input;
10636 vl_api_gre_tunnel_dump_t *mp;
10639 u8 sw_if_index_set = 0;
10641 /* Parse args required to build the message */
10642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10644 if (unformat (i, "sw_if_index %d", &sw_if_index))
10645 sw_if_index_set = 1;
10650 if (sw_if_index_set == 0)
10655 if (!vam->json_output)
10657 print (vam->ofp, "%11s%15s%15s%6s%14s",
10658 "sw_if_index", "src_address", "dst_address", "teb",
10662 /* Get list of gre-tunnel interfaces */
10663 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10665 mp->sw_if_index = htonl (sw_if_index);
10669 /* Use a control ping for synchronization */
10671 vl_api_control_ping_t *mp;
10672 M (CONTROL_PING, control_ping);
10679 api_l2_fib_clear_table (vat_main_t * vam)
10681 // unformat_input_t * i = vam->input;
10682 vl_api_l2_fib_clear_table_t *mp;
10685 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10694 api_l2_interface_efp_filter (vat_main_t * vam)
10696 unformat_input_t *i = vam->input;
10697 vl_api_l2_interface_efp_filter_t *mp;
10701 u8 sw_if_index_set = 0;
10703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10705 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10706 sw_if_index_set = 1;
10707 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10708 sw_if_index_set = 1;
10709 else if (unformat (i, "enable"))
10711 else if (unformat (i, "disable"))
10715 clib_warning ("parse error '%U'", format_unformat_error, i);
10720 if (sw_if_index_set == 0)
10722 errmsg ("missing sw_if_index");
10726 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10728 mp->sw_if_index = ntohl (sw_if_index);
10729 mp->enable_disable = enable;
10737 #define foreach_vtr_op \
10738 _("disable", L2_VTR_DISABLED) \
10739 _("push-1", L2_VTR_PUSH_1) \
10740 _("push-2", L2_VTR_PUSH_2) \
10741 _("pop-1", L2_VTR_POP_1) \
10742 _("pop-2", L2_VTR_POP_2) \
10743 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10744 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10745 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10746 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10749 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10751 unformat_input_t *i = vam->input;
10752 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10755 u8 sw_if_index_set = 0;
10758 u32 push_dot1q = 1;
10762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10765 sw_if_index_set = 1;
10766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10767 sw_if_index_set = 1;
10768 else if (unformat (i, "vtr_op %d", &vtr_op))
10770 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10773 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10775 else if (unformat (i, "tag1 %d", &tag1))
10777 else if (unformat (i, "tag2 %d", &tag2))
10781 clib_warning ("parse error '%U'", format_unformat_error, i);
10786 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10788 errmsg ("missing vtr operation or sw_if_index");
10792 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10793 mp->sw_if_index = ntohl (sw_if_index);
10794 mp->vtr_op = ntohl (vtr_op);
10795 mp->push_dot1q = ntohl (push_dot1q);
10796 mp->tag1 = ntohl (tag1);
10797 mp->tag2 = ntohl (tag2);
10806 api_create_vhost_user_if (vat_main_t * vam)
10808 unformat_input_t *i = vam->input;
10809 vl_api_create_vhost_user_if_t *mp;
10813 u8 file_name_set = 0;
10814 u32 custom_dev_instance = ~0;
10816 u8 use_custom_mac = 0;
10819 /* Shut up coverity */
10820 memset (hwaddr, 0, sizeof (hwaddr));
10822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10824 if (unformat (i, "socket %s", &file_name))
10828 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10830 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10831 use_custom_mac = 1;
10832 else if (unformat (i, "server"))
10834 else if (unformat (i, "tag %s", &tag))
10840 if (file_name_set == 0)
10842 errmsg ("missing socket file name");
10846 if (vec_len (file_name) > 255)
10848 errmsg ("socket file name too long");
10851 vec_add1 (file_name, 0);
10853 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10855 mp->is_server = is_server;
10856 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10857 vec_free (file_name);
10858 if (custom_dev_instance != ~0)
10861 mp->custom_dev_instance = ntohl (custom_dev_instance);
10863 mp->use_custom_mac = use_custom_mac;
10864 clib_memcpy (mp->mac_address, hwaddr, 6);
10866 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10876 api_modify_vhost_user_if (vat_main_t * vam)
10878 unformat_input_t *i = vam->input;
10879 vl_api_modify_vhost_user_if_t *mp;
10883 u8 file_name_set = 0;
10884 u32 custom_dev_instance = ~0;
10885 u8 sw_if_index_set = 0;
10886 u32 sw_if_index = (u32) ~ 0;
10888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10890 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10891 sw_if_index_set = 1;
10892 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10893 sw_if_index_set = 1;
10894 else if (unformat (i, "socket %s", &file_name))
10898 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10900 else if (unformat (i, "server"))
10906 if (sw_if_index_set == 0)
10908 errmsg ("missing sw_if_index or interface name");
10912 if (file_name_set == 0)
10914 errmsg ("missing socket file name");
10918 if (vec_len (file_name) > 255)
10920 errmsg ("socket file name too long");
10923 vec_add1 (file_name, 0);
10925 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10927 mp->sw_if_index = ntohl (sw_if_index);
10928 mp->is_server = is_server;
10929 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10930 vec_free (file_name);
10931 if (custom_dev_instance != ~0)
10934 mp->custom_dev_instance = ntohl (custom_dev_instance);
10944 api_delete_vhost_user_if (vat_main_t * vam)
10946 unformat_input_t *i = vam->input;
10947 vl_api_delete_vhost_user_if_t *mp;
10949 u32 sw_if_index = ~0;
10950 u8 sw_if_index_set = 0;
10952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10955 sw_if_index_set = 1;
10956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10957 sw_if_index_set = 1;
10962 if (sw_if_index_set == 0)
10964 errmsg ("missing sw_if_index or interface name");
10969 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10971 mp->sw_if_index = ntohl (sw_if_index);
10979 static void vl_api_sw_interface_vhost_user_details_t_handler
10980 (vl_api_sw_interface_vhost_user_details_t * mp)
10982 vat_main_t *vam = &vat_main;
10984 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
10985 (char *) mp->interface_name,
10986 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10987 clib_net_to_host_u64 (mp->features), mp->is_server,
10988 ntohl (mp->num_regions), (char *) mp->sock_filename);
10989 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
10992 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10993 (vl_api_sw_interface_vhost_user_details_t * mp)
10995 vat_main_t *vam = &vat_main;
10996 vat_json_node_t *node = NULL;
10998 if (VAT_JSON_ARRAY != vam->json_tree.type)
11000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11001 vat_json_init_array (&vam->json_tree);
11003 node = vat_json_array_add (&vam->json_tree);
11005 vat_json_init_object (node);
11006 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11007 vat_json_object_add_string_copy (node, "interface_name",
11008 mp->interface_name);
11009 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11010 ntohl (mp->virtio_net_hdr_sz));
11011 vat_json_object_add_uint (node, "features",
11012 clib_net_to_host_u64 (mp->features));
11013 vat_json_object_add_uint (node, "is_server", mp->is_server);
11014 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11015 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11016 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11020 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11022 vl_api_sw_interface_vhost_user_dump_t *mp;
11025 "Interface name idx hdr_sz features server regions filename");
11027 /* Get list of vhost-user interfaces */
11028 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
11031 /* Use a control ping for synchronization */
11033 vl_api_control_ping_t *mp;
11034 M (CONTROL_PING, control_ping);
11041 api_show_version (vat_main_t * vam)
11043 vl_api_show_version_t *mp;
11046 M (SHOW_VERSION, show_version);
11056 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11058 unformat_input_t *line_input = vam->input;
11059 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11061 ip4_address_t local4, remote4;
11062 ip6_address_t local6, remote6;
11064 u8 ipv4_set = 0, ipv6_set = 0;
11067 u32 encap_vrf_id = 0;
11068 u32 decap_vrf_id = 0;
11073 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11075 if (unformat (line_input, "del"))
11077 else if (unformat (line_input, "local %U",
11078 unformat_ip4_address, &local4))
11083 else if (unformat (line_input, "remote %U",
11084 unformat_ip4_address, &remote4))
11089 else if (unformat (line_input, "local %U",
11090 unformat_ip6_address, &local6))
11095 else if (unformat (line_input, "remote %U",
11096 unformat_ip6_address, &remote6))
11101 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11103 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11105 else if (unformat (line_input, "vni %d", &vni))
11107 else if (unformat (line_input, "next-ip4"))
11109 else if (unformat (line_input, "next-ip6"))
11111 else if (unformat (line_input, "next-ethernet"))
11113 else if (unformat (line_input, "next-nsh"))
11117 errmsg ("parse error '%U'", format_unformat_error, line_input);
11122 if (local_set == 0)
11124 errmsg ("tunnel local address not specified");
11127 if (remote_set == 0)
11129 errmsg ("tunnel remote address not specified");
11132 if (ipv4_set && ipv6_set)
11134 errmsg ("both IPv4 and IPv6 addresses specified");
11140 errmsg ("vni not specified");
11144 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11149 clib_memcpy (&mp->local, &local6, sizeof (local6));
11150 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11154 clib_memcpy (&mp->local, &local4, sizeof (local4));
11155 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11158 mp->encap_vrf_id = ntohl (encap_vrf_id);
11159 mp->decap_vrf_id = ntohl (decap_vrf_id);
11160 mp->protocol = protocol;
11161 mp->vni = ntohl (vni);
11162 mp->is_add = is_add;
11163 mp->is_ipv6 = ipv6_set;
11171 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11172 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11174 vat_main_t *vam = &vat_main;
11176 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11177 ntohl (mp->sw_if_index),
11178 format_ip46_address, &(mp->local[0]),
11179 format_ip46_address, &(mp->remote[0]),
11181 ntohl (mp->protocol),
11182 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11185 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11186 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11188 vat_main_t *vam = &vat_main;
11189 vat_json_node_t *node = NULL;
11190 struct in_addr ip4;
11191 struct in6_addr ip6;
11193 if (VAT_JSON_ARRAY != vam->json_tree.type)
11195 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11196 vat_json_init_array (&vam->json_tree);
11198 node = vat_json_array_add (&vam->json_tree);
11200 vat_json_init_object (node);
11201 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11204 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11205 vat_json_object_add_ip6 (node, "local", ip6);
11206 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11207 vat_json_object_add_ip6 (node, "remote", ip6);
11211 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11212 vat_json_object_add_ip4 (node, "local", ip4);
11213 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11214 vat_json_object_add_ip4 (node, "remote", ip4);
11216 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11217 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11218 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11219 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11220 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11224 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11226 unformat_input_t *i = vam->input;
11227 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11230 u8 sw_if_index_set = 0;
11232 /* Parse args required to build the message */
11233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11235 if (unformat (i, "sw_if_index %d", &sw_if_index))
11236 sw_if_index_set = 1;
11241 if (sw_if_index_set == 0)
11246 if (!vam->json_output)
11248 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11249 "sw_if_index", "local", "remote", "vni",
11250 "protocol", "encap_vrf_id", "decap_vrf_id");
11253 /* Get list of vxlan-tunnel interfaces */
11254 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11256 mp->sw_if_index = htonl (sw_if_index);
11260 /* Use a control ping for synchronization */
11262 vl_api_control_ping_t *mp;
11263 M (CONTROL_PING, control_ping);
11270 format_l2_fib_mac_address (u8 * s, va_list * args)
11272 u8 *a = va_arg (*args, u8 *);
11274 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11275 a[2], a[3], a[4], a[5], a[6], a[7]);
11278 static void vl_api_l2_fib_table_entry_t_handler
11279 (vl_api_l2_fib_table_entry_t * mp)
11281 vat_main_t *vam = &vat_main;
11283 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11285 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11286 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11290 static void vl_api_l2_fib_table_entry_t_handler_json
11291 (vl_api_l2_fib_table_entry_t * mp)
11293 vat_main_t *vam = &vat_main;
11294 vat_json_node_t *node = NULL;
11296 if (VAT_JSON_ARRAY != vam->json_tree.type)
11298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11299 vat_json_init_array (&vam->json_tree);
11301 node = vat_json_array_add (&vam->json_tree);
11303 vat_json_init_object (node);
11304 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11305 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11306 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11307 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11308 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11309 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11313 api_l2_fib_table_dump (vat_main_t * vam)
11315 unformat_input_t *i = vam->input;
11316 vl_api_l2_fib_table_dump_t *mp;
11321 /* Parse args required to build the message */
11322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11324 if (unformat (i, "bd_id %d", &bd_id))
11330 if (bd_id_set == 0)
11332 errmsg ("missing bridge domain");
11336 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11338 /* Get list of l2 fib entries */
11339 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11341 mp->bd_id = ntohl (bd_id);
11344 /* Use a control ping for synchronization */
11346 vl_api_control_ping_t *mp;
11347 M (CONTROL_PING, control_ping);
11355 api_interface_name_renumber (vat_main_t * vam)
11357 unformat_input_t *line_input = vam->input;
11358 vl_api_interface_name_renumber_t *mp;
11359 u32 sw_if_index = ~0;
11361 u32 new_show_dev_instance = ~0;
11363 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11365 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11368 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11370 else if (unformat (line_input, "new_show_dev_instance %d",
11371 &new_show_dev_instance))
11377 if (sw_if_index == ~0)
11379 errmsg ("missing interface name or sw_if_index");
11383 if (new_show_dev_instance == ~0)
11385 errmsg ("missing new_show_dev_instance");
11389 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11391 mp->sw_if_index = ntohl (sw_if_index);
11392 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11399 api_want_ip4_arp_events (vat_main_t * vam)
11401 unformat_input_t *line_input = vam->input;
11402 vl_api_want_ip4_arp_events_t *mp;
11404 ip4_address_t address;
11405 int address_set = 0;
11406 u32 enable_disable = 1;
11408 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11410 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11412 else if (unformat (line_input, "del"))
11413 enable_disable = 0;
11418 if (address_set == 0)
11420 errmsg ("missing addresses");
11424 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11425 mp->enable_disable = enable_disable;
11426 mp->pid = getpid ();
11427 mp->address = address.as_u32;
11434 api_want_ip6_nd_events (vat_main_t * vam)
11436 unformat_input_t *line_input = vam->input;
11437 vl_api_want_ip6_nd_events_t *mp;
11439 ip6_address_t address;
11440 int address_set = 0;
11441 u32 enable_disable = 1;
11443 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11445 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11447 else if (unformat (line_input, "del"))
11448 enable_disable = 0;
11453 if (address_set == 0)
11455 errmsg ("missing addresses");
11459 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11460 mp->enable_disable = enable_disable;
11461 mp->pid = getpid ();
11462 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11469 api_input_acl_set_interface (vat_main_t * vam)
11471 unformat_input_t *i = vam->input;
11472 vl_api_input_acl_set_interface_t *mp;
11475 int sw_if_index_set;
11476 u32 ip4_table_index = ~0;
11477 u32 ip6_table_index = ~0;
11478 u32 l2_table_index = ~0;
11481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11484 sw_if_index_set = 1;
11485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11486 sw_if_index_set = 1;
11487 else if (unformat (i, "del"))
11489 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11491 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11493 else if (unformat (i, "l2-table %d", &l2_table_index))
11497 clib_warning ("parse error '%U'", format_unformat_error, i);
11502 if (sw_if_index_set == 0)
11504 errmsg ("missing interface name or sw_if_index");
11508 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11510 mp->sw_if_index = ntohl (sw_if_index);
11511 mp->ip4_table_index = ntohl (ip4_table_index);
11512 mp->ip6_table_index = ntohl (ip6_table_index);
11513 mp->l2_table_index = ntohl (l2_table_index);
11514 mp->is_add = is_add;
11523 api_ip_address_dump (vat_main_t * vam)
11525 unformat_input_t *i = vam->input;
11526 vl_api_ip_address_dump_t *mp;
11527 u32 sw_if_index = ~0;
11528 u8 sw_if_index_set = 0;
11533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (i, "sw_if_index %d", &sw_if_index))
11536 sw_if_index_set = 1;
11538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11539 sw_if_index_set = 1;
11540 else if (unformat (i, "ipv4"))
11542 else if (unformat (i, "ipv6"))
11548 if (ipv4_set && ipv6_set)
11550 errmsg ("ipv4 and ipv6 flags cannot be both set");
11554 if ((!ipv4_set) && (!ipv6_set))
11556 errmsg ("no ipv4 nor ipv6 flag set");
11560 if (sw_if_index_set == 0)
11562 errmsg ("missing interface name or sw_if_index");
11566 vam->current_sw_if_index = sw_if_index;
11567 vam->is_ipv6 = ipv6_set;
11569 M (IP_ADDRESS_DUMP, ip_address_dump);
11570 mp->sw_if_index = ntohl (sw_if_index);
11571 mp->is_ipv6 = ipv6_set;
11574 /* Use a control ping for synchronization */
11576 vl_api_control_ping_t *mp;
11577 M (CONTROL_PING, control_ping);
11584 api_ip_dump (vat_main_t * vam)
11586 vl_api_ip_dump_t *mp;
11587 unformat_input_t *in = vam->input;
11594 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11596 if (unformat (in, "ipv4"))
11598 else if (unformat (in, "ipv6"))
11604 if (ipv4_set && ipv6_set)
11606 errmsg ("ipv4 and ipv6 flags cannot be both set");
11610 if ((!ipv4_set) && (!ipv6_set))
11612 errmsg ("no ipv4 nor ipv6 flag set");
11616 is_ipv6 = ipv6_set;
11617 vam->is_ipv6 = is_ipv6;
11619 /* free old data */
11620 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11622 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11624 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11626 M (IP_DUMP, ip_dump);
11627 mp->is_ipv6 = ipv6_set;
11630 /* Use a control ping for synchronization */
11632 vl_api_control_ping_t *mp;
11633 M (CONTROL_PING, control_ping);
11640 api_ipsec_spd_add_del (vat_main_t * vam)
11642 unformat_input_t *i = vam->input;
11643 vl_api_ipsec_spd_add_del_t *mp;
11648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11650 if (unformat (i, "spd_id %d", &spd_id))
11652 else if (unformat (i, "del"))
11656 clib_warning ("parse error '%U'", format_unformat_error, i);
11662 errmsg ("spd_id must be set");
11666 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11668 mp->spd_id = ntohl (spd_id);
11669 mp->is_add = is_add;
11678 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11680 unformat_input_t *i = vam->input;
11681 vl_api_ipsec_interface_add_del_spd_t *mp;
11684 u8 sw_if_index_set = 0;
11685 u32 spd_id = (u32) ~ 0;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "del"))
11692 else if (unformat (i, "spd_id %d", &spd_id))
11695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11696 sw_if_index_set = 1;
11697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11698 sw_if_index_set = 1;
11701 clib_warning ("parse error '%U'", format_unformat_error, i);
11707 if (spd_id == (u32) ~ 0)
11709 errmsg ("spd_id must be set");
11713 if (sw_if_index_set == 0)
11715 errmsg ("missing interface name or sw_if_index");
11719 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11721 mp->spd_id = ntohl (spd_id);
11722 mp->sw_if_index = ntohl (sw_if_index);
11723 mp->is_add = is_add;
11732 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11734 unformat_input_t *i = vam->input;
11735 vl_api_ipsec_spd_add_del_entry_t *mp;
11737 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11738 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11740 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11741 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11742 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11743 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11745 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11746 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11747 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11748 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11749 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11750 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11754 if (unformat (i, "del"))
11756 if (unformat (i, "outbound"))
11758 if (unformat (i, "inbound"))
11760 else if (unformat (i, "spd_id %d", &spd_id))
11762 else if (unformat (i, "sa_id %d", &sa_id))
11764 else if (unformat (i, "priority %d", &priority))
11766 else if (unformat (i, "protocol %d", &protocol))
11768 else if (unformat (i, "lport_start %d", &lport_start))
11770 else if (unformat (i, "lport_stop %d", &lport_stop))
11772 else if (unformat (i, "rport_start %d", &rport_start))
11774 else if (unformat (i, "rport_stop %d", &rport_stop))
11778 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11784 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11791 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11797 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11804 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11810 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11817 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11823 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11829 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11831 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11833 clib_warning ("unsupported action: 'resolve'");
11839 clib_warning ("parse error '%U'", format_unformat_error, i);
11845 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11847 mp->spd_id = ntohl (spd_id);
11848 mp->priority = ntohl (priority);
11849 mp->is_outbound = is_outbound;
11851 mp->is_ipv6 = is_ipv6;
11852 if (is_ipv6 || is_ip_any)
11854 clib_memcpy (mp->remote_address_start, &raddr6_start,
11855 sizeof (ip6_address_t));
11856 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11857 sizeof (ip6_address_t));
11858 clib_memcpy (mp->local_address_start, &laddr6_start,
11859 sizeof (ip6_address_t));
11860 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11861 sizeof (ip6_address_t));
11865 clib_memcpy (mp->remote_address_start, &raddr4_start,
11866 sizeof (ip4_address_t));
11867 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11868 sizeof (ip4_address_t));
11869 clib_memcpy (mp->local_address_start, &laddr4_start,
11870 sizeof (ip4_address_t));
11871 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11872 sizeof (ip4_address_t));
11874 mp->protocol = (u8) protocol;
11875 mp->local_port_start = ntohs ((u16) lport_start);
11876 mp->local_port_stop = ntohs ((u16) lport_stop);
11877 mp->remote_port_start = ntohs ((u16) rport_start);
11878 mp->remote_port_stop = ntohs ((u16) rport_stop);
11879 mp->policy = (u8) policy;
11880 mp->sa_id = ntohl (sa_id);
11881 mp->is_add = is_add;
11882 mp->is_ip_any = is_ip_any;
11890 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11892 unformat_input_t *i = vam->input;
11893 vl_api_ipsec_sad_add_del_entry_t *mp;
11895 u32 sad_id = 0, spi = 0;
11896 u8 *ck = 0, *ik = 0;
11899 u8 protocol = IPSEC_PROTOCOL_AH;
11900 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11901 u32 crypto_alg = 0, integ_alg = 0;
11902 ip4_address_t tun_src4;
11903 ip4_address_t tun_dst4;
11904 ip6_address_t tun_src6;
11905 ip6_address_t tun_dst6;
11907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11909 if (unformat (i, "del"))
11911 else if (unformat (i, "sad_id %d", &sad_id))
11913 else if (unformat (i, "spi %d", &spi))
11915 else if (unformat (i, "esp"))
11916 protocol = IPSEC_PROTOCOL_ESP;
11917 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11920 is_tunnel_ipv6 = 0;
11922 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11925 is_tunnel_ipv6 = 0;
11927 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11930 is_tunnel_ipv6 = 1;
11932 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11935 is_tunnel_ipv6 = 1;
11939 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11941 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11942 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11944 clib_warning ("unsupported crypto-alg: '%U'",
11945 format_ipsec_crypto_alg, crypto_alg);
11949 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11953 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11956 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11958 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11960 integ_alg >= IPSEC_INTEG_N_ALG)
11962 clib_warning ("unsupported integ-alg: '%U'",
11963 format_ipsec_integ_alg, integ_alg);
11967 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11971 clib_warning ("parse error '%U'", format_unformat_error, i);
11978 /*Special cases, aes-gcm-128 encryption */
11979 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11981 if (integ_alg != IPSEC_INTEG_ALG_NONE
11982 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11985 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11988 else /*set integ-alg internally to aes-gcm-128 */
11989 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11991 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11993 clib_warning ("unsupported integ-alg: aes-gcm-128");
11996 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11998 clib_warning ("unsupported integ-alg: none");
12004 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
12006 mp->sad_id = ntohl (sad_id);
12007 mp->is_add = is_add;
12008 mp->protocol = protocol;
12009 mp->spi = ntohl (spi);
12010 mp->is_tunnel = is_tunnel;
12011 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12012 mp->crypto_algorithm = crypto_alg;
12013 mp->integrity_algorithm = integ_alg;
12014 mp->crypto_key_length = vec_len (ck);
12015 mp->integrity_key_length = vec_len (ik);
12017 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12018 mp->crypto_key_length = sizeof (mp->crypto_key);
12020 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12021 mp->integrity_key_length = sizeof (mp->integrity_key);
12024 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12026 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12030 if (is_tunnel_ipv6)
12032 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12033 sizeof (ip6_address_t));
12034 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12035 sizeof (ip6_address_t));
12039 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12040 sizeof (ip4_address_t));
12041 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12042 sizeof (ip4_address_t));
12053 api_ipsec_sa_set_key (vat_main_t * vam)
12055 unformat_input_t *i = vam->input;
12056 vl_api_ipsec_sa_set_key_t *mp;
12059 u8 *ck = 0, *ik = 0;
12061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12063 if (unformat (i, "sa_id %d", &sa_id))
12065 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12067 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12071 clib_warning ("parse error '%U'", format_unformat_error, i);
12076 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12078 mp->sa_id = ntohl (sa_id);
12079 mp->crypto_key_length = vec_len (ck);
12080 mp->integrity_key_length = vec_len (ik);
12082 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12083 mp->crypto_key_length = sizeof (mp->crypto_key);
12085 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12086 mp->integrity_key_length = sizeof (mp->integrity_key);
12089 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12091 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12100 api_ikev2_profile_add_del (vat_main_t * vam)
12102 unformat_input_t *i = vam->input;
12103 vl_api_ikev2_profile_add_del_t *mp;
12108 const char *valid_chars = "a-zA-Z0-9_";
12110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12112 if (unformat (i, "del"))
12114 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12115 vec_add1 (name, 0);
12118 errmsg ("parse error '%U'", format_unformat_error, i);
12123 if (!vec_len (name))
12125 errmsg ("profile name must be specified");
12129 if (vec_len (name) > 64)
12131 errmsg ("profile name too long");
12135 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12137 clib_memcpy (mp->name, name, vec_len (name));
12138 mp->is_add = is_add;
12148 api_ikev2_profile_set_auth (vat_main_t * vam)
12150 unformat_input_t *i = vam->input;
12151 vl_api_ikev2_profile_set_auth_t *mp;
12155 u32 auth_method = 0;
12158 const char *valid_chars = "a-zA-Z0-9_";
12160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12162 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12163 vec_add1 (name, 0);
12164 else if (unformat (i, "auth_method %U",
12165 unformat_ikev2_auth_method, &auth_method))
12167 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12169 else if (unformat (i, "auth_data %v", &data))
12173 errmsg ("parse error '%U'", format_unformat_error, i);
12178 if (!vec_len (name))
12180 errmsg ("profile name must be specified");
12184 if (vec_len (name) > 64)
12186 errmsg ("profile name too long");
12190 if (!vec_len (data))
12192 errmsg ("auth_data must be specified");
12198 errmsg ("auth_method must be specified");
12202 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12204 mp->is_hex = is_hex;
12205 mp->auth_method = (u8) auth_method;
12206 mp->data_len = vec_len (data);
12207 clib_memcpy (mp->name, name, vec_len (name));
12208 clib_memcpy (mp->data, data, vec_len (data));
12219 api_ikev2_profile_set_id (vat_main_t * vam)
12221 unformat_input_t *i = vam->input;
12222 vl_api_ikev2_profile_set_id_t *mp;
12230 const char *valid_chars = "a-zA-Z0-9_";
12232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12234 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12235 vec_add1 (name, 0);
12236 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12238 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12240 data = vec_new (u8, 4);
12241 clib_memcpy (data, ip4.as_u8, 4);
12243 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12245 else if (unformat (i, "id_data %v", &data))
12247 else if (unformat (i, "local"))
12249 else if (unformat (i, "remote"))
12253 errmsg ("parse error '%U'", format_unformat_error, i);
12258 if (!vec_len (name))
12260 errmsg ("profile name must be specified");
12264 if (vec_len (name) > 64)
12266 errmsg ("profile name too long");
12270 if (!vec_len (data))
12272 errmsg ("id_data must be specified");
12278 errmsg ("id_type must be specified");
12282 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12284 mp->is_local = is_local;
12285 mp->id_type = (u8) id_type;
12286 mp->data_len = vec_len (data);
12287 clib_memcpy (mp->name, name, vec_len (name));
12288 clib_memcpy (mp->data, data, vec_len (data));
12299 api_ikev2_profile_set_ts (vat_main_t * vam)
12301 unformat_input_t *i = vam->input;
12302 vl_api_ikev2_profile_set_ts_t *mp;
12306 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12307 ip4_address_t start_addr, end_addr;
12309 const char *valid_chars = "a-zA-Z0-9_";
12311 start_addr.as_u32 = 0;
12312 end_addr.as_u32 = (u32) ~ 0;
12314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12316 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12317 vec_add1 (name, 0);
12318 else if (unformat (i, "protocol %d", &proto))
12320 else if (unformat (i, "start_port %d", &start_port))
12322 else if (unformat (i, "end_port %d", &end_port))
12325 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12327 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12329 else if (unformat (i, "local"))
12331 else if (unformat (i, "remote"))
12335 errmsg ("parse error '%U'", format_unformat_error, i);
12340 if (!vec_len (name))
12342 errmsg ("profile name must be specified");
12346 if (vec_len (name) > 64)
12348 errmsg ("profile name too long");
12352 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12354 mp->is_local = is_local;
12355 mp->proto = (u8) proto;
12356 mp->start_port = (u16) start_port;
12357 mp->end_port = (u16) end_port;
12358 mp->start_addr = start_addr.as_u32;
12359 mp->end_addr = end_addr.as_u32;
12360 clib_memcpy (mp->name, name, vec_len (name));
12370 api_ikev2_set_local_key (vat_main_t * vam)
12372 unformat_input_t *i = vam->input;
12373 vl_api_ikev2_set_local_key_t *mp;
12377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12379 if (unformat (i, "file %v", &file))
12380 vec_add1 (file, 0);
12383 errmsg ("parse error '%U'", format_unformat_error, i);
12388 if (!vec_len (file))
12390 errmsg ("RSA key file must be specified");
12394 if (vec_len (file) > 256)
12396 errmsg ("file name too long");
12400 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12402 clib_memcpy (mp->key_file, file, vec_len (file));
12415 api_map_add_domain (vat_main_t * vam)
12417 unformat_input_t *i = vam->input;
12418 vl_api_map_add_domain_t *mp;
12421 ip4_address_t ip4_prefix;
12422 ip6_address_t ip6_prefix;
12423 ip6_address_t ip6_src;
12424 u32 num_m_args = 0;
12425 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12426 0, psid_length = 0;
12427 u8 is_translation = 0;
12429 u32 ip6_src_len = 128;
12431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12433 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12434 &ip4_prefix, &ip4_prefix_len))
12436 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12437 &ip6_prefix, &ip6_prefix_len))
12441 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12444 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12446 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12448 else if (unformat (i, "psid-offset %d", &psid_offset))
12450 else if (unformat (i, "psid-len %d", &psid_length))
12452 else if (unformat (i, "mtu %d", &mtu))
12454 else if (unformat (i, "map-t"))
12455 is_translation = 1;
12458 clib_warning ("parse error '%U'", format_unformat_error, i);
12463 if (num_m_args < 3)
12465 errmsg ("mandatory argument(s) missing");
12469 /* Construct the API message */
12470 M (MAP_ADD_DOMAIN, map_add_domain);
12472 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12473 mp->ip4_prefix_len = ip4_prefix_len;
12475 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12476 mp->ip6_prefix_len = ip6_prefix_len;
12478 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12479 mp->ip6_src_prefix_len = ip6_src_len;
12481 mp->ea_bits_len = ea_bits_len;
12482 mp->psid_offset = psid_offset;
12483 mp->psid_length = psid_length;
12484 mp->is_translation = is_translation;
12485 mp->mtu = htons (mtu);
12490 /* Wait for a reply, return good/bad news */
12495 api_map_del_domain (vat_main_t * vam)
12497 unformat_input_t *i = vam->input;
12498 vl_api_map_del_domain_t *mp;
12501 u32 num_m_args = 0;
12504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12506 if (unformat (i, "index %d", &index))
12510 clib_warning ("parse error '%U'", format_unformat_error, i);
12515 if (num_m_args != 1)
12517 errmsg ("mandatory argument(s) missing");
12521 /* Construct the API message */
12522 M (MAP_DEL_DOMAIN, map_del_domain);
12524 mp->index = ntohl (index);
12529 /* Wait for a reply, return good/bad news */
12534 api_map_add_del_rule (vat_main_t * vam)
12536 unformat_input_t *i = vam->input;
12537 vl_api_map_add_del_rule_t *mp;
12540 ip6_address_t ip6_dst;
12541 u32 num_m_args = 0, index, psid = 0;
12543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12545 if (unformat (i, "index %d", &index))
12547 else if (unformat (i, "psid %d", &psid))
12549 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12551 else if (unformat (i, "del"))
12557 clib_warning ("parse error '%U'", format_unformat_error, i);
12562 /* Construct the API message */
12563 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12565 mp->index = ntohl (index);
12566 mp->is_add = is_add;
12567 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12568 mp->psid = ntohs (psid);
12573 /* Wait for a reply, return good/bad news */
12578 api_map_domain_dump (vat_main_t * vam)
12580 vl_api_map_domain_dump_t *mp;
12583 /* Construct the API message */
12584 M (MAP_DOMAIN_DUMP, map_domain_dump);
12589 /* Use a control ping for synchronization */
12591 vl_api_control_ping_t *mp;
12592 M (CONTROL_PING, control_ping);
12599 api_map_rule_dump (vat_main_t * vam)
12601 unformat_input_t *i = vam->input;
12602 vl_api_map_rule_dump_t *mp;
12604 u32 domain_index = ~0;
12606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12608 if (unformat (i, "index %u", &domain_index))
12614 if (domain_index == ~0)
12616 clib_warning ("parse error: domain index expected");
12620 /* Construct the API message */
12621 M (MAP_RULE_DUMP, map_rule_dump);
12623 mp->domain_index = htonl (domain_index);
12628 /* Use a control ping for synchronization */
12630 vl_api_control_ping_t *mp;
12631 M (CONTROL_PING, control_ping);
12637 static void vl_api_map_add_domain_reply_t_handler
12638 (vl_api_map_add_domain_reply_t * mp)
12640 vat_main_t *vam = &vat_main;
12641 i32 retval = ntohl (mp->retval);
12643 if (vam->async_mode)
12645 vam->async_errors += (retval < 0);
12649 vam->retval = retval;
12650 vam->result_ready = 1;
12654 static void vl_api_map_add_domain_reply_t_handler_json
12655 (vl_api_map_add_domain_reply_t * mp)
12657 vat_main_t *vam = &vat_main;
12658 vat_json_node_t node;
12660 vat_json_init_object (&node);
12661 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12662 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12664 vat_json_print (vam->ofp, &node);
12665 vat_json_free (&node);
12667 vam->retval = ntohl (mp->retval);
12668 vam->result_ready = 1;
12672 api_get_first_msg_id (vat_main_t * vam)
12674 vl_api_get_first_msg_id_t *mp;
12676 unformat_input_t *i = vam->input;
12680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12682 if (unformat (i, "client %s", &name))
12690 errmsg ("missing client name");
12693 vec_add1 (name, 0);
12695 if (vec_len (name) > 63)
12697 errmsg ("client name too long");
12701 M (GET_FIRST_MSG_ID, get_first_msg_id);
12702 clib_memcpy (mp->name, name, vec_len (name));
12710 api_cop_interface_enable_disable (vat_main_t * vam)
12712 unformat_input_t *line_input = vam->input;
12713 vl_api_cop_interface_enable_disable_t *mp;
12715 u32 sw_if_index = ~0;
12716 u8 enable_disable = 1;
12718 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12720 if (unformat (line_input, "disable"))
12721 enable_disable = 0;
12722 if (unformat (line_input, "enable"))
12723 enable_disable = 1;
12724 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12725 vam, &sw_if_index))
12727 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12733 if (sw_if_index == ~0)
12735 errmsg ("missing interface name or sw_if_index");
12739 /* Construct the API message */
12740 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12741 mp->sw_if_index = ntohl (sw_if_index);
12742 mp->enable_disable = enable_disable;
12746 /* Wait for the reply */
12751 api_cop_whitelist_enable_disable (vat_main_t * vam)
12753 unformat_input_t *line_input = vam->input;
12754 vl_api_cop_whitelist_enable_disable_t *mp;
12756 u32 sw_if_index = ~0;
12757 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12760 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12762 if (unformat (line_input, "ip4"))
12764 else if (unformat (line_input, "ip6"))
12766 else if (unformat (line_input, "default"))
12768 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12769 vam, &sw_if_index))
12771 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12773 else if (unformat (line_input, "fib-id %d", &fib_id))
12779 if (sw_if_index == ~0)
12781 errmsg ("missing interface name or sw_if_index");
12785 /* Construct the API message */
12786 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12787 mp->sw_if_index = ntohl (sw_if_index);
12788 mp->fib_id = ntohl (fib_id);
12791 mp->default_cop = default_cop;
12795 /* Wait for the reply */
12800 api_get_node_graph (vat_main_t * vam)
12802 vl_api_get_node_graph_t *mp;
12805 M (GET_NODE_GRAPH, get_node_graph);
12809 /* Wait for the reply */
12814 /** Used for parsing LISP eids */
12815 typedef CLIB_PACKED(struct{
12816 u8 addr[16]; /**< eid address */
12817 u32 len; /**< prefix length if IP */
12818 u8 type; /**< type of eid */
12823 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12825 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12827 memset (a, 0, sizeof (a[0]));
12829 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12831 a->type = 0; /* ipv4 type */
12833 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12835 a->type = 1; /* ipv6 type */
12837 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12839 a->type = 2; /* mac type */
12846 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12855 lisp_eid_size_vat (u8 type)
12870 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12872 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12876 /** Used for transferring locators via VPP API */
12877 typedef CLIB_PACKED(struct
12879 u32 sw_if_index; /**< locator sw_if_index */
12880 u8 priority; /**< locator priority */
12881 u8 weight; /**< locator weight */
12886 api_lisp_add_del_locator_set (vat_main_t * vam)
12888 unformat_input_t *input = vam->input;
12889 vl_api_lisp_add_del_locator_set_t *mp;
12892 u8 *locator_set_name = NULL;
12893 u8 locator_set_name_set = 0;
12894 ls_locator_t locator, *locators = 0;
12895 u32 sw_if_index, priority, weight;
12898 /* Parse args required to build the message */
12899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12901 if (unformat (input, "del"))
12905 else if (unformat (input, "locator-set %s", &locator_set_name))
12907 locator_set_name_set = 1;
12909 else if (unformat (input, "sw_if_index %u p %u w %u",
12910 &sw_if_index, &priority, &weight))
12912 locator.sw_if_index = htonl (sw_if_index);
12913 locator.priority = priority;
12914 locator.weight = weight;
12915 vec_add1 (locators, locator);
12919 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
12920 &sw_if_index, &priority, &weight))
12922 locator.sw_if_index = htonl (sw_if_index);
12923 locator.priority = priority;
12924 locator.weight = weight;
12925 vec_add1 (locators, locator);
12931 if (locator_set_name_set == 0)
12933 errmsg ("missing locator-set name");
12934 vec_free (locators);
12938 if (vec_len (locator_set_name) > 64)
12940 errmsg ("locator-set name too long");
12941 vec_free (locator_set_name);
12942 vec_free (locators);
12945 vec_add1 (locator_set_name, 0);
12947 data_len = sizeof (ls_locator_t) * vec_len (locators);
12949 /* Construct the API message */
12950 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12952 mp->is_add = is_add;
12953 clib_memcpy (mp->locator_set_name, locator_set_name,
12954 vec_len (locator_set_name));
12955 vec_free (locator_set_name);
12957 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12959 clib_memcpy (mp->locators, locators, data_len);
12960 vec_free (locators);
12965 /* Wait for a reply... */
12973 api_lisp_add_del_locator (vat_main_t * vam)
12975 unformat_input_t *input = vam->input;
12976 vl_api_lisp_add_del_locator_t *mp;
12978 u32 tmp_if_index = ~0;
12979 u32 sw_if_index = ~0;
12980 u8 sw_if_index_set = 0;
12981 u8 sw_if_index_if_name_set = 0;
12983 u8 priority_set = 0;
12987 u8 *locator_set_name = NULL;
12988 u8 locator_set_name_set = 0;
12990 /* Parse args required to build the message */
12991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12993 if (unformat (input, "del"))
12997 else if (unformat (input, "locator-set %s", &locator_set_name))
12999 locator_set_name_set = 1;
13001 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13004 sw_if_index_if_name_set = 1;
13005 sw_if_index = tmp_if_index;
13007 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13009 sw_if_index_set = 1;
13010 sw_if_index = tmp_if_index;
13012 else if (unformat (input, "p %d", &priority))
13016 else if (unformat (input, "w %d", &weight))
13024 if (locator_set_name_set == 0)
13026 errmsg ("missing locator-set name");
13030 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13032 errmsg ("missing sw_if_index");
13033 vec_free (locator_set_name);
13037 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13039 errmsg ("cannot use both params interface name and sw_if_index");
13040 vec_free (locator_set_name);
13044 if (priority_set == 0)
13046 errmsg ("missing locator-set priority");
13047 vec_free (locator_set_name);
13051 if (weight_set == 0)
13053 errmsg ("missing locator-set weight");
13054 vec_free (locator_set_name);
13058 if (vec_len (locator_set_name) > 64)
13060 errmsg ("locator-set name too long");
13061 vec_free (locator_set_name);
13064 vec_add1 (locator_set_name, 0);
13066 /* Construct the API message */
13067 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13069 mp->is_add = is_add;
13070 mp->sw_if_index = ntohl (sw_if_index);
13071 mp->priority = priority;
13072 mp->weight = weight;
13073 clib_memcpy (mp->locator_set_name, locator_set_name,
13074 vec_len (locator_set_name));
13075 vec_free (locator_set_name);
13080 /* Wait for a reply... */
13088 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13090 u32 *key_id = va_arg (*args, u32 *);
13093 if (unformat (input, "%s", &s))
13095 if (!strcmp ((char *) s, "sha1"))
13096 key_id[0] = HMAC_SHA_1_96;
13097 else if (!strcmp ((char *) s, "sha256"))
13098 key_id[0] = HMAC_SHA_256_128;
13101 clib_warning ("invalid key_id: '%s'", s);
13102 key_id[0] = HMAC_NO_KEY;
13113 api_lisp_add_del_local_eid (vat_main_t * vam)
13115 unformat_input_t *input = vam->input;
13116 vl_api_lisp_add_del_local_eid_t *mp;
13120 lisp_eid_vat_t _eid, *eid = &_eid;
13121 u8 *locator_set_name = 0;
13122 u8 locator_set_name_set = 0;
13127 /* Parse args required to build the message */
13128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13130 if (unformat (input, "del"))
13134 else if (unformat (input, "vni %d", &vni))
13138 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13142 else if (unformat (input, "locator-set %s", &locator_set_name))
13144 locator_set_name_set = 1;
13146 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13148 else if (unformat (input, "secret-key %_%v%_", &key))
13154 if (locator_set_name_set == 0)
13156 errmsg ("missing locator-set name");
13162 errmsg ("EID address not set!");
13163 vec_free (locator_set_name);
13167 if (key && (0 == key_id))
13169 errmsg ("invalid key_id!");
13173 if (vec_len (key) > 64)
13175 errmsg ("key too long");
13180 if (vec_len (locator_set_name) > 64)
13182 errmsg ("locator-set name too long");
13183 vec_free (locator_set_name);
13186 vec_add1 (locator_set_name, 0);
13188 /* Construct the API message */
13189 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13191 mp->is_add = is_add;
13192 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13193 mp->eid_type = eid->type;
13194 mp->prefix_len = eid->len;
13195 mp->vni = clib_host_to_net_u32 (vni);
13196 mp->key_id = clib_host_to_net_u16 (key_id);
13197 clib_memcpy (mp->locator_set_name, locator_set_name,
13198 vec_len (locator_set_name));
13199 clib_memcpy (mp->key, key, vec_len (key));
13201 vec_free (locator_set_name);
13207 /* Wait for a reply... */
13215 /** Used for transferring locators via VPP API */
13216 typedef CLIB_PACKED(struct
13218 u8 is_ip4; /**< is locator an IPv4 address? */
13219 u8 priority; /**< locator priority */
13220 u8 weight; /**< locator weight */
13221 u8 addr[16]; /**< IPv4/IPv6 address */
13226 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13228 unformat_input_t *input = vam->input;
13229 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13232 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13233 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13234 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13235 u32 action = ~0, p, w;
13236 ip4_address_t rmt_rloc4, lcl_rloc4;
13237 ip6_address_t rmt_rloc6, lcl_rloc6;
13238 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13240 memset (&rloc, 0, sizeof (rloc));
13242 /* Parse args required to build the message */
13243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13245 if (unformat (input, "del"))
13249 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
13253 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
13257 else if (unformat (input, "p %d w %d", &p, &w))
13261 errmsg ("No RLOC configured for setting priority/weight!");
13264 curr_rloc->priority = p;
13265 curr_rloc->weight = w;
13267 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13268 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13272 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13273 rloc.priority = rloc.weight = 0;
13274 vec_add1 (lcl_locs, rloc);
13276 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13277 vec_add1 (rmt_locs, rloc);
13278 /* priority and weight saved in rmt loc */
13279 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13281 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13282 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13285 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13286 rloc.priority = rloc.weight = 0;
13287 vec_add1 (lcl_locs, rloc);
13289 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13290 vec_add1 (rmt_locs, rloc);
13291 /* priority and weight saved in rmt loc */
13292 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13294 else if (unformat (input, "action %d", &action))
13300 clib_warning ("parse error '%U'", format_unformat_error, input);
13307 errmsg ("remote eid addresses not set");
13311 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13313 errmsg ("eid types don't match");
13317 if (0 == rmt_locs && (u32) ~ 0 == action)
13319 errmsg ("action not set for negative mapping");
13323 /* Construct the API message */
13324 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13326 mp->is_add = is_add;
13327 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13328 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13329 mp->eid_type = rmt_eid->type;
13330 mp->rmt_len = rmt_eid->len;
13331 mp->lcl_len = lcl_eid->len;
13332 mp->action = action;
13334 if (0 != rmt_locs && 0 != lcl_locs)
13336 mp->loc_num = vec_len (rmt_locs);
13337 clib_memcpy (mp->lcl_locs, lcl_locs,
13338 (sizeof (rloc_t) * vec_len (lcl_locs)));
13339 clib_memcpy (mp->rmt_locs, rmt_locs,
13340 (sizeof (rloc_t) * vec_len (rmt_locs)));
13342 vec_free (lcl_locs);
13343 vec_free (rmt_locs);
13348 /* Wait for a reply... */
13356 api_lisp_add_del_map_server (vat_main_t * vam)
13358 unformat_input_t *input = vam->input;
13359 vl_api_lisp_add_del_map_server_t *mp;
13364 ip4_address_t ipv4;
13365 ip6_address_t ipv6;
13367 /* Parse args required to build the message */
13368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13370 if (unformat (input, "del"))
13374 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13378 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13386 if (ipv4_set && ipv6_set)
13388 errmsg ("both eid v4 and v6 addresses set");
13392 if (!ipv4_set && !ipv6_set)
13394 errmsg ("eid addresses not set");
13398 /* Construct the API message */
13399 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13401 mp->is_add = is_add;
13405 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13410 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13416 /* Wait for a reply... */
13424 api_lisp_add_del_map_resolver (vat_main_t * vam)
13426 unformat_input_t *input = vam->input;
13427 vl_api_lisp_add_del_map_resolver_t *mp;
13432 ip4_address_t ipv4;
13433 ip6_address_t ipv6;
13435 /* Parse args required to build the message */
13436 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13438 if (unformat (input, "del"))
13442 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13446 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13454 if (ipv4_set && ipv6_set)
13456 errmsg ("both eid v4 and v6 addresses set");
13460 if (!ipv4_set && !ipv6_set)
13462 errmsg ("eid addresses not set");
13466 /* Construct the API message */
13467 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13469 mp->is_add = is_add;
13473 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13478 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13484 /* Wait for a reply... */
13492 api_lisp_gpe_enable_disable (vat_main_t * vam)
13494 unformat_input_t *input = vam->input;
13495 vl_api_lisp_gpe_enable_disable_t *mp;
13500 /* Parse args required to build the message */
13501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13503 if (unformat (input, "enable"))
13508 else if (unformat (input, "disable"))
13519 errmsg ("Value not set");
13523 /* Construct the API message */
13524 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13531 /* Wait for a reply... */
13539 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13541 unformat_input_t *input = vam->input;
13542 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13547 /* Parse args required to build the message */
13548 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13550 if (unformat (input, "enable"))
13555 else if (unformat (input, "disable"))
13563 errmsg ("Value not set");
13567 /* Construct the API message */
13568 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13570 mp->is_enabled = is_en;
13575 /* Wait for a reply... */
13583 api_lisp_map_register_enable_disable (vat_main_t * vam)
13585 unformat_input_t *input = vam->input;
13586 vl_api_lisp_map_register_enable_disable_t *mp;
13591 /* Parse args required to build the message */
13592 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13594 if (unformat (input, "enable"))
13599 else if (unformat (input, "disable"))
13607 errmsg ("Value not set");
13611 /* Construct the API message */
13612 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13614 mp->is_enabled = is_en;
13619 /* Wait for a reply... */
13627 api_lisp_enable_disable (vat_main_t * vam)
13629 unformat_input_t *input = vam->input;
13630 vl_api_lisp_enable_disable_t *mp;
13635 /* Parse args required to build the message */
13636 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13638 if (unformat (input, "enable"))
13643 else if (unformat (input, "disable"))
13653 errmsg ("Value not set");
13657 /* Construct the API message */
13658 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13665 /* Wait for a reply... */
13673 api_show_lisp_map_register_state (vat_main_t * vam)
13676 vl_api_show_lisp_map_register_state_t *mp;
13678 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13683 /* wait for reply */
13690 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13693 vl_api_show_lisp_rloc_probe_state_t *mp;
13695 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13700 /* wait for reply */
13707 api_show_lisp_map_request_mode (vat_main_t * vam)
13710 vl_api_show_lisp_map_request_mode_t *mp;
13712 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13717 /* wait for reply */
13724 api_lisp_map_request_mode (vat_main_t * vam)
13727 unformat_input_t *input = vam->input;
13728 vl_api_lisp_map_request_mode_t *mp;
13731 /* Parse args required to build the message */
13732 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13734 if (unformat (input, "dst-only"))
13736 else if (unformat (input, "src-dst"))
13740 errmsg ("parse error '%U'", format_unformat_error, input);
13745 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13752 /* wait for reply */
13760 * Enable/disable LISP proxy ITR.
13762 * @param vam vpp API test context
13763 * @return return code
13766 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13769 u8 ls_name_set = 0;
13770 unformat_input_t *input = vam->input;
13771 vl_api_lisp_pitr_set_locator_set_t *mp;
13775 /* Parse args required to build the message */
13776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13778 if (unformat (input, "del"))
13780 else if (unformat (input, "locator-set %s", &ls_name))
13784 errmsg ("parse error '%U'", format_unformat_error, input);
13791 errmsg ("locator-set name not set!");
13795 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13797 mp->is_add = is_add;
13798 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13799 vec_free (ls_name);
13804 /* wait for reply */
13812 api_show_lisp_pitr (vat_main_t * vam)
13814 vl_api_show_lisp_pitr_t *mp;
13817 if (!vam->json_output)
13819 print (vam->ofp, "%=20s", "lisp status:");
13822 M (SHOW_LISP_PITR, show_lisp_pitr);
13826 /* Wait for a reply... */
13834 * Add/delete mapping between vni and vrf
13837 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13840 unformat_input_t *input = vam->input;
13841 vl_api_lisp_eid_table_add_del_map_t *mp;
13842 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13843 u32 vni, vrf, bd_index;
13845 /* Parse args required to build the message */
13846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13848 if (unformat (input, "del"))
13850 else if (unformat (input, "vrf %d", &vrf))
13852 else if (unformat (input, "bd_index %d", &bd_index))
13854 else if (unformat (input, "vni %d", &vni))
13860 if (!vni_set || (!vrf_set && !bd_index_set))
13862 errmsg ("missing arguments!");
13866 if (vrf_set && bd_index_set)
13868 errmsg ("error: both vrf and bd entered!");
13872 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13874 mp->is_add = is_add;
13875 mp->vni = htonl (vni);
13876 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13877 mp->is_l2 = bd_index_set;
13882 /* wait for reply */
13890 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13892 u32 *action = va_arg (*args, u32 *);
13895 if (unformat (input, "%s", &s))
13897 if (!strcmp ((char *) s, "no-action"))
13899 else if (!strcmp ((char *) s, "natively-forward"))
13901 else if (!strcmp ((char *) s, "send-map-request"))
13903 else if (!strcmp ((char *) s, "drop"))
13907 clib_warning ("invalid action: '%s'", s);
13919 * Add/del remote mapping to/from LISP control plane
13921 * @param vam vpp API test context
13922 * @return return code
13925 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13927 unformat_input_t *input = vam->input;
13928 vl_api_lisp_add_del_remote_mapping_t *mp;
13931 lisp_eid_vat_t _eid, *eid = &_eid;
13932 lisp_eid_vat_t _seid, *seid = &_seid;
13933 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13934 u32 action = ~0, p, w, data_len;
13935 ip4_address_t rloc4;
13936 ip6_address_t rloc6;
13937 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13939 memset (&rloc, 0, sizeof (rloc));
13941 /* Parse args required to build the message */
13942 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13944 if (unformat (input, "del-all"))
13948 else if (unformat (input, "del"))
13952 else if (unformat (input, "add"))
13956 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13960 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13964 else if (unformat (input, "vni %d", &vni))
13968 else if (unformat (input, "p %d w %d", &p, &w))
13972 errmsg ("No RLOC configured for setting priority/weight!");
13975 curr_rloc->priority = p;
13976 curr_rloc->weight = w;
13978 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13981 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13982 vec_add1 (rlocs, rloc);
13983 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13985 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13988 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13989 vec_add1 (rlocs, rloc);
13990 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13992 else if (unformat (input, "action %U",
13993 unformat_negative_mapping_action, &action))
13999 clib_warning ("parse error '%U'", format_unformat_error, input);
14006 errmsg ("missing params!");
14010 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14012 errmsg ("no action set for negative map-reply!");
14016 data_len = vec_len (rlocs) * sizeof (rloc_t);
14018 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14019 mp->is_add = is_add;
14020 mp->vni = htonl (vni);
14021 mp->action = (u8) action;
14022 mp->is_src_dst = seid_set;
14023 mp->eid_len = eid->len;
14024 mp->seid_len = seid->len;
14025 mp->del_all = del_all;
14026 mp->eid_type = eid->type;
14027 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14028 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14030 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14031 clib_memcpy (mp->rlocs, rlocs, data_len);
14037 /* Wait for a reply... */
14045 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14046 * forwarding entries in data-plane accordingly.
14048 * @param vam vpp API test context
14049 * @return return code
14052 api_lisp_add_del_adjacency (vat_main_t * vam)
14054 unformat_input_t *input = vam->input;
14055 vl_api_lisp_add_del_adjacency_t *mp;
14058 ip4_address_t leid4, reid4;
14059 ip6_address_t leid6, reid6;
14060 u8 reid_mac[6] = { 0 };
14061 u8 leid_mac[6] = { 0 };
14062 u8 reid_type, leid_type;
14063 u32 leid_len = 0, reid_len = 0, len;
14066 leid_type = reid_type = (u8) ~ 0;
14068 /* Parse args required to build the message */
14069 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14071 if (unformat (input, "del"))
14075 else if (unformat (input, "add"))
14079 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14082 reid_type = 0; /* ipv4 */
14085 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14088 reid_type = 1; /* ipv6 */
14091 else if (unformat (input, "reid %U", unformat_ethernet_address,
14094 reid_type = 2; /* mac */
14096 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14099 leid_type = 0; /* ipv4 */
14102 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14105 leid_type = 1; /* ipv6 */
14108 else if (unformat (input, "leid %U", unformat_ethernet_address,
14111 leid_type = 2; /* mac */
14113 else if (unformat (input, "vni %d", &vni))
14119 errmsg ("parse error '%U'", format_unformat_error, input);
14124 if ((u8) ~ 0 == reid_type)
14126 errmsg ("missing params!");
14130 if (leid_type != reid_type)
14132 errmsg ("remote and local EIDs are of different types!");
14136 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14137 mp->is_add = is_add;
14138 mp->vni = htonl (vni);
14139 mp->leid_len = leid_len;
14140 mp->reid_len = reid_len;
14141 mp->eid_type = reid_type;
14143 switch (mp->eid_type)
14146 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14147 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14150 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14151 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14154 clib_memcpy (mp->leid, leid_mac, 6);
14155 clib_memcpy (mp->reid, reid_mac, 6);
14158 errmsg ("unknown EID type %d!", mp->eid_type);
14165 /* Wait for a reply... */
14173 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14175 unformat_input_t *input = vam->input;
14176 vl_api_lisp_gpe_add_del_iface_t *mp;
14178 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14179 u32 dp_table = 0, vni = 0;
14181 /* Parse args required to build the message */
14182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14184 if (unformat (input, "up"))
14189 else if (unformat (input, "down"))
14194 else if (unformat (input, "table_id %d", &dp_table))
14198 else if (unformat (input, "bd_id %d", &dp_table))
14203 else if (unformat (input, "vni %d", &vni))
14211 if (action_set == 0)
14213 errmsg ("Action not set");
14216 if (dp_table_set == 0 || vni_set == 0)
14218 errmsg ("vni and dp_table must be set");
14222 /* Construct the API message */
14223 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14225 mp->is_add = is_add;
14226 mp->dp_table = dp_table;
14233 /* Wait for a reply... */
14241 * Add/del map request itr rlocs from LISP control plane and updates
14243 * @param vam vpp API test context
14244 * @return return code
14247 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14249 unformat_input_t *input = vam->input;
14250 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14252 u8 *locator_set_name = 0;
14253 u8 locator_set_name_set = 0;
14256 /* Parse args required to build the message */
14257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14259 if (unformat (input, "del"))
14263 else if (unformat (input, "%_%v%_", &locator_set_name))
14265 locator_set_name_set = 1;
14269 clib_warning ("parse error '%U'", format_unformat_error, input);
14274 if (is_add && !locator_set_name_set)
14276 errmsg ("itr-rloc is not set!");
14280 if (is_add && vec_len (locator_set_name) > 64)
14282 errmsg ("itr-rloc locator-set name too long");
14283 vec_free (locator_set_name);
14287 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14288 mp->is_add = is_add;
14291 clib_memcpy (mp->locator_set_name, locator_set_name,
14292 vec_len (locator_set_name));
14296 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14298 vec_free (locator_set_name);
14303 /* Wait for a reply... */
14311 api_lisp_locator_dump (vat_main_t * vam)
14313 unformat_input_t *input = vam->input;
14314 vl_api_lisp_locator_dump_t *mp;
14316 u8 is_index_set = 0, is_name_set = 0;
14320 /* Parse args required to build the message */
14321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14323 if (unformat (input, "ls_name %_%v%_", &ls_name))
14327 else if (unformat (input, "ls_index %d", &ls_index))
14333 errmsg ("parse error '%U'", format_unformat_error, input);
14338 if (!is_index_set && !is_name_set)
14340 errmsg ("error: expected one of index or name!");
14344 if (is_index_set && is_name_set)
14346 errmsg ("error: only one param expected!");
14350 if (vec_len (ls_name) > 62)
14352 errmsg ("error: locator set name too long!");
14356 if (!vam->json_output)
14358 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14361 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14362 mp->is_index_set = is_index_set;
14365 mp->ls_index = clib_host_to_net_u32 (ls_index);
14368 vec_add1 (ls_name, 0);
14369 strncpy ((char *) mp->ls_name, (char *) ls_name,
14370 sizeof (mp->ls_name) - 1);
14376 /* Use a control ping for synchronization */
14378 vl_api_control_ping_t *mp;
14379 M (CONTROL_PING, control_ping);
14382 /* Wait for a reply... */
14390 api_lisp_locator_set_dump (vat_main_t * vam)
14392 vl_api_lisp_locator_set_dump_t *mp;
14393 unformat_input_t *input = vam->input;
14397 /* Parse args required to build the message */
14398 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14400 if (unformat (input, "local"))
14404 else if (unformat (input, "remote"))
14410 errmsg ("parse error '%U'", format_unformat_error, input);
14415 if (!vam->json_output)
14417 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14420 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14422 mp->filter = filter;
14427 /* Use a control ping for synchronization */
14429 vl_api_control_ping_t *mp;
14430 M (CONTROL_PING, control_ping);
14433 /* Wait for a reply... */
14441 api_lisp_eid_table_map_dump (vat_main_t * vam)
14445 unformat_input_t *input = vam->input;
14446 vl_api_lisp_eid_table_map_dump_t *mp;
14449 /* Parse args required to build the message */
14450 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14452 if (unformat (input, "l2"))
14457 else if (unformat (input, "l3"))
14464 errmsg ("parse error '%U'", format_unformat_error, input);
14471 errmsg ("expected one of 'l2' or 'l3' parameter!");
14475 if (!vam->json_output)
14477 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14480 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14486 /* Use a control ping for synchronization */
14488 vl_api_control_ping_t *mp;
14489 M (CONTROL_PING, control_ping);
14492 /* Wait for a reply... */
14500 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14502 vl_api_lisp_eid_table_vni_dump_t *mp;
14505 if (!vam->json_output)
14507 print (vam->ofp, "VNI");
14510 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14515 /* Use a control ping for synchronization */
14517 vl_api_control_ping_t *mp;
14518 M (CONTROL_PING, control_ping);
14521 /* Wait for a reply... */
14529 api_lisp_eid_table_dump (vat_main_t * vam)
14531 unformat_input_t *i = vam->input;
14532 vl_api_lisp_eid_table_dump_t *mp;
14534 struct in_addr ip4;
14535 struct in6_addr ip6;
14537 u8 eid_type = ~0, eid_set = 0;
14538 u32 prefix_length = ~0, t, vni = 0;
14541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14543 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14549 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14555 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14560 else if (unformat (i, "vni %d", &t))
14564 else if (unformat (i, "local"))
14568 else if (unformat (i, "remote"))
14574 errmsg ("parse error '%U'", format_unformat_error, i);
14579 if (!vam->json_output)
14581 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14582 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14585 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14587 mp->filter = filter;
14591 mp->vni = htonl (vni);
14592 mp->eid_type = eid_type;
14596 mp->prefix_length = prefix_length;
14597 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14600 mp->prefix_length = prefix_length;
14601 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14604 clib_memcpy (mp->eid, mac, sizeof (mac));
14607 errmsg ("unknown EID type %d!", eid_type);
14615 /* Use a control ping for synchronization */
14617 vl_api_control_ping_t *mp;
14618 M (CONTROL_PING, control_ping);
14622 /* Wait for a reply... */
14630 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14632 vl_api_lisp_gpe_tunnel_dump_t *mp;
14635 if (!vam->json_output)
14637 print (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14638 "%=16s%=16s%=16s%=16s%=16s",
14639 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14640 "Decap next", "Lisp version", "Flags", "Next protocol",
14641 "ver_res", "res", "iid");
14644 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14648 /* Use a control ping for synchronization */
14650 vl_api_control_ping_t *mp;
14651 M (CONTROL_PING, control_ping);
14654 /* Wait for a reply... */
14662 api_lisp_adjacencies_get (vat_main_t * vam)
14664 unformat_input_t *i = vam->input;
14665 vl_api_lisp_adjacencies_get_t *mp;
14670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14672 if (unformat (i, "vni %d", &vni))
14678 errmsg ("parse error '%U'", format_unformat_error, i);
14685 errmsg ("vni not set!");
14689 if (!vam->json_output)
14691 print (vam->ofp, "%s %40s", "leid", "reid");
14694 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14695 mp->vni = clib_host_to_net_u32 (vni);
14700 /* Wait for a reply... */
14708 api_lisp_map_server_dump (vat_main_t * vam)
14710 vl_api_lisp_map_server_dump_t *mp;
14713 if (!vam->json_output)
14715 print (vam->ofp, "%=20s", "Map server");
14718 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14722 /* Use a control ping for synchronization */
14724 vl_api_control_ping_t *mp;
14725 M (CONTROL_PING, control_ping);
14728 /* Wait for a reply... */
14736 api_lisp_map_resolver_dump (vat_main_t * vam)
14738 vl_api_lisp_map_resolver_dump_t *mp;
14741 if (!vam->json_output)
14743 print (vam->ofp, "%=20s", "Map resolver");
14746 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14750 /* Use a control ping for synchronization */
14752 vl_api_control_ping_t *mp;
14753 M (CONTROL_PING, control_ping);
14756 /* Wait for a reply... */
14764 api_show_lisp_status (vat_main_t * vam)
14766 vl_api_show_lisp_status_t *mp;
14769 if (!vam->json_output)
14771 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14774 M (SHOW_LISP_STATUS, show_lisp_status);
14777 /* Wait for a reply... */
14785 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14787 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14790 if (!vam->json_output)
14792 print (vam->ofp, "%=20s", "itr-rlocs:");
14795 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14798 /* Wait for a reply... */
14806 api_af_packet_create (vat_main_t * vam)
14808 unformat_input_t *i = vam->input;
14809 vl_api_af_packet_create_t *mp;
14811 u8 *host_if_name = 0;
14813 u8 random_hw_addr = 1;
14815 memset (hw_addr, 0, sizeof (hw_addr));
14817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14819 if (unformat (i, "name %s", &host_if_name))
14820 vec_add1 (host_if_name, 0);
14821 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14822 random_hw_addr = 0;
14827 if (!vec_len (host_if_name))
14829 errmsg ("host-interface name must be specified");
14833 if (vec_len (host_if_name) > 64)
14835 errmsg ("host-interface name too long");
14839 M (AF_PACKET_CREATE, af_packet_create);
14841 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14842 clib_memcpy (mp->hw_addr, hw_addr, 6);
14843 mp->use_random_hw_addr = random_hw_addr;
14844 vec_free (host_if_name);
14847 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14853 api_af_packet_delete (vat_main_t * vam)
14855 unformat_input_t *i = vam->input;
14856 vl_api_af_packet_delete_t *mp;
14858 u8 *host_if_name = 0;
14860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14862 if (unformat (i, "name %s", &host_if_name))
14863 vec_add1 (host_if_name, 0);
14868 if (!vec_len (host_if_name))
14870 errmsg ("host-interface name must be specified");
14874 if (vec_len (host_if_name) > 64)
14876 errmsg ("host-interface name too long");
14880 M (AF_PACKET_DELETE, af_packet_delete);
14882 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14883 vec_free (host_if_name);
14892 api_policer_add_del (vat_main_t * vam)
14894 unformat_input_t *i = vam->input;
14895 vl_api_policer_add_del_t *mp;
14906 u8 color_aware = 0;
14907 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14909 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14910 conform_action.dscp = 0;
14911 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14912 exceed_action.dscp = 0;
14913 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14914 violate_action.dscp = 0;
14916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14918 if (unformat (i, "del"))
14920 else if (unformat (i, "name %s", &name))
14921 vec_add1 (name, 0);
14922 else if (unformat (i, "cir %u", &cir))
14924 else if (unformat (i, "eir %u", &eir))
14926 else if (unformat (i, "cb %u", &cb))
14928 else if (unformat (i, "eb %u", &eb))
14930 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14933 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14936 else if (unformat (i, "type %U", unformat_policer_type, &type))
14938 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14941 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14944 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14947 else if (unformat (i, "color-aware"))
14953 if (!vec_len (name))
14955 errmsg ("policer name must be specified");
14959 if (vec_len (name) > 64)
14961 errmsg ("policer name too long");
14965 M (POLICER_ADD_DEL, policer_add_del);
14967 clib_memcpy (mp->name, name, vec_len (name));
14969 mp->is_add = is_add;
14974 mp->rate_type = rate_type;
14975 mp->round_type = round_type;
14977 mp->conform_action_type = conform_action.action_type;
14978 mp->conform_dscp = conform_action.dscp;
14979 mp->exceed_action_type = exceed_action.action_type;
14980 mp->exceed_dscp = exceed_action.dscp;
14981 mp->violate_action_type = violate_action.action_type;
14982 mp->violate_dscp = violate_action.dscp;
14983 mp->color_aware = color_aware;
14992 api_policer_dump (vat_main_t * vam)
14994 unformat_input_t *i = vam->input;
14995 vl_api_policer_dump_t *mp;
14997 u8 *match_name = 0;
14998 u8 match_name_valid = 0;
15000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15002 if (unformat (i, "name %s", &match_name))
15004 vec_add1 (match_name, 0);
15005 match_name_valid = 1;
15011 M (POLICER_DUMP, policer_dump);
15012 mp->match_name_valid = match_name_valid;
15013 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15014 vec_free (match_name);
15018 /* Use a control ping for synchronization */
15020 vl_api_control_ping_t *mp;
15021 M (CONTROL_PING, control_ping);
15024 /* Wait for a reply... */
15032 api_policer_classify_set_interface (vat_main_t * vam)
15034 unformat_input_t *i = vam->input;
15035 vl_api_policer_classify_set_interface_t *mp;
15038 int sw_if_index_set;
15039 u32 ip4_table_index = ~0;
15040 u32 ip6_table_index = ~0;
15041 u32 l2_table_index = ~0;
15044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15046 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15047 sw_if_index_set = 1;
15048 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15049 sw_if_index_set = 1;
15050 else if (unformat (i, "del"))
15052 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15054 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15056 else if (unformat (i, "l2-table %d", &l2_table_index))
15060 clib_warning ("parse error '%U'", format_unformat_error, i);
15065 if (sw_if_index_set == 0)
15067 errmsg ("missing interface name or sw_if_index");
15071 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15073 mp->sw_if_index = ntohl (sw_if_index);
15074 mp->ip4_table_index = ntohl (ip4_table_index);
15075 mp->ip6_table_index = ntohl (ip6_table_index);
15076 mp->l2_table_index = ntohl (l2_table_index);
15077 mp->is_add = is_add;
15086 api_policer_classify_dump (vat_main_t * vam)
15088 unformat_input_t *i = vam->input;
15089 vl_api_policer_classify_dump_t *mp;
15091 u8 type = POLICER_CLASSIFY_N_TABLES;
15093 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15097 errmsg ("classify table type must be specified");
15101 if (!vam->json_output)
15103 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15106 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15111 /* Use a control ping for synchronization */
15113 vl_api_control_ping_t *mp;
15114 M (CONTROL_PING, control_ping);
15117 /* Wait for a reply... */
15125 api_netmap_create (vat_main_t * vam)
15127 unformat_input_t *i = vam->input;
15128 vl_api_netmap_create_t *mp;
15132 u8 random_hw_addr = 1;
15136 memset (hw_addr, 0, sizeof (hw_addr));
15138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15140 if (unformat (i, "name %s", &if_name))
15141 vec_add1 (if_name, 0);
15142 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15143 random_hw_addr = 0;
15144 else if (unformat (i, "pipe"))
15146 else if (unformat (i, "master"))
15148 else if (unformat (i, "slave"))
15154 if (!vec_len (if_name))
15156 errmsg ("interface name must be specified");
15160 if (vec_len (if_name) > 64)
15162 errmsg ("interface name too long");
15166 M (NETMAP_CREATE, netmap_create);
15168 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15169 clib_memcpy (mp->hw_addr, hw_addr, 6);
15170 mp->use_random_hw_addr = random_hw_addr;
15171 mp->is_pipe = is_pipe;
15172 mp->is_master = is_master;
15173 vec_free (if_name);
15182 api_netmap_delete (vat_main_t * vam)
15184 unformat_input_t *i = vam->input;
15185 vl_api_netmap_delete_t *mp;
15189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15191 if (unformat (i, "name %s", &if_name))
15192 vec_add1 (if_name, 0);
15197 if (!vec_len (if_name))
15199 errmsg ("interface name must be specified");
15203 if (vec_len (if_name) > 64)
15205 errmsg ("interface name too long");
15209 M (NETMAP_DELETE, netmap_delete);
15211 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15212 vec_free (if_name);
15220 static void vl_api_mpls_tunnel_details_t_handler
15221 (vl_api_mpls_tunnel_details_t * mp)
15223 vat_main_t *vam = &vat_main;
15224 i32 len = mp->mt_next_hop_n_labels;
15227 print (vam->ofp, "[%d]: via %U %d labels ",
15229 format_ip4_address, mp->mt_next_hop,
15230 ntohl (mp->mt_next_hop_sw_if_index));
15231 for (i = 0; i < len; i++)
15233 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15235 print (vam->ofp, "");
15238 static void vl_api_mpls_tunnel_details_t_handler_json
15239 (vl_api_mpls_tunnel_details_t * mp)
15241 vat_main_t *vam = &vat_main;
15242 vat_json_node_t *node = NULL;
15243 struct in_addr ip4;
15245 i32 len = mp->mt_next_hop_n_labels;
15247 if (VAT_JSON_ARRAY != vam->json_tree.type)
15249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15250 vat_json_init_array (&vam->json_tree);
15252 node = vat_json_array_add (&vam->json_tree);
15254 vat_json_init_object (node);
15255 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15256 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15257 vat_json_object_add_ip4 (node, "next_hop", ip4);
15258 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15259 ntohl (mp->mt_next_hop_sw_if_index));
15260 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15261 vat_json_object_add_uint (node, "label_count", len);
15262 for (i = 0; i < len; i++)
15264 vat_json_object_add_uint (node, "label",
15265 ntohl (mp->mt_next_hop_out_labels[i]));
15270 api_mpls_tunnel_dump (vat_main_t * vam)
15272 vl_api_mpls_tunnel_dump_t *mp;
15276 /* Parse args required to build the message */
15277 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15279 if (!unformat (vam->input, "tunnel_index %d", &index))
15286 print (vam->ofp, " tunnel_index %d", index);
15288 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15289 mp->tunnel_index = htonl (index);
15292 /* Use a control ping for synchronization */
15294 vl_api_control_ping_t *mp;
15295 M (CONTROL_PING, control_ping);
15301 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15302 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15305 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15307 vat_main_t *vam = &vat_main;
15308 int count = ntohl (mp->count);
15309 vl_api_fib_path2_t *fp;
15313 "table-id %d, label %u, ess_bit %u",
15314 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15316 for (i = 0; i < count; i++)
15318 if (fp->afi == IP46_TYPE_IP6)
15320 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15321 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15322 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15323 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15324 format_ip6_address, fp->next_hop);
15325 else if (fp->afi == IP46_TYPE_IP4)
15327 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15328 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15329 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15330 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15331 format_ip4_address, fp->next_hop);
15336 static void vl_api_mpls_fib_details_t_handler_json
15337 (vl_api_mpls_fib_details_t * mp)
15339 vat_main_t *vam = &vat_main;
15340 int count = ntohl (mp->count);
15341 vat_json_node_t *node = NULL;
15342 struct in_addr ip4;
15343 struct in6_addr ip6;
15344 vl_api_fib_path2_t *fp;
15347 if (VAT_JSON_ARRAY != vam->json_tree.type)
15349 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15350 vat_json_init_array (&vam->json_tree);
15352 node = vat_json_array_add (&vam->json_tree);
15354 vat_json_init_object (node);
15355 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15356 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15357 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15358 vat_json_object_add_uint (node, "path_count", count);
15360 for (i = 0; i < count; i++)
15362 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15363 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15364 vat_json_object_add_uint (node, "is_local", fp->is_local);
15365 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15366 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15367 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15368 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15369 if (fp->afi == IP46_TYPE_IP4)
15371 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15372 vat_json_object_add_ip4 (node, "next_hop", ip4);
15374 else if (fp->afi == IP46_TYPE_IP6)
15376 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15377 vat_json_object_add_ip6 (node, "next_hop", ip6);
15383 api_mpls_fib_dump (vat_main_t * vam)
15385 vl_api_mpls_fib_dump_t *mp;
15388 M (MPLS_FIB_DUMP, mpls_fib_dump);
15391 /* Use a control ping for synchronization */
15393 vl_api_control_ping_t *mp;
15394 M (CONTROL_PING, control_ping);
15400 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15401 #define vl_api_ip_fib_details_t_print vl_noop_handler
15404 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15406 vat_main_t *vam = &vat_main;
15407 int count = ntohl (mp->count);
15408 vl_api_fib_path_t *fp;
15412 "table-id %d, prefix %U/%d",
15413 ntohl (mp->table_id), format_ip4_address, mp->address,
15414 mp->address_length);
15416 for (i = 0; i < count; i++)
15418 if (fp->afi == IP46_TYPE_IP6)
15420 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15421 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15422 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15423 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15424 format_ip6_address, fp->next_hop);
15425 else if (fp->afi == IP46_TYPE_IP4)
15427 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15428 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15429 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15430 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15431 format_ip4_address, fp->next_hop);
15436 static void vl_api_ip_fib_details_t_handler_json
15437 (vl_api_ip_fib_details_t * mp)
15439 vat_main_t *vam = &vat_main;
15440 int count = ntohl (mp->count);
15441 vat_json_node_t *node = NULL;
15442 struct in_addr ip4;
15443 struct in6_addr ip6;
15444 vl_api_fib_path_t *fp;
15447 if (VAT_JSON_ARRAY != vam->json_tree.type)
15449 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15450 vat_json_init_array (&vam->json_tree);
15452 node = vat_json_array_add (&vam->json_tree);
15454 vat_json_init_object (node);
15455 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15456 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15457 vat_json_object_add_ip4 (node, "prefix", ip4);
15458 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15459 vat_json_object_add_uint (node, "path_count", count);
15461 for (i = 0; i < count; i++)
15463 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15464 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15465 vat_json_object_add_uint (node, "is_local", fp->is_local);
15466 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15467 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15468 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15469 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15470 if (fp->afi == IP46_TYPE_IP4)
15472 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15473 vat_json_object_add_ip4 (node, "next_hop", ip4);
15475 else if (fp->afi == IP46_TYPE_IP6)
15477 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15478 vat_json_object_add_ip6 (node, "next_hop", ip6);
15484 api_ip_fib_dump (vat_main_t * vam)
15486 vl_api_ip_fib_dump_t *mp;
15489 M (IP_FIB_DUMP, ip_fib_dump);
15492 /* Use a control ping for synchronization */
15494 vl_api_control_ping_t *mp;
15495 M (CONTROL_PING, control_ping);
15501 static void vl_api_ip_neighbor_details_t_handler
15502 (vl_api_ip_neighbor_details_t * mp)
15504 vat_main_t *vam = &vat_main;
15506 print (vam->ofp, "%c %U %U",
15507 (mp->is_static) ? 'S' : 'D',
15508 format_ethernet_address, &mp->mac_address,
15509 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15513 static void vl_api_ip_neighbor_details_t_handler_json
15514 (vl_api_ip_neighbor_details_t * mp)
15517 vat_main_t *vam = &vat_main;
15518 vat_json_node_t *node;
15519 struct in_addr ip4;
15520 struct in6_addr ip6;
15522 if (VAT_JSON_ARRAY != vam->json_tree.type)
15524 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15525 vat_json_init_array (&vam->json_tree);
15527 node = vat_json_array_add (&vam->json_tree);
15529 vat_json_init_object (node);
15530 vat_json_object_add_string_copy (node, "flag",
15531 (mp->is_static) ? (u8 *) "static" : (u8 *)
15534 vat_json_object_add_string_copy (node, "link_layer",
15535 format (0, "%U", format_ethernet_address,
15536 &mp->mac_address));
15540 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15541 vat_json_object_add_ip6 (node, "ip_address", ip6);
15545 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15546 vat_json_object_add_ip4 (node, "ip_address", ip4);
15551 api_ip_neighbor_dump (vat_main_t * vam)
15553 unformat_input_t *i = vam->input;
15554 vl_api_ip_neighbor_dump_t *mp;
15557 u32 sw_if_index = ~0;
15559 /* Parse args required to build the message */
15560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15562 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15564 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15566 else if (unformat (i, "ip6"))
15572 if (sw_if_index == ~0)
15574 errmsg ("missing interface name or sw_if_index");
15578 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15579 mp->is_ipv6 = (u8) is_ipv6;
15580 mp->sw_if_index = ntohl (sw_if_index);
15583 /* Use a control ping for synchronization */
15585 vl_api_control_ping_t *mp;
15586 M (CONTROL_PING, control_ping);
15592 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15593 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15596 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15598 vat_main_t *vam = &vat_main;
15599 int count = ntohl (mp->count);
15600 vl_api_fib_path_t *fp;
15604 "table-id %d, prefix %U/%d",
15605 ntohl (mp->table_id), format_ip6_address, mp->address,
15606 mp->address_length);
15608 for (i = 0; i < count; i++)
15610 if (fp->afi == IP46_TYPE_IP6)
15612 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15613 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15614 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15615 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15616 format_ip6_address, fp->next_hop);
15617 else if (fp->afi == IP46_TYPE_IP4)
15619 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15620 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15621 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15622 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15623 format_ip4_address, fp->next_hop);
15628 static void vl_api_ip6_fib_details_t_handler_json
15629 (vl_api_ip6_fib_details_t * mp)
15631 vat_main_t *vam = &vat_main;
15632 int count = ntohl (mp->count);
15633 vat_json_node_t *node = NULL;
15634 struct in_addr ip4;
15635 struct in6_addr ip6;
15636 vl_api_fib_path_t *fp;
15639 if (VAT_JSON_ARRAY != vam->json_tree.type)
15641 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15642 vat_json_init_array (&vam->json_tree);
15644 node = vat_json_array_add (&vam->json_tree);
15646 vat_json_init_object (node);
15647 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15648 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15649 vat_json_object_add_ip6 (node, "prefix", ip6);
15650 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15651 vat_json_object_add_uint (node, "path_count", count);
15653 for (i = 0; i < count; i++)
15655 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15656 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15657 vat_json_object_add_uint (node, "is_local", fp->is_local);
15658 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15659 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15660 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15661 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15662 if (fp->afi == IP46_TYPE_IP4)
15664 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15665 vat_json_object_add_ip4 (node, "next_hop", ip4);
15667 else if (fp->afi == IP46_TYPE_IP6)
15669 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15670 vat_json_object_add_ip6 (node, "next_hop", ip6);
15676 api_ip6_fib_dump (vat_main_t * vam)
15678 vl_api_ip6_fib_dump_t *mp;
15681 M (IP6_FIB_DUMP, ip6_fib_dump);
15684 /* Use a control ping for synchronization */
15686 vl_api_control_ping_t *mp;
15687 M (CONTROL_PING, control_ping);
15694 api_classify_table_ids (vat_main_t * vam)
15696 vl_api_classify_table_ids_t *mp;
15699 /* Construct the API message */
15700 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15710 api_classify_table_by_interface (vat_main_t * vam)
15712 unformat_input_t *input = vam->input;
15713 vl_api_classify_table_by_interface_t *mp;
15716 u32 sw_if_index = ~0;
15717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15719 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15721 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15726 if (sw_if_index == ~0)
15728 errmsg ("missing interface name or sw_if_index");
15732 /* Construct the API message */
15733 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15735 mp->sw_if_index = ntohl (sw_if_index);
15744 api_classify_table_info (vat_main_t * vam)
15746 unformat_input_t *input = vam->input;
15747 vl_api_classify_table_info_t *mp;
15751 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15753 if (unformat (input, "table_id %d", &table_id))
15758 if (table_id == ~0)
15760 errmsg ("missing table id");
15764 /* Construct the API message */
15765 M (CLASSIFY_TABLE_INFO, classify_table_info);
15767 mp->table_id = ntohl (table_id);
15776 api_classify_session_dump (vat_main_t * vam)
15778 unformat_input_t *input = vam->input;
15779 vl_api_classify_session_dump_t *mp;
15783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15785 if (unformat (input, "table_id %d", &table_id))
15790 if (table_id == ~0)
15792 errmsg ("missing table id");
15796 /* Construct the API message */
15797 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15799 mp->table_id = ntohl (table_id);
15802 /* Use a control ping for synchronization */
15804 vl_api_control_ping_t *mp;
15805 M (CONTROL_PING, control_ping);
15814 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15816 vat_main_t *vam = &vat_main;
15818 print (vam->ofp, "collector_address %U, collector_port %d, "
15819 "src_address %U, vrf_id %d, path_mtu %u, "
15820 "template_interval %u, udp_checksum %d",
15821 format_ip4_address, mp->collector_address,
15822 ntohs (mp->collector_port),
15823 format_ip4_address, mp->src_address,
15824 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15825 ntohl (mp->template_interval), mp->udp_checksum);
15828 vam->result_ready = 1;
15832 vl_api_ipfix_exporter_details_t_handler_json
15833 (vl_api_ipfix_exporter_details_t * mp)
15835 vat_main_t *vam = &vat_main;
15836 vat_json_node_t node;
15837 struct in_addr collector_address;
15838 struct in_addr src_address;
15840 vat_json_init_object (&node);
15841 clib_memcpy (&collector_address, &mp->collector_address,
15842 sizeof (collector_address));
15843 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15844 vat_json_object_add_uint (&node, "collector_port",
15845 ntohs (mp->collector_port));
15846 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15847 vat_json_object_add_ip4 (&node, "src_address", src_address);
15848 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15849 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15850 vat_json_object_add_uint (&node, "template_interval",
15851 ntohl (mp->template_interval));
15852 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15854 vat_json_print (vam->ofp, &node);
15855 vat_json_free (&node);
15857 vam->result_ready = 1;
15861 api_ipfix_exporter_dump (vat_main_t * vam)
15863 vl_api_ipfix_exporter_dump_t *mp;
15866 /* Construct the API message */
15867 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15877 api_ipfix_classify_stream_dump (vat_main_t * vam)
15879 vl_api_ipfix_classify_stream_dump_t *mp;
15882 /* Construct the API message */
15883 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15893 vl_api_ipfix_classify_stream_details_t_handler
15894 (vl_api_ipfix_classify_stream_details_t * mp)
15896 vat_main_t *vam = &vat_main;
15897 print (vam->ofp, "domain_id %d, src_port %d",
15898 ntohl (mp->domain_id), ntohs (mp->src_port));
15900 vam->result_ready = 1;
15904 vl_api_ipfix_classify_stream_details_t_handler_json
15905 (vl_api_ipfix_classify_stream_details_t * mp)
15907 vat_main_t *vam = &vat_main;
15908 vat_json_node_t node;
15910 vat_json_init_object (&node);
15911 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15912 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15914 vat_json_print (vam->ofp, &node);
15915 vat_json_free (&node);
15917 vam->result_ready = 1;
15921 api_ipfix_classify_table_dump (vat_main_t * vam)
15923 vl_api_ipfix_classify_table_dump_t *mp;
15926 if (!vam->json_output)
15928 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
15929 "transport_protocol");
15932 /* Construct the API message */
15933 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15938 /* Use a control ping for synchronization */
15940 vl_api_control_ping_t *mp;
15941 M (CONTROL_PING, control_ping);
15948 vl_api_ipfix_classify_table_details_t_handler
15949 (vl_api_ipfix_classify_table_details_t * mp)
15951 vat_main_t *vam = &vat_main;
15952 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
15953 mp->transport_protocol);
15957 vl_api_ipfix_classify_table_details_t_handler_json
15958 (vl_api_ipfix_classify_table_details_t * mp)
15960 vat_json_node_t *node = NULL;
15961 vat_main_t *vam = &vat_main;
15963 if (VAT_JSON_ARRAY != vam->json_tree.type)
15965 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15966 vat_json_init_array (&vam->json_tree);
15969 node = vat_json_array_add (&vam->json_tree);
15970 vat_json_init_object (node);
15972 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15973 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15974 vat_json_object_add_uint (node, "transport_protocol",
15975 mp->transport_protocol);
15979 api_sw_interface_span_enable_disable (vat_main_t * vam)
15981 unformat_input_t *i = vam->input;
15982 vl_api_sw_interface_span_enable_disable_t *mp;
15984 u32 src_sw_if_index = ~0;
15985 u32 dst_sw_if_index = ~0;
15988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15991 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
15993 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15997 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
15999 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16001 else if (unformat (i, "disable"))
16003 else if (unformat (i, "rx"))
16005 else if (unformat (i, "tx"))
16007 else if (unformat (i, "both"))
16013 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16015 mp->sw_if_index_from = htonl (src_sw_if_index);
16016 mp->sw_if_index_to = htonl (dst_sw_if_index);
16026 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16029 vat_main_t *vam = &vat_main;
16030 u8 *sw_if_from_name = 0;
16031 u8 *sw_if_to_name = 0;
16032 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16033 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16034 char *states[] = { "none", "rx", "tx", "both" };
16038 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16040 if ((u32) p->value[0] == sw_if_index_from)
16042 sw_if_from_name = (u8 *)(p->key);
16046 if ((u32) p->value[0] == sw_if_index_to)
16048 sw_if_to_name = (u8 *)(p->key);
16049 if (sw_if_from_name)
16054 print (vam->ofp, "%20s => %20s (%s)",
16055 sw_if_from_name, sw_if_to_name, states[mp->state]);
16059 vl_api_sw_interface_span_details_t_handler_json
16060 (vl_api_sw_interface_span_details_t * mp)
16062 vat_main_t *vam = &vat_main;
16063 vat_json_node_t *node = NULL;
16064 u8 *sw_if_from_name = 0;
16065 u8 *sw_if_to_name = 0;
16066 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16067 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16071 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16073 if ((u32) p->value[0] == sw_if_index_from)
16075 sw_if_from_name = (u8 *)(p->key);
16079 if ((u32) p->value[0] == sw_if_index_to)
16081 sw_if_to_name = (u8 *)(p->key);
16082 if (sw_if_from_name)
16088 if (VAT_JSON_ARRAY != vam->json_tree.type)
16090 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16091 vat_json_init_array (&vam->json_tree);
16093 node = vat_json_array_add (&vam->json_tree);
16095 vat_json_init_object (node);
16096 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16097 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16098 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16099 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16100 vat_json_object_add_uint (node, "state", mp->state);
16104 api_sw_interface_span_dump (vat_main_t * vam)
16106 vl_api_sw_interface_span_dump_t *mp;
16109 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16112 /* Use a control ping for synchronization */
16114 vl_api_control_ping_t *mp;
16115 M (CONTROL_PING, control_ping);
16122 api_pg_create_interface (vat_main_t * vam)
16124 unformat_input_t *input = vam->input;
16125 vl_api_pg_create_interface_t *mp;
16129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16131 if (unformat (input, "if_id %d", &if_id))
16138 errmsg ("missing pg interface index");
16142 /* Construct the API message */
16143 M (PG_CREATE_INTERFACE, pg_create_interface);
16145 mp->interface_id = ntohl (if_id);
16154 api_pg_capture (vat_main_t * vam)
16156 unformat_input_t *input = vam->input;
16157 vl_api_pg_capture_t *mp;
16163 u8 pcap_file_set = 0;
16165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16167 if (unformat (input, "if_id %d", &if_id))
16169 else if (unformat (input, "pcap %s", &pcap_file))
16171 else if (unformat (input, "count %d", &count))
16173 else if (unformat (input, "disable"))
16180 errmsg ("missing pg interface index");
16183 if (pcap_file_set > 0)
16185 if (vec_len (pcap_file) > 255)
16187 errmsg ("pcap file name is too long");
16192 u32 name_len = vec_len (pcap_file);
16193 /* Construct the API message */
16194 M (PG_CAPTURE, pg_capture);
16196 mp->interface_id = ntohl (if_id);
16197 mp->is_enabled = enable;
16198 mp->count = ntohl (count);
16199 mp->pcap_name_length = ntohl (name_len);
16200 if (pcap_file_set != 0)
16202 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16204 vec_free (pcap_file);
16213 api_pg_enable_disable (vat_main_t * vam)
16215 unformat_input_t *input = vam->input;
16216 vl_api_pg_enable_disable_t *mp;
16220 u8 stream_name_set = 0;
16221 u8 *stream_name = 0;
16222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16224 if (unformat (input, "stream %s", &stream_name))
16225 stream_name_set = 1;
16226 else if (unformat (input, "disable"))
16232 if (stream_name_set > 0)
16234 if (vec_len (stream_name) > 255)
16236 errmsg ("stream name too long");
16241 u32 name_len = vec_len (stream_name);
16242 /* Construct the API message */
16243 M (PG_ENABLE_DISABLE, pg_enable_disable);
16245 mp->is_enabled = enable;
16246 if (stream_name_set != 0)
16248 mp->stream_name_length = ntohl (name_len);
16249 clib_memcpy (mp->stream_name, stream_name, name_len);
16251 vec_free (stream_name);
16260 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16262 unformat_input_t *input = vam->input;
16263 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16266 u16 *low_ports = 0;
16267 u16 *high_ports = 0;
16270 ip4_address_t ip4_addr;
16271 ip6_address_t ip6_addr;
16279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16281 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16287 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16292 else if (unformat (input, "vrf %d", &vrf_id))
16294 else if (unformat (input, "del"))
16296 else if (unformat (input, "port %d", &tmp))
16298 if (tmp == 0 || tmp > 65535)
16300 errmsg ("port %d out of range", tmp);
16304 this_hi = this_low + 1;
16305 vec_add1 (low_ports, this_low);
16306 vec_add1 (high_ports, this_hi);
16308 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16310 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16312 errmsg ("incorrect range parameters");
16316 /* Note: in debug CLI +1 is added to high before
16317 passing to real fn that does "the work"
16318 (ip_source_and_port_range_check_add_del).
16319 This fn is a wrapper around the binary API fn a
16320 control plane will call, which expects this increment
16321 to have occurred. Hence letting the binary API control
16322 plane fn do the increment for consistency between VAT
16323 and other control planes.
16326 vec_add1 (low_ports, this_low);
16327 vec_add1 (high_ports, this_hi);
16333 if (prefix_set == 0)
16335 errmsg ("<address>/<mask> not specified");
16341 errmsg ("VRF ID required, not specified");
16348 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16352 if (vec_len (low_ports) == 0)
16354 errmsg ("At least one port or port range required");
16358 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16359 ip_source_and_port_range_check_add_del);
16361 mp->is_add = is_add;
16366 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16371 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16374 mp->mask_length = length;
16375 mp->number_of_ranges = vec_len (low_ports);
16377 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16378 vec_free (low_ports);
16380 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16381 vec_free (high_ports);
16383 mp->vrf_id = ntohl (vrf_id);
16392 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16394 unformat_input_t *input = vam->input;
16395 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16397 u32 sw_if_index = ~0;
16399 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16400 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16405 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16407 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16409 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16411 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16413 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16415 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16417 else if (unformat (input, "del"))
16423 if (sw_if_index == ~0)
16425 errmsg ("Interface required but not specified");
16431 errmsg ("VRF ID required but not specified");
16435 if (tcp_out_vrf_id == 0
16436 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16439 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16443 /* Construct the API message */
16444 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16445 ip_source_and_port_range_check_interface_add_del);
16447 mp->sw_if_index = ntohl (sw_if_index);
16448 mp->is_add = is_add;
16449 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16450 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16451 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16452 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16457 /* Wait for a reply... */
16462 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16464 unformat_input_t *i = vam->input;
16465 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16467 u32 local_sa_id = 0;
16468 u32 remote_sa_id = 0;
16469 ip4_address_t src_address;
16470 ip4_address_t dst_address;
16473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16475 if (unformat (i, "local_sa %d", &local_sa_id))
16477 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16479 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16481 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16483 else if (unformat (i, "del"))
16487 clib_warning ("parse error '%U'", format_unformat_error, i);
16492 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16494 mp->local_sa_id = ntohl (local_sa_id);
16495 mp->remote_sa_id = ntohl (remote_sa_id);
16496 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16497 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16498 mp->is_add = is_add;
16507 api_punt (vat_main_t * vam)
16509 unformat_input_t *i = vam->input;
16517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16519 if (unformat (i, "ip %d", &ipv))
16521 else if (unformat (i, "protocol %d", &protocol))
16523 else if (unformat (i, "port %d", &port))
16525 else if (unformat (i, "del"))
16529 clib_warning ("parse error '%U'", format_unformat_error, i);
16536 mp->is_add = (u8) is_add;
16537 mp->ipv = (u8) ipv;
16538 mp->l4_protocol = (u8) protocol;
16539 mp->l4_port = htons ((u16) port);
16547 static void vl_api_ipsec_gre_tunnel_details_t_handler
16548 (vl_api_ipsec_gre_tunnel_details_t * mp)
16550 vat_main_t *vam = &vat_main;
16552 print (vam->ofp, "%11d%15U%15U%14d%14d",
16553 ntohl (mp->sw_if_index),
16554 format_ip4_address, &mp->src_address,
16555 format_ip4_address, &mp->dst_address,
16556 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16559 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16560 (vl_api_ipsec_gre_tunnel_details_t * mp)
16562 vat_main_t *vam = &vat_main;
16563 vat_json_node_t *node = NULL;
16564 struct in_addr ip4;
16566 if (VAT_JSON_ARRAY != vam->json_tree.type)
16568 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16569 vat_json_init_array (&vam->json_tree);
16571 node = vat_json_array_add (&vam->json_tree);
16573 vat_json_init_object (node);
16574 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16575 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16576 vat_json_object_add_ip4 (node, "src_address", ip4);
16577 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16578 vat_json_object_add_ip4 (node, "dst_address", ip4);
16579 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16580 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16584 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16586 unformat_input_t *i = vam->input;
16587 vl_api_ipsec_gre_tunnel_dump_t *mp;
16590 u8 sw_if_index_set = 0;
16592 /* Parse args required to build the message */
16593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16595 if (unformat (i, "sw_if_index %d", &sw_if_index))
16596 sw_if_index_set = 1;
16601 if (sw_if_index_set == 0)
16606 if (!vam->json_output)
16608 print (vam->ofp, "%11s%15s%15s%14s%14s",
16609 "sw_if_index", "src_address", "dst_address",
16610 "local_sa_id", "remote_sa_id");
16613 /* Get list of gre-tunnel interfaces */
16614 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16616 mp->sw_if_index = htonl (sw_if_index);
16620 /* Use a control ping for synchronization */
16622 vl_api_control_ping_t *mp;
16623 M (CONTROL_PING, control_ping);
16630 api_delete_subif (vat_main_t * vam)
16632 unformat_input_t *i = vam->input;
16633 vl_api_delete_subif_t *mp;
16635 u32 sw_if_index = ~0;
16637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16639 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16641 if (unformat (i, "sw_if_index %d", &sw_if_index))
16647 if (sw_if_index == ~0)
16649 errmsg ("missing sw_if_index");
16653 /* Construct the API message */
16654 M (DELETE_SUBIF, delete_subif);
16655 mp->sw_if_index = ntohl (sw_if_index);
16661 #define foreach_pbb_vtr_op \
16662 _("disable", L2_VTR_DISABLED) \
16663 _("pop", L2_VTR_POP_2) \
16664 _("push", L2_VTR_PUSH_2)
16667 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16669 unformat_input_t *i = vam->input;
16670 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16672 u32 sw_if_index = ~0, vtr_op = ~0;
16673 u16 outer_tag = ~0;
16674 u8 dmac[6], smac[6];
16675 u8 dmac_set = 0, smac_set = 0;
16680 /* Shut up coverity */
16681 memset (dmac, 0, sizeof (dmac));
16682 memset (smac, 0, sizeof (smac));
16684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16686 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16688 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16690 else if (unformat (i, "vtr_op %d", &vtr_op))
16692 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16695 else if (unformat (i, "translate_pbb_stag"))
16697 if (unformat (i, "%d", &tmp))
16699 vtr_op = L2_VTR_TRANSLATE_2_1;
16705 ("translate_pbb_stag operation requires outer tag definition");
16709 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16711 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16713 else if (unformat (i, "sid %d", &sid))
16715 else if (unformat (i, "vlanid %d", &tmp))
16719 clib_warning ("parse error '%U'", format_unformat_error, i);
16724 if ((sw_if_index == ~0) || (vtr_op == ~0))
16726 errmsg ("missing sw_if_index or vtr operation");
16729 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16730 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16733 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16737 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16738 mp->sw_if_index = ntohl (sw_if_index);
16739 mp->vtr_op = ntohl (vtr_op);
16740 mp->outer_tag = ntohs (outer_tag);
16741 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16742 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16743 mp->b_vlanid = ntohs (vlanid);
16744 mp->i_sid = ntohl (sid);
16753 api_flow_classify_set_interface (vat_main_t * vam)
16755 unformat_input_t *i = vam->input;
16756 vl_api_flow_classify_set_interface_t *mp;
16759 int sw_if_index_set;
16760 u32 ip4_table_index = ~0;
16761 u32 ip6_table_index = ~0;
16764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16766 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16767 sw_if_index_set = 1;
16768 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16769 sw_if_index_set = 1;
16770 else if (unformat (i, "del"))
16772 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16774 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16778 clib_warning ("parse error '%U'", format_unformat_error, i);
16783 if (sw_if_index_set == 0)
16785 errmsg ("missing interface name or sw_if_index");
16789 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16791 mp->sw_if_index = ntohl (sw_if_index);
16792 mp->ip4_table_index = ntohl (ip4_table_index);
16793 mp->ip6_table_index = ntohl (ip6_table_index);
16794 mp->is_add = is_add;
16803 api_flow_classify_dump (vat_main_t * vam)
16805 unformat_input_t *i = vam->input;
16806 vl_api_flow_classify_dump_t *mp;
16808 u8 type = FLOW_CLASSIFY_N_TABLES;
16810 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16814 errmsg ("classify table type must be specified");
16818 if (!vam->json_output)
16820 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16823 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16828 /* Use a control ping for synchronization */
16830 vl_api_control_ping_t *mp;
16831 M (CONTROL_PING, control_ping);
16834 /* Wait for a reply... */
16842 api_feature_enable_disable (vat_main_t * vam)
16844 unformat_input_t *i = vam->input;
16845 vl_api_feature_enable_disable_t *mp;
16848 u8 *feature_name = 0;
16849 u32 sw_if_index = ~0;
16852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16854 if (unformat (i, "arc_name %s", &arc_name))
16856 else if (unformat (i, "feature_name %s", &feature_name))
16859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16863 else if (unformat (i, "disable"))
16871 errmsg ("missing arc name");
16874 if (vec_len (arc_name) > 63)
16876 errmsg ("arc name too long");
16879 if (feature_name == 0)
16881 errmsg ("missing feature name");
16884 if (vec_len (feature_name) > 63)
16886 errmsg ("feature name too long");
16889 if (sw_if_index == ~0)
16891 errmsg ("missing interface name or sw_if_index");
16895 /* Construct the API message */
16896 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16897 mp->sw_if_index = ntohl (sw_if_index);
16898 mp->enable = enable;
16899 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16900 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16901 vec_free (arc_name);
16902 vec_free (feature_name);
16909 api_sw_interface_tag_add_del (vat_main_t * vam)
16911 unformat_input_t *i = vam->input;
16912 vl_api_sw_interface_tag_add_del_t *mp;
16914 u32 sw_if_index = ~0;
16918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16920 if (unformat (i, "tag %s", &tag))
16922 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16926 else if (unformat (i, "del"))
16932 if (sw_if_index == ~0)
16934 errmsg ("missing interface name or sw_if_index");
16938 if (enable && (tag == 0))
16940 errmsg ("no tag specified");
16944 /* Construct the API message */
16945 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16946 mp->sw_if_index = ntohl (sw_if_index);
16947 mp->is_add = enable;
16949 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16956 static void vl_api_l2_xconnect_details_t_handler
16957 (vl_api_l2_xconnect_details_t * mp)
16959 vat_main_t *vam = &vat_main;
16961 print (vam->ofp, "%15d%15d",
16962 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16965 static void vl_api_l2_xconnect_details_t_handler_json
16966 (vl_api_l2_xconnect_details_t * mp)
16968 vat_main_t *vam = &vat_main;
16969 vat_json_node_t *node = NULL;
16971 if (VAT_JSON_ARRAY != vam->json_tree.type)
16973 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16974 vat_json_init_array (&vam->json_tree);
16976 node = vat_json_array_add (&vam->json_tree);
16978 vat_json_init_object (node);
16979 vat_json_object_add_uint (node, "rx_sw_if_index",
16980 ntohl (mp->rx_sw_if_index));
16981 vat_json_object_add_uint (node, "tx_sw_if_index",
16982 ntohl (mp->tx_sw_if_index));
16986 api_l2_xconnect_dump (vat_main_t * vam)
16988 vl_api_l2_xconnect_dump_t *mp;
16991 if (!vam->json_output)
16993 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
16996 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
17000 /* Use a control ping for synchronization */
17002 vl_api_control_ping_t *mp;
17003 M (CONTROL_PING, control_ping);
17010 api_sw_interface_set_mtu (vat_main_t * vam)
17012 unformat_input_t *i = vam->input;
17013 vl_api_sw_interface_set_mtu_t *mp;
17015 u32 sw_if_index = ~0;
17018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17020 if (unformat (i, "mtu %d", &mtu))
17022 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17024 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17030 if (sw_if_index == ~0)
17032 errmsg ("missing interface name or sw_if_index");
17038 errmsg ("no mtu specified");
17042 /* Construct the API message */
17043 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17044 mp->sw_if_index = ntohl (sw_if_index);
17045 mp->mtu = ntohs ((u16) mtu);
17053 q_or_quit (vat_main_t * vam)
17055 longjmp (vam->jump_buf, 1);
17056 return 0; /* not so much */
17060 q (vat_main_t * vam)
17062 return q_or_quit (vam);
17066 quit (vat_main_t * vam)
17068 return q_or_quit (vam);
17072 comment (vat_main_t * vam)
17078 cmd_cmp (void *a1, void *a2)
17083 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17087 help (vat_main_t * vam)
17092 unformat_input_t *i = vam->input;
17095 if (unformat (i, "%s", &name))
17099 vec_add1 (name, 0);
17101 hs = hash_get_mem (vam->help_by_name, name);
17103 print (vam->ofp, "usage: %s %s", name, hs[0]);
17105 print (vam->ofp, "No such msg / command '%s'", name);
17110 print (vam->ofp, "Help is available for the following:");
17113 hash_foreach_pair (p, vam->function_by_name,
17115 vec_add1 (cmds, (u8 *)(p->key));
17119 vec_sort_with_function (cmds, cmd_cmp);
17121 for (j = 0; j < vec_len (cmds); j++)
17122 print (vam->ofp, "%s", cmds[j]);
17129 set (vat_main_t * vam)
17131 u8 *name = 0, *value = 0;
17132 unformat_input_t *i = vam->input;
17134 if (unformat (i, "%s", &name))
17136 /* The input buffer is a vector, not a string. */
17137 value = vec_dup (i->buffer);
17138 vec_delete (value, i->index, 0);
17139 /* Almost certainly has a trailing newline */
17140 if (value[vec_len (value) - 1] == '\n')
17141 value[vec_len (value) - 1] = 0;
17142 /* Make sure it's a proper string, one way or the other */
17143 vec_add1 (value, 0);
17144 (void) clib_macro_set_value (&vam->macro_main,
17145 (char *) name, (char *) value);
17148 errmsg ("usage: set <name> <value>");
17156 unset (vat_main_t * vam)
17160 if (unformat (vam->input, "%s", &name))
17161 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17162 errmsg ("unset: %s wasn't set", name);
17175 macro_sort_cmp (void *a1, void *a2)
17177 macro_sort_t *s1 = a1;
17178 macro_sort_t *s2 = a2;
17180 return strcmp ((char *) (s1->name), (char *) (s2->name));
17184 dump_macro_table (vat_main_t * vam)
17186 macro_sort_t *sort_me = 0, *sm;
17191 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17193 vec_add2 (sort_me, sm, 1);
17194 sm->name = (u8 *)(p->key);
17195 sm->value = (u8 *) (p->value[0]);
17199 vec_sort_with_function (sort_me, macro_sort_cmp);
17201 if (vec_len (sort_me))
17202 print (vam->ofp, "%-15s%s", "Name", "Value");
17204 print (vam->ofp, "The macro table is empty...");
17206 for (i = 0; i < vec_len (sort_me); i++)
17207 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17212 dump_node_table (vat_main_t * vam)
17215 vlib_node_t *node, *next_node;
17217 if (vec_len (vam->graph_nodes) == 0)
17219 print (vam->ofp, "Node table empty, issue get_node_graph...");
17223 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17225 node = vam->graph_nodes[i];
17226 print (vam->ofp, "[%d] %s", i, node->name);
17227 for (j = 0; j < vec_len (node->next_nodes); j++)
17229 if (node->next_nodes[j] != ~0)
17231 next_node = vam->graph_nodes[node->next_nodes[j]];
17232 print (vam->ofp, " [%d] %s", j, next_node->name);
17240 value_sort_cmp (void *a1, void *a2)
17242 name_sort_t *n1 = a1;
17243 name_sort_t *n2 = a2;
17245 if (n1->value < n2->value)
17247 if (n1->value > n2->value)
17254 dump_msg_api_table (vat_main_t * vam)
17256 api_main_t *am = &api_main;
17257 name_sort_t *nses = 0, *ns;
17262 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17264 vec_add2 (nses, ns, 1);
17265 ns->name = (u8 *)(hp->key);
17266 ns->value = (u32) hp->value[0];
17270 vec_sort_with_function (nses, value_sort_cmp);
17272 for (i = 0; i < vec_len (nses); i++)
17273 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17279 get_msg_id (vat_main_t * vam)
17284 if (unformat (vam->input, "%s", &name_and_crc))
17286 message_index = vl_api_get_msg_index (name_and_crc);
17287 if (message_index == ~0)
17289 print (vam->ofp, " '%s' not found", name_and_crc);
17292 print (vam->ofp, " '%s' has message index %d",
17293 name_and_crc, message_index);
17296 errmsg ("name_and_crc required...");
17301 search_node_table (vat_main_t * vam)
17303 unformat_input_t *line_input = vam->input;
17306 vlib_node_t *node, *next_node;
17309 if (vam->graph_node_index_by_name == 0)
17311 print (vam->ofp, "Node table empty, issue get_node_graph...");
17315 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17317 if (unformat (line_input, "%s", &node_to_find))
17319 vec_add1 (node_to_find, 0);
17320 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17323 print (vam->ofp, "%s not found...", node_to_find);
17326 node = vam->graph_nodes[p[0]];
17327 print (vam->ofp, "[%d] %s", p[0], node->name);
17328 for (j = 0; j < vec_len (node->next_nodes); j++)
17330 if (node->next_nodes[j] != ~0)
17332 next_node = vam->graph_nodes[node->next_nodes[j]];
17333 print (vam->ofp, " [%d] %s", j, next_node->name);
17340 clib_warning ("parse error '%U'", format_unformat_error,
17346 vec_free (node_to_find);
17355 script (vat_main_t * vam)
17357 #if (VPP_API_TEST_BUILTIN==0)
17359 char *save_current_file;
17360 unformat_input_t save_input;
17361 jmp_buf save_jump_buf;
17362 u32 save_line_number;
17364 FILE *new_fp, *save_ifp;
17366 if (unformat (vam->input, "%s", &s))
17368 new_fp = fopen ((char *) s, "r");
17371 errmsg ("Couldn't open script file %s", s);
17378 errmsg ("Missing script name");
17382 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17383 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17384 save_ifp = vam->ifp;
17385 save_line_number = vam->input_line_number;
17386 save_current_file = (char *) vam->current_file;
17388 vam->input_line_number = 0;
17390 vam->current_file = s;
17393 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17394 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17395 vam->ifp = save_ifp;
17396 vam->input_line_number = save_line_number;
17397 vam->current_file = (u8 *) save_current_file;
17402 clib_warning ("use the exec command...");
17408 echo (vat_main_t * vam)
17410 print (vam->ofp, "%v", vam->input->buffer);
17414 /* List of API message constructors, CLI names map to api_xxx */
17415 #define foreach_vpe_api_msg \
17416 _(create_loopback,"[mac <mac-addr>]") \
17417 _(sw_interface_dump,"") \
17418 _(sw_interface_set_flags, \
17419 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17420 _(sw_interface_add_del_address, \
17421 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17422 _(sw_interface_set_table, \
17423 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17424 _(sw_interface_set_mpls_enable, \
17425 "<intfc> | sw_if_index [disable | dis]") \
17426 _(sw_interface_set_vpath, \
17427 "<intfc> | sw_if_index <id> enable | disable") \
17428 _(sw_interface_set_vxlan_bypass, \
17429 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17430 _(sw_interface_set_l2_xconnect, \
17431 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17432 "enable | disable") \
17433 _(sw_interface_set_l2_bridge, \
17434 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17435 "[shg <split-horizon-group>] [bvi]\n" \
17436 "enable | disable") \
17437 _(sw_interface_set_dpdk_hqos_pipe, \
17438 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17439 "profile <profile-id>\n") \
17440 _(sw_interface_set_dpdk_hqos_subport, \
17441 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17442 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17443 _(sw_interface_set_dpdk_hqos_tctbl, \
17444 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
17445 _(bridge_domain_add_del, \
17446 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17447 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17449 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17451 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17453 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17455 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17457 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17459 "<vpp-if-name> | sw_if_index <id>") \
17460 _(sw_interface_tap_dump, "") \
17461 _(ip_add_del_route, \
17462 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17463 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17464 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17465 "[multipath] [count <n>]") \
17466 _(mpls_route_add_del, \
17467 "<label> <eos> via <addr> [table-id <n>]\n" \
17468 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17469 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17470 "[multipath] [count <n>]") \
17471 _(mpls_ip_bind_unbind, \
17472 "<label> <addr/len>") \
17473 _(mpls_tunnel_add_del, \
17474 " via <addr> [table-id <n>]\n" \
17475 "sw_if_index <id>] [l2] [del]") \
17476 _(proxy_arp_add_del, \
17477 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17478 _(proxy_arp_intfc_enable_disable, \
17479 "<intfc> | sw_if_index <id> enable | disable") \
17480 _(sw_interface_set_unnumbered, \
17481 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17482 _(ip_neighbor_add_del, \
17483 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17484 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17485 _(reset_vrf, "vrf <id> [ipv6]") \
17486 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17487 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17488 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17489 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17490 "[outer_vlan_id_any][inner_vlan_id_any]") \
17491 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17492 _(reset_fib, "vrf <n> [ipv6]") \
17493 _(dhcp_proxy_config, \
17494 "svr <v46-address> src <v46-address>\n" \
17495 "insert-cid <n> [del]") \
17496 _(dhcp_proxy_config_2, \
17497 "svr <v46-address> src <v46-address>\n" \
17498 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17499 _(dhcp_proxy_set_vss, \
17500 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17501 _(dhcp_client_config, \
17502 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17503 _(set_ip_flow_hash, \
17504 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17505 _(sw_interface_ip6_enable_disable, \
17506 "<intfc> | sw_if_index <id> enable | disable") \
17507 _(sw_interface_ip6_set_link_local_address, \
17508 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17509 _(sw_interface_ip6nd_ra_prefix, \
17510 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17511 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17512 "[nolink] [isno]") \
17513 _(sw_interface_ip6nd_ra_config, \
17514 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17515 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17516 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17517 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17518 _(l2_patch_add_del, \
17519 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17520 "enable | disable") \
17521 _(sr_tunnel_add_del, \
17522 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17523 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17524 "[policy <policy_name>]") \
17525 _(sr_policy_add_del, \
17526 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17527 _(sr_multicast_map_add_del, \
17528 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17529 _(classify_add_del_table, \
17530 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17531 " [del] [del-chain] mask <mask-value>\n" \
17532 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17533 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17534 _(classify_add_del_session, \
17535 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17536 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17537 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17538 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17539 _(classify_set_interface_ip_table, \
17540 "<intfc> | sw_if_index <nn> table <nn>") \
17541 _(classify_set_interface_l2_tables, \
17542 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17543 " [other-table <nn>]") \
17544 _(get_node_index, "node <node-name") \
17545 _(add_node_next, "node <node-name> next <next-node-name>") \
17546 _(l2tpv3_create_tunnel, \
17547 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17548 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17549 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17550 _(l2tpv3_set_tunnel_cookies, \
17551 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17552 "[new_remote_cookie <nn>]\n") \
17553 _(l2tpv3_interface_enable_disable, \
17554 "<intfc> | sw_if_index <nn> enable | disable") \
17555 _(l2tpv3_set_lookup_key, \
17556 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17557 _(sw_if_l2tpv3_tunnel_dump, "") \
17558 _(vxlan_add_del_tunnel, \
17559 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17560 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17561 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17562 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17563 _(gre_add_del_tunnel, \
17564 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17565 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17566 _(l2_fib_clear_table, "") \
17567 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17568 _(l2_interface_vlan_tag_rewrite, \
17569 "<intfc> | sw_if_index <nn> \n" \
17570 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17571 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17572 _(create_vhost_user_if, \
17573 "socket <filename> [server] [renumber <dev_instance>] " \
17574 "[mac <mac_address>]") \
17575 _(modify_vhost_user_if, \
17576 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17577 "[server] [renumber <dev_instance>]") \
17578 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17579 _(sw_interface_vhost_user_dump, "") \
17580 _(show_version, "") \
17581 _(vxlan_gpe_add_del_tunnel, \
17582 "local <addr> remote <addr> vni <nn>\n" \
17583 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17584 "[next-ethernet] [next-nsh]\n") \
17585 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17586 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17587 _(interface_name_renumber, \
17588 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17589 _(input_acl_set_interface, \
17590 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17591 " [l2-table <nn>] [del]") \
17592 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17593 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17594 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17595 _(ip_dump, "ipv4 | ipv6") \
17596 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17597 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17599 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17600 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17601 " integ_alg <alg> integ_key <hex>") \
17602 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17603 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17604 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17605 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17606 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17607 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17608 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17609 "(auth_data 0x<data> | auth_data <data>)") \
17610 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17611 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17612 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17613 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17614 "(local|remote)") \
17615 _(ikev2_set_local_key, "file <absolute_file_path>") \
17616 _(delete_loopback,"sw_if_index <nn>") \
17617 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17618 _(map_add_domain, \
17619 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17620 "ip6-src <ip6addr> " \
17621 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17622 _(map_del_domain, "index <n>") \
17623 _(map_add_del_rule, \
17624 "index <n> psid <n> dst <ip6addr> [del]") \
17625 _(map_domain_dump, "") \
17626 _(map_rule_dump, "index <map-domain>") \
17627 _(want_interface_events, "enable|disable") \
17628 _(want_stats,"enable|disable") \
17629 _(get_first_msg_id, "client <name>") \
17630 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17631 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17632 "fib-id <nn> [ip4][ip6][default]") \
17633 _(get_node_graph, " ") \
17634 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17635 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17636 _(ioam_disable, "") \
17637 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17638 " sw_if_index <sw_if_index> p <priority> " \
17639 "w <weight>] [del]") \
17640 _(lisp_add_del_locator, "locator-set <locator_name> " \
17641 "iface <intf> | sw_if_index <sw_if_index> " \
17642 "p <priority> w <weight> [del]") \
17643 _(lisp_add_del_local_eid,"vni <vni> eid " \
17644 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17645 "locator-set <locator_name> [del]" \
17646 "[key-id sha1|sha256 secret-key <secret-key>]") \
17647 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
17648 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
17649 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17650 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17651 _(lisp_gpe_enable_disable, "enable|disable") \
17652 _(lisp_enable_disable, "enable|disable") \
17653 _(lisp_map_register_enable_disable, "enable|disable") \
17654 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17655 _(lisp_gpe_add_del_iface, "up|down") \
17656 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17658 "rloc <locator> p <prio> " \
17659 "w <weight> [rloc <loc> ... ] " \
17660 "action <action> [del-all]") \
17661 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17663 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17664 _(lisp_map_request_mode, "src-dst|dst-only") \
17665 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17666 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17667 _(lisp_locator_set_dump, "[local | remote]") \
17668 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17669 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17670 "[local] | [remote]") \
17671 _(lisp_eid_table_vni_dump, "") \
17672 _(lisp_eid_table_map_dump, "l2|l3") \
17673 _(lisp_gpe_tunnel_dump, "") \
17674 _(lisp_map_resolver_dump, "") \
17675 _(lisp_map_server_dump, "") \
17676 _(lisp_adjacencies_get, "vni <vni>") \
17677 _(show_lisp_rloc_probe_state, "") \
17678 _(show_lisp_map_register_state, "") \
17679 _(show_lisp_status, "") \
17680 _(lisp_get_map_request_itr_rlocs, "") \
17681 _(show_lisp_pitr, "") \
17682 _(show_lisp_map_request_mode, "") \
17683 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17684 _(af_packet_delete, "name <host interface name>") \
17685 _(policer_add_del, "name <policer name> <params> [del]") \
17686 _(policer_dump, "[name <policer name>]") \
17687 _(policer_classify_set_interface, \
17688 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17689 " [l2-table <nn>] [del]") \
17690 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17691 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17692 "[master|slave]") \
17693 _(netmap_delete, "name <interface name>") \
17694 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17695 _(mpls_fib_dump, "") \
17696 _(classify_table_ids, "") \
17697 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17698 _(classify_table_info, "table_id <nn>") \
17699 _(classify_session_dump, "table_id <nn>") \
17700 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17701 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17702 "[template_interval <nn>] [udp_checksum]") \
17703 _(ipfix_exporter_dump, "") \
17704 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17705 _(ipfix_classify_stream_dump, "") \
17706 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17707 _(ipfix_classify_table_dump, "") \
17708 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17709 _(sw_interface_span_dump, "") \
17710 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17711 _(pg_create_interface, "if_id <nn>") \
17712 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17713 _(pg_enable_disable, "[stream <id>] disable") \
17714 _(ip_source_and_port_range_check_add_del, \
17715 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17716 _(ip_source_and_port_range_check_interface_add_del, \
17717 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17718 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17719 _(ipsec_gre_add_del_tunnel, \
17720 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17721 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17722 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17723 _(l2_interface_pbb_tag_rewrite, \
17724 "<intfc> | sw_if_index <nn> \n" \
17725 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17726 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17727 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17728 _(flow_classify_set_interface, \
17729 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17730 _(flow_classify_dump, "type [ip4|ip6]") \
17731 _(ip_fib_dump, "") \
17732 _(ip6_fib_dump, "") \
17733 _(feature_enable_disable, "arc_name <arc_name> " \
17734 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17735 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17737 _(l2_xconnect_dump, "") \
17738 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17739 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17740 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17742 /* List of command functions, CLI names map directly to functions */
17743 #define foreach_cli_function \
17744 _(comment, "usage: comment <ignore-rest-of-line>") \
17745 _(dump_interface_table, "usage: dump_interface_table") \
17746 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17747 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17748 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17749 _(dump_stats_table, "usage: dump_stats_table") \
17750 _(dump_macro_table, "usage: dump_macro_table ") \
17751 _(dump_node_table, "usage: dump_node_table") \
17752 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17753 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17754 _(echo, "usage: echo <message>") \
17755 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17756 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17757 _(help, "usage: help") \
17758 _(q, "usage: quit") \
17759 _(quit, "usage: quit") \
17760 _(search_node_table, "usage: search_node_table <name>...") \
17761 _(set, "usage: set <variable-name> <value>") \
17762 _(script, "usage: script <file-name>") \
17763 _(unset, "usage: unset <variable-name>")
17766 static void vl_api_##n##_t_handler_uni \
17767 (vl_api_##n##_t * mp) \
17769 vat_main_t * vam = &vat_main; \
17770 if (vam->json_output) { \
17771 vl_api_##n##_t_handler_json(mp); \
17773 vl_api_##n##_t_handler(mp); \
17776 foreach_vpe_api_reply_msg;
17780 vat_api_hookup (vat_main_t * vam)
17783 vl_msg_api_set_handlers(VL_API_##N, #n, \
17784 vl_api_##n##_t_handler_uni, \
17786 vl_api_##n##_t_endian, \
17787 vl_api_##n##_t_print, \
17788 sizeof(vl_api_##n##_t), 1);
17789 foreach_vpe_api_reply_msg;
17792 #if (VPP_API_TEST_BUILTIN==0)
17793 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17796 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17798 vam->function_by_name = hash_create_string (0, sizeof (uword));
17800 vam->help_by_name = hash_create_string (0, sizeof (uword));
17802 /* API messages we can send */
17803 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17804 foreach_vpe_api_msg;
17808 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17809 foreach_vpe_api_msg;
17812 /* CLI functions */
17813 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17814 foreach_cli_function;
17818 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17819 foreach_cli_function;
17824 * fd.io coding-style-patch-verification: ON
17827 * eval: (c-set-style "gnu")