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 _(bridge_domain_add_del_reply) \
3573 _(sw_interface_set_l2_xconnect_reply) \
3574 _(l2fib_add_del_reply) \
3575 _(ip_add_del_route_reply) \
3576 _(mpls_route_add_del_reply) \
3577 _(mpls_ip_bind_unbind_reply) \
3578 _(proxy_arp_add_del_reply) \
3579 _(proxy_arp_intfc_enable_disable_reply) \
3580 _(sw_interface_set_unnumbered_reply) \
3581 _(ip_neighbor_add_del_reply) \
3582 _(reset_vrf_reply) \
3583 _(oam_add_del_reply) \
3584 _(reset_fib_reply) \
3585 _(dhcp_proxy_config_reply) \
3586 _(dhcp_proxy_config_2_reply) \
3587 _(dhcp_proxy_set_vss_reply) \
3588 _(dhcp_client_config_reply) \
3589 _(set_ip_flow_hash_reply) \
3590 _(sw_interface_ip6_enable_disable_reply) \
3591 _(sw_interface_ip6_set_link_local_address_reply) \
3592 _(sw_interface_ip6nd_ra_prefix_reply) \
3593 _(sw_interface_ip6nd_ra_config_reply) \
3594 _(set_arp_neighbor_limit_reply) \
3595 _(l2_patch_add_del_reply) \
3596 _(sr_tunnel_add_del_reply) \
3597 _(sr_policy_add_del_reply) \
3598 _(sr_multicast_map_add_del_reply) \
3599 _(classify_add_del_session_reply) \
3600 _(classify_set_interface_ip_table_reply) \
3601 _(classify_set_interface_l2_tables_reply) \
3602 _(l2tpv3_set_tunnel_cookies_reply) \
3603 _(l2tpv3_interface_enable_disable_reply) \
3604 _(l2tpv3_set_lookup_key_reply) \
3605 _(l2_fib_clear_table_reply) \
3606 _(l2_interface_efp_filter_reply) \
3607 _(l2_interface_vlan_tag_rewrite_reply) \
3608 _(modify_vhost_user_if_reply) \
3609 _(delete_vhost_user_if_reply) \
3610 _(want_ip4_arp_events_reply) \
3611 _(want_ip6_nd_events_reply) \
3612 _(input_acl_set_interface_reply) \
3613 _(ipsec_spd_add_del_reply) \
3614 _(ipsec_interface_add_del_spd_reply) \
3615 _(ipsec_spd_add_del_entry_reply) \
3616 _(ipsec_sad_add_del_entry_reply) \
3617 _(ipsec_sa_set_key_reply) \
3618 _(ikev2_profile_add_del_reply) \
3619 _(ikev2_profile_set_auth_reply) \
3620 _(ikev2_profile_set_id_reply) \
3621 _(ikev2_profile_set_ts_reply) \
3622 _(ikev2_set_local_key_reply) \
3623 _(delete_loopback_reply) \
3624 _(bd_ip_mac_add_del_reply) \
3625 _(map_del_domain_reply) \
3626 _(map_add_del_rule_reply) \
3627 _(want_interface_events_reply) \
3628 _(want_stats_reply) \
3629 _(cop_interface_enable_disable_reply) \
3630 _(cop_whitelist_enable_disable_reply) \
3631 _(sw_interface_clear_stats_reply) \
3632 _(ioam_enable_reply) \
3633 _(ioam_disable_reply) \
3634 _(lisp_add_del_locator_reply) \
3635 _(lisp_add_del_local_eid_reply) \
3636 _(lisp_add_del_remote_mapping_reply) \
3637 _(lisp_add_del_adjacency_reply) \
3638 _(lisp_gpe_add_del_fwd_entry_reply) \
3639 _(lisp_add_del_map_resolver_reply) \
3640 _(lisp_add_del_map_server_reply) \
3641 _(lisp_gpe_enable_disable_reply) \
3642 _(lisp_gpe_add_del_iface_reply) \
3643 _(lisp_enable_disable_reply) \
3644 _(lisp_rloc_probe_enable_disable_reply) \
3645 _(lisp_map_register_enable_disable_reply) \
3646 _(lisp_pitr_set_locator_set_reply) \
3647 _(lisp_map_request_mode_reply) \
3648 _(lisp_add_del_map_request_itr_rlocs_reply) \
3649 _(lisp_eid_table_add_del_map_reply) \
3650 _(vxlan_gpe_add_del_tunnel_reply) \
3651 _(af_packet_delete_reply) \
3652 _(policer_classify_set_interface_reply) \
3653 _(netmap_create_reply) \
3654 _(netmap_delete_reply) \
3655 _(set_ipfix_exporter_reply) \
3656 _(set_ipfix_classify_stream_reply) \
3657 _(ipfix_classify_table_add_del_reply) \
3658 _(flow_classify_set_interface_reply) \
3659 _(sw_interface_span_enable_disable_reply) \
3660 _(pg_capture_reply) \
3661 _(pg_enable_disable_reply) \
3662 _(ip_source_and_port_range_check_add_del_reply) \
3663 _(ip_source_and_port_range_check_interface_add_del_reply)\
3664 _(delete_subif_reply) \
3665 _(l2_interface_pbb_tag_rewrite_reply) \
3667 _(feature_enable_disable_reply) \
3668 _(sw_interface_tag_add_del_reply) \
3669 _(sw_interface_set_mtu_reply)
3672 #define foreach_standard_dpdk_reply_retval_handler \
3673 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3674 _(sw_interface_set_dpdk_hqos_subport_reply) \
3675 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3679 static void vl_api_##n##_t_handler \
3680 (vl_api_##n##_t * mp) \
3682 vat_main_t * vam = &vat_main; \
3683 i32 retval = ntohl(mp->retval); \
3684 if (vam->async_mode) { \
3685 vam->async_errors += (retval < 0); \
3687 vam->retval = retval; \
3688 vam->result_ready = 1; \
3691 foreach_standard_reply_retval_handler;
3695 static void vl_api_##n##_t_handler_json \
3696 (vl_api_##n##_t * mp) \
3698 vat_main_t * vam = &vat_main; \
3699 vat_json_node_t node; \
3700 vat_json_init_object(&node); \
3701 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3702 vat_json_print(vam->ofp, &node); \
3703 vam->retval = ntohl(mp->retval); \
3704 vam->result_ready = 1; \
3706 foreach_standard_reply_retval_handler;
3711 static void vl_api_##n##_t_handler \
3712 (vl_api_##n##_t * mp) \
3714 vat_main_t * vam = &vat_main; \
3715 i32 retval = ntohl(mp->retval); \
3716 if (vam->async_mode) { \
3717 vam->async_errors += (retval < 0); \
3719 vam->retval = retval; \
3720 vam->result_ready = 1; \
3723 foreach_standard_dpdk_reply_retval_handler;
3727 static void vl_api_##n##_t_handler_json \
3728 (vl_api_##n##_t * mp) \
3730 vat_main_t * vam = &vat_main; \
3731 vat_json_node_t node; \
3732 vat_json_init_object(&node); \
3733 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3734 vat_json_print(vam->ofp, &node); \
3735 vam->retval = ntohl(mp->retval); \
3736 vam->result_ready = 1; \
3738 foreach_standard_dpdk_reply_retval_handler;
3743 * Table of message reply handlers, must include boilerplate handlers
3747 #define foreach_vpe_api_reply_msg \
3748 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3749 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3750 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3751 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3752 _(CONTROL_PING_REPLY, control_ping_reply) \
3753 _(CLI_REPLY, cli_reply) \
3754 _(CLI_INBAND_REPLY, cli_inband_reply) \
3755 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3756 sw_interface_add_del_address_reply) \
3757 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3758 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3759 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3760 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3761 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3762 sw_interface_set_l2_xconnect_reply) \
3763 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3764 sw_interface_set_l2_bridge_reply) \
3765 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3766 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3767 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3768 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3769 _(L2_FLAGS_REPLY, l2_flags_reply) \
3770 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3771 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3772 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3773 _(TAP_DELETE_REPLY, tap_delete_reply) \
3774 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3775 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3776 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3777 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3778 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3779 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3780 proxy_arp_intfc_enable_disable_reply) \
3781 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3782 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3783 sw_interface_set_unnumbered_reply) \
3784 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3785 _(RESET_VRF_REPLY, reset_vrf_reply) \
3786 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3787 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3788 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3789 _(RESET_FIB_REPLY, reset_fib_reply) \
3790 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3791 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3792 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3793 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3794 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3795 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3796 sw_interface_ip6_enable_disable_reply) \
3797 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3798 sw_interface_ip6_set_link_local_address_reply) \
3799 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3800 sw_interface_ip6nd_ra_prefix_reply) \
3801 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3802 sw_interface_ip6nd_ra_config_reply) \
3803 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3804 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3805 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3806 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3807 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3808 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3809 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3810 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3811 classify_set_interface_ip_table_reply) \
3812 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3813 classify_set_interface_l2_tables_reply) \
3814 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3815 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3816 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3817 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3818 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3819 l2tpv3_interface_enable_disable_reply) \
3820 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3821 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3822 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3823 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3824 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3825 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3826 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3827 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3828 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3829 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3830 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3831 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3832 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3833 _(SHOW_VERSION_REPLY, show_version_reply) \
3834 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3835 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3836 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3837 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3838 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3839 _(IP4_ARP_EVENT, ip4_arp_event) \
3840 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3841 _(IP6_ND_EVENT, ip6_nd_event) \
3842 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3843 _(IP_ADDRESS_DETAILS, ip_address_details) \
3844 _(IP_DETAILS, ip_details) \
3845 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3846 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3847 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3848 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3849 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3850 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3851 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3852 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3853 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3854 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3855 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3856 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3857 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3858 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3859 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3860 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3861 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3862 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3863 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3864 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3865 _(MAP_RULE_DETAILS, map_rule_details) \
3866 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3867 _(WANT_STATS_REPLY, want_stats_reply) \
3868 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3869 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3870 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3871 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3872 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3873 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3874 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3875 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3876 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3877 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3878 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3879 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3880 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3881 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3882 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3883 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3884 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3885 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3886 lisp_map_register_enable_disable_reply) \
3887 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3888 lisp_rloc_probe_enable_disable_reply) \
3889 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3890 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3891 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3892 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3893 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3894 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3895 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3896 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3897 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3898 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3899 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3900 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3901 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3902 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3903 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3904 lisp_add_del_map_request_itr_rlocs_reply) \
3905 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3906 lisp_get_map_request_itr_rlocs_reply) \
3907 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3908 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3909 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3910 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3911 show_lisp_map_register_state_reply) \
3912 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3913 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3914 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3915 _(POLICER_DETAILS, policer_details) \
3916 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3917 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3918 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3919 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3920 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3921 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3922 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3923 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3924 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3925 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3926 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3927 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3928 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3929 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3930 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3931 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3932 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3933 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3934 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3935 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3936 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3937 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3938 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3939 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3940 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3941 ip_source_and_port_range_check_add_del_reply) \
3942 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3943 ip_source_and_port_range_check_interface_add_del_reply) \
3944 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3945 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3946 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3947 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3948 _(PUNT_REPLY, punt_reply) \
3949 _(IP_FIB_DETAILS, ip_fib_details) \
3950 _(IP6_FIB_DETAILS, ip6_fib_details) \
3951 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3952 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3953 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3954 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
3955 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
3956 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
3959 #define foreach_vpe_dpdk_api_reply_msg \
3960 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3961 sw_interface_set_dpdk_hqos_pipe_reply) \
3962 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3963 sw_interface_set_dpdk_hqos_subport_reply) \
3964 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3965 sw_interface_set_dpdk_hqos_tctbl_reply)
3968 /* M: construct, but don't yet send a message */
3972 vam->result_ready = 0; \
3973 mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \
3974 memset (mp, 0, sizeof (*mp)); \
3975 mp->_vl_msg_id = ntohs (VL_API_##T); \
3976 mp->client_index = vam->my_client_index; \
3981 vam->result_ready = 0; \
3982 mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \
3983 memset (mp, 0, sizeof (*mp)); \
3984 mp->_vl_msg_id = ntohs (VL_API_##T); \
3985 mp->client_index = vam->my_client_index; \
3989 /* S: send a message */
3990 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3992 /* W: wait for results, with timeout */
3995 timeout = vat_time_now (vam) + 1.0; \
3997 while (vat_time_now (vam) < timeout) { \
3998 if (vam->result_ready == 1) { \
3999 return (vam->retval); \
4001 vat_suspend (vam->vlib_main, 1e-3); \
4006 /* W2: wait for results, with timeout */
4009 timeout = vat_time_now (vam) + 1.0; \
4011 while (vat_time_now (vam) < timeout) { \
4012 if (vam->result_ready == 1) { \
4014 return (vam->retval); \
4016 vat_suspend (vam->vlib_main, 1e-3); \
4028 #define STR_VTR_OP_CASE(op) \
4029 case L2_VTR_ ## op: \
4033 str_vtr_op (u32 vtr_op)
4037 STR_VTR_OP_CASE (DISABLED);
4038 STR_VTR_OP_CASE (PUSH_1);
4039 STR_VTR_OP_CASE (PUSH_2);
4040 STR_VTR_OP_CASE (POP_1);
4041 STR_VTR_OP_CASE (POP_2);
4042 STR_VTR_OP_CASE (TRANSLATE_1_1);
4043 STR_VTR_OP_CASE (TRANSLATE_1_2);
4044 STR_VTR_OP_CASE (TRANSLATE_2_1);
4045 STR_VTR_OP_CASE (TRANSLATE_2_2);
4052 dump_sub_interface_table (vat_main_t * vam)
4054 const sw_interface_subif_t *sub = NULL;
4056 if (vam->json_output)
4059 ("JSON output supported only for VPE API calls and dump_stats_table");
4064 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4065 "Interface", "sw_if_index",
4066 "sub id", "dot1ad", "tags", "outer id",
4067 "inner id", "exact", "default", "outer any", "inner any");
4069 vec_foreach (sub, vam->sw_if_subif_table)
4072 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4073 sub->interface_name,
4075 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4076 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4077 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4078 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4079 if (sub->vtr_op != L2_VTR_DISABLED)
4082 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4083 "tag1: %d tag2: %d ]",
4084 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4085 sub->vtr_tag1, sub->vtr_tag2);
4093 name_sort_cmp (void *a1, void *a2)
4095 name_sort_t *n1 = a1;
4096 name_sort_t *n2 = a2;
4098 return strcmp ((char *) n1->name, (char *) n2->name);
4102 dump_interface_table (vat_main_t * vam)
4105 name_sort_t *nses = 0, *ns;
4107 if (vam->json_output)
4110 ("JSON output supported only for VPE API calls and dump_stats_table");
4115 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4117 vec_add2 (nses, ns, 1);
4118 ns->name = (u8 *)(p->key);
4119 ns->value = (u32) p->value[0];
4123 vec_sort_with_function (nses, name_sort_cmp);
4125 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4126 vec_foreach (ns, nses)
4128 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4135 dump_ip_table (vat_main_t * vam, int is_ipv6)
4137 const ip_details_t *det = NULL;
4138 const ip_address_details_t *address = NULL;
4141 print (vam->ofp, "%-12s", "sw_if_index");
4143 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4150 print (vam->ofp, "%-12d", i);
4151 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4156 vec_foreach (address, det->addr)
4160 is_ipv6 ? format_ip6_address : format_ip4_address,
4161 address->ip, address->prefix_length);
4169 dump_ipv4_table (vat_main_t * vam)
4171 if (vam->json_output)
4174 ("JSON output supported only for VPE API calls and dump_stats_table");
4178 return dump_ip_table (vam, 0);
4182 dump_ipv6_table (vat_main_t * vam)
4184 if (vam->json_output)
4187 ("JSON output supported only for VPE API calls and dump_stats_table");
4191 return dump_ip_table (vam, 1);
4195 counter_type_to_str (u8 counter_type, u8 is_combined)
4199 switch (counter_type)
4201 case VNET_INTERFACE_COUNTER_DROP:
4203 case VNET_INTERFACE_COUNTER_PUNT:
4205 case VNET_INTERFACE_COUNTER_IP4:
4207 case VNET_INTERFACE_COUNTER_IP6:
4209 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4211 case VNET_INTERFACE_COUNTER_RX_MISS:
4213 case VNET_INTERFACE_COUNTER_RX_ERROR:
4215 case VNET_INTERFACE_COUNTER_TX_ERROR:
4218 return "INVALID-COUNTER-TYPE";
4223 switch (counter_type)
4225 case VNET_INTERFACE_COUNTER_RX:
4227 case VNET_INTERFACE_COUNTER_TX:
4230 return "INVALID-COUNTER-TYPE";
4236 dump_stats_table (vat_main_t * vam)
4238 vat_json_node_t node;
4239 vat_json_node_t *msg_array;
4240 vat_json_node_t *msg;
4241 vat_json_node_t *counter_array;
4242 vat_json_node_t *counter;
4243 interface_counter_t c;
4245 ip4_fib_counter_t *c4;
4246 ip6_fib_counter_t *c6;
4249 if (!vam->json_output)
4251 clib_warning ("dump_stats_table supported only in JSON format");
4255 vat_json_init_object (&node);
4257 /* interface counters */
4258 msg_array = vat_json_object_add (&node, "interface_counters");
4259 vat_json_init_array (msg_array);
4260 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4262 msg = vat_json_array_add (msg_array);
4263 vat_json_init_object (msg);
4264 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4265 (u8 *) counter_type_to_str (i, 0));
4266 vat_json_object_add_int (msg, "is_combined", 0);
4267 counter_array = vat_json_object_add (msg, "data");
4268 vat_json_init_array (counter_array);
4269 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4271 packets = vam->simple_interface_counters[i][j];
4272 vat_json_array_add_uint (counter_array, packets);
4275 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4277 msg = vat_json_array_add (msg_array);
4278 vat_json_init_object (msg);
4279 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4280 (u8 *) counter_type_to_str (i, 1));
4281 vat_json_object_add_int (msg, "is_combined", 1);
4282 counter_array = vat_json_object_add (msg, "data");
4283 vat_json_init_array (counter_array);
4284 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4286 c = vam->combined_interface_counters[i][j];
4287 counter = vat_json_array_add (counter_array);
4288 vat_json_init_object (counter);
4289 vat_json_object_add_uint (counter, "packets", c.packets);
4290 vat_json_object_add_uint (counter, "bytes", c.bytes);
4294 /* ip4 fib counters */
4295 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4296 vat_json_init_array (msg_array);
4297 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4299 msg = vat_json_array_add (msg_array);
4300 vat_json_init_object (msg);
4301 vat_json_object_add_uint (msg, "vrf_id",
4302 vam->ip4_fib_counters_vrf_id_by_index[i]);
4303 counter_array = vat_json_object_add (msg, "c");
4304 vat_json_init_array (counter_array);
4305 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4307 counter = vat_json_array_add (counter_array);
4308 vat_json_init_object (counter);
4309 c4 = &vam->ip4_fib_counters[i][j];
4310 vat_json_object_add_ip4 (counter, "address", c4->address);
4311 vat_json_object_add_uint (counter, "address_length",
4312 c4->address_length);
4313 vat_json_object_add_uint (counter, "packets", c4->packets);
4314 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4318 /* ip6 fib counters */
4319 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4320 vat_json_init_array (msg_array);
4321 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4323 msg = vat_json_array_add (msg_array);
4324 vat_json_init_object (msg);
4325 vat_json_object_add_uint (msg, "vrf_id",
4326 vam->ip6_fib_counters_vrf_id_by_index[i]);
4327 counter_array = vat_json_object_add (msg, "c");
4328 vat_json_init_array (counter_array);
4329 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4331 counter = vat_json_array_add (counter_array);
4332 vat_json_init_object (counter);
4333 c6 = &vam->ip6_fib_counters[i][j];
4334 vat_json_object_add_ip6 (counter, "address", c6->address);
4335 vat_json_object_add_uint (counter, "address_length",
4336 c6->address_length);
4337 vat_json_object_add_uint (counter, "packets", c6->packets);
4338 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4342 vat_json_print (vam->ofp, &node);
4343 vat_json_free (&node);
4349 exec (vat_main_t * vam)
4351 api_main_t *am = &api_main;
4352 vl_api_cli_request_t *mp;
4356 unformat_input_t *i = vam->input;
4358 if (vec_len (i->buffer) == 0)
4361 if (vam->exec_mode == 0 && unformat (i, "mode"))
4366 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4373 M (CLI_REQUEST, cli_request);
4376 * Copy cmd into shared memory.
4377 * In order for the CLI command to work, it
4378 * must be a vector ending in \n, not a C-string ending
4381 pthread_mutex_lock (&am->vlib_rp->mutex);
4382 oldheap = svm_push_data_heap (am->vlib_rp);
4384 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4385 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4387 svm_pop_heap (oldheap);
4388 pthread_mutex_unlock (&am->vlib_rp->mutex);
4390 mp->cmd_in_shmem = (u64) cmd;
4392 timeout = vat_time_now (vam) + 10.0;
4394 while (vat_time_now (vam) < timeout)
4396 if (vam->result_ready == 1)
4399 if (vam->shmem_result != NULL)
4400 print (vam->ofp, "%s", vam->shmem_result);
4401 pthread_mutex_lock (&am->vlib_rp->mutex);
4402 oldheap = svm_push_data_heap (am->vlib_rp);
4404 free_me = (u8 *) vam->shmem_result;
4407 svm_pop_heap (oldheap);
4408 pthread_mutex_unlock (&am->vlib_rp->mutex);
4416 * Future replacement of exec() that passes CLI buffers directly in
4417 * the API messages instead of an additional shared memory area.
4420 exec_inband (vat_main_t * vam)
4422 vl_api_cli_inband_t *mp;
4424 unformat_input_t *i = vam->input;
4426 if (vec_len (i->buffer) == 0)
4429 if (vam->exec_mode == 0 && unformat (i, "mode"))
4434 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4441 * In order for the CLI command to work, it
4442 * must be a vector ending in \n, not a C-string ending
4445 u32 len = vec_len (vam->input->buffer);
4446 M2 (CLI_INBAND, cli_inband, len);
4447 clib_memcpy (mp->cmd, vam->input->buffer, len);
4448 mp->length = htonl (len);
4451 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4455 api_create_loopback (vat_main_t * vam)
4457 unformat_input_t *i = vam->input;
4458 vl_api_create_loopback_t *mp;
4463 memset (mac_address, 0, sizeof (mac_address));
4465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4467 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4473 /* Construct the API message */
4474 M (CREATE_LOOPBACK, create_loopback);
4476 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4483 api_delete_loopback (vat_main_t * vam)
4485 unformat_input_t *i = vam->input;
4486 vl_api_delete_loopback_t *mp;
4488 u32 sw_if_index = ~0;
4490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4492 if (unformat (i, "sw_if_index %d", &sw_if_index))
4498 if (sw_if_index == ~0)
4500 errmsg ("missing sw_if_index");
4504 /* Construct the API message */
4505 M (DELETE_LOOPBACK, delete_loopback);
4506 mp->sw_if_index = ntohl (sw_if_index);
4513 api_want_stats (vat_main_t * vam)
4515 unformat_input_t *i = vam->input;
4516 vl_api_want_stats_t *mp;
4520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4522 if (unformat (i, "enable"))
4524 else if (unformat (i, "disable"))
4532 errmsg ("missing enable|disable");
4536 M (WANT_STATS, want_stats);
4537 mp->enable_disable = enable;
4544 api_want_interface_events (vat_main_t * vam)
4546 unformat_input_t *i = vam->input;
4547 vl_api_want_interface_events_t *mp;
4551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4553 if (unformat (i, "enable"))
4555 else if (unformat (i, "disable"))
4563 errmsg ("missing enable|disable");
4567 M (WANT_INTERFACE_EVENTS, want_interface_events);
4568 mp->enable_disable = enable;
4570 vam->interface_event_display = enable;
4577 /* Note: non-static, called once to set up the initial intfc table */
4579 api_sw_interface_dump (vat_main_t * vam)
4581 vl_api_sw_interface_dump_t *mp;
4584 name_sort_t *nses = 0, *ns;
4585 sw_interface_subif_t *sub = NULL;
4587 /* Toss the old name table */
4589 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4591 vec_add2 (nses, ns, 1);
4592 ns->name = (u8 *)(p->key);
4593 ns->value = (u32) p->value[0];
4597 hash_free (vam->sw_if_index_by_interface_name);
4599 vec_foreach (ns, nses) vec_free (ns->name);
4603 vec_foreach (sub, vam->sw_if_subif_table)
4605 vec_free (sub->interface_name);
4607 vec_free (vam->sw_if_subif_table);
4609 /* recreate the interface name hash table */
4610 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4612 /* Get list of ethernets */
4613 M (SW_INTERFACE_DUMP, sw_interface_dump);
4614 mp->name_filter_valid = 1;
4615 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4618 /* and local / loopback interfaces */
4619 M (SW_INTERFACE_DUMP, sw_interface_dump);
4620 mp->name_filter_valid = 1;
4621 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4624 /* and packet-generator interfaces */
4625 M (SW_INTERFACE_DUMP, sw_interface_dump);
4626 mp->name_filter_valid = 1;
4627 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4630 /* and vxlan-gpe tunnel interfaces */
4631 M (SW_INTERFACE_DUMP, sw_interface_dump);
4632 mp->name_filter_valid = 1;
4633 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4634 sizeof (mp->name_filter) - 1);
4637 /* and vxlan tunnel interfaces */
4638 M (SW_INTERFACE_DUMP, sw_interface_dump);
4639 mp->name_filter_valid = 1;
4640 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4643 /* and host (af_packet) interfaces */
4644 M (SW_INTERFACE_DUMP, sw_interface_dump);
4645 mp->name_filter_valid = 1;
4646 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4649 /* and l2tpv3 tunnel interfaces */
4650 M (SW_INTERFACE_DUMP, sw_interface_dump);
4651 mp->name_filter_valid = 1;
4652 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4653 sizeof (mp->name_filter) - 1);
4656 /* and GRE tunnel interfaces */
4657 M (SW_INTERFACE_DUMP, sw_interface_dump);
4658 mp->name_filter_valid = 1;
4659 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4662 /* and LISP-GPE interfaces */
4663 M (SW_INTERFACE_DUMP, sw_interface_dump);
4664 mp->name_filter_valid = 1;
4665 strncpy ((char *) mp->name_filter, "lisp_gpe",
4666 sizeof (mp->name_filter) - 1);
4669 /* and IPSEC tunnel interfaces */
4670 M (SW_INTERFACE_DUMP, sw_interface_dump);
4671 mp->name_filter_valid = 1;
4672 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4675 /* Use a control ping for synchronization */
4677 vl_api_control_ping_t *mp;
4678 M (CONTROL_PING, control_ping);
4685 api_sw_interface_set_flags (vat_main_t * vam)
4687 unformat_input_t *i = vam->input;
4688 vl_api_sw_interface_set_flags_t *mp;
4691 u8 sw_if_index_set = 0;
4692 u8 admin_up = 0, link_up = 0;
4694 /* Parse args required to build the message */
4695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4697 if (unformat (i, "admin-up"))
4699 else if (unformat (i, "admin-down"))
4701 else if (unformat (i, "link-up"))
4703 else if (unformat (i, "link-down"))
4706 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4707 sw_if_index_set = 1;
4708 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4709 sw_if_index_set = 1;
4714 if (sw_if_index_set == 0)
4716 errmsg ("missing interface name or sw_if_index");
4720 /* Construct the API message */
4721 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4722 mp->sw_if_index = ntohl (sw_if_index);
4723 mp->admin_up_down = admin_up;
4724 mp->link_up_down = link_up;
4729 /* Wait for a reply, return the good/bad news... */
4734 api_sw_interface_clear_stats (vat_main_t * vam)
4736 unformat_input_t *i = vam->input;
4737 vl_api_sw_interface_clear_stats_t *mp;
4740 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, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4746 sw_if_index_set = 1;
4747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4748 sw_if_index_set = 1;
4753 /* Construct the API message */
4754 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4756 if (sw_if_index_set == 1)
4757 mp->sw_if_index = ntohl (sw_if_index);
4759 mp->sw_if_index = ~0;
4764 /* Wait for a reply, return the good/bad news... */
4770 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4772 unformat_input_t *i = vam->input;
4773 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4776 u8 sw_if_index_set = 0;
4784 /* Parse args required to build the message */
4785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4787 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4788 sw_if_index_set = 1;
4789 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4790 sw_if_index_set = 1;
4791 else if (unformat (i, "subport %u", &subport))
4794 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4795 sw_if_index_set = 1;
4796 else if (unformat (i, "pipe %u", &pipe))
4798 else if (unformat (i, "profile %u", &profile))
4804 if (sw_if_index_set == 0)
4806 errmsg ("missing interface name or sw_if_index");
4810 if (subport_set == 0)
4812 errmsg ("missing subport ");
4818 errmsg ("missing pipe");
4822 if (profile_set == 0)
4824 errmsg ("missing profile");
4828 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4830 mp->sw_if_index = ntohl (sw_if_index);
4831 mp->subport = ntohl (subport);
4832 mp->pipe = ntohl (pipe);
4833 mp->profile = ntohl (profile);
4843 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4845 unformat_input_t *i = vam->input;
4846 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4849 u8 sw_if_index_set = 0;
4852 u32 tb_rate = 1250000000; /* 10GbE */
4853 u32 tb_size = 1000000;
4854 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4857 /* Parse args required to build the message */
4858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4860 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4861 sw_if_index_set = 1;
4862 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4863 sw_if_index_set = 1;
4864 else if (unformat (i, "subport %u", &subport))
4867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4868 sw_if_index_set = 1;
4869 else if (unformat (i, "rate %u", &tb_rate))
4873 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4875 tc_rate[tc_id] = tb_rate;
4877 else if (unformat (i, "bktsize %u", &tb_size))
4879 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4881 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4883 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4885 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4887 else if (unformat (i, "period %u", &tc_period))
4893 if (sw_if_index_set == 0)
4895 errmsg ("missing interface name or sw_if_index");
4899 if (subport_set == 0)
4901 errmsg ("missing subport ");
4905 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4907 mp->sw_if_index = ntohl (sw_if_index);
4908 mp->subport = ntohl (subport);
4909 mp->tb_rate = ntohl (tb_rate);
4910 mp->tb_size = ntohl (tb_size);
4911 mp->tc_rate[0] = ntohl (tc_rate[0]);
4912 mp->tc_rate[1] = ntohl (tc_rate[1]);
4913 mp->tc_rate[2] = ntohl (tc_rate[2]);
4914 mp->tc_rate[3] = ntohl (tc_rate[3]);
4915 mp->tc_period = ntohl (tc_period);
4924 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4926 unformat_input_t *i = vam->input;
4927 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4930 u8 sw_if_index_set = 0;
4934 u32 entry, tc, queue;
4936 /* Parse args required to build the message */
4937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4939 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4940 sw_if_index_set = 1;
4941 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4942 sw_if_index_set = 1;
4943 else if (unformat (i, "entry %d", &entry))
4945 else if (unformat (i, "tc %d", &tc))
4947 else if (unformat (i, "queue %d", &queue))
4953 if (sw_if_index_set == 0)
4955 errmsg ("missing interface name or sw_if_index");
4961 errmsg ("missing entry ");
4967 errmsg ("missing traffic class ");
4973 errmsg ("missing queue ");
4977 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4979 mp->sw_if_index = ntohl (sw_if_index);
4980 mp->entry = ntohl (entry);
4981 mp->tc = ntohl (tc);
4982 mp->queue = ntohl (queue);
4992 api_sw_interface_add_del_address (vat_main_t * vam)
4994 unformat_input_t *i = vam->input;
4995 vl_api_sw_interface_add_del_address_t *mp;
4998 u8 sw_if_index_set = 0;
4999 u8 is_add = 1, del_all = 0;
5000 u32 address_length = 0;
5001 u8 v4_address_set = 0;
5002 u8 v6_address_set = 0;
5003 ip4_address_t v4address;
5004 ip6_address_t v6address;
5006 /* Parse args required to build the message */
5007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5009 if (unformat (i, "del-all"))
5011 else if (unformat (i, "del"))
5014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5015 sw_if_index_set = 1;
5016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5017 sw_if_index_set = 1;
5018 else if (unformat (i, "%U/%d",
5019 unformat_ip4_address, &v4address, &address_length))
5021 else if (unformat (i, "%U/%d",
5022 unformat_ip6_address, &v6address, &address_length))
5028 if (sw_if_index_set == 0)
5030 errmsg ("missing interface name or sw_if_index");
5033 if (v4_address_set && v6_address_set)
5035 errmsg ("both v4 and v6 addresses set");
5038 if (!v4_address_set && !v6_address_set && !del_all)
5040 errmsg ("no addresses set");
5044 /* Construct the API message */
5045 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
5047 mp->sw_if_index = ntohl (sw_if_index);
5048 mp->is_add = is_add;
5049 mp->del_all = del_all;
5053 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5057 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5059 mp->address_length = address_length;
5064 /* Wait for a reply, return good/bad news */
5069 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5071 unformat_input_t *i = vam->input;
5072 vl_api_sw_interface_set_mpls_enable_t *mp;
5075 u8 sw_if_index_set = 0;
5078 /* Parse args required to build the message */
5079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5082 sw_if_index_set = 1;
5083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5084 sw_if_index_set = 1;
5085 else if (unformat (i, "disable"))
5087 else if (unformat (i, "dis"))
5093 if (sw_if_index_set == 0)
5095 errmsg ("missing interface name or sw_if_index");
5099 /* Construct the API message */
5100 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5102 mp->sw_if_index = ntohl (sw_if_index);
5103 mp->enable = enable;
5108 /* Wait for a reply... */
5113 api_sw_interface_set_table (vat_main_t * vam)
5115 unformat_input_t *i = vam->input;
5116 vl_api_sw_interface_set_table_t *mp;
5118 u32 sw_if_index, vrf_id = 0;
5119 u8 sw_if_index_set = 0;
5122 /* Parse args required to build the message */
5123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5125 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5126 sw_if_index_set = 1;
5127 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5128 sw_if_index_set = 1;
5129 else if (unformat (i, "vrf %d", &vrf_id))
5131 else if (unformat (i, "ipv6"))
5137 if (sw_if_index_set == 0)
5139 errmsg ("missing interface name or sw_if_index");
5143 /* Construct the API message */
5144 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5146 mp->sw_if_index = ntohl (sw_if_index);
5147 mp->is_ipv6 = is_ipv6;
5148 mp->vrf_id = ntohl (vrf_id);
5153 /* Wait for a reply... */
5157 static void vl_api_sw_interface_get_table_reply_t_handler
5158 (vl_api_sw_interface_get_table_reply_t * mp)
5160 vat_main_t *vam = &vat_main;
5162 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5164 vam->retval = ntohl (mp->retval);
5165 vam->result_ready = 1;
5169 static void vl_api_sw_interface_get_table_reply_t_handler_json
5170 (vl_api_sw_interface_get_table_reply_t * mp)
5172 vat_main_t *vam = &vat_main;
5173 vat_json_node_t node;
5175 vat_json_init_object (&node);
5176 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5177 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5179 vat_json_print (vam->ofp, &node);
5180 vat_json_free (&node);
5182 vam->retval = ntohl (mp->retval);
5183 vam->result_ready = 1;
5187 api_sw_interface_get_table (vat_main_t * vam)
5189 unformat_input_t *i = vam->input;
5190 vl_api_sw_interface_get_table_t *mp;
5192 u8 sw_if_index_set = 0;
5196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5198 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5199 sw_if_index_set = 1;
5200 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5201 sw_if_index_set = 1;
5202 else if (unformat (i, "ipv6"))
5208 if (sw_if_index_set == 0)
5210 errmsg ("missing interface name or sw_if_index");
5214 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5215 mp->sw_if_index = htonl (sw_if_index);
5216 mp->is_ipv6 = is_ipv6;
5223 api_sw_interface_set_vpath (vat_main_t * vam)
5225 unformat_input_t *i = vam->input;
5226 vl_api_sw_interface_set_vpath_t *mp;
5228 u32 sw_if_index = 0;
5229 u8 sw_if_index_set = 0;
5232 /* Parse args required to build the message */
5233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5235 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5236 sw_if_index_set = 1;
5237 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5238 sw_if_index_set = 1;
5239 else if (unformat (i, "enable"))
5241 else if (unformat (i, "disable"))
5247 if (sw_if_index_set == 0)
5249 errmsg ("missing interface name or sw_if_index");
5253 /* Construct the API message */
5254 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5256 mp->sw_if_index = ntohl (sw_if_index);
5257 mp->enable = is_enable;
5262 /* Wait for a reply... */
5267 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5269 unformat_input_t *i = vam->input;
5270 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5272 u32 sw_if_index = 0;
5273 u8 sw_if_index_set = 0;
5277 /* Parse args required to build the message */
5278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5280 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5281 sw_if_index_set = 1;
5282 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5283 sw_if_index_set = 1;
5284 else if (unformat (i, "enable"))
5286 else if (unformat (i, "disable"))
5288 else if (unformat (i, "ip4"))
5290 else if (unformat (i, "ip6"))
5296 if (sw_if_index_set == 0)
5298 errmsg ("missing interface name or sw_if_index");
5302 /* Construct the API message */
5303 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5305 mp->sw_if_index = ntohl (sw_if_index);
5306 mp->enable = is_enable;
5307 mp->is_ipv6 = is_ipv6;
5312 /* Wait for a reply... */
5317 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5319 unformat_input_t *i = vam->input;
5320 vl_api_sw_interface_set_l2_xconnect_t *mp;
5323 u8 rx_sw_if_index_set = 0;
5325 u8 tx_sw_if_index_set = 0;
5328 /* Parse args required to build the message */
5329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5331 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5332 rx_sw_if_index_set = 1;
5333 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5334 tx_sw_if_index_set = 1;
5335 else if (unformat (i, "rx"))
5337 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5339 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5341 rx_sw_if_index_set = 1;
5346 else if (unformat (i, "tx"))
5348 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5350 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5352 tx_sw_if_index_set = 1;
5357 else if (unformat (i, "enable"))
5359 else if (unformat (i, "disable"))
5365 if (rx_sw_if_index_set == 0)
5367 errmsg ("missing rx interface name or rx_sw_if_index");
5371 if (enable && (tx_sw_if_index_set == 0))
5373 errmsg ("missing tx interface name or tx_sw_if_index");
5377 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5379 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5380 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5381 mp->enable = enable;
5390 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5392 unformat_input_t *i = vam->input;
5393 vl_api_sw_interface_set_l2_bridge_t *mp;
5396 u8 rx_sw_if_index_set = 0;
5403 /* Parse args required to build the message */
5404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5406 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5407 rx_sw_if_index_set = 1;
5408 else if (unformat (i, "bd_id %d", &bd_id))
5412 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5413 rx_sw_if_index_set = 1;
5414 else if (unformat (i, "shg %d", &shg))
5416 else if (unformat (i, "bvi"))
5418 else if (unformat (i, "enable"))
5420 else if (unformat (i, "disable"))
5426 if (rx_sw_if_index_set == 0)
5428 errmsg ("missing rx interface name or sw_if_index");
5432 if (enable && (bd_id_set == 0))
5434 errmsg ("missing bridge domain");
5438 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5440 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5441 mp->bd_id = ntohl (bd_id);
5444 mp->enable = enable;
5453 api_bridge_domain_dump (vat_main_t * vam)
5455 unformat_input_t *i = vam->input;
5456 vl_api_bridge_domain_dump_t *mp;
5460 /* Parse args required to build the message */
5461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5463 if (unformat (i, "bd_id %d", &bd_id))
5469 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5470 mp->bd_id = ntohl (bd_id);
5473 /* Use a control ping for synchronization */
5475 vl_api_control_ping_t *mp;
5476 M (CONTROL_PING, control_ping);
5486 api_bridge_domain_add_del (vat_main_t * vam)
5488 unformat_input_t *i = vam->input;
5489 vl_api_bridge_domain_add_del_t *mp;
5493 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5496 /* Parse args required to build the message */
5497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5499 if (unformat (i, "bd_id %d", &bd_id))
5501 else if (unformat (i, "flood %d", &flood))
5503 else if (unformat (i, "uu-flood %d", &uu_flood))
5505 else if (unformat (i, "forward %d", &forward))
5507 else if (unformat (i, "learn %d", &learn))
5509 else if (unformat (i, "arp-term %d", &arp_term))
5511 else if (unformat (i, "mac-age %d", &mac_age))
5513 else if (unformat (i, "del"))
5516 flood = uu_flood = forward = learn = 0;
5524 errmsg ("missing bridge domain");
5530 errmsg ("mac age must be less than 256 ");
5534 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5536 mp->bd_id = ntohl (bd_id);
5538 mp->uu_flood = uu_flood;
5539 mp->forward = forward;
5541 mp->arp_term = arp_term;
5542 mp->is_add = is_add;
5543 mp->mac_age = (u8) mac_age;
5552 api_l2fib_add_del (vat_main_t * vam)
5554 unformat_input_t *i = vam->input;
5555 vl_api_l2fib_add_del_t *mp;
5561 u32 sw_if_index = ~0;
5562 u8 sw_if_index_set = 0;
5571 /* Parse args required to build the message */
5572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5574 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5576 else if (unformat (i, "bd_id %d", &bd_id))
5578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5579 sw_if_index_set = 1;
5580 else if (unformat (i, "sw_if"))
5582 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5585 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5586 sw_if_index_set = 1;
5591 else if (unformat (i, "static"))
5593 else if (unformat (i, "filter"))
5598 else if (unformat (i, "bvi"))
5603 else if (unformat (i, "del"))
5605 else if (unformat (i, "count %d", &count))
5613 errmsg ("missing mac address");
5619 errmsg ("missing bridge domain");
5623 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5625 errmsg ("missing interface name or sw_if_index");
5631 /* Turn on async mode */
5632 vam->async_mode = 1;
5633 vam->async_errors = 0;
5634 before = vat_time_now (vam);
5637 for (j = 0; j < count; j++)
5639 M (L2FIB_ADD_DEL, l2fib_add_del);
5642 mp->bd_id = ntohl (bd_id);
5643 mp->is_add = is_add;
5647 mp->sw_if_index = ntohl (sw_if_index);
5648 mp->static_mac = static_mac;
5649 mp->filter_mac = filter_mac;
5650 mp->bvi_mac = bvi_mac;
5652 increment_mac_address (&mac);
5659 vl_api_control_ping_t *mp;
5662 /* Shut off async mode */
5663 vam->async_mode = 0;
5665 M (CONTROL_PING, control_ping);
5668 timeout = vat_time_now (vam) + 1.0;
5669 while (vat_time_now (vam) < timeout)
5670 if (vam->result_ready == 1)
5675 if (vam->retval == -99)
5678 if (vam->async_errors > 0)
5680 errmsg ("%d asynchronous errors", vam->async_errors);
5683 vam->async_errors = 0;
5684 after = vat_time_now (vam);
5686 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5687 count, after - before, count / (after - before));
5691 /* Wait for a reply... */
5694 /* Return the good/bad news */
5695 return (vam->retval);
5699 api_l2_flags (vat_main_t * vam)
5701 unformat_input_t *i = vam->input;
5702 vl_api_l2_flags_t *mp;
5705 u32 feature_bitmap = 0;
5706 u8 sw_if_index_set = 0;
5708 /* Parse args required to build the message */
5709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5711 if (unformat (i, "sw_if_index %d", &sw_if_index))
5712 sw_if_index_set = 1;
5713 else if (unformat (i, "sw_if"))
5715 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5718 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5719 sw_if_index_set = 1;
5724 else if (unformat (i, "learn"))
5725 feature_bitmap |= L2INPUT_FEAT_LEARN;
5726 else if (unformat (i, "forward"))
5727 feature_bitmap |= L2INPUT_FEAT_FWD;
5728 else if (unformat (i, "flood"))
5729 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5730 else if (unformat (i, "uu-flood"))
5731 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5736 if (sw_if_index_set == 0)
5738 errmsg ("missing interface name or sw_if_index");
5742 M (L2_FLAGS, l2_flags);
5744 mp->sw_if_index = ntohl (sw_if_index);
5745 mp->feature_bitmap = ntohl (feature_bitmap);
5754 api_bridge_flags (vat_main_t * vam)
5756 unformat_input_t *i = vam->input;
5757 vl_api_bridge_flags_t *mp;
5764 /* Parse args required to build the message */
5765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5767 if (unformat (i, "bd_id %d", &bd_id))
5769 else if (unformat (i, "learn"))
5771 else if (unformat (i, "forward"))
5773 else if (unformat (i, "flood"))
5775 else if (unformat (i, "uu-flood"))
5776 flags |= L2_UU_FLOOD;
5777 else if (unformat (i, "arp-term"))
5778 flags |= L2_ARP_TERM;
5779 else if (unformat (i, "off"))
5781 else if (unformat (i, "disable"))
5789 errmsg ("missing bridge domain");
5793 M (BRIDGE_FLAGS, bridge_flags);
5795 mp->bd_id = ntohl (bd_id);
5796 mp->feature_bitmap = ntohl (flags);
5797 mp->is_set = is_set;
5806 api_bd_ip_mac_add_del (vat_main_t * vam)
5808 unformat_input_t *i = vam->input;
5809 vl_api_bd_ip_mac_add_del_t *mp;
5817 ip4_address_t v4addr;
5818 ip6_address_t v6addr;
5822 /* Parse args required to build the message */
5823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5825 if (unformat (i, "bd_id %d", &bd_id))
5829 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5833 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5838 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5842 else if (unformat (i, "del"))
5850 errmsg ("missing bridge domain");
5853 else if (ip_set == 0)
5855 errmsg ("missing IP address");
5858 else if (mac_set == 0)
5860 errmsg ("missing MAC address");
5864 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5866 mp->bd_id = ntohl (bd_id);
5867 mp->is_ipv6 = is_ipv6;
5868 mp->is_add = is_add;
5870 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5872 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5873 clib_memcpy (mp->mac_address, macaddr, 6);
5881 api_tap_connect (vat_main_t * vam)
5883 unformat_input_t *i = vam->input;
5884 vl_api_tap_connect_t *mp;
5892 memset (mac_address, 0, sizeof (mac_address));
5894 /* Parse args required to build the message */
5895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5897 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5901 else if (unformat (i, "random-mac"))
5903 else if (unformat (i, "tapname %s", &tap_name))
5905 else if (unformat (i, "tag %s", &tag))
5913 errmsg ("missing tap name");
5916 if (vec_len (tap_name) > 63)
5918 errmsg ("tap name too long");
5921 vec_add1 (tap_name, 0);
5923 if (vec_len (tag) > 63)
5925 errmsg ("tag too long");
5929 /* Construct the API message */
5930 M (TAP_CONNECT, tap_connect);
5932 mp->use_random_mac = random_mac;
5933 clib_memcpy (mp->mac_address, mac_address, 6);
5934 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5936 clib_memcpy (mp->tag, tag, vec_len (tag));
5938 vec_free (tap_name);
5944 /* Wait for a reply... */
5949 api_tap_modify (vat_main_t * vam)
5951 unformat_input_t *i = vam->input;
5952 vl_api_tap_modify_t *mp;
5958 u32 sw_if_index = ~0;
5959 u8 sw_if_index_set = 0;
5961 memset (mac_address, 0, sizeof (mac_address));
5963 /* Parse args required to build the message */
5964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5966 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5967 sw_if_index_set = 1;
5968 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5969 sw_if_index_set = 1;
5970 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5974 else if (unformat (i, "random-mac"))
5976 else if (unformat (i, "tapname %s", &tap_name))
5982 if (sw_if_index_set == 0)
5984 errmsg ("missing vpp interface name");
5989 errmsg ("missing tap name");
5992 if (vec_len (tap_name) > 63)
5994 errmsg ("tap name too long");
5996 vec_add1 (tap_name, 0);
5998 /* Construct the API message */
5999 M (TAP_MODIFY, tap_modify);
6001 mp->use_random_mac = random_mac;
6002 mp->sw_if_index = ntohl (sw_if_index);
6003 clib_memcpy (mp->mac_address, mac_address, 6);
6004 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6005 vec_free (tap_name);
6010 /* Wait for a reply... */
6015 api_tap_delete (vat_main_t * vam)
6017 unformat_input_t *i = vam->input;
6018 vl_api_tap_delete_t *mp;
6020 u32 sw_if_index = ~0;
6021 u8 sw_if_index_set = 0;
6023 /* Parse args required to build the message */
6024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6027 sw_if_index_set = 1;
6028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6029 sw_if_index_set = 1;
6034 if (sw_if_index_set == 0)
6036 errmsg ("missing vpp interface name");
6040 /* Construct the API message */
6041 M (TAP_DELETE, tap_delete);
6043 mp->sw_if_index = ntohl (sw_if_index);
6048 /* Wait for a reply... */
6053 api_ip_add_del_route (vat_main_t * vam)
6055 unformat_input_t *i = vam->input;
6056 vl_api_ip_add_del_route_t *mp;
6058 u32 sw_if_index = ~0, vrf_id = 0;
6060 u8 is_local = 0, is_drop = 0;
6061 u8 is_unreach = 0, is_prohibit = 0;
6062 u8 create_vrf_if_needed = 0;
6064 u32 next_hop_weight = 1;
6066 u8 is_multipath = 0;
6068 u8 address_length_set = 0;
6069 u32 next_hop_table_id = 0;
6070 u32 resolve_attempts = 0;
6071 u32 dst_address_length = 0;
6072 u8 next_hop_set = 0;
6073 ip4_address_t v4_dst_address, v4_next_hop_address;
6074 ip6_address_t v6_dst_address, v6_next_hop_address;
6078 u32 random_add_del = 0;
6079 u32 *random_vector = 0;
6081 u32 random_seed = 0xdeaddabe;
6082 u32 classify_table_index = ~0;
6084 u8 resolve_host = 0, resolve_attached = 0;
6085 mpls_label_t *next_hop_out_label_stack = NULL;
6086 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6087 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6089 /* Parse args required to build the message */
6090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6096 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6101 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6106 else if (unformat (i, "/%d", &dst_address_length))
6108 address_length_set = 1;
6111 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6112 &v4_next_hop_address))
6116 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6117 &v6_next_hop_address))
6121 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6123 else if (unformat (i, "weight %d", &next_hop_weight))
6125 else if (unformat (i, "drop"))
6129 else if (unformat (i, "null-send-unreach"))
6133 else if (unformat (i, "null-send-prohibit"))
6137 else if (unformat (i, "local"))
6141 else if (unformat (i, "classify %d", &classify_table_index))
6145 else if (unformat (i, "del"))
6147 else if (unformat (i, "add"))
6149 else if (unformat (i, "not-last"))
6151 else if (unformat (i, "resolve-via-host"))
6153 else if (unformat (i, "resolve-via-attached"))
6154 resolve_attached = 1;
6155 else if (unformat (i, "multipath"))
6157 else if (unformat (i, "vrf %d", &vrf_id))
6159 else if (unformat (i, "create-vrf"))
6160 create_vrf_if_needed = 1;
6161 else if (unformat (i, "count %d", &count))
6163 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6165 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6167 else if (unformat (i, "out-label %d", &next_hop_out_label))
6168 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6169 else if (unformat (i, "via-label %d", &next_hop_via_label))
6171 else if (unformat (i, "random"))
6173 else if (unformat (i, "seed %d", &random_seed))
6177 clib_warning ("parse error '%U'", format_unformat_error, i);
6182 if (!next_hop_set && !is_drop && !is_local &&
6183 !is_classify && !is_unreach && !is_prohibit &&
6184 MPLS_LABEL_INVALID == next_hop_via_label)
6187 ("next hop / local / drop / unreach / prohibit / classify not set");
6191 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6193 errmsg ("next hop and next-hop via label set");
6196 if (address_set == 0)
6198 errmsg ("missing addresses");
6202 if (address_length_set == 0)
6204 errmsg ("missing address length");
6208 /* Generate a pile of unique, random routes */
6211 u32 this_random_address;
6212 random_hash = hash_create (count, sizeof (uword));
6214 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6215 for (j = 0; j <= count; j++)
6219 this_random_address = random_u32 (&random_seed);
6220 this_random_address =
6221 clib_host_to_net_u32 (this_random_address);
6223 while (hash_get (random_hash, this_random_address));
6224 vec_add1 (random_vector, this_random_address);
6225 hash_set (random_hash, this_random_address, 1);
6227 hash_free (random_hash);
6228 v4_dst_address.as_u32 = random_vector[0];
6233 /* Turn on async mode */
6234 vam->async_mode = 1;
6235 vam->async_errors = 0;
6236 before = vat_time_now (vam);
6239 for (j = 0; j < count; j++)
6241 /* Construct the API message */
6242 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6243 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6245 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6246 mp->table_id = ntohl (vrf_id);
6247 mp->create_vrf_if_needed = create_vrf_if_needed;
6249 mp->is_add = is_add;
6250 mp->is_drop = is_drop;
6251 mp->is_unreach = is_unreach;
6252 mp->is_prohibit = is_prohibit;
6253 mp->is_ipv6 = is_ipv6;
6254 mp->is_local = is_local;
6255 mp->is_classify = is_classify;
6256 mp->is_multipath = is_multipath;
6257 mp->is_resolve_host = resolve_host;
6258 mp->is_resolve_attached = resolve_attached;
6259 mp->not_last = not_last;
6260 mp->next_hop_weight = next_hop_weight;
6261 mp->dst_address_length = dst_address_length;
6262 mp->next_hop_table_id = ntohl (next_hop_table_id);
6263 mp->classify_table_index = ntohl (classify_table_index);
6264 mp->next_hop_via_label = ntohl (next_hop_via_label);
6265 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6266 if (0 != mp->next_hop_n_out_labels)
6268 memcpy (mp->next_hop_out_label_stack,
6269 next_hop_out_label_stack,
6270 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6271 vec_free (next_hop_out_label_stack);
6276 clib_memcpy (mp->dst_address, &v6_dst_address,
6277 sizeof (v6_dst_address));
6279 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6280 sizeof (v6_next_hop_address));
6281 increment_v6_address (&v6_dst_address);
6285 clib_memcpy (mp->dst_address, &v4_dst_address,
6286 sizeof (v4_dst_address));
6288 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6289 sizeof (v4_next_hop_address));
6291 v4_dst_address.as_u32 = random_vector[j + 1];
6293 increment_v4_address (&v4_dst_address);
6297 /* If we receive SIGTERM, stop now... */
6302 /* When testing multiple add/del ops, use a control-ping to sync */
6305 vl_api_control_ping_t *mp;
6308 /* Shut off async mode */
6309 vam->async_mode = 0;
6311 M (CONTROL_PING, control_ping);
6314 timeout = vat_time_now (vam) + 1.0;
6315 while (vat_time_now (vam) < timeout)
6316 if (vam->result_ready == 1)
6321 if (vam->retval == -99)
6324 if (vam->async_errors > 0)
6326 errmsg ("%d asynchronous errors", vam->async_errors);
6329 vam->async_errors = 0;
6330 after = vat_time_now (vam);
6332 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6336 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6337 count, after - before, count / (after - before));
6341 /* Wait for a reply... */
6345 /* Return the good/bad news */
6346 return (vam->retval);
6350 api_mpls_route_add_del (vat_main_t * vam)
6352 unformat_input_t *i = vam->input;
6353 vl_api_mpls_route_add_del_t *mp;
6355 u32 sw_if_index = ~0, table_id = 0;
6356 u8 create_table_if_needed = 0;
6358 u32 next_hop_weight = 1;
6359 u8 is_multipath = 0;
6360 u32 next_hop_table_id = 0;
6361 u8 next_hop_set = 0;
6362 ip4_address_t v4_next_hop_address = {
6365 ip6_address_t v6_next_hop_address = { {0} };
6369 u32 classify_table_index = ~0;
6371 u8 resolve_host = 0, resolve_attached = 0;
6372 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6373 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6374 mpls_label_t *next_hop_out_label_stack = NULL;
6375 mpls_label_t local_label = MPLS_LABEL_INVALID;
6377 u8 next_hop_proto_is_ip4 = 1;
6379 /* Parse args required to build the message */
6380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6386 else if (unformat (i, "%d", &local_label))
6388 else if (unformat (i, "eos"))
6390 else if (unformat (i, "non-eos"))
6392 else if (unformat (i, "via %U", unformat_ip4_address,
6393 &v4_next_hop_address))
6396 next_hop_proto_is_ip4 = 1;
6398 else if (unformat (i, "via %U", unformat_ip6_address,
6399 &v6_next_hop_address))
6402 next_hop_proto_is_ip4 = 0;
6404 else if (unformat (i, "weight %d", &next_hop_weight))
6406 else if (unformat (i, "create-table"))
6407 create_table_if_needed = 1;
6408 else if (unformat (i, "classify %d", &classify_table_index))
6412 else if (unformat (i, "del"))
6414 else if (unformat (i, "add"))
6416 else if (unformat (i, "resolve-via-host"))
6418 else if (unformat (i, "resolve-via-attached"))
6419 resolve_attached = 1;
6420 else if (unformat (i, "multipath"))
6422 else if (unformat (i, "count %d", &count))
6424 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6427 next_hop_proto_is_ip4 = 1;
6429 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6432 next_hop_proto_is_ip4 = 0;
6434 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6436 else if (unformat (i, "via-label %d", &next_hop_via_label))
6438 else if (unformat (i, "out-label %d", &next_hop_out_label))
6439 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6442 clib_warning ("parse error '%U'", format_unformat_error, i);
6447 if (!next_hop_set && !is_classify)
6449 errmsg ("next hop / classify not set");
6453 if (MPLS_LABEL_INVALID == local_label)
6455 errmsg ("missing label");
6461 /* Turn on async mode */
6462 vam->async_mode = 1;
6463 vam->async_errors = 0;
6464 before = vat_time_now (vam);
6467 for (j = 0; j < count; j++)
6469 /* Construct the API message */
6470 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6471 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6473 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6474 mp->mr_table_id = ntohl (table_id);
6475 mp->mr_create_table_if_needed = create_table_if_needed;
6477 mp->mr_is_add = is_add;
6478 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6479 mp->mr_is_classify = is_classify;
6480 mp->mr_is_multipath = is_multipath;
6481 mp->mr_is_resolve_host = resolve_host;
6482 mp->mr_is_resolve_attached = resolve_attached;
6483 mp->mr_next_hop_weight = next_hop_weight;
6484 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6485 mp->mr_classify_table_index = ntohl (classify_table_index);
6486 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6487 mp->mr_label = ntohl (local_label);
6488 mp->mr_eos = is_eos;
6490 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6491 if (0 != mp->mr_next_hop_n_out_labels)
6493 memcpy (mp->mr_next_hop_out_label_stack,
6494 next_hop_out_label_stack,
6495 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6496 vec_free (next_hop_out_label_stack);
6501 if (next_hop_proto_is_ip4)
6503 clib_memcpy (mp->mr_next_hop,
6504 &v4_next_hop_address,
6505 sizeof (v4_next_hop_address));
6509 clib_memcpy (mp->mr_next_hop,
6510 &v6_next_hop_address,
6511 sizeof (v6_next_hop_address));
6518 /* If we receive SIGTERM, stop now... */
6523 /* When testing multiple add/del ops, use a control-ping to sync */
6526 vl_api_control_ping_t *mp;
6529 /* Shut off async mode */
6530 vam->async_mode = 0;
6532 M (CONTROL_PING, control_ping);
6535 timeout = vat_time_now (vam) + 1.0;
6536 while (vat_time_now (vam) < timeout)
6537 if (vam->result_ready == 1)
6542 if (vam->retval == -99)
6545 if (vam->async_errors > 0)
6547 errmsg ("%d asynchronous errors", vam->async_errors);
6550 vam->async_errors = 0;
6551 after = vat_time_now (vam);
6553 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6557 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6558 count, after - before, count / (after - before));
6562 /* Wait for a reply... */
6566 /* Return the good/bad news */
6567 return (vam->retval);
6571 api_mpls_ip_bind_unbind (vat_main_t * vam)
6573 unformat_input_t *i = vam->input;
6574 vl_api_mpls_ip_bind_unbind_t *mp;
6576 u32 ip_table_id = 0;
6577 u8 create_table_if_needed = 0;
6580 ip4_address_t v4_address;
6581 ip6_address_t v6_address;
6584 mpls_label_t local_label = MPLS_LABEL_INVALID;
6586 /* Parse args required to build the message */
6587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6589 if (unformat (i, "%U/%d", unformat_ip4_address,
6590 &v4_address, &address_length))
6595 else if (unformat (i, "%U/%d", unformat_ip6_address,
6596 &v6_address, &address_length))
6601 else if (unformat (i, "%d", &local_label))
6603 else if (unformat (i, "create-table"))
6604 create_table_if_needed = 1;
6605 else if (unformat (i, "table-id %d", &ip_table_id))
6607 else if (unformat (i, "unbind"))
6609 else if (unformat (i, "bind"))
6613 clib_warning ("parse error '%U'", format_unformat_error, i);
6620 errmsg ("IP addres not set");
6624 if (MPLS_LABEL_INVALID == local_label)
6626 errmsg ("missing label");
6630 /* Construct the API message */
6631 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6633 mp->mb_create_table_if_needed = create_table_if_needed;
6634 mp->mb_is_bind = is_bind;
6635 mp->mb_is_ip4 = is_ip4;
6636 mp->mb_ip_table_id = ntohl (ip_table_id);
6637 mp->mb_mpls_table_id = 0;
6638 mp->mb_label = ntohl (local_label);
6639 mp->mb_address_length = address_length;
6642 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6644 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6649 /* Wait for a reply... */
6654 api_proxy_arp_add_del (vat_main_t * vam)
6656 unformat_input_t *i = vam->input;
6657 vl_api_proxy_arp_add_del_t *mp;
6661 ip4_address_t lo, hi;
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "vrf %d", &vrf_id))
6668 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6669 unformat_ip4_address, &hi))
6671 else if (unformat (i, "del"))
6675 clib_warning ("parse error '%U'", format_unformat_error, i);
6682 errmsg ("address range not set");
6686 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6688 mp->vrf_id = ntohl (vrf_id);
6689 mp->is_add = is_add;
6690 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6691 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6700 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6702 unformat_input_t *i = vam->input;
6703 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6707 u8 sw_if_index_set = 0;
6709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6711 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6712 sw_if_index_set = 1;
6713 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6714 sw_if_index_set = 1;
6715 else if (unformat (i, "enable"))
6717 else if (unformat (i, "disable"))
6721 clib_warning ("parse error '%U'", format_unformat_error, i);
6726 if (sw_if_index_set == 0)
6728 errmsg ("missing interface name or sw_if_index");
6732 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6734 mp->sw_if_index = ntohl (sw_if_index);
6735 mp->enable_disable = enable;
6744 api_mpls_tunnel_add_del (vat_main_t * vam)
6746 unformat_input_t *i = vam->input;
6747 vl_api_mpls_tunnel_add_del_t *mp;
6752 u32 sw_if_index = ~0;
6753 u32 next_hop_sw_if_index = ~0;
6754 u32 next_hop_proto_is_ip4 = 1;
6756 u32 next_hop_table_id = 0;
6757 ip4_address_t v4_next_hop_address = {
6760 ip6_address_t v6_next_hop_address = { {0} };
6761 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6765 if (unformat (i, "add"))
6767 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6769 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6771 else if (unformat (i, "via %U",
6772 unformat_ip4_address, &v4_next_hop_address))
6774 next_hop_proto_is_ip4 = 1;
6776 else if (unformat (i, "via %U",
6777 unformat_ip6_address, &v6_next_hop_address))
6779 next_hop_proto_is_ip4 = 0;
6781 else if (unformat (i, "l2-only"))
6783 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6785 else if (unformat (i, "out-label %d", &next_hop_out_label))
6786 vec_add1 (labels, ntohl (next_hop_out_label));
6789 clib_warning ("parse error '%U'", format_unformat_error, i);
6794 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6795 sizeof (mpls_label_t) * vec_len (labels));
6797 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6798 mp->mt_sw_if_index = ntohl (sw_if_index);
6799 mp->mt_is_add = is_add;
6800 mp->mt_l2_only = l2_only;
6801 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6802 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6804 mp->mt_next_hop_n_out_labels = vec_len (labels);
6806 if (0 != mp->mt_next_hop_n_out_labels)
6808 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6809 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6813 if (next_hop_proto_is_ip4)
6815 clib_memcpy (mp->mt_next_hop,
6816 &v4_next_hop_address, sizeof (v4_next_hop_address));
6820 clib_memcpy (mp->mt_next_hop,
6821 &v6_next_hop_address, sizeof (v6_next_hop_address));
6831 api_sw_interface_set_unnumbered (vat_main_t * vam)
6833 unformat_input_t *i = vam->input;
6834 vl_api_sw_interface_set_unnumbered_t *mp;
6837 u32 unnum_sw_index = ~0;
6839 u8 sw_if_index_set = 0;
6841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6844 sw_if_index_set = 1;
6845 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6846 sw_if_index_set = 1;
6847 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6849 else if (unformat (i, "del"))
6853 clib_warning ("parse error '%U'", format_unformat_error, i);
6858 if (sw_if_index_set == 0)
6860 errmsg ("missing interface name or sw_if_index");
6864 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6866 mp->sw_if_index = ntohl (sw_if_index);
6867 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6868 mp->is_add = is_add;
6877 api_ip_neighbor_add_del (vat_main_t * vam)
6879 unformat_input_t *i = vam->input;
6880 vl_api_ip_neighbor_add_del_t *mp;
6883 u8 sw_if_index_set = 0;
6889 u8 v4_address_set = 0;
6890 u8 v6_address_set = 0;
6891 ip4_address_t v4address;
6892 ip6_address_t v6address;
6894 memset (mac_address, 0, sizeof (mac_address));
6896 /* Parse args required to build the message */
6897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6899 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6903 else if (unformat (i, "del"))
6906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6907 sw_if_index_set = 1;
6908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6909 sw_if_index_set = 1;
6910 else if (unformat (i, "is_static"))
6912 else if (unformat (i, "vrf %d", &vrf_id))
6914 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6916 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6920 clib_warning ("parse error '%U'", format_unformat_error, i);
6925 if (sw_if_index_set == 0)
6927 errmsg ("missing interface name or sw_if_index");
6930 if (v4_address_set && v6_address_set)
6932 errmsg ("both v4 and v6 addresses set");
6935 if (!v4_address_set && !v6_address_set)
6937 errmsg ("no address set");
6941 /* Construct the API message */
6942 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6944 mp->sw_if_index = ntohl (sw_if_index);
6945 mp->is_add = is_add;
6946 mp->vrf_id = ntohl (vrf_id);
6947 mp->is_static = is_static;
6949 clib_memcpy (mp->mac_address, mac_address, 6);
6953 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6957 /* mp->is_ipv6 = 0; via memset in M macro above */
6958 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6964 /* Wait for a reply, return good/bad news */
6972 api_reset_vrf (vat_main_t * vam)
6974 unformat_input_t *i = vam->input;
6975 vl_api_reset_vrf_t *mp;
6981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6983 if (unformat (i, "vrf %d", &vrf_id))
6985 else if (unformat (i, "ipv6"))
6989 clib_warning ("parse error '%U'", format_unformat_error, i);
6994 if (vrf_id_set == 0)
6996 errmsg ("missing vrf id");
7000 M (RESET_VRF, reset_vrf);
7002 mp->vrf_id = ntohl (vrf_id);
7003 mp->is_ipv6 = is_ipv6;
7012 api_create_vlan_subif (vat_main_t * vam)
7014 unformat_input_t *i = vam->input;
7015 vl_api_create_vlan_subif_t *mp;
7018 u8 sw_if_index_set = 0;
7022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7024 if (unformat (i, "sw_if_index %d", &sw_if_index))
7025 sw_if_index_set = 1;
7027 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7028 sw_if_index_set = 1;
7029 else if (unformat (i, "vlan %d", &vlan_id))
7033 clib_warning ("parse error '%U'", format_unformat_error, i);
7038 if (sw_if_index_set == 0)
7040 errmsg ("missing interface name or sw_if_index");
7044 if (vlan_id_set == 0)
7046 errmsg ("missing vlan_id");
7049 M (CREATE_VLAN_SUBIF, create_vlan_subif);
7051 mp->sw_if_index = ntohl (sw_if_index);
7052 mp->vlan_id = ntohl (vlan_id);
7060 #define foreach_create_subif_bit \
7067 _(outer_vlan_id_any) \
7068 _(inner_vlan_id_any)
7071 api_create_subif (vat_main_t * vam)
7073 unformat_input_t *i = vam->input;
7074 vl_api_create_subif_t *mp;
7077 u8 sw_if_index_set = 0;
7084 u32 exact_match = 0;
7085 u32 default_sub = 0;
7086 u32 outer_vlan_id_any = 0;
7087 u32 inner_vlan_id_any = 0;
7089 u16 outer_vlan_id = 0;
7090 u16 inner_vlan_id = 0;
7092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7094 if (unformat (i, "sw_if_index %d", &sw_if_index))
7095 sw_if_index_set = 1;
7097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7098 sw_if_index_set = 1;
7099 else if (unformat (i, "sub_id %d", &sub_id))
7101 else if (unformat (i, "outer_vlan_id %d", &tmp))
7102 outer_vlan_id = tmp;
7103 else if (unformat (i, "inner_vlan_id %d", &tmp))
7104 inner_vlan_id = tmp;
7106 #define _(a) else if (unformat (i, #a)) a = 1 ;
7107 foreach_create_subif_bit
7111 clib_warning ("parse error '%U'", format_unformat_error, i);
7116 if (sw_if_index_set == 0)
7118 errmsg ("missing interface name or sw_if_index");
7122 if (sub_id_set == 0)
7124 errmsg ("missing sub_id");
7127 M (CREATE_SUBIF, create_subif);
7129 mp->sw_if_index = ntohl (sw_if_index);
7130 mp->sub_id = ntohl (sub_id);
7132 #define _(a) mp->a = a;
7133 foreach_create_subif_bit;
7136 mp->outer_vlan_id = ntohs (outer_vlan_id);
7137 mp->inner_vlan_id = ntohs (inner_vlan_id);
7146 api_oam_add_del (vat_main_t * vam)
7148 unformat_input_t *i = vam->input;
7149 vl_api_oam_add_del_t *mp;
7153 ip4_address_t src, dst;
7157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7159 if (unformat (i, "vrf %d", &vrf_id))
7161 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7163 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7165 else if (unformat (i, "del"))
7169 clib_warning ("parse error '%U'", format_unformat_error, i);
7176 errmsg ("missing src addr");
7182 errmsg ("missing dst addr");
7186 M (OAM_ADD_DEL, oam_add_del);
7188 mp->vrf_id = ntohl (vrf_id);
7189 mp->is_add = is_add;
7190 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7191 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7200 api_reset_fib (vat_main_t * vam)
7202 unformat_input_t *i = vam->input;
7203 vl_api_reset_fib_t *mp;
7209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7211 if (unformat (i, "vrf %d", &vrf_id))
7213 else if (unformat (i, "ipv6"))
7217 clib_warning ("parse error '%U'", format_unformat_error, i);
7222 if (vrf_id_set == 0)
7224 errmsg ("missing vrf id");
7228 M (RESET_FIB, reset_fib);
7230 mp->vrf_id = ntohl (vrf_id);
7231 mp->is_ipv6 = is_ipv6;
7240 api_dhcp_proxy_config (vat_main_t * vam)
7242 unformat_input_t *i = vam->input;
7243 vl_api_dhcp_proxy_config_t *mp;
7248 u8 v4_address_set = 0;
7249 u8 v6_address_set = 0;
7250 ip4_address_t v4address;
7251 ip6_address_t v6address;
7252 u8 v4_src_address_set = 0;
7253 u8 v6_src_address_set = 0;
7254 ip4_address_t v4srcaddress;
7255 ip6_address_t v6srcaddress;
7257 /* Parse args required to build the message */
7258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7260 if (unformat (i, "del"))
7262 else if (unformat (i, "vrf %d", &vrf_id))
7264 else if (unformat (i, "insert-cid %d", &insert_cid))
7266 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7268 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7270 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7271 v4_src_address_set = 1;
7272 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7273 v6_src_address_set = 1;
7278 if (v4_address_set && v6_address_set)
7280 errmsg ("both v4 and v6 server addresses set");
7283 if (!v4_address_set && !v6_address_set)
7285 errmsg ("no server addresses set");
7289 if (v4_src_address_set && v6_src_address_set)
7291 errmsg ("both v4 and v6 src addresses set");
7294 if (!v4_src_address_set && !v6_src_address_set)
7296 errmsg ("no src addresses set");
7300 if (!(v4_src_address_set && v4_address_set) &&
7301 !(v6_src_address_set && v6_address_set))
7303 errmsg ("no matching server and src addresses set");
7307 /* Construct the API message */
7308 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7310 mp->insert_circuit_id = insert_cid;
7311 mp->is_add = is_add;
7312 mp->vrf_id = ntohl (vrf_id);
7316 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7317 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7321 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7322 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7328 /* Wait for a reply, return good/bad news */
7335 api_dhcp_proxy_config_2 (vat_main_t * vam)
7337 unformat_input_t *i = vam->input;
7338 vl_api_dhcp_proxy_config_2_t *mp;
7341 u32 server_vrf_id = 0;
7344 u8 v4_address_set = 0;
7345 u8 v6_address_set = 0;
7346 ip4_address_t v4address;
7347 ip6_address_t v6address;
7348 u8 v4_src_address_set = 0;
7349 u8 v6_src_address_set = 0;
7350 ip4_address_t v4srcaddress;
7351 ip6_address_t v6srcaddress;
7353 /* Parse args required to build the message */
7354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7356 if (unformat (i, "del"))
7358 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7360 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7362 else if (unformat (i, "insert-cid %d", &insert_cid))
7364 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7366 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7368 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7369 v4_src_address_set = 1;
7370 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7371 v6_src_address_set = 1;
7376 if (v4_address_set && v6_address_set)
7378 errmsg ("both v4 and v6 server addresses set");
7381 if (!v4_address_set && !v6_address_set)
7383 errmsg ("no server addresses set");
7387 if (v4_src_address_set && v6_src_address_set)
7389 errmsg ("both v4 and v6 src addresses set");
7392 if (!v4_src_address_set && !v6_src_address_set)
7394 errmsg ("no src addresses set");
7398 if (!(v4_src_address_set && v4_address_set) &&
7399 !(v6_src_address_set && v6_address_set))
7401 errmsg ("no matching server and src addresses set");
7405 /* Construct the API message */
7406 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7408 mp->insert_circuit_id = insert_cid;
7409 mp->is_add = is_add;
7410 mp->rx_vrf_id = ntohl (rx_vrf_id);
7411 mp->server_vrf_id = ntohl (server_vrf_id);
7415 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7416 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7420 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7421 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7427 /* Wait for a reply, return good/bad news */
7434 api_dhcp_proxy_set_vss (vat_main_t * vam)
7436 unformat_input_t *i = vam->input;
7437 vl_api_dhcp_proxy_set_vss_t *mp;
7448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7450 if (unformat (i, "tbl_id %d", &tbl_id))
7452 if (unformat (i, "fib_id %d", &fib_id))
7454 if (unformat (i, "oui %d", &oui))
7456 else if (unformat (i, "ipv6"))
7458 else if (unformat (i, "del"))
7462 clib_warning ("parse error '%U'", format_unformat_error, i);
7467 if (tbl_id_set == 0)
7469 errmsg ("missing tbl id");
7473 if (fib_id_set == 0)
7475 errmsg ("missing fib id");
7480 errmsg ("missing oui");
7484 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7485 mp->tbl_id = ntohl (tbl_id);
7486 mp->fib_id = ntohl (fib_id);
7487 mp->oui = ntohl (oui);
7488 mp->is_ipv6 = is_ipv6;
7489 mp->is_add = is_add;
7498 api_dhcp_client_config (vat_main_t * vam)
7500 unformat_input_t *i = vam->input;
7501 vl_api_dhcp_client_config_t *mp;
7504 u8 sw_if_index_set = 0;
7507 u8 disable_event = 0;
7509 /* Parse args required to build the message */
7510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7512 if (unformat (i, "del"))
7515 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7516 sw_if_index_set = 1;
7517 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7518 sw_if_index_set = 1;
7519 else if (unformat (i, "hostname %s", &hostname))
7521 else if (unformat (i, "disable_event"))
7527 if (sw_if_index_set == 0)
7529 errmsg ("missing interface name or sw_if_index");
7533 if (vec_len (hostname) > 63)
7535 errmsg ("hostname too long");
7537 vec_add1 (hostname, 0);
7539 /* Construct the API message */
7540 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7542 mp->sw_if_index = ntohl (sw_if_index);
7543 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7544 vec_free (hostname);
7545 mp->is_add = is_add;
7546 mp->want_dhcp_event = disable_event ? 0 : 1;
7547 mp->pid = getpid ();
7552 /* Wait for a reply, return good/bad news */
7559 api_set_ip_flow_hash (vat_main_t * vam)
7561 unformat_input_t *i = vam->input;
7562 vl_api_set_ip_flow_hash_t *mp;
7574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7576 if (unformat (i, "vrf %d", &vrf_id))
7578 else if (unformat (i, "ipv6"))
7580 else if (unformat (i, "src"))
7582 else if (unformat (i, "dst"))
7584 else if (unformat (i, "sport"))
7586 else if (unformat (i, "dport"))
7588 else if (unformat (i, "proto"))
7590 else if (unformat (i, "reverse"))
7595 clib_warning ("parse error '%U'", format_unformat_error, i);
7600 if (vrf_id_set == 0)
7602 errmsg ("missing vrf id");
7606 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7612 mp->reverse = reverse;
7613 mp->vrf_id = ntohl (vrf_id);
7614 mp->is_ipv6 = is_ipv6;
7623 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7625 unformat_input_t *i = vam->input;
7626 vl_api_sw_interface_ip6_enable_disable_t *mp;
7629 u8 sw_if_index_set = 0;
7632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7635 sw_if_index_set = 1;
7636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7637 sw_if_index_set = 1;
7638 else if (unformat (i, "enable"))
7640 else if (unformat (i, "disable"))
7644 clib_warning ("parse error '%U'", format_unformat_error, i);
7649 if (sw_if_index_set == 0)
7651 errmsg ("missing interface name or sw_if_index");
7655 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7657 mp->sw_if_index = ntohl (sw_if_index);
7658 mp->enable = enable;
7667 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7669 unformat_input_t *i = vam->input;
7670 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7673 u8 sw_if_index_set = 0;
7674 u8 v6_address_set = 0;
7675 ip6_address_t v6address;
7677 /* Parse args required to build the message */
7678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7680 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7681 sw_if_index_set = 1;
7682 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7683 sw_if_index_set = 1;
7684 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7690 if (sw_if_index_set == 0)
7692 errmsg ("missing interface name or sw_if_index");
7695 if (!v6_address_set)
7697 errmsg ("no address set");
7701 /* Construct the API message */
7702 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7703 sw_interface_ip6_set_link_local_address);
7705 mp->sw_if_index = ntohl (sw_if_index);
7706 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7711 /* Wait for a reply, return good/bad news */
7720 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7722 unformat_input_t *i = vam->input;
7723 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7726 u8 sw_if_index_set = 0;
7727 u32 address_length = 0;
7728 u8 v6_address_set = 0;
7729 ip6_address_t v6address;
7731 u8 no_advertise = 0;
7733 u8 no_autoconfig = 0;
7736 u32 val_lifetime = 0;
7737 u32 pref_lifetime = 0;
7739 /* Parse args required to build the message */
7740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7742 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7743 sw_if_index_set = 1;
7744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7745 sw_if_index_set = 1;
7746 else if (unformat (i, "%U/%d",
7747 unformat_ip6_address, &v6address, &address_length))
7749 else if (unformat (i, "val_life %d", &val_lifetime))
7751 else if (unformat (i, "pref_life %d", &pref_lifetime))
7753 else if (unformat (i, "def"))
7755 else if (unformat (i, "noadv"))
7757 else if (unformat (i, "offl"))
7759 else if (unformat (i, "noauto"))
7761 else if (unformat (i, "nolink"))
7763 else if (unformat (i, "isno"))
7767 clib_warning ("parse error '%U'", format_unformat_error, i);
7772 if (sw_if_index_set == 0)
7774 errmsg ("missing interface name or sw_if_index");
7777 if (!v6_address_set)
7779 errmsg ("no address set");
7783 /* Construct the API message */
7784 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7786 mp->sw_if_index = ntohl (sw_if_index);
7787 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7788 mp->address_length = address_length;
7789 mp->use_default = use_default;
7790 mp->no_advertise = no_advertise;
7791 mp->off_link = off_link;
7792 mp->no_autoconfig = no_autoconfig;
7793 mp->no_onlink = no_onlink;
7795 mp->val_lifetime = ntohl (val_lifetime);
7796 mp->pref_lifetime = ntohl (pref_lifetime);
7801 /* Wait for a reply, return good/bad news */
7809 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7811 unformat_input_t *i = vam->input;
7812 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7815 u8 sw_if_index_set = 0;
7820 u8 send_unicast = 0;
7823 u8 default_router = 0;
7824 u32 max_interval = 0;
7825 u32 min_interval = 0;
7827 u32 initial_count = 0;
7828 u32 initial_interval = 0;
7831 /* Parse args required to build the message */
7832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7834 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7835 sw_if_index_set = 1;
7836 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7837 sw_if_index_set = 1;
7838 else if (unformat (i, "maxint %d", &max_interval))
7840 else if (unformat (i, "minint %d", &min_interval))
7842 else if (unformat (i, "life %d", &lifetime))
7844 else if (unformat (i, "count %d", &initial_count))
7846 else if (unformat (i, "interval %d", &initial_interval))
7848 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7850 else if (unformat (i, "managed"))
7852 else if (unformat (i, "other"))
7854 else if (unformat (i, "ll"))
7856 else if (unformat (i, "send"))
7858 else if (unformat (i, "cease"))
7860 else if (unformat (i, "isno"))
7862 else if (unformat (i, "def"))
7866 clib_warning ("parse error '%U'", format_unformat_error, i);
7871 if (sw_if_index_set == 0)
7873 errmsg ("missing interface name or sw_if_index");
7877 /* Construct the API message */
7878 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7880 mp->sw_if_index = ntohl (sw_if_index);
7881 mp->max_interval = ntohl (max_interval);
7882 mp->min_interval = ntohl (min_interval);
7883 mp->lifetime = ntohl (lifetime);
7884 mp->initial_count = ntohl (initial_count);
7885 mp->initial_interval = ntohl (initial_interval);
7886 mp->suppress = suppress;
7887 mp->managed = managed;
7889 mp->ll_option = ll_option;
7890 mp->send_unicast = send_unicast;
7893 mp->default_router = default_router;
7898 /* Wait for a reply, return good/bad news */
7906 api_set_arp_neighbor_limit (vat_main_t * vam)
7908 unformat_input_t *i = vam->input;
7909 vl_api_set_arp_neighbor_limit_t *mp;
7915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7917 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7919 else if (unformat (i, "ipv6"))
7923 clib_warning ("parse error '%U'", format_unformat_error, i);
7930 errmsg ("missing limit value");
7934 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7936 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7937 mp->is_ipv6 = is_ipv6;
7946 api_l2_patch_add_del (vat_main_t * vam)
7948 unformat_input_t *i = vam->input;
7949 vl_api_l2_patch_add_del_t *mp;
7952 u8 rx_sw_if_index_set = 0;
7954 u8 tx_sw_if_index_set = 0;
7957 /* Parse args required to build the message */
7958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7960 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7961 rx_sw_if_index_set = 1;
7962 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7963 tx_sw_if_index_set = 1;
7964 else if (unformat (i, "rx"))
7966 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7968 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7970 rx_sw_if_index_set = 1;
7975 else if (unformat (i, "tx"))
7977 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7979 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7981 tx_sw_if_index_set = 1;
7986 else if (unformat (i, "del"))
7992 if (rx_sw_if_index_set == 0)
7994 errmsg ("missing rx interface name or rx_sw_if_index");
7998 if (tx_sw_if_index_set == 0)
8000 errmsg ("missing tx interface name or tx_sw_if_index");
8004 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
8006 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8007 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8008 mp->is_add = is_add;
8017 api_ioam_enable (vat_main_t * vam)
8019 unformat_input_t *input = vam->input;
8020 vl_api_ioam_enable_t *mp;
8023 int has_trace_option = 0;
8024 int has_pot_option = 0;
8025 int has_seqno_option = 0;
8026 int has_analyse_option = 0;
8028 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8030 if (unformat (input, "trace"))
8031 has_trace_option = 1;
8032 else if (unformat (input, "pot"))
8034 else if (unformat (input, "seqno"))
8035 has_seqno_option = 1;
8036 else if (unformat (input, "analyse"))
8037 has_analyse_option = 1;
8041 M (IOAM_ENABLE, ioam_enable);
8042 mp->id = htons (id);
8043 mp->seqno = has_seqno_option;
8044 mp->analyse = has_analyse_option;
8045 mp->pot_enable = has_pot_option;
8046 mp->trace_enable = has_trace_option;
8057 api_ioam_disable (vat_main_t * vam)
8059 vl_api_ioam_disable_t *mp;
8062 M (IOAM_DISABLE, ioam_disable);
8069 api_sr_tunnel_add_del (vat_main_t * vam)
8071 unformat_input_t *i = vam->input;
8072 vl_api_sr_tunnel_add_del_t *mp;
8076 ip6_address_t src_address;
8077 int src_address_set = 0;
8078 ip6_address_t dst_address;
8080 int dst_address_set = 0;
8082 u32 rx_table_id = 0;
8083 u32 tx_table_id = 0;
8084 ip6_address_t *segments = 0;
8085 ip6_address_t *this_seg;
8086 ip6_address_t *tags = 0;
8087 ip6_address_t *this_tag;
8088 ip6_address_t next_address, tag;
8090 u8 *policy_name = 0;
8092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8094 if (unformat (i, "del"))
8096 else if (unformat (i, "name %s", &name))
8098 else if (unformat (i, "policy %s", &policy_name))
8100 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8102 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8104 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8105 src_address_set = 1;
8106 else if (unformat (i, "dst %U/%d",
8107 unformat_ip6_address, &dst_address, &dst_mask_width))
8108 dst_address_set = 1;
8109 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8111 vec_add2 (segments, this_seg, 1);
8112 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8113 sizeof (*this_seg));
8115 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8117 vec_add2 (tags, this_tag, 1);
8118 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8120 else if (unformat (i, "clean"))
8121 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8122 else if (unformat (i, "protected"))
8123 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8124 else if (unformat (i, "InPE %d", &pl_index))
8126 if (pl_index <= 0 || pl_index > 4)
8128 pl_index_range_error:
8129 errmsg ("pl index %d out of range", pl_index);
8133 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8135 else if (unformat (i, "EgPE %d", &pl_index))
8137 if (pl_index <= 0 || pl_index > 4)
8138 goto pl_index_range_error;
8140 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8142 else if (unformat (i, "OrgSrc %d", &pl_index))
8144 if (pl_index <= 0 || pl_index > 4)
8145 goto pl_index_range_error;
8147 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8153 if (!src_address_set)
8155 errmsg ("src address required");
8159 if (!dst_address_set)
8161 errmsg ("dst address required");
8167 errmsg ("at least one sr segment required");
8171 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8172 vec_len (segments) * sizeof (ip6_address_t)
8173 + vec_len (tags) * sizeof (ip6_address_t));
8175 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8176 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8177 mp->dst_mask_width = dst_mask_width;
8178 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8179 mp->n_segments = vec_len (segments);
8180 mp->n_tags = vec_len (tags);
8181 mp->is_add = is_del == 0;
8182 clib_memcpy (mp->segs_and_tags, segments,
8183 vec_len (segments) * sizeof (ip6_address_t));
8184 clib_memcpy (mp->segs_and_tags +
8185 vec_len (segments) * sizeof (ip6_address_t), tags,
8186 vec_len (tags) * sizeof (ip6_address_t));
8188 mp->outer_vrf_id = ntohl (rx_table_id);
8189 mp->inner_vrf_id = ntohl (tx_table_id);
8190 memcpy (mp->name, name, vec_len (name));
8191 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8193 vec_free (segments);
8202 api_sr_policy_add_del (vat_main_t * vam)
8204 unformat_input_t *input = vam->input;
8205 vl_api_sr_policy_add_del_t *mp;
8209 u8 *tunnel_name = 0;
8210 u8 **tunnel_names = 0;
8215 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8216 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8220 if (unformat (input, "del"))
8222 else if (unformat (input, "name %s", &name))
8224 else if (unformat (input, "tunnel %s", &tunnel_name))
8228 vec_add1 (tunnel_names, tunnel_name);
8230 - length = #bytes to store in serial vector
8231 - +1 = byte to store that length
8233 tunnel_names_length += (vec_len (tunnel_name) + 1);
8244 errmsg ("policy name required");
8248 if ((!tunnel_set) && (!is_del))
8250 errmsg ("tunnel name required");
8254 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8258 mp->is_add = !is_del;
8260 memcpy (mp->name, name, vec_len (name));
8261 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8262 u8 *serial_orig = 0;
8263 vec_validate (serial_orig, tunnel_names_length);
8264 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8265 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8267 for (j = 0; j < vec_len (tunnel_names); j++)
8269 tun_name_len = vec_len (tunnel_names[j]);
8270 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8271 serial_orig += 1; // Move along one byte to store the actual tunnel name
8272 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8273 serial_orig += tun_name_len; // Advance past the copy
8275 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8277 vec_free (tunnel_names);
8278 vec_free (tunnel_name);
8286 api_sr_multicast_map_add_del (vat_main_t * vam)
8288 unformat_input_t *input = vam->input;
8289 vl_api_sr_multicast_map_add_del_t *mp;
8292 ip6_address_t multicast_address;
8293 u8 *policy_name = 0;
8294 int multicast_address_set = 0;
8296 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8298 if (unformat (input, "del"))
8302 (input, "address %U", unformat_ip6_address, &multicast_address))
8303 multicast_address_set = 1;
8304 else if (unformat (input, "sr-policy %s", &policy_name))
8310 if (!is_del && !policy_name)
8312 errmsg ("sr-policy name required");
8317 if (!multicast_address_set)
8319 errmsg ("address required");
8323 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8325 mp->is_add = !is_del;
8326 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8327 clib_memcpy (mp->multicast_address, &multicast_address,
8328 sizeof (mp->multicast_address));
8331 vec_free (policy_name);
8339 #define foreach_tcp_proto_field \
8343 #define foreach_udp_proto_field \
8347 #define foreach_ip4_proto_field \
8358 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8360 u8 **maskp = va_arg (*args, u8 **);
8362 u8 found_something = 0;
8365 #define _(a) u8 a=0;
8366 foreach_tcp_proto_field;
8369 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8372 #define _(a) else if (unformat (input, #a)) a=1;
8373 foreach_tcp_proto_field
8379 #define _(a) found_something += a;
8380 foreach_tcp_proto_field;
8383 if (found_something == 0)
8386 vec_validate (mask, sizeof (*tcp) - 1);
8388 tcp = (tcp_header_t *) mask;
8390 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8391 foreach_tcp_proto_field;
8399 unformat_udp_mask (unformat_input_t * input, va_list * args)
8401 u8 **maskp = va_arg (*args, u8 **);
8403 u8 found_something = 0;
8406 #define _(a) u8 a=0;
8407 foreach_udp_proto_field;
8410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8413 #define _(a) else if (unformat (input, #a)) a=1;
8414 foreach_udp_proto_field
8420 #define _(a) found_something += a;
8421 foreach_udp_proto_field;
8424 if (found_something == 0)
8427 vec_validate (mask, sizeof (*udp) - 1);
8429 udp = (udp_header_t *) mask;
8431 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8432 foreach_udp_proto_field;
8441 u16 src_port, dst_port;
8445 unformat_l4_mask (unformat_input_t * input, va_list * args)
8447 u8 **maskp = va_arg (*args, u8 **);
8448 u16 src_port = 0, dst_port = 0;
8449 tcpudp_header_t *tcpudp;
8451 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8453 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8455 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8457 else if (unformat (input, "src_port"))
8459 else if (unformat (input, "dst_port"))
8465 if (!src_port && !dst_port)
8469 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8471 tcpudp = (tcpudp_header_t *) mask;
8472 tcpudp->src_port = src_port;
8473 tcpudp->dst_port = dst_port;
8481 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8483 u8 **maskp = va_arg (*args, u8 **);
8485 u8 found_something = 0;
8488 #define _(a) u8 a=0;
8489 foreach_ip4_proto_field;
8495 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8497 if (unformat (input, "version"))
8499 else if (unformat (input, "hdr_length"))
8501 else if (unformat (input, "src"))
8503 else if (unformat (input, "dst"))
8505 else if (unformat (input, "proto"))
8508 #define _(a) else if (unformat (input, #a)) a=1;
8509 foreach_ip4_proto_field
8515 #define _(a) found_something += a;
8516 foreach_ip4_proto_field;
8519 if (found_something == 0)
8522 vec_validate (mask, sizeof (*ip) - 1);
8524 ip = (ip4_header_t *) mask;
8526 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8527 foreach_ip4_proto_field;
8530 ip->ip_version_and_header_length = 0;
8533 ip->ip_version_and_header_length |= 0xF0;
8536 ip->ip_version_and_header_length |= 0x0F;
8542 #define foreach_ip6_proto_field \
8550 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8552 u8 **maskp = va_arg (*args, u8 **);
8554 u8 found_something = 0;
8556 u32 ip_version_traffic_class_and_flow_label;
8558 #define _(a) u8 a=0;
8559 foreach_ip6_proto_field;
8562 u8 traffic_class = 0;
8565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8567 if (unformat (input, "version"))
8569 else if (unformat (input, "traffic-class"))
8571 else if (unformat (input, "flow-label"))
8573 else if (unformat (input, "src"))
8575 else if (unformat (input, "dst"))
8577 else if (unformat (input, "proto"))
8580 #define _(a) else if (unformat (input, #a)) a=1;
8581 foreach_ip6_proto_field
8587 #define _(a) found_something += a;
8588 foreach_ip6_proto_field;
8591 if (found_something == 0)
8594 vec_validate (mask, sizeof (*ip) - 1);
8596 ip = (ip6_header_t *) mask;
8598 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8599 foreach_ip6_proto_field;
8602 ip_version_traffic_class_and_flow_label = 0;
8605 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8608 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8611 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8613 ip->ip_version_traffic_class_and_flow_label =
8614 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8621 unformat_l3_mask (unformat_input_t * input, va_list * args)
8623 u8 **maskp = va_arg (*args, u8 **);
8625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8627 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8629 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8638 unformat_l2_mask (unformat_input_t * input, va_list * args)
8640 u8 **maskp = va_arg (*args, u8 **);
8655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8657 if (unformat (input, "src"))
8659 else if (unformat (input, "dst"))
8661 else if (unformat (input, "proto"))
8663 else if (unformat (input, "tag1"))
8665 else if (unformat (input, "tag2"))
8667 else if (unformat (input, "ignore-tag1"))
8669 else if (unformat (input, "ignore-tag2"))
8671 else if (unformat (input, "cos1"))
8673 else if (unformat (input, "cos2"))
8675 else if (unformat (input, "dot1q"))
8677 else if (unformat (input, "dot1ad"))
8682 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8683 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8686 if (tag1 || ignore_tag1 || cos1 || dot1q)
8688 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8691 vec_validate (mask, len - 1);
8694 memset (mask, 0xff, 6);
8697 memset (mask + 6, 0xff, 6);
8701 /* inner vlan tag */
8710 mask[21] = mask[20] = 0xff;
8731 mask[16] = mask[17] = 0xff;
8741 mask[12] = mask[13] = 0xff;
8748 unformat_classify_mask (unformat_input_t * input, va_list * args)
8750 u8 **maskp = va_arg (*args, u8 **);
8751 u32 *skipp = va_arg (*args, u32 *);
8752 u32 *matchp = va_arg (*args, u32 *);
8760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8762 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8764 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8766 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8768 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8782 if (mask || l2 || l3 || l4)
8786 /* "With a free Ethernet header in every package" */
8788 vec_validate (l2, 13);
8792 vec_append (mask, l3);
8797 vec_append (mask, l4);
8802 /* Scan forward looking for the first significant mask octet */
8803 for (i = 0; i < vec_len (mask); i++)
8807 /* compute (skip, match) params */
8808 *skipp = i / sizeof (u32x4);
8809 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8811 /* Pad mask to an even multiple of the vector size */
8812 while (vec_len (mask) % sizeof (u32x4))
8815 match = vec_len (mask) / sizeof (u32x4);
8817 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8819 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8820 if (*tmp || *(tmp + 1))
8825 clib_warning ("BUG: match 0");
8827 _vec_len (mask) = match * sizeof (u32x4);
8838 #define foreach_l2_next \
8840 _(ethernet, ETHERNET_INPUT) \
8845 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8847 u32 *miss_next_indexp = va_arg (*args, u32 *);
8852 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8856 if (unformat (input, "%d", &tmp))
8865 *miss_next_indexp = next_index;
8869 #define foreach_ip_next \
8875 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8877 u32 *miss_next_indexp = va_arg (*args, u32 *);
8882 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8886 if (unformat (input, "%d", &tmp))
8895 *miss_next_indexp = next_index;
8899 #define foreach_acl_next \
8903 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8905 u32 *miss_next_indexp = va_arg (*args, u32 *);
8910 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8914 if (unformat (input, "permit"))
8919 else if (unformat (input, "%d", &tmp))
8928 *miss_next_indexp = next_index;
8933 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8935 u32 *r = va_arg (*args, u32 *);
8937 if (unformat (input, "conform-color"))
8938 *r = POLICE_CONFORM;
8939 else if (unformat (input, "exceed-color"))
8948 api_classify_add_del_table (vat_main_t * vam)
8950 unformat_input_t *i = vam->input;
8951 vl_api_classify_add_del_table_t *mp;
8958 u32 table_index = ~0;
8959 u32 next_table_index = ~0;
8960 u32 miss_next_index = ~0;
8961 u32 memory_size = 32 << 20;
8964 u32 current_data_flag = 0;
8965 int current_data_offset = 0;
8967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8969 if (unformat (i, "del"))
8971 else if (unformat (i, "del-chain"))
8976 else if (unformat (i, "buckets %d", &nbuckets))
8978 else if (unformat (i, "memory_size %d", &memory_size))
8980 else if (unformat (i, "skip %d", &skip))
8982 else if (unformat (i, "match %d", &match))
8984 else if (unformat (i, "table %d", &table_index))
8986 else if (unformat (i, "mask %U", unformat_classify_mask,
8987 &mask, &skip, &match))
8989 else if (unformat (i, "next-table %d", &next_table_index))
8991 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8994 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8997 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9000 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9002 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9008 if (is_add && mask == 0)
9010 errmsg ("Mask required");
9014 if (is_add && skip == ~0)
9016 errmsg ("skip count required");
9020 if (is_add && match == ~0)
9022 errmsg ("match count required");
9026 if (!is_add && table_index == ~0)
9028 errmsg ("table index required for delete");
9032 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
9034 mp->is_add = is_add;
9035 mp->del_chain = del_chain;
9036 mp->table_index = ntohl (table_index);
9037 mp->nbuckets = ntohl (nbuckets);
9038 mp->memory_size = ntohl (memory_size);
9039 mp->skip_n_vectors = ntohl (skip);
9040 mp->match_n_vectors = ntohl (match);
9041 mp->next_table_index = ntohl (next_table_index);
9042 mp->miss_next_index = ntohl (miss_next_index);
9043 mp->current_data_flag = ntohl (current_data_flag);
9044 mp->current_data_offset = ntohl (current_data_offset);
9045 clib_memcpy (mp->mask, mask, vec_len (mask));
9055 unformat_l4_match (unformat_input_t * input, va_list * args)
9057 u8 **matchp = va_arg (*args, u8 **);
9059 u8 *proto_header = 0;
9065 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9067 if (unformat (input, "src_port %d", &src_port))
9069 else if (unformat (input, "dst_port %d", &dst_port))
9075 h.src_port = clib_host_to_net_u16 (src_port);
9076 h.dst_port = clib_host_to_net_u16 (dst_port);
9077 vec_validate (proto_header, sizeof (h) - 1);
9078 memcpy (proto_header, &h, sizeof (h));
9080 *matchp = proto_header;
9086 unformat_ip4_match (unformat_input_t * input, va_list * args)
9088 u8 **matchp = va_arg (*args, u8 **);
9095 int src = 0, dst = 0;
9096 ip4_address_t src_val, dst_val;
9103 int fragment_id = 0;
9104 u32 fragment_id_val;
9110 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9112 if (unformat (input, "version %d", &version_val))
9114 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9116 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9118 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9120 else if (unformat (input, "proto %d", &proto_val))
9122 else if (unformat (input, "tos %d", &tos_val))
9124 else if (unformat (input, "length %d", &length_val))
9126 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9128 else if (unformat (input, "ttl %d", &ttl_val))
9130 else if (unformat (input, "checksum %d", &checksum_val))
9136 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9137 + ttl + checksum == 0)
9141 * Aligned because we use the real comparison functions
9143 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9145 ip = (ip4_header_t *) match;
9147 /* These are realistically matched in practice */
9149 ip->src_address.as_u32 = src_val.as_u32;
9152 ip->dst_address.as_u32 = dst_val.as_u32;
9155 ip->protocol = proto_val;
9158 /* These are not, but they're included for completeness */
9160 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9163 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9169 ip->length = clib_host_to_net_u16 (length_val);
9175 ip->checksum = clib_host_to_net_u16 (checksum_val);
9182 unformat_ip6_match (unformat_input_t * input, va_list * args)
9184 u8 **matchp = va_arg (*args, u8 **);
9189 u8 traffic_class = 0;
9190 u32 traffic_class_val = 0;
9193 int src = 0, dst = 0;
9194 ip6_address_t src_val, dst_val;
9197 int payload_length = 0;
9198 u32 payload_length_val;
9201 u32 ip_version_traffic_class_and_flow_label;
9203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9205 if (unformat (input, "version %d", &version_val))
9207 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9209 else if (unformat (input, "flow_label %d", &flow_label_val))
9211 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9213 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9215 else if (unformat (input, "proto %d", &proto_val))
9217 else if (unformat (input, "payload_length %d", &payload_length_val))
9219 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9225 if (version + traffic_class + flow_label + src + dst + proto +
9226 payload_length + hop_limit == 0)
9230 * Aligned because we use the real comparison functions
9232 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9234 ip = (ip6_header_t *) match;
9237 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9240 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9243 ip->protocol = proto_val;
9245 ip_version_traffic_class_and_flow_label = 0;
9248 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9251 ip_version_traffic_class_and_flow_label |=
9252 (traffic_class_val & 0xFF) << 20;
9255 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9257 ip->ip_version_traffic_class_and_flow_label =
9258 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9261 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9264 ip->hop_limit = hop_limit_val;
9271 unformat_l3_match (unformat_input_t * input, va_list * args)
9273 u8 **matchp = va_arg (*args, u8 **);
9275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9277 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9279 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9288 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9290 u8 *tagp = va_arg (*args, u8 *);
9293 if (unformat (input, "%d", &tag))
9295 tagp[0] = (tag >> 8) & 0x0F;
9296 tagp[1] = tag & 0xFF;
9304 unformat_l2_match (unformat_input_t * input, va_list * args)
9306 u8 **matchp = va_arg (*args, u8 **);
9326 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9328 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9331 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9333 else if (unformat (input, "proto %U",
9334 unformat_ethernet_type_host_byte_order, &proto_val))
9336 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9338 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9340 else if (unformat (input, "ignore-tag1"))
9342 else if (unformat (input, "ignore-tag2"))
9344 else if (unformat (input, "cos1 %d", &cos1_val))
9346 else if (unformat (input, "cos2 %d", &cos2_val))
9351 if ((src + dst + proto + tag1 + tag2 +
9352 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9355 if (tag1 || ignore_tag1 || cos1)
9357 if (tag2 || ignore_tag2 || cos2)
9360 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9363 clib_memcpy (match, dst_val, 6);
9366 clib_memcpy (match + 6, src_val, 6);
9370 /* inner vlan tag */
9371 match[19] = tag2_val[1];
9372 match[18] = tag2_val[0];
9374 match[18] |= (cos2_val & 0x7) << 5;
9377 match[21] = proto_val & 0xff;
9378 match[20] = proto_val >> 8;
9382 match[15] = tag1_val[1];
9383 match[14] = tag1_val[0];
9386 match[14] |= (cos1_val & 0x7) << 5;
9392 match[15] = tag1_val[1];
9393 match[14] = tag1_val[0];
9396 match[17] = proto_val & 0xff;
9397 match[16] = proto_val >> 8;
9400 match[14] |= (cos1_val & 0x7) << 5;
9406 match[18] |= (cos2_val & 0x7) << 5;
9408 match[14] |= (cos1_val & 0x7) << 5;
9411 match[13] = proto_val & 0xff;
9412 match[12] = proto_val >> 8;
9421 unformat_classify_match (unformat_input_t * input, va_list * args)
9423 u8 **matchp = va_arg (*args, u8 **);
9424 u32 skip_n_vectors = va_arg (*args, u32);
9425 u32 match_n_vectors = va_arg (*args, u32);
9432 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9434 if (unformat (input, "hex %U", unformat_hex_string, &match))
9436 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9438 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9440 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9454 if (match || l2 || l3 || l4)
9458 /* "Win a free Ethernet header in every packet" */
9460 vec_validate_aligned (l2, 13, sizeof (u32x4));
9464 vec_append_aligned (match, l3, sizeof (u32x4));
9469 vec_append_aligned (match, l4, sizeof (u32x4));
9474 /* Make sure the vector is big enough even if key is all 0's */
9475 vec_validate_aligned
9476 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9479 /* Set size, include skipped vectors */
9480 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9491 api_classify_add_del_session (vat_main_t * vam)
9493 unformat_input_t *i = vam->input;
9494 vl_api_classify_add_del_session_t *mp;
9496 u32 table_index = ~0;
9497 u32 hit_next_index = ~0;
9498 u32 opaque_index = ~0;
9502 u32 skip_n_vectors = 0;
9503 u32 match_n_vectors = 0;
9508 * Warning: you have to supply skip_n and match_n
9509 * because the API client cant simply look at the classify
9513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9515 if (unformat (i, "del"))
9517 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9520 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9523 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9526 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9528 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9530 else if (unformat (i, "opaque-index %d", &opaque_index))
9532 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9534 else if (unformat (i, "match_n %d", &match_n_vectors))
9536 else if (unformat (i, "match %U", unformat_classify_match,
9537 &match, skip_n_vectors, match_n_vectors))
9539 else if (unformat (i, "advance %d", &advance))
9541 else if (unformat (i, "table-index %d", &table_index))
9543 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9545 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9547 else if (unformat (i, "action %d", &action))
9549 else if (unformat (i, "metadata %d", &metadata))
9555 if (table_index == ~0)
9557 errmsg ("Table index required");
9561 if (is_add && match == 0)
9563 errmsg ("Match value required");
9567 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9569 mp->is_add = is_add;
9570 mp->table_index = ntohl (table_index);
9571 mp->hit_next_index = ntohl (hit_next_index);
9572 mp->opaque_index = ntohl (opaque_index);
9573 mp->advance = ntohl (advance);
9574 mp->action = action;
9575 mp->metadata = ntohl (metadata);
9576 clib_memcpy (mp->match, match, vec_len (match));
9585 api_classify_set_interface_ip_table (vat_main_t * vam)
9587 unformat_input_t *i = vam->input;
9588 vl_api_classify_set_interface_ip_table_t *mp;
9591 int sw_if_index_set;
9592 u32 table_index = ~0;
9595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9597 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9598 sw_if_index_set = 1;
9599 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9600 sw_if_index_set = 1;
9601 else if (unformat (i, "table %d", &table_index))
9605 clib_warning ("parse error '%U'", format_unformat_error, i);
9610 if (sw_if_index_set == 0)
9612 errmsg ("missing interface name or sw_if_index");
9617 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9619 mp->sw_if_index = ntohl (sw_if_index);
9620 mp->table_index = ntohl (table_index);
9621 mp->is_ipv6 = is_ipv6;
9630 api_classify_set_interface_l2_tables (vat_main_t * vam)
9632 unformat_input_t *i = vam->input;
9633 vl_api_classify_set_interface_l2_tables_t *mp;
9636 int sw_if_index_set;
9637 u32 ip4_table_index = ~0;
9638 u32 ip6_table_index = ~0;
9639 u32 other_table_index = ~0;
9642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9645 sw_if_index_set = 1;
9646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9647 sw_if_index_set = 1;
9648 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9650 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9652 else if (unformat (i, "other-table %d", &other_table_index))
9654 else if (unformat (i, "is-input %d", &is_input))
9658 clib_warning ("parse error '%U'", format_unformat_error, i);
9663 if (sw_if_index_set == 0)
9665 errmsg ("missing interface name or sw_if_index");
9670 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9672 mp->sw_if_index = ntohl (sw_if_index);
9673 mp->ip4_table_index = ntohl (ip4_table_index);
9674 mp->ip6_table_index = ntohl (ip6_table_index);
9675 mp->other_table_index = ntohl (other_table_index);
9676 mp->is_input = (u8) is_input;
9685 api_set_ipfix_exporter (vat_main_t * vam)
9687 unformat_input_t *i = vam->input;
9688 vl_api_set_ipfix_exporter_t *mp;
9689 ip4_address_t collector_address;
9690 u8 collector_address_set = 0;
9691 u32 collector_port = ~0;
9692 ip4_address_t src_address;
9693 u8 src_address_set = 0;
9696 u32 template_interval = ~0;
9697 u8 udp_checksum = 0;
9700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9702 if (unformat (i, "collector_address %U", unformat_ip4_address,
9703 &collector_address))
9704 collector_address_set = 1;
9705 else if (unformat (i, "collector_port %d", &collector_port))
9707 else if (unformat (i, "src_address %U", unformat_ip4_address,
9709 src_address_set = 1;
9710 else if (unformat (i, "vrf_id %d", &vrf_id))
9712 else if (unformat (i, "path_mtu %d", &path_mtu))
9714 else if (unformat (i, "template_interval %d", &template_interval))
9716 else if (unformat (i, "udp_checksum"))
9722 if (collector_address_set == 0)
9724 errmsg ("collector_address required");
9728 if (src_address_set == 0)
9730 errmsg ("src_address required");
9734 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9736 memcpy (mp->collector_address, collector_address.data,
9737 sizeof (collector_address.data));
9738 mp->collector_port = htons ((u16) collector_port);
9739 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9740 mp->vrf_id = htonl (vrf_id);
9741 mp->path_mtu = htonl (path_mtu);
9742 mp->template_interval = htonl (template_interval);
9743 mp->udp_checksum = udp_checksum;
9751 api_set_ipfix_classify_stream (vat_main_t * vam)
9753 unformat_input_t *i = vam->input;
9754 vl_api_set_ipfix_classify_stream_t *mp;
9756 u32 src_port = UDP_DST_PORT_ipfix;
9759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9761 if (unformat (i, "domain %d", &domain_id))
9763 else if (unformat (i, "src_port %d", &src_port))
9767 errmsg ("unknown input `%U'", format_unformat_error, i);
9772 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9774 mp->domain_id = htonl (domain_id);
9775 mp->src_port = htons ((u16) src_port);
9783 api_ipfix_classify_table_add_del (vat_main_t * vam)
9785 unformat_input_t *i = vam->input;
9786 vl_api_ipfix_classify_table_add_del_t *mp;
9788 u32 classify_table_index = ~0;
9790 u8 transport_protocol = 255;
9793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9795 if (unformat (i, "add"))
9797 else if (unformat (i, "del"))
9799 else if (unformat (i, "table %d", &classify_table_index))
9801 else if (unformat (i, "ip4"))
9803 else if (unformat (i, "ip6"))
9805 else if (unformat (i, "tcp"))
9806 transport_protocol = 6;
9807 else if (unformat (i, "udp"))
9808 transport_protocol = 17;
9811 errmsg ("unknown input `%U'", format_unformat_error, i);
9818 errmsg ("expecting: add|del");
9821 if (classify_table_index == ~0)
9823 errmsg ("classifier table not specified");
9826 if (ip_version == 0)
9828 errmsg ("IP version not specified");
9832 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9834 mp->is_add = is_add;
9835 mp->table_id = htonl (classify_table_index);
9836 mp->ip_version = ip_version;
9837 mp->transport_protocol = transport_protocol;
9845 api_get_node_index (vat_main_t * vam)
9847 unformat_input_t *i = vam->input;
9848 vl_api_get_node_index_t *mp;
9852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9854 if (unformat (i, "node %s", &name))
9861 errmsg ("node name required");
9864 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9866 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9870 M (GET_NODE_INDEX, get_node_index);
9871 clib_memcpy (mp->node_name, name, vec_len (name));
9881 api_get_next_index (vat_main_t * vam)
9883 unformat_input_t *i = vam->input;
9884 vl_api_get_next_index_t *mp;
9886 u8 *node_name = 0, *next_node_name = 0;
9888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9890 if (unformat (i, "node-name %s", &node_name))
9892 else if (unformat (i, "next-node-name %s", &next_node_name))
9898 errmsg ("node name required");
9901 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9903 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9907 if (next_node_name == 0)
9909 errmsg ("next node name required");
9912 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9914 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9918 M (GET_NEXT_INDEX, get_next_index);
9919 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9920 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9921 vec_free (node_name);
9922 vec_free (next_node_name);
9931 api_add_node_next (vat_main_t * vam)
9933 unformat_input_t *i = vam->input;
9934 vl_api_add_node_next_t *mp;
9939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9941 if (unformat (i, "node %s", &name))
9943 else if (unformat (i, "next %s", &next))
9950 errmsg ("node name required");
9953 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9955 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9960 errmsg ("next node required");
9963 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9965 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9969 M (ADD_NODE_NEXT, add_node_next);
9970 clib_memcpy (mp->node_name, name, vec_len (name));
9971 clib_memcpy (mp->next_name, next, vec_len (next));
9982 api_l2tpv3_create_tunnel (vat_main_t * vam)
9984 unformat_input_t *i = vam->input;
9985 ip6_address_t client_address, our_address;
9986 int client_address_set = 0;
9987 int our_address_set = 0;
9988 u32 local_session_id = 0;
9989 u32 remote_session_id = 0;
9990 u64 local_cookie = 0;
9991 u64 remote_cookie = 0;
9992 u8 l2_sublayer_present = 0;
9993 vl_api_l2tpv3_create_tunnel_t *mp;
9996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9998 if (unformat (i, "client_address %U", unformat_ip6_address,
10000 client_address_set = 1;
10001 else if (unformat (i, "our_address %U", unformat_ip6_address,
10003 our_address_set = 1;
10004 else if (unformat (i, "local_session_id %d", &local_session_id))
10006 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10008 else if (unformat (i, "local_cookie %lld", &local_cookie))
10010 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10012 else if (unformat (i, "l2-sublayer-present"))
10013 l2_sublayer_present = 1;
10018 if (client_address_set == 0)
10020 errmsg ("client_address required");
10024 if (our_address_set == 0)
10026 errmsg ("our_address required");
10030 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
10032 clib_memcpy (mp->client_address, client_address.as_u8,
10033 sizeof (mp->client_address));
10035 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10037 mp->local_session_id = ntohl (local_session_id);
10038 mp->remote_session_id = ntohl (remote_session_id);
10039 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10040 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10041 mp->l2_sublayer_present = l2_sublayer_present;
10051 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10053 unformat_input_t *i = vam->input;
10055 u8 sw_if_index_set = 0;
10056 u64 new_local_cookie = 0;
10057 u64 new_remote_cookie = 0;
10058 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10063 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10064 sw_if_index_set = 1;
10065 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10066 sw_if_index_set = 1;
10067 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10069 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10075 if (sw_if_index_set == 0)
10077 errmsg ("missing interface name or sw_if_index");
10081 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
10083 mp->sw_if_index = ntohl (sw_if_index);
10084 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10085 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10094 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10096 unformat_input_t *i = vam->input;
10097 vl_api_l2tpv3_interface_enable_disable_t *mp;
10100 u8 sw_if_index_set = 0;
10101 u8 enable_disable = 1;
10103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10106 sw_if_index_set = 1;
10107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10108 sw_if_index_set = 1;
10109 else if (unformat (i, "enable"))
10110 enable_disable = 1;
10111 else if (unformat (i, "disable"))
10112 enable_disable = 0;
10117 if (sw_if_index_set == 0)
10119 errmsg ("missing interface name or sw_if_index");
10123 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10125 mp->sw_if_index = ntohl (sw_if_index);
10126 mp->enable_disable = enable_disable;
10135 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10137 unformat_input_t *i = vam->input;
10138 vl_api_l2tpv3_set_lookup_key_t *mp;
10142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10144 if (unformat (i, "lookup_v6_src"))
10145 key = L2T_LOOKUP_SRC_ADDRESS;
10146 else if (unformat (i, "lookup_v6_dst"))
10147 key = L2T_LOOKUP_DST_ADDRESS;
10148 else if (unformat (i, "lookup_session_id"))
10149 key = L2T_LOOKUP_SESSION_ID;
10154 if (key == (u8) ~ 0)
10156 errmsg ("l2tp session lookup key unset");
10160 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10170 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10171 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10173 vat_main_t *vam = &vat_main;
10175 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10176 format_ip6_address, mp->our_address,
10177 format_ip6_address, mp->client_address,
10178 clib_net_to_host_u32 (mp->sw_if_index));
10181 " local cookies %016llx %016llx remote cookie %016llx",
10182 clib_net_to_host_u64 (mp->local_cookie[0]),
10183 clib_net_to_host_u64 (mp->local_cookie[1]),
10184 clib_net_to_host_u64 (mp->remote_cookie));
10186 print (vam->ofp, " local session-id %d remote session-id %d",
10187 clib_net_to_host_u32 (mp->local_session_id),
10188 clib_net_to_host_u32 (mp->remote_session_id));
10190 print (vam->ofp, " l2 specific sublayer %s\n",
10191 mp->l2_sublayer_present ? "preset" : "absent");
10195 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10196 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10198 vat_main_t *vam = &vat_main;
10199 vat_json_node_t *node = NULL;
10200 struct in6_addr addr;
10202 if (VAT_JSON_ARRAY != vam->json_tree.type)
10204 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10205 vat_json_init_array (&vam->json_tree);
10207 node = vat_json_array_add (&vam->json_tree);
10209 vat_json_init_object (node);
10211 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10212 vat_json_object_add_ip6 (node, "our_address", addr);
10213 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10214 vat_json_object_add_ip6 (node, "client_address", addr);
10216 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10217 vat_json_init_array (lc);
10218 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10219 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10220 vat_json_object_add_uint (node, "remote_cookie",
10221 clib_net_to_host_u64 (mp->remote_cookie));
10223 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10224 vat_json_object_add_uint (node, "local_session_id",
10225 clib_net_to_host_u32 (mp->local_session_id));
10226 vat_json_object_add_uint (node, "remote_session_id",
10227 clib_net_to_host_u32 (mp->remote_session_id));
10228 vat_json_object_add_string_copy (node, "l2_sublayer",
10229 mp->l2_sublayer_present ? (u8 *) "present"
10230 : (u8 *) "absent");
10234 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10236 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10239 /* Get list of l2tpv3-tunnel interfaces */
10240 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10243 /* Use a control ping for synchronization */
10245 vl_api_control_ping_t *mp;
10246 M (CONTROL_PING, control_ping);
10253 static void vl_api_sw_interface_tap_details_t_handler
10254 (vl_api_sw_interface_tap_details_t * mp)
10256 vat_main_t *vam = &vat_main;
10258 print (vam->ofp, "%-16s %d",
10259 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10262 static void vl_api_sw_interface_tap_details_t_handler_json
10263 (vl_api_sw_interface_tap_details_t * mp)
10265 vat_main_t *vam = &vat_main;
10266 vat_json_node_t *node = NULL;
10268 if (VAT_JSON_ARRAY != vam->json_tree.type)
10270 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10271 vat_json_init_array (&vam->json_tree);
10273 node = vat_json_array_add (&vam->json_tree);
10275 vat_json_init_object (node);
10276 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10277 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10281 api_sw_interface_tap_dump (vat_main_t * vam)
10283 vl_api_sw_interface_tap_dump_t *mp;
10286 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10287 /* Get list of tap interfaces */
10288 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10291 /* Use a control ping for synchronization */
10293 vl_api_control_ping_t *mp;
10294 M (CONTROL_PING, control_ping);
10300 static uword unformat_vxlan_decap_next
10301 (unformat_input_t * input, va_list * args)
10303 u32 *result = va_arg (*args, u32 *);
10306 if (unformat (input, "l2"))
10307 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10308 else if (unformat (input, "%d", &tmp))
10316 api_vxlan_add_del_tunnel (vat_main_t * vam)
10318 unformat_input_t *line_input = vam->input;
10319 vl_api_vxlan_add_del_tunnel_t *mp;
10321 ip46_address_t src, dst;
10323 u8 ipv4_set = 0, ipv6_set = 0;
10327 u32 mcast_sw_if_index = ~0;
10328 u32 encap_vrf_id = 0;
10329 u32 decap_next_index = ~0;
10332 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10333 memset (&src, 0, sizeof src);
10334 memset (&dst, 0, sizeof dst);
10336 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10338 if (unformat (line_input, "del"))
10341 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10347 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10353 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10359 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10364 else if (unformat (line_input, "group %U %U",
10365 unformat_ip4_address, &dst.ip4,
10366 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10368 grp_set = dst_set = 1;
10371 else if (unformat (line_input, "group %U",
10372 unformat_ip4_address, &dst.ip4))
10374 grp_set = dst_set = 1;
10377 else if (unformat (line_input, "group %U %U",
10378 unformat_ip6_address, &dst.ip6,
10379 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10381 grp_set = dst_set = 1;
10384 else if (unformat (line_input, "group %U",
10385 unformat_ip6_address, &dst.ip6))
10387 grp_set = dst_set = 1;
10391 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10393 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10395 else if (unformat (line_input, "decap-next %U",
10396 unformat_vxlan_decap_next, &decap_next_index))
10398 else if (unformat (line_input, "vni %d", &vni))
10402 errmsg ("parse error '%U'", format_unformat_error, line_input);
10409 errmsg ("tunnel src address not specified");
10414 errmsg ("tunnel dst address not specified");
10418 if (grp_set && !ip46_address_is_multicast (&dst))
10420 errmsg ("tunnel group address not multicast");
10423 if (grp_set && mcast_sw_if_index == ~0)
10425 errmsg ("tunnel nonexistent multicast device");
10428 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10430 errmsg ("tunnel dst address must be unicast");
10435 if (ipv4_set && ipv6_set)
10437 errmsg ("both IPv4 and IPv6 addresses specified");
10441 if ((vni == 0) || (vni >> 24))
10443 errmsg ("vni not specified or out of range");
10447 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10451 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10452 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10456 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10457 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10459 mp->encap_vrf_id = ntohl (encap_vrf_id);
10460 mp->decap_next_index = ntohl (decap_next_index);
10461 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10462 mp->vni = ntohl (vni);
10463 mp->is_add = is_add;
10464 mp->is_ipv6 = ipv6_set;
10472 static void vl_api_vxlan_tunnel_details_t_handler
10473 (vl_api_vxlan_tunnel_details_t * mp)
10475 vat_main_t *vam = &vat_main;
10476 ip46_address_t src, dst;
10478 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10479 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10481 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10482 ntohl (mp->sw_if_index),
10483 format_ip46_address, &src, IP46_TYPE_ANY,
10484 format_ip46_address, &dst, IP46_TYPE_ANY,
10485 ntohl (mp->encap_vrf_id),
10486 ntohl (mp->decap_next_index), ntohl (mp->vni),
10487 ntohl (mp->mcast_sw_if_index));
10490 static void vl_api_vxlan_tunnel_details_t_handler_json
10491 (vl_api_vxlan_tunnel_details_t * mp)
10493 vat_main_t *vam = &vat_main;
10494 vat_json_node_t *node = NULL;
10496 if (VAT_JSON_ARRAY != vam->json_tree.type)
10498 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10499 vat_json_init_array (&vam->json_tree);
10501 node = vat_json_array_add (&vam->json_tree);
10503 vat_json_init_object (node);
10504 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10507 struct in6_addr ip6;
10509 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10510 vat_json_object_add_ip6 (node, "src_address", ip6);
10511 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10512 vat_json_object_add_ip6 (node, "dst_address", ip6);
10516 struct in_addr ip4;
10518 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10519 vat_json_object_add_ip4 (node, "src_address", ip4);
10520 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10521 vat_json_object_add_ip4 (node, "dst_address", ip4);
10523 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10524 vat_json_object_add_uint (node, "decap_next_index",
10525 ntohl (mp->decap_next_index));
10526 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10527 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10528 vat_json_object_add_uint (node, "mcast_sw_if_index",
10529 ntohl (mp->mcast_sw_if_index));
10533 api_vxlan_tunnel_dump (vat_main_t * vam)
10535 unformat_input_t *i = vam->input;
10536 vl_api_vxlan_tunnel_dump_t *mp;
10539 u8 sw_if_index_set = 0;
10541 /* Parse args required to build the message */
10542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10544 if (unformat (i, "sw_if_index %d", &sw_if_index))
10545 sw_if_index_set = 1;
10550 if (sw_if_index_set == 0)
10555 if (!vam->json_output)
10557 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10558 "sw_if_index", "src_address", "dst_address",
10559 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10562 /* Get list of vxlan-tunnel interfaces */
10563 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10565 mp->sw_if_index = htonl (sw_if_index);
10569 /* Use a control ping for synchronization */
10571 vl_api_control_ping_t *mp;
10572 M (CONTROL_PING, control_ping);
10579 api_gre_add_del_tunnel (vat_main_t * vam)
10581 unformat_input_t *line_input = vam->input;
10582 vl_api_gre_add_del_tunnel_t *mp;
10584 ip4_address_t src4, dst4;
10589 u32 outer_fib_id = 0;
10591 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10593 if (unformat (line_input, "del"))
10595 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10597 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10599 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10601 else if (unformat (line_input, "teb"))
10605 errmsg ("parse error '%U'", format_unformat_error, line_input);
10612 errmsg ("tunnel src address not specified");
10617 errmsg ("tunnel dst address not specified");
10622 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10624 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10625 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10626 mp->outer_fib_id = ntohl (outer_fib_id);
10627 mp->is_add = is_add;
10636 static void vl_api_gre_tunnel_details_t_handler
10637 (vl_api_gre_tunnel_details_t * mp)
10639 vat_main_t *vam = &vat_main;
10641 print (vam->ofp, "%11d%15U%15U%6d%14d",
10642 ntohl (mp->sw_if_index),
10643 format_ip4_address, &mp->src_address,
10644 format_ip4_address, &mp->dst_address,
10645 mp->teb, ntohl (mp->outer_fib_id));
10648 static void vl_api_gre_tunnel_details_t_handler_json
10649 (vl_api_gre_tunnel_details_t * mp)
10651 vat_main_t *vam = &vat_main;
10652 vat_json_node_t *node = NULL;
10653 struct in_addr ip4;
10655 if (VAT_JSON_ARRAY != vam->json_tree.type)
10657 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10658 vat_json_init_array (&vam->json_tree);
10660 node = vat_json_array_add (&vam->json_tree);
10662 vat_json_init_object (node);
10663 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10664 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10665 vat_json_object_add_ip4 (node, "src_address", ip4);
10666 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10667 vat_json_object_add_ip4 (node, "dst_address", ip4);
10668 vat_json_object_add_uint (node, "teb", mp->teb);
10669 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10673 api_gre_tunnel_dump (vat_main_t * vam)
10675 unformat_input_t *i = vam->input;
10676 vl_api_gre_tunnel_dump_t *mp;
10679 u8 sw_if_index_set = 0;
10681 /* Parse args required to build the message */
10682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10684 if (unformat (i, "sw_if_index %d", &sw_if_index))
10685 sw_if_index_set = 1;
10690 if (sw_if_index_set == 0)
10695 if (!vam->json_output)
10697 print (vam->ofp, "%11s%15s%15s%6s%14s",
10698 "sw_if_index", "src_address", "dst_address", "teb",
10702 /* Get list of gre-tunnel interfaces */
10703 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10705 mp->sw_if_index = htonl (sw_if_index);
10709 /* Use a control ping for synchronization */
10711 vl_api_control_ping_t *mp;
10712 M (CONTROL_PING, control_ping);
10719 api_l2_fib_clear_table (vat_main_t * vam)
10721 // unformat_input_t * i = vam->input;
10722 vl_api_l2_fib_clear_table_t *mp;
10725 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10734 api_l2_interface_efp_filter (vat_main_t * vam)
10736 unformat_input_t *i = vam->input;
10737 vl_api_l2_interface_efp_filter_t *mp;
10741 u8 sw_if_index_set = 0;
10743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10746 sw_if_index_set = 1;
10747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10748 sw_if_index_set = 1;
10749 else if (unformat (i, "enable"))
10751 else if (unformat (i, "disable"))
10755 clib_warning ("parse error '%U'", format_unformat_error, i);
10760 if (sw_if_index_set == 0)
10762 errmsg ("missing sw_if_index");
10766 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10768 mp->sw_if_index = ntohl (sw_if_index);
10769 mp->enable_disable = enable;
10777 #define foreach_vtr_op \
10778 _("disable", L2_VTR_DISABLED) \
10779 _("push-1", L2_VTR_PUSH_1) \
10780 _("push-2", L2_VTR_PUSH_2) \
10781 _("pop-1", L2_VTR_POP_1) \
10782 _("pop-2", L2_VTR_POP_2) \
10783 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10784 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10785 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10786 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10789 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10791 unformat_input_t *i = vam->input;
10792 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10795 u8 sw_if_index_set = 0;
10798 u32 push_dot1q = 1;
10802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10805 sw_if_index_set = 1;
10806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10807 sw_if_index_set = 1;
10808 else if (unformat (i, "vtr_op %d", &vtr_op))
10810 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10813 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10815 else if (unformat (i, "tag1 %d", &tag1))
10817 else if (unformat (i, "tag2 %d", &tag2))
10821 clib_warning ("parse error '%U'", format_unformat_error, i);
10826 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10828 errmsg ("missing vtr operation or sw_if_index");
10832 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10833 mp->sw_if_index = ntohl (sw_if_index);
10834 mp->vtr_op = ntohl (vtr_op);
10835 mp->push_dot1q = ntohl (push_dot1q);
10836 mp->tag1 = ntohl (tag1);
10837 mp->tag2 = ntohl (tag2);
10846 api_create_vhost_user_if (vat_main_t * vam)
10848 unformat_input_t *i = vam->input;
10849 vl_api_create_vhost_user_if_t *mp;
10853 u8 file_name_set = 0;
10854 u32 custom_dev_instance = ~0;
10856 u8 use_custom_mac = 0;
10859 /* Shut up coverity */
10860 memset (hwaddr, 0, sizeof (hwaddr));
10862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10864 if (unformat (i, "socket %s", &file_name))
10868 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10870 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10871 use_custom_mac = 1;
10872 else if (unformat (i, "server"))
10874 else if (unformat (i, "tag %s", &tag))
10880 if (file_name_set == 0)
10882 errmsg ("missing socket file name");
10886 if (vec_len (file_name) > 255)
10888 errmsg ("socket file name too long");
10891 vec_add1 (file_name, 0);
10893 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10895 mp->is_server = is_server;
10896 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10897 vec_free (file_name);
10898 if (custom_dev_instance != ~0)
10901 mp->custom_dev_instance = ntohl (custom_dev_instance);
10903 mp->use_custom_mac = use_custom_mac;
10904 clib_memcpy (mp->mac_address, hwaddr, 6);
10906 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10916 api_modify_vhost_user_if (vat_main_t * vam)
10918 unformat_input_t *i = vam->input;
10919 vl_api_modify_vhost_user_if_t *mp;
10923 u8 file_name_set = 0;
10924 u32 custom_dev_instance = ~0;
10925 u8 sw_if_index_set = 0;
10926 u32 sw_if_index = (u32) ~ 0;
10928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10930 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10931 sw_if_index_set = 1;
10932 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10933 sw_if_index_set = 1;
10934 else if (unformat (i, "socket %s", &file_name))
10938 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10940 else if (unformat (i, "server"))
10946 if (sw_if_index_set == 0)
10948 errmsg ("missing sw_if_index or interface name");
10952 if (file_name_set == 0)
10954 errmsg ("missing socket file name");
10958 if (vec_len (file_name) > 255)
10960 errmsg ("socket file name too long");
10963 vec_add1 (file_name, 0);
10965 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10967 mp->sw_if_index = ntohl (sw_if_index);
10968 mp->is_server = is_server;
10969 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10970 vec_free (file_name);
10971 if (custom_dev_instance != ~0)
10974 mp->custom_dev_instance = ntohl (custom_dev_instance);
10984 api_delete_vhost_user_if (vat_main_t * vam)
10986 unformat_input_t *i = vam->input;
10987 vl_api_delete_vhost_user_if_t *mp;
10989 u32 sw_if_index = ~0;
10990 u8 sw_if_index_set = 0;
10992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10995 sw_if_index_set = 1;
10996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10997 sw_if_index_set = 1;
11002 if (sw_if_index_set == 0)
11004 errmsg ("missing sw_if_index or interface name");
11009 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
11011 mp->sw_if_index = ntohl (sw_if_index);
11019 static void vl_api_sw_interface_vhost_user_details_t_handler
11020 (vl_api_sw_interface_vhost_user_details_t * mp)
11022 vat_main_t *vam = &vat_main;
11024 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11025 (char *) mp->interface_name,
11026 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11027 clib_net_to_host_u64 (mp->features), mp->is_server,
11028 ntohl (mp->num_regions), (char *) mp->sock_filename);
11029 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11032 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11033 (vl_api_sw_interface_vhost_user_details_t * mp)
11035 vat_main_t *vam = &vat_main;
11036 vat_json_node_t *node = NULL;
11038 if (VAT_JSON_ARRAY != vam->json_tree.type)
11040 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11041 vat_json_init_array (&vam->json_tree);
11043 node = vat_json_array_add (&vam->json_tree);
11045 vat_json_init_object (node);
11046 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11047 vat_json_object_add_string_copy (node, "interface_name",
11048 mp->interface_name);
11049 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11050 ntohl (mp->virtio_net_hdr_sz));
11051 vat_json_object_add_uint (node, "features",
11052 clib_net_to_host_u64 (mp->features));
11053 vat_json_object_add_uint (node, "is_server", mp->is_server);
11054 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11055 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11056 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11060 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11062 vl_api_sw_interface_vhost_user_dump_t *mp;
11065 "Interface name idx hdr_sz features server regions filename");
11067 /* Get list of vhost-user interfaces */
11068 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
11071 /* Use a control ping for synchronization */
11073 vl_api_control_ping_t *mp;
11074 M (CONTROL_PING, control_ping);
11081 api_show_version (vat_main_t * vam)
11083 vl_api_show_version_t *mp;
11086 M (SHOW_VERSION, show_version);
11096 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11098 unformat_input_t *line_input = vam->input;
11099 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11101 ip4_address_t local4, remote4;
11102 ip6_address_t local6, remote6;
11104 u8 ipv4_set = 0, ipv6_set = 0;
11107 u32 encap_vrf_id = 0;
11108 u32 decap_vrf_id = 0;
11113 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11115 if (unformat (line_input, "del"))
11117 else if (unformat (line_input, "local %U",
11118 unformat_ip4_address, &local4))
11123 else if (unformat (line_input, "remote %U",
11124 unformat_ip4_address, &remote4))
11129 else if (unformat (line_input, "local %U",
11130 unformat_ip6_address, &local6))
11135 else if (unformat (line_input, "remote %U",
11136 unformat_ip6_address, &remote6))
11141 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11143 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11145 else if (unformat (line_input, "vni %d", &vni))
11147 else if (unformat (line_input, "next-ip4"))
11149 else if (unformat (line_input, "next-ip6"))
11151 else if (unformat (line_input, "next-ethernet"))
11153 else if (unformat (line_input, "next-nsh"))
11157 errmsg ("parse error '%U'", format_unformat_error, line_input);
11162 if (local_set == 0)
11164 errmsg ("tunnel local address not specified");
11167 if (remote_set == 0)
11169 errmsg ("tunnel remote address not specified");
11172 if (ipv4_set && ipv6_set)
11174 errmsg ("both IPv4 and IPv6 addresses specified");
11180 errmsg ("vni not specified");
11184 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11189 clib_memcpy (&mp->local, &local6, sizeof (local6));
11190 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11194 clib_memcpy (&mp->local, &local4, sizeof (local4));
11195 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11198 mp->encap_vrf_id = ntohl (encap_vrf_id);
11199 mp->decap_vrf_id = ntohl (decap_vrf_id);
11200 mp->protocol = protocol;
11201 mp->vni = ntohl (vni);
11202 mp->is_add = is_add;
11203 mp->is_ipv6 = ipv6_set;
11211 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11212 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11214 vat_main_t *vam = &vat_main;
11216 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11217 ntohl (mp->sw_if_index),
11218 format_ip46_address, &(mp->local[0]),
11219 format_ip46_address, &(mp->remote[0]),
11221 ntohl (mp->protocol),
11222 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11225 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11226 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11228 vat_main_t *vam = &vat_main;
11229 vat_json_node_t *node = NULL;
11230 struct in_addr ip4;
11231 struct in6_addr ip6;
11233 if (VAT_JSON_ARRAY != vam->json_tree.type)
11235 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11236 vat_json_init_array (&vam->json_tree);
11238 node = vat_json_array_add (&vam->json_tree);
11240 vat_json_init_object (node);
11241 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11244 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11245 vat_json_object_add_ip6 (node, "local", ip6);
11246 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11247 vat_json_object_add_ip6 (node, "remote", ip6);
11251 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11252 vat_json_object_add_ip4 (node, "local", ip4);
11253 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11254 vat_json_object_add_ip4 (node, "remote", ip4);
11256 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11257 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11258 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11259 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11260 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11264 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11266 unformat_input_t *i = vam->input;
11267 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11270 u8 sw_if_index_set = 0;
11272 /* Parse args required to build the message */
11273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11275 if (unformat (i, "sw_if_index %d", &sw_if_index))
11276 sw_if_index_set = 1;
11281 if (sw_if_index_set == 0)
11286 if (!vam->json_output)
11288 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11289 "sw_if_index", "local", "remote", "vni",
11290 "protocol", "encap_vrf_id", "decap_vrf_id");
11293 /* Get list of vxlan-tunnel interfaces */
11294 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11296 mp->sw_if_index = htonl (sw_if_index);
11300 /* Use a control ping for synchronization */
11302 vl_api_control_ping_t *mp;
11303 M (CONTROL_PING, control_ping);
11310 format_l2_fib_mac_address (u8 * s, va_list * args)
11312 u8 *a = va_arg (*args, u8 *);
11314 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11315 a[2], a[3], a[4], a[5], a[6], a[7]);
11318 static void vl_api_l2_fib_table_entry_t_handler
11319 (vl_api_l2_fib_table_entry_t * mp)
11321 vat_main_t *vam = &vat_main;
11323 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11325 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11326 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11330 static void vl_api_l2_fib_table_entry_t_handler_json
11331 (vl_api_l2_fib_table_entry_t * mp)
11333 vat_main_t *vam = &vat_main;
11334 vat_json_node_t *node = NULL;
11336 if (VAT_JSON_ARRAY != vam->json_tree.type)
11338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11339 vat_json_init_array (&vam->json_tree);
11341 node = vat_json_array_add (&vam->json_tree);
11343 vat_json_init_object (node);
11344 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11345 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11346 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11347 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11348 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11349 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11353 api_l2_fib_table_dump (vat_main_t * vam)
11355 unformat_input_t *i = vam->input;
11356 vl_api_l2_fib_table_dump_t *mp;
11361 /* Parse args required to build the message */
11362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11364 if (unformat (i, "bd_id %d", &bd_id))
11370 if (bd_id_set == 0)
11372 errmsg ("missing bridge domain");
11376 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11378 /* Get list of l2 fib entries */
11379 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11381 mp->bd_id = ntohl (bd_id);
11384 /* Use a control ping for synchronization */
11386 vl_api_control_ping_t *mp;
11387 M (CONTROL_PING, control_ping);
11395 api_interface_name_renumber (vat_main_t * vam)
11397 unformat_input_t *line_input = vam->input;
11398 vl_api_interface_name_renumber_t *mp;
11399 u32 sw_if_index = ~0;
11401 u32 new_show_dev_instance = ~0;
11403 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11405 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11408 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11410 else if (unformat (line_input, "new_show_dev_instance %d",
11411 &new_show_dev_instance))
11417 if (sw_if_index == ~0)
11419 errmsg ("missing interface name or sw_if_index");
11423 if (new_show_dev_instance == ~0)
11425 errmsg ("missing new_show_dev_instance");
11429 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11431 mp->sw_if_index = ntohl (sw_if_index);
11432 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11439 api_want_ip4_arp_events (vat_main_t * vam)
11441 unformat_input_t *line_input = vam->input;
11442 vl_api_want_ip4_arp_events_t *mp;
11444 ip4_address_t address;
11445 int address_set = 0;
11446 u32 enable_disable = 1;
11448 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11450 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11452 else if (unformat (line_input, "del"))
11453 enable_disable = 0;
11458 if (address_set == 0)
11460 errmsg ("missing addresses");
11464 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11465 mp->enable_disable = enable_disable;
11466 mp->pid = getpid ();
11467 mp->address = address.as_u32;
11474 api_want_ip6_nd_events (vat_main_t * vam)
11476 unformat_input_t *line_input = vam->input;
11477 vl_api_want_ip6_nd_events_t *mp;
11479 ip6_address_t address;
11480 int address_set = 0;
11481 u32 enable_disable = 1;
11483 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11487 else if (unformat (line_input, "del"))
11488 enable_disable = 0;
11493 if (address_set == 0)
11495 errmsg ("missing addresses");
11499 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11500 mp->enable_disable = enable_disable;
11501 mp->pid = getpid ();
11502 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11509 api_input_acl_set_interface (vat_main_t * vam)
11511 unformat_input_t *i = vam->input;
11512 vl_api_input_acl_set_interface_t *mp;
11515 int sw_if_index_set;
11516 u32 ip4_table_index = ~0;
11517 u32 ip6_table_index = ~0;
11518 u32 l2_table_index = ~0;
11521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11523 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11524 sw_if_index_set = 1;
11525 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11526 sw_if_index_set = 1;
11527 else if (unformat (i, "del"))
11529 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11531 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11533 else if (unformat (i, "l2-table %d", &l2_table_index))
11537 clib_warning ("parse error '%U'", format_unformat_error, i);
11542 if (sw_if_index_set == 0)
11544 errmsg ("missing interface name or sw_if_index");
11548 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11550 mp->sw_if_index = ntohl (sw_if_index);
11551 mp->ip4_table_index = ntohl (ip4_table_index);
11552 mp->ip6_table_index = ntohl (ip6_table_index);
11553 mp->l2_table_index = ntohl (l2_table_index);
11554 mp->is_add = is_add;
11563 api_ip_address_dump (vat_main_t * vam)
11565 unformat_input_t *i = vam->input;
11566 vl_api_ip_address_dump_t *mp;
11567 u32 sw_if_index = ~0;
11568 u8 sw_if_index_set = 0;
11573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11575 if (unformat (i, "sw_if_index %d", &sw_if_index))
11576 sw_if_index_set = 1;
11578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11579 sw_if_index_set = 1;
11580 else if (unformat (i, "ipv4"))
11582 else if (unformat (i, "ipv6"))
11588 if (ipv4_set && ipv6_set)
11590 errmsg ("ipv4 and ipv6 flags cannot be both set");
11594 if ((!ipv4_set) && (!ipv6_set))
11596 errmsg ("no ipv4 nor ipv6 flag set");
11600 if (sw_if_index_set == 0)
11602 errmsg ("missing interface name or sw_if_index");
11606 vam->current_sw_if_index = sw_if_index;
11607 vam->is_ipv6 = ipv6_set;
11609 M (IP_ADDRESS_DUMP, ip_address_dump);
11610 mp->sw_if_index = ntohl (sw_if_index);
11611 mp->is_ipv6 = ipv6_set;
11614 /* Use a control ping for synchronization */
11616 vl_api_control_ping_t *mp;
11617 M (CONTROL_PING, control_ping);
11624 api_ip_dump (vat_main_t * vam)
11626 vl_api_ip_dump_t *mp;
11627 unformat_input_t *in = vam->input;
11634 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11636 if (unformat (in, "ipv4"))
11638 else if (unformat (in, "ipv6"))
11644 if (ipv4_set && ipv6_set)
11646 errmsg ("ipv4 and ipv6 flags cannot be both set");
11650 if ((!ipv4_set) && (!ipv6_set))
11652 errmsg ("no ipv4 nor ipv6 flag set");
11656 is_ipv6 = ipv6_set;
11657 vam->is_ipv6 = is_ipv6;
11659 /* free old data */
11660 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11662 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11664 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11666 M (IP_DUMP, ip_dump);
11667 mp->is_ipv6 = ipv6_set;
11670 /* Use a control ping for synchronization */
11672 vl_api_control_ping_t *mp;
11673 M (CONTROL_PING, control_ping);
11680 api_ipsec_spd_add_del (vat_main_t * vam)
11682 unformat_input_t *i = vam->input;
11683 vl_api_ipsec_spd_add_del_t *mp;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "spd_id %d", &spd_id))
11692 else if (unformat (i, "del"))
11696 clib_warning ("parse error '%U'", format_unformat_error, i);
11702 errmsg ("spd_id must be set");
11706 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11708 mp->spd_id = ntohl (spd_id);
11709 mp->is_add = is_add;
11718 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11720 unformat_input_t *i = vam->input;
11721 vl_api_ipsec_interface_add_del_spd_t *mp;
11724 u8 sw_if_index_set = 0;
11725 u32 spd_id = (u32) ~ 0;
11728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11730 if (unformat (i, "del"))
11732 else if (unformat (i, "spd_id %d", &spd_id))
11735 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11736 sw_if_index_set = 1;
11737 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11738 sw_if_index_set = 1;
11741 clib_warning ("parse error '%U'", format_unformat_error, i);
11747 if (spd_id == (u32) ~ 0)
11749 errmsg ("spd_id must be set");
11753 if (sw_if_index_set == 0)
11755 errmsg ("missing interface name or sw_if_index");
11759 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11761 mp->spd_id = ntohl (spd_id);
11762 mp->sw_if_index = ntohl (sw_if_index);
11763 mp->is_add = is_add;
11772 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11774 unformat_input_t *i = vam->input;
11775 vl_api_ipsec_spd_add_del_entry_t *mp;
11777 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11778 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11780 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11781 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11782 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11783 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11785 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11786 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11787 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11788 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11789 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11790 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11794 if (unformat (i, "del"))
11796 if (unformat (i, "outbound"))
11798 if (unformat (i, "inbound"))
11800 else if (unformat (i, "spd_id %d", &spd_id))
11802 else if (unformat (i, "sa_id %d", &sa_id))
11804 else if (unformat (i, "priority %d", &priority))
11806 else if (unformat (i, "protocol %d", &protocol))
11808 else if (unformat (i, "lport_start %d", &lport_start))
11810 else if (unformat (i, "lport_stop %d", &lport_stop))
11812 else if (unformat (i, "rport_start %d", &rport_start))
11814 else if (unformat (i, "rport_stop %d", &rport_stop))
11818 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11824 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11831 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11837 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11844 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11850 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11857 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11863 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11869 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11871 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11873 clib_warning ("unsupported action: 'resolve'");
11879 clib_warning ("parse error '%U'", format_unformat_error, i);
11885 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11887 mp->spd_id = ntohl (spd_id);
11888 mp->priority = ntohl (priority);
11889 mp->is_outbound = is_outbound;
11891 mp->is_ipv6 = is_ipv6;
11892 if (is_ipv6 || is_ip_any)
11894 clib_memcpy (mp->remote_address_start, &raddr6_start,
11895 sizeof (ip6_address_t));
11896 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11897 sizeof (ip6_address_t));
11898 clib_memcpy (mp->local_address_start, &laddr6_start,
11899 sizeof (ip6_address_t));
11900 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11901 sizeof (ip6_address_t));
11905 clib_memcpy (mp->remote_address_start, &raddr4_start,
11906 sizeof (ip4_address_t));
11907 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11908 sizeof (ip4_address_t));
11909 clib_memcpy (mp->local_address_start, &laddr4_start,
11910 sizeof (ip4_address_t));
11911 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11912 sizeof (ip4_address_t));
11914 mp->protocol = (u8) protocol;
11915 mp->local_port_start = ntohs ((u16) lport_start);
11916 mp->local_port_stop = ntohs ((u16) lport_stop);
11917 mp->remote_port_start = ntohs ((u16) rport_start);
11918 mp->remote_port_stop = ntohs ((u16) rport_stop);
11919 mp->policy = (u8) policy;
11920 mp->sa_id = ntohl (sa_id);
11921 mp->is_add = is_add;
11922 mp->is_ip_any = is_ip_any;
11930 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11932 unformat_input_t *i = vam->input;
11933 vl_api_ipsec_sad_add_del_entry_t *mp;
11935 u32 sad_id = 0, spi = 0;
11936 u8 *ck = 0, *ik = 0;
11939 u8 protocol = IPSEC_PROTOCOL_AH;
11940 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11941 u32 crypto_alg = 0, integ_alg = 0;
11942 ip4_address_t tun_src4;
11943 ip4_address_t tun_dst4;
11944 ip6_address_t tun_src6;
11945 ip6_address_t tun_dst6;
11947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11949 if (unformat (i, "del"))
11951 else if (unformat (i, "sad_id %d", &sad_id))
11953 else if (unformat (i, "spi %d", &spi))
11955 else if (unformat (i, "esp"))
11956 protocol = IPSEC_PROTOCOL_ESP;
11957 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11960 is_tunnel_ipv6 = 0;
11962 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11965 is_tunnel_ipv6 = 0;
11967 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11970 is_tunnel_ipv6 = 1;
11972 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11975 is_tunnel_ipv6 = 1;
11979 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11981 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11982 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11984 clib_warning ("unsupported crypto-alg: '%U'",
11985 format_ipsec_crypto_alg, crypto_alg);
11989 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11993 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11996 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11998 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12000 integ_alg >= IPSEC_INTEG_N_ALG)
12002 clib_warning ("unsupported integ-alg: '%U'",
12003 format_ipsec_integ_alg, integ_alg);
12007 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12011 clib_warning ("parse error '%U'", format_unformat_error, i);
12018 /*Special cases, aes-gcm-128 encryption */
12019 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
12021 if (integ_alg != IPSEC_INTEG_ALG_NONE
12022 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
12025 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
12028 else /*set integ-alg internally to aes-gcm-128 */
12029 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
12031 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
12033 clib_warning ("unsupported integ-alg: aes-gcm-128");
12036 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
12038 clib_warning ("unsupported integ-alg: none");
12044 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
12046 mp->sad_id = ntohl (sad_id);
12047 mp->is_add = is_add;
12048 mp->protocol = protocol;
12049 mp->spi = ntohl (spi);
12050 mp->is_tunnel = is_tunnel;
12051 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12052 mp->crypto_algorithm = crypto_alg;
12053 mp->integrity_algorithm = integ_alg;
12054 mp->crypto_key_length = vec_len (ck);
12055 mp->integrity_key_length = vec_len (ik);
12057 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12058 mp->crypto_key_length = sizeof (mp->crypto_key);
12060 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12061 mp->integrity_key_length = sizeof (mp->integrity_key);
12064 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12066 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12070 if (is_tunnel_ipv6)
12072 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12073 sizeof (ip6_address_t));
12074 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12075 sizeof (ip6_address_t));
12079 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12080 sizeof (ip4_address_t));
12081 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12082 sizeof (ip4_address_t));
12093 api_ipsec_sa_set_key (vat_main_t * vam)
12095 unformat_input_t *i = vam->input;
12096 vl_api_ipsec_sa_set_key_t *mp;
12099 u8 *ck = 0, *ik = 0;
12101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12103 if (unformat (i, "sa_id %d", &sa_id))
12105 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12107 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12111 clib_warning ("parse error '%U'", format_unformat_error, i);
12116 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12118 mp->sa_id = ntohl (sa_id);
12119 mp->crypto_key_length = vec_len (ck);
12120 mp->integrity_key_length = vec_len (ik);
12122 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12123 mp->crypto_key_length = sizeof (mp->crypto_key);
12125 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12126 mp->integrity_key_length = sizeof (mp->integrity_key);
12129 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12131 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12140 api_ikev2_profile_add_del (vat_main_t * vam)
12142 unformat_input_t *i = vam->input;
12143 vl_api_ikev2_profile_add_del_t *mp;
12148 const char *valid_chars = "a-zA-Z0-9_";
12150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12152 if (unformat (i, "del"))
12154 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12155 vec_add1 (name, 0);
12158 errmsg ("parse error '%U'", format_unformat_error, i);
12163 if (!vec_len (name))
12165 errmsg ("profile name must be specified");
12169 if (vec_len (name) > 64)
12171 errmsg ("profile name too long");
12175 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12177 clib_memcpy (mp->name, name, vec_len (name));
12178 mp->is_add = is_add;
12188 api_ikev2_profile_set_auth (vat_main_t * vam)
12190 unformat_input_t *i = vam->input;
12191 vl_api_ikev2_profile_set_auth_t *mp;
12195 u32 auth_method = 0;
12198 const char *valid_chars = "a-zA-Z0-9_";
12200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12202 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12203 vec_add1 (name, 0);
12204 else if (unformat (i, "auth_method %U",
12205 unformat_ikev2_auth_method, &auth_method))
12207 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12209 else if (unformat (i, "auth_data %v", &data))
12213 errmsg ("parse error '%U'", format_unformat_error, i);
12218 if (!vec_len (name))
12220 errmsg ("profile name must be specified");
12224 if (vec_len (name) > 64)
12226 errmsg ("profile name too long");
12230 if (!vec_len (data))
12232 errmsg ("auth_data must be specified");
12238 errmsg ("auth_method must be specified");
12242 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12244 mp->is_hex = is_hex;
12245 mp->auth_method = (u8) auth_method;
12246 mp->data_len = vec_len (data);
12247 clib_memcpy (mp->name, name, vec_len (name));
12248 clib_memcpy (mp->data, data, vec_len (data));
12259 api_ikev2_profile_set_id (vat_main_t * vam)
12261 unformat_input_t *i = vam->input;
12262 vl_api_ikev2_profile_set_id_t *mp;
12270 const char *valid_chars = "a-zA-Z0-9_";
12272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12274 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12275 vec_add1 (name, 0);
12276 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12278 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12280 data = vec_new (u8, 4);
12281 clib_memcpy (data, ip4.as_u8, 4);
12283 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12285 else if (unformat (i, "id_data %v", &data))
12287 else if (unformat (i, "local"))
12289 else if (unformat (i, "remote"))
12293 errmsg ("parse error '%U'", format_unformat_error, i);
12298 if (!vec_len (name))
12300 errmsg ("profile name must be specified");
12304 if (vec_len (name) > 64)
12306 errmsg ("profile name too long");
12310 if (!vec_len (data))
12312 errmsg ("id_data must be specified");
12318 errmsg ("id_type must be specified");
12322 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12324 mp->is_local = is_local;
12325 mp->id_type = (u8) id_type;
12326 mp->data_len = vec_len (data);
12327 clib_memcpy (mp->name, name, vec_len (name));
12328 clib_memcpy (mp->data, data, vec_len (data));
12339 api_ikev2_profile_set_ts (vat_main_t * vam)
12341 unformat_input_t *i = vam->input;
12342 vl_api_ikev2_profile_set_ts_t *mp;
12346 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12347 ip4_address_t start_addr, end_addr;
12349 const char *valid_chars = "a-zA-Z0-9_";
12351 start_addr.as_u32 = 0;
12352 end_addr.as_u32 = (u32) ~ 0;
12354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12356 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12357 vec_add1 (name, 0);
12358 else if (unformat (i, "protocol %d", &proto))
12360 else if (unformat (i, "start_port %d", &start_port))
12362 else if (unformat (i, "end_port %d", &end_port))
12365 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12367 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12369 else if (unformat (i, "local"))
12371 else if (unformat (i, "remote"))
12375 errmsg ("parse error '%U'", format_unformat_error, i);
12380 if (!vec_len (name))
12382 errmsg ("profile name must be specified");
12386 if (vec_len (name) > 64)
12388 errmsg ("profile name too long");
12392 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12394 mp->is_local = is_local;
12395 mp->proto = (u8) proto;
12396 mp->start_port = (u16) start_port;
12397 mp->end_port = (u16) end_port;
12398 mp->start_addr = start_addr.as_u32;
12399 mp->end_addr = end_addr.as_u32;
12400 clib_memcpy (mp->name, name, vec_len (name));
12410 api_ikev2_set_local_key (vat_main_t * vam)
12412 unformat_input_t *i = vam->input;
12413 vl_api_ikev2_set_local_key_t *mp;
12417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12419 if (unformat (i, "file %v", &file))
12420 vec_add1 (file, 0);
12423 errmsg ("parse error '%U'", format_unformat_error, i);
12428 if (!vec_len (file))
12430 errmsg ("RSA key file must be specified");
12434 if (vec_len (file) > 256)
12436 errmsg ("file name too long");
12440 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12442 clib_memcpy (mp->key_file, file, vec_len (file));
12455 api_map_add_domain (vat_main_t * vam)
12457 unformat_input_t *i = vam->input;
12458 vl_api_map_add_domain_t *mp;
12461 ip4_address_t ip4_prefix;
12462 ip6_address_t ip6_prefix;
12463 ip6_address_t ip6_src;
12464 u32 num_m_args = 0;
12465 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12466 0, psid_length = 0;
12467 u8 is_translation = 0;
12469 u32 ip6_src_len = 128;
12471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12473 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12474 &ip4_prefix, &ip4_prefix_len))
12476 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12477 &ip6_prefix, &ip6_prefix_len))
12481 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12484 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12486 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12488 else if (unformat (i, "psid-offset %d", &psid_offset))
12490 else if (unformat (i, "psid-len %d", &psid_length))
12492 else if (unformat (i, "mtu %d", &mtu))
12494 else if (unformat (i, "map-t"))
12495 is_translation = 1;
12498 clib_warning ("parse error '%U'", format_unformat_error, i);
12503 if (num_m_args < 3)
12505 errmsg ("mandatory argument(s) missing");
12509 /* Construct the API message */
12510 M (MAP_ADD_DOMAIN, map_add_domain);
12512 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12513 mp->ip4_prefix_len = ip4_prefix_len;
12515 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12516 mp->ip6_prefix_len = ip6_prefix_len;
12518 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12519 mp->ip6_src_prefix_len = ip6_src_len;
12521 mp->ea_bits_len = ea_bits_len;
12522 mp->psid_offset = psid_offset;
12523 mp->psid_length = psid_length;
12524 mp->is_translation = is_translation;
12525 mp->mtu = htons (mtu);
12530 /* Wait for a reply, return good/bad news */
12535 api_map_del_domain (vat_main_t * vam)
12537 unformat_input_t *i = vam->input;
12538 vl_api_map_del_domain_t *mp;
12541 u32 num_m_args = 0;
12544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12546 if (unformat (i, "index %d", &index))
12550 clib_warning ("parse error '%U'", format_unformat_error, i);
12555 if (num_m_args != 1)
12557 errmsg ("mandatory argument(s) missing");
12561 /* Construct the API message */
12562 M (MAP_DEL_DOMAIN, map_del_domain);
12564 mp->index = ntohl (index);
12569 /* Wait for a reply, return good/bad news */
12574 api_map_add_del_rule (vat_main_t * vam)
12576 unformat_input_t *i = vam->input;
12577 vl_api_map_add_del_rule_t *mp;
12580 ip6_address_t ip6_dst;
12581 u32 num_m_args = 0, index, psid = 0;
12583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12585 if (unformat (i, "index %d", &index))
12587 else if (unformat (i, "psid %d", &psid))
12589 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12591 else if (unformat (i, "del"))
12597 clib_warning ("parse error '%U'", format_unformat_error, i);
12602 /* Construct the API message */
12603 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12605 mp->index = ntohl (index);
12606 mp->is_add = is_add;
12607 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12608 mp->psid = ntohs (psid);
12613 /* Wait for a reply, return good/bad news */
12618 api_map_domain_dump (vat_main_t * vam)
12620 vl_api_map_domain_dump_t *mp;
12623 /* Construct the API message */
12624 M (MAP_DOMAIN_DUMP, map_domain_dump);
12629 /* Use a control ping for synchronization */
12631 vl_api_control_ping_t *mp;
12632 M (CONTROL_PING, control_ping);
12639 api_map_rule_dump (vat_main_t * vam)
12641 unformat_input_t *i = vam->input;
12642 vl_api_map_rule_dump_t *mp;
12644 u32 domain_index = ~0;
12646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12648 if (unformat (i, "index %u", &domain_index))
12654 if (domain_index == ~0)
12656 clib_warning ("parse error: domain index expected");
12660 /* Construct the API message */
12661 M (MAP_RULE_DUMP, map_rule_dump);
12663 mp->domain_index = htonl (domain_index);
12668 /* Use a control ping for synchronization */
12670 vl_api_control_ping_t *mp;
12671 M (CONTROL_PING, control_ping);
12677 static void vl_api_map_add_domain_reply_t_handler
12678 (vl_api_map_add_domain_reply_t * mp)
12680 vat_main_t *vam = &vat_main;
12681 i32 retval = ntohl (mp->retval);
12683 if (vam->async_mode)
12685 vam->async_errors += (retval < 0);
12689 vam->retval = retval;
12690 vam->result_ready = 1;
12694 static void vl_api_map_add_domain_reply_t_handler_json
12695 (vl_api_map_add_domain_reply_t * mp)
12697 vat_main_t *vam = &vat_main;
12698 vat_json_node_t node;
12700 vat_json_init_object (&node);
12701 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12702 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12704 vat_json_print (vam->ofp, &node);
12705 vat_json_free (&node);
12707 vam->retval = ntohl (mp->retval);
12708 vam->result_ready = 1;
12712 api_get_first_msg_id (vat_main_t * vam)
12714 vl_api_get_first_msg_id_t *mp;
12716 unformat_input_t *i = vam->input;
12720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12722 if (unformat (i, "client %s", &name))
12730 errmsg ("missing client name");
12733 vec_add1 (name, 0);
12735 if (vec_len (name) > 63)
12737 errmsg ("client name too long");
12741 M (GET_FIRST_MSG_ID, get_first_msg_id);
12742 clib_memcpy (mp->name, name, vec_len (name));
12750 api_cop_interface_enable_disable (vat_main_t * vam)
12752 unformat_input_t *line_input = vam->input;
12753 vl_api_cop_interface_enable_disable_t *mp;
12755 u32 sw_if_index = ~0;
12756 u8 enable_disable = 1;
12758 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12760 if (unformat (line_input, "disable"))
12761 enable_disable = 0;
12762 if (unformat (line_input, "enable"))
12763 enable_disable = 1;
12764 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12765 vam, &sw_if_index))
12767 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12773 if (sw_if_index == ~0)
12775 errmsg ("missing interface name or sw_if_index");
12779 /* Construct the API message */
12780 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12781 mp->sw_if_index = ntohl (sw_if_index);
12782 mp->enable_disable = enable_disable;
12786 /* Wait for the reply */
12791 api_cop_whitelist_enable_disable (vat_main_t * vam)
12793 unformat_input_t *line_input = vam->input;
12794 vl_api_cop_whitelist_enable_disable_t *mp;
12796 u32 sw_if_index = ~0;
12797 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12800 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12802 if (unformat (line_input, "ip4"))
12804 else if (unformat (line_input, "ip6"))
12806 else if (unformat (line_input, "default"))
12808 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12809 vam, &sw_if_index))
12811 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12813 else if (unformat (line_input, "fib-id %d", &fib_id))
12819 if (sw_if_index == ~0)
12821 errmsg ("missing interface name or sw_if_index");
12825 /* Construct the API message */
12826 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12827 mp->sw_if_index = ntohl (sw_if_index);
12828 mp->fib_id = ntohl (fib_id);
12831 mp->default_cop = default_cop;
12835 /* Wait for the reply */
12840 api_get_node_graph (vat_main_t * vam)
12842 vl_api_get_node_graph_t *mp;
12845 M (GET_NODE_GRAPH, get_node_graph);
12849 /* Wait for the reply */
12854 /** Used for parsing LISP eids */
12855 typedef CLIB_PACKED(struct{
12856 u8 addr[16]; /**< eid address */
12857 u32 len; /**< prefix length if IP */
12858 u8 type; /**< type of eid */
12863 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12865 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12867 memset (a, 0, sizeof (a[0]));
12869 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12871 a->type = 0; /* ipv4 type */
12873 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12875 a->type = 1; /* ipv6 type */
12877 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12879 a->type = 2; /* mac type */
12886 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12895 lisp_eid_size_vat (u8 type)
12910 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12912 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12916 /** Used for transferring locators via VPP API */
12917 typedef CLIB_PACKED(struct
12919 u32 sw_if_index; /**< locator sw_if_index */
12920 u8 priority; /**< locator priority */
12921 u8 weight; /**< locator weight */
12926 api_lisp_add_del_locator_set (vat_main_t * vam)
12928 unformat_input_t *input = vam->input;
12929 vl_api_lisp_add_del_locator_set_t *mp;
12932 u8 *locator_set_name = NULL;
12933 u8 locator_set_name_set = 0;
12934 ls_locator_t locator, *locators = 0;
12935 u32 sw_if_index, priority, weight;
12938 /* Parse args required to build the message */
12939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12941 if (unformat (input, "del"))
12945 else if (unformat (input, "locator-set %s", &locator_set_name))
12947 locator_set_name_set = 1;
12949 else if (unformat (input, "sw_if_index %u p %u w %u",
12950 &sw_if_index, &priority, &weight))
12952 locator.sw_if_index = htonl (sw_if_index);
12953 locator.priority = priority;
12954 locator.weight = weight;
12955 vec_add1 (locators, locator);
12959 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
12960 &sw_if_index, &priority, &weight))
12962 locator.sw_if_index = htonl (sw_if_index);
12963 locator.priority = priority;
12964 locator.weight = weight;
12965 vec_add1 (locators, locator);
12971 if (locator_set_name_set == 0)
12973 errmsg ("missing locator-set name");
12974 vec_free (locators);
12978 if (vec_len (locator_set_name) > 64)
12980 errmsg ("locator-set name too long");
12981 vec_free (locator_set_name);
12982 vec_free (locators);
12985 vec_add1 (locator_set_name, 0);
12987 data_len = sizeof (ls_locator_t) * vec_len (locators);
12989 /* Construct the API message */
12990 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12992 mp->is_add = is_add;
12993 clib_memcpy (mp->locator_set_name, locator_set_name,
12994 vec_len (locator_set_name));
12995 vec_free (locator_set_name);
12997 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12999 clib_memcpy (mp->locators, locators, data_len);
13000 vec_free (locators);
13005 /* Wait for a reply... */
13013 api_lisp_add_del_locator (vat_main_t * vam)
13015 unformat_input_t *input = vam->input;
13016 vl_api_lisp_add_del_locator_t *mp;
13018 u32 tmp_if_index = ~0;
13019 u32 sw_if_index = ~0;
13020 u8 sw_if_index_set = 0;
13021 u8 sw_if_index_if_name_set = 0;
13023 u8 priority_set = 0;
13027 u8 *locator_set_name = NULL;
13028 u8 locator_set_name_set = 0;
13030 /* Parse args required to build the message */
13031 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13033 if (unformat (input, "del"))
13037 else if (unformat (input, "locator-set %s", &locator_set_name))
13039 locator_set_name_set = 1;
13041 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13044 sw_if_index_if_name_set = 1;
13045 sw_if_index = tmp_if_index;
13047 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13049 sw_if_index_set = 1;
13050 sw_if_index = tmp_if_index;
13052 else if (unformat (input, "p %d", &priority))
13056 else if (unformat (input, "w %d", &weight))
13064 if (locator_set_name_set == 0)
13066 errmsg ("missing locator-set name");
13070 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13072 errmsg ("missing sw_if_index");
13073 vec_free (locator_set_name);
13077 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13079 errmsg ("cannot use both params interface name and sw_if_index");
13080 vec_free (locator_set_name);
13084 if (priority_set == 0)
13086 errmsg ("missing locator-set priority");
13087 vec_free (locator_set_name);
13091 if (weight_set == 0)
13093 errmsg ("missing locator-set weight");
13094 vec_free (locator_set_name);
13098 if (vec_len (locator_set_name) > 64)
13100 errmsg ("locator-set name too long");
13101 vec_free (locator_set_name);
13104 vec_add1 (locator_set_name, 0);
13106 /* Construct the API message */
13107 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13109 mp->is_add = is_add;
13110 mp->sw_if_index = ntohl (sw_if_index);
13111 mp->priority = priority;
13112 mp->weight = weight;
13113 clib_memcpy (mp->locator_set_name, locator_set_name,
13114 vec_len (locator_set_name));
13115 vec_free (locator_set_name);
13120 /* Wait for a reply... */
13128 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13130 u32 *key_id = va_arg (*args, u32 *);
13133 if (unformat (input, "%s", &s))
13135 if (!strcmp ((char *) s, "sha1"))
13136 key_id[0] = HMAC_SHA_1_96;
13137 else if (!strcmp ((char *) s, "sha256"))
13138 key_id[0] = HMAC_SHA_256_128;
13141 clib_warning ("invalid key_id: '%s'", s);
13142 key_id[0] = HMAC_NO_KEY;
13153 api_lisp_add_del_local_eid (vat_main_t * vam)
13155 unformat_input_t *input = vam->input;
13156 vl_api_lisp_add_del_local_eid_t *mp;
13160 lisp_eid_vat_t _eid, *eid = &_eid;
13161 u8 *locator_set_name = 0;
13162 u8 locator_set_name_set = 0;
13167 /* Parse args required to build the message */
13168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13170 if (unformat (input, "del"))
13174 else if (unformat (input, "vni %d", &vni))
13178 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13182 else if (unformat (input, "locator-set %s", &locator_set_name))
13184 locator_set_name_set = 1;
13186 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13188 else if (unformat (input, "secret-key %_%v%_", &key))
13194 if (locator_set_name_set == 0)
13196 errmsg ("missing locator-set name");
13202 errmsg ("EID address not set!");
13203 vec_free (locator_set_name);
13207 if (key && (0 == key_id))
13209 errmsg ("invalid key_id!");
13213 if (vec_len (key) > 64)
13215 errmsg ("key too long");
13220 if (vec_len (locator_set_name) > 64)
13222 errmsg ("locator-set name too long");
13223 vec_free (locator_set_name);
13226 vec_add1 (locator_set_name, 0);
13228 /* Construct the API message */
13229 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13231 mp->is_add = is_add;
13232 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13233 mp->eid_type = eid->type;
13234 mp->prefix_len = eid->len;
13235 mp->vni = clib_host_to_net_u32 (vni);
13236 mp->key_id = clib_host_to_net_u16 (key_id);
13237 clib_memcpy (mp->locator_set_name, locator_set_name,
13238 vec_len (locator_set_name));
13239 clib_memcpy (mp->key, key, vec_len (key));
13241 vec_free (locator_set_name);
13247 /* Wait for a reply... */
13255 /** Used for transferring locators via VPP API */
13256 typedef CLIB_PACKED(struct
13258 u8 is_ip4; /**< is locator an IPv4 address? */
13259 u8 priority; /**< locator priority */
13260 u8 weight; /**< locator weight */
13261 u8 addr[16]; /**< IPv4/IPv6 address */
13266 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13268 unformat_input_t *input = vam->input;
13269 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13272 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13273 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13274 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13275 u32 action = ~0, p, w;
13276 ip4_address_t rmt_rloc4, lcl_rloc4;
13277 ip6_address_t rmt_rloc6, lcl_rloc6;
13278 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13280 memset (&rloc, 0, sizeof (rloc));
13282 /* Parse args required to build the message */
13283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13285 if (unformat (input, "del"))
13289 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
13293 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
13297 else if (unformat (input, "p %d w %d", &p, &w))
13301 errmsg ("No RLOC configured for setting priority/weight!");
13304 curr_rloc->priority = p;
13305 curr_rloc->weight = w;
13307 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13308 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13312 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13313 rloc.priority = rloc.weight = 0;
13314 vec_add1 (lcl_locs, rloc);
13316 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13317 vec_add1 (rmt_locs, rloc);
13318 /* priority and weight saved in rmt loc */
13319 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13321 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13322 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13325 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13326 rloc.priority = rloc.weight = 0;
13327 vec_add1 (lcl_locs, rloc);
13329 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13330 vec_add1 (rmt_locs, rloc);
13331 /* priority and weight saved in rmt loc */
13332 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13334 else if (unformat (input, "action %d", &action))
13340 clib_warning ("parse error '%U'", format_unformat_error, input);
13347 errmsg ("remote eid addresses not set");
13351 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13353 errmsg ("eid types don't match");
13357 if (0 == rmt_locs && (u32) ~ 0 == action)
13359 errmsg ("action not set for negative mapping");
13363 /* Construct the API message */
13364 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13366 mp->is_add = is_add;
13367 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13368 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13369 mp->eid_type = rmt_eid->type;
13370 mp->rmt_len = rmt_eid->len;
13371 mp->lcl_len = lcl_eid->len;
13372 mp->action = action;
13374 if (0 != rmt_locs && 0 != lcl_locs)
13376 mp->loc_num = vec_len (rmt_locs);
13377 clib_memcpy (mp->lcl_locs, lcl_locs,
13378 (sizeof (rloc_t) * vec_len (lcl_locs)));
13379 clib_memcpy (mp->rmt_locs, rmt_locs,
13380 (sizeof (rloc_t) * vec_len (rmt_locs)));
13382 vec_free (lcl_locs);
13383 vec_free (rmt_locs);
13388 /* Wait for a reply... */
13396 api_lisp_add_del_map_server (vat_main_t * vam)
13398 unformat_input_t *input = vam->input;
13399 vl_api_lisp_add_del_map_server_t *mp;
13404 ip4_address_t ipv4;
13405 ip6_address_t ipv6;
13407 /* Parse args required to build the message */
13408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13410 if (unformat (input, "del"))
13414 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13418 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13426 if (ipv4_set && ipv6_set)
13428 errmsg ("both eid v4 and v6 addresses set");
13432 if (!ipv4_set && !ipv6_set)
13434 errmsg ("eid addresses not set");
13438 /* Construct the API message */
13439 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13441 mp->is_add = is_add;
13445 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13450 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13456 /* Wait for a reply... */
13464 api_lisp_add_del_map_resolver (vat_main_t * vam)
13466 unformat_input_t *input = vam->input;
13467 vl_api_lisp_add_del_map_resolver_t *mp;
13472 ip4_address_t ipv4;
13473 ip6_address_t ipv6;
13475 /* Parse args required to build the message */
13476 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13478 if (unformat (input, "del"))
13482 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13486 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13494 if (ipv4_set && ipv6_set)
13496 errmsg ("both eid v4 and v6 addresses set");
13500 if (!ipv4_set && !ipv6_set)
13502 errmsg ("eid addresses not set");
13506 /* Construct the API message */
13507 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13509 mp->is_add = is_add;
13513 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13518 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13524 /* Wait for a reply... */
13532 api_lisp_gpe_enable_disable (vat_main_t * vam)
13534 unformat_input_t *input = vam->input;
13535 vl_api_lisp_gpe_enable_disable_t *mp;
13540 /* Parse args required to build the message */
13541 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13543 if (unformat (input, "enable"))
13548 else if (unformat (input, "disable"))
13559 errmsg ("Value not set");
13563 /* Construct the API message */
13564 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13571 /* Wait for a reply... */
13579 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13581 unformat_input_t *input = vam->input;
13582 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13587 /* Parse args required to build the message */
13588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13590 if (unformat (input, "enable"))
13595 else if (unformat (input, "disable"))
13603 errmsg ("Value not set");
13607 /* Construct the API message */
13608 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13610 mp->is_enabled = is_en;
13615 /* Wait for a reply... */
13623 api_lisp_map_register_enable_disable (vat_main_t * vam)
13625 unformat_input_t *input = vam->input;
13626 vl_api_lisp_map_register_enable_disable_t *mp;
13631 /* Parse args required to build the message */
13632 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13634 if (unformat (input, "enable"))
13639 else if (unformat (input, "disable"))
13647 errmsg ("Value not set");
13651 /* Construct the API message */
13652 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13654 mp->is_enabled = is_en;
13659 /* Wait for a reply... */
13667 api_lisp_enable_disable (vat_main_t * vam)
13669 unformat_input_t *input = vam->input;
13670 vl_api_lisp_enable_disable_t *mp;
13675 /* Parse args required to build the message */
13676 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13678 if (unformat (input, "enable"))
13683 else if (unformat (input, "disable"))
13693 errmsg ("Value not set");
13697 /* Construct the API message */
13698 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13705 /* Wait for a reply... */
13713 api_show_lisp_map_register_state (vat_main_t * vam)
13716 vl_api_show_lisp_map_register_state_t *mp;
13718 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13723 /* wait for reply */
13730 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13733 vl_api_show_lisp_rloc_probe_state_t *mp;
13735 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13740 /* wait for reply */
13747 api_show_lisp_map_request_mode (vat_main_t * vam)
13750 vl_api_show_lisp_map_request_mode_t *mp;
13752 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13757 /* wait for reply */
13764 api_lisp_map_request_mode (vat_main_t * vam)
13767 unformat_input_t *input = vam->input;
13768 vl_api_lisp_map_request_mode_t *mp;
13771 /* Parse args required to build the message */
13772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13774 if (unformat (input, "dst-only"))
13776 else if (unformat (input, "src-dst"))
13780 errmsg ("parse error '%U'", format_unformat_error, input);
13785 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13792 /* wait for reply */
13800 * Enable/disable LISP proxy ITR.
13802 * @param vam vpp API test context
13803 * @return return code
13806 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13809 u8 ls_name_set = 0;
13810 unformat_input_t *input = vam->input;
13811 vl_api_lisp_pitr_set_locator_set_t *mp;
13815 /* Parse args required to build the message */
13816 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13818 if (unformat (input, "del"))
13820 else if (unformat (input, "locator-set %s", &ls_name))
13824 errmsg ("parse error '%U'", format_unformat_error, input);
13831 errmsg ("locator-set name not set!");
13835 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13837 mp->is_add = is_add;
13838 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13839 vec_free (ls_name);
13844 /* wait for reply */
13852 api_show_lisp_pitr (vat_main_t * vam)
13854 vl_api_show_lisp_pitr_t *mp;
13857 if (!vam->json_output)
13859 print (vam->ofp, "%=20s", "lisp status:");
13862 M (SHOW_LISP_PITR, show_lisp_pitr);
13866 /* Wait for a reply... */
13874 * Add/delete mapping between vni and vrf
13877 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13880 unformat_input_t *input = vam->input;
13881 vl_api_lisp_eid_table_add_del_map_t *mp;
13882 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13883 u32 vni, vrf, bd_index;
13885 /* Parse args required to build the message */
13886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13888 if (unformat (input, "del"))
13890 else if (unformat (input, "vrf %d", &vrf))
13892 else if (unformat (input, "bd_index %d", &bd_index))
13894 else if (unformat (input, "vni %d", &vni))
13900 if (!vni_set || (!vrf_set && !bd_index_set))
13902 errmsg ("missing arguments!");
13906 if (vrf_set && bd_index_set)
13908 errmsg ("error: both vrf and bd entered!");
13912 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13914 mp->is_add = is_add;
13915 mp->vni = htonl (vni);
13916 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13917 mp->is_l2 = bd_index_set;
13922 /* wait for reply */
13930 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13932 u32 *action = va_arg (*args, u32 *);
13935 if (unformat (input, "%s", &s))
13937 if (!strcmp ((char *) s, "no-action"))
13939 else if (!strcmp ((char *) s, "natively-forward"))
13941 else if (!strcmp ((char *) s, "send-map-request"))
13943 else if (!strcmp ((char *) s, "drop"))
13947 clib_warning ("invalid action: '%s'", s);
13959 * Add/del remote mapping to/from LISP control plane
13961 * @param vam vpp API test context
13962 * @return return code
13965 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13967 unformat_input_t *input = vam->input;
13968 vl_api_lisp_add_del_remote_mapping_t *mp;
13971 lisp_eid_vat_t _eid, *eid = &_eid;
13972 lisp_eid_vat_t _seid, *seid = &_seid;
13973 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13974 u32 action = ~0, p, w, data_len;
13975 ip4_address_t rloc4;
13976 ip6_address_t rloc6;
13977 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13979 memset (&rloc, 0, sizeof (rloc));
13981 /* Parse args required to build the message */
13982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13984 if (unformat (input, "del-all"))
13988 else if (unformat (input, "del"))
13992 else if (unformat (input, "add"))
13996 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14000 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14004 else if (unformat (input, "vni %d", &vni))
14008 else if (unformat (input, "p %d w %d", &p, &w))
14012 errmsg ("No RLOC configured for setting priority/weight!");
14015 curr_rloc->priority = p;
14016 curr_rloc->weight = w;
14018 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14021 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14022 vec_add1 (rlocs, rloc);
14023 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14025 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14028 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14029 vec_add1 (rlocs, rloc);
14030 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14032 else if (unformat (input, "action %U",
14033 unformat_negative_mapping_action, &action))
14039 clib_warning ("parse error '%U'", format_unformat_error, input);
14046 errmsg ("missing params!");
14050 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14052 errmsg ("no action set for negative map-reply!");
14056 data_len = vec_len (rlocs) * sizeof (rloc_t);
14058 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14059 mp->is_add = is_add;
14060 mp->vni = htonl (vni);
14061 mp->action = (u8) action;
14062 mp->is_src_dst = seid_set;
14063 mp->eid_len = eid->len;
14064 mp->seid_len = seid->len;
14065 mp->del_all = del_all;
14066 mp->eid_type = eid->type;
14067 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14068 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14070 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14071 clib_memcpy (mp->rlocs, rlocs, data_len);
14077 /* Wait for a reply... */
14085 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14086 * forwarding entries in data-plane accordingly.
14088 * @param vam vpp API test context
14089 * @return return code
14092 api_lisp_add_del_adjacency (vat_main_t * vam)
14094 unformat_input_t *input = vam->input;
14095 vl_api_lisp_add_del_adjacency_t *mp;
14098 ip4_address_t leid4, reid4;
14099 ip6_address_t leid6, reid6;
14100 u8 reid_mac[6] = { 0 };
14101 u8 leid_mac[6] = { 0 };
14102 u8 reid_type, leid_type;
14103 u32 leid_len = 0, reid_len = 0, len;
14106 leid_type = reid_type = (u8) ~ 0;
14108 /* Parse args required to build the message */
14109 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14111 if (unformat (input, "del"))
14115 else if (unformat (input, "add"))
14119 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14122 reid_type = 0; /* ipv4 */
14125 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14128 reid_type = 1; /* ipv6 */
14131 else if (unformat (input, "reid %U", unformat_ethernet_address,
14134 reid_type = 2; /* mac */
14136 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14139 leid_type = 0; /* ipv4 */
14142 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14145 leid_type = 1; /* ipv6 */
14148 else if (unformat (input, "leid %U", unformat_ethernet_address,
14151 leid_type = 2; /* mac */
14153 else if (unformat (input, "vni %d", &vni))
14159 errmsg ("parse error '%U'", format_unformat_error, input);
14164 if ((u8) ~ 0 == reid_type)
14166 errmsg ("missing params!");
14170 if (leid_type != reid_type)
14172 errmsg ("remote and local EIDs are of different types!");
14176 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14177 mp->is_add = is_add;
14178 mp->vni = htonl (vni);
14179 mp->leid_len = leid_len;
14180 mp->reid_len = reid_len;
14181 mp->eid_type = reid_type;
14183 switch (mp->eid_type)
14186 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14187 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14190 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14191 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14194 clib_memcpy (mp->leid, leid_mac, 6);
14195 clib_memcpy (mp->reid, reid_mac, 6);
14198 errmsg ("unknown EID type %d!", mp->eid_type);
14205 /* Wait for a reply... */
14213 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14215 unformat_input_t *input = vam->input;
14216 vl_api_lisp_gpe_add_del_iface_t *mp;
14218 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14219 u32 dp_table = 0, vni = 0;
14221 /* Parse args required to build the message */
14222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14224 if (unformat (input, "up"))
14229 else if (unformat (input, "down"))
14234 else if (unformat (input, "table_id %d", &dp_table))
14238 else if (unformat (input, "bd_id %d", &dp_table))
14243 else if (unformat (input, "vni %d", &vni))
14251 if (action_set == 0)
14253 errmsg ("Action not set");
14256 if (dp_table_set == 0 || vni_set == 0)
14258 errmsg ("vni and dp_table must be set");
14262 /* Construct the API message */
14263 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14265 mp->is_add = is_add;
14266 mp->dp_table = dp_table;
14273 /* Wait for a reply... */
14281 * Add/del map request itr rlocs from LISP control plane and updates
14283 * @param vam vpp API test context
14284 * @return return code
14287 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14289 unformat_input_t *input = vam->input;
14290 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14292 u8 *locator_set_name = 0;
14293 u8 locator_set_name_set = 0;
14296 /* Parse args required to build the message */
14297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14299 if (unformat (input, "del"))
14303 else if (unformat (input, "%_%v%_", &locator_set_name))
14305 locator_set_name_set = 1;
14309 clib_warning ("parse error '%U'", format_unformat_error, input);
14314 if (is_add && !locator_set_name_set)
14316 errmsg ("itr-rloc is not set!");
14320 if (is_add && vec_len (locator_set_name) > 64)
14322 errmsg ("itr-rloc locator-set name too long");
14323 vec_free (locator_set_name);
14327 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14328 mp->is_add = is_add;
14331 clib_memcpy (mp->locator_set_name, locator_set_name,
14332 vec_len (locator_set_name));
14336 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14338 vec_free (locator_set_name);
14343 /* Wait for a reply... */
14351 api_lisp_locator_dump (vat_main_t * vam)
14353 unformat_input_t *input = vam->input;
14354 vl_api_lisp_locator_dump_t *mp;
14356 u8 is_index_set = 0, is_name_set = 0;
14360 /* Parse args required to build the message */
14361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14363 if (unformat (input, "ls_name %_%v%_", &ls_name))
14367 else if (unformat (input, "ls_index %d", &ls_index))
14373 errmsg ("parse error '%U'", format_unformat_error, input);
14378 if (!is_index_set && !is_name_set)
14380 errmsg ("error: expected one of index or name!");
14384 if (is_index_set && is_name_set)
14386 errmsg ("error: only one param expected!");
14390 if (vec_len (ls_name) > 62)
14392 errmsg ("error: locator set name too long!");
14396 if (!vam->json_output)
14398 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14401 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14402 mp->is_index_set = is_index_set;
14405 mp->ls_index = clib_host_to_net_u32 (ls_index);
14408 vec_add1 (ls_name, 0);
14409 strncpy ((char *) mp->ls_name, (char *) ls_name,
14410 sizeof (mp->ls_name) - 1);
14416 /* Use a control ping for synchronization */
14418 vl_api_control_ping_t *mp;
14419 M (CONTROL_PING, control_ping);
14422 /* Wait for a reply... */
14430 api_lisp_locator_set_dump (vat_main_t * vam)
14432 vl_api_lisp_locator_set_dump_t *mp;
14433 unformat_input_t *input = vam->input;
14437 /* Parse args required to build the message */
14438 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14440 if (unformat (input, "local"))
14444 else if (unformat (input, "remote"))
14450 errmsg ("parse error '%U'", format_unformat_error, input);
14455 if (!vam->json_output)
14457 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14460 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14462 mp->filter = filter;
14467 /* Use a control ping for synchronization */
14469 vl_api_control_ping_t *mp;
14470 M (CONTROL_PING, control_ping);
14473 /* Wait for a reply... */
14481 api_lisp_eid_table_map_dump (vat_main_t * vam)
14485 unformat_input_t *input = vam->input;
14486 vl_api_lisp_eid_table_map_dump_t *mp;
14489 /* Parse args required to build the message */
14490 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14492 if (unformat (input, "l2"))
14497 else if (unformat (input, "l3"))
14504 errmsg ("parse error '%U'", format_unformat_error, input);
14511 errmsg ("expected one of 'l2' or 'l3' parameter!");
14515 if (!vam->json_output)
14517 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14520 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14526 /* Use a control ping for synchronization */
14528 vl_api_control_ping_t *mp;
14529 M (CONTROL_PING, control_ping);
14532 /* Wait for a reply... */
14540 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14542 vl_api_lisp_eid_table_vni_dump_t *mp;
14545 if (!vam->json_output)
14547 print (vam->ofp, "VNI");
14550 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14555 /* Use a control ping for synchronization */
14557 vl_api_control_ping_t *mp;
14558 M (CONTROL_PING, control_ping);
14561 /* Wait for a reply... */
14569 api_lisp_eid_table_dump (vat_main_t * vam)
14571 unformat_input_t *i = vam->input;
14572 vl_api_lisp_eid_table_dump_t *mp;
14574 struct in_addr ip4;
14575 struct in6_addr ip6;
14577 u8 eid_type = ~0, eid_set = 0;
14578 u32 prefix_length = ~0, t, vni = 0;
14581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14583 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14589 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14595 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14600 else if (unformat (i, "vni %d", &t))
14604 else if (unformat (i, "local"))
14608 else if (unformat (i, "remote"))
14614 errmsg ("parse error '%U'", format_unformat_error, i);
14619 if (!vam->json_output)
14621 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14622 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14625 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14627 mp->filter = filter;
14631 mp->vni = htonl (vni);
14632 mp->eid_type = eid_type;
14636 mp->prefix_length = prefix_length;
14637 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14640 mp->prefix_length = prefix_length;
14641 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14644 clib_memcpy (mp->eid, mac, sizeof (mac));
14647 errmsg ("unknown EID type %d!", eid_type);
14655 /* Use a control ping for synchronization */
14657 vl_api_control_ping_t *mp;
14658 M (CONTROL_PING, control_ping);
14662 /* Wait for a reply... */
14670 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14672 vl_api_lisp_gpe_tunnel_dump_t *mp;
14675 if (!vam->json_output)
14677 print (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14678 "%=16s%=16s%=16s%=16s%=16s",
14679 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14680 "Decap next", "Lisp version", "Flags", "Next protocol",
14681 "ver_res", "res", "iid");
14684 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14688 /* Use a control ping for synchronization */
14690 vl_api_control_ping_t *mp;
14691 M (CONTROL_PING, control_ping);
14694 /* Wait for a reply... */
14702 api_lisp_adjacencies_get (vat_main_t * vam)
14704 unformat_input_t *i = vam->input;
14705 vl_api_lisp_adjacencies_get_t *mp;
14710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14712 if (unformat (i, "vni %d", &vni))
14718 errmsg ("parse error '%U'", format_unformat_error, i);
14725 errmsg ("vni not set!");
14729 if (!vam->json_output)
14731 print (vam->ofp, "%s %40s", "leid", "reid");
14734 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14735 mp->vni = clib_host_to_net_u32 (vni);
14740 /* Wait for a reply... */
14748 api_lisp_map_server_dump (vat_main_t * vam)
14750 vl_api_lisp_map_server_dump_t *mp;
14753 if (!vam->json_output)
14755 print (vam->ofp, "%=20s", "Map server");
14758 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14762 /* Use a control ping for synchronization */
14764 vl_api_control_ping_t *mp;
14765 M (CONTROL_PING, control_ping);
14768 /* Wait for a reply... */
14776 api_lisp_map_resolver_dump (vat_main_t * vam)
14778 vl_api_lisp_map_resolver_dump_t *mp;
14781 if (!vam->json_output)
14783 print (vam->ofp, "%=20s", "Map resolver");
14786 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14790 /* Use a control ping for synchronization */
14792 vl_api_control_ping_t *mp;
14793 M (CONTROL_PING, control_ping);
14796 /* Wait for a reply... */
14804 api_show_lisp_status (vat_main_t * vam)
14806 vl_api_show_lisp_status_t *mp;
14809 if (!vam->json_output)
14811 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14814 M (SHOW_LISP_STATUS, show_lisp_status);
14817 /* Wait for a reply... */
14825 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14827 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14830 if (!vam->json_output)
14832 print (vam->ofp, "%=20s", "itr-rlocs:");
14835 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14838 /* Wait for a reply... */
14846 api_af_packet_create (vat_main_t * vam)
14848 unformat_input_t *i = vam->input;
14849 vl_api_af_packet_create_t *mp;
14851 u8 *host_if_name = 0;
14853 u8 random_hw_addr = 1;
14855 memset (hw_addr, 0, sizeof (hw_addr));
14857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14859 if (unformat (i, "name %s", &host_if_name))
14860 vec_add1 (host_if_name, 0);
14861 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14862 random_hw_addr = 0;
14867 if (!vec_len (host_if_name))
14869 errmsg ("host-interface name must be specified");
14873 if (vec_len (host_if_name) > 64)
14875 errmsg ("host-interface name too long");
14879 M (AF_PACKET_CREATE, af_packet_create);
14881 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14882 clib_memcpy (mp->hw_addr, hw_addr, 6);
14883 mp->use_random_hw_addr = random_hw_addr;
14884 vec_free (host_if_name);
14887 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14893 api_af_packet_delete (vat_main_t * vam)
14895 unformat_input_t *i = vam->input;
14896 vl_api_af_packet_delete_t *mp;
14898 u8 *host_if_name = 0;
14900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14902 if (unformat (i, "name %s", &host_if_name))
14903 vec_add1 (host_if_name, 0);
14908 if (!vec_len (host_if_name))
14910 errmsg ("host-interface name must be specified");
14914 if (vec_len (host_if_name) > 64)
14916 errmsg ("host-interface name too long");
14920 M (AF_PACKET_DELETE, af_packet_delete);
14922 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14923 vec_free (host_if_name);
14932 api_policer_add_del (vat_main_t * vam)
14934 unformat_input_t *i = vam->input;
14935 vl_api_policer_add_del_t *mp;
14946 u8 color_aware = 0;
14947 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14949 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14950 conform_action.dscp = 0;
14951 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14952 exceed_action.dscp = 0;
14953 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14954 violate_action.dscp = 0;
14956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14958 if (unformat (i, "del"))
14960 else if (unformat (i, "name %s", &name))
14961 vec_add1 (name, 0);
14962 else if (unformat (i, "cir %u", &cir))
14964 else if (unformat (i, "eir %u", &eir))
14966 else if (unformat (i, "cb %u", &cb))
14968 else if (unformat (i, "eb %u", &eb))
14970 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14973 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14976 else if (unformat (i, "type %U", unformat_policer_type, &type))
14978 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14981 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14984 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14987 else if (unformat (i, "color-aware"))
14993 if (!vec_len (name))
14995 errmsg ("policer name must be specified");
14999 if (vec_len (name) > 64)
15001 errmsg ("policer name too long");
15005 M (POLICER_ADD_DEL, policer_add_del);
15007 clib_memcpy (mp->name, name, vec_len (name));
15009 mp->is_add = is_add;
15014 mp->rate_type = rate_type;
15015 mp->round_type = round_type;
15017 mp->conform_action_type = conform_action.action_type;
15018 mp->conform_dscp = conform_action.dscp;
15019 mp->exceed_action_type = exceed_action.action_type;
15020 mp->exceed_dscp = exceed_action.dscp;
15021 mp->violate_action_type = violate_action.action_type;
15022 mp->violate_dscp = violate_action.dscp;
15023 mp->color_aware = color_aware;
15032 api_policer_dump (vat_main_t * vam)
15034 unformat_input_t *i = vam->input;
15035 vl_api_policer_dump_t *mp;
15037 u8 *match_name = 0;
15038 u8 match_name_valid = 0;
15040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15042 if (unformat (i, "name %s", &match_name))
15044 vec_add1 (match_name, 0);
15045 match_name_valid = 1;
15051 M (POLICER_DUMP, policer_dump);
15052 mp->match_name_valid = match_name_valid;
15053 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15054 vec_free (match_name);
15058 /* Use a control ping for synchronization */
15060 vl_api_control_ping_t *mp;
15061 M (CONTROL_PING, control_ping);
15064 /* Wait for a reply... */
15072 api_policer_classify_set_interface (vat_main_t * vam)
15074 unformat_input_t *i = vam->input;
15075 vl_api_policer_classify_set_interface_t *mp;
15078 int sw_if_index_set;
15079 u32 ip4_table_index = ~0;
15080 u32 ip6_table_index = ~0;
15081 u32 l2_table_index = ~0;
15084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15087 sw_if_index_set = 1;
15088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15089 sw_if_index_set = 1;
15090 else if (unformat (i, "del"))
15092 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15094 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15096 else if (unformat (i, "l2-table %d", &l2_table_index))
15100 clib_warning ("parse error '%U'", format_unformat_error, i);
15105 if (sw_if_index_set == 0)
15107 errmsg ("missing interface name or sw_if_index");
15111 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15113 mp->sw_if_index = ntohl (sw_if_index);
15114 mp->ip4_table_index = ntohl (ip4_table_index);
15115 mp->ip6_table_index = ntohl (ip6_table_index);
15116 mp->l2_table_index = ntohl (l2_table_index);
15117 mp->is_add = is_add;
15126 api_policer_classify_dump (vat_main_t * vam)
15128 unformat_input_t *i = vam->input;
15129 vl_api_policer_classify_dump_t *mp;
15131 u8 type = POLICER_CLASSIFY_N_TABLES;
15133 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15137 errmsg ("classify table type must be specified");
15141 if (!vam->json_output)
15143 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15146 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15151 /* Use a control ping for synchronization */
15153 vl_api_control_ping_t *mp;
15154 M (CONTROL_PING, control_ping);
15157 /* Wait for a reply... */
15165 api_netmap_create (vat_main_t * vam)
15167 unformat_input_t *i = vam->input;
15168 vl_api_netmap_create_t *mp;
15172 u8 random_hw_addr = 1;
15176 memset (hw_addr, 0, sizeof (hw_addr));
15178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15180 if (unformat (i, "name %s", &if_name))
15181 vec_add1 (if_name, 0);
15182 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15183 random_hw_addr = 0;
15184 else if (unformat (i, "pipe"))
15186 else if (unformat (i, "master"))
15188 else if (unformat (i, "slave"))
15194 if (!vec_len (if_name))
15196 errmsg ("interface name must be specified");
15200 if (vec_len (if_name) > 64)
15202 errmsg ("interface name too long");
15206 M (NETMAP_CREATE, netmap_create);
15208 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15209 clib_memcpy (mp->hw_addr, hw_addr, 6);
15210 mp->use_random_hw_addr = random_hw_addr;
15211 mp->is_pipe = is_pipe;
15212 mp->is_master = is_master;
15213 vec_free (if_name);
15222 api_netmap_delete (vat_main_t * vam)
15224 unformat_input_t *i = vam->input;
15225 vl_api_netmap_delete_t *mp;
15229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15231 if (unformat (i, "name %s", &if_name))
15232 vec_add1 (if_name, 0);
15237 if (!vec_len (if_name))
15239 errmsg ("interface name must be specified");
15243 if (vec_len (if_name) > 64)
15245 errmsg ("interface name too long");
15249 M (NETMAP_DELETE, netmap_delete);
15251 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15252 vec_free (if_name);
15260 static void vl_api_mpls_tunnel_details_t_handler
15261 (vl_api_mpls_tunnel_details_t * mp)
15263 vat_main_t *vam = &vat_main;
15264 i32 len = mp->mt_next_hop_n_labels;
15267 print (vam->ofp, "[%d]: via %U %d labels ",
15269 format_ip4_address, mp->mt_next_hop,
15270 ntohl (mp->mt_next_hop_sw_if_index));
15271 for (i = 0; i < len; i++)
15273 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15275 print (vam->ofp, "");
15278 static void vl_api_mpls_tunnel_details_t_handler_json
15279 (vl_api_mpls_tunnel_details_t * mp)
15281 vat_main_t *vam = &vat_main;
15282 vat_json_node_t *node = NULL;
15283 struct in_addr ip4;
15285 i32 len = mp->mt_next_hop_n_labels;
15287 if (VAT_JSON_ARRAY != vam->json_tree.type)
15289 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15290 vat_json_init_array (&vam->json_tree);
15292 node = vat_json_array_add (&vam->json_tree);
15294 vat_json_init_object (node);
15295 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15296 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15297 vat_json_object_add_ip4 (node, "next_hop", ip4);
15298 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15299 ntohl (mp->mt_next_hop_sw_if_index));
15300 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15301 vat_json_object_add_uint (node, "label_count", len);
15302 for (i = 0; i < len; i++)
15304 vat_json_object_add_uint (node, "label",
15305 ntohl (mp->mt_next_hop_out_labels[i]));
15310 api_mpls_tunnel_dump (vat_main_t * vam)
15312 vl_api_mpls_tunnel_dump_t *mp;
15316 /* Parse args required to build the message */
15317 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15319 if (!unformat (vam->input, "tunnel_index %d", &index))
15326 print (vam->ofp, " tunnel_index %d", index);
15328 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15329 mp->tunnel_index = htonl (index);
15332 /* Use a control ping for synchronization */
15334 vl_api_control_ping_t *mp;
15335 M (CONTROL_PING, control_ping);
15341 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15342 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15345 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15347 vat_main_t *vam = &vat_main;
15348 int count = ntohl (mp->count);
15349 vl_api_fib_path2_t *fp;
15353 "table-id %d, label %u, ess_bit %u",
15354 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15356 for (i = 0; i < count; i++)
15358 if (fp->afi == IP46_TYPE_IP6)
15360 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15361 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15362 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15363 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15364 format_ip6_address, fp->next_hop);
15365 else if (fp->afi == IP46_TYPE_IP4)
15367 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15368 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15369 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15370 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15371 format_ip4_address, fp->next_hop);
15376 static void vl_api_mpls_fib_details_t_handler_json
15377 (vl_api_mpls_fib_details_t * mp)
15379 vat_main_t *vam = &vat_main;
15380 int count = ntohl (mp->count);
15381 vat_json_node_t *node = NULL;
15382 struct in_addr ip4;
15383 struct in6_addr ip6;
15384 vl_api_fib_path2_t *fp;
15387 if (VAT_JSON_ARRAY != vam->json_tree.type)
15389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15390 vat_json_init_array (&vam->json_tree);
15392 node = vat_json_array_add (&vam->json_tree);
15394 vat_json_init_object (node);
15395 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15396 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15397 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15398 vat_json_object_add_uint (node, "path_count", count);
15400 for (i = 0; i < count; i++)
15402 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15403 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15404 vat_json_object_add_uint (node, "is_local", fp->is_local);
15405 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15406 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15407 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15408 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15409 if (fp->afi == IP46_TYPE_IP4)
15411 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15412 vat_json_object_add_ip4 (node, "next_hop", ip4);
15414 else if (fp->afi == IP46_TYPE_IP6)
15416 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15417 vat_json_object_add_ip6 (node, "next_hop", ip6);
15423 api_mpls_fib_dump (vat_main_t * vam)
15425 vl_api_mpls_fib_dump_t *mp;
15428 M (MPLS_FIB_DUMP, mpls_fib_dump);
15431 /* Use a control ping for synchronization */
15433 vl_api_control_ping_t *mp;
15434 M (CONTROL_PING, control_ping);
15440 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15441 #define vl_api_ip_fib_details_t_print vl_noop_handler
15444 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15446 vat_main_t *vam = &vat_main;
15447 int count = ntohl (mp->count);
15448 vl_api_fib_path_t *fp;
15452 "table-id %d, prefix %U/%d",
15453 ntohl (mp->table_id), format_ip4_address, mp->address,
15454 mp->address_length);
15456 for (i = 0; i < count; i++)
15458 if (fp->afi == IP46_TYPE_IP6)
15460 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15461 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15462 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15463 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15464 format_ip6_address, fp->next_hop);
15465 else if (fp->afi == IP46_TYPE_IP4)
15467 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15468 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15469 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15470 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15471 format_ip4_address, fp->next_hop);
15476 static void vl_api_ip_fib_details_t_handler_json
15477 (vl_api_ip_fib_details_t * mp)
15479 vat_main_t *vam = &vat_main;
15480 int count = ntohl (mp->count);
15481 vat_json_node_t *node = NULL;
15482 struct in_addr ip4;
15483 struct in6_addr ip6;
15484 vl_api_fib_path_t *fp;
15487 if (VAT_JSON_ARRAY != vam->json_tree.type)
15489 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15490 vat_json_init_array (&vam->json_tree);
15492 node = vat_json_array_add (&vam->json_tree);
15494 vat_json_init_object (node);
15495 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15496 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15497 vat_json_object_add_ip4 (node, "prefix", ip4);
15498 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15499 vat_json_object_add_uint (node, "path_count", count);
15501 for (i = 0; i < count; i++)
15503 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15504 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15505 vat_json_object_add_uint (node, "is_local", fp->is_local);
15506 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15507 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15508 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15509 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15510 if (fp->afi == IP46_TYPE_IP4)
15512 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15513 vat_json_object_add_ip4 (node, "next_hop", ip4);
15515 else if (fp->afi == IP46_TYPE_IP6)
15517 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15518 vat_json_object_add_ip6 (node, "next_hop", ip6);
15524 api_ip_fib_dump (vat_main_t * vam)
15526 vl_api_ip_fib_dump_t *mp;
15529 M (IP_FIB_DUMP, ip_fib_dump);
15532 /* Use a control ping for synchronization */
15534 vl_api_control_ping_t *mp;
15535 M (CONTROL_PING, control_ping);
15541 static void vl_api_ip_neighbor_details_t_handler
15542 (vl_api_ip_neighbor_details_t * mp)
15544 vat_main_t *vam = &vat_main;
15546 print (vam->ofp, "%c %U %U",
15547 (mp->is_static) ? 'S' : 'D',
15548 format_ethernet_address, &mp->mac_address,
15549 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15553 static void vl_api_ip_neighbor_details_t_handler_json
15554 (vl_api_ip_neighbor_details_t * mp)
15557 vat_main_t *vam = &vat_main;
15558 vat_json_node_t *node;
15559 struct in_addr ip4;
15560 struct in6_addr ip6;
15562 if (VAT_JSON_ARRAY != vam->json_tree.type)
15564 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15565 vat_json_init_array (&vam->json_tree);
15567 node = vat_json_array_add (&vam->json_tree);
15569 vat_json_init_object (node);
15570 vat_json_object_add_string_copy (node, "flag",
15571 (mp->is_static) ? (u8 *) "static" : (u8 *)
15574 vat_json_object_add_string_copy (node, "link_layer",
15575 format (0, "%U", format_ethernet_address,
15576 &mp->mac_address));
15580 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15581 vat_json_object_add_ip6 (node, "ip_address", ip6);
15585 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15586 vat_json_object_add_ip4 (node, "ip_address", ip4);
15591 api_ip_neighbor_dump (vat_main_t * vam)
15593 unformat_input_t *i = vam->input;
15594 vl_api_ip_neighbor_dump_t *mp;
15597 u32 sw_if_index = ~0;
15599 /* Parse args required to build the message */
15600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15602 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15604 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15606 else if (unformat (i, "ip6"))
15612 if (sw_if_index == ~0)
15614 errmsg ("missing interface name or sw_if_index");
15618 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15619 mp->is_ipv6 = (u8) is_ipv6;
15620 mp->sw_if_index = ntohl (sw_if_index);
15623 /* Use a control ping for synchronization */
15625 vl_api_control_ping_t *mp;
15626 M (CONTROL_PING, control_ping);
15632 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15633 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15636 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15638 vat_main_t *vam = &vat_main;
15639 int count = ntohl (mp->count);
15640 vl_api_fib_path_t *fp;
15644 "table-id %d, prefix %U/%d",
15645 ntohl (mp->table_id), format_ip6_address, mp->address,
15646 mp->address_length);
15648 for (i = 0; i < count; i++)
15650 if (fp->afi == IP46_TYPE_IP6)
15652 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15653 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15654 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15655 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15656 format_ip6_address, fp->next_hop);
15657 else if (fp->afi == IP46_TYPE_IP4)
15659 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15660 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15661 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15662 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15663 format_ip4_address, fp->next_hop);
15668 static void vl_api_ip6_fib_details_t_handler_json
15669 (vl_api_ip6_fib_details_t * mp)
15671 vat_main_t *vam = &vat_main;
15672 int count = ntohl (mp->count);
15673 vat_json_node_t *node = NULL;
15674 struct in_addr ip4;
15675 struct in6_addr ip6;
15676 vl_api_fib_path_t *fp;
15679 if (VAT_JSON_ARRAY != vam->json_tree.type)
15681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15682 vat_json_init_array (&vam->json_tree);
15684 node = vat_json_array_add (&vam->json_tree);
15686 vat_json_init_object (node);
15687 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15688 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15689 vat_json_object_add_ip6 (node, "prefix", ip6);
15690 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15691 vat_json_object_add_uint (node, "path_count", count);
15693 for (i = 0; i < count; i++)
15695 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15696 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15697 vat_json_object_add_uint (node, "is_local", fp->is_local);
15698 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15699 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15700 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15701 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15702 if (fp->afi == IP46_TYPE_IP4)
15704 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15705 vat_json_object_add_ip4 (node, "next_hop", ip4);
15707 else if (fp->afi == IP46_TYPE_IP6)
15709 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15710 vat_json_object_add_ip6 (node, "next_hop", ip6);
15716 api_ip6_fib_dump (vat_main_t * vam)
15718 vl_api_ip6_fib_dump_t *mp;
15721 M (IP6_FIB_DUMP, ip6_fib_dump);
15724 /* Use a control ping for synchronization */
15726 vl_api_control_ping_t *mp;
15727 M (CONTROL_PING, control_ping);
15734 api_classify_table_ids (vat_main_t * vam)
15736 vl_api_classify_table_ids_t *mp;
15739 /* Construct the API message */
15740 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15750 api_classify_table_by_interface (vat_main_t * vam)
15752 unformat_input_t *input = vam->input;
15753 vl_api_classify_table_by_interface_t *mp;
15756 u32 sw_if_index = ~0;
15757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15759 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15761 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15766 if (sw_if_index == ~0)
15768 errmsg ("missing interface name or sw_if_index");
15772 /* Construct the API message */
15773 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15775 mp->sw_if_index = ntohl (sw_if_index);
15784 api_classify_table_info (vat_main_t * vam)
15786 unformat_input_t *input = vam->input;
15787 vl_api_classify_table_info_t *mp;
15791 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15793 if (unformat (input, "table_id %d", &table_id))
15798 if (table_id == ~0)
15800 errmsg ("missing table id");
15804 /* Construct the API message */
15805 M (CLASSIFY_TABLE_INFO, classify_table_info);
15807 mp->table_id = ntohl (table_id);
15816 api_classify_session_dump (vat_main_t * vam)
15818 unformat_input_t *input = vam->input;
15819 vl_api_classify_session_dump_t *mp;
15823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15825 if (unformat (input, "table_id %d", &table_id))
15830 if (table_id == ~0)
15832 errmsg ("missing table id");
15836 /* Construct the API message */
15837 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15839 mp->table_id = ntohl (table_id);
15842 /* Use a control ping for synchronization */
15844 vl_api_control_ping_t *mp;
15845 M (CONTROL_PING, control_ping);
15854 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15856 vat_main_t *vam = &vat_main;
15858 print (vam->ofp, "collector_address %U, collector_port %d, "
15859 "src_address %U, vrf_id %d, path_mtu %u, "
15860 "template_interval %u, udp_checksum %d",
15861 format_ip4_address, mp->collector_address,
15862 ntohs (mp->collector_port),
15863 format_ip4_address, mp->src_address,
15864 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15865 ntohl (mp->template_interval), mp->udp_checksum);
15868 vam->result_ready = 1;
15872 vl_api_ipfix_exporter_details_t_handler_json
15873 (vl_api_ipfix_exporter_details_t * mp)
15875 vat_main_t *vam = &vat_main;
15876 vat_json_node_t node;
15877 struct in_addr collector_address;
15878 struct in_addr src_address;
15880 vat_json_init_object (&node);
15881 clib_memcpy (&collector_address, &mp->collector_address,
15882 sizeof (collector_address));
15883 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15884 vat_json_object_add_uint (&node, "collector_port",
15885 ntohs (mp->collector_port));
15886 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15887 vat_json_object_add_ip4 (&node, "src_address", src_address);
15888 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15889 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15890 vat_json_object_add_uint (&node, "template_interval",
15891 ntohl (mp->template_interval));
15892 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15894 vat_json_print (vam->ofp, &node);
15895 vat_json_free (&node);
15897 vam->result_ready = 1;
15901 api_ipfix_exporter_dump (vat_main_t * vam)
15903 vl_api_ipfix_exporter_dump_t *mp;
15906 /* Construct the API message */
15907 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15917 api_ipfix_classify_stream_dump (vat_main_t * vam)
15919 vl_api_ipfix_classify_stream_dump_t *mp;
15922 /* Construct the API message */
15923 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15933 vl_api_ipfix_classify_stream_details_t_handler
15934 (vl_api_ipfix_classify_stream_details_t * mp)
15936 vat_main_t *vam = &vat_main;
15937 print (vam->ofp, "domain_id %d, src_port %d",
15938 ntohl (mp->domain_id), ntohs (mp->src_port));
15940 vam->result_ready = 1;
15944 vl_api_ipfix_classify_stream_details_t_handler_json
15945 (vl_api_ipfix_classify_stream_details_t * mp)
15947 vat_main_t *vam = &vat_main;
15948 vat_json_node_t node;
15950 vat_json_init_object (&node);
15951 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15952 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15954 vat_json_print (vam->ofp, &node);
15955 vat_json_free (&node);
15957 vam->result_ready = 1;
15961 api_ipfix_classify_table_dump (vat_main_t * vam)
15963 vl_api_ipfix_classify_table_dump_t *mp;
15966 if (!vam->json_output)
15968 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
15969 "transport_protocol");
15972 /* Construct the API message */
15973 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15978 /* Use a control ping for synchronization */
15980 vl_api_control_ping_t *mp;
15981 M (CONTROL_PING, control_ping);
15988 vl_api_ipfix_classify_table_details_t_handler
15989 (vl_api_ipfix_classify_table_details_t * mp)
15991 vat_main_t *vam = &vat_main;
15992 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
15993 mp->transport_protocol);
15997 vl_api_ipfix_classify_table_details_t_handler_json
15998 (vl_api_ipfix_classify_table_details_t * mp)
16000 vat_json_node_t *node = NULL;
16001 vat_main_t *vam = &vat_main;
16003 if (VAT_JSON_ARRAY != vam->json_tree.type)
16005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16006 vat_json_init_array (&vam->json_tree);
16009 node = vat_json_array_add (&vam->json_tree);
16010 vat_json_init_object (node);
16012 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16013 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16014 vat_json_object_add_uint (node, "transport_protocol",
16015 mp->transport_protocol);
16019 api_sw_interface_span_enable_disable (vat_main_t * vam)
16021 unformat_input_t *i = vam->input;
16022 vl_api_sw_interface_span_enable_disable_t *mp;
16024 u32 src_sw_if_index = ~0;
16025 u32 dst_sw_if_index = ~0;
16028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16031 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16033 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16037 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16039 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16041 else if (unformat (i, "disable"))
16043 else if (unformat (i, "rx"))
16045 else if (unformat (i, "tx"))
16047 else if (unformat (i, "both"))
16053 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16055 mp->sw_if_index_from = htonl (src_sw_if_index);
16056 mp->sw_if_index_to = htonl (dst_sw_if_index);
16066 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16069 vat_main_t *vam = &vat_main;
16070 u8 *sw_if_from_name = 0;
16071 u8 *sw_if_to_name = 0;
16072 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16073 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16074 char *states[] = { "none", "rx", "tx", "both" };
16078 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16080 if ((u32) p->value[0] == sw_if_index_from)
16082 sw_if_from_name = (u8 *)(p->key);
16086 if ((u32) p->value[0] == sw_if_index_to)
16088 sw_if_to_name = (u8 *)(p->key);
16089 if (sw_if_from_name)
16094 print (vam->ofp, "%20s => %20s (%s)",
16095 sw_if_from_name, sw_if_to_name, states[mp->state]);
16099 vl_api_sw_interface_span_details_t_handler_json
16100 (vl_api_sw_interface_span_details_t * mp)
16102 vat_main_t *vam = &vat_main;
16103 vat_json_node_t *node = NULL;
16104 u8 *sw_if_from_name = 0;
16105 u8 *sw_if_to_name = 0;
16106 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16107 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16111 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16113 if ((u32) p->value[0] == sw_if_index_from)
16115 sw_if_from_name = (u8 *)(p->key);
16119 if ((u32) p->value[0] == sw_if_index_to)
16121 sw_if_to_name = (u8 *)(p->key);
16122 if (sw_if_from_name)
16128 if (VAT_JSON_ARRAY != vam->json_tree.type)
16130 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16131 vat_json_init_array (&vam->json_tree);
16133 node = vat_json_array_add (&vam->json_tree);
16135 vat_json_init_object (node);
16136 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16137 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16138 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16139 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16140 vat_json_object_add_uint (node, "state", mp->state);
16144 api_sw_interface_span_dump (vat_main_t * vam)
16146 vl_api_sw_interface_span_dump_t *mp;
16149 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16152 /* Use a control ping for synchronization */
16154 vl_api_control_ping_t *mp;
16155 M (CONTROL_PING, control_ping);
16162 api_pg_create_interface (vat_main_t * vam)
16164 unformat_input_t *input = vam->input;
16165 vl_api_pg_create_interface_t *mp;
16169 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16171 if (unformat (input, "if_id %d", &if_id))
16178 errmsg ("missing pg interface index");
16182 /* Construct the API message */
16183 M (PG_CREATE_INTERFACE, pg_create_interface);
16185 mp->interface_id = ntohl (if_id);
16194 api_pg_capture (vat_main_t * vam)
16196 unformat_input_t *input = vam->input;
16197 vl_api_pg_capture_t *mp;
16203 u8 pcap_file_set = 0;
16205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16207 if (unformat (input, "if_id %d", &if_id))
16209 else if (unformat (input, "pcap %s", &pcap_file))
16211 else if (unformat (input, "count %d", &count))
16213 else if (unformat (input, "disable"))
16220 errmsg ("missing pg interface index");
16223 if (pcap_file_set > 0)
16225 if (vec_len (pcap_file) > 255)
16227 errmsg ("pcap file name is too long");
16232 u32 name_len = vec_len (pcap_file);
16233 /* Construct the API message */
16234 M (PG_CAPTURE, pg_capture);
16236 mp->interface_id = ntohl (if_id);
16237 mp->is_enabled = enable;
16238 mp->count = ntohl (count);
16239 mp->pcap_name_length = ntohl (name_len);
16240 if (pcap_file_set != 0)
16242 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16244 vec_free (pcap_file);
16253 api_pg_enable_disable (vat_main_t * vam)
16255 unformat_input_t *input = vam->input;
16256 vl_api_pg_enable_disable_t *mp;
16260 u8 stream_name_set = 0;
16261 u8 *stream_name = 0;
16262 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16264 if (unformat (input, "stream %s", &stream_name))
16265 stream_name_set = 1;
16266 else if (unformat (input, "disable"))
16272 if (stream_name_set > 0)
16274 if (vec_len (stream_name) > 255)
16276 errmsg ("stream name too long");
16281 u32 name_len = vec_len (stream_name);
16282 /* Construct the API message */
16283 M (PG_ENABLE_DISABLE, pg_enable_disable);
16285 mp->is_enabled = enable;
16286 if (stream_name_set != 0)
16288 mp->stream_name_length = ntohl (name_len);
16289 clib_memcpy (mp->stream_name, stream_name, name_len);
16291 vec_free (stream_name);
16300 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16302 unformat_input_t *input = vam->input;
16303 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16306 u16 *low_ports = 0;
16307 u16 *high_ports = 0;
16310 ip4_address_t ip4_addr;
16311 ip6_address_t ip6_addr;
16319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16321 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16327 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16332 else if (unformat (input, "vrf %d", &vrf_id))
16334 else if (unformat (input, "del"))
16336 else if (unformat (input, "port %d", &tmp))
16338 if (tmp == 0 || tmp > 65535)
16340 errmsg ("port %d out of range", tmp);
16344 this_hi = this_low + 1;
16345 vec_add1 (low_ports, this_low);
16346 vec_add1 (high_ports, this_hi);
16348 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16350 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16352 errmsg ("incorrect range parameters");
16356 /* Note: in debug CLI +1 is added to high before
16357 passing to real fn that does "the work"
16358 (ip_source_and_port_range_check_add_del).
16359 This fn is a wrapper around the binary API fn a
16360 control plane will call, which expects this increment
16361 to have occurred. Hence letting the binary API control
16362 plane fn do the increment for consistency between VAT
16363 and other control planes.
16366 vec_add1 (low_ports, this_low);
16367 vec_add1 (high_ports, this_hi);
16373 if (prefix_set == 0)
16375 errmsg ("<address>/<mask> not specified");
16381 errmsg ("VRF ID required, not specified");
16388 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16392 if (vec_len (low_ports) == 0)
16394 errmsg ("At least one port or port range required");
16398 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16399 ip_source_and_port_range_check_add_del);
16401 mp->is_add = is_add;
16406 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16411 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16414 mp->mask_length = length;
16415 mp->number_of_ranges = vec_len (low_ports);
16417 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16418 vec_free (low_ports);
16420 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16421 vec_free (high_ports);
16423 mp->vrf_id = ntohl (vrf_id);
16432 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16434 unformat_input_t *input = vam->input;
16435 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16437 u32 sw_if_index = ~0;
16439 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16440 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16445 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16447 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16449 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16451 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16453 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16455 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16457 else if (unformat (input, "del"))
16463 if (sw_if_index == ~0)
16465 errmsg ("Interface required but not specified");
16471 errmsg ("VRF ID required but not specified");
16475 if (tcp_out_vrf_id == 0
16476 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16479 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16483 /* Construct the API message */
16484 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16485 ip_source_and_port_range_check_interface_add_del);
16487 mp->sw_if_index = ntohl (sw_if_index);
16488 mp->is_add = is_add;
16489 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16490 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16491 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16492 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16497 /* Wait for a reply... */
16502 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16504 unformat_input_t *i = vam->input;
16505 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16507 u32 local_sa_id = 0;
16508 u32 remote_sa_id = 0;
16509 ip4_address_t src_address;
16510 ip4_address_t dst_address;
16513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16515 if (unformat (i, "local_sa %d", &local_sa_id))
16517 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16519 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16521 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16523 else if (unformat (i, "del"))
16527 clib_warning ("parse error '%U'", format_unformat_error, i);
16532 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16534 mp->local_sa_id = ntohl (local_sa_id);
16535 mp->remote_sa_id = ntohl (remote_sa_id);
16536 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16537 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16538 mp->is_add = is_add;
16547 api_punt (vat_main_t * vam)
16549 unformat_input_t *i = vam->input;
16557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16559 if (unformat (i, "ip %d", &ipv))
16561 else if (unformat (i, "protocol %d", &protocol))
16563 else if (unformat (i, "port %d", &port))
16565 else if (unformat (i, "del"))
16569 clib_warning ("parse error '%U'", format_unformat_error, i);
16576 mp->is_add = (u8) is_add;
16577 mp->ipv = (u8) ipv;
16578 mp->l4_protocol = (u8) protocol;
16579 mp->l4_port = htons ((u16) port);
16587 static void vl_api_ipsec_gre_tunnel_details_t_handler
16588 (vl_api_ipsec_gre_tunnel_details_t * mp)
16590 vat_main_t *vam = &vat_main;
16592 print (vam->ofp, "%11d%15U%15U%14d%14d",
16593 ntohl (mp->sw_if_index),
16594 format_ip4_address, &mp->src_address,
16595 format_ip4_address, &mp->dst_address,
16596 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16599 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16600 (vl_api_ipsec_gre_tunnel_details_t * mp)
16602 vat_main_t *vam = &vat_main;
16603 vat_json_node_t *node = NULL;
16604 struct in_addr ip4;
16606 if (VAT_JSON_ARRAY != vam->json_tree.type)
16608 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16609 vat_json_init_array (&vam->json_tree);
16611 node = vat_json_array_add (&vam->json_tree);
16613 vat_json_init_object (node);
16614 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16615 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16616 vat_json_object_add_ip4 (node, "src_address", ip4);
16617 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16618 vat_json_object_add_ip4 (node, "dst_address", ip4);
16619 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16620 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16624 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16626 unformat_input_t *i = vam->input;
16627 vl_api_ipsec_gre_tunnel_dump_t *mp;
16630 u8 sw_if_index_set = 0;
16632 /* Parse args required to build the message */
16633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16635 if (unformat (i, "sw_if_index %d", &sw_if_index))
16636 sw_if_index_set = 1;
16641 if (sw_if_index_set == 0)
16646 if (!vam->json_output)
16648 print (vam->ofp, "%11s%15s%15s%14s%14s",
16649 "sw_if_index", "src_address", "dst_address",
16650 "local_sa_id", "remote_sa_id");
16653 /* Get list of gre-tunnel interfaces */
16654 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16656 mp->sw_if_index = htonl (sw_if_index);
16660 /* Use a control ping for synchronization */
16662 vl_api_control_ping_t *mp;
16663 M (CONTROL_PING, control_ping);
16670 api_delete_subif (vat_main_t * vam)
16672 unformat_input_t *i = vam->input;
16673 vl_api_delete_subif_t *mp;
16675 u32 sw_if_index = ~0;
16677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16681 if (unformat (i, "sw_if_index %d", &sw_if_index))
16687 if (sw_if_index == ~0)
16689 errmsg ("missing sw_if_index");
16693 /* Construct the API message */
16694 M (DELETE_SUBIF, delete_subif);
16695 mp->sw_if_index = ntohl (sw_if_index);
16701 #define foreach_pbb_vtr_op \
16702 _("disable", L2_VTR_DISABLED) \
16703 _("pop", L2_VTR_POP_2) \
16704 _("push", L2_VTR_PUSH_2)
16707 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16709 unformat_input_t *i = vam->input;
16710 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16712 u32 sw_if_index = ~0, vtr_op = ~0;
16713 u16 outer_tag = ~0;
16714 u8 dmac[6], smac[6];
16715 u8 dmac_set = 0, smac_set = 0;
16720 /* Shut up coverity */
16721 memset (dmac, 0, sizeof (dmac));
16722 memset (smac, 0, sizeof (smac));
16724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16726 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16728 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16730 else if (unformat (i, "vtr_op %d", &vtr_op))
16732 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16735 else if (unformat (i, "translate_pbb_stag"))
16737 if (unformat (i, "%d", &tmp))
16739 vtr_op = L2_VTR_TRANSLATE_2_1;
16745 ("translate_pbb_stag operation requires outer tag definition");
16749 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16751 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16753 else if (unformat (i, "sid %d", &sid))
16755 else if (unformat (i, "vlanid %d", &tmp))
16759 clib_warning ("parse error '%U'", format_unformat_error, i);
16764 if ((sw_if_index == ~0) || (vtr_op == ~0))
16766 errmsg ("missing sw_if_index or vtr operation");
16769 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16770 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16773 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16777 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16778 mp->sw_if_index = ntohl (sw_if_index);
16779 mp->vtr_op = ntohl (vtr_op);
16780 mp->outer_tag = ntohs (outer_tag);
16781 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16782 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16783 mp->b_vlanid = ntohs (vlanid);
16784 mp->i_sid = ntohl (sid);
16793 api_flow_classify_set_interface (vat_main_t * vam)
16795 unformat_input_t *i = vam->input;
16796 vl_api_flow_classify_set_interface_t *mp;
16799 int sw_if_index_set;
16800 u32 ip4_table_index = ~0;
16801 u32 ip6_table_index = ~0;
16804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16806 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16807 sw_if_index_set = 1;
16808 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16809 sw_if_index_set = 1;
16810 else if (unformat (i, "del"))
16812 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16814 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16818 clib_warning ("parse error '%U'", format_unformat_error, i);
16823 if (sw_if_index_set == 0)
16825 errmsg ("missing interface name or sw_if_index");
16829 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16831 mp->sw_if_index = ntohl (sw_if_index);
16832 mp->ip4_table_index = ntohl (ip4_table_index);
16833 mp->ip6_table_index = ntohl (ip6_table_index);
16834 mp->is_add = is_add;
16843 api_flow_classify_dump (vat_main_t * vam)
16845 unformat_input_t *i = vam->input;
16846 vl_api_flow_classify_dump_t *mp;
16848 u8 type = FLOW_CLASSIFY_N_TABLES;
16850 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16854 errmsg ("classify table type must be specified");
16858 if (!vam->json_output)
16860 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16863 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16868 /* Use a control ping for synchronization */
16870 vl_api_control_ping_t *mp;
16871 M (CONTROL_PING, control_ping);
16874 /* Wait for a reply... */
16882 api_feature_enable_disable (vat_main_t * vam)
16884 unformat_input_t *i = vam->input;
16885 vl_api_feature_enable_disable_t *mp;
16888 u8 *feature_name = 0;
16889 u32 sw_if_index = ~0;
16892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16894 if (unformat (i, "arc_name %s", &arc_name))
16896 else if (unformat (i, "feature_name %s", &feature_name))
16899 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16901 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16903 else if (unformat (i, "disable"))
16911 errmsg ("missing arc name");
16914 if (vec_len (arc_name) > 63)
16916 errmsg ("arc name too long");
16919 if (feature_name == 0)
16921 errmsg ("missing feature name");
16924 if (vec_len (feature_name) > 63)
16926 errmsg ("feature name too long");
16929 if (sw_if_index == ~0)
16931 errmsg ("missing interface name or sw_if_index");
16935 /* Construct the API message */
16936 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16937 mp->sw_if_index = ntohl (sw_if_index);
16938 mp->enable = enable;
16939 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16940 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16941 vec_free (arc_name);
16942 vec_free (feature_name);
16949 api_sw_interface_tag_add_del (vat_main_t * vam)
16951 unformat_input_t *i = vam->input;
16952 vl_api_sw_interface_tag_add_del_t *mp;
16954 u32 sw_if_index = ~0;
16958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16960 if (unformat (i, "tag %s", &tag))
16962 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16966 else if (unformat (i, "del"))
16972 if (sw_if_index == ~0)
16974 errmsg ("missing interface name or sw_if_index");
16978 if (enable && (tag == 0))
16980 errmsg ("no tag specified");
16984 /* Construct the API message */
16985 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16986 mp->sw_if_index = ntohl (sw_if_index);
16987 mp->is_add = enable;
16989 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16996 static void vl_api_l2_xconnect_details_t_handler
16997 (vl_api_l2_xconnect_details_t * mp)
16999 vat_main_t *vam = &vat_main;
17001 print (vam->ofp, "%15d%15d",
17002 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17005 static void vl_api_l2_xconnect_details_t_handler_json
17006 (vl_api_l2_xconnect_details_t * mp)
17008 vat_main_t *vam = &vat_main;
17009 vat_json_node_t *node = NULL;
17011 if (VAT_JSON_ARRAY != vam->json_tree.type)
17013 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17014 vat_json_init_array (&vam->json_tree);
17016 node = vat_json_array_add (&vam->json_tree);
17018 vat_json_init_object (node);
17019 vat_json_object_add_uint (node, "rx_sw_if_index",
17020 ntohl (mp->rx_sw_if_index));
17021 vat_json_object_add_uint (node, "tx_sw_if_index",
17022 ntohl (mp->tx_sw_if_index));
17026 api_l2_xconnect_dump (vat_main_t * vam)
17028 vl_api_l2_xconnect_dump_t *mp;
17031 if (!vam->json_output)
17033 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17036 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
17040 /* Use a control ping for synchronization */
17042 vl_api_control_ping_t *mp;
17043 M (CONTROL_PING, control_ping);
17050 api_sw_interface_set_mtu (vat_main_t * vam)
17052 unformat_input_t *i = vam->input;
17053 vl_api_sw_interface_set_mtu_t *mp;
17055 u32 sw_if_index = ~0;
17058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17060 if (unformat (i, "mtu %d", &mtu))
17062 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17064 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17070 if (sw_if_index == ~0)
17072 errmsg ("missing interface name or sw_if_index");
17078 errmsg ("no mtu specified");
17082 /* Construct the API message */
17083 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17084 mp->sw_if_index = ntohl (sw_if_index);
17085 mp->mtu = ntohs ((u16) mtu);
17093 q_or_quit (vat_main_t * vam)
17095 longjmp (vam->jump_buf, 1);
17096 return 0; /* not so much */
17100 q (vat_main_t * vam)
17102 return q_or_quit (vam);
17106 quit (vat_main_t * vam)
17108 return q_or_quit (vam);
17112 comment (vat_main_t * vam)
17118 cmd_cmp (void *a1, void *a2)
17123 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17127 help (vat_main_t * vam)
17132 unformat_input_t *i = vam->input;
17135 if (unformat (i, "%s", &name))
17139 vec_add1 (name, 0);
17141 hs = hash_get_mem (vam->help_by_name, name);
17143 print (vam->ofp, "usage: %s %s", name, hs[0]);
17145 print (vam->ofp, "No such msg / command '%s'", name);
17150 print (vam->ofp, "Help is available for the following:");
17153 hash_foreach_pair (p, vam->function_by_name,
17155 vec_add1 (cmds, (u8 *)(p->key));
17159 vec_sort_with_function (cmds, cmd_cmp);
17161 for (j = 0; j < vec_len (cmds); j++)
17162 print (vam->ofp, "%s", cmds[j]);
17169 set (vat_main_t * vam)
17171 u8 *name = 0, *value = 0;
17172 unformat_input_t *i = vam->input;
17174 if (unformat (i, "%s", &name))
17176 /* The input buffer is a vector, not a string. */
17177 value = vec_dup (i->buffer);
17178 vec_delete (value, i->index, 0);
17179 /* Almost certainly has a trailing newline */
17180 if (value[vec_len (value) - 1] == '\n')
17181 value[vec_len (value) - 1] = 0;
17182 /* Make sure it's a proper string, one way or the other */
17183 vec_add1 (value, 0);
17184 (void) clib_macro_set_value (&vam->macro_main,
17185 (char *) name, (char *) value);
17188 errmsg ("usage: set <name> <value>");
17196 unset (vat_main_t * vam)
17200 if (unformat (vam->input, "%s", &name))
17201 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17202 errmsg ("unset: %s wasn't set", name);
17215 macro_sort_cmp (void *a1, void *a2)
17217 macro_sort_t *s1 = a1;
17218 macro_sort_t *s2 = a2;
17220 return strcmp ((char *) (s1->name), (char *) (s2->name));
17224 dump_macro_table (vat_main_t * vam)
17226 macro_sort_t *sort_me = 0, *sm;
17231 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17233 vec_add2 (sort_me, sm, 1);
17234 sm->name = (u8 *)(p->key);
17235 sm->value = (u8 *) (p->value[0]);
17239 vec_sort_with_function (sort_me, macro_sort_cmp);
17241 if (vec_len (sort_me))
17242 print (vam->ofp, "%-15s%s", "Name", "Value");
17244 print (vam->ofp, "The macro table is empty...");
17246 for (i = 0; i < vec_len (sort_me); i++)
17247 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17252 dump_node_table (vat_main_t * vam)
17255 vlib_node_t *node, *next_node;
17257 if (vec_len (vam->graph_nodes) == 0)
17259 print (vam->ofp, "Node table empty, issue get_node_graph...");
17263 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17265 node = vam->graph_nodes[i];
17266 print (vam->ofp, "[%d] %s", i, node->name);
17267 for (j = 0; j < vec_len (node->next_nodes); j++)
17269 if (node->next_nodes[j] != ~0)
17271 next_node = vam->graph_nodes[node->next_nodes[j]];
17272 print (vam->ofp, " [%d] %s", j, next_node->name);
17280 value_sort_cmp (void *a1, void *a2)
17282 name_sort_t *n1 = a1;
17283 name_sort_t *n2 = a2;
17285 if (n1->value < n2->value)
17287 if (n1->value > n2->value)
17294 dump_msg_api_table (vat_main_t * vam)
17296 api_main_t *am = &api_main;
17297 name_sort_t *nses = 0, *ns;
17302 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17304 vec_add2 (nses, ns, 1);
17305 ns->name = (u8 *)(hp->key);
17306 ns->value = (u32) hp->value[0];
17310 vec_sort_with_function (nses, value_sort_cmp);
17312 for (i = 0; i < vec_len (nses); i++)
17313 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17319 get_msg_id (vat_main_t * vam)
17324 if (unformat (vam->input, "%s", &name_and_crc))
17326 message_index = vl_api_get_msg_index (name_and_crc);
17327 if (message_index == ~0)
17329 print (vam->ofp, " '%s' not found", name_and_crc);
17332 print (vam->ofp, " '%s' has message index %d",
17333 name_and_crc, message_index);
17336 errmsg ("name_and_crc required...");
17341 search_node_table (vat_main_t * vam)
17343 unformat_input_t *line_input = vam->input;
17346 vlib_node_t *node, *next_node;
17349 if (vam->graph_node_index_by_name == 0)
17351 print (vam->ofp, "Node table empty, issue get_node_graph...");
17355 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17357 if (unformat (line_input, "%s", &node_to_find))
17359 vec_add1 (node_to_find, 0);
17360 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17363 print (vam->ofp, "%s not found...", node_to_find);
17366 node = vam->graph_nodes[p[0]];
17367 print (vam->ofp, "[%d] %s", p[0], node->name);
17368 for (j = 0; j < vec_len (node->next_nodes); j++)
17370 if (node->next_nodes[j] != ~0)
17372 next_node = vam->graph_nodes[node->next_nodes[j]];
17373 print (vam->ofp, " [%d] %s", j, next_node->name);
17380 clib_warning ("parse error '%U'", format_unformat_error,
17386 vec_free (node_to_find);
17395 script (vat_main_t * vam)
17397 #if (VPP_API_TEST_BUILTIN==0)
17399 char *save_current_file;
17400 unformat_input_t save_input;
17401 jmp_buf save_jump_buf;
17402 u32 save_line_number;
17404 FILE *new_fp, *save_ifp;
17406 if (unformat (vam->input, "%s", &s))
17408 new_fp = fopen ((char *) s, "r");
17411 errmsg ("Couldn't open script file %s", s);
17418 errmsg ("Missing script name");
17422 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17423 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17424 save_ifp = vam->ifp;
17425 save_line_number = vam->input_line_number;
17426 save_current_file = (char *) vam->current_file;
17428 vam->input_line_number = 0;
17430 vam->current_file = s;
17433 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17434 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17435 vam->ifp = save_ifp;
17436 vam->input_line_number = save_line_number;
17437 vam->current_file = (u8 *) save_current_file;
17442 clib_warning ("use the exec command...");
17448 echo (vat_main_t * vam)
17450 print (vam->ofp, "%v", vam->input->buffer);
17454 /* List of API message constructors, CLI names map to api_xxx */
17455 #define foreach_vpe_api_msg \
17456 _(create_loopback,"[mac <mac-addr>]") \
17457 _(sw_interface_dump,"") \
17458 _(sw_interface_set_flags, \
17459 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17460 _(sw_interface_add_del_address, \
17461 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17462 _(sw_interface_set_table, \
17463 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17464 _(sw_interface_set_mpls_enable, \
17465 "<intfc> | sw_if_index [disable | dis]") \
17466 _(sw_interface_set_vpath, \
17467 "<intfc> | sw_if_index <id> enable | disable") \
17468 _(sw_interface_set_vxlan_bypass, \
17469 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17470 _(sw_interface_set_l2_xconnect, \
17471 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17472 "enable | disable") \
17473 _(sw_interface_set_l2_bridge, \
17474 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17475 "[shg <split-horizon-group>] [bvi]\n" \
17476 "enable | disable") \
17477 _(bridge_domain_add_del, \
17478 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17479 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17481 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17483 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17485 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17487 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17489 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17491 "<vpp-if-name> | sw_if_index <id>") \
17492 _(sw_interface_tap_dump, "") \
17493 _(ip_add_del_route, \
17494 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17495 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17496 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17497 "[multipath] [count <n>]") \
17498 _(mpls_route_add_del, \
17499 "<label> <eos> via <addr> [table-id <n>]\n" \
17500 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17501 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17502 "[multipath] [count <n>]") \
17503 _(mpls_ip_bind_unbind, \
17504 "<label> <addr/len>") \
17505 _(mpls_tunnel_add_del, \
17506 " via <addr> [table-id <n>]\n" \
17507 "sw_if_index <id>] [l2] [del]") \
17508 _(proxy_arp_add_del, \
17509 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17510 _(proxy_arp_intfc_enable_disable, \
17511 "<intfc> | sw_if_index <id> enable | disable") \
17512 _(sw_interface_set_unnumbered, \
17513 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17514 _(ip_neighbor_add_del, \
17515 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17516 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17517 _(reset_vrf, "vrf <id> [ipv6]") \
17518 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17519 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17520 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17521 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17522 "[outer_vlan_id_any][inner_vlan_id_any]") \
17523 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17524 _(reset_fib, "vrf <n> [ipv6]") \
17525 _(dhcp_proxy_config, \
17526 "svr <v46-address> src <v46-address>\n" \
17527 "insert-cid <n> [del]") \
17528 _(dhcp_proxy_config_2, \
17529 "svr <v46-address> src <v46-address>\n" \
17530 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17531 _(dhcp_proxy_set_vss, \
17532 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17533 _(dhcp_client_config, \
17534 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17535 _(set_ip_flow_hash, \
17536 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17537 _(sw_interface_ip6_enable_disable, \
17538 "<intfc> | sw_if_index <id> enable | disable") \
17539 _(sw_interface_ip6_set_link_local_address, \
17540 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17541 _(sw_interface_ip6nd_ra_prefix, \
17542 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17543 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17544 "[nolink] [isno]") \
17545 _(sw_interface_ip6nd_ra_config, \
17546 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17547 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17548 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17549 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17550 _(l2_patch_add_del, \
17551 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17552 "enable | disable") \
17553 _(sr_tunnel_add_del, \
17554 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17555 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17556 "[policy <policy_name>]") \
17557 _(sr_policy_add_del, \
17558 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17559 _(sr_multicast_map_add_del, \
17560 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17561 _(classify_add_del_table, \
17562 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17563 " [del] [del-chain] mask <mask-value>\n" \
17564 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17565 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17566 _(classify_add_del_session, \
17567 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17568 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17569 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17570 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17571 _(classify_set_interface_ip_table, \
17572 "<intfc> | sw_if_index <nn> table <nn>") \
17573 _(classify_set_interface_l2_tables, \
17574 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17575 " [other-table <nn>]") \
17576 _(get_node_index, "node <node-name") \
17577 _(add_node_next, "node <node-name> next <next-node-name>") \
17578 _(l2tpv3_create_tunnel, \
17579 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17580 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17581 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17582 _(l2tpv3_set_tunnel_cookies, \
17583 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17584 "[new_remote_cookie <nn>]\n") \
17585 _(l2tpv3_interface_enable_disable, \
17586 "<intfc> | sw_if_index <nn> enable | disable") \
17587 _(l2tpv3_set_lookup_key, \
17588 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17589 _(sw_if_l2tpv3_tunnel_dump, "") \
17590 _(vxlan_add_del_tunnel, \
17591 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17592 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17593 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17594 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17595 _(gre_add_del_tunnel, \
17596 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17597 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17598 _(l2_fib_clear_table, "") \
17599 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17600 _(l2_interface_vlan_tag_rewrite, \
17601 "<intfc> | sw_if_index <nn> \n" \
17602 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17603 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17604 _(create_vhost_user_if, \
17605 "socket <filename> [server] [renumber <dev_instance>] " \
17606 "[mac <mac_address>]") \
17607 _(modify_vhost_user_if, \
17608 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17609 "[server] [renumber <dev_instance>]") \
17610 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17611 _(sw_interface_vhost_user_dump, "") \
17612 _(show_version, "") \
17613 _(vxlan_gpe_add_del_tunnel, \
17614 "local <addr> remote <addr> vni <nn>\n" \
17615 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17616 "[next-ethernet] [next-nsh]\n") \
17617 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17618 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17619 _(interface_name_renumber, \
17620 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17621 _(input_acl_set_interface, \
17622 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17623 " [l2-table <nn>] [del]") \
17624 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17625 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17626 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17627 _(ip_dump, "ipv4 | ipv6") \
17628 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17629 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17631 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17632 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17633 " integ_alg <alg> integ_key <hex>") \
17634 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17635 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17636 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17637 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17638 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17639 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17640 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17641 "(auth_data 0x<data> | auth_data <data>)") \
17642 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17643 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17644 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17645 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17646 "(local|remote)") \
17647 _(ikev2_set_local_key, "file <absolute_file_path>") \
17648 _(delete_loopback,"sw_if_index <nn>") \
17649 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17650 _(map_add_domain, \
17651 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17652 "ip6-src <ip6addr> " \
17653 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17654 _(map_del_domain, "index <n>") \
17655 _(map_add_del_rule, \
17656 "index <n> psid <n> dst <ip6addr> [del]") \
17657 _(map_domain_dump, "") \
17658 _(map_rule_dump, "index <map-domain>") \
17659 _(want_interface_events, "enable|disable") \
17660 _(want_stats,"enable|disable") \
17661 _(get_first_msg_id, "client <name>") \
17662 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17663 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17664 "fib-id <nn> [ip4][ip6][default]") \
17665 _(get_node_graph, " ") \
17666 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17667 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17668 _(ioam_disable, "") \
17669 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17670 " sw_if_index <sw_if_index> p <priority> " \
17671 "w <weight>] [del]") \
17672 _(lisp_add_del_locator, "locator-set <locator_name> " \
17673 "iface <intf> | sw_if_index <sw_if_index> " \
17674 "p <priority> w <weight> [del]") \
17675 _(lisp_add_del_local_eid,"vni <vni> eid " \
17676 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17677 "locator-set <locator_name> [del]" \
17678 "[key-id sha1|sha256 secret-key <secret-key>]") \
17679 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
17680 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
17681 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17682 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17683 _(lisp_gpe_enable_disable, "enable|disable") \
17684 _(lisp_enable_disable, "enable|disable") \
17685 _(lisp_map_register_enable_disable, "enable|disable") \
17686 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17687 _(lisp_gpe_add_del_iface, "up|down") \
17688 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17690 "rloc <locator> p <prio> " \
17691 "w <weight> [rloc <loc> ... ] " \
17692 "action <action> [del-all]") \
17693 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17695 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17696 _(lisp_map_request_mode, "src-dst|dst-only") \
17697 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17698 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17699 _(lisp_locator_set_dump, "[local | remote]") \
17700 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17701 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17702 "[local] | [remote]") \
17703 _(lisp_eid_table_vni_dump, "") \
17704 _(lisp_eid_table_map_dump, "l2|l3") \
17705 _(lisp_gpe_tunnel_dump, "") \
17706 _(lisp_map_resolver_dump, "") \
17707 _(lisp_map_server_dump, "") \
17708 _(lisp_adjacencies_get, "vni <vni>") \
17709 _(show_lisp_rloc_probe_state, "") \
17710 _(show_lisp_map_register_state, "") \
17711 _(show_lisp_status, "") \
17712 _(lisp_get_map_request_itr_rlocs, "") \
17713 _(show_lisp_pitr, "") \
17714 _(show_lisp_map_request_mode, "") \
17715 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17716 _(af_packet_delete, "name <host interface name>") \
17717 _(policer_add_del, "name <policer name> <params> [del]") \
17718 _(policer_dump, "[name <policer name>]") \
17719 _(policer_classify_set_interface, \
17720 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17721 " [l2-table <nn>] [del]") \
17722 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17723 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17724 "[master|slave]") \
17725 _(netmap_delete, "name <interface name>") \
17726 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17727 _(mpls_fib_dump, "") \
17728 _(classify_table_ids, "") \
17729 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17730 _(classify_table_info, "table_id <nn>") \
17731 _(classify_session_dump, "table_id <nn>") \
17732 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17733 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17734 "[template_interval <nn>] [udp_checksum]") \
17735 _(ipfix_exporter_dump, "") \
17736 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17737 _(ipfix_classify_stream_dump, "") \
17738 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17739 _(ipfix_classify_table_dump, "") \
17740 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17741 _(sw_interface_span_dump, "") \
17742 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17743 _(pg_create_interface, "if_id <nn>") \
17744 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17745 _(pg_enable_disable, "[stream <id>] disable") \
17746 _(ip_source_and_port_range_check_add_del, \
17747 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17748 _(ip_source_and_port_range_check_interface_add_del, \
17749 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17750 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17751 _(ipsec_gre_add_del_tunnel, \
17752 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17753 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17754 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17755 _(l2_interface_pbb_tag_rewrite, \
17756 "<intfc> | sw_if_index <nn> \n" \
17757 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17758 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17759 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17760 _(flow_classify_set_interface, \
17761 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17762 _(flow_classify_dump, "type [ip4|ip6]") \
17763 _(ip_fib_dump, "") \
17764 _(ip6_fib_dump, "") \
17765 _(feature_enable_disable, "arc_name <arc_name> " \
17766 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17767 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17769 _(l2_xconnect_dump, "") \
17770 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17771 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17772 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17775 #define foreach_vpe_dpdk_api_msg \
17776 _(sw_interface_set_dpdk_hqos_pipe, \
17777 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17778 "profile <profile-id>\n") \
17779 _(sw_interface_set_dpdk_hqos_subport, \
17780 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17781 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17782 _(sw_interface_set_dpdk_hqos_tctbl, \
17783 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
17786 /* List of command functions, CLI names map directly to functions */
17787 #define foreach_cli_function \
17788 _(comment, "usage: comment <ignore-rest-of-line>") \
17789 _(dump_interface_table, "usage: dump_interface_table") \
17790 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17791 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17792 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17793 _(dump_stats_table, "usage: dump_stats_table") \
17794 _(dump_macro_table, "usage: dump_macro_table ") \
17795 _(dump_node_table, "usage: dump_node_table") \
17796 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17797 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17798 _(echo, "usage: echo <message>") \
17799 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17800 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17801 _(help, "usage: help") \
17802 _(q, "usage: quit") \
17803 _(quit, "usage: quit") \
17804 _(search_node_table, "usage: search_node_table <name>...") \
17805 _(set, "usage: set <variable-name> <value>") \
17806 _(script, "usage: script <file-name>") \
17807 _(unset, "usage: unset <variable-name>")
17810 static void vl_api_##n##_t_handler_uni \
17811 (vl_api_##n##_t * mp) \
17813 vat_main_t * vam = &vat_main; \
17814 if (vam->json_output) { \
17815 vl_api_##n##_t_handler_json(mp); \
17817 vl_api_##n##_t_handler(mp); \
17820 foreach_vpe_api_reply_msg;
17825 static void vl_api_##n##_t_handler_uni \
17826 (vl_api_##n##_t * mp) \
17828 vat_main_t * vam = &vat_main; \
17829 if (vam->json_output) { \
17830 vl_api_##n##_t_handler_json(mp); \
17832 vl_api_##n##_t_handler(mp); \
17835 foreach_vpe_dpdk_api_reply_msg;
17840 vat_api_hookup (vat_main_t * vam)
17843 vl_msg_api_set_handlers(VL_API_##N, #n, \
17844 vl_api_##n##_t_handler_uni, \
17846 vl_api_##n##_t_endian, \
17847 vl_api_##n##_t_print, \
17848 sizeof(vl_api_##n##_t), 1);
17849 foreach_vpe_api_reply_msg;
17854 vl_msg_api_set_handlers(VL_API_##N, #n, \
17855 vl_api_##n##_t_handler_uni, \
17857 vl_api_##n##_t_endian, \
17858 vl_api_##n##_t_print, \
17859 sizeof(vl_api_##n##_t), 1);
17860 foreach_vpe_dpdk_api_reply_msg;
17864 #if (VPP_API_TEST_BUILTIN==0)
17865 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17868 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17870 vam->function_by_name = hash_create_string (0, sizeof (uword));
17872 vam->help_by_name = hash_create_string (0, sizeof (uword));
17874 /* API messages we can send */
17875 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17876 foreach_vpe_api_msg;
17879 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17880 foreach_vpe_dpdk_api_msg;
17885 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17886 foreach_vpe_api_msg;
17889 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17890 foreach_vpe_dpdk_api_msg;
17894 /* CLI functions */
17895 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17896 foreach_cli_function;
17900 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17901 foreach_cli_function;
17906 * fd.io coding-style-patch-verification: ON
17909 * eval: (c-set-style "gnu")