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 vl_api_show_lisp_map_register_state_reply_t_handler
2457 (vl_api_show_lisp_map_register_state_reply_t * mp)
2459 vat_main_t *vam = &vat_main;
2460 int retval = clib_net_to_host_u32 (mp->retval);
2462 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2464 vam->retval = retval;
2465 vam->result_ready = 1;
2469 vl_api_show_lisp_map_register_state_reply_t_handler_json
2470 (vl_api_show_lisp_map_register_state_reply_t * mp)
2472 vat_main_t *vam = &vat_main;
2473 vat_json_node_t _node, *node = &_node;
2474 int retval = clib_net_to_host_u32 (mp->retval);
2476 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2478 vat_json_init_object (node);
2479 vat_json_object_add_string_copy (node, "state", s);
2481 vat_json_print (vam->ofp, node);
2482 vat_json_free (node);
2484 vam->retval = retval;
2485 vam->result_ready = 1;
2490 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2491 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2493 vat_main_t *vam = &vat_main;
2494 int retval = clib_net_to_host_u32 (mp->retval);
2499 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2501 vam->retval = retval;
2502 vam->result_ready = 1;
2506 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2507 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2509 vat_main_t *vam = &vat_main;
2510 vat_json_node_t _node, *node = &_node;
2511 int retval = clib_net_to_host_u32 (mp->retval);
2513 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2514 vat_json_init_object (node);
2515 vat_json_object_add_string_copy (node, "state", s);
2517 vat_json_print (vam->ofp, node);
2518 vat_json_free (node);
2520 vam->retval = retval;
2521 vam->result_ready = 1;
2526 vl_api_lisp_adjacencies_get_reply_t_handler
2527 (vl_api_lisp_adjacencies_get_reply_t * mp)
2529 vat_main_t *vam = &vat_main;
2531 int retval = clib_net_to_host_u32 (mp->retval);
2532 vl_api_lisp_adjacency_t *a;
2537 n = clib_net_to_host_u32 (mp->count);
2539 for (i = 0; i < n; i++)
2541 a = &mp->adjacencies[i];
2542 print (vam->ofp, "%U %40U",
2543 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2544 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2548 vam->retval = retval;
2549 vam->result_ready = 1;
2553 vl_api_lisp_adjacencies_get_reply_t_handler_json
2554 (vl_api_lisp_adjacencies_get_reply_t * mp)
2557 vat_main_t *vam = &vat_main;
2558 vat_json_node_t *e = 0, root;
2560 int retval = clib_net_to_host_u32 (mp->retval);
2561 vl_api_lisp_adjacency_t *a;
2566 n = clib_net_to_host_u32 (mp->count);
2567 vat_json_init_array (&root);
2569 for (i = 0; i < n; i++)
2571 e = vat_json_array_add (&root);
2572 a = &mp->adjacencies[i];
2574 vat_json_init_object (e);
2575 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2576 a->leid_prefix_len);
2578 vat_json_object_add_string_copy (e, "leid", s);
2581 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2582 a->reid_prefix_len);
2584 vat_json_object_add_string_copy (e, "reid", s);
2588 vat_json_print (vam->ofp, &root);
2589 vat_json_free (&root);
2592 vam->retval = retval;
2593 vam->result_ready = 1;
2597 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2600 vat_main_t *vam = &vat_main;
2602 print (vam->ofp, "%=20U",
2603 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2608 vl_api_lisp_map_server_details_t_handler_json
2609 (vl_api_lisp_map_server_details_t * mp)
2611 vat_main_t *vam = &vat_main;
2612 vat_json_node_t *node = NULL;
2613 struct in6_addr ip6;
2616 if (VAT_JSON_ARRAY != vam->json_tree.type)
2618 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2619 vat_json_init_array (&vam->json_tree);
2621 node = vat_json_array_add (&vam->json_tree);
2623 vat_json_init_object (node);
2626 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2627 vat_json_object_add_ip6 (node, "map-server", ip6);
2631 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2632 vat_json_object_add_ip4 (node, "map-server", ip4);
2637 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2640 vat_main_t *vam = &vat_main;
2642 print (vam->ofp, "%=20U",
2643 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2648 vl_api_lisp_map_resolver_details_t_handler_json
2649 (vl_api_lisp_map_resolver_details_t * mp)
2651 vat_main_t *vam = &vat_main;
2652 vat_json_node_t *node = NULL;
2653 struct in6_addr ip6;
2656 if (VAT_JSON_ARRAY != vam->json_tree.type)
2658 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2659 vat_json_init_array (&vam->json_tree);
2661 node = vat_json_array_add (&vam->json_tree);
2663 vat_json_init_object (node);
2666 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2667 vat_json_object_add_ip6 (node, "map resolver", ip6);
2671 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2672 vat_json_object_add_ip4 (node, "map resolver", ip4);
2677 vl_api_show_lisp_status_reply_t_handler
2678 (vl_api_show_lisp_status_reply_t * mp)
2680 vat_main_t *vam = &vat_main;
2681 i32 retval = ntohl (mp->retval);
2685 print (vam->ofp, "feature: %s\ngpe: %s",
2686 mp->feature_status ? "enabled" : "disabled",
2687 mp->gpe_status ? "enabled" : "disabled");
2690 vam->retval = retval;
2691 vam->result_ready = 1;
2695 vl_api_show_lisp_status_reply_t_handler_json
2696 (vl_api_show_lisp_status_reply_t * mp)
2698 vat_main_t *vam = &vat_main;
2699 vat_json_node_t node;
2700 u8 *gpe_status = NULL;
2701 u8 *feature_status = NULL;
2703 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2704 feature_status = format (0, "%s",
2705 mp->feature_status ? "enabled" : "disabled");
2706 vec_add1 (gpe_status, 0);
2707 vec_add1 (feature_status, 0);
2709 vat_json_init_object (&node);
2710 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2711 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2713 vec_free (gpe_status);
2714 vec_free (feature_status);
2716 vat_json_print (vam->ofp, &node);
2717 vat_json_free (&node);
2719 vam->retval = ntohl (mp->retval);
2720 vam->result_ready = 1;
2724 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2725 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 i32 retval = ntohl (mp->retval);
2732 print (vam->ofp, "%=20s", mp->locator_set_name);
2735 vam->retval = retval;
2736 vam->result_ready = 1;
2740 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2741 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2743 vat_main_t *vam = &vat_main;
2744 vat_json_node_t *node = NULL;
2746 if (VAT_JSON_ARRAY != vam->json_tree.type)
2748 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2749 vat_json_init_array (&vam->json_tree);
2751 node = vat_json_array_add (&vam->json_tree);
2753 vat_json_init_object (node);
2754 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2756 vat_json_print (vam->ofp, node);
2757 vat_json_free (node);
2759 vam->retval = ntohl (mp->retval);
2760 vam->result_ready = 1;
2764 format_lisp_map_request_mode (u8 * s, va_list * args)
2766 u32 mode = va_arg (*args, u32);
2771 return format (0, "dst-only");
2773 return format (0, "src-dst");
2779 vl_api_show_lisp_map_request_mode_reply_t_handler
2780 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2782 vat_main_t *vam = &vat_main;
2783 i32 retval = ntohl (mp->retval);
2787 u32 mode = mp->mode;
2788 print (vam->ofp, "map_request_mode: %U",
2789 format_lisp_map_request_mode, mode);
2792 vam->retval = retval;
2793 vam->result_ready = 1;
2797 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2798 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2800 vat_main_t *vam = &vat_main;
2801 vat_json_node_t node;
2806 s = format (0, "%U", format_lisp_map_request_mode, mode);
2809 vat_json_init_object (&node);
2810 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2811 vat_json_print (vam->ofp, &node);
2812 vat_json_free (&node);
2815 vam->retval = ntohl (mp->retval);
2816 vam->result_ready = 1;
2820 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2822 vat_main_t *vam = &vat_main;
2823 i32 retval = ntohl (mp->retval);
2827 print (vam->ofp, "%-20s%-16s",
2828 mp->status ? "enabled" : "disabled",
2829 mp->status ? (char *) mp->locator_set_name : "");
2832 vam->retval = retval;
2833 vam->result_ready = 1;
2837 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2840 vat_main_t *vam = &vat_main;
2841 vat_json_node_t node;
2844 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2845 vec_add1 (status, 0);
2847 vat_json_init_object (&node);
2848 vat_json_object_add_string_copy (&node, "status", status);
2851 vat_json_object_add_string_copy (&node, "locator_set",
2852 mp->locator_set_name);
2857 vat_json_print (vam->ofp, &node);
2858 vat_json_free (&node);
2860 vam->retval = ntohl (mp->retval);
2861 vam->result_ready = 1;
2865 format_policer_type (u8 * s, va_list * va)
2867 u32 i = va_arg (*va, u32);
2869 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2870 s = format (s, "1r2c");
2871 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2872 s = format (s, "1r3c");
2873 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2874 s = format (s, "2r3c-2698");
2875 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2876 s = format (s, "2r3c-4115");
2877 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2878 s = format (s, "2r3c-mef5cf1");
2880 s = format (s, "ILLEGAL");
2885 format_policer_rate_type (u8 * s, va_list * va)
2887 u32 i = va_arg (*va, u32);
2889 if (i == SSE2_QOS_RATE_KBPS)
2890 s = format (s, "kbps");
2891 else if (i == SSE2_QOS_RATE_PPS)
2892 s = format (s, "pps");
2894 s = format (s, "ILLEGAL");
2899 format_policer_round_type (u8 * s, va_list * va)
2901 u32 i = va_arg (*va, u32);
2903 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2904 s = format (s, "closest");
2905 else if (i == SSE2_QOS_ROUND_TO_UP)
2906 s = format (s, "up");
2907 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2908 s = format (s, "down");
2910 s = format (s, "ILLEGAL");
2915 format_policer_action_type (u8 * s, va_list * va)
2917 u32 i = va_arg (*va, u32);
2919 if (i == SSE2_QOS_ACTION_DROP)
2920 s = format (s, "drop");
2921 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2922 s = format (s, "transmit");
2923 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2924 s = format (s, "mark-and-transmit");
2926 s = format (s, "ILLEGAL");
2931 format_dscp (u8 * s, va_list * va)
2933 u32 i = va_arg (*va, u32);
2938 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2942 return format (s, "ILLEGAL");
2944 s = format (s, "%s", t);
2949 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2951 vat_main_t *vam = &vat_main;
2952 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2954 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2955 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2957 conform_dscp_str = format (0, "");
2959 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2960 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2962 exceed_dscp_str = format (0, "");
2964 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2965 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2967 violate_dscp_str = format (0, "");
2969 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2970 "rate type %U, round type %U, %s rate, %s color-aware, "
2971 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2972 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2973 "conform action %U%s, exceed action %U%s, violate action %U%s",
2975 format_policer_type, mp->type,
2978 clib_net_to_host_u64 (mp->cb),
2979 clib_net_to_host_u64 (mp->eb),
2980 format_policer_rate_type, mp->rate_type,
2981 format_policer_round_type, mp->round_type,
2982 mp->single_rate ? "single" : "dual",
2983 mp->color_aware ? "is" : "not",
2984 ntohl (mp->cir_tokens_per_period),
2985 ntohl (mp->pir_tokens_per_period),
2987 ntohl (mp->current_limit),
2988 ntohl (mp->current_bucket),
2989 ntohl (mp->extended_limit),
2990 ntohl (mp->extended_bucket),
2991 clib_net_to_host_u64 (mp->last_update_time),
2992 format_policer_action_type, mp->conform_action_type,
2994 format_policer_action_type, mp->exceed_action_type,
2996 format_policer_action_type, mp->violate_action_type,
2999 vec_free (conform_dscp_str);
3000 vec_free (exceed_dscp_str);
3001 vec_free (violate_dscp_str);
3004 static void vl_api_policer_details_t_handler_json
3005 (vl_api_policer_details_t * mp)
3007 vat_main_t *vam = &vat_main;
3008 vat_json_node_t *node;
3009 u8 *rate_type_str, *round_type_str, *type_str;
3010 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3012 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3014 format (0, "%U", format_policer_round_type, mp->round_type);
3015 type_str = format (0, "%U", format_policer_type, mp->type);
3016 conform_action_str = format (0, "%U", format_policer_action_type,
3017 mp->conform_action_type);
3018 exceed_action_str = format (0, "%U", format_policer_action_type,
3019 mp->exceed_action_type);
3020 violate_action_str = format (0, "%U", format_policer_action_type,
3021 mp->violate_action_type);
3023 if (VAT_JSON_ARRAY != vam->json_tree.type)
3025 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3026 vat_json_init_array (&vam->json_tree);
3028 node = vat_json_array_add (&vam->json_tree);
3030 vat_json_init_object (node);
3031 vat_json_object_add_string_copy (node, "name", mp->name);
3032 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3033 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3034 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3035 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3036 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3037 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3038 vat_json_object_add_string_copy (node, "type", type_str);
3039 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3040 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3041 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3042 vat_json_object_add_uint (node, "cir_tokens_per_period",
3043 ntohl (mp->cir_tokens_per_period));
3044 vat_json_object_add_uint (node, "eir_tokens_per_period",
3045 ntohl (mp->pir_tokens_per_period));
3046 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3047 vat_json_object_add_uint (node, "current_bucket",
3048 ntohl (mp->current_bucket));
3049 vat_json_object_add_uint (node, "extended_limit",
3050 ntohl (mp->extended_limit));
3051 vat_json_object_add_uint (node, "extended_bucket",
3052 ntohl (mp->extended_bucket));
3053 vat_json_object_add_uint (node, "last_update_time",
3054 ntohl (mp->last_update_time));
3055 vat_json_object_add_string_copy (node, "conform_action",
3056 conform_action_str);
3057 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3059 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3060 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3061 vec_free (dscp_str);
3063 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3064 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3066 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3067 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3068 vec_free (dscp_str);
3070 vat_json_object_add_string_copy (node, "violate_action",
3071 violate_action_str);
3072 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3074 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3075 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3076 vec_free (dscp_str);
3079 vec_free (rate_type_str);
3080 vec_free (round_type_str);
3081 vec_free (type_str);
3082 vec_free (conform_action_str);
3083 vec_free (exceed_action_str);
3084 vec_free (violate_action_str);
3088 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3091 vat_main_t *vam = &vat_main;
3092 int i, count = ntohl (mp->count);
3095 print (vam->ofp, "classify table ids (%d) : ", count);
3096 for (i = 0; i < count; i++)
3098 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3099 print (vam->ofp, (i < count - 1) ? "," : "");
3101 vam->retval = ntohl (mp->retval);
3102 vam->result_ready = 1;
3106 vl_api_classify_table_ids_reply_t_handler_json
3107 (vl_api_classify_table_ids_reply_t * mp)
3109 vat_main_t *vam = &vat_main;
3110 int i, count = ntohl (mp->count);
3114 vat_json_node_t node;
3116 vat_json_init_object (&node);
3117 for (i = 0; i < count; i++)
3119 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3121 vat_json_print (vam->ofp, &node);
3122 vat_json_free (&node);
3124 vam->retval = ntohl (mp->retval);
3125 vam->result_ready = 1;
3129 vl_api_classify_table_by_interface_reply_t_handler
3130 (vl_api_classify_table_by_interface_reply_t * mp)
3132 vat_main_t *vam = &vat_main;
3135 table_id = ntohl (mp->l2_table_id);
3137 print (vam->ofp, "l2 table id : %d", table_id);
3139 print (vam->ofp, "l2 table id : No input ACL tables configured");
3140 table_id = ntohl (mp->ip4_table_id);
3142 print (vam->ofp, "ip4 table id : %d", table_id);
3144 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3145 table_id = ntohl (mp->ip6_table_id);
3147 print (vam->ofp, "ip6 table id : %d", table_id);
3149 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3150 vam->retval = ntohl (mp->retval);
3151 vam->result_ready = 1;
3155 vl_api_classify_table_by_interface_reply_t_handler_json
3156 (vl_api_classify_table_by_interface_reply_t * mp)
3158 vat_main_t *vam = &vat_main;
3159 vat_json_node_t node;
3161 vat_json_init_object (&node);
3163 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3164 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3165 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3167 vat_json_print (vam->ofp, &node);
3168 vat_json_free (&node);
3170 vam->retval = ntohl (mp->retval);
3171 vam->result_ready = 1;
3174 static void vl_api_policer_add_del_reply_t_handler
3175 (vl_api_policer_add_del_reply_t * mp)
3177 vat_main_t *vam = &vat_main;
3178 i32 retval = ntohl (mp->retval);
3179 if (vam->async_mode)
3181 vam->async_errors += (retval < 0);
3185 vam->retval = retval;
3186 vam->result_ready = 1;
3187 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3189 * Note: this is just barely thread-safe, depends on
3190 * the main thread spinning waiting for an answer...
3192 errmsg ("policer index %d", ntohl (mp->policer_index));
3196 static void vl_api_policer_add_del_reply_t_handler_json
3197 (vl_api_policer_add_del_reply_t * mp)
3199 vat_main_t *vam = &vat_main;
3200 vat_json_node_t node;
3202 vat_json_init_object (&node);
3203 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3204 vat_json_object_add_uint (&node, "policer_index",
3205 ntohl (mp->policer_index));
3207 vat_json_print (vam->ofp, &node);
3208 vat_json_free (&node);
3210 vam->retval = ntohl (mp->retval);
3211 vam->result_ready = 1;
3214 /* Format hex dump. */
3216 format_hex_bytes (u8 * s, va_list * va)
3218 u8 *bytes = va_arg (*va, u8 *);
3219 int n_bytes = va_arg (*va, int);
3222 /* Print short or long form depending on byte count. */
3223 uword short_form = n_bytes <= 32;
3224 uword indent = format_get_indent (s);
3229 for (i = 0; i < n_bytes; i++)
3231 if (!short_form && (i % 32) == 0)
3232 s = format (s, "%08x: ", i);
3233 s = format (s, "%02x", bytes[i]);
3234 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3235 s = format (s, "\n%U", format_white_space, indent);
3242 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3245 vat_main_t *vam = &vat_main;
3246 i32 retval = ntohl (mp->retval);
3249 print (vam->ofp, "classify table info :");
3250 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3251 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3252 ntohl (mp->miss_next_index));
3253 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3254 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3255 ntohl (mp->match_n_vectors));
3256 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3257 ntohl (mp->mask_length));
3259 vam->retval = retval;
3260 vam->result_ready = 1;
3264 vl_api_classify_table_info_reply_t_handler_json
3265 (vl_api_classify_table_info_reply_t * mp)
3267 vat_main_t *vam = &vat_main;
3268 vat_json_node_t node;
3270 i32 retval = ntohl (mp->retval);
3273 vat_json_init_object (&node);
3275 vat_json_object_add_int (&node, "sessions",
3276 ntohl (mp->active_sessions));
3277 vat_json_object_add_int (&node, "nexttbl",
3278 ntohl (mp->next_table_index));
3279 vat_json_object_add_int (&node, "nextnode",
3280 ntohl (mp->miss_next_index));
3281 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3282 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3283 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3284 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3285 ntohl (mp->mask_length), 0);
3286 vat_json_object_add_string_copy (&node, "mask", s);
3288 vat_json_print (vam->ofp, &node);
3289 vat_json_free (&node);
3291 vam->retval = ntohl (mp->retval);
3292 vam->result_ready = 1;
3296 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3299 vat_main_t *vam = &vat_main;
3301 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3302 ntohl (mp->hit_next_index), ntohl (mp->advance),
3303 ntohl (mp->opaque_index));
3304 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3305 ntohl (mp->match_length));
3309 vl_api_classify_session_details_t_handler_json
3310 (vl_api_classify_session_details_t * mp)
3312 vat_main_t *vam = &vat_main;
3313 vat_json_node_t *node = NULL;
3315 if (VAT_JSON_ARRAY != vam->json_tree.type)
3317 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3318 vat_json_init_array (&vam->json_tree);
3320 node = vat_json_array_add (&vam->json_tree);
3322 vat_json_init_object (node);
3323 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3324 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3325 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3327 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3329 vat_json_object_add_string_copy (node, "match", s);
3332 static void vl_api_pg_create_interface_reply_t_handler
3333 (vl_api_pg_create_interface_reply_t * mp)
3335 vat_main_t *vam = &vat_main;
3337 vam->retval = ntohl (mp->retval);
3338 vam->result_ready = 1;
3341 static void vl_api_pg_create_interface_reply_t_handler_json
3342 (vl_api_pg_create_interface_reply_t * mp)
3344 vat_main_t *vam = &vat_main;
3345 vat_json_node_t node;
3347 i32 retval = ntohl (mp->retval);
3350 vat_json_init_object (&node);
3352 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3354 vat_json_print (vam->ofp, &node);
3355 vat_json_free (&node);
3357 vam->retval = ntohl (mp->retval);
3358 vam->result_ready = 1;
3361 static void vl_api_policer_classify_details_t_handler
3362 (vl_api_policer_classify_details_t * mp)
3364 vat_main_t *vam = &vat_main;
3366 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3367 ntohl (mp->table_index));
3370 static void vl_api_policer_classify_details_t_handler_json
3371 (vl_api_policer_classify_details_t * mp)
3373 vat_main_t *vam = &vat_main;
3374 vat_json_node_t *node;
3376 if (VAT_JSON_ARRAY != vam->json_tree.type)
3378 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3379 vat_json_init_array (&vam->json_tree);
3381 node = vat_json_array_add (&vam->json_tree);
3383 vat_json_init_object (node);
3384 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3385 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3388 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3389 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3391 vat_main_t *vam = &vat_main;
3392 i32 retval = ntohl (mp->retval);
3393 if (vam->async_mode)
3395 vam->async_errors += (retval < 0);
3399 vam->retval = retval;
3400 vam->sw_if_index = ntohl (mp->sw_if_index);
3401 vam->result_ready = 1;
3405 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3406 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3408 vat_main_t *vam = &vat_main;
3409 vat_json_node_t node;
3411 vat_json_init_object (&node);
3412 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3413 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3415 vat_json_print (vam->ofp, &node);
3416 vat_json_free (&node);
3418 vam->retval = ntohl (mp->retval);
3419 vam->result_ready = 1;
3422 static void vl_api_flow_classify_details_t_handler
3423 (vl_api_flow_classify_details_t * mp)
3425 vat_main_t *vam = &vat_main;
3427 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3428 ntohl (mp->table_index));
3431 static void vl_api_flow_classify_details_t_handler_json
3432 (vl_api_flow_classify_details_t * mp)
3434 vat_main_t *vam = &vat_main;
3435 vat_json_node_t *node;
3437 if (VAT_JSON_ARRAY != vam->json_tree.type)
3439 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3440 vat_json_init_array (&vam->json_tree);
3442 node = vat_json_array_add (&vam->json_tree);
3444 vat_json_init_object (node);
3445 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3446 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3451 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3452 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3453 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3454 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3455 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3456 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3459 * Generate boilerplate reply handlers, which
3460 * dig the return value out of the xxx_reply_t API message,
3461 * stick it into vam->retval, and set vam->result_ready
3463 * Could also do this by pointing N message decode slots at
3464 * a single function, but that could break in subtle ways.
3467 #define foreach_standard_reply_retval_handler \
3468 _(sw_interface_set_flags_reply) \
3469 _(sw_interface_add_del_address_reply) \
3470 _(sw_interface_set_table_reply) \
3471 _(sw_interface_set_mpls_enable_reply) \
3472 _(sw_interface_set_vpath_reply) \
3473 _(sw_interface_set_vxlan_bypass_reply) \
3474 _(sw_interface_set_l2_bridge_reply) \
3475 _(bridge_domain_add_del_reply) \
3476 _(sw_interface_set_l2_xconnect_reply) \
3477 _(l2fib_add_del_reply) \
3478 _(ip_add_del_route_reply) \
3479 _(mpls_route_add_del_reply) \
3480 _(mpls_ip_bind_unbind_reply) \
3481 _(proxy_arp_add_del_reply) \
3482 _(proxy_arp_intfc_enable_disable_reply) \
3483 _(sw_interface_set_unnumbered_reply) \
3484 _(ip_neighbor_add_del_reply) \
3485 _(reset_vrf_reply) \
3486 _(oam_add_del_reply) \
3487 _(reset_fib_reply) \
3488 _(dhcp_proxy_config_reply) \
3489 _(dhcp_proxy_config_2_reply) \
3490 _(dhcp_proxy_set_vss_reply) \
3491 _(dhcp_client_config_reply) \
3492 _(set_ip_flow_hash_reply) \
3493 _(sw_interface_ip6_enable_disable_reply) \
3494 _(sw_interface_ip6_set_link_local_address_reply) \
3495 _(sw_interface_ip6nd_ra_prefix_reply) \
3496 _(sw_interface_ip6nd_ra_config_reply) \
3497 _(set_arp_neighbor_limit_reply) \
3498 _(l2_patch_add_del_reply) \
3499 _(sr_tunnel_add_del_reply) \
3500 _(sr_policy_add_del_reply) \
3501 _(sr_multicast_map_add_del_reply) \
3502 _(classify_add_del_session_reply) \
3503 _(classify_set_interface_ip_table_reply) \
3504 _(classify_set_interface_l2_tables_reply) \
3505 _(l2tpv3_set_tunnel_cookies_reply) \
3506 _(l2tpv3_interface_enable_disable_reply) \
3507 _(l2tpv3_set_lookup_key_reply) \
3508 _(l2_fib_clear_table_reply) \
3509 _(l2_interface_efp_filter_reply) \
3510 _(l2_interface_vlan_tag_rewrite_reply) \
3511 _(modify_vhost_user_if_reply) \
3512 _(delete_vhost_user_if_reply) \
3513 _(want_ip4_arp_events_reply) \
3514 _(want_ip6_nd_events_reply) \
3515 _(input_acl_set_interface_reply) \
3516 _(ipsec_spd_add_del_reply) \
3517 _(ipsec_interface_add_del_spd_reply) \
3518 _(ipsec_spd_add_del_entry_reply) \
3519 _(ipsec_sad_add_del_entry_reply) \
3520 _(ipsec_sa_set_key_reply) \
3521 _(ikev2_profile_add_del_reply) \
3522 _(ikev2_profile_set_auth_reply) \
3523 _(ikev2_profile_set_id_reply) \
3524 _(ikev2_profile_set_ts_reply) \
3525 _(ikev2_set_local_key_reply) \
3526 _(delete_loopback_reply) \
3527 _(bd_ip_mac_add_del_reply) \
3528 _(map_del_domain_reply) \
3529 _(map_add_del_rule_reply) \
3530 _(want_interface_events_reply) \
3531 _(want_stats_reply) \
3532 _(cop_interface_enable_disable_reply) \
3533 _(cop_whitelist_enable_disable_reply) \
3534 _(sw_interface_clear_stats_reply) \
3535 _(ioam_enable_reply) \
3536 _(ioam_disable_reply) \
3537 _(lisp_add_del_locator_reply) \
3538 _(lisp_add_del_local_eid_reply) \
3539 _(lisp_add_del_remote_mapping_reply) \
3540 _(lisp_add_del_adjacency_reply) \
3541 _(lisp_gpe_add_del_fwd_entry_reply) \
3542 _(lisp_add_del_map_resolver_reply) \
3543 _(lisp_add_del_map_server_reply) \
3544 _(lisp_gpe_enable_disable_reply) \
3545 _(lisp_gpe_add_del_iface_reply) \
3546 _(lisp_enable_disable_reply) \
3547 _(lisp_rloc_probe_enable_disable_reply) \
3548 _(lisp_map_register_enable_disable_reply) \
3549 _(lisp_pitr_set_locator_set_reply) \
3550 _(lisp_map_request_mode_reply) \
3551 _(lisp_add_del_map_request_itr_rlocs_reply) \
3552 _(lisp_eid_table_add_del_map_reply) \
3553 _(vxlan_gpe_add_del_tunnel_reply) \
3554 _(af_packet_delete_reply) \
3555 _(policer_classify_set_interface_reply) \
3556 _(netmap_create_reply) \
3557 _(netmap_delete_reply) \
3558 _(set_ipfix_exporter_reply) \
3559 _(set_ipfix_classify_stream_reply) \
3560 _(ipfix_classify_table_add_del_reply) \
3561 _(flow_classify_set_interface_reply) \
3562 _(sw_interface_span_enable_disable_reply) \
3563 _(pg_capture_reply) \
3564 _(pg_enable_disable_reply) \
3565 _(ip_source_and_port_range_check_add_del_reply) \
3566 _(ip_source_and_port_range_check_interface_add_del_reply)\
3567 _(delete_subif_reply) \
3568 _(l2_interface_pbb_tag_rewrite_reply) \
3570 _(feature_enable_disable_reply) \
3571 _(sw_interface_tag_add_del_reply) \
3572 _(sw_interface_set_mtu_reply)
3575 #define foreach_standard_dpdk_reply_retval_handler \
3576 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3577 _(sw_interface_set_dpdk_hqos_subport_reply) \
3578 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3582 static void vl_api_##n##_t_handler \
3583 (vl_api_##n##_t * mp) \
3585 vat_main_t * vam = &vat_main; \
3586 i32 retval = ntohl(mp->retval); \
3587 if (vam->async_mode) { \
3588 vam->async_errors += (retval < 0); \
3590 vam->retval = retval; \
3591 vam->result_ready = 1; \
3594 foreach_standard_reply_retval_handler;
3598 static void vl_api_##n##_t_handler_json \
3599 (vl_api_##n##_t * mp) \
3601 vat_main_t * vam = &vat_main; \
3602 vat_json_node_t node; \
3603 vat_json_init_object(&node); \
3604 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3605 vat_json_print(vam->ofp, &node); \
3606 vam->retval = ntohl(mp->retval); \
3607 vam->result_ready = 1; \
3609 foreach_standard_reply_retval_handler;
3614 static void vl_api_##n##_t_handler \
3615 (vl_api_##n##_t * mp) \
3617 vat_main_t * vam = &vat_main; \
3618 i32 retval = ntohl(mp->retval); \
3619 if (vam->async_mode) { \
3620 vam->async_errors += (retval < 0); \
3622 vam->retval = retval; \
3623 vam->result_ready = 1; \
3626 foreach_standard_dpdk_reply_retval_handler;
3630 static void vl_api_##n##_t_handler_json \
3631 (vl_api_##n##_t * mp) \
3633 vat_main_t * vam = &vat_main; \
3634 vat_json_node_t node; \
3635 vat_json_init_object(&node); \
3636 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3637 vat_json_print(vam->ofp, &node); \
3638 vam->retval = ntohl(mp->retval); \
3639 vam->result_ready = 1; \
3641 foreach_standard_dpdk_reply_retval_handler;
3646 * Table of message reply handlers, must include boilerplate handlers
3650 #define foreach_vpe_api_reply_msg \
3651 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3652 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3653 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3654 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3655 _(CONTROL_PING_REPLY, control_ping_reply) \
3656 _(CLI_REPLY, cli_reply) \
3657 _(CLI_INBAND_REPLY, cli_inband_reply) \
3658 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3659 sw_interface_add_del_address_reply) \
3660 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3661 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3662 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3663 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3664 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3665 sw_interface_set_l2_xconnect_reply) \
3666 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3667 sw_interface_set_l2_bridge_reply) \
3668 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3669 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3670 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3671 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3672 _(L2_FLAGS_REPLY, l2_flags_reply) \
3673 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3674 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3675 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3676 _(TAP_DELETE_REPLY, tap_delete_reply) \
3677 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3678 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3679 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3680 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3681 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3682 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3683 proxy_arp_intfc_enable_disable_reply) \
3684 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3685 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3686 sw_interface_set_unnumbered_reply) \
3687 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3688 _(RESET_VRF_REPLY, reset_vrf_reply) \
3689 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3690 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3691 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3692 _(RESET_FIB_REPLY, reset_fib_reply) \
3693 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3694 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3695 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3696 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3697 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3698 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3699 sw_interface_ip6_enable_disable_reply) \
3700 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3701 sw_interface_ip6_set_link_local_address_reply) \
3702 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3703 sw_interface_ip6nd_ra_prefix_reply) \
3704 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3705 sw_interface_ip6nd_ra_config_reply) \
3706 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3707 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3708 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3709 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3710 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3711 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3712 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3713 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3714 classify_set_interface_ip_table_reply) \
3715 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3716 classify_set_interface_l2_tables_reply) \
3717 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3718 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3719 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3720 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3721 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3722 l2tpv3_interface_enable_disable_reply) \
3723 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3724 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3725 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3726 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3727 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3728 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3729 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3730 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3731 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3732 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3733 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3734 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3735 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3736 _(SHOW_VERSION_REPLY, show_version_reply) \
3737 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3738 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3739 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3740 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3741 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3742 _(IP4_ARP_EVENT, ip4_arp_event) \
3743 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3744 _(IP6_ND_EVENT, ip6_nd_event) \
3745 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3746 _(IP_ADDRESS_DETAILS, ip_address_details) \
3747 _(IP_DETAILS, ip_details) \
3748 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3749 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3750 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3751 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3752 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3753 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3754 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3755 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3756 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3757 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3758 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3759 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3760 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3761 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3762 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3763 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3764 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3765 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3766 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3767 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3768 _(MAP_RULE_DETAILS, map_rule_details) \
3769 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3770 _(WANT_STATS_REPLY, want_stats_reply) \
3771 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3772 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3773 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3774 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3775 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3776 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3777 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3778 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3779 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3780 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3781 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3782 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3783 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3784 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3785 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3786 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3787 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3788 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3789 lisp_map_register_enable_disable_reply) \
3790 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3791 lisp_rloc_probe_enable_disable_reply) \
3792 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3793 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3794 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3795 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3796 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3797 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3798 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3799 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3800 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3801 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3802 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3803 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3804 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3805 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3806 lisp_add_del_map_request_itr_rlocs_reply) \
3807 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3808 lisp_get_map_request_itr_rlocs_reply) \
3809 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3810 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3811 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3812 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3813 show_lisp_map_register_state_reply) \
3814 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3815 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3816 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3817 _(POLICER_DETAILS, policer_details) \
3818 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3819 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3820 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3821 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3822 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3823 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3824 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3825 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3826 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3827 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3828 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3829 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3830 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3831 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3832 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3833 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3834 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3835 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3836 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3837 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3838 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3839 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3840 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3841 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3842 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3843 ip_source_and_port_range_check_add_del_reply) \
3844 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3845 ip_source_and_port_range_check_interface_add_del_reply) \
3846 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3847 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3848 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3849 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3850 _(PUNT_REPLY, punt_reply) \
3851 _(IP_FIB_DETAILS, ip_fib_details) \
3852 _(IP6_FIB_DETAILS, ip6_fib_details) \
3853 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3854 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3855 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3856 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
3857 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
3858 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
3861 #define foreach_vpe_dpdk_api_reply_msg \
3862 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3863 sw_interface_set_dpdk_hqos_pipe_reply) \
3864 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3865 sw_interface_set_dpdk_hqos_subport_reply) \
3866 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3867 sw_interface_set_dpdk_hqos_tctbl_reply)
3870 /* M: construct, but don't yet send a message */
3874 vam->result_ready = 0; \
3875 mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)); \
3876 memset (mp, 0, sizeof (*mp)); \
3877 mp->_vl_msg_id = ntohs (VL_API_##T); \
3878 mp->client_index = vam->my_client_index; \
3883 vam->result_ready = 0; \
3884 mp = vl_msg_api_alloc_as_if_client(sizeof(*mp)+(n)); \
3885 memset (mp, 0, sizeof (*mp)); \
3886 mp->_vl_msg_id = ntohs (VL_API_##T); \
3887 mp->client_index = vam->my_client_index; \
3891 /* S: send a message */
3892 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3894 /* W: wait for results, with timeout */
3897 timeout = vat_time_now (vam) + 1.0; \
3899 while (vat_time_now (vam) < timeout) { \
3900 if (vam->result_ready == 1) { \
3901 return (vam->retval); \
3903 vat_suspend (vam->vlib_main, 1e-3); \
3908 /* W2: wait for results, with timeout */
3911 timeout = vat_time_now (vam) + 1.0; \
3913 while (vat_time_now (vam) < timeout) { \
3914 if (vam->result_ready == 1) { \
3916 return (vam->retval); \
3918 vat_suspend (vam->vlib_main, 1e-3); \
3930 #define STR_VTR_OP_CASE(op) \
3931 case L2_VTR_ ## op: \
3935 str_vtr_op (u32 vtr_op)
3939 STR_VTR_OP_CASE (DISABLED);
3940 STR_VTR_OP_CASE (PUSH_1);
3941 STR_VTR_OP_CASE (PUSH_2);
3942 STR_VTR_OP_CASE (POP_1);
3943 STR_VTR_OP_CASE (POP_2);
3944 STR_VTR_OP_CASE (TRANSLATE_1_1);
3945 STR_VTR_OP_CASE (TRANSLATE_1_2);
3946 STR_VTR_OP_CASE (TRANSLATE_2_1);
3947 STR_VTR_OP_CASE (TRANSLATE_2_2);
3954 dump_sub_interface_table (vat_main_t * vam)
3956 const sw_interface_subif_t *sub = NULL;
3958 if (vam->json_output)
3961 ("JSON output supported only for VPE API calls and dump_stats_table");
3966 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
3967 "Interface", "sw_if_index",
3968 "sub id", "dot1ad", "tags", "outer id",
3969 "inner id", "exact", "default", "outer any", "inner any");
3971 vec_foreach (sub, vam->sw_if_subif_table)
3974 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
3975 sub->interface_name,
3977 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3978 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3979 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3980 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3981 if (sub->vtr_op != L2_VTR_DISABLED)
3984 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3985 "tag1: %d tag2: %d ]",
3986 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3987 sub->vtr_tag1, sub->vtr_tag2);
3995 name_sort_cmp (void *a1, void *a2)
3997 name_sort_t *n1 = a1;
3998 name_sort_t *n2 = a2;
4000 return strcmp ((char *) n1->name, (char *) n2->name);
4004 dump_interface_table (vat_main_t * vam)
4007 name_sort_t *nses = 0, *ns;
4009 if (vam->json_output)
4012 ("JSON output supported only for VPE API calls and dump_stats_table");
4017 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4019 vec_add2 (nses, ns, 1);
4020 ns->name = (u8 *)(p->key);
4021 ns->value = (u32) p->value[0];
4025 vec_sort_with_function (nses, name_sort_cmp);
4027 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4028 vec_foreach (ns, nses)
4030 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4037 dump_ip_table (vat_main_t * vam, int is_ipv6)
4039 const ip_details_t *det = NULL;
4040 const ip_address_details_t *address = NULL;
4043 print (vam->ofp, "%-12s", "sw_if_index");
4045 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4052 print (vam->ofp, "%-12d", i);
4053 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4058 vec_foreach (address, det->addr)
4062 is_ipv6 ? format_ip6_address : format_ip4_address,
4063 address->ip, address->prefix_length);
4071 dump_ipv4_table (vat_main_t * vam)
4073 if (vam->json_output)
4076 ("JSON output supported only for VPE API calls and dump_stats_table");
4080 return dump_ip_table (vam, 0);
4084 dump_ipv6_table (vat_main_t * vam)
4086 if (vam->json_output)
4089 ("JSON output supported only for VPE API calls and dump_stats_table");
4093 return dump_ip_table (vam, 1);
4097 counter_type_to_str (u8 counter_type, u8 is_combined)
4101 switch (counter_type)
4103 case VNET_INTERFACE_COUNTER_DROP:
4105 case VNET_INTERFACE_COUNTER_PUNT:
4107 case VNET_INTERFACE_COUNTER_IP4:
4109 case VNET_INTERFACE_COUNTER_IP6:
4111 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4113 case VNET_INTERFACE_COUNTER_RX_MISS:
4115 case VNET_INTERFACE_COUNTER_RX_ERROR:
4117 case VNET_INTERFACE_COUNTER_TX_ERROR:
4120 return "INVALID-COUNTER-TYPE";
4125 switch (counter_type)
4127 case VNET_INTERFACE_COUNTER_RX:
4129 case VNET_INTERFACE_COUNTER_TX:
4132 return "INVALID-COUNTER-TYPE";
4138 dump_stats_table (vat_main_t * vam)
4140 vat_json_node_t node;
4141 vat_json_node_t *msg_array;
4142 vat_json_node_t *msg;
4143 vat_json_node_t *counter_array;
4144 vat_json_node_t *counter;
4145 interface_counter_t c;
4147 ip4_fib_counter_t *c4;
4148 ip6_fib_counter_t *c6;
4151 if (!vam->json_output)
4153 clib_warning ("dump_stats_table supported only in JSON format");
4157 vat_json_init_object (&node);
4159 /* interface counters */
4160 msg_array = vat_json_object_add (&node, "interface_counters");
4161 vat_json_init_array (msg_array);
4162 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4164 msg = vat_json_array_add (msg_array);
4165 vat_json_init_object (msg);
4166 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4167 (u8 *) counter_type_to_str (i, 0));
4168 vat_json_object_add_int (msg, "is_combined", 0);
4169 counter_array = vat_json_object_add (msg, "data");
4170 vat_json_init_array (counter_array);
4171 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4173 packets = vam->simple_interface_counters[i][j];
4174 vat_json_array_add_uint (counter_array, packets);
4177 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4179 msg = vat_json_array_add (msg_array);
4180 vat_json_init_object (msg);
4181 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4182 (u8 *) counter_type_to_str (i, 1));
4183 vat_json_object_add_int (msg, "is_combined", 1);
4184 counter_array = vat_json_object_add (msg, "data");
4185 vat_json_init_array (counter_array);
4186 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4188 c = vam->combined_interface_counters[i][j];
4189 counter = vat_json_array_add (counter_array);
4190 vat_json_init_object (counter);
4191 vat_json_object_add_uint (counter, "packets", c.packets);
4192 vat_json_object_add_uint (counter, "bytes", c.bytes);
4196 /* ip4 fib counters */
4197 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4198 vat_json_init_array (msg_array);
4199 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4201 msg = vat_json_array_add (msg_array);
4202 vat_json_init_object (msg);
4203 vat_json_object_add_uint (msg, "vrf_id",
4204 vam->ip4_fib_counters_vrf_id_by_index[i]);
4205 counter_array = vat_json_object_add (msg, "c");
4206 vat_json_init_array (counter_array);
4207 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4209 counter = vat_json_array_add (counter_array);
4210 vat_json_init_object (counter);
4211 c4 = &vam->ip4_fib_counters[i][j];
4212 vat_json_object_add_ip4 (counter, "address", c4->address);
4213 vat_json_object_add_uint (counter, "address_length",
4214 c4->address_length);
4215 vat_json_object_add_uint (counter, "packets", c4->packets);
4216 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4220 /* ip6 fib counters */
4221 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4222 vat_json_init_array (msg_array);
4223 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4225 msg = vat_json_array_add (msg_array);
4226 vat_json_init_object (msg);
4227 vat_json_object_add_uint (msg, "vrf_id",
4228 vam->ip6_fib_counters_vrf_id_by_index[i]);
4229 counter_array = vat_json_object_add (msg, "c");
4230 vat_json_init_array (counter_array);
4231 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4233 counter = vat_json_array_add (counter_array);
4234 vat_json_init_object (counter);
4235 c6 = &vam->ip6_fib_counters[i][j];
4236 vat_json_object_add_ip6 (counter, "address", c6->address);
4237 vat_json_object_add_uint (counter, "address_length",
4238 c6->address_length);
4239 vat_json_object_add_uint (counter, "packets", c6->packets);
4240 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4244 vat_json_print (vam->ofp, &node);
4245 vat_json_free (&node);
4251 exec (vat_main_t * vam)
4253 api_main_t *am = &api_main;
4254 vl_api_cli_request_t *mp;
4258 unformat_input_t *i = vam->input;
4260 if (vec_len (i->buffer) == 0)
4263 if (vam->exec_mode == 0 && unformat (i, "mode"))
4268 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4275 M (CLI_REQUEST, cli_request);
4278 * Copy cmd into shared memory.
4279 * In order for the CLI command to work, it
4280 * must be a vector ending in \n, not a C-string ending
4283 pthread_mutex_lock (&am->vlib_rp->mutex);
4284 oldheap = svm_push_data_heap (am->vlib_rp);
4286 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4287 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4289 svm_pop_heap (oldheap);
4290 pthread_mutex_unlock (&am->vlib_rp->mutex);
4292 mp->cmd_in_shmem = (u64) cmd;
4294 timeout = vat_time_now (vam) + 10.0;
4296 while (vat_time_now (vam) < timeout)
4298 if (vam->result_ready == 1)
4301 if (vam->shmem_result != NULL)
4302 print (vam->ofp, "%s", vam->shmem_result);
4303 pthread_mutex_lock (&am->vlib_rp->mutex);
4304 oldheap = svm_push_data_heap (am->vlib_rp);
4306 free_me = (u8 *) vam->shmem_result;
4309 svm_pop_heap (oldheap);
4310 pthread_mutex_unlock (&am->vlib_rp->mutex);
4318 * Future replacement of exec() that passes CLI buffers directly in
4319 * the API messages instead of an additional shared memory area.
4322 exec_inband (vat_main_t * vam)
4324 vl_api_cli_inband_t *mp;
4326 unformat_input_t *i = vam->input;
4328 if (vec_len (i->buffer) == 0)
4331 if (vam->exec_mode == 0 && unformat (i, "mode"))
4336 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4343 * In order for the CLI command to work, it
4344 * must be a vector ending in \n, not a C-string ending
4347 u32 len = vec_len (vam->input->buffer);
4348 M2 (CLI_INBAND, cli_inband, len);
4349 clib_memcpy (mp->cmd, vam->input->buffer, len);
4350 mp->length = htonl (len);
4353 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4357 api_create_loopback (vat_main_t * vam)
4359 unformat_input_t *i = vam->input;
4360 vl_api_create_loopback_t *mp;
4365 memset (mac_address, 0, sizeof (mac_address));
4367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4369 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4375 /* Construct the API message */
4376 M (CREATE_LOOPBACK, create_loopback);
4378 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4385 api_delete_loopback (vat_main_t * vam)
4387 unformat_input_t *i = vam->input;
4388 vl_api_delete_loopback_t *mp;
4390 u32 sw_if_index = ~0;
4392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4394 if (unformat (i, "sw_if_index %d", &sw_if_index))
4400 if (sw_if_index == ~0)
4402 errmsg ("missing sw_if_index");
4406 /* Construct the API message */
4407 M (DELETE_LOOPBACK, delete_loopback);
4408 mp->sw_if_index = ntohl (sw_if_index);
4415 api_want_stats (vat_main_t * vam)
4417 unformat_input_t *i = vam->input;
4418 vl_api_want_stats_t *mp;
4422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4424 if (unformat (i, "enable"))
4426 else if (unformat (i, "disable"))
4434 errmsg ("missing enable|disable");
4438 M (WANT_STATS, want_stats);
4439 mp->enable_disable = enable;
4446 api_want_interface_events (vat_main_t * vam)
4448 unformat_input_t *i = vam->input;
4449 vl_api_want_interface_events_t *mp;
4453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4455 if (unformat (i, "enable"))
4457 else if (unformat (i, "disable"))
4465 errmsg ("missing enable|disable");
4469 M (WANT_INTERFACE_EVENTS, want_interface_events);
4470 mp->enable_disable = enable;
4472 vam->interface_event_display = enable;
4479 /* Note: non-static, called once to set up the initial intfc table */
4481 api_sw_interface_dump (vat_main_t * vam)
4483 vl_api_sw_interface_dump_t *mp;
4486 name_sort_t *nses = 0, *ns;
4487 sw_interface_subif_t *sub = NULL;
4489 /* Toss the old name table */
4491 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4493 vec_add2 (nses, ns, 1);
4494 ns->name = (u8 *)(p->key);
4495 ns->value = (u32) p->value[0];
4499 hash_free (vam->sw_if_index_by_interface_name);
4501 vec_foreach (ns, nses) vec_free (ns->name);
4505 vec_foreach (sub, vam->sw_if_subif_table)
4507 vec_free (sub->interface_name);
4509 vec_free (vam->sw_if_subif_table);
4511 /* recreate the interface name hash table */
4512 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4514 /* Get list of ethernets */
4515 M (SW_INTERFACE_DUMP, sw_interface_dump);
4516 mp->name_filter_valid = 1;
4517 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4520 /* and local / loopback interfaces */
4521 M (SW_INTERFACE_DUMP, sw_interface_dump);
4522 mp->name_filter_valid = 1;
4523 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4526 /* and packet-generator interfaces */
4527 M (SW_INTERFACE_DUMP, sw_interface_dump);
4528 mp->name_filter_valid = 1;
4529 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4532 /* and vxlan-gpe tunnel interfaces */
4533 M (SW_INTERFACE_DUMP, sw_interface_dump);
4534 mp->name_filter_valid = 1;
4535 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4536 sizeof (mp->name_filter) - 1);
4539 /* and vxlan tunnel interfaces */
4540 M (SW_INTERFACE_DUMP, sw_interface_dump);
4541 mp->name_filter_valid = 1;
4542 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4545 /* and host (af_packet) interfaces */
4546 M (SW_INTERFACE_DUMP, sw_interface_dump);
4547 mp->name_filter_valid = 1;
4548 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4551 /* and l2tpv3 tunnel interfaces */
4552 M (SW_INTERFACE_DUMP, sw_interface_dump);
4553 mp->name_filter_valid = 1;
4554 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4555 sizeof (mp->name_filter) - 1);
4558 /* and GRE tunnel interfaces */
4559 M (SW_INTERFACE_DUMP, sw_interface_dump);
4560 mp->name_filter_valid = 1;
4561 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4564 /* and LISP-GPE interfaces */
4565 M (SW_INTERFACE_DUMP, sw_interface_dump);
4566 mp->name_filter_valid = 1;
4567 strncpy ((char *) mp->name_filter, "lisp_gpe",
4568 sizeof (mp->name_filter) - 1);
4571 /* and IPSEC tunnel interfaces */
4572 M (SW_INTERFACE_DUMP, sw_interface_dump);
4573 mp->name_filter_valid = 1;
4574 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4577 /* Use a control ping for synchronization */
4579 vl_api_control_ping_t *mp;
4580 M (CONTROL_PING, control_ping);
4587 api_sw_interface_set_flags (vat_main_t * vam)
4589 unformat_input_t *i = vam->input;
4590 vl_api_sw_interface_set_flags_t *mp;
4593 u8 sw_if_index_set = 0;
4594 u8 admin_up = 0, link_up = 0;
4596 /* Parse args required to build the message */
4597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4599 if (unformat (i, "admin-up"))
4601 else if (unformat (i, "admin-down"))
4603 else if (unformat (i, "link-up"))
4605 else if (unformat (i, "link-down"))
4608 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4609 sw_if_index_set = 1;
4610 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4611 sw_if_index_set = 1;
4616 if (sw_if_index_set == 0)
4618 errmsg ("missing interface name or sw_if_index");
4622 /* Construct the API message */
4623 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4624 mp->sw_if_index = ntohl (sw_if_index);
4625 mp->admin_up_down = admin_up;
4626 mp->link_up_down = link_up;
4631 /* Wait for a reply, return the good/bad news... */
4636 api_sw_interface_clear_stats (vat_main_t * vam)
4638 unformat_input_t *i = vam->input;
4639 vl_api_sw_interface_clear_stats_t *mp;
4642 u8 sw_if_index_set = 0;
4644 /* Parse args required to build the message */
4645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4648 sw_if_index_set = 1;
4649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4650 sw_if_index_set = 1;
4655 /* Construct the API message */
4656 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4658 if (sw_if_index_set == 1)
4659 mp->sw_if_index = ntohl (sw_if_index);
4661 mp->sw_if_index = ~0;
4666 /* Wait for a reply, return the good/bad news... */
4672 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4674 unformat_input_t *i = vam->input;
4675 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4678 u8 sw_if_index_set = 0;
4686 /* Parse args required to build the message */
4687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4689 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4690 sw_if_index_set = 1;
4691 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4692 sw_if_index_set = 1;
4693 else if (unformat (i, "subport %u", &subport))
4696 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4697 sw_if_index_set = 1;
4698 else if (unformat (i, "pipe %u", &pipe))
4700 else if (unformat (i, "profile %u", &profile))
4706 if (sw_if_index_set == 0)
4708 errmsg ("missing interface name or sw_if_index");
4712 if (subport_set == 0)
4714 errmsg ("missing subport ");
4720 errmsg ("missing pipe");
4724 if (profile_set == 0)
4726 errmsg ("missing profile");
4730 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4732 mp->sw_if_index = ntohl (sw_if_index);
4733 mp->subport = ntohl (subport);
4734 mp->pipe = ntohl (pipe);
4735 mp->profile = ntohl (profile);
4745 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4747 unformat_input_t *i = vam->input;
4748 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4751 u8 sw_if_index_set = 0;
4754 u32 tb_rate = 1250000000; /* 10GbE */
4755 u32 tb_size = 1000000;
4756 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4759 /* Parse args required to build the message */
4760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4762 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4763 sw_if_index_set = 1;
4764 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4765 sw_if_index_set = 1;
4766 else if (unformat (i, "subport %u", &subport))
4769 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4770 sw_if_index_set = 1;
4771 else if (unformat (i, "rate %u", &tb_rate))
4775 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4777 tc_rate[tc_id] = tb_rate;
4779 else if (unformat (i, "bktsize %u", &tb_size))
4781 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4783 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4785 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4787 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4789 else if (unformat (i, "period %u", &tc_period))
4795 if (sw_if_index_set == 0)
4797 errmsg ("missing interface name or sw_if_index");
4801 if (subport_set == 0)
4803 errmsg ("missing subport ");
4807 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4809 mp->sw_if_index = ntohl (sw_if_index);
4810 mp->subport = ntohl (subport);
4811 mp->tb_rate = ntohl (tb_rate);
4812 mp->tb_size = ntohl (tb_size);
4813 mp->tc_rate[0] = ntohl (tc_rate[0]);
4814 mp->tc_rate[1] = ntohl (tc_rate[1]);
4815 mp->tc_rate[2] = ntohl (tc_rate[2]);
4816 mp->tc_rate[3] = ntohl (tc_rate[3]);
4817 mp->tc_period = ntohl (tc_period);
4826 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4828 unformat_input_t *i = vam->input;
4829 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4832 u8 sw_if_index_set = 0;
4836 u32 entry, tc, queue;
4838 /* Parse args required to build the message */
4839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4841 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4842 sw_if_index_set = 1;
4843 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4844 sw_if_index_set = 1;
4845 else if (unformat (i, "entry %d", &entry))
4847 else if (unformat (i, "tc %d", &tc))
4849 else if (unformat (i, "queue %d", &queue))
4855 if (sw_if_index_set == 0)
4857 errmsg ("missing interface name or sw_if_index");
4863 errmsg ("missing entry ");
4869 errmsg ("missing traffic class ");
4875 errmsg ("missing queue ");
4879 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4881 mp->sw_if_index = ntohl (sw_if_index);
4882 mp->entry = ntohl (entry);
4883 mp->tc = ntohl (tc);
4884 mp->queue = ntohl (queue);
4894 api_sw_interface_add_del_address (vat_main_t * vam)
4896 unformat_input_t *i = vam->input;
4897 vl_api_sw_interface_add_del_address_t *mp;
4900 u8 sw_if_index_set = 0;
4901 u8 is_add = 1, del_all = 0;
4902 u32 address_length = 0;
4903 u8 v4_address_set = 0;
4904 u8 v6_address_set = 0;
4905 ip4_address_t v4address;
4906 ip6_address_t v6address;
4908 /* Parse args required to build the message */
4909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4911 if (unformat (i, "del-all"))
4913 else if (unformat (i, "del"))
4916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4917 sw_if_index_set = 1;
4918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4919 sw_if_index_set = 1;
4920 else if (unformat (i, "%U/%d",
4921 unformat_ip4_address, &v4address, &address_length))
4923 else if (unformat (i, "%U/%d",
4924 unformat_ip6_address, &v6address, &address_length))
4930 if (sw_if_index_set == 0)
4932 errmsg ("missing interface name or sw_if_index");
4935 if (v4_address_set && v6_address_set)
4937 errmsg ("both v4 and v6 addresses set");
4940 if (!v4_address_set && !v6_address_set && !del_all)
4942 errmsg ("no addresses set");
4946 /* Construct the API message */
4947 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4949 mp->sw_if_index = ntohl (sw_if_index);
4950 mp->is_add = is_add;
4951 mp->del_all = del_all;
4955 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4959 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4961 mp->address_length = address_length;
4966 /* Wait for a reply, return good/bad news */
4971 api_sw_interface_set_mpls_enable (vat_main_t * vam)
4973 unformat_input_t *i = vam->input;
4974 vl_api_sw_interface_set_mpls_enable_t *mp;
4977 u8 sw_if_index_set = 0;
4980 /* Parse args required to build the message */
4981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4984 sw_if_index_set = 1;
4985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4986 sw_if_index_set = 1;
4987 else if (unformat (i, "disable"))
4989 else if (unformat (i, "dis"))
4995 if (sw_if_index_set == 0)
4997 errmsg ("missing interface name or sw_if_index");
5001 /* Construct the API message */
5002 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5004 mp->sw_if_index = ntohl (sw_if_index);
5005 mp->enable = enable;
5010 /* Wait for a reply... */
5015 api_sw_interface_set_table (vat_main_t * vam)
5017 unformat_input_t *i = vam->input;
5018 vl_api_sw_interface_set_table_t *mp;
5020 u32 sw_if_index, vrf_id = 0;
5021 u8 sw_if_index_set = 0;
5024 /* Parse args required to build the message */
5025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5027 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5028 sw_if_index_set = 1;
5029 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5030 sw_if_index_set = 1;
5031 else if (unformat (i, "vrf %d", &vrf_id))
5033 else if (unformat (i, "ipv6"))
5039 if (sw_if_index_set == 0)
5041 errmsg ("missing interface name or sw_if_index");
5045 /* Construct the API message */
5046 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5048 mp->sw_if_index = ntohl (sw_if_index);
5049 mp->is_ipv6 = is_ipv6;
5050 mp->vrf_id = ntohl (vrf_id);
5055 /* Wait for a reply... */
5059 static void vl_api_sw_interface_get_table_reply_t_handler
5060 (vl_api_sw_interface_get_table_reply_t * mp)
5062 vat_main_t *vam = &vat_main;
5064 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5066 vam->retval = ntohl (mp->retval);
5067 vam->result_ready = 1;
5071 static void vl_api_sw_interface_get_table_reply_t_handler_json
5072 (vl_api_sw_interface_get_table_reply_t * mp)
5074 vat_main_t *vam = &vat_main;
5075 vat_json_node_t node;
5077 vat_json_init_object (&node);
5078 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5079 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5081 vat_json_print (vam->ofp, &node);
5082 vat_json_free (&node);
5084 vam->retval = ntohl (mp->retval);
5085 vam->result_ready = 1;
5089 api_sw_interface_get_table (vat_main_t * vam)
5091 unformat_input_t *i = vam->input;
5092 vl_api_sw_interface_get_table_t *mp;
5094 u8 sw_if_index_set = 0;
5098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5101 sw_if_index_set = 1;
5102 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5103 sw_if_index_set = 1;
5104 else if (unformat (i, "ipv6"))
5110 if (sw_if_index_set == 0)
5112 errmsg ("missing interface name or sw_if_index");
5116 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5117 mp->sw_if_index = htonl (sw_if_index);
5118 mp->is_ipv6 = is_ipv6;
5125 api_sw_interface_set_vpath (vat_main_t * vam)
5127 unformat_input_t *i = vam->input;
5128 vl_api_sw_interface_set_vpath_t *mp;
5130 u32 sw_if_index = 0;
5131 u8 sw_if_index_set = 0;
5134 /* Parse args required to build the message */
5135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5138 sw_if_index_set = 1;
5139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5140 sw_if_index_set = 1;
5141 else if (unformat (i, "enable"))
5143 else if (unformat (i, "disable"))
5149 if (sw_if_index_set == 0)
5151 errmsg ("missing interface name or sw_if_index");
5155 /* Construct the API message */
5156 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5158 mp->sw_if_index = ntohl (sw_if_index);
5159 mp->enable = is_enable;
5164 /* Wait for a reply... */
5169 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5171 unformat_input_t *i = vam->input;
5172 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5174 u32 sw_if_index = 0;
5175 u8 sw_if_index_set = 0;
5179 /* Parse args required to build the message */
5180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5183 sw_if_index_set = 1;
5184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5185 sw_if_index_set = 1;
5186 else if (unformat (i, "enable"))
5188 else if (unformat (i, "disable"))
5190 else if (unformat (i, "ip4"))
5192 else if (unformat (i, "ip6"))
5198 if (sw_if_index_set == 0)
5200 errmsg ("missing interface name or sw_if_index");
5204 /* Construct the API message */
5205 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5207 mp->sw_if_index = ntohl (sw_if_index);
5208 mp->enable = is_enable;
5209 mp->is_ipv6 = is_ipv6;
5214 /* Wait for a reply... */
5219 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5221 unformat_input_t *i = vam->input;
5222 vl_api_sw_interface_set_l2_xconnect_t *mp;
5225 u8 rx_sw_if_index_set = 0;
5227 u8 tx_sw_if_index_set = 0;
5230 /* Parse args required to build the message */
5231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5233 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5234 rx_sw_if_index_set = 1;
5235 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5236 tx_sw_if_index_set = 1;
5237 else if (unformat (i, "rx"))
5239 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5241 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5243 rx_sw_if_index_set = 1;
5248 else if (unformat (i, "tx"))
5250 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5252 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5254 tx_sw_if_index_set = 1;
5259 else if (unformat (i, "enable"))
5261 else if (unformat (i, "disable"))
5267 if (rx_sw_if_index_set == 0)
5269 errmsg ("missing rx interface name or rx_sw_if_index");
5273 if (enable && (tx_sw_if_index_set == 0))
5275 errmsg ("missing tx interface name or tx_sw_if_index");
5279 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5281 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5282 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5283 mp->enable = enable;
5292 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5294 unformat_input_t *i = vam->input;
5295 vl_api_sw_interface_set_l2_bridge_t *mp;
5298 u8 rx_sw_if_index_set = 0;
5305 /* Parse args required to build the message */
5306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5308 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5309 rx_sw_if_index_set = 1;
5310 else if (unformat (i, "bd_id %d", &bd_id))
5314 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5315 rx_sw_if_index_set = 1;
5316 else if (unformat (i, "shg %d", &shg))
5318 else if (unformat (i, "bvi"))
5320 else if (unformat (i, "enable"))
5322 else if (unformat (i, "disable"))
5328 if (rx_sw_if_index_set == 0)
5330 errmsg ("missing rx interface name or sw_if_index");
5334 if (enable && (bd_id_set == 0))
5336 errmsg ("missing bridge domain");
5340 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5342 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5343 mp->bd_id = ntohl (bd_id);
5346 mp->enable = enable;
5355 api_bridge_domain_dump (vat_main_t * vam)
5357 unformat_input_t *i = vam->input;
5358 vl_api_bridge_domain_dump_t *mp;
5362 /* Parse args required to build the message */
5363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5365 if (unformat (i, "bd_id %d", &bd_id))
5371 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5372 mp->bd_id = ntohl (bd_id);
5375 /* Use a control ping for synchronization */
5377 vl_api_control_ping_t *mp;
5378 M (CONTROL_PING, control_ping);
5388 api_bridge_domain_add_del (vat_main_t * vam)
5390 unformat_input_t *i = vam->input;
5391 vl_api_bridge_domain_add_del_t *mp;
5395 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5398 /* Parse args required to build the message */
5399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5401 if (unformat (i, "bd_id %d", &bd_id))
5403 else if (unformat (i, "flood %d", &flood))
5405 else if (unformat (i, "uu-flood %d", &uu_flood))
5407 else if (unformat (i, "forward %d", &forward))
5409 else if (unformat (i, "learn %d", &learn))
5411 else if (unformat (i, "arp-term %d", &arp_term))
5413 else if (unformat (i, "mac-age %d", &mac_age))
5415 else if (unformat (i, "del"))
5418 flood = uu_flood = forward = learn = 0;
5426 errmsg ("missing bridge domain");
5432 errmsg ("mac age must be less than 256 ");
5436 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5438 mp->bd_id = ntohl (bd_id);
5440 mp->uu_flood = uu_flood;
5441 mp->forward = forward;
5443 mp->arp_term = arp_term;
5444 mp->is_add = is_add;
5445 mp->mac_age = (u8) mac_age;
5454 api_l2fib_add_del (vat_main_t * vam)
5456 unformat_input_t *i = vam->input;
5457 vl_api_l2fib_add_del_t *mp;
5463 u32 sw_if_index = ~0;
5464 u8 sw_if_index_set = 0;
5473 /* Parse args required to build the message */
5474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5476 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5478 else if (unformat (i, "bd_id %d", &bd_id))
5480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5481 sw_if_index_set = 1;
5482 else if (unformat (i, "sw_if"))
5484 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5487 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5488 sw_if_index_set = 1;
5493 else if (unformat (i, "static"))
5495 else if (unformat (i, "filter"))
5500 else if (unformat (i, "bvi"))
5505 else if (unformat (i, "del"))
5507 else if (unformat (i, "count %d", &count))
5515 errmsg ("missing mac address");
5521 errmsg ("missing bridge domain");
5525 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5527 errmsg ("missing interface name or sw_if_index");
5533 /* Turn on async mode */
5534 vam->async_mode = 1;
5535 vam->async_errors = 0;
5536 before = vat_time_now (vam);
5539 for (j = 0; j < count; j++)
5541 M (L2FIB_ADD_DEL, l2fib_add_del);
5544 mp->bd_id = ntohl (bd_id);
5545 mp->is_add = is_add;
5549 mp->sw_if_index = ntohl (sw_if_index);
5550 mp->static_mac = static_mac;
5551 mp->filter_mac = filter_mac;
5552 mp->bvi_mac = bvi_mac;
5554 increment_mac_address (&mac);
5561 vl_api_control_ping_t *mp;
5564 /* Shut off async mode */
5565 vam->async_mode = 0;
5567 M (CONTROL_PING, control_ping);
5570 timeout = vat_time_now (vam) + 1.0;
5571 while (vat_time_now (vam) < timeout)
5572 if (vam->result_ready == 1)
5577 if (vam->retval == -99)
5580 if (vam->async_errors > 0)
5582 errmsg ("%d asynchronous errors", vam->async_errors);
5585 vam->async_errors = 0;
5586 after = vat_time_now (vam);
5588 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5589 count, after - before, count / (after - before));
5593 /* Wait for a reply... */
5596 /* Return the good/bad news */
5597 return (vam->retval);
5601 api_l2_flags (vat_main_t * vam)
5603 unformat_input_t *i = vam->input;
5604 vl_api_l2_flags_t *mp;
5607 u32 feature_bitmap = 0;
5608 u8 sw_if_index_set = 0;
5610 /* Parse args required to build the message */
5611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5613 if (unformat (i, "sw_if_index %d", &sw_if_index))
5614 sw_if_index_set = 1;
5615 else if (unformat (i, "sw_if"))
5617 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5620 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5621 sw_if_index_set = 1;
5626 else if (unformat (i, "learn"))
5627 feature_bitmap |= L2INPUT_FEAT_LEARN;
5628 else if (unformat (i, "forward"))
5629 feature_bitmap |= L2INPUT_FEAT_FWD;
5630 else if (unformat (i, "flood"))
5631 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5632 else if (unformat (i, "uu-flood"))
5633 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5638 if (sw_if_index_set == 0)
5640 errmsg ("missing interface name or sw_if_index");
5644 M (L2_FLAGS, l2_flags);
5646 mp->sw_if_index = ntohl (sw_if_index);
5647 mp->feature_bitmap = ntohl (feature_bitmap);
5656 api_bridge_flags (vat_main_t * vam)
5658 unformat_input_t *i = vam->input;
5659 vl_api_bridge_flags_t *mp;
5666 /* Parse args required to build the message */
5667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5669 if (unformat (i, "bd_id %d", &bd_id))
5671 else if (unformat (i, "learn"))
5673 else if (unformat (i, "forward"))
5675 else if (unformat (i, "flood"))
5677 else if (unformat (i, "uu-flood"))
5678 flags |= L2_UU_FLOOD;
5679 else if (unformat (i, "arp-term"))
5680 flags |= L2_ARP_TERM;
5681 else if (unformat (i, "off"))
5683 else if (unformat (i, "disable"))
5691 errmsg ("missing bridge domain");
5695 M (BRIDGE_FLAGS, bridge_flags);
5697 mp->bd_id = ntohl (bd_id);
5698 mp->feature_bitmap = ntohl (flags);
5699 mp->is_set = is_set;
5708 api_bd_ip_mac_add_del (vat_main_t * vam)
5710 unformat_input_t *i = vam->input;
5711 vl_api_bd_ip_mac_add_del_t *mp;
5719 ip4_address_t v4addr;
5720 ip6_address_t v6addr;
5724 /* Parse args required to build the message */
5725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5727 if (unformat (i, "bd_id %d", &bd_id))
5731 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5735 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5740 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5744 else if (unformat (i, "del"))
5752 errmsg ("missing bridge domain");
5755 else if (ip_set == 0)
5757 errmsg ("missing IP address");
5760 else if (mac_set == 0)
5762 errmsg ("missing MAC address");
5766 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5768 mp->bd_id = ntohl (bd_id);
5769 mp->is_ipv6 = is_ipv6;
5770 mp->is_add = is_add;
5772 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5774 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5775 clib_memcpy (mp->mac_address, macaddr, 6);
5783 api_tap_connect (vat_main_t * vam)
5785 unformat_input_t *i = vam->input;
5786 vl_api_tap_connect_t *mp;
5794 memset (mac_address, 0, sizeof (mac_address));
5796 /* Parse args required to build the message */
5797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5799 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5803 else if (unformat (i, "random-mac"))
5805 else if (unformat (i, "tapname %s", &tap_name))
5807 else if (unformat (i, "tag %s", &tag))
5815 errmsg ("missing tap name");
5818 if (vec_len (tap_name) > 63)
5820 errmsg ("tap name too long");
5823 vec_add1 (tap_name, 0);
5825 if (vec_len (tag) > 63)
5827 errmsg ("tag too long");
5831 /* Construct the API message */
5832 M (TAP_CONNECT, tap_connect);
5834 mp->use_random_mac = random_mac;
5835 clib_memcpy (mp->mac_address, mac_address, 6);
5836 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5838 clib_memcpy (mp->tag, tag, vec_len (tag));
5840 vec_free (tap_name);
5846 /* Wait for a reply... */
5851 api_tap_modify (vat_main_t * vam)
5853 unformat_input_t *i = vam->input;
5854 vl_api_tap_modify_t *mp;
5860 u32 sw_if_index = ~0;
5861 u8 sw_if_index_set = 0;
5863 memset (mac_address, 0, sizeof (mac_address));
5865 /* Parse args required to build the message */
5866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5868 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5869 sw_if_index_set = 1;
5870 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5871 sw_if_index_set = 1;
5872 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5876 else if (unformat (i, "random-mac"))
5878 else if (unformat (i, "tapname %s", &tap_name))
5884 if (sw_if_index_set == 0)
5886 errmsg ("missing vpp interface name");
5891 errmsg ("missing tap name");
5894 if (vec_len (tap_name) > 63)
5896 errmsg ("tap name too long");
5898 vec_add1 (tap_name, 0);
5900 /* Construct the API message */
5901 M (TAP_MODIFY, tap_modify);
5903 mp->use_random_mac = random_mac;
5904 mp->sw_if_index = ntohl (sw_if_index);
5905 clib_memcpy (mp->mac_address, mac_address, 6);
5906 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5907 vec_free (tap_name);
5912 /* Wait for a reply... */
5917 api_tap_delete (vat_main_t * vam)
5919 unformat_input_t *i = vam->input;
5920 vl_api_tap_delete_t *mp;
5922 u32 sw_if_index = ~0;
5923 u8 sw_if_index_set = 0;
5925 /* Parse args required to build the message */
5926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5928 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5929 sw_if_index_set = 1;
5930 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5931 sw_if_index_set = 1;
5936 if (sw_if_index_set == 0)
5938 errmsg ("missing vpp interface name");
5942 /* Construct the API message */
5943 M (TAP_DELETE, tap_delete);
5945 mp->sw_if_index = ntohl (sw_if_index);
5950 /* Wait for a reply... */
5955 api_ip_add_del_route (vat_main_t * vam)
5957 unformat_input_t *i = vam->input;
5958 vl_api_ip_add_del_route_t *mp;
5960 u32 sw_if_index = ~0, vrf_id = 0;
5962 u8 is_local = 0, is_drop = 0;
5963 u8 is_unreach = 0, is_prohibit = 0;
5964 u8 create_vrf_if_needed = 0;
5966 u32 next_hop_weight = 1;
5968 u8 is_multipath = 0;
5970 u8 address_length_set = 0;
5971 u32 next_hop_table_id = 0;
5972 u32 resolve_attempts = 0;
5973 u32 dst_address_length = 0;
5974 u8 next_hop_set = 0;
5975 ip4_address_t v4_dst_address, v4_next_hop_address;
5976 ip6_address_t v6_dst_address, v6_next_hop_address;
5980 u32 random_add_del = 0;
5981 u32 *random_vector = 0;
5983 u32 random_seed = 0xdeaddabe;
5984 u32 classify_table_index = ~0;
5986 u8 resolve_host = 0, resolve_attached = 0;
5987 mpls_label_t *next_hop_out_label_stack = NULL;
5988 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
5989 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
5991 /* Parse args required to build the message */
5992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5998 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6003 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6008 else if (unformat (i, "/%d", &dst_address_length))
6010 address_length_set = 1;
6013 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6014 &v4_next_hop_address))
6018 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6019 &v6_next_hop_address))
6023 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6025 else if (unformat (i, "weight %d", &next_hop_weight))
6027 else if (unformat (i, "drop"))
6031 else if (unformat (i, "null-send-unreach"))
6035 else if (unformat (i, "null-send-prohibit"))
6039 else if (unformat (i, "local"))
6043 else if (unformat (i, "classify %d", &classify_table_index))
6047 else if (unformat (i, "del"))
6049 else if (unformat (i, "add"))
6051 else if (unformat (i, "not-last"))
6053 else if (unformat (i, "resolve-via-host"))
6055 else if (unformat (i, "resolve-via-attached"))
6056 resolve_attached = 1;
6057 else if (unformat (i, "multipath"))
6059 else if (unformat (i, "vrf %d", &vrf_id))
6061 else if (unformat (i, "create-vrf"))
6062 create_vrf_if_needed = 1;
6063 else if (unformat (i, "count %d", &count))
6065 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6067 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6069 else if (unformat (i, "out-label %d", &next_hop_out_label))
6070 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6071 else if (unformat (i, "via-label %d", &next_hop_via_label))
6073 else if (unformat (i, "random"))
6075 else if (unformat (i, "seed %d", &random_seed))
6079 clib_warning ("parse error '%U'", format_unformat_error, i);
6084 if (!next_hop_set && !is_drop && !is_local &&
6085 !is_classify && !is_unreach && !is_prohibit &&
6086 MPLS_LABEL_INVALID == next_hop_via_label)
6089 ("next hop / local / drop / unreach / prohibit / classify not set");
6093 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6095 errmsg ("next hop and next-hop via label set");
6098 if (address_set == 0)
6100 errmsg ("missing addresses");
6104 if (address_length_set == 0)
6106 errmsg ("missing address length");
6110 /* Generate a pile of unique, random routes */
6113 u32 this_random_address;
6114 random_hash = hash_create (count, sizeof (uword));
6116 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6117 for (j = 0; j <= count; j++)
6121 this_random_address = random_u32 (&random_seed);
6122 this_random_address =
6123 clib_host_to_net_u32 (this_random_address);
6125 while (hash_get (random_hash, this_random_address));
6126 vec_add1 (random_vector, this_random_address);
6127 hash_set (random_hash, this_random_address, 1);
6129 hash_free (random_hash);
6130 v4_dst_address.as_u32 = random_vector[0];
6135 /* Turn on async mode */
6136 vam->async_mode = 1;
6137 vam->async_errors = 0;
6138 before = vat_time_now (vam);
6141 for (j = 0; j < count; j++)
6143 /* Construct the API message */
6144 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6145 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6147 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6148 mp->table_id = ntohl (vrf_id);
6149 mp->create_vrf_if_needed = create_vrf_if_needed;
6151 mp->is_add = is_add;
6152 mp->is_drop = is_drop;
6153 mp->is_unreach = is_unreach;
6154 mp->is_prohibit = is_prohibit;
6155 mp->is_ipv6 = is_ipv6;
6156 mp->is_local = is_local;
6157 mp->is_classify = is_classify;
6158 mp->is_multipath = is_multipath;
6159 mp->is_resolve_host = resolve_host;
6160 mp->is_resolve_attached = resolve_attached;
6161 mp->not_last = not_last;
6162 mp->next_hop_weight = next_hop_weight;
6163 mp->dst_address_length = dst_address_length;
6164 mp->next_hop_table_id = ntohl (next_hop_table_id);
6165 mp->classify_table_index = ntohl (classify_table_index);
6166 mp->next_hop_via_label = ntohl (next_hop_via_label);
6167 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6168 if (0 != mp->next_hop_n_out_labels)
6170 memcpy (mp->next_hop_out_label_stack,
6171 next_hop_out_label_stack,
6172 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6173 vec_free (next_hop_out_label_stack);
6178 clib_memcpy (mp->dst_address, &v6_dst_address,
6179 sizeof (v6_dst_address));
6181 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6182 sizeof (v6_next_hop_address));
6183 increment_v6_address (&v6_dst_address);
6187 clib_memcpy (mp->dst_address, &v4_dst_address,
6188 sizeof (v4_dst_address));
6190 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6191 sizeof (v4_next_hop_address));
6193 v4_dst_address.as_u32 = random_vector[j + 1];
6195 increment_v4_address (&v4_dst_address);
6199 /* If we receive SIGTERM, stop now... */
6204 /* When testing multiple add/del ops, use a control-ping to sync */
6207 vl_api_control_ping_t *mp;
6210 /* Shut off async mode */
6211 vam->async_mode = 0;
6213 M (CONTROL_PING, control_ping);
6216 timeout = vat_time_now (vam) + 1.0;
6217 while (vat_time_now (vam) < timeout)
6218 if (vam->result_ready == 1)
6223 if (vam->retval == -99)
6226 if (vam->async_errors > 0)
6228 errmsg ("%d asynchronous errors", vam->async_errors);
6231 vam->async_errors = 0;
6232 after = vat_time_now (vam);
6234 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6238 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6239 count, after - before, count / (after - before));
6243 /* Wait for a reply... */
6247 /* Return the good/bad news */
6248 return (vam->retval);
6252 api_mpls_route_add_del (vat_main_t * vam)
6254 unformat_input_t *i = vam->input;
6255 vl_api_mpls_route_add_del_t *mp;
6257 u32 sw_if_index = ~0, table_id = 0;
6258 u8 create_table_if_needed = 0;
6260 u32 next_hop_weight = 1;
6261 u8 is_multipath = 0;
6262 u32 next_hop_table_id = 0;
6263 u8 next_hop_set = 0;
6264 ip4_address_t v4_next_hop_address = {
6267 ip6_address_t v6_next_hop_address = { {0} };
6271 u32 classify_table_index = ~0;
6273 u8 resolve_host = 0, resolve_attached = 0;
6274 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6275 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6276 mpls_label_t *next_hop_out_label_stack = NULL;
6277 mpls_label_t local_label = MPLS_LABEL_INVALID;
6279 u8 next_hop_proto_is_ip4 = 1;
6281 /* Parse args required to build the message */
6282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6284 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6286 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6288 else if (unformat (i, "%d", &local_label))
6290 else if (unformat (i, "eos"))
6292 else if (unformat (i, "non-eos"))
6294 else if (unformat (i, "via %U", unformat_ip4_address,
6295 &v4_next_hop_address))
6298 next_hop_proto_is_ip4 = 1;
6300 else if (unformat (i, "via %U", unformat_ip6_address,
6301 &v6_next_hop_address))
6304 next_hop_proto_is_ip4 = 0;
6306 else if (unformat (i, "weight %d", &next_hop_weight))
6308 else if (unformat (i, "create-table"))
6309 create_table_if_needed = 1;
6310 else if (unformat (i, "classify %d", &classify_table_index))
6314 else if (unformat (i, "del"))
6316 else if (unformat (i, "add"))
6318 else if (unformat (i, "resolve-via-host"))
6320 else if (unformat (i, "resolve-via-attached"))
6321 resolve_attached = 1;
6322 else if (unformat (i, "multipath"))
6324 else if (unformat (i, "count %d", &count))
6326 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6329 next_hop_proto_is_ip4 = 1;
6331 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6334 next_hop_proto_is_ip4 = 0;
6336 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6338 else if (unformat (i, "via-label %d", &next_hop_via_label))
6340 else if (unformat (i, "out-label %d", &next_hop_out_label))
6341 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6344 clib_warning ("parse error '%U'", format_unformat_error, i);
6349 if (!next_hop_set && !is_classify)
6351 errmsg ("next hop / classify not set");
6355 if (MPLS_LABEL_INVALID == local_label)
6357 errmsg ("missing label");
6363 /* Turn on async mode */
6364 vam->async_mode = 1;
6365 vam->async_errors = 0;
6366 before = vat_time_now (vam);
6369 for (j = 0; j < count; j++)
6371 /* Construct the API message */
6372 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6373 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6375 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6376 mp->mr_table_id = ntohl (table_id);
6377 mp->mr_create_table_if_needed = create_table_if_needed;
6379 mp->mr_is_add = is_add;
6380 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6381 mp->mr_is_classify = is_classify;
6382 mp->mr_is_multipath = is_multipath;
6383 mp->mr_is_resolve_host = resolve_host;
6384 mp->mr_is_resolve_attached = resolve_attached;
6385 mp->mr_next_hop_weight = next_hop_weight;
6386 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6387 mp->mr_classify_table_index = ntohl (classify_table_index);
6388 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6389 mp->mr_label = ntohl (local_label);
6390 mp->mr_eos = is_eos;
6392 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6393 if (0 != mp->mr_next_hop_n_out_labels)
6395 memcpy (mp->mr_next_hop_out_label_stack,
6396 next_hop_out_label_stack,
6397 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6398 vec_free (next_hop_out_label_stack);
6403 if (next_hop_proto_is_ip4)
6405 clib_memcpy (mp->mr_next_hop,
6406 &v4_next_hop_address,
6407 sizeof (v4_next_hop_address));
6411 clib_memcpy (mp->mr_next_hop,
6412 &v6_next_hop_address,
6413 sizeof (v6_next_hop_address));
6420 /* If we receive SIGTERM, stop now... */
6425 /* When testing multiple add/del ops, use a control-ping to sync */
6428 vl_api_control_ping_t *mp;
6431 /* Shut off async mode */
6432 vam->async_mode = 0;
6434 M (CONTROL_PING, control_ping);
6437 timeout = vat_time_now (vam) + 1.0;
6438 while (vat_time_now (vam) < timeout)
6439 if (vam->result_ready == 1)
6444 if (vam->retval == -99)
6447 if (vam->async_errors > 0)
6449 errmsg ("%d asynchronous errors", vam->async_errors);
6452 vam->async_errors = 0;
6453 after = vat_time_now (vam);
6455 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6459 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6460 count, after - before, count / (after - before));
6464 /* Wait for a reply... */
6468 /* Return the good/bad news */
6469 return (vam->retval);
6473 api_mpls_ip_bind_unbind (vat_main_t * vam)
6475 unformat_input_t *i = vam->input;
6476 vl_api_mpls_ip_bind_unbind_t *mp;
6478 u32 ip_table_id = 0;
6479 u8 create_table_if_needed = 0;
6482 ip4_address_t v4_address;
6483 ip6_address_t v6_address;
6486 mpls_label_t local_label = MPLS_LABEL_INVALID;
6488 /* Parse args required to build the message */
6489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6491 if (unformat (i, "%U/%d", unformat_ip4_address,
6492 &v4_address, &address_length))
6497 else if (unformat (i, "%U/%d", unformat_ip6_address,
6498 &v6_address, &address_length))
6503 else if (unformat (i, "%d", &local_label))
6505 else if (unformat (i, "create-table"))
6506 create_table_if_needed = 1;
6507 else if (unformat (i, "table-id %d", &ip_table_id))
6509 else if (unformat (i, "unbind"))
6511 else if (unformat (i, "bind"))
6515 clib_warning ("parse error '%U'", format_unformat_error, i);
6522 errmsg ("IP addres not set");
6526 if (MPLS_LABEL_INVALID == local_label)
6528 errmsg ("missing label");
6532 /* Construct the API message */
6533 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6535 mp->mb_create_table_if_needed = create_table_if_needed;
6536 mp->mb_is_bind = is_bind;
6537 mp->mb_is_ip4 = is_ip4;
6538 mp->mb_ip_table_id = ntohl (ip_table_id);
6539 mp->mb_mpls_table_id = 0;
6540 mp->mb_label = ntohl (local_label);
6541 mp->mb_address_length = address_length;
6544 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6546 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6551 /* Wait for a reply... */
6556 api_proxy_arp_add_del (vat_main_t * vam)
6558 unformat_input_t *i = vam->input;
6559 vl_api_proxy_arp_add_del_t *mp;
6563 ip4_address_t lo, hi;
6566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6568 if (unformat (i, "vrf %d", &vrf_id))
6570 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6571 unformat_ip4_address, &hi))
6573 else if (unformat (i, "del"))
6577 clib_warning ("parse error '%U'", format_unformat_error, i);
6584 errmsg ("address range not set");
6588 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6590 mp->vrf_id = ntohl (vrf_id);
6591 mp->is_add = is_add;
6592 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6593 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6602 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6604 unformat_input_t *i = vam->input;
6605 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6609 u8 sw_if_index_set = 0;
6611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6613 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6614 sw_if_index_set = 1;
6615 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6616 sw_if_index_set = 1;
6617 else if (unformat (i, "enable"))
6619 else if (unformat (i, "disable"))
6623 clib_warning ("parse error '%U'", format_unformat_error, i);
6628 if (sw_if_index_set == 0)
6630 errmsg ("missing interface name or sw_if_index");
6634 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6636 mp->sw_if_index = ntohl (sw_if_index);
6637 mp->enable_disable = enable;
6646 api_mpls_tunnel_add_del (vat_main_t * vam)
6648 unformat_input_t *i = vam->input;
6649 vl_api_mpls_tunnel_add_del_t *mp;
6654 u32 sw_if_index = ~0;
6655 u32 next_hop_sw_if_index = ~0;
6656 u32 next_hop_proto_is_ip4 = 1;
6658 u32 next_hop_table_id = 0;
6659 ip4_address_t v4_next_hop_address = {
6662 ip6_address_t v6_next_hop_address = { {0} };
6663 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6667 if (unformat (i, "add"))
6669 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6671 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6673 else if (unformat (i, "via %U",
6674 unformat_ip4_address, &v4_next_hop_address))
6676 next_hop_proto_is_ip4 = 1;
6678 else if (unformat (i, "via %U",
6679 unformat_ip6_address, &v6_next_hop_address))
6681 next_hop_proto_is_ip4 = 0;
6683 else if (unformat (i, "l2-only"))
6685 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6687 else if (unformat (i, "out-label %d", &next_hop_out_label))
6688 vec_add1 (labels, ntohl (next_hop_out_label));
6691 clib_warning ("parse error '%U'", format_unformat_error, i);
6696 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6697 sizeof (mpls_label_t) * vec_len (labels));
6699 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6700 mp->mt_sw_if_index = ntohl (sw_if_index);
6701 mp->mt_is_add = is_add;
6702 mp->mt_l2_only = l2_only;
6703 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6704 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6706 mp->mt_next_hop_n_out_labels = vec_len (labels);
6708 if (0 != mp->mt_next_hop_n_out_labels)
6710 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6711 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6715 if (next_hop_proto_is_ip4)
6717 clib_memcpy (mp->mt_next_hop,
6718 &v4_next_hop_address, sizeof (v4_next_hop_address));
6722 clib_memcpy (mp->mt_next_hop,
6723 &v6_next_hop_address, sizeof (v6_next_hop_address));
6733 api_sw_interface_set_unnumbered (vat_main_t * vam)
6735 unformat_input_t *i = vam->input;
6736 vl_api_sw_interface_set_unnumbered_t *mp;
6739 u32 unnum_sw_index = ~0;
6741 u8 sw_if_index_set = 0;
6743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6746 sw_if_index_set = 1;
6747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6748 sw_if_index_set = 1;
6749 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6751 else if (unformat (i, "del"))
6755 clib_warning ("parse error '%U'", format_unformat_error, i);
6760 if (sw_if_index_set == 0)
6762 errmsg ("missing interface name or sw_if_index");
6766 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6768 mp->sw_if_index = ntohl (sw_if_index);
6769 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6770 mp->is_add = is_add;
6779 api_ip_neighbor_add_del (vat_main_t * vam)
6781 unformat_input_t *i = vam->input;
6782 vl_api_ip_neighbor_add_del_t *mp;
6785 u8 sw_if_index_set = 0;
6791 u8 v4_address_set = 0;
6792 u8 v6_address_set = 0;
6793 ip4_address_t v4address;
6794 ip6_address_t v6address;
6796 memset (mac_address, 0, sizeof (mac_address));
6798 /* Parse args required to build the message */
6799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6801 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6805 else if (unformat (i, "del"))
6808 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6809 sw_if_index_set = 1;
6810 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6811 sw_if_index_set = 1;
6812 else if (unformat (i, "is_static"))
6814 else if (unformat (i, "vrf %d", &vrf_id))
6816 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6818 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6822 clib_warning ("parse error '%U'", format_unformat_error, i);
6827 if (sw_if_index_set == 0)
6829 errmsg ("missing interface name or sw_if_index");
6832 if (v4_address_set && v6_address_set)
6834 errmsg ("both v4 and v6 addresses set");
6837 if (!v4_address_set && !v6_address_set)
6839 errmsg ("no address set");
6843 /* Construct the API message */
6844 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6846 mp->sw_if_index = ntohl (sw_if_index);
6847 mp->is_add = is_add;
6848 mp->vrf_id = ntohl (vrf_id);
6849 mp->is_static = is_static;
6851 clib_memcpy (mp->mac_address, mac_address, 6);
6855 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6859 /* mp->is_ipv6 = 0; via memset in M macro above */
6860 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6866 /* Wait for a reply, return good/bad news */
6874 api_reset_vrf (vat_main_t * vam)
6876 unformat_input_t *i = vam->input;
6877 vl_api_reset_vrf_t *mp;
6883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6885 if (unformat (i, "vrf %d", &vrf_id))
6887 else if (unformat (i, "ipv6"))
6891 clib_warning ("parse error '%U'", format_unformat_error, i);
6896 if (vrf_id_set == 0)
6898 errmsg ("missing vrf id");
6902 M (RESET_VRF, reset_vrf);
6904 mp->vrf_id = ntohl (vrf_id);
6905 mp->is_ipv6 = is_ipv6;
6914 api_create_vlan_subif (vat_main_t * vam)
6916 unformat_input_t *i = vam->input;
6917 vl_api_create_vlan_subif_t *mp;
6920 u8 sw_if_index_set = 0;
6924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6926 if (unformat (i, "sw_if_index %d", &sw_if_index))
6927 sw_if_index_set = 1;
6929 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6930 sw_if_index_set = 1;
6931 else if (unformat (i, "vlan %d", &vlan_id))
6935 clib_warning ("parse error '%U'", format_unformat_error, i);
6940 if (sw_if_index_set == 0)
6942 errmsg ("missing interface name or sw_if_index");
6946 if (vlan_id_set == 0)
6948 errmsg ("missing vlan_id");
6951 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6953 mp->sw_if_index = ntohl (sw_if_index);
6954 mp->vlan_id = ntohl (vlan_id);
6962 #define foreach_create_subif_bit \
6969 _(outer_vlan_id_any) \
6970 _(inner_vlan_id_any)
6973 api_create_subif (vat_main_t * vam)
6975 unformat_input_t *i = vam->input;
6976 vl_api_create_subif_t *mp;
6979 u8 sw_if_index_set = 0;
6986 u32 exact_match = 0;
6987 u32 default_sub = 0;
6988 u32 outer_vlan_id_any = 0;
6989 u32 inner_vlan_id_any = 0;
6991 u16 outer_vlan_id = 0;
6992 u16 inner_vlan_id = 0;
6994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6996 if (unformat (i, "sw_if_index %d", &sw_if_index))
6997 sw_if_index_set = 1;
6999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7000 sw_if_index_set = 1;
7001 else if (unformat (i, "sub_id %d", &sub_id))
7003 else if (unformat (i, "outer_vlan_id %d", &tmp))
7004 outer_vlan_id = tmp;
7005 else if (unformat (i, "inner_vlan_id %d", &tmp))
7006 inner_vlan_id = tmp;
7008 #define _(a) else if (unformat (i, #a)) a = 1 ;
7009 foreach_create_subif_bit
7013 clib_warning ("parse error '%U'", format_unformat_error, i);
7018 if (sw_if_index_set == 0)
7020 errmsg ("missing interface name or sw_if_index");
7024 if (sub_id_set == 0)
7026 errmsg ("missing sub_id");
7029 M (CREATE_SUBIF, create_subif);
7031 mp->sw_if_index = ntohl (sw_if_index);
7032 mp->sub_id = ntohl (sub_id);
7034 #define _(a) mp->a = a;
7035 foreach_create_subif_bit;
7038 mp->outer_vlan_id = ntohs (outer_vlan_id);
7039 mp->inner_vlan_id = ntohs (inner_vlan_id);
7048 api_oam_add_del (vat_main_t * vam)
7050 unformat_input_t *i = vam->input;
7051 vl_api_oam_add_del_t *mp;
7055 ip4_address_t src, dst;
7059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7061 if (unformat (i, "vrf %d", &vrf_id))
7063 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7065 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7067 else if (unformat (i, "del"))
7071 clib_warning ("parse error '%U'", format_unformat_error, i);
7078 errmsg ("missing src addr");
7084 errmsg ("missing dst addr");
7088 M (OAM_ADD_DEL, oam_add_del);
7090 mp->vrf_id = ntohl (vrf_id);
7091 mp->is_add = is_add;
7092 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7093 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7102 api_reset_fib (vat_main_t * vam)
7104 unformat_input_t *i = vam->input;
7105 vl_api_reset_fib_t *mp;
7111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7113 if (unformat (i, "vrf %d", &vrf_id))
7115 else if (unformat (i, "ipv6"))
7119 clib_warning ("parse error '%U'", format_unformat_error, i);
7124 if (vrf_id_set == 0)
7126 errmsg ("missing vrf id");
7130 M (RESET_FIB, reset_fib);
7132 mp->vrf_id = ntohl (vrf_id);
7133 mp->is_ipv6 = is_ipv6;
7142 api_dhcp_proxy_config (vat_main_t * vam)
7144 unformat_input_t *i = vam->input;
7145 vl_api_dhcp_proxy_config_t *mp;
7150 u8 v4_address_set = 0;
7151 u8 v6_address_set = 0;
7152 ip4_address_t v4address;
7153 ip6_address_t v6address;
7154 u8 v4_src_address_set = 0;
7155 u8 v6_src_address_set = 0;
7156 ip4_address_t v4srcaddress;
7157 ip6_address_t v6srcaddress;
7159 /* Parse args required to build the message */
7160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7162 if (unformat (i, "del"))
7164 else if (unformat (i, "vrf %d", &vrf_id))
7166 else if (unformat (i, "insert-cid %d", &insert_cid))
7168 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7170 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7172 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7173 v4_src_address_set = 1;
7174 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7175 v6_src_address_set = 1;
7180 if (v4_address_set && v6_address_set)
7182 errmsg ("both v4 and v6 server addresses set");
7185 if (!v4_address_set && !v6_address_set)
7187 errmsg ("no server addresses set");
7191 if (v4_src_address_set && v6_src_address_set)
7193 errmsg ("both v4 and v6 src addresses set");
7196 if (!v4_src_address_set && !v6_src_address_set)
7198 errmsg ("no src addresses set");
7202 if (!(v4_src_address_set && v4_address_set) &&
7203 !(v6_src_address_set && v6_address_set))
7205 errmsg ("no matching server and src addresses set");
7209 /* Construct the API message */
7210 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7212 mp->insert_circuit_id = insert_cid;
7213 mp->is_add = is_add;
7214 mp->vrf_id = ntohl (vrf_id);
7218 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7219 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7223 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7224 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7230 /* Wait for a reply, return good/bad news */
7237 api_dhcp_proxy_config_2 (vat_main_t * vam)
7239 unformat_input_t *i = vam->input;
7240 vl_api_dhcp_proxy_config_2_t *mp;
7243 u32 server_vrf_id = 0;
7246 u8 v4_address_set = 0;
7247 u8 v6_address_set = 0;
7248 ip4_address_t v4address;
7249 ip6_address_t v6address;
7250 u8 v4_src_address_set = 0;
7251 u8 v6_src_address_set = 0;
7252 ip4_address_t v4srcaddress;
7253 ip6_address_t v6srcaddress;
7255 /* Parse args required to build the message */
7256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7258 if (unformat (i, "del"))
7260 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7262 else if (unformat (i, "server_vrf_id %d", &server_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_2, dhcp_proxy_config_2);
7310 mp->insert_circuit_id = insert_cid;
7311 mp->is_add = is_add;
7312 mp->rx_vrf_id = ntohl (rx_vrf_id);
7313 mp->server_vrf_id = ntohl (server_vrf_id);
7317 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7318 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7322 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7323 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7329 /* Wait for a reply, return good/bad news */
7336 api_dhcp_proxy_set_vss (vat_main_t * vam)
7338 unformat_input_t *i = vam->input;
7339 vl_api_dhcp_proxy_set_vss_t *mp;
7350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7352 if (unformat (i, "tbl_id %d", &tbl_id))
7354 if (unformat (i, "fib_id %d", &fib_id))
7356 if (unformat (i, "oui %d", &oui))
7358 else if (unformat (i, "ipv6"))
7360 else if (unformat (i, "del"))
7364 clib_warning ("parse error '%U'", format_unformat_error, i);
7369 if (tbl_id_set == 0)
7371 errmsg ("missing tbl id");
7375 if (fib_id_set == 0)
7377 errmsg ("missing fib id");
7382 errmsg ("missing oui");
7386 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7387 mp->tbl_id = ntohl (tbl_id);
7388 mp->fib_id = ntohl (fib_id);
7389 mp->oui = ntohl (oui);
7390 mp->is_ipv6 = is_ipv6;
7391 mp->is_add = is_add;
7400 api_dhcp_client_config (vat_main_t * vam)
7402 unformat_input_t *i = vam->input;
7403 vl_api_dhcp_client_config_t *mp;
7406 u8 sw_if_index_set = 0;
7409 u8 disable_event = 0;
7411 /* Parse args required to build the message */
7412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7414 if (unformat (i, "del"))
7417 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7418 sw_if_index_set = 1;
7419 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7420 sw_if_index_set = 1;
7421 else if (unformat (i, "hostname %s", &hostname))
7423 else if (unformat (i, "disable_event"))
7429 if (sw_if_index_set == 0)
7431 errmsg ("missing interface name or sw_if_index");
7435 if (vec_len (hostname) > 63)
7437 errmsg ("hostname too long");
7439 vec_add1 (hostname, 0);
7441 /* Construct the API message */
7442 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7444 mp->sw_if_index = ntohl (sw_if_index);
7445 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7446 vec_free (hostname);
7447 mp->is_add = is_add;
7448 mp->want_dhcp_event = disable_event ? 0 : 1;
7449 mp->pid = getpid ();
7454 /* Wait for a reply, return good/bad news */
7461 api_set_ip_flow_hash (vat_main_t * vam)
7463 unformat_input_t *i = vam->input;
7464 vl_api_set_ip_flow_hash_t *mp;
7476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7478 if (unformat (i, "vrf %d", &vrf_id))
7480 else if (unformat (i, "ipv6"))
7482 else if (unformat (i, "src"))
7484 else if (unformat (i, "dst"))
7486 else if (unformat (i, "sport"))
7488 else if (unformat (i, "dport"))
7490 else if (unformat (i, "proto"))
7492 else if (unformat (i, "reverse"))
7497 clib_warning ("parse error '%U'", format_unformat_error, i);
7502 if (vrf_id_set == 0)
7504 errmsg ("missing vrf id");
7508 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7514 mp->reverse = reverse;
7515 mp->vrf_id = ntohl (vrf_id);
7516 mp->is_ipv6 = is_ipv6;
7525 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7527 unformat_input_t *i = vam->input;
7528 vl_api_sw_interface_ip6_enable_disable_t *mp;
7531 u8 sw_if_index_set = 0;
7534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7537 sw_if_index_set = 1;
7538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7539 sw_if_index_set = 1;
7540 else if (unformat (i, "enable"))
7542 else if (unformat (i, "disable"))
7546 clib_warning ("parse error '%U'", format_unformat_error, i);
7551 if (sw_if_index_set == 0)
7553 errmsg ("missing interface name or sw_if_index");
7557 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7559 mp->sw_if_index = ntohl (sw_if_index);
7560 mp->enable = enable;
7569 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7571 unformat_input_t *i = vam->input;
7572 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7575 u8 sw_if_index_set = 0;
7576 u8 v6_address_set = 0;
7577 ip6_address_t v6address;
7579 /* Parse args required to build the message */
7580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7583 sw_if_index_set = 1;
7584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7585 sw_if_index_set = 1;
7586 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7592 if (sw_if_index_set == 0)
7594 errmsg ("missing interface name or sw_if_index");
7597 if (!v6_address_set)
7599 errmsg ("no address set");
7603 /* Construct the API message */
7604 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7605 sw_interface_ip6_set_link_local_address);
7607 mp->sw_if_index = ntohl (sw_if_index);
7608 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7613 /* Wait for a reply, return good/bad news */
7622 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7624 unformat_input_t *i = vam->input;
7625 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7628 u8 sw_if_index_set = 0;
7629 u32 address_length = 0;
7630 u8 v6_address_set = 0;
7631 ip6_address_t v6address;
7633 u8 no_advertise = 0;
7635 u8 no_autoconfig = 0;
7638 u32 val_lifetime = 0;
7639 u32 pref_lifetime = 0;
7641 /* Parse args required to build the message */
7642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7645 sw_if_index_set = 1;
7646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7647 sw_if_index_set = 1;
7648 else if (unformat (i, "%U/%d",
7649 unformat_ip6_address, &v6address, &address_length))
7651 else if (unformat (i, "val_life %d", &val_lifetime))
7653 else if (unformat (i, "pref_life %d", &pref_lifetime))
7655 else if (unformat (i, "def"))
7657 else if (unformat (i, "noadv"))
7659 else if (unformat (i, "offl"))
7661 else if (unformat (i, "noauto"))
7663 else if (unformat (i, "nolink"))
7665 else if (unformat (i, "isno"))
7669 clib_warning ("parse error '%U'", format_unformat_error, i);
7674 if (sw_if_index_set == 0)
7676 errmsg ("missing interface name or sw_if_index");
7679 if (!v6_address_set)
7681 errmsg ("no address set");
7685 /* Construct the API message */
7686 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7688 mp->sw_if_index = ntohl (sw_if_index);
7689 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7690 mp->address_length = address_length;
7691 mp->use_default = use_default;
7692 mp->no_advertise = no_advertise;
7693 mp->off_link = off_link;
7694 mp->no_autoconfig = no_autoconfig;
7695 mp->no_onlink = no_onlink;
7697 mp->val_lifetime = ntohl (val_lifetime);
7698 mp->pref_lifetime = ntohl (pref_lifetime);
7703 /* Wait for a reply, return good/bad news */
7711 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7713 unformat_input_t *i = vam->input;
7714 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7717 u8 sw_if_index_set = 0;
7722 u8 send_unicast = 0;
7725 u8 default_router = 0;
7726 u32 max_interval = 0;
7727 u32 min_interval = 0;
7729 u32 initial_count = 0;
7730 u32 initial_interval = 0;
7733 /* Parse args required to build the message */
7734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7736 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7737 sw_if_index_set = 1;
7738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7739 sw_if_index_set = 1;
7740 else if (unformat (i, "maxint %d", &max_interval))
7742 else if (unformat (i, "minint %d", &min_interval))
7744 else if (unformat (i, "life %d", &lifetime))
7746 else if (unformat (i, "count %d", &initial_count))
7748 else if (unformat (i, "interval %d", &initial_interval))
7750 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7752 else if (unformat (i, "managed"))
7754 else if (unformat (i, "other"))
7756 else if (unformat (i, "ll"))
7758 else if (unformat (i, "send"))
7760 else if (unformat (i, "cease"))
7762 else if (unformat (i, "isno"))
7764 else if (unformat (i, "def"))
7768 clib_warning ("parse error '%U'", format_unformat_error, i);
7773 if (sw_if_index_set == 0)
7775 errmsg ("missing interface name or sw_if_index");
7779 /* Construct the API message */
7780 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7782 mp->sw_if_index = ntohl (sw_if_index);
7783 mp->max_interval = ntohl (max_interval);
7784 mp->min_interval = ntohl (min_interval);
7785 mp->lifetime = ntohl (lifetime);
7786 mp->initial_count = ntohl (initial_count);
7787 mp->initial_interval = ntohl (initial_interval);
7788 mp->suppress = suppress;
7789 mp->managed = managed;
7791 mp->ll_option = ll_option;
7792 mp->send_unicast = send_unicast;
7795 mp->default_router = default_router;
7800 /* Wait for a reply, return good/bad news */
7808 api_set_arp_neighbor_limit (vat_main_t * vam)
7810 unformat_input_t *i = vam->input;
7811 vl_api_set_arp_neighbor_limit_t *mp;
7817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7819 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7821 else if (unformat (i, "ipv6"))
7825 clib_warning ("parse error '%U'", format_unformat_error, i);
7832 errmsg ("missing limit value");
7836 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7838 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7839 mp->is_ipv6 = is_ipv6;
7848 api_l2_patch_add_del (vat_main_t * vam)
7850 unformat_input_t *i = vam->input;
7851 vl_api_l2_patch_add_del_t *mp;
7854 u8 rx_sw_if_index_set = 0;
7856 u8 tx_sw_if_index_set = 0;
7859 /* Parse args required to build the message */
7860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7862 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7863 rx_sw_if_index_set = 1;
7864 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7865 tx_sw_if_index_set = 1;
7866 else if (unformat (i, "rx"))
7868 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7870 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7872 rx_sw_if_index_set = 1;
7877 else if (unformat (i, "tx"))
7879 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7881 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7883 tx_sw_if_index_set = 1;
7888 else if (unformat (i, "del"))
7894 if (rx_sw_if_index_set == 0)
7896 errmsg ("missing rx interface name or rx_sw_if_index");
7900 if (tx_sw_if_index_set == 0)
7902 errmsg ("missing tx interface name or tx_sw_if_index");
7906 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7908 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7909 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7910 mp->is_add = is_add;
7919 api_ioam_enable (vat_main_t * vam)
7921 unformat_input_t *input = vam->input;
7922 vl_api_ioam_enable_t *mp;
7925 int has_trace_option = 0;
7926 int has_pot_option = 0;
7927 int has_seqno_option = 0;
7928 int has_analyse_option = 0;
7930 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7932 if (unformat (input, "trace"))
7933 has_trace_option = 1;
7934 else if (unformat (input, "pot"))
7936 else if (unformat (input, "seqno"))
7937 has_seqno_option = 1;
7938 else if (unformat (input, "analyse"))
7939 has_analyse_option = 1;
7943 M (IOAM_ENABLE, ioam_enable);
7944 mp->id = htons (id);
7945 mp->seqno = has_seqno_option;
7946 mp->analyse = has_analyse_option;
7947 mp->pot_enable = has_pot_option;
7948 mp->trace_enable = has_trace_option;
7959 api_ioam_disable (vat_main_t * vam)
7961 vl_api_ioam_disable_t *mp;
7964 M (IOAM_DISABLE, ioam_disable);
7971 api_sr_tunnel_add_del (vat_main_t * vam)
7973 unformat_input_t *i = vam->input;
7974 vl_api_sr_tunnel_add_del_t *mp;
7978 ip6_address_t src_address;
7979 int src_address_set = 0;
7980 ip6_address_t dst_address;
7982 int dst_address_set = 0;
7984 u32 rx_table_id = 0;
7985 u32 tx_table_id = 0;
7986 ip6_address_t *segments = 0;
7987 ip6_address_t *this_seg;
7988 ip6_address_t *tags = 0;
7989 ip6_address_t *this_tag;
7990 ip6_address_t next_address, tag;
7992 u8 *policy_name = 0;
7994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7996 if (unformat (i, "del"))
7998 else if (unformat (i, "name %s", &name))
8000 else if (unformat (i, "policy %s", &policy_name))
8002 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8004 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8006 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8007 src_address_set = 1;
8008 else if (unformat (i, "dst %U/%d",
8009 unformat_ip6_address, &dst_address, &dst_mask_width))
8010 dst_address_set = 1;
8011 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8013 vec_add2 (segments, this_seg, 1);
8014 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8015 sizeof (*this_seg));
8017 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8019 vec_add2 (tags, this_tag, 1);
8020 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8022 else if (unformat (i, "clean"))
8023 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8024 else if (unformat (i, "protected"))
8025 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8026 else if (unformat (i, "InPE %d", &pl_index))
8028 if (pl_index <= 0 || pl_index > 4)
8030 pl_index_range_error:
8031 errmsg ("pl index %d out of range", pl_index);
8035 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8037 else if (unformat (i, "EgPE %d", &pl_index))
8039 if (pl_index <= 0 || pl_index > 4)
8040 goto pl_index_range_error;
8042 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8044 else if (unformat (i, "OrgSrc %d", &pl_index))
8046 if (pl_index <= 0 || pl_index > 4)
8047 goto pl_index_range_error;
8049 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8055 if (!src_address_set)
8057 errmsg ("src address required");
8061 if (!dst_address_set)
8063 errmsg ("dst address required");
8069 errmsg ("at least one sr segment required");
8073 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8074 vec_len (segments) * sizeof (ip6_address_t)
8075 + vec_len (tags) * sizeof (ip6_address_t));
8077 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8078 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8079 mp->dst_mask_width = dst_mask_width;
8080 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8081 mp->n_segments = vec_len (segments);
8082 mp->n_tags = vec_len (tags);
8083 mp->is_add = is_del == 0;
8084 clib_memcpy (mp->segs_and_tags, segments,
8085 vec_len (segments) * sizeof (ip6_address_t));
8086 clib_memcpy (mp->segs_and_tags +
8087 vec_len (segments) * sizeof (ip6_address_t), tags,
8088 vec_len (tags) * sizeof (ip6_address_t));
8090 mp->outer_vrf_id = ntohl (rx_table_id);
8091 mp->inner_vrf_id = ntohl (tx_table_id);
8092 memcpy (mp->name, name, vec_len (name));
8093 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8095 vec_free (segments);
8104 api_sr_policy_add_del (vat_main_t * vam)
8106 unformat_input_t *input = vam->input;
8107 vl_api_sr_policy_add_del_t *mp;
8111 u8 *tunnel_name = 0;
8112 u8 **tunnel_names = 0;
8117 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8118 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8122 if (unformat (input, "del"))
8124 else if (unformat (input, "name %s", &name))
8126 else if (unformat (input, "tunnel %s", &tunnel_name))
8130 vec_add1 (tunnel_names, tunnel_name);
8132 - length = #bytes to store in serial vector
8133 - +1 = byte to store that length
8135 tunnel_names_length += (vec_len (tunnel_name) + 1);
8146 errmsg ("policy name required");
8150 if ((!tunnel_set) && (!is_del))
8152 errmsg ("tunnel name required");
8156 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8160 mp->is_add = !is_del;
8162 memcpy (mp->name, name, vec_len (name));
8163 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8164 u8 *serial_orig = 0;
8165 vec_validate (serial_orig, tunnel_names_length);
8166 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8167 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8169 for (j = 0; j < vec_len (tunnel_names); j++)
8171 tun_name_len = vec_len (tunnel_names[j]);
8172 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8173 serial_orig += 1; // Move along one byte to store the actual tunnel name
8174 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8175 serial_orig += tun_name_len; // Advance past the copy
8177 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8179 vec_free (tunnel_names);
8180 vec_free (tunnel_name);
8188 api_sr_multicast_map_add_del (vat_main_t * vam)
8190 unformat_input_t *input = vam->input;
8191 vl_api_sr_multicast_map_add_del_t *mp;
8194 ip6_address_t multicast_address;
8195 u8 *policy_name = 0;
8196 int multicast_address_set = 0;
8198 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8200 if (unformat (input, "del"))
8204 (input, "address %U", unformat_ip6_address, &multicast_address))
8205 multicast_address_set = 1;
8206 else if (unformat (input, "sr-policy %s", &policy_name))
8212 if (!is_del && !policy_name)
8214 errmsg ("sr-policy name required");
8219 if (!multicast_address_set)
8221 errmsg ("address required");
8225 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8227 mp->is_add = !is_del;
8228 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8229 clib_memcpy (mp->multicast_address, &multicast_address,
8230 sizeof (mp->multicast_address));
8233 vec_free (policy_name);
8241 #define foreach_tcp_proto_field \
8245 #define foreach_udp_proto_field \
8249 #define foreach_ip4_proto_field \
8260 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8262 u8 **maskp = va_arg (*args, u8 **);
8264 u8 found_something = 0;
8267 #define _(a) u8 a=0;
8268 foreach_tcp_proto_field;
8271 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8274 #define _(a) else if (unformat (input, #a)) a=1;
8275 foreach_tcp_proto_field
8281 #define _(a) found_something += a;
8282 foreach_tcp_proto_field;
8285 if (found_something == 0)
8288 vec_validate (mask, sizeof (*tcp) - 1);
8290 tcp = (tcp_header_t *) mask;
8292 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8293 foreach_tcp_proto_field;
8301 unformat_udp_mask (unformat_input_t * input, va_list * args)
8303 u8 **maskp = va_arg (*args, u8 **);
8305 u8 found_something = 0;
8308 #define _(a) u8 a=0;
8309 foreach_udp_proto_field;
8312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8315 #define _(a) else if (unformat (input, #a)) a=1;
8316 foreach_udp_proto_field
8322 #define _(a) found_something += a;
8323 foreach_udp_proto_field;
8326 if (found_something == 0)
8329 vec_validate (mask, sizeof (*udp) - 1);
8331 udp = (udp_header_t *) mask;
8333 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8334 foreach_udp_proto_field;
8343 u16 src_port, dst_port;
8347 unformat_l4_mask (unformat_input_t * input, va_list * args)
8349 u8 **maskp = va_arg (*args, u8 **);
8350 u16 src_port = 0, dst_port = 0;
8351 tcpudp_header_t *tcpudp;
8353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8355 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8357 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8359 else if (unformat (input, "src_port"))
8361 else if (unformat (input, "dst_port"))
8367 if (!src_port && !dst_port)
8371 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8373 tcpudp = (tcpudp_header_t *) mask;
8374 tcpudp->src_port = src_port;
8375 tcpudp->dst_port = dst_port;
8383 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8385 u8 **maskp = va_arg (*args, u8 **);
8387 u8 found_something = 0;
8390 #define _(a) u8 a=0;
8391 foreach_ip4_proto_field;
8397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8399 if (unformat (input, "version"))
8401 else if (unformat (input, "hdr_length"))
8403 else if (unformat (input, "src"))
8405 else if (unformat (input, "dst"))
8407 else if (unformat (input, "proto"))
8410 #define _(a) else if (unformat (input, #a)) a=1;
8411 foreach_ip4_proto_field
8417 #define _(a) found_something += a;
8418 foreach_ip4_proto_field;
8421 if (found_something == 0)
8424 vec_validate (mask, sizeof (*ip) - 1);
8426 ip = (ip4_header_t *) mask;
8428 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8429 foreach_ip4_proto_field;
8432 ip->ip_version_and_header_length = 0;
8435 ip->ip_version_and_header_length |= 0xF0;
8438 ip->ip_version_and_header_length |= 0x0F;
8444 #define foreach_ip6_proto_field \
8452 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8454 u8 **maskp = va_arg (*args, u8 **);
8456 u8 found_something = 0;
8458 u32 ip_version_traffic_class_and_flow_label;
8460 #define _(a) u8 a=0;
8461 foreach_ip6_proto_field;
8464 u8 traffic_class = 0;
8467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8469 if (unformat (input, "version"))
8471 else if (unformat (input, "traffic-class"))
8473 else if (unformat (input, "flow-label"))
8475 else if (unformat (input, "src"))
8477 else if (unformat (input, "dst"))
8479 else if (unformat (input, "proto"))
8482 #define _(a) else if (unformat (input, #a)) a=1;
8483 foreach_ip6_proto_field
8489 #define _(a) found_something += a;
8490 foreach_ip6_proto_field;
8493 if (found_something == 0)
8496 vec_validate (mask, sizeof (*ip) - 1);
8498 ip = (ip6_header_t *) mask;
8500 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8501 foreach_ip6_proto_field;
8504 ip_version_traffic_class_and_flow_label = 0;
8507 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8510 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8513 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8515 ip->ip_version_traffic_class_and_flow_label =
8516 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8523 unformat_l3_mask (unformat_input_t * input, va_list * args)
8525 u8 **maskp = va_arg (*args, u8 **);
8527 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8529 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8531 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8540 unformat_l2_mask (unformat_input_t * input, va_list * args)
8542 u8 **maskp = va_arg (*args, u8 **);
8557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8559 if (unformat (input, "src"))
8561 else if (unformat (input, "dst"))
8563 else if (unformat (input, "proto"))
8565 else if (unformat (input, "tag1"))
8567 else if (unformat (input, "tag2"))
8569 else if (unformat (input, "ignore-tag1"))
8571 else if (unformat (input, "ignore-tag2"))
8573 else if (unformat (input, "cos1"))
8575 else if (unformat (input, "cos2"))
8577 else if (unformat (input, "dot1q"))
8579 else if (unformat (input, "dot1ad"))
8584 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8585 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8588 if (tag1 || ignore_tag1 || cos1 || dot1q)
8590 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8593 vec_validate (mask, len - 1);
8596 memset (mask, 0xff, 6);
8599 memset (mask + 6, 0xff, 6);
8603 /* inner vlan tag */
8612 mask[21] = mask[20] = 0xff;
8633 mask[16] = mask[17] = 0xff;
8643 mask[12] = mask[13] = 0xff;
8650 unformat_classify_mask (unformat_input_t * input, va_list * args)
8652 u8 **maskp = va_arg (*args, u8 **);
8653 u32 *skipp = va_arg (*args, u32 *);
8654 u32 *matchp = va_arg (*args, u32 *);
8662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8664 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8666 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8668 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8670 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8684 if (mask || l2 || l3 || l4)
8688 /* "With a free Ethernet header in every package" */
8690 vec_validate (l2, 13);
8694 vec_append (mask, l3);
8699 vec_append (mask, l4);
8704 /* Scan forward looking for the first significant mask octet */
8705 for (i = 0; i < vec_len (mask); i++)
8709 /* compute (skip, match) params */
8710 *skipp = i / sizeof (u32x4);
8711 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8713 /* Pad mask to an even multiple of the vector size */
8714 while (vec_len (mask) % sizeof (u32x4))
8717 match = vec_len (mask) / sizeof (u32x4);
8719 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8721 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8722 if (*tmp || *(tmp + 1))
8727 clib_warning ("BUG: match 0");
8729 _vec_len (mask) = match * sizeof (u32x4);
8740 #define foreach_l2_next \
8742 _(ethernet, ETHERNET_INPUT) \
8747 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8749 u32 *miss_next_indexp = va_arg (*args, u32 *);
8754 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8758 if (unformat (input, "%d", &tmp))
8767 *miss_next_indexp = next_index;
8771 #define foreach_ip_next \
8777 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8779 u32 *miss_next_indexp = va_arg (*args, u32 *);
8784 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8788 if (unformat (input, "%d", &tmp))
8797 *miss_next_indexp = next_index;
8801 #define foreach_acl_next \
8805 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8807 u32 *miss_next_indexp = va_arg (*args, u32 *);
8812 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8816 if (unformat (input, "permit"))
8821 else if (unformat (input, "%d", &tmp))
8830 *miss_next_indexp = next_index;
8835 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8837 u32 *r = va_arg (*args, u32 *);
8839 if (unformat (input, "conform-color"))
8840 *r = POLICE_CONFORM;
8841 else if (unformat (input, "exceed-color"))
8850 api_classify_add_del_table (vat_main_t * vam)
8852 unformat_input_t *i = vam->input;
8853 vl_api_classify_add_del_table_t *mp;
8860 u32 table_index = ~0;
8861 u32 next_table_index = ~0;
8862 u32 miss_next_index = ~0;
8863 u32 memory_size = 32 << 20;
8866 u32 current_data_flag = 0;
8867 int current_data_offset = 0;
8869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8871 if (unformat (i, "del"))
8873 else if (unformat (i, "del-chain"))
8878 else if (unformat (i, "buckets %d", &nbuckets))
8880 else if (unformat (i, "memory_size %d", &memory_size))
8882 else if (unformat (i, "skip %d", &skip))
8884 else if (unformat (i, "match %d", &match))
8886 else if (unformat (i, "table %d", &table_index))
8888 else if (unformat (i, "mask %U", unformat_classify_mask,
8889 &mask, &skip, &match))
8891 else if (unformat (i, "next-table %d", &next_table_index))
8893 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8896 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8899 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8902 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8904 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8910 if (is_add && mask == 0)
8912 errmsg ("Mask required");
8916 if (is_add && skip == ~0)
8918 errmsg ("skip count required");
8922 if (is_add && match == ~0)
8924 errmsg ("match count required");
8928 if (!is_add && table_index == ~0)
8930 errmsg ("table index required for delete");
8934 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8936 mp->is_add = is_add;
8937 mp->del_chain = del_chain;
8938 mp->table_index = ntohl (table_index);
8939 mp->nbuckets = ntohl (nbuckets);
8940 mp->memory_size = ntohl (memory_size);
8941 mp->skip_n_vectors = ntohl (skip);
8942 mp->match_n_vectors = ntohl (match);
8943 mp->next_table_index = ntohl (next_table_index);
8944 mp->miss_next_index = ntohl (miss_next_index);
8945 mp->current_data_flag = ntohl (current_data_flag);
8946 mp->current_data_offset = ntohl (current_data_offset);
8947 clib_memcpy (mp->mask, mask, vec_len (mask));
8957 unformat_l4_match (unformat_input_t * input, va_list * args)
8959 u8 **matchp = va_arg (*args, u8 **);
8961 u8 *proto_header = 0;
8967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8969 if (unformat (input, "src_port %d", &src_port))
8971 else if (unformat (input, "dst_port %d", &dst_port))
8977 h.src_port = clib_host_to_net_u16 (src_port);
8978 h.dst_port = clib_host_to_net_u16 (dst_port);
8979 vec_validate (proto_header, sizeof (h) - 1);
8980 memcpy (proto_header, &h, sizeof (h));
8982 *matchp = proto_header;
8988 unformat_ip4_match (unformat_input_t * input, va_list * args)
8990 u8 **matchp = va_arg (*args, u8 **);
8997 int src = 0, dst = 0;
8998 ip4_address_t src_val, dst_val;
9005 int fragment_id = 0;
9006 u32 fragment_id_val;
9012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9014 if (unformat (input, "version %d", &version_val))
9016 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9018 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9020 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9022 else if (unformat (input, "proto %d", &proto_val))
9024 else if (unformat (input, "tos %d", &tos_val))
9026 else if (unformat (input, "length %d", &length_val))
9028 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9030 else if (unformat (input, "ttl %d", &ttl_val))
9032 else if (unformat (input, "checksum %d", &checksum_val))
9038 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9039 + ttl + checksum == 0)
9043 * Aligned because we use the real comparison functions
9045 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9047 ip = (ip4_header_t *) match;
9049 /* These are realistically matched in practice */
9051 ip->src_address.as_u32 = src_val.as_u32;
9054 ip->dst_address.as_u32 = dst_val.as_u32;
9057 ip->protocol = proto_val;
9060 /* These are not, but they're included for completeness */
9062 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9065 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9071 ip->length = clib_host_to_net_u16 (length_val);
9077 ip->checksum = clib_host_to_net_u16 (checksum_val);
9084 unformat_ip6_match (unformat_input_t * input, va_list * args)
9086 u8 **matchp = va_arg (*args, u8 **);
9091 u8 traffic_class = 0;
9092 u32 traffic_class_val = 0;
9095 int src = 0, dst = 0;
9096 ip6_address_t src_val, dst_val;
9099 int payload_length = 0;
9100 u32 payload_length_val;
9103 u32 ip_version_traffic_class_and_flow_label;
9105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9107 if (unformat (input, "version %d", &version_val))
9109 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9111 else if (unformat (input, "flow_label %d", &flow_label_val))
9113 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9115 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9117 else if (unformat (input, "proto %d", &proto_val))
9119 else if (unformat (input, "payload_length %d", &payload_length_val))
9121 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9127 if (version + traffic_class + flow_label + src + dst + proto +
9128 payload_length + hop_limit == 0)
9132 * Aligned because we use the real comparison functions
9134 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9136 ip = (ip6_header_t *) match;
9139 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9142 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9145 ip->protocol = proto_val;
9147 ip_version_traffic_class_and_flow_label = 0;
9150 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9153 ip_version_traffic_class_and_flow_label |=
9154 (traffic_class_val & 0xFF) << 20;
9157 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9159 ip->ip_version_traffic_class_and_flow_label =
9160 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9163 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9166 ip->hop_limit = hop_limit_val;
9173 unformat_l3_match (unformat_input_t * input, va_list * args)
9175 u8 **matchp = va_arg (*args, u8 **);
9177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9179 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9181 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9190 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9192 u8 *tagp = va_arg (*args, u8 *);
9195 if (unformat (input, "%d", &tag))
9197 tagp[0] = (tag >> 8) & 0x0F;
9198 tagp[1] = tag & 0xFF;
9206 unformat_l2_match (unformat_input_t * input, va_list * args)
9208 u8 **matchp = va_arg (*args, u8 **);
9228 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9230 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9233 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9235 else if (unformat (input, "proto %U",
9236 unformat_ethernet_type_host_byte_order, &proto_val))
9238 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9240 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9242 else if (unformat (input, "ignore-tag1"))
9244 else if (unformat (input, "ignore-tag2"))
9246 else if (unformat (input, "cos1 %d", &cos1_val))
9248 else if (unformat (input, "cos2 %d", &cos2_val))
9253 if ((src + dst + proto + tag1 + tag2 +
9254 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9257 if (tag1 || ignore_tag1 || cos1)
9259 if (tag2 || ignore_tag2 || cos2)
9262 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9265 clib_memcpy (match, dst_val, 6);
9268 clib_memcpy (match + 6, src_val, 6);
9272 /* inner vlan tag */
9273 match[19] = tag2_val[1];
9274 match[18] = tag2_val[0];
9276 match[18] |= (cos2_val & 0x7) << 5;
9279 match[21] = proto_val & 0xff;
9280 match[20] = proto_val >> 8;
9284 match[15] = tag1_val[1];
9285 match[14] = tag1_val[0];
9288 match[14] |= (cos1_val & 0x7) << 5;
9294 match[15] = tag1_val[1];
9295 match[14] = tag1_val[0];
9298 match[17] = proto_val & 0xff;
9299 match[16] = proto_val >> 8;
9302 match[14] |= (cos1_val & 0x7) << 5;
9308 match[18] |= (cos2_val & 0x7) << 5;
9310 match[14] |= (cos1_val & 0x7) << 5;
9313 match[13] = proto_val & 0xff;
9314 match[12] = proto_val >> 8;
9323 unformat_classify_match (unformat_input_t * input, va_list * args)
9325 u8 **matchp = va_arg (*args, u8 **);
9326 u32 skip_n_vectors = va_arg (*args, u32);
9327 u32 match_n_vectors = va_arg (*args, u32);
9334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9336 if (unformat (input, "hex %U", unformat_hex_string, &match))
9338 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9340 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9342 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9356 if (match || l2 || l3 || l4)
9360 /* "Win a free Ethernet header in every packet" */
9362 vec_validate_aligned (l2, 13, sizeof (u32x4));
9366 vec_append_aligned (match, l3, sizeof (u32x4));
9371 vec_append_aligned (match, l4, sizeof (u32x4));
9376 /* Make sure the vector is big enough even if key is all 0's */
9377 vec_validate_aligned
9378 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9381 /* Set size, include skipped vectors */
9382 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9393 api_classify_add_del_session (vat_main_t * vam)
9395 unformat_input_t *i = vam->input;
9396 vl_api_classify_add_del_session_t *mp;
9398 u32 table_index = ~0;
9399 u32 hit_next_index = ~0;
9400 u32 opaque_index = ~0;
9404 u32 skip_n_vectors = 0;
9405 u32 match_n_vectors = 0;
9410 * Warning: you have to supply skip_n and match_n
9411 * because the API client cant simply look at the classify
9415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9417 if (unformat (i, "del"))
9419 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9422 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9425 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9428 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9430 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9432 else if (unformat (i, "opaque-index %d", &opaque_index))
9434 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9436 else if (unformat (i, "match_n %d", &match_n_vectors))
9438 else if (unformat (i, "match %U", unformat_classify_match,
9439 &match, skip_n_vectors, match_n_vectors))
9441 else if (unformat (i, "advance %d", &advance))
9443 else if (unformat (i, "table-index %d", &table_index))
9445 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9447 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9449 else if (unformat (i, "action %d", &action))
9451 else if (unformat (i, "metadata %d", &metadata))
9457 if (table_index == ~0)
9459 errmsg ("Table index required");
9463 if (is_add && match == 0)
9465 errmsg ("Match value required");
9469 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9471 mp->is_add = is_add;
9472 mp->table_index = ntohl (table_index);
9473 mp->hit_next_index = ntohl (hit_next_index);
9474 mp->opaque_index = ntohl (opaque_index);
9475 mp->advance = ntohl (advance);
9476 mp->action = action;
9477 mp->metadata = ntohl (metadata);
9478 clib_memcpy (mp->match, match, vec_len (match));
9487 api_classify_set_interface_ip_table (vat_main_t * vam)
9489 unformat_input_t *i = vam->input;
9490 vl_api_classify_set_interface_ip_table_t *mp;
9493 int sw_if_index_set;
9494 u32 table_index = ~0;
9497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9500 sw_if_index_set = 1;
9501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9502 sw_if_index_set = 1;
9503 else if (unformat (i, "table %d", &table_index))
9507 clib_warning ("parse error '%U'", format_unformat_error, i);
9512 if (sw_if_index_set == 0)
9514 errmsg ("missing interface name or sw_if_index");
9519 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9521 mp->sw_if_index = ntohl (sw_if_index);
9522 mp->table_index = ntohl (table_index);
9523 mp->is_ipv6 = is_ipv6;
9532 api_classify_set_interface_l2_tables (vat_main_t * vam)
9534 unformat_input_t *i = vam->input;
9535 vl_api_classify_set_interface_l2_tables_t *mp;
9538 int sw_if_index_set;
9539 u32 ip4_table_index = ~0;
9540 u32 ip6_table_index = ~0;
9541 u32 other_table_index = ~0;
9544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9546 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9547 sw_if_index_set = 1;
9548 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9549 sw_if_index_set = 1;
9550 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9552 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9554 else if (unformat (i, "other-table %d", &other_table_index))
9556 else if (unformat (i, "is-input %d", &is_input))
9560 clib_warning ("parse error '%U'", format_unformat_error, i);
9565 if (sw_if_index_set == 0)
9567 errmsg ("missing interface name or sw_if_index");
9572 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9574 mp->sw_if_index = ntohl (sw_if_index);
9575 mp->ip4_table_index = ntohl (ip4_table_index);
9576 mp->ip6_table_index = ntohl (ip6_table_index);
9577 mp->other_table_index = ntohl (other_table_index);
9578 mp->is_input = (u8) is_input;
9587 api_set_ipfix_exporter (vat_main_t * vam)
9589 unformat_input_t *i = vam->input;
9590 vl_api_set_ipfix_exporter_t *mp;
9591 ip4_address_t collector_address;
9592 u8 collector_address_set = 0;
9593 u32 collector_port = ~0;
9594 ip4_address_t src_address;
9595 u8 src_address_set = 0;
9598 u32 template_interval = ~0;
9599 u8 udp_checksum = 0;
9602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9604 if (unformat (i, "collector_address %U", unformat_ip4_address,
9605 &collector_address))
9606 collector_address_set = 1;
9607 else if (unformat (i, "collector_port %d", &collector_port))
9609 else if (unformat (i, "src_address %U", unformat_ip4_address,
9611 src_address_set = 1;
9612 else if (unformat (i, "vrf_id %d", &vrf_id))
9614 else if (unformat (i, "path_mtu %d", &path_mtu))
9616 else if (unformat (i, "template_interval %d", &template_interval))
9618 else if (unformat (i, "udp_checksum"))
9624 if (collector_address_set == 0)
9626 errmsg ("collector_address required");
9630 if (src_address_set == 0)
9632 errmsg ("src_address required");
9636 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9638 memcpy (mp->collector_address, collector_address.data,
9639 sizeof (collector_address.data));
9640 mp->collector_port = htons ((u16) collector_port);
9641 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9642 mp->vrf_id = htonl (vrf_id);
9643 mp->path_mtu = htonl (path_mtu);
9644 mp->template_interval = htonl (template_interval);
9645 mp->udp_checksum = udp_checksum;
9653 api_set_ipfix_classify_stream (vat_main_t * vam)
9655 unformat_input_t *i = vam->input;
9656 vl_api_set_ipfix_classify_stream_t *mp;
9658 u32 src_port = UDP_DST_PORT_ipfix;
9661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9663 if (unformat (i, "domain %d", &domain_id))
9665 else if (unformat (i, "src_port %d", &src_port))
9669 errmsg ("unknown input `%U'", format_unformat_error, i);
9674 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9676 mp->domain_id = htonl (domain_id);
9677 mp->src_port = htons ((u16) src_port);
9685 api_ipfix_classify_table_add_del (vat_main_t * vam)
9687 unformat_input_t *i = vam->input;
9688 vl_api_ipfix_classify_table_add_del_t *mp;
9690 u32 classify_table_index = ~0;
9692 u8 transport_protocol = 255;
9695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9697 if (unformat (i, "add"))
9699 else if (unformat (i, "del"))
9701 else if (unformat (i, "table %d", &classify_table_index))
9703 else if (unformat (i, "ip4"))
9705 else if (unformat (i, "ip6"))
9707 else if (unformat (i, "tcp"))
9708 transport_protocol = 6;
9709 else if (unformat (i, "udp"))
9710 transport_protocol = 17;
9713 errmsg ("unknown input `%U'", format_unformat_error, i);
9720 errmsg ("expecting: add|del");
9723 if (classify_table_index == ~0)
9725 errmsg ("classifier table not specified");
9728 if (ip_version == 0)
9730 errmsg ("IP version not specified");
9734 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9736 mp->is_add = is_add;
9737 mp->table_id = htonl (classify_table_index);
9738 mp->ip_version = ip_version;
9739 mp->transport_protocol = transport_protocol;
9747 api_get_node_index (vat_main_t * vam)
9749 unformat_input_t *i = vam->input;
9750 vl_api_get_node_index_t *mp;
9754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9756 if (unformat (i, "node %s", &name))
9763 errmsg ("node name required");
9766 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9768 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9772 M (GET_NODE_INDEX, get_node_index);
9773 clib_memcpy (mp->node_name, name, vec_len (name));
9783 api_get_next_index (vat_main_t * vam)
9785 unformat_input_t *i = vam->input;
9786 vl_api_get_next_index_t *mp;
9788 u8 *node_name = 0, *next_node_name = 0;
9790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9792 if (unformat (i, "node-name %s", &node_name))
9794 else if (unformat (i, "next-node-name %s", &next_node_name))
9800 errmsg ("node name required");
9803 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9805 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9809 if (next_node_name == 0)
9811 errmsg ("next node name required");
9814 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9816 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9820 M (GET_NEXT_INDEX, get_next_index);
9821 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9822 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9823 vec_free (node_name);
9824 vec_free (next_node_name);
9833 api_add_node_next (vat_main_t * vam)
9835 unformat_input_t *i = vam->input;
9836 vl_api_add_node_next_t *mp;
9841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9843 if (unformat (i, "node %s", &name))
9845 else if (unformat (i, "next %s", &next))
9852 errmsg ("node name required");
9855 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9857 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9862 errmsg ("next node required");
9865 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9867 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9871 M (ADD_NODE_NEXT, add_node_next);
9872 clib_memcpy (mp->node_name, name, vec_len (name));
9873 clib_memcpy (mp->next_name, next, vec_len (next));
9884 api_l2tpv3_create_tunnel (vat_main_t * vam)
9886 unformat_input_t *i = vam->input;
9887 ip6_address_t client_address, our_address;
9888 int client_address_set = 0;
9889 int our_address_set = 0;
9890 u32 local_session_id = 0;
9891 u32 remote_session_id = 0;
9892 u64 local_cookie = 0;
9893 u64 remote_cookie = 0;
9894 u8 l2_sublayer_present = 0;
9895 vl_api_l2tpv3_create_tunnel_t *mp;
9898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9900 if (unformat (i, "client_address %U", unformat_ip6_address,
9902 client_address_set = 1;
9903 else if (unformat (i, "our_address %U", unformat_ip6_address,
9905 our_address_set = 1;
9906 else if (unformat (i, "local_session_id %d", &local_session_id))
9908 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9910 else if (unformat (i, "local_cookie %lld", &local_cookie))
9912 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9914 else if (unformat (i, "l2-sublayer-present"))
9915 l2_sublayer_present = 1;
9920 if (client_address_set == 0)
9922 errmsg ("client_address required");
9926 if (our_address_set == 0)
9928 errmsg ("our_address required");
9932 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9934 clib_memcpy (mp->client_address, client_address.as_u8,
9935 sizeof (mp->client_address));
9937 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9939 mp->local_session_id = ntohl (local_session_id);
9940 mp->remote_session_id = ntohl (remote_session_id);
9941 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9942 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9943 mp->l2_sublayer_present = l2_sublayer_present;
9953 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9955 unformat_input_t *i = vam->input;
9957 u8 sw_if_index_set = 0;
9958 u64 new_local_cookie = 0;
9959 u64 new_remote_cookie = 0;
9960 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9966 sw_if_index_set = 1;
9967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9968 sw_if_index_set = 1;
9969 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9971 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9977 if (sw_if_index_set == 0)
9979 errmsg ("missing interface name or sw_if_index");
9983 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9985 mp->sw_if_index = ntohl (sw_if_index);
9986 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9987 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9996 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9998 unformat_input_t *i = vam->input;
9999 vl_api_l2tpv3_interface_enable_disable_t *mp;
10002 u8 sw_if_index_set = 0;
10003 u8 enable_disable = 1;
10005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10007 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10008 sw_if_index_set = 1;
10009 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10010 sw_if_index_set = 1;
10011 else if (unformat (i, "enable"))
10012 enable_disable = 1;
10013 else if (unformat (i, "disable"))
10014 enable_disable = 0;
10019 if (sw_if_index_set == 0)
10021 errmsg ("missing interface name or sw_if_index");
10025 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10027 mp->sw_if_index = ntohl (sw_if_index);
10028 mp->enable_disable = enable_disable;
10037 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10039 unformat_input_t *i = vam->input;
10040 vl_api_l2tpv3_set_lookup_key_t *mp;
10044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10046 if (unformat (i, "lookup_v6_src"))
10047 key = L2T_LOOKUP_SRC_ADDRESS;
10048 else if (unformat (i, "lookup_v6_dst"))
10049 key = L2T_LOOKUP_DST_ADDRESS;
10050 else if (unformat (i, "lookup_session_id"))
10051 key = L2T_LOOKUP_SESSION_ID;
10056 if (key == (u8) ~ 0)
10058 errmsg ("l2tp session lookup key unset");
10062 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10072 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10073 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10075 vat_main_t *vam = &vat_main;
10077 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10078 format_ip6_address, mp->our_address,
10079 format_ip6_address, mp->client_address,
10080 clib_net_to_host_u32 (mp->sw_if_index));
10083 " local cookies %016llx %016llx remote cookie %016llx",
10084 clib_net_to_host_u64 (mp->local_cookie[0]),
10085 clib_net_to_host_u64 (mp->local_cookie[1]),
10086 clib_net_to_host_u64 (mp->remote_cookie));
10088 print (vam->ofp, " local session-id %d remote session-id %d",
10089 clib_net_to_host_u32 (mp->local_session_id),
10090 clib_net_to_host_u32 (mp->remote_session_id));
10092 print (vam->ofp, " l2 specific sublayer %s\n",
10093 mp->l2_sublayer_present ? "preset" : "absent");
10097 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10098 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10100 vat_main_t *vam = &vat_main;
10101 vat_json_node_t *node = NULL;
10102 struct in6_addr addr;
10104 if (VAT_JSON_ARRAY != vam->json_tree.type)
10106 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10107 vat_json_init_array (&vam->json_tree);
10109 node = vat_json_array_add (&vam->json_tree);
10111 vat_json_init_object (node);
10113 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10114 vat_json_object_add_ip6 (node, "our_address", addr);
10115 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10116 vat_json_object_add_ip6 (node, "client_address", addr);
10118 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10119 vat_json_init_array (lc);
10120 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10121 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10122 vat_json_object_add_uint (node, "remote_cookie",
10123 clib_net_to_host_u64 (mp->remote_cookie));
10125 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10126 vat_json_object_add_uint (node, "local_session_id",
10127 clib_net_to_host_u32 (mp->local_session_id));
10128 vat_json_object_add_uint (node, "remote_session_id",
10129 clib_net_to_host_u32 (mp->remote_session_id));
10130 vat_json_object_add_string_copy (node, "l2_sublayer",
10131 mp->l2_sublayer_present ? (u8 *) "present"
10132 : (u8 *) "absent");
10136 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10138 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10141 /* Get list of l2tpv3-tunnel interfaces */
10142 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10145 /* Use a control ping for synchronization */
10147 vl_api_control_ping_t *mp;
10148 M (CONTROL_PING, control_ping);
10155 static void vl_api_sw_interface_tap_details_t_handler
10156 (vl_api_sw_interface_tap_details_t * mp)
10158 vat_main_t *vam = &vat_main;
10160 print (vam->ofp, "%-16s %d",
10161 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10164 static void vl_api_sw_interface_tap_details_t_handler_json
10165 (vl_api_sw_interface_tap_details_t * mp)
10167 vat_main_t *vam = &vat_main;
10168 vat_json_node_t *node = NULL;
10170 if (VAT_JSON_ARRAY != vam->json_tree.type)
10172 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10173 vat_json_init_array (&vam->json_tree);
10175 node = vat_json_array_add (&vam->json_tree);
10177 vat_json_init_object (node);
10178 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10179 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10183 api_sw_interface_tap_dump (vat_main_t * vam)
10185 vl_api_sw_interface_tap_dump_t *mp;
10188 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10189 /* Get list of tap interfaces */
10190 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10193 /* Use a control ping for synchronization */
10195 vl_api_control_ping_t *mp;
10196 M (CONTROL_PING, control_ping);
10202 static uword unformat_vxlan_decap_next
10203 (unformat_input_t * input, va_list * args)
10205 u32 *result = va_arg (*args, u32 *);
10208 if (unformat (input, "l2"))
10209 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10210 else if (unformat (input, "%d", &tmp))
10218 api_vxlan_add_del_tunnel (vat_main_t * vam)
10220 unformat_input_t *line_input = vam->input;
10221 vl_api_vxlan_add_del_tunnel_t *mp;
10223 ip46_address_t src, dst;
10225 u8 ipv4_set = 0, ipv6_set = 0;
10229 u32 mcast_sw_if_index = ~0;
10230 u32 encap_vrf_id = 0;
10231 u32 decap_next_index = ~0;
10234 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10235 memset (&src, 0, sizeof src);
10236 memset (&dst, 0, sizeof dst);
10238 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10240 if (unformat (line_input, "del"))
10243 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10249 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10255 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10261 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10266 else if (unformat (line_input, "group %U %U",
10267 unformat_ip4_address, &dst.ip4,
10268 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10270 grp_set = dst_set = 1;
10273 else if (unformat (line_input, "group %U",
10274 unformat_ip4_address, &dst.ip4))
10276 grp_set = dst_set = 1;
10279 else if (unformat (line_input, "group %U %U",
10280 unformat_ip6_address, &dst.ip6,
10281 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10283 grp_set = dst_set = 1;
10286 else if (unformat (line_input, "group %U",
10287 unformat_ip6_address, &dst.ip6))
10289 grp_set = dst_set = 1;
10293 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10295 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10297 else if (unformat (line_input, "decap-next %U",
10298 unformat_vxlan_decap_next, &decap_next_index))
10300 else if (unformat (line_input, "vni %d", &vni))
10304 errmsg ("parse error '%U'", format_unformat_error, line_input);
10311 errmsg ("tunnel src address not specified");
10316 errmsg ("tunnel dst address not specified");
10320 if (grp_set && !ip46_address_is_multicast (&dst))
10322 errmsg ("tunnel group address not multicast");
10325 if (grp_set && mcast_sw_if_index == ~0)
10327 errmsg ("tunnel nonexistent multicast device");
10330 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10332 errmsg ("tunnel dst address must be unicast");
10337 if (ipv4_set && ipv6_set)
10339 errmsg ("both IPv4 and IPv6 addresses specified");
10343 if ((vni == 0) || (vni >> 24))
10345 errmsg ("vni not specified or out of range");
10349 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10353 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10354 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10358 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10359 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10361 mp->encap_vrf_id = ntohl (encap_vrf_id);
10362 mp->decap_next_index = ntohl (decap_next_index);
10363 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10364 mp->vni = ntohl (vni);
10365 mp->is_add = is_add;
10366 mp->is_ipv6 = ipv6_set;
10374 static void vl_api_vxlan_tunnel_details_t_handler
10375 (vl_api_vxlan_tunnel_details_t * mp)
10377 vat_main_t *vam = &vat_main;
10378 ip46_address_t src, dst;
10380 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10381 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10383 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10384 ntohl (mp->sw_if_index),
10385 format_ip46_address, &src, IP46_TYPE_ANY,
10386 format_ip46_address, &dst, IP46_TYPE_ANY,
10387 ntohl (mp->encap_vrf_id),
10388 ntohl (mp->decap_next_index), ntohl (mp->vni),
10389 ntohl (mp->mcast_sw_if_index));
10392 static void vl_api_vxlan_tunnel_details_t_handler_json
10393 (vl_api_vxlan_tunnel_details_t * mp)
10395 vat_main_t *vam = &vat_main;
10396 vat_json_node_t *node = NULL;
10398 if (VAT_JSON_ARRAY != vam->json_tree.type)
10400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10401 vat_json_init_array (&vam->json_tree);
10403 node = vat_json_array_add (&vam->json_tree);
10405 vat_json_init_object (node);
10406 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10409 struct in6_addr ip6;
10411 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10412 vat_json_object_add_ip6 (node, "src_address", ip6);
10413 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10414 vat_json_object_add_ip6 (node, "dst_address", ip6);
10418 struct in_addr ip4;
10420 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10421 vat_json_object_add_ip4 (node, "src_address", ip4);
10422 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10423 vat_json_object_add_ip4 (node, "dst_address", ip4);
10425 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10426 vat_json_object_add_uint (node, "decap_next_index",
10427 ntohl (mp->decap_next_index));
10428 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10429 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10430 vat_json_object_add_uint (node, "mcast_sw_if_index",
10431 ntohl (mp->mcast_sw_if_index));
10435 api_vxlan_tunnel_dump (vat_main_t * vam)
10437 unformat_input_t *i = vam->input;
10438 vl_api_vxlan_tunnel_dump_t *mp;
10441 u8 sw_if_index_set = 0;
10443 /* Parse args required to build the message */
10444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10446 if (unformat (i, "sw_if_index %d", &sw_if_index))
10447 sw_if_index_set = 1;
10452 if (sw_if_index_set == 0)
10457 if (!vam->json_output)
10459 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10460 "sw_if_index", "src_address", "dst_address",
10461 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10464 /* Get list of vxlan-tunnel interfaces */
10465 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10467 mp->sw_if_index = htonl (sw_if_index);
10471 /* Use a control ping for synchronization */
10473 vl_api_control_ping_t *mp;
10474 M (CONTROL_PING, control_ping);
10481 api_gre_add_del_tunnel (vat_main_t * vam)
10483 unformat_input_t *line_input = vam->input;
10484 vl_api_gre_add_del_tunnel_t *mp;
10486 ip4_address_t src4, dst4;
10491 u32 outer_fib_id = 0;
10493 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (line_input, "del"))
10497 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10499 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10501 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10503 else if (unformat (line_input, "teb"))
10507 errmsg ("parse error '%U'", format_unformat_error, line_input);
10514 errmsg ("tunnel src address not specified");
10519 errmsg ("tunnel dst address not specified");
10524 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10526 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10527 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10528 mp->outer_fib_id = ntohl (outer_fib_id);
10529 mp->is_add = is_add;
10538 static void vl_api_gre_tunnel_details_t_handler
10539 (vl_api_gre_tunnel_details_t * mp)
10541 vat_main_t *vam = &vat_main;
10543 print (vam->ofp, "%11d%15U%15U%6d%14d",
10544 ntohl (mp->sw_if_index),
10545 format_ip4_address, &mp->src_address,
10546 format_ip4_address, &mp->dst_address,
10547 mp->teb, ntohl (mp->outer_fib_id));
10550 static void vl_api_gre_tunnel_details_t_handler_json
10551 (vl_api_gre_tunnel_details_t * mp)
10553 vat_main_t *vam = &vat_main;
10554 vat_json_node_t *node = NULL;
10555 struct in_addr ip4;
10557 if (VAT_JSON_ARRAY != vam->json_tree.type)
10559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10560 vat_json_init_array (&vam->json_tree);
10562 node = vat_json_array_add (&vam->json_tree);
10564 vat_json_init_object (node);
10565 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10566 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10567 vat_json_object_add_ip4 (node, "src_address", ip4);
10568 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10569 vat_json_object_add_ip4 (node, "dst_address", ip4);
10570 vat_json_object_add_uint (node, "teb", mp->teb);
10571 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10575 api_gre_tunnel_dump (vat_main_t * vam)
10577 unformat_input_t *i = vam->input;
10578 vl_api_gre_tunnel_dump_t *mp;
10581 u8 sw_if_index_set = 0;
10583 /* Parse args required to build the message */
10584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10586 if (unformat (i, "sw_if_index %d", &sw_if_index))
10587 sw_if_index_set = 1;
10592 if (sw_if_index_set == 0)
10597 if (!vam->json_output)
10599 print (vam->ofp, "%11s%15s%15s%6s%14s",
10600 "sw_if_index", "src_address", "dst_address", "teb",
10604 /* Get list of gre-tunnel interfaces */
10605 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10607 mp->sw_if_index = htonl (sw_if_index);
10611 /* Use a control ping for synchronization */
10613 vl_api_control_ping_t *mp;
10614 M (CONTROL_PING, control_ping);
10621 api_l2_fib_clear_table (vat_main_t * vam)
10623 // unformat_input_t * i = vam->input;
10624 vl_api_l2_fib_clear_table_t *mp;
10627 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10636 api_l2_interface_efp_filter (vat_main_t * vam)
10638 unformat_input_t *i = vam->input;
10639 vl_api_l2_interface_efp_filter_t *mp;
10643 u8 sw_if_index_set = 0;
10645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10648 sw_if_index_set = 1;
10649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10650 sw_if_index_set = 1;
10651 else if (unformat (i, "enable"))
10653 else if (unformat (i, "disable"))
10657 clib_warning ("parse error '%U'", format_unformat_error, i);
10662 if (sw_if_index_set == 0)
10664 errmsg ("missing sw_if_index");
10668 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10670 mp->sw_if_index = ntohl (sw_if_index);
10671 mp->enable_disable = enable;
10679 #define foreach_vtr_op \
10680 _("disable", L2_VTR_DISABLED) \
10681 _("push-1", L2_VTR_PUSH_1) \
10682 _("push-2", L2_VTR_PUSH_2) \
10683 _("pop-1", L2_VTR_POP_1) \
10684 _("pop-2", L2_VTR_POP_2) \
10685 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10686 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10687 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10688 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10691 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10693 unformat_input_t *i = vam->input;
10694 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10697 u8 sw_if_index_set = 0;
10700 u32 push_dot1q = 1;
10704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10706 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10707 sw_if_index_set = 1;
10708 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10709 sw_if_index_set = 1;
10710 else if (unformat (i, "vtr_op %d", &vtr_op))
10712 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10715 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10717 else if (unformat (i, "tag1 %d", &tag1))
10719 else if (unformat (i, "tag2 %d", &tag2))
10723 clib_warning ("parse error '%U'", format_unformat_error, i);
10728 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10730 errmsg ("missing vtr operation or sw_if_index");
10734 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10735 mp->sw_if_index = ntohl (sw_if_index);
10736 mp->vtr_op = ntohl (vtr_op);
10737 mp->push_dot1q = ntohl (push_dot1q);
10738 mp->tag1 = ntohl (tag1);
10739 mp->tag2 = ntohl (tag2);
10748 api_create_vhost_user_if (vat_main_t * vam)
10750 unformat_input_t *i = vam->input;
10751 vl_api_create_vhost_user_if_t *mp;
10755 u8 file_name_set = 0;
10756 u32 custom_dev_instance = ~0;
10758 u8 use_custom_mac = 0;
10761 /* Shut up coverity */
10762 memset (hwaddr, 0, sizeof (hwaddr));
10764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10766 if (unformat (i, "socket %s", &file_name))
10770 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10772 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10773 use_custom_mac = 1;
10774 else if (unformat (i, "server"))
10776 else if (unformat (i, "tag %s", &tag))
10782 if (file_name_set == 0)
10784 errmsg ("missing socket file name");
10788 if (vec_len (file_name) > 255)
10790 errmsg ("socket file name too long");
10793 vec_add1 (file_name, 0);
10795 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10797 mp->is_server = is_server;
10798 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10799 vec_free (file_name);
10800 if (custom_dev_instance != ~0)
10803 mp->custom_dev_instance = ntohl (custom_dev_instance);
10805 mp->use_custom_mac = use_custom_mac;
10806 clib_memcpy (mp->mac_address, hwaddr, 6);
10808 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10818 api_modify_vhost_user_if (vat_main_t * vam)
10820 unformat_input_t *i = vam->input;
10821 vl_api_modify_vhost_user_if_t *mp;
10825 u8 file_name_set = 0;
10826 u32 custom_dev_instance = ~0;
10827 u8 sw_if_index_set = 0;
10828 u32 sw_if_index = (u32) ~ 0;
10830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10832 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10833 sw_if_index_set = 1;
10834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10835 sw_if_index_set = 1;
10836 else if (unformat (i, "socket %s", &file_name))
10840 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10842 else if (unformat (i, "server"))
10848 if (sw_if_index_set == 0)
10850 errmsg ("missing sw_if_index or interface name");
10854 if (file_name_set == 0)
10856 errmsg ("missing socket file name");
10860 if (vec_len (file_name) > 255)
10862 errmsg ("socket file name too long");
10865 vec_add1 (file_name, 0);
10867 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10869 mp->sw_if_index = ntohl (sw_if_index);
10870 mp->is_server = is_server;
10871 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10872 vec_free (file_name);
10873 if (custom_dev_instance != ~0)
10876 mp->custom_dev_instance = ntohl (custom_dev_instance);
10886 api_delete_vhost_user_if (vat_main_t * vam)
10888 unformat_input_t *i = vam->input;
10889 vl_api_delete_vhost_user_if_t *mp;
10891 u32 sw_if_index = ~0;
10892 u8 sw_if_index_set = 0;
10894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10896 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10897 sw_if_index_set = 1;
10898 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10899 sw_if_index_set = 1;
10904 if (sw_if_index_set == 0)
10906 errmsg ("missing sw_if_index or interface name");
10911 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10913 mp->sw_if_index = ntohl (sw_if_index);
10921 static void vl_api_sw_interface_vhost_user_details_t_handler
10922 (vl_api_sw_interface_vhost_user_details_t * mp)
10924 vat_main_t *vam = &vat_main;
10926 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
10927 (char *) mp->interface_name,
10928 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10929 clib_net_to_host_u64 (mp->features), mp->is_server,
10930 ntohl (mp->num_regions), (char *) mp->sock_filename);
10931 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
10934 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10935 (vl_api_sw_interface_vhost_user_details_t * mp)
10937 vat_main_t *vam = &vat_main;
10938 vat_json_node_t *node = NULL;
10940 if (VAT_JSON_ARRAY != vam->json_tree.type)
10942 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10943 vat_json_init_array (&vam->json_tree);
10945 node = vat_json_array_add (&vam->json_tree);
10947 vat_json_init_object (node);
10948 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10949 vat_json_object_add_string_copy (node, "interface_name",
10950 mp->interface_name);
10951 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10952 ntohl (mp->virtio_net_hdr_sz));
10953 vat_json_object_add_uint (node, "features",
10954 clib_net_to_host_u64 (mp->features));
10955 vat_json_object_add_uint (node, "is_server", mp->is_server);
10956 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10957 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10958 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10962 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10964 vl_api_sw_interface_vhost_user_dump_t *mp;
10967 "Interface name idx hdr_sz features server regions filename");
10969 /* Get list of vhost-user interfaces */
10970 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10973 /* Use a control ping for synchronization */
10975 vl_api_control_ping_t *mp;
10976 M (CONTROL_PING, control_ping);
10983 api_show_version (vat_main_t * vam)
10985 vl_api_show_version_t *mp;
10988 M (SHOW_VERSION, show_version);
10998 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11000 unformat_input_t *line_input = vam->input;
11001 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11003 ip4_address_t local4, remote4;
11004 ip6_address_t local6, remote6;
11006 u8 ipv4_set = 0, ipv6_set = 0;
11009 u32 encap_vrf_id = 0;
11010 u32 decap_vrf_id = 0;
11015 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11017 if (unformat (line_input, "del"))
11019 else if (unformat (line_input, "local %U",
11020 unformat_ip4_address, &local4))
11025 else if (unformat (line_input, "remote %U",
11026 unformat_ip4_address, &remote4))
11031 else if (unformat (line_input, "local %U",
11032 unformat_ip6_address, &local6))
11037 else if (unformat (line_input, "remote %U",
11038 unformat_ip6_address, &remote6))
11043 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11045 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11047 else if (unformat (line_input, "vni %d", &vni))
11049 else if (unformat (line_input, "next-ip4"))
11051 else if (unformat (line_input, "next-ip6"))
11053 else if (unformat (line_input, "next-ethernet"))
11055 else if (unformat (line_input, "next-nsh"))
11059 errmsg ("parse error '%U'", format_unformat_error, line_input);
11064 if (local_set == 0)
11066 errmsg ("tunnel local address not specified");
11069 if (remote_set == 0)
11071 errmsg ("tunnel remote address not specified");
11074 if (ipv4_set && ipv6_set)
11076 errmsg ("both IPv4 and IPv6 addresses specified");
11082 errmsg ("vni not specified");
11086 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11091 clib_memcpy (&mp->local, &local6, sizeof (local6));
11092 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11096 clib_memcpy (&mp->local, &local4, sizeof (local4));
11097 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11100 mp->encap_vrf_id = ntohl (encap_vrf_id);
11101 mp->decap_vrf_id = ntohl (decap_vrf_id);
11102 mp->protocol = protocol;
11103 mp->vni = ntohl (vni);
11104 mp->is_add = is_add;
11105 mp->is_ipv6 = ipv6_set;
11113 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11114 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11116 vat_main_t *vam = &vat_main;
11118 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11119 ntohl (mp->sw_if_index),
11120 format_ip46_address, &(mp->local[0]),
11121 format_ip46_address, &(mp->remote[0]),
11123 ntohl (mp->protocol),
11124 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11127 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11128 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11130 vat_main_t *vam = &vat_main;
11131 vat_json_node_t *node = NULL;
11132 struct in_addr ip4;
11133 struct in6_addr ip6;
11135 if (VAT_JSON_ARRAY != vam->json_tree.type)
11137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11138 vat_json_init_array (&vam->json_tree);
11140 node = vat_json_array_add (&vam->json_tree);
11142 vat_json_init_object (node);
11143 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11146 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11147 vat_json_object_add_ip6 (node, "local", ip6);
11148 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11149 vat_json_object_add_ip6 (node, "remote", ip6);
11153 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11154 vat_json_object_add_ip4 (node, "local", ip4);
11155 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11156 vat_json_object_add_ip4 (node, "remote", ip4);
11158 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11159 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11160 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11161 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11162 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11166 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11168 unformat_input_t *i = vam->input;
11169 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11172 u8 sw_if_index_set = 0;
11174 /* Parse args required to build the message */
11175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11177 if (unformat (i, "sw_if_index %d", &sw_if_index))
11178 sw_if_index_set = 1;
11183 if (sw_if_index_set == 0)
11188 if (!vam->json_output)
11190 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11191 "sw_if_index", "local", "remote", "vni",
11192 "protocol", "encap_vrf_id", "decap_vrf_id");
11195 /* Get list of vxlan-tunnel interfaces */
11196 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11198 mp->sw_if_index = htonl (sw_if_index);
11202 /* Use a control ping for synchronization */
11204 vl_api_control_ping_t *mp;
11205 M (CONTROL_PING, control_ping);
11212 format_l2_fib_mac_address (u8 * s, va_list * args)
11214 u8 *a = va_arg (*args, u8 *);
11216 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11217 a[2], a[3], a[4], a[5], a[6], a[7]);
11220 static void vl_api_l2_fib_table_entry_t_handler
11221 (vl_api_l2_fib_table_entry_t * mp)
11223 vat_main_t *vam = &vat_main;
11225 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11227 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11228 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11232 static void vl_api_l2_fib_table_entry_t_handler_json
11233 (vl_api_l2_fib_table_entry_t * mp)
11235 vat_main_t *vam = &vat_main;
11236 vat_json_node_t *node = NULL;
11238 if (VAT_JSON_ARRAY != vam->json_tree.type)
11240 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11241 vat_json_init_array (&vam->json_tree);
11243 node = vat_json_array_add (&vam->json_tree);
11245 vat_json_init_object (node);
11246 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11247 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11248 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11249 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11250 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11251 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11255 api_l2_fib_table_dump (vat_main_t * vam)
11257 unformat_input_t *i = vam->input;
11258 vl_api_l2_fib_table_dump_t *mp;
11263 /* Parse args required to build the message */
11264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11266 if (unformat (i, "bd_id %d", &bd_id))
11272 if (bd_id_set == 0)
11274 errmsg ("missing bridge domain");
11278 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11280 /* Get list of l2 fib entries */
11281 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11283 mp->bd_id = ntohl (bd_id);
11286 /* Use a control ping for synchronization */
11288 vl_api_control_ping_t *mp;
11289 M (CONTROL_PING, control_ping);
11297 api_interface_name_renumber (vat_main_t * vam)
11299 unformat_input_t *line_input = vam->input;
11300 vl_api_interface_name_renumber_t *mp;
11301 u32 sw_if_index = ~0;
11303 u32 new_show_dev_instance = ~0;
11305 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11307 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11310 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11312 else if (unformat (line_input, "new_show_dev_instance %d",
11313 &new_show_dev_instance))
11319 if (sw_if_index == ~0)
11321 errmsg ("missing interface name or sw_if_index");
11325 if (new_show_dev_instance == ~0)
11327 errmsg ("missing new_show_dev_instance");
11331 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11333 mp->sw_if_index = ntohl (sw_if_index);
11334 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11341 api_want_ip4_arp_events (vat_main_t * vam)
11343 unformat_input_t *line_input = vam->input;
11344 vl_api_want_ip4_arp_events_t *mp;
11346 ip4_address_t address;
11347 int address_set = 0;
11348 u32 enable_disable = 1;
11350 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11352 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11354 else if (unformat (line_input, "del"))
11355 enable_disable = 0;
11360 if (address_set == 0)
11362 errmsg ("missing addresses");
11366 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11367 mp->enable_disable = enable_disable;
11368 mp->pid = getpid ();
11369 mp->address = address.as_u32;
11376 api_want_ip6_nd_events (vat_main_t * vam)
11378 unformat_input_t *line_input = vam->input;
11379 vl_api_want_ip6_nd_events_t *mp;
11381 ip6_address_t address;
11382 int address_set = 0;
11383 u32 enable_disable = 1;
11385 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11387 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11389 else if (unformat (line_input, "del"))
11390 enable_disable = 0;
11395 if (address_set == 0)
11397 errmsg ("missing addresses");
11401 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11402 mp->enable_disable = enable_disable;
11403 mp->pid = getpid ();
11404 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11411 api_input_acl_set_interface (vat_main_t * vam)
11413 unformat_input_t *i = vam->input;
11414 vl_api_input_acl_set_interface_t *mp;
11417 int sw_if_index_set;
11418 u32 ip4_table_index = ~0;
11419 u32 ip6_table_index = ~0;
11420 u32 l2_table_index = ~0;
11423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11425 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11426 sw_if_index_set = 1;
11427 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11428 sw_if_index_set = 1;
11429 else if (unformat (i, "del"))
11431 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11433 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11435 else if (unformat (i, "l2-table %d", &l2_table_index))
11439 clib_warning ("parse error '%U'", format_unformat_error, i);
11444 if (sw_if_index_set == 0)
11446 errmsg ("missing interface name or sw_if_index");
11450 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11452 mp->sw_if_index = ntohl (sw_if_index);
11453 mp->ip4_table_index = ntohl (ip4_table_index);
11454 mp->ip6_table_index = ntohl (ip6_table_index);
11455 mp->l2_table_index = ntohl (l2_table_index);
11456 mp->is_add = is_add;
11465 api_ip_address_dump (vat_main_t * vam)
11467 unformat_input_t *i = vam->input;
11468 vl_api_ip_address_dump_t *mp;
11469 u32 sw_if_index = ~0;
11470 u8 sw_if_index_set = 0;
11475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11477 if (unformat (i, "sw_if_index %d", &sw_if_index))
11478 sw_if_index_set = 1;
11480 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11481 sw_if_index_set = 1;
11482 else if (unformat (i, "ipv4"))
11484 else if (unformat (i, "ipv6"))
11490 if (ipv4_set && ipv6_set)
11492 errmsg ("ipv4 and ipv6 flags cannot be both set");
11496 if ((!ipv4_set) && (!ipv6_set))
11498 errmsg ("no ipv4 nor ipv6 flag set");
11502 if (sw_if_index_set == 0)
11504 errmsg ("missing interface name or sw_if_index");
11508 vam->current_sw_if_index = sw_if_index;
11509 vam->is_ipv6 = ipv6_set;
11511 M (IP_ADDRESS_DUMP, ip_address_dump);
11512 mp->sw_if_index = ntohl (sw_if_index);
11513 mp->is_ipv6 = ipv6_set;
11516 /* Use a control ping for synchronization */
11518 vl_api_control_ping_t *mp;
11519 M (CONTROL_PING, control_ping);
11526 api_ip_dump (vat_main_t * vam)
11528 vl_api_ip_dump_t *mp;
11529 unformat_input_t *in = vam->input;
11536 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11538 if (unformat (in, "ipv4"))
11540 else if (unformat (in, "ipv6"))
11546 if (ipv4_set && ipv6_set)
11548 errmsg ("ipv4 and ipv6 flags cannot be both set");
11552 if ((!ipv4_set) && (!ipv6_set))
11554 errmsg ("no ipv4 nor ipv6 flag set");
11558 is_ipv6 = ipv6_set;
11559 vam->is_ipv6 = is_ipv6;
11561 /* free old data */
11562 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11564 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11566 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11568 M (IP_DUMP, ip_dump);
11569 mp->is_ipv6 = ipv6_set;
11572 /* Use a control ping for synchronization */
11574 vl_api_control_ping_t *mp;
11575 M (CONTROL_PING, control_ping);
11582 api_ipsec_spd_add_del (vat_main_t * vam)
11584 unformat_input_t *i = vam->input;
11585 vl_api_ipsec_spd_add_del_t *mp;
11590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11592 if (unformat (i, "spd_id %d", &spd_id))
11594 else if (unformat (i, "del"))
11598 clib_warning ("parse error '%U'", format_unformat_error, i);
11604 errmsg ("spd_id must be set");
11608 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11610 mp->spd_id = ntohl (spd_id);
11611 mp->is_add = is_add;
11620 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11622 unformat_input_t *i = vam->input;
11623 vl_api_ipsec_interface_add_del_spd_t *mp;
11626 u8 sw_if_index_set = 0;
11627 u32 spd_id = (u32) ~ 0;
11630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11632 if (unformat (i, "del"))
11634 else if (unformat (i, "spd_id %d", &spd_id))
11637 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11638 sw_if_index_set = 1;
11639 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11640 sw_if_index_set = 1;
11643 clib_warning ("parse error '%U'", format_unformat_error, i);
11649 if (spd_id == (u32) ~ 0)
11651 errmsg ("spd_id must be set");
11655 if (sw_if_index_set == 0)
11657 errmsg ("missing interface name or sw_if_index");
11661 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11663 mp->spd_id = ntohl (spd_id);
11664 mp->sw_if_index = ntohl (sw_if_index);
11665 mp->is_add = is_add;
11674 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11676 unformat_input_t *i = vam->input;
11677 vl_api_ipsec_spd_add_del_entry_t *mp;
11679 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11680 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11682 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11683 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11684 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11685 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11687 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11688 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11689 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11690 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11691 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11692 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11696 if (unformat (i, "del"))
11698 if (unformat (i, "outbound"))
11700 if (unformat (i, "inbound"))
11702 else if (unformat (i, "spd_id %d", &spd_id))
11704 else if (unformat (i, "sa_id %d", &sa_id))
11706 else if (unformat (i, "priority %d", &priority))
11708 else if (unformat (i, "protocol %d", &protocol))
11710 else if (unformat (i, "lport_start %d", &lport_start))
11712 else if (unformat (i, "lport_stop %d", &lport_stop))
11714 else if (unformat (i, "rport_start %d", &rport_start))
11716 else if (unformat (i, "rport_stop %d", &rport_stop))
11720 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11726 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11733 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11739 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11746 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11752 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11759 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11765 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11771 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11773 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11775 clib_warning ("unsupported action: 'resolve'");
11781 clib_warning ("parse error '%U'", format_unformat_error, i);
11787 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11789 mp->spd_id = ntohl (spd_id);
11790 mp->priority = ntohl (priority);
11791 mp->is_outbound = is_outbound;
11793 mp->is_ipv6 = is_ipv6;
11794 if (is_ipv6 || is_ip_any)
11796 clib_memcpy (mp->remote_address_start, &raddr6_start,
11797 sizeof (ip6_address_t));
11798 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11799 sizeof (ip6_address_t));
11800 clib_memcpy (mp->local_address_start, &laddr6_start,
11801 sizeof (ip6_address_t));
11802 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11803 sizeof (ip6_address_t));
11807 clib_memcpy (mp->remote_address_start, &raddr4_start,
11808 sizeof (ip4_address_t));
11809 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11810 sizeof (ip4_address_t));
11811 clib_memcpy (mp->local_address_start, &laddr4_start,
11812 sizeof (ip4_address_t));
11813 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11814 sizeof (ip4_address_t));
11816 mp->protocol = (u8) protocol;
11817 mp->local_port_start = ntohs ((u16) lport_start);
11818 mp->local_port_stop = ntohs ((u16) lport_stop);
11819 mp->remote_port_start = ntohs ((u16) rport_start);
11820 mp->remote_port_stop = ntohs ((u16) rport_stop);
11821 mp->policy = (u8) policy;
11822 mp->sa_id = ntohl (sa_id);
11823 mp->is_add = is_add;
11824 mp->is_ip_any = is_ip_any;
11832 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11834 unformat_input_t *i = vam->input;
11835 vl_api_ipsec_sad_add_del_entry_t *mp;
11837 u32 sad_id = 0, spi = 0;
11838 u8 *ck = 0, *ik = 0;
11841 u8 protocol = IPSEC_PROTOCOL_AH;
11842 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11843 u32 crypto_alg = 0, integ_alg = 0;
11844 ip4_address_t tun_src4;
11845 ip4_address_t tun_dst4;
11846 ip6_address_t tun_src6;
11847 ip6_address_t tun_dst6;
11849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11851 if (unformat (i, "del"))
11853 else if (unformat (i, "sad_id %d", &sad_id))
11855 else if (unformat (i, "spi %d", &spi))
11857 else if (unformat (i, "esp"))
11858 protocol = IPSEC_PROTOCOL_ESP;
11859 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11862 is_tunnel_ipv6 = 0;
11864 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11867 is_tunnel_ipv6 = 0;
11869 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11872 is_tunnel_ipv6 = 1;
11874 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11877 is_tunnel_ipv6 = 1;
11881 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11883 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11884 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11886 clib_warning ("unsupported crypto-alg: '%U'",
11887 format_ipsec_crypto_alg, crypto_alg);
11891 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11895 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11898 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11900 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11902 integ_alg >= IPSEC_INTEG_N_ALG)
11904 clib_warning ("unsupported integ-alg: '%U'",
11905 format_ipsec_integ_alg, integ_alg);
11909 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11913 clib_warning ("parse error '%U'", format_unformat_error, i);
11920 /*Special cases, aes-gcm-128 encryption */
11921 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11923 if (integ_alg != IPSEC_INTEG_ALG_NONE
11924 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11927 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11930 else /*set integ-alg internally to aes-gcm-128 */
11931 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11933 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11935 clib_warning ("unsupported integ-alg: aes-gcm-128");
11938 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11940 clib_warning ("unsupported integ-alg: none");
11946 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11948 mp->sad_id = ntohl (sad_id);
11949 mp->is_add = is_add;
11950 mp->protocol = protocol;
11951 mp->spi = ntohl (spi);
11952 mp->is_tunnel = is_tunnel;
11953 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11954 mp->crypto_algorithm = crypto_alg;
11955 mp->integrity_algorithm = integ_alg;
11956 mp->crypto_key_length = vec_len (ck);
11957 mp->integrity_key_length = vec_len (ik);
11959 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11960 mp->crypto_key_length = sizeof (mp->crypto_key);
11962 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11963 mp->integrity_key_length = sizeof (mp->integrity_key);
11966 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11968 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11972 if (is_tunnel_ipv6)
11974 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11975 sizeof (ip6_address_t));
11976 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11977 sizeof (ip6_address_t));
11981 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11982 sizeof (ip4_address_t));
11983 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11984 sizeof (ip4_address_t));
11995 api_ipsec_sa_set_key (vat_main_t * vam)
11997 unformat_input_t *i = vam->input;
11998 vl_api_ipsec_sa_set_key_t *mp;
12001 u8 *ck = 0, *ik = 0;
12003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12005 if (unformat (i, "sa_id %d", &sa_id))
12007 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12009 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12013 clib_warning ("parse error '%U'", format_unformat_error, i);
12018 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12020 mp->sa_id = ntohl (sa_id);
12021 mp->crypto_key_length = vec_len (ck);
12022 mp->integrity_key_length = vec_len (ik);
12024 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12025 mp->crypto_key_length = sizeof (mp->crypto_key);
12027 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12028 mp->integrity_key_length = sizeof (mp->integrity_key);
12031 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12033 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12042 api_ikev2_profile_add_del (vat_main_t * vam)
12044 unformat_input_t *i = vam->input;
12045 vl_api_ikev2_profile_add_del_t *mp;
12050 const char *valid_chars = "a-zA-Z0-9_";
12052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12054 if (unformat (i, "del"))
12056 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12057 vec_add1 (name, 0);
12060 errmsg ("parse error '%U'", format_unformat_error, i);
12065 if (!vec_len (name))
12067 errmsg ("profile name must be specified");
12071 if (vec_len (name) > 64)
12073 errmsg ("profile name too long");
12077 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12079 clib_memcpy (mp->name, name, vec_len (name));
12080 mp->is_add = is_add;
12090 api_ikev2_profile_set_auth (vat_main_t * vam)
12092 unformat_input_t *i = vam->input;
12093 vl_api_ikev2_profile_set_auth_t *mp;
12097 u32 auth_method = 0;
12100 const char *valid_chars = "a-zA-Z0-9_";
12102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12104 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12105 vec_add1 (name, 0);
12106 else if (unformat (i, "auth_method %U",
12107 unformat_ikev2_auth_method, &auth_method))
12109 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12111 else if (unformat (i, "auth_data %v", &data))
12115 errmsg ("parse error '%U'", format_unformat_error, i);
12120 if (!vec_len (name))
12122 errmsg ("profile name must be specified");
12126 if (vec_len (name) > 64)
12128 errmsg ("profile name too long");
12132 if (!vec_len (data))
12134 errmsg ("auth_data must be specified");
12140 errmsg ("auth_method must be specified");
12144 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12146 mp->is_hex = is_hex;
12147 mp->auth_method = (u8) auth_method;
12148 mp->data_len = vec_len (data);
12149 clib_memcpy (mp->name, name, vec_len (name));
12150 clib_memcpy (mp->data, data, vec_len (data));
12161 api_ikev2_profile_set_id (vat_main_t * vam)
12163 unformat_input_t *i = vam->input;
12164 vl_api_ikev2_profile_set_id_t *mp;
12172 const char *valid_chars = "a-zA-Z0-9_";
12174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12176 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12177 vec_add1 (name, 0);
12178 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12180 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12182 data = vec_new (u8, 4);
12183 clib_memcpy (data, ip4.as_u8, 4);
12185 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12187 else if (unformat (i, "id_data %v", &data))
12189 else if (unformat (i, "local"))
12191 else if (unformat (i, "remote"))
12195 errmsg ("parse error '%U'", format_unformat_error, i);
12200 if (!vec_len (name))
12202 errmsg ("profile name must be specified");
12206 if (vec_len (name) > 64)
12208 errmsg ("profile name too long");
12212 if (!vec_len (data))
12214 errmsg ("id_data must be specified");
12220 errmsg ("id_type must be specified");
12224 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12226 mp->is_local = is_local;
12227 mp->id_type = (u8) id_type;
12228 mp->data_len = vec_len (data);
12229 clib_memcpy (mp->name, name, vec_len (name));
12230 clib_memcpy (mp->data, data, vec_len (data));
12241 api_ikev2_profile_set_ts (vat_main_t * vam)
12243 unformat_input_t *i = vam->input;
12244 vl_api_ikev2_profile_set_ts_t *mp;
12248 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12249 ip4_address_t start_addr, end_addr;
12251 const char *valid_chars = "a-zA-Z0-9_";
12253 start_addr.as_u32 = 0;
12254 end_addr.as_u32 = (u32) ~ 0;
12256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12258 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12259 vec_add1 (name, 0);
12260 else if (unformat (i, "protocol %d", &proto))
12262 else if (unformat (i, "start_port %d", &start_port))
12264 else if (unformat (i, "end_port %d", &end_port))
12267 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12269 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12271 else if (unformat (i, "local"))
12273 else if (unformat (i, "remote"))
12277 errmsg ("parse error '%U'", format_unformat_error, i);
12282 if (!vec_len (name))
12284 errmsg ("profile name must be specified");
12288 if (vec_len (name) > 64)
12290 errmsg ("profile name too long");
12294 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12296 mp->is_local = is_local;
12297 mp->proto = (u8) proto;
12298 mp->start_port = (u16) start_port;
12299 mp->end_port = (u16) end_port;
12300 mp->start_addr = start_addr.as_u32;
12301 mp->end_addr = end_addr.as_u32;
12302 clib_memcpy (mp->name, name, vec_len (name));
12312 api_ikev2_set_local_key (vat_main_t * vam)
12314 unformat_input_t *i = vam->input;
12315 vl_api_ikev2_set_local_key_t *mp;
12319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12321 if (unformat (i, "file %v", &file))
12322 vec_add1 (file, 0);
12325 errmsg ("parse error '%U'", format_unformat_error, i);
12330 if (!vec_len (file))
12332 errmsg ("RSA key file must be specified");
12336 if (vec_len (file) > 256)
12338 errmsg ("file name too long");
12342 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12344 clib_memcpy (mp->key_file, file, vec_len (file));
12357 api_map_add_domain (vat_main_t * vam)
12359 unformat_input_t *i = vam->input;
12360 vl_api_map_add_domain_t *mp;
12363 ip4_address_t ip4_prefix;
12364 ip6_address_t ip6_prefix;
12365 ip6_address_t ip6_src;
12366 u32 num_m_args = 0;
12367 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12368 0, psid_length = 0;
12369 u8 is_translation = 0;
12371 u32 ip6_src_len = 128;
12373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12375 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12376 &ip4_prefix, &ip4_prefix_len))
12378 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12379 &ip6_prefix, &ip6_prefix_len))
12383 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12386 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12388 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12390 else if (unformat (i, "psid-offset %d", &psid_offset))
12392 else if (unformat (i, "psid-len %d", &psid_length))
12394 else if (unformat (i, "mtu %d", &mtu))
12396 else if (unformat (i, "map-t"))
12397 is_translation = 1;
12400 clib_warning ("parse error '%U'", format_unformat_error, i);
12405 if (num_m_args < 3)
12407 errmsg ("mandatory argument(s) missing");
12411 /* Construct the API message */
12412 M (MAP_ADD_DOMAIN, map_add_domain);
12414 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12415 mp->ip4_prefix_len = ip4_prefix_len;
12417 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12418 mp->ip6_prefix_len = ip6_prefix_len;
12420 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12421 mp->ip6_src_prefix_len = ip6_src_len;
12423 mp->ea_bits_len = ea_bits_len;
12424 mp->psid_offset = psid_offset;
12425 mp->psid_length = psid_length;
12426 mp->is_translation = is_translation;
12427 mp->mtu = htons (mtu);
12432 /* Wait for a reply, return good/bad news */
12437 api_map_del_domain (vat_main_t * vam)
12439 unformat_input_t *i = vam->input;
12440 vl_api_map_del_domain_t *mp;
12443 u32 num_m_args = 0;
12446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12448 if (unformat (i, "index %d", &index))
12452 clib_warning ("parse error '%U'", format_unformat_error, i);
12457 if (num_m_args != 1)
12459 errmsg ("mandatory argument(s) missing");
12463 /* Construct the API message */
12464 M (MAP_DEL_DOMAIN, map_del_domain);
12466 mp->index = ntohl (index);
12471 /* Wait for a reply, return good/bad news */
12476 api_map_add_del_rule (vat_main_t * vam)
12478 unformat_input_t *i = vam->input;
12479 vl_api_map_add_del_rule_t *mp;
12482 ip6_address_t ip6_dst;
12483 u32 num_m_args = 0, index, psid = 0;
12485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12487 if (unformat (i, "index %d", &index))
12489 else if (unformat (i, "psid %d", &psid))
12491 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12493 else if (unformat (i, "del"))
12499 clib_warning ("parse error '%U'", format_unformat_error, i);
12504 /* Construct the API message */
12505 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12507 mp->index = ntohl (index);
12508 mp->is_add = is_add;
12509 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12510 mp->psid = ntohs (psid);
12515 /* Wait for a reply, return good/bad news */
12520 api_map_domain_dump (vat_main_t * vam)
12522 vl_api_map_domain_dump_t *mp;
12525 /* Construct the API message */
12526 M (MAP_DOMAIN_DUMP, map_domain_dump);
12531 /* Use a control ping for synchronization */
12533 vl_api_control_ping_t *mp;
12534 M (CONTROL_PING, control_ping);
12541 api_map_rule_dump (vat_main_t * vam)
12543 unformat_input_t *i = vam->input;
12544 vl_api_map_rule_dump_t *mp;
12546 u32 domain_index = ~0;
12548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12550 if (unformat (i, "index %u", &domain_index))
12556 if (domain_index == ~0)
12558 clib_warning ("parse error: domain index expected");
12562 /* Construct the API message */
12563 M (MAP_RULE_DUMP, map_rule_dump);
12565 mp->domain_index = htonl (domain_index);
12570 /* Use a control ping for synchronization */
12572 vl_api_control_ping_t *mp;
12573 M (CONTROL_PING, control_ping);
12579 static void vl_api_map_add_domain_reply_t_handler
12580 (vl_api_map_add_domain_reply_t * mp)
12582 vat_main_t *vam = &vat_main;
12583 i32 retval = ntohl (mp->retval);
12585 if (vam->async_mode)
12587 vam->async_errors += (retval < 0);
12591 vam->retval = retval;
12592 vam->result_ready = 1;
12596 static void vl_api_map_add_domain_reply_t_handler_json
12597 (vl_api_map_add_domain_reply_t * mp)
12599 vat_main_t *vam = &vat_main;
12600 vat_json_node_t node;
12602 vat_json_init_object (&node);
12603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12604 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12606 vat_json_print (vam->ofp, &node);
12607 vat_json_free (&node);
12609 vam->retval = ntohl (mp->retval);
12610 vam->result_ready = 1;
12614 api_get_first_msg_id (vat_main_t * vam)
12616 vl_api_get_first_msg_id_t *mp;
12618 unformat_input_t *i = vam->input;
12622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12624 if (unformat (i, "client %s", &name))
12632 errmsg ("missing client name");
12635 vec_add1 (name, 0);
12637 if (vec_len (name) > 63)
12639 errmsg ("client name too long");
12643 M (GET_FIRST_MSG_ID, get_first_msg_id);
12644 clib_memcpy (mp->name, name, vec_len (name));
12652 api_cop_interface_enable_disable (vat_main_t * vam)
12654 unformat_input_t *line_input = vam->input;
12655 vl_api_cop_interface_enable_disable_t *mp;
12657 u32 sw_if_index = ~0;
12658 u8 enable_disable = 1;
12660 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12662 if (unformat (line_input, "disable"))
12663 enable_disable = 0;
12664 if (unformat (line_input, "enable"))
12665 enable_disable = 1;
12666 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12667 vam, &sw_if_index))
12669 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12675 if (sw_if_index == ~0)
12677 errmsg ("missing interface name or sw_if_index");
12681 /* Construct the API message */
12682 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12683 mp->sw_if_index = ntohl (sw_if_index);
12684 mp->enable_disable = enable_disable;
12688 /* Wait for the reply */
12693 api_cop_whitelist_enable_disable (vat_main_t * vam)
12695 unformat_input_t *line_input = vam->input;
12696 vl_api_cop_whitelist_enable_disable_t *mp;
12698 u32 sw_if_index = ~0;
12699 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12702 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12704 if (unformat (line_input, "ip4"))
12706 else if (unformat (line_input, "ip6"))
12708 else if (unformat (line_input, "default"))
12710 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12711 vam, &sw_if_index))
12713 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12715 else if (unformat (line_input, "fib-id %d", &fib_id))
12721 if (sw_if_index == ~0)
12723 errmsg ("missing interface name or sw_if_index");
12727 /* Construct the API message */
12728 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12729 mp->sw_if_index = ntohl (sw_if_index);
12730 mp->fib_id = ntohl (fib_id);
12733 mp->default_cop = default_cop;
12737 /* Wait for the reply */
12742 api_get_node_graph (vat_main_t * vam)
12744 vl_api_get_node_graph_t *mp;
12747 M (GET_NODE_GRAPH, get_node_graph);
12751 /* Wait for the reply */
12756 /** Used for parsing LISP eids */
12757 typedef CLIB_PACKED(struct{
12758 u8 addr[16]; /**< eid address */
12759 u32 len; /**< prefix length if IP */
12760 u8 type; /**< type of eid */
12765 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12767 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12769 memset (a, 0, sizeof (a[0]));
12771 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12773 a->type = 0; /* ipv4 type */
12775 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12777 a->type = 1; /* ipv6 type */
12779 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12781 a->type = 2; /* mac type */
12788 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12797 lisp_eid_size_vat (u8 type)
12812 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12814 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12818 /** Used for transferring locators via VPP API */
12819 typedef CLIB_PACKED(struct
12821 u32 sw_if_index; /**< locator sw_if_index */
12822 u8 priority; /**< locator priority */
12823 u8 weight; /**< locator weight */
12828 api_lisp_add_del_locator_set (vat_main_t * vam)
12830 unformat_input_t *input = vam->input;
12831 vl_api_lisp_add_del_locator_set_t *mp;
12834 u8 *locator_set_name = NULL;
12835 u8 locator_set_name_set = 0;
12836 ls_locator_t locator, *locators = 0;
12837 u32 sw_if_index, priority, weight;
12840 /* Parse args required to build the message */
12841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12843 if (unformat (input, "del"))
12847 else if (unformat (input, "locator-set %s", &locator_set_name))
12849 locator_set_name_set = 1;
12851 else if (unformat (input, "sw_if_index %u p %u w %u",
12852 &sw_if_index, &priority, &weight))
12854 locator.sw_if_index = htonl (sw_if_index);
12855 locator.priority = priority;
12856 locator.weight = weight;
12857 vec_add1 (locators, locator);
12861 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
12862 &sw_if_index, &priority, &weight))
12864 locator.sw_if_index = htonl (sw_if_index);
12865 locator.priority = priority;
12866 locator.weight = weight;
12867 vec_add1 (locators, locator);
12873 if (locator_set_name_set == 0)
12875 errmsg ("missing locator-set name");
12876 vec_free (locators);
12880 if (vec_len (locator_set_name) > 64)
12882 errmsg ("locator-set name too long");
12883 vec_free (locator_set_name);
12884 vec_free (locators);
12887 vec_add1 (locator_set_name, 0);
12889 data_len = sizeof (ls_locator_t) * vec_len (locators);
12891 /* Construct the API message */
12892 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12894 mp->is_add = is_add;
12895 clib_memcpy (mp->locator_set_name, locator_set_name,
12896 vec_len (locator_set_name));
12897 vec_free (locator_set_name);
12899 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12901 clib_memcpy (mp->locators, locators, data_len);
12902 vec_free (locators);
12907 /* Wait for a reply... */
12915 api_lisp_add_del_locator (vat_main_t * vam)
12917 unformat_input_t *input = vam->input;
12918 vl_api_lisp_add_del_locator_t *mp;
12920 u32 tmp_if_index = ~0;
12921 u32 sw_if_index = ~0;
12922 u8 sw_if_index_set = 0;
12923 u8 sw_if_index_if_name_set = 0;
12925 u8 priority_set = 0;
12929 u8 *locator_set_name = NULL;
12930 u8 locator_set_name_set = 0;
12932 /* Parse args required to build the message */
12933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12935 if (unformat (input, "del"))
12939 else if (unformat (input, "locator-set %s", &locator_set_name))
12941 locator_set_name_set = 1;
12943 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
12946 sw_if_index_if_name_set = 1;
12947 sw_if_index = tmp_if_index;
12949 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12951 sw_if_index_set = 1;
12952 sw_if_index = tmp_if_index;
12954 else if (unformat (input, "p %d", &priority))
12958 else if (unformat (input, "w %d", &weight))
12966 if (locator_set_name_set == 0)
12968 errmsg ("missing locator-set name");
12972 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12974 errmsg ("missing sw_if_index");
12975 vec_free (locator_set_name);
12979 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12981 errmsg ("cannot use both params interface name and sw_if_index");
12982 vec_free (locator_set_name);
12986 if (priority_set == 0)
12988 errmsg ("missing locator-set priority");
12989 vec_free (locator_set_name);
12993 if (weight_set == 0)
12995 errmsg ("missing locator-set weight");
12996 vec_free (locator_set_name);
13000 if (vec_len (locator_set_name) > 64)
13002 errmsg ("locator-set name too long");
13003 vec_free (locator_set_name);
13006 vec_add1 (locator_set_name, 0);
13008 /* Construct the API message */
13009 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13011 mp->is_add = is_add;
13012 mp->sw_if_index = ntohl (sw_if_index);
13013 mp->priority = priority;
13014 mp->weight = weight;
13015 clib_memcpy (mp->locator_set_name, locator_set_name,
13016 vec_len (locator_set_name));
13017 vec_free (locator_set_name);
13022 /* Wait for a reply... */
13030 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13032 u32 *key_id = va_arg (*args, u32 *);
13035 if (unformat (input, "%s", &s))
13037 if (!strcmp ((char *) s, "sha1"))
13038 key_id[0] = HMAC_SHA_1_96;
13039 else if (!strcmp ((char *) s, "sha256"))
13040 key_id[0] = HMAC_SHA_256_128;
13043 clib_warning ("invalid key_id: '%s'", s);
13044 key_id[0] = HMAC_NO_KEY;
13055 api_lisp_add_del_local_eid (vat_main_t * vam)
13057 unformat_input_t *input = vam->input;
13058 vl_api_lisp_add_del_local_eid_t *mp;
13062 lisp_eid_vat_t _eid, *eid = &_eid;
13063 u8 *locator_set_name = 0;
13064 u8 locator_set_name_set = 0;
13069 /* Parse args required to build the message */
13070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13072 if (unformat (input, "del"))
13076 else if (unformat (input, "vni %d", &vni))
13080 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13084 else if (unformat (input, "locator-set %s", &locator_set_name))
13086 locator_set_name_set = 1;
13088 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13090 else if (unformat (input, "secret-key %_%v%_", &key))
13096 if (locator_set_name_set == 0)
13098 errmsg ("missing locator-set name");
13104 errmsg ("EID address not set!");
13105 vec_free (locator_set_name);
13109 if (key && (0 == key_id))
13111 errmsg ("invalid key_id!");
13115 if (vec_len (key) > 64)
13117 errmsg ("key too long");
13122 if (vec_len (locator_set_name) > 64)
13124 errmsg ("locator-set name too long");
13125 vec_free (locator_set_name);
13128 vec_add1 (locator_set_name, 0);
13130 /* Construct the API message */
13131 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13133 mp->is_add = is_add;
13134 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13135 mp->eid_type = eid->type;
13136 mp->prefix_len = eid->len;
13137 mp->vni = clib_host_to_net_u32 (vni);
13138 mp->key_id = clib_host_to_net_u16 (key_id);
13139 clib_memcpy (mp->locator_set_name, locator_set_name,
13140 vec_len (locator_set_name));
13141 clib_memcpy (mp->key, key, vec_len (key));
13143 vec_free (locator_set_name);
13149 /* Wait for a reply... */
13157 /** Used for transferring locators via VPP API */
13158 typedef CLIB_PACKED(struct
13160 u8 is_ip4; /**< is locator an IPv4 address? */
13161 u8 priority; /**< locator priority */
13162 u8 weight; /**< locator weight */
13163 u8 addr[16]; /**< IPv4/IPv6 address */
13168 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13170 u32 dp_table = 0, vni = 0;;
13171 unformat_input_t *input = vam->input;
13172 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13175 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13176 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13177 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13178 u32 action = ~0, w;
13179 ip4_address_t rmt_rloc4, lcl_rloc4;
13180 ip6_address_t rmt_rloc6, lcl_rloc6;
13181 vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc =
13184 memset (&rloc, 0, sizeof (rloc));
13186 /* Parse args required to build the message */
13187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13189 if (unformat (input, "del"))
13191 else if (unformat (input, "add"))
13193 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13197 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13201 else if (unformat (input, "vrf %d", &dp_table))
13203 else if (unformat (input, "bd %d", &dp_table))
13205 else if (unformat (input, "vni %d", &vni))
13207 else if (unformat (input, "w %d", &w))
13211 errmsg ("No RLOC configured for setting priority/weight!");
13214 curr_rloc->weight = w;
13216 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13217 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13221 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13223 vec_add1 (lcl_locs, rloc);
13225 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13226 vec_add1 (rmt_locs, rloc);
13227 /* weight saved in rmt loc */
13228 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13230 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13231 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13234 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13236 vec_add1 (lcl_locs, rloc);
13238 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13239 vec_add1 (rmt_locs, rloc);
13240 /* weight saved in rmt loc */
13241 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13243 else if (unformat (input, "action %d", &action))
13249 clib_warning ("parse error '%U'", format_unformat_error, input);
13256 errmsg ("remote eid addresses not set");
13260 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13262 errmsg ("eid types don't match");
13266 if (0 == rmt_locs && (u32) ~ 0 == action)
13268 errmsg ("action not set for negative mapping");
13272 /* Construct the API message */
13273 M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry,
13274 sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2);
13276 mp->is_add = is_add;
13277 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13278 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13279 mp->eid_type = rmt_eid->type;
13280 mp->dp_table = clib_host_to_net_u32 (dp_table);
13281 mp->vni = clib_host_to_net_u32 (vni);
13282 mp->rmt_len = rmt_eid->len;
13283 mp->lcl_len = lcl_eid->len;
13284 mp->action = action;
13286 if (0 != rmt_locs && 0 != lcl_locs)
13288 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13289 clib_memcpy (mp->locs, lcl_locs,
13290 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs)));
13292 u32 offset = sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs);
13293 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13294 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs)));
13296 vec_free (lcl_locs);
13297 vec_free (rmt_locs);
13302 /* Wait for a reply... */
13310 api_lisp_add_del_map_server (vat_main_t * vam)
13312 unformat_input_t *input = vam->input;
13313 vl_api_lisp_add_del_map_server_t *mp;
13318 ip4_address_t ipv4;
13319 ip6_address_t ipv6;
13321 /* Parse args required to build the message */
13322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13324 if (unformat (input, "del"))
13328 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13332 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13340 if (ipv4_set && ipv6_set)
13342 errmsg ("both eid v4 and v6 addresses set");
13346 if (!ipv4_set && !ipv6_set)
13348 errmsg ("eid addresses not set");
13352 /* Construct the API message */
13353 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13355 mp->is_add = is_add;
13359 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13364 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13370 /* Wait for a reply... */
13378 api_lisp_add_del_map_resolver (vat_main_t * vam)
13380 unformat_input_t *input = vam->input;
13381 vl_api_lisp_add_del_map_resolver_t *mp;
13386 ip4_address_t ipv4;
13387 ip6_address_t ipv6;
13389 /* Parse args required to build the message */
13390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13392 if (unformat (input, "del"))
13396 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13400 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13408 if (ipv4_set && ipv6_set)
13410 errmsg ("both eid v4 and v6 addresses set");
13414 if (!ipv4_set && !ipv6_set)
13416 errmsg ("eid addresses not set");
13420 /* Construct the API message */
13421 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13423 mp->is_add = is_add;
13427 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13432 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13438 /* Wait for a reply... */
13446 api_lisp_gpe_enable_disable (vat_main_t * vam)
13448 unformat_input_t *input = vam->input;
13449 vl_api_lisp_gpe_enable_disable_t *mp;
13454 /* Parse args required to build the message */
13455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13457 if (unformat (input, "enable"))
13462 else if (unformat (input, "disable"))
13473 errmsg ("Value not set");
13477 /* Construct the API message */
13478 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13485 /* Wait for a reply... */
13493 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13495 unformat_input_t *input = vam->input;
13496 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13501 /* Parse args required to build the message */
13502 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13504 if (unformat (input, "enable"))
13509 else if (unformat (input, "disable"))
13517 errmsg ("Value not set");
13521 /* Construct the API message */
13522 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13524 mp->is_enabled = is_en;
13529 /* Wait for a reply... */
13537 api_lisp_map_register_enable_disable (vat_main_t * vam)
13539 unformat_input_t *input = vam->input;
13540 vl_api_lisp_map_register_enable_disable_t *mp;
13545 /* Parse args required to build the message */
13546 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13548 if (unformat (input, "enable"))
13553 else if (unformat (input, "disable"))
13561 errmsg ("Value not set");
13565 /* Construct the API message */
13566 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13568 mp->is_enabled = is_en;
13573 /* Wait for a reply... */
13581 api_lisp_enable_disable (vat_main_t * vam)
13583 unformat_input_t *input = vam->input;
13584 vl_api_lisp_enable_disable_t *mp;
13589 /* Parse args required to build the message */
13590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13592 if (unformat (input, "enable"))
13597 else if (unformat (input, "disable"))
13607 errmsg ("Value not set");
13611 /* Construct the API message */
13612 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13619 /* Wait for a reply... */
13627 api_show_lisp_map_register_state (vat_main_t * vam)
13630 vl_api_show_lisp_map_register_state_t *mp;
13632 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13637 /* wait for reply */
13644 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13647 vl_api_show_lisp_rloc_probe_state_t *mp;
13649 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13654 /* wait for reply */
13661 api_show_lisp_map_request_mode (vat_main_t * vam)
13664 vl_api_show_lisp_map_request_mode_t *mp;
13666 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13671 /* wait for reply */
13678 api_lisp_map_request_mode (vat_main_t * vam)
13681 unformat_input_t *input = vam->input;
13682 vl_api_lisp_map_request_mode_t *mp;
13685 /* Parse args required to build the message */
13686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13688 if (unformat (input, "dst-only"))
13690 else if (unformat (input, "src-dst"))
13694 errmsg ("parse error '%U'", format_unformat_error, input);
13699 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13706 /* wait for reply */
13714 * Enable/disable LISP proxy ITR.
13716 * @param vam vpp API test context
13717 * @return return code
13720 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13723 u8 ls_name_set = 0;
13724 unformat_input_t *input = vam->input;
13725 vl_api_lisp_pitr_set_locator_set_t *mp;
13729 /* Parse args required to build the message */
13730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13732 if (unformat (input, "del"))
13734 else if (unformat (input, "locator-set %s", &ls_name))
13738 errmsg ("parse error '%U'", format_unformat_error, input);
13745 errmsg ("locator-set name not set!");
13749 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13751 mp->is_add = is_add;
13752 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13753 vec_free (ls_name);
13758 /* wait for reply */
13766 api_show_lisp_pitr (vat_main_t * vam)
13768 vl_api_show_lisp_pitr_t *mp;
13771 if (!vam->json_output)
13773 print (vam->ofp, "%=20s", "lisp status:");
13776 M (SHOW_LISP_PITR, show_lisp_pitr);
13780 /* Wait for a reply... */
13788 * Add/delete mapping between vni and vrf
13791 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13794 unformat_input_t *input = vam->input;
13795 vl_api_lisp_eid_table_add_del_map_t *mp;
13796 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13797 u32 vni, vrf, bd_index;
13799 /* Parse args required to build the message */
13800 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13802 if (unformat (input, "del"))
13804 else if (unformat (input, "vrf %d", &vrf))
13806 else if (unformat (input, "bd_index %d", &bd_index))
13808 else if (unformat (input, "vni %d", &vni))
13814 if (!vni_set || (!vrf_set && !bd_index_set))
13816 errmsg ("missing arguments!");
13820 if (vrf_set && bd_index_set)
13822 errmsg ("error: both vrf and bd entered!");
13826 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13828 mp->is_add = is_add;
13829 mp->vni = htonl (vni);
13830 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13831 mp->is_l2 = bd_index_set;
13836 /* wait for reply */
13844 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13846 u32 *action = va_arg (*args, u32 *);
13849 if (unformat (input, "%s", &s))
13851 if (!strcmp ((char *) s, "no-action"))
13853 else if (!strcmp ((char *) s, "natively-forward"))
13855 else if (!strcmp ((char *) s, "send-map-request"))
13857 else if (!strcmp ((char *) s, "drop"))
13861 clib_warning ("invalid action: '%s'", s);
13873 * Add/del remote mapping to/from LISP control plane
13875 * @param vam vpp API test context
13876 * @return return code
13879 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13881 unformat_input_t *input = vam->input;
13882 vl_api_lisp_add_del_remote_mapping_t *mp;
13885 lisp_eid_vat_t _eid, *eid = &_eid;
13886 lisp_eid_vat_t _seid, *seid = &_seid;
13887 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13888 u32 action = ~0, p, w, data_len;
13889 ip4_address_t rloc4;
13890 ip6_address_t rloc6;
13891 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13893 memset (&rloc, 0, sizeof (rloc));
13895 /* Parse args required to build the message */
13896 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13898 if (unformat (input, "del-all"))
13902 else if (unformat (input, "del"))
13906 else if (unformat (input, "add"))
13910 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13914 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13918 else if (unformat (input, "vni %d", &vni))
13922 else if (unformat (input, "p %d w %d", &p, &w))
13926 errmsg ("No RLOC configured for setting priority/weight!");
13929 curr_rloc->priority = p;
13930 curr_rloc->weight = w;
13932 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13935 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13936 vec_add1 (rlocs, rloc);
13937 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13939 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13942 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13943 vec_add1 (rlocs, rloc);
13944 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13946 else if (unformat (input, "action %U",
13947 unformat_negative_mapping_action, &action))
13953 clib_warning ("parse error '%U'", format_unformat_error, input);
13960 errmsg ("missing params!");
13964 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13966 errmsg ("no action set for negative map-reply!");
13970 data_len = vec_len (rlocs) * sizeof (rloc_t);
13972 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13973 mp->is_add = is_add;
13974 mp->vni = htonl (vni);
13975 mp->action = (u8) action;
13976 mp->is_src_dst = seid_set;
13977 mp->eid_len = eid->len;
13978 mp->seid_len = seid->len;
13979 mp->del_all = del_all;
13980 mp->eid_type = eid->type;
13981 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13982 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13984 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13985 clib_memcpy (mp->rlocs, rlocs, data_len);
13991 /* Wait for a reply... */
13999 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14000 * forwarding entries in data-plane accordingly.
14002 * @param vam vpp API test context
14003 * @return return code
14006 api_lisp_add_del_adjacency (vat_main_t * vam)
14008 unformat_input_t *input = vam->input;
14009 vl_api_lisp_add_del_adjacency_t *mp;
14012 ip4_address_t leid4, reid4;
14013 ip6_address_t leid6, reid6;
14014 u8 reid_mac[6] = { 0 };
14015 u8 leid_mac[6] = { 0 };
14016 u8 reid_type, leid_type;
14017 u32 leid_len = 0, reid_len = 0, len;
14020 leid_type = reid_type = (u8) ~ 0;
14022 /* Parse args required to build the message */
14023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14025 if (unformat (input, "del"))
14029 else if (unformat (input, "add"))
14033 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14036 reid_type = 0; /* ipv4 */
14039 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14042 reid_type = 1; /* ipv6 */
14045 else if (unformat (input, "reid %U", unformat_ethernet_address,
14048 reid_type = 2; /* mac */
14050 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14053 leid_type = 0; /* ipv4 */
14056 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14059 leid_type = 1; /* ipv6 */
14062 else if (unformat (input, "leid %U", unformat_ethernet_address,
14065 leid_type = 2; /* mac */
14067 else if (unformat (input, "vni %d", &vni))
14073 errmsg ("parse error '%U'", format_unformat_error, input);
14078 if ((u8) ~ 0 == reid_type)
14080 errmsg ("missing params!");
14084 if (leid_type != reid_type)
14086 errmsg ("remote and local EIDs are of different types!");
14090 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14091 mp->is_add = is_add;
14092 mp->vni = htonl (vni);
14093 mp->leid_len = leid_len;
14094 mp->reid_len = reid_len;
14095 mp->eid_type = reid_type;
14097 switch (mp->eid_type)
14100 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14101 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14104 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14105 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14108 clib_memcpy (mp->leid, leid_mac, 6);
14109 clib_memcpy (mp->reid, reid_mac, 6);
14112 errmsg ("unknown EID type %d!", mp->eid_type);
14119 /* Wait for a reply... */
14127 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14129 unformat_input_t *input = vam->input;
14130 vl_api_lisp_gpe_add_del_iface_t *mp;
14132 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14133 u32 dp_table = 0, vni = 0;
14135 /* Parse args required to build the message */
14136 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14138 if (unformat (input, "up"))
14143 else if (unformat (input, "down"))
14148 else if (unformat (input, "table_id %d", &dp_table))
14152 else if (unformat (input, "bd_id %d", &dp_table))
14157 else if (unformat (input, "vni %d", &vni))
14165 if (action_set == 0)
14167 errmsg ("Action not set");
14170 if (dp_table_set == 0 || vni_set == 0)
14172 errmsg ("vni and dp_table must be set");
14176 /* Construct the API message */
14177 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14179 mp->is_add = is_add;
14180 mp->dp_table = dp_table;
14187 /* Wait for a reply... */
14195 * Add/del map request itr rlocs from LISP control plane and updates
14197 * @param vam vpp API test context
14198 * @return return code
14201 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14203 unformat_input_t *input = vam->input;
14204 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14206 u8 *locator_set_name = 0;
14207 u8 locator_set_name_set = 0;
14210 /* Parse args required to build the message */
14211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14213 if (unformat (input, "del"))
14217 else if (unformat (input, "%_%v%_", &locator_set_name))
14219 locator_set_name_set = 1;
14223 clib_warning ("parse error '%U'", format_unformat_error, input);
14228 if (is_add && !locator_set_name_set)
14230 errmsg ("itr-rloc is not set!");
14234 if (is_add && vec_len (locator_set_name) > 64)
14236 errmsg ("itr-rloc locator-set name too long");
14237 vec_free (locator_set_name);
14241 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14242 mp->is_add = is_add;
14245 clib_memcpy (mp->locator_set_name, locator_set_name,
14246 vec_len (locator_set_name));
14250 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14252 vec_free (locator_set_name);
14257 /* Wait for a reply... */
14265 api_lisp_locator_dump (vat_main_t * vam)
14267 unformat_input_t *input = vam->input;
14268 vl_api_lisp_locator_dump_t *mp;
14270 u8 is_index_set = 0, is_name_set = 0;
14274 /* Parse args required to build the message */
14275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14277 if (unformat (input, "ls_name %_%v%_", &ls_name))
14281 else if (unformat (input, "ls_index %d", &ls_index))
14287 errmsg ("parse error '%U'", format_unformat_error, input);
14292 if (!is_index_set && !is_name_set)
14294 errmsg ("error: expected one of index or name!");
14298 if (is_index_set && is_name_set)
14300 errmsg ("error: only one param expected!");
14304 if (vec_len (ls_name) > 62)
14306 errmsg ("error: locator set name too long!");
14310 if (!vam->json_output)
14312 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14315 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14316 mp->is_index_set = is_index_set;
14319 mp->ls_index = clib_host_to_net_u32 (ls_index);
14322 vec_add1 (ls_name, 0);
14323 strncpy ((char *) mp->ls_name, (char *) ls_name,
14324 sizeof (mp->ls_name) - 1);
14330 /* Use a control ping for synchronization */
14332 vl_api_control_ping_t *mp;
14333 M (CONTROL_PING, control_ping);
14336 /* Wait for a reply... */
14344 api_lisp_locator_set_dump (vat_main_t * vam)
14346 vl_api_lisp_locator_set_dump_t *mp;
14347 unformat_input_t *input = vam->input;
14351 /* Parse args required to build the message */
14352 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14354 if (unformat (input, "local"))
14358 else if (unformat (input, "remote"))
14364 errmsg ("parse error '%U'", format_unformat_error, input);
14369 if (!vam->json_output)
14371 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14374 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14376 mp->filter = filter;
14381 /* Use a control ping for synchronization */
14383 vl_api_control_ping_t *mp;
14384 M (CONTROL_PING, control_ping);
14387 /* Wait for a reply... */
14395 api_lisp_eid_table_map_dump (vat_main_t * vam)
14399 unformat_input_t *input = vam->input;
14400 vl_api_lisp_eid_table_map_dump_t *mp;
14403 /* Parse args required to build the message */
14404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14406 if (unformat (input, "l2"))
14411 else if (unformat (input, "l3"))
14418 errmsg ("parse error '%U'", format_unformat_error, input);
14425 errmsg ("expected one of 'l2' or 'l3' parameter!");
14429 if (!vam->json_output)
14431 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14434 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14440 /* Use a control ping for synchronization */
14442 vl_api_control_ping_t *mp;
14443 M (CONTROL_PING, control_ping);
14446 /* Wait for a reply... */
14454 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14456 vl_api_lisp_eid_table_vni_dump_t *mp;
14459 if (!vam->json_output)
14461 print (vam->ofp, "VNI");
14464 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14469 /* Use a control ping for synchronization */
14471 vl_api_control_ping_t *mp;
14472 M (CONTROL_PING, control_ping);
14475 /* Wait for a reply... */
14483 api_lisp_eid_table_dump (vat_main_t * vam)
14485 unformat_input_t *i = vam->input;
14486 vl_api_lisp_eid_table_dump_t *mp;
14488 struct in_addr ip4;
14489 struct in6_addr ip6;
14491 u8 eid_type = ~0, eid_set = 0;
14492 u32 prefix_length = ~0, t, vni = 0;
14495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14497 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14503 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14509 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14514 else if (unformat (i, "vni %d", &t))
14518 else if (unformat (i, "local"))
14522 else if (unformat (i, "remote"))
14528 errmsg ("parse error '%U'", format_unformat_error, i);
14533 if (!vam->json_output)
14535 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14536 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14539 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14541 mp->filter = filter;
14545 mp->vni = htonl (vni);
14546 mp->eid_type = eid_type;
14550 mp->prefix_length = prefix_length;
14551 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14554 mp->prefix_length = prefix_length;
14555 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14558 clib_memcpy (mp->eid, mac, sizeof (mac));
14561 errmsg ("unknown EID type %d!", eid_type);
14569 /* Use a control ping for synchronization */
14571 vl_api_control_ping_t *mp;
14572 M (CONTROL_PING, control_ping);
14576 /* Wait for a reply... */
14584 api_lisp_adjacencies_get (vat_main_t * vam)
14586 unformat_input_t *i = vam->input;
14587 vl_api_lisp_adjacencies_get_t *mp;
14592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14594 if (unformat (i, "vni %d", &vni))
14600 errmsg ("parse error '%U'", format_unformat_error, i);
14607 errmsg ("vni not set!");
14611 if (!vam->json_output)
14613 print (vam->ofp, "%s %40s", "leid", "reid");
14616 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14617 mp->vni = clib_host_to_net_u32 (vni);
14622 /* Wait for a reply... */
14630 api_lisp_map_server_dump (vat_main_t * vam)
14632 vl_api_lisp_map_server_dump_t *mp;
14635 if (!vam->json_output)
14637 print (vam->ofp, "%=20s", "Map server");
14640 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14644 /* Use a control ping for synchronization */
14646 vl_api_control_ping_t *mp;
14647 M (CONTROL_PING, control_ping);
14650 /* Wait for a reply... */
14658 api_lisp_map_resolver_dump (vat_main_t * vam)
14660 vl_api_lisp_map_resolver_dump_t *mp;
14663 if (!vam->json_output)
14665 print (vam->ofp, "%=20s", "Map resolver");
14668 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14672 /* Use a control ping for synchronization */
14674 vl_api_control_ping_t *mp;
14675 M (CONTROL_PING, control_ping);
14678 /* Wait for a reply... */
14686 api_show_lisp_status (vat_main_t * vam)
14688 vl_api_show_lisp_status_t *mp;
14691 if (!vam->json_output)
14693 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14696 M (SHOW_LISP_STATUS, show_lisp_status);
14699 /* Wait for a reply... */
14707 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14709 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14712 if (!vam->json_output)
14714 print (vam->ofp, "%=20s", "itr-rlocs:");
14717 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14720 /* Wait for a reply... */
14728 api_af_packet_create (vat_main_t * vam)
14730 unformat_input_t *i = vam->input;
14731 vl_api_af_packet_create_t *mp;
14733 u8 *host_if_name = 0;
14735 u8 random_hw_addr = 1;
14737 memset (hw_addr, 0, sizeof (hw_addr));
14739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14741 if (unformat (i, "name %s", &host_if_name))
14742 vec_add1 (host_if_name, 0);
14743 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14744 random_hw_addr = 0;
14749 if (!vec_len (host_if_name))
14751 errmsg ("host-interface name must be specified");
14755 if (vec_len (host_if_name) > 64)
14757 errmsg ("host-interface name too long");
14761 M (AF_PACKET_CREATE, af_packet_create);
14763 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14764 clib_memcpy (mp->hw_addr, hw_addr, 6);
14765 mp->use_random_hw_addr = random_hw_addr;
14766 vec_free (host_if_name);
14769 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14775 api_af_packet_delete (vat_main_t * vam)
14777 unformat_input_t *i = vam->input;
14778 vl_api_af_packet_delete_t *mp;
14780 u8 *host_if_name = 0;
14782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14784 if (unformat (i, "name %s", &host_if_name))
14785 vec_add1 (host_if_name, 0);
14790 if (!vec_len (host_if_name))
14792 errmsg ("host-interface name must be specified");
14796 if (vec_len (host_if_name) > 64)
14798 errmsg ("host-interface name too long");
14802 M (AF_PACKET_DELETE, af_packet_delete);
14804 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14805 vec_free (host_if_name);
14814 api_policer_add_del (vat_main_t * vam)
14816 unformat_input_t *i = vam->input;
14817 vl_api_policer_add_del_t *mp;
14828 u8 color_aware = 0;
14829 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14831 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14832 conform_action.dscp = 0;
14833 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14834 exceed_action.dscp = 0;
14835 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14836 violate_action.dscp = 0;
14838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14840 if (unformat (i, "del"))
14842 else if (unformat (i, "name %s", &name))
14843 vec_add1 (name, 0);
14844 else if (unformat (i, "cir %u", &cir))
14846 else if (unformat (i, "eir %u", &eir))
14848 else if (unformat (i, "cb %u", &cb))
14850 else if (unformat (i, "eb %u", &eb))
14852 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14855 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14858 else if (unformat (i, "type %U", unformat_policer_type, &type))
14860 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14863 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14866 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14869 else if (unformat (i, "color-aware"))
14875 if (!vec_len (name))
14877 errmsg ("policer name must be specified");
14881 if (vec_len (name) > 64)
14883 errmsg ("policer name too long");
14887 M (POLICER_ADD_DEL, policer_add_del);
14889 clib_memcpy (mp->name, name, vec_len (name));
14891 mp->is_add = is_add;
14896 mp->rate_type = rate_type;
14897 mp->round_type = round_type;
14899 mp->conform_action_type = conform_action.action_type;
14900 mp->conform_dscp = conform_action.dscp;
14901 mp->exceed_action_type = exceed_action.action_type;
14902 mp->exceed_dscp = exceed_action.dscp;
14903 mp->violate_action_type = violate_action.action_type;
14904 mp->violate_dscp = violate_action.dscp;
14905 mp->color_aware = color_aware;
14914 api_policer_dump (vat_main_t * vam)
14916 unformat_input_t *i = vam->input;
14917 vl_api_policer_dump_t *mp;
14919 u8 *match_name = 0;
14920 u8 match_name_valid = 0;
14922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14924 if (unformat (i, "name %s", &match_name))
14926 vec_add1 (match_name, 0);
14927 match_name_valid = 1;
14933 M (POLICER_DUMP, policer_dump);
14934 mp->match_name_valid = match_name_valid;
14935 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14936 vec_free (match_name);
14940 /* Use a control ping for synchronization */
14942 vl_api_control_ping_t *mp;
14943 M (CONTROL_PING, control_ping);
14946 /* Wait for a reply... */
14954 api_policer_classify_set_interface (vat_main_t * vam)
14956 unformat_input_t *i = vam->input;
14957 vl_api_policer_classify_set_interface_t *mp;
14960 int sw_if_index_set;
14961 u32 ip4_table_index = ~0;
14962 u32 ip6_table_index = ~0;
14963 u32 l2_table_index = ~0;
14966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14969 sw_if_index_set = 1;
14970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14971 sw_if_index_set = 1;
14972 else if (unformat (i, "del"))
14974 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14976 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14978 else if (unformat (i, "l2-table %d", &l2_table_index))
14982 clib_warning ("parse error '%U'", format_unformat_error, i);
14987 if (sw_if_index_set == 0)
14989 errmsg ("missing interface name or sw_if_index");
14993 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14995 mp->sw_if_index = ntohl (sw_if_index);
14996 mp->ip4_table_index = ntohl (ip4_table_index);
14997 mp->ip6_table_index = ntohl (ip6_table_index);
14998 mp->l2_table_index = ntohl (l2_table_index);
14999 mp->is_add = is_add;
15008 api_policer_classify_dump (vat_main_t * vam)
15010 unformat_input_t *i = vam->input;
15011 vl_api_policer_classify_dump_t *mp;
15013 u8 type = POLICER_CLASSIFY_N_TABLES;
15015 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15019 errmsg ("classify table type must be specified");
15023 if (!vam->json_output)
15025 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15028 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15033 /* Use a control ping for synchronization */
15035 vl_api_control_ping_t *mp;
15036 M (CONTROL_PING, control_ping);
15039 /* Wait for a reply... */
15047 api_netmap_create (vat_main_t * vam)
15049 unformat_input_t *i = vam->input;
15050 vl_api_netmap_create_t *mp;
15054 u8 random_hw_addr = 1;
15058 memset (hw_addr, 0, sizeof (hw_addr));
15060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15062 if (unformat (i, "name %s", &if_name))
15063 vec_add1 (if_name, 0);
15064 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15065 random_hw_addr = 0;
15066 else if (unformat (i, "pipe"))
15068 else if (unformat (i, "master"))
15070 else if (unformat (i, "slave"))
15076 if (!vec_len (if_name))
15078 errmsg ("interface name must be specified");
15082 if (vec_len (if_name) > 64)
15084 errmsg ("interface name too long");
15088 M (NETMAP_CREATE, netmap_create);
15090 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15091 clib_memcpy (mp->hw_addr, hw_addr, 6);
15092 mp->use_random_hw_addr = random_hw_addr;
15093 mp->is_pipe = is_pipe;
15094 mp->is_master = is_master;
15095 vec_free (if_name);
15104 api_netmap_delete (vat_main_t * vam)
15106 unformat_input_t *i = vam->input;
15107 vl_api_netmap_delete_t *mp;
15111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15113 if (unformat (i, "name %s", &if_name))
15114 vec_add1 (if_name, 0);
15119 if (!vec_len (if_name))
15121 errmsg ("interface name must be specified");
15125 if (vec_len (if_name) > 64)
15127 errmsg ("interface name too long");
15131 M (NETMAP_DELETE, netmap_delete);
15133 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15134 vec_free (if_name);
15142 static void vl_api_mpls_tunnel_details_t_handler
15143 (vl_api_mpls_tunnel_details_t * mp)
15145 vat_main_t *vam = &vat_main;
15146 i32 len = mp->mt_next_hop_n_labels;
15149 print (vam->ofp, "[%d]: via %U %d labels ",
15151 format_ip4_address, mp->mt_next_hop,
15152 ntohl (mp->mt_next_hop_sw_if_index));
15153 for (i = 0; i < len; i++)
15155 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15157 print (vam->ofp, "");
15160 static void vl_api_mpls_tunnel_details_t_handler_json
15161 (vl_api_mpls_tunnel_details_t * mp)
15163 vat_main_t *vam = &vat_main;
15164 vat_json_node_t *node = NULL;
15165 struct in_addr ip4;
15167 i32 len = mp->mt_next_hop_n_labels;
15169 if (VAT_JSON_ARRAY != vam->json_tree.type)
15171 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15172 vat_json_init_array (&vam->json_tree);
15174 node = vat_json_array_add (&vam->json_tree);
15176 vat_json_init_object (node);
15177 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15178 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15179 vat_json_object_add_ip4 (node, "next_hop", ip4);
15180 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15181 ntohl (mp->mt_next_hop_sw_if_index));
15182 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15183 vat_json_object_add_uint (node, "label_count", len);
15184 for (i = 0; i < len; i++)
15186 vat_json_object_add_uint (node, "label",
15187 ntohl (mp->mt_next_hop_out_labels[i]));
15192 api_mpls_tunnel_dump (vat_main_t * vam)
15194 vl_api_mpls_tunnel_dump_t *mp;
15198 /* Parse args required to build the message */
15199 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15201 if (!unformat (vam->input, "tunnel_index %d", &index))
15208 print (vam->ofp, " tunnel_index %d", index);
15210 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15211 mp->tunnel_index = htonl (index);
15214 /* Use a control ping for synchronization */
15216 vl_api_control_ping_t *mp;
15217 M (CONTROL_PING, control_ping);
15223 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15224 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15227 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15229 vat_main_t *vam = &vat_main;
15230 int count = ntohl (mp->count);
15231 vl_api_fib_path2_t *fp;
15235 "table-id %d, label %u, ess_bit %u",
15236 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15238 for (i = 0; i < count; i++)
15240 if (fp->afi == IP46_TYPE_IP6)
15242 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15243 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15244 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15245 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15246 format_ip6_address, fp->next_hop);
15247 else if (fp->afi == IP46_TYPE_IP4)
15249 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15250 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15251 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15252 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15253 format_ip4_address, fp->next_hop);
15258 static void vl_api_mpls_fib_details_t_handler_json
15259 (vl_api_mpls_fib_details_t * mp)
15261 vat_main_t *vam = &vat_main;
15262 int count = ntohl (mp->count);
15263 vat_json_node_t *node = NULL;
15264 struct in_addr ip4;
15265 struct in6_addr ip6;
15266 vl_api_fib_path2_t *fp;
15269 if (VAT_JSON_ARRAY != vam->json_tree.type)
15271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15272 vat_json_init_array (&vam->json_tree);
15274 node = vat_json_array_add (&vam->json_tree);
15276 vat_json_init_object (node);
15277 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15278 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15279 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15280 vat_json_object_add_uint (node, "path_count", count);
15282 for (i = 0; i < count; i++)
15284 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15285 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15286 vat_json_object_add_uint (node, "is_local", fp->is_local);
15287 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15288 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15289 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15290 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15291 if (fp->afi == IP46_TYPE_IP4)
15293 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15294 vat_json_object_add_ip4 (node, "next_hop", ip4);
15296 else if (fp->afi == IP46_TYPE_IP6)
15298 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15299 vat_json_object_add_ip6 (node, "next_hop", ip6);
15305 api_mpls_fib_dump (vat_main_t * vam)
15307 vl_api_mpls_fib_dump_t *mp;
15310 M (MPLS_FIB_DUMP, mpls_fib_dump);
15313 /* Use a control ping for synchronization */
15315 vl_api_control_ping_t *mp;
15316 M (CONTROL_PING, control_ping);
15322 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15323 #define vl_api_ip_fib_details_t_print vl_noop_handler
15326 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15328 vat_main_t *vam = &vat_main;
15329 int count = ntohl (mp->count);
15330 vl_api_fib_path_t *fp;
15334 "table-id %d, prefix %U/%d",
15335 ntohl (mp->table_id), format_ip4_address, mp->address,
15336 mp->address_length);
15338 for (i = 0; i < count; i++)
15340 if (fp->afi == IP46_TYPE_IP6)
15342 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15343 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15344 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15345 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15346 format_ip6_address, fp->next_hop);
15347 else if (fp->afi == IP46_TYPE_IP4)
15349 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15350 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15351 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15352 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15353 format_ip4_address, fp->next_hop);
15358 static void vl_api_ip_fib_details_t_handler_json
15359 (vl_api_ip_fib_details_t * mp)
15361 vat_main_t *vam = &vat_main;
15362 int count = ntohl (mp->count);
15363 vat_json_node_t *node = NULL;
15364 struct in_addr ip4;
15365 struct in6_addr ip6;
15366 vl_api_fib_path_t *fp;
15369 if (VAT_JSON_ARRAY != vam->json_tree.type)
15371 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15372 vat_json_init_array (&vam->json_tree);
15374 node = vat_json_array_add (&vam->json_tree);
15376 vat_json_init_object (node);
15377 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15378 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15379 vat_json_object_add_ip4 (node, "prefix", ip4);
15380 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15381 vat_json_object_add_uint (node, "path_count", count);
15383 for (i = 0; i < count; i++)
15385 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15386 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15387 vat_json_object_add_uint (node, "is_local", fp->is_local);
15388 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15389 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15390 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15391 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15392 if (fp->afi == IP46_TYPE_IP4)
15394 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15395 vat_json_object_add_ip4 (node, "next_hop", ip4);
15397 else if (fp->afi == IP46_TYPE_IP6)
15399 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15400 vat_json_object_add_ip6 (node, "next_hop", ip6);
15406 api_ip_fib_dump (vat_main_t * vam)
15408 vl_api_ip_fib_dump_t *mp;
15411 M (IP_FIB_DUMP, ip_fib_dump);
15414 /* Use a control ping for synchronization */
15416 vl_api_control_ping_t *mp;
15417 M (CONTROL_PING, control_ping);
15423 static void vl_api_ip_neighbor_details_t_handler
15424 (vl_api_ip_neighbor_details_t * mp)
15426 vat_main_t *vam = &vat_main;
15428 print (vam->ofp, "%c %U %U",
15429 (mp->is_static) ? 'S' : 'D',
15430 format_ethernet_address, &mp->mac_address,
15431 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15435 static void vl_api_ip_neighbor_details_t_handler_json
15436 (vl_api_ip_neighbor_details_t * mp)
15439 vat_main_t *vam = &vat_main;
15440 vat_json_node_t *node;
15441 struct in_addr ip4;
15442 struct in6_addr ip6;
15444 if (VAT_JSON_ARRAY != vam->json_tree.type)
15446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15447 vat_json_init_array (&vam->json_tree);
15449 node = vat_json_array_add (&vam->json_tree);
15451 vat_json_init_object (node);
15452 vat_json_object_add_string_copy (node, "flag",
15453 (mp->is_static) ? (u8 *) "static" : (u8 *)
15456 vat_json_object_add_string_copy (node, "link_layer",
15457 format (0, "%U", format_ethernet_address,
15458 &mp->mac_address));
15462 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15463 vat_json_object_add_ip6 (node, "ip_address", ip6);
15467 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15468 vat_json_object_add_ip4 (node, "ip_address", ip4);
15473 api_ip_neighbor_dump (vat_main_t * vam)
15475 unformat_input_t *i = vam->input;
15476 vl_api_ip_neighbor_dump_t *mp;
15479 u32 sw_if_index = ~0;
15481 /* Parse args required to build the message */
15482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15488 else if (unformat (i, "ip6"))
15494 if (sw_if_index == ~0)
15496 errmsg ("missing interface name or sw_if_index");
15500 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15501 mp->is_ipv6 = (u8) is_ipv6;
15502 mp->sw_if_index = ntohl (sw_if_index);
15505 /* Use a control ping for synchronization */
15507 vl_api_control_ping_t *mp;
15508 M (CONTROL_PING, control_ping);
15514 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15515 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15518 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15520 vat_main_t *vam = &vat_main;
15521 int count = ntohl (mp->count);
15522 vl_api_fib_path_t *fp;
15526 "table-id %d, prefix %U/%d",
15527 ntohl (mp->table_id), format_ip6_address, mp->address,
15528 mp->address_length);
15530 for (i = 0; i < count; i++)
15532 if (fp->afi == IP46_TYPE_IP6)
15534 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15535 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15536 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15537 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15538 format_ip6_address, fp->next_hop);
15539 else if (fp->afi == IP46_TYPE_IP4)
15541 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15542 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15543 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15544 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15545 format_ip4_address, fp->next_hop);
15550 static void vl_api_ip6_fib_details_t_handler_json
15551 (vl_api_ip6_fib_details_t * mp)
15553 vat_main_t *vam = &vat_main;
15554 int count = ntohl (mp->count);
15555 vat_json_node_t *node = NULL;
15556 struct in_addr ip4;
15557 struct in6_addr ip6;
15558 vl_api_fib_path_t *fp;
15561 if (VAT_JSON_ARRAY != vam->json_tree.type)
15563 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15564 vat_json_init_array (&vam->json_tree);
15566 node = vat_json_array_add (&vam->json_tree);
15568 vat_json_init_object (node);
15569 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15570 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15571 vat_json_object_add_ip6 (node, "prefix", ip6);
15572 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15573 vat_json_object_add_uint (node, "path_count", count);
15575 for (i = 0; i < count; i++)
15577 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15578 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15579 vat_json_object_add_uint (node, "is_local", fp->is_local);
15580 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15581 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15582 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15583 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15584 if (fp->afi == IP46_TYPE_IP4)
15586 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15587 vat_json_object_add_ip4 (node, "next_hop", ip4);
15589 else if (fp->afi == IP46_TYPE_IP6)
15591 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15592 vat_json_object_add_ip6 (node, "next_hop", ip6);
15598 api_ip6_fib_dump (vat_main_t * vam)
15600 vl_api_ip6_fib_dump_t *mp;
15603 M (IP6_FIB_DUMP, ip6_fib_dump);
15606 /* Use a control ping for synchronization */
15608 vl_api_control_ping_t *mp;
15609 M (CONTROL_PING, control_ping);
15616 api_classify_table_ids (vat_main_t * vam)
15618 vl_api_classify_table_ids_t *mp;
15621 /* Construct the API message */
15622 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15632 api_classify_table_by_interface (vat_main_t * vam)
15634 unformat_input_t *input = vam->input;
15635 vl_api_classify_table_by_interface_t *mp;
15638 u32 sw_if_index = ~0;
15639 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15641 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15643 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15648 if (sw_if_index == ~0)
15650 errmsg ("missing interface name or sw_if_index");
15654 /* Construct the API message */
15655 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15657 mp->sw_if_index = ntohl (sw_if_index);
15666 api_classify_table_info (vat_main_t * vam)
15668 unformat_input_t *input = vam->input;
15669 vl_api_classify_table_info_t *mp;
15673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15675 if (unformat (input, "table_id %d", &table_id))
15680 if (table_id == ~0)
15682 errmsg ("missing table id");
15686 /* Construct the API message */
15687 M (CLASSIFY_TABLE_INFO, classify_table_info);
15689 mp->table_id = ntohl (table_id);
15698 api_classify_session_dump (vat_main_t * vam)
15700 unformat_input_t *input = vam->input;
15701 vl_api_classify_session_dump_t *mp;
15705 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15707 if (unformat (input, "table_id %d", &table_id))
15712 if (table_id == ~0)
15714 errmsg ("missing table id");
15718 /* Construct the API message */
15719 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15721 mp->table_id = ntohl (table_id);
15724 /* Use a control ping for synchronization */
15726 vl_api_control_ping_t *mp;
15727 M (CONTROL_PING, control_ping);
15736 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15738 vat_main_t *vam = &vat_main;
15740 print (vam->ofp, "collector_address %U, collector_port %d, "
15741 "src_address %U, vrf_id %d, path_mtu %u, "
15742 "template_interval %u, udp_checksum %d",
15743 format_ip4_address, mp->collector_address,
15744 ntohs (mp->collector_port),
15745 format_ip4_address, mp->src_address,
15746 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15747 ntohl (mp->template_interval), mp->udp_checksum);
15750 vam->result_ready = 1;
15754 vl_api_ipfix_exporter_details_t_handler_json
15755 (vl_api_ipfix_exporter_details_t * mp)
15757 vat_main_t *vam = &vat_main;
15758 vat_json_node_t node;
15759 struct in_addr collector_address;
15760 struct in_addr src_address;
15762 vat_json_init_object (&node);
15763 clib_memcpy (&collector_address, &mp->collector_address,
15764 sizeof (collector_address));
15765 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15766 vat_json_object_add_uint (&node, "collector_port",
15767 ntohs (mp->collector_port));
15768 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15769 vat_json_object_add_ip4 (&node, "src_address", src_address);
15770 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15771 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15772 vat_json_object_add_uint (&node, "template_interval",
15773 ntohl (mp->template_interval));
15774 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15776 vat_json_print (vam->ofp, &node);
15777 vat_json_free (&node);
15779 vam->result_ready = 1;
15783 api_ipfix_exporter_dump (vat_main_t * vam)
15785 vl_api_ipfix_exporter_dump_t *mp;
15788 /* Construct the API message */
15789 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15799 api_ipfix_classify_stream_dump (vat_main_t * vam)
15801 vl_api_ipfix_classify_stream_dump_t *mp;
15804 /* Construct the API message */
15805 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15815 vl_api_ipfix_classify_stream_details_t_handler
15816 (vl_api_ipfix_classify_stream_details_t * mp)
15818 vat_main_t *vam = &vat_main;
15819 print (vam->ofp, "domain_id %d, src_port %d",
15820 ntohl (mp->domain_id), ntohs (mp->src_port));
15822 vam->result_ready = 1;
15826 vl_api_ipfix_classify_stream_details_t_handler_json
15827 (vl_api_ipfix_classify_stream_details_t * mp)
15829 vat_main_t *vam = &vat_main;
15830 vat_json_node_t node;
15832 vat_json_init_object (&node);
15833 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15834 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15836 vat_json_print (vam->ofp, &node);
15837 vat_json_free (&node);
15839 vam->result_ready = 1;
15843 api_ipfix_classify_table_dump (vat_main_t * vam)
15845 vl_api_ipfix_classify_table_dump_t *mp;
15848 if (!vam->json_output)
15850 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
15851 "transport_protocol");
15854 /* Construct the API message */
15855 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15860 /* Use a control ping for synchronization */
15862 vl_api_control_ping_t *mp;
15863 M (CONTROL_PING, control_ping);
15870 vl_api_ipfix_classify_table_details_t_handler
15871 (vl_api_ipfix_classify_table_details_t * mp)
15873 vat_main_t *vam = &vat_main;
15874 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
15875 mp->transport_protocol);
15879 vl_api_ipfix_classify_table_details_t_handler_json
15880 (vl_api_ipfix_classify_table_details_t * mp)
15882 vat_json_node_t *node = NULL;
15883 vat_main_t *vam = &vat_main;
15885 if (VAT_JSON_ARRAY != vam->json_tree.type)
15887 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15888 vat_json_init_array (&vam->json_tree);
15891 node = vat_json_array_add (&vam->json_tree);
15892 vat_json_init_object (node);
15894 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15895 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15896 vat_json_object_add_uint (node, "transport_protocol",
15897 mp->transport_protocol);
15901 api_sw_interface_span_enable_disable (vat_main_t * vam)
15903 unformat_input_t *i = vam->input;
15904 vl_api_sw_interface_span_enable_disable_t *mp;
15906 u32 src_sw_if_index = ~0;
15907 u32 dst_sw_if_index = ~0;
15910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15913 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
15915 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15919 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
15921 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15923 else if (unformat (i, "disable"))
15925 else if (unformat (i, "rx"))
15927 else if (unformat (i, "tx"))
15929 else if (unformat (i, "both"))
15935 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
15937 mp->sw_if_index_from = htonl (src_sw_if_index);
15938 mp->sw_if_index_to = htonl (dst_sw_if_index);
15948 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
15951 vat_main_t *vam = &vat_main;
15952 u8 *sw_if_from_name = 0;
15953 u8 *sw_if_to_name = 0;
15954 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
15955 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
15956 char *states[] = { "none", "rx", "tx", "both" };
15960 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
15962 if ((u32) p->value[0] == sw_if_index_from)
15964 sw_if_from_name = (u8 *)(p->key);
15968 if ((u32) p->value[0] == sw_if_index_to)
15970 sw_if_to_name = (u8 *)(p->key);
15971 if (sw_if_from_name)
15976 print (vam->ofp, "%20s => %20s (%s)",
15977 sw_if_from_name, sw_if_to_name, states[mp->state]);
15981 vl_api_sw_interface_span_details_t_handler_json
15982 (vl_api_sw_interface_span_details_t * mp)
15984 vat_main_t *vam = &vat_main;
15985 vat_json_node_t *node = NULL;
15986 u8 *sw_if_from_name = 0;
15987 u8 *sw_if_to_name = 0;
15988 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
15989 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
15993 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
15995 if ((u32) p->value[0] == sw_if_index_from)
15997 sw_if_from_name = (u8 *)(p->key);
16001 if ((u32) p->value[0] == sw_if_index_to)
16003 sw_if_to_name = (u8 *)(p->key);
16004 if (sw_if_from_name)
16010 if (VAT_JSON_ARRAY != vam->json_tree.type)
16012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16013 vat_json_init_array (&vam->json_tree);
16015 node = vat_json_array_add (&vam->json_tree);
16017 vat_json_init_object (node);
16018 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16019 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16020 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16021 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16022 vat_json_object_add_uint (node, "state", mp->state);
16026 api_sw_interface_span_dump (vat_main_t * vam)
16028 vl_api_sw_interface_span_dump_t *mp;
16031 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16034 /* Use a control ping for synchronization */
16036 vl_api_control_ping_t *mp;
16037 M (CONTROL_PING, control_ping);
16044 api_pg_create_interface (vat_main_t * vam)
16046 unformat_input_t *input = vam->input;
16047 vl_api_pg_create_interface_t *mp;
16051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16053 if (unformat (input, "if_id %d", &if_id))
16060 errmsg ("missing pg interface index");
16064 /* Construct the API message */
16065 M (PG_CREATE_INTERFACE, pg_create_interface);
16067 mp->interface_id = ntohl (if_id);
16076 api_pg_capture (vat_main_t * vam)
16078 unformat_input_t *input = vam->input;
16079 vl_api_pg_capture_t *mp;
16085 u8 pcap_file_set = 0;
16087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16089 if (unformat (input, "if_id %d", &if_id))
16091 else if (unformat (input, "pcap %s", &pcap_file))
16093 else if (unformat (input, "count %d", &count))
16095 else if (unformat (input, "disable"))
16102 errmsg ("missing pg interface index");
16105 if (pcap_file_set > 0)
16107 if (vec_len (pcap_file) > 255)
16109 errmsg ("pcap file name is too long");
16114 u32 name_len = vec_len (pcap_file);
16115 /* Construct the API message */
16116 M (PG_CAPTURE, pg_capture);
16118 mp->interface_id = ntohl (if_id);
16119 mp->is_enabled = enable;
16120 mp->count = ntohl (count);
16121 mp->pcap_name_length = ntohl (name_len);
16122 if (pcap_file_set != 0)
16124 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16126 vec_free (pcap_file);
16135 api_pg_enable_disable (vat_main_t * vam)
16137 unformat_input_t *input = vam->input;
16138 vl_api_pg_enable_disable_t *mp;
16142 u8 stream_name_set = 0;
16143 u8 *stream_name = 0;
16144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (input, "stream %s", &stream_name))
16147 stream_name_set = 1;
16148 else if (unformat (input, "disable"))
16154 if (stream_name_set > 0)
16156 if (vec_len (stream_name) > 255)
16158 errmsg ("stream name too long");
16163 u32 name_len = vec_len (stream_name);
16164 /* Construct the API message */
16165 M (PG_ENABLE_DISABLE, pg_enable_disable);
16167 mp->is_enabled = enable;
16168 if (stream_name_set != 0)
16170 mp->stream_name_length = ntohl (name_len);
16171 clib_memcpy (mp->stream_name, stream_name, name_len);
16173 vec_free (stream_name);
16182 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16184 unformat_input_t *input = vam->input;
16185 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16188 u16 *low_ports = 0;
16189 u16 *high_ports = 0;
16192 ip4_address_t ip4_addr;
16193 ip6_address_t ip6_addr;
16201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16203 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16209 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16214 else if (unformat (input, "vrf %d", &vrf_id))
16216 else if (unformat (input, "del"))
16218 else if (unformat (input, "port %d", &tmp))
16220 if (tmp == 0 || tmp > 65535)
16222 errmsg ("port %d out of range", tmp);
16226 this_hi = this_low + 1;
16227 vec_add1 (low_ports, this_low);
16228 vec_add1 (high_ports, this_hi);
16230 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16232 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16234 errmsg ("incorrect range parameters");
16238 /* Note: in debug CLI +1 is added to high before
16239 passing to real fn that does "the work"
16240 (ip_source_and_port_range_check_add_del).
16241 This fn is a wrapper around the binary API fn a
16242 control plane will call, which expects this increment
16243 to have occurred. Hence letting the binary API control
16244 plane fn do the increment for consistency between VAT
16245 and other control planes.
16248 vec_add1 (low_ports, this_low);
16249 vec_add1 (high_ports, this_hi);
16255 if (prefix_set == 0)
16257 errmsg ("<address>/<mask> not specified");
16263 errmsg ("VRF ID required, not specified");
16270 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16274 if (vec_len (low_ports) == 0)
16276 errmsg ("At least one port or port range required");
16280 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16281 ip_source_and_port_range_check_add_del);
16283 mp->is_add = is_add;
16288 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16293 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16296 mp->mask_length = length;
16297 mp->number_of_ranges = vec_len (low_ports);
16299 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16300 vec_free (low_ports);
16302 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16303 vec_free (high_ports);
16305 mp->vrf_id = ntohl (vrf_id);
16314 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16316 unformat_input_t *input = vam->input;
16317 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16319 u32 sw_if_index = ~0;
16321 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16322 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16327 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16329 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16331 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16333 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16335 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16337 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16339 else if (unformat (input, "del"))
16345 if (sw_if_index == ~0)
16347 errmsg ("Interface required but not specified");
16353 errmsg ("VRF ID required but not specified");
16357 if (tcp_out_vrf_id == 0
16358 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16361 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16365 /* Construct the API message */
16366 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16367 ip_source_and_port_range_check_interface_add_del);
16369 mp->sw_if_index = ntohl (sw_if_index);
16370 mp->is_add = is_add;
16371 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16372 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16373 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16374 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16379 /* Wait for a reply... */
16384 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16386 unformat_input_t *i = vam->input;
16387 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16389 u32 local_sa_id = 0;
16390 u32 remote_sa_id = 0;
16391 ip4_address_t src_address;
16392 ip4_address_t dst_address;
16395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16397 if (unformat (i, "local_sa %d", &local_sa_id))
16399 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16401 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16403 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16405 else if (unformat (i, "del"))
16409 clib_warning ("parse error '%U'", format_unformat_error, i);
16414 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16416 mp->local_sa_id = ntohl (local_sa_id);
16417 mp->remote_sa_id = ntohl (remote_sa_id);
16418 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16419 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16420 mp->is_add = is_add;
16429 api_punt (vat_main_t * vam)
16431 unformat_input_t *i = vam->input;
16439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16441 if (unformat (i, "ip %d", &ipv))
16443 else if (unformat (i, "protocol %d", &protocol))
16445 else if (unformat (i, "port %d", &port))
16447 else if (unformat (i, "del"))
16451 clib_warning ("parse error '%U'", format_unformat_error, i);
16458 mp->is_add = (u8) is_add;
16459 mp->ipv = (u8) ipv;
16460 mp->l4_protocol = (u8) protocol;
16461 mp->l4_port = htons ((u16) port);
16469 static void vl_api_ipsec_gre_tunnel_details_t_handler
16470 (vl_api_ipsec_gre_tunnel_details_t * mp)
16472 vat_main_t *vam = &vat_main;
16474 print (vam->ofp, "%11d%15U%15U%14d%14d",
16475 ntohl (mp->sw_if_index),
16476 format_ip4_address, &mp->src_address,
16477 format_ip4_address, &mp->dst_address,
16478 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16481 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16482 (vl_api_ipsec_gre_tunnel_details_t * mp)
16484 vat_main_t *vam = &vat_main;
16485 vat_json_node_t *node = NULL;
16486 struct in_addr ip4;
16488 if (VAT_JSON_ARRAY != vam->json_tree.type)
16490 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16491 vat_json_init_array (&vam->json_tree);
16493 node = vat_json_array_add (&vam->json_tree);
16495 vat_json_init_object (node);
16496 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16497 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16498 vat_json_object_add_ip4 (node, "src_address", ip4);
16499 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16500 vat_json_object_add_ip4 (node, "dst_address", ip4);
16501 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16502 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16506 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16508 unformat_input_t *i = vam->input;
16509 vl_api_ipsec_gre_tunnel_dump_t *mp;
16512 u8 sw_if_index_set = 0;
16514 /* Parse args required to build the message */
16515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16517 if (unformat (i, "sw_if_index %d", &sw_if_index))
16518 sw_if_index_set = 1;
16523 if (sw_if_index_set == 0)
16528 if (!vam->json_output)
16530 print (vam->ofp, "%11s%15s%15s%14s%14s",
16531 "sw_if_index", "src_address", "dst_address",
16532 "local_sa_id", "remote_sa_id");
16535 /* Get list of gre-tunnel interfaces */
16536 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16538 mp->sw_if_index = htonl (sw_if_index);
16542 /* Use a control ping for synchronization */
16544 vl_api_control_ping_t *mp;
16545 M (CONTROL_PING, control_ping);
16552 api_delete_subif (vat_main_t * vam)
16554 unformat_input_t *i = vam->input;
16555 vl_api_delete_subif_t *mp;
16557 u32 sw_if_index = ~0;
16559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16563 if (unformat (i, "sw_if_index %d", &sw_if_index))
16569 if (sw_if_index == ~0)
16571 errmsg ("missing sw_if_index");
16575 /* Construct the API message */
16576 M (DELETE_SUBIF, delete_subif);
16577 mp->sw_if_index = ntohl (sw_if_index);
16583 #define foreach_pbb_vtr_op \
16584 _("disable", L2_VTR_DISABLED) \
16585 _("pop", L2_VTR_POP_2) \
16586 _("push", L2_VTR_PUSH_2)
16589 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16591 unformat_input_t *i = vam->input;
16592 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16594 u32 sw_if_index = ~0, vtr_op = ~0;
16595 u16 outer_tag = ~0;
16596 u8 dmac[6], smac[6];
16597 u8 dmac_set = 0, smac_set = 0;
16602 /* Shut up coverity */
16603 memset (dmac, 0, sizeof (dmac));
16604 memset (smac, 0, sizeof (smac));
16606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16608 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16610 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16612 else if (unformat (i, "vtr_op %d", &vtr_op))
16614 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16617 else if (unformat (i, "translate_pbb_stag"))
16619 if (unformat (i, "%d", &tmp))
16621 vtr_op = L2_VTR_TRANSLATE_2_1;
16627 ("translate_pbb_stag operation requires outer tag definition");
16631 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16633 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16635 else if (unformat (i, "sid %d", &sid))
16637 else if (unformat (i, "vlanid %d", &tmp))
16641 clib_warning ("parse error '%U'", format_unformat_error, i);
16646 if ((sw_if_index == ~0) || (vtr_op == ~0))
16648 errmsg ("missing sw_if_index or vtr operation");
16651 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16652 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16655 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16659 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16660 mp->sw_if_index = ntohl (sw_if_index);
16661 mp->vtr_op = ntohl (vtr_op);
16662 mp->outer_tag = ntohs (outer_tag);
16663 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16664 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16665 mp->b_vlanid = ntohs (vlanid);
16666 mp->i_sid = ntohl (sid);
16675 api_flow_classify_set_interface (vat_main_t * vam)
16677 unformat_input_t *i = vam->input;
16678 vl_api_flow_classify_set_interface_t *mp;
16681 int sw_if_index_set;
16682 u32 ip4_table_index = ~0;
16683 u32 ip6_table_index = ~0;
16686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16689 sw_if_index_set = 1;
16690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16691 sw_if_index_set = 1;
16692 else if (unformat (i, "del"))
16694 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16696 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16700 clib_warning ("parse error '%U'", format_unformat_error, i);
16705 if (sw_if_index_set == 0)
16707 errmsg ("missing interface name or sw_if_index");
16711 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16713 mp->sw_if_index = ntohl (sw_if_index);
16714 mp->ip4_table_index = ntohl (ip4_table_index);
16715 mp->ip6_table_index = ntohl (ip6_table_index);
16716 mp->is_add = is_add;
16725 api_flow_classify_dump (vat_main_t * vam)
16727 unformat_input_t *i = vam->input;
16728 vl_api_flow_classify_dump_t *mp;
16730 u8 type = FLOW_CLASSIFY_N_TABLES;
16732 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16736 errmsg ("classify table type must be specified");
16740 if (!vam->json_output)
16742 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16745 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16750 /* Use a control ping for synchronization */
16752 vl_api_control_ping_t *mp;
16753 M (CONTROL_PING, control_ping);
16756 /* Wait for a reply... */
16764 api_feature_enable_disable (vat_main_t * vam)
16766 unformat_input_t *i = vam->input;
16767 vl_api_feature_enable_disable_t *mp;
16770 u8 *feature_name = 0;
16771 u32 sw_if_index = ~0;
16774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16776 if (unformat (i, "arc_name %s", &arc_name))
16778 else if (unformat (i, "feature_name %s", &feature_name))
16781 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16783 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16785 else if (unformat (i, "disable"))
16793 errmsg ("missing arc name");
16796 if (vec_len (arc_name) > 63)
16798 errmsg ("arc name too long");
16801 if (feature_name == 0)
16803 errmsg ("missing feature name");
16806 if (vec_len (feature_name) > 63)
16808 errmsg ("feature name too long");
16811 if (sw_if_index == ~0)
16813 errmsg ("missing interface name or sw_if_index");
16817 /* Construct the API message */
16818 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16819 mp->sw_if_index = ntohl (sw_if_index);
16820 mp->enable = enable;
16821 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16822 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16823 vec_free (arc_name);
16824 vec_free (feature_name);
16831 api_sw_interface_tag_add_del (vat_main_t * vam)
16833 unformat_input_t *i = vam->input;
16834 vl_api_sw_interface_tag_add_del_t *mp;
16836 u32 sw_if_index = ~0;
16840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16842 if (unformat (i, "tag %s", &tag))
16844 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16846 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16848 else if (unformat (i, "del"))
16854 if (sw_if_index == ~0)
16856 errmsg ("missing interface name or sw_if_index");
16860 if (enable && (tag == 0))
16862 errmsg ("no tag specified");
16866 /* Construct the API message */
16867 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16868 mp->sw_if_index = ntohl (sw_if_index);
16869 mp->is_add = enable;
16871 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16878 static void vl_api_l2_xconnect_details_t_handler
16879 (vl_api_l2_xconnect_details_t * mp)
16881 vat_main_t *vam = &vat_main;
16883 print (vam->ofp, "%15d%15d",
16884 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16887 static void vl_api_l2_xconnect_details_t_handler_json
16888 (vl_api_l2_xconnect_details_t * mp)
16890 vat_main_t *vam = &vat_main;
16891 vat_json_node_t *node = NULL;
16893 if (VAT_JSON_ARRAY != vam->json_tree.type)
16895 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16896 vat_json_init_array (&vam->json_tree);
16898 node = vat_json_array_add (&vam->json_tree);
16900 vat_json_init_object (node);
16901 vat_json_object_add_uint (node, "rx_sw_if_index",
16902 ntohl (mp->rx_sw_if_index));
16903 vat_json_object_add_uint (node, "tx_sw_if_index",
16904 ntohl (mp->tx_sw_if_index));
16908 api_l2_xconnect_dump (vat_main_t * vam)
16910 vl_api_l2_xconnect_dump_t *mp;
16913 if (!vam->json_output)
16915 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
16918 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
16922 /* Use a control ping for synchronization */
16924 vl_api_control_ping_t *mp;
16925 M (CONTROL_PING, control_ping);
16932 api_sw_interface_set_mtu (vat_main_t * vam)
16934 unformat_input_t *i = vam->input;
16935 vl_api_sw_interface_set_mtu_t *mp;
16937 u32 sw_if_index = ~0;
16940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16942 if (unformat (i, "mtu %d", &mtu))
16944 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16946 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16952 if (sw_if_index == ~0)
16954 errmsg ("missing interface name or sw_if_index");
16960 errmsg ("no mtu specified");
16964 /* Construct the API message */
16965 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
16966 mp->sw_if_index = ntohl (sw_if_index);
16967 mp->mtu = ntohs ((u16) mtu);
16975 q_or_quit (vat_main_t * vam)
16977 longjmp (vam->jump_buf, 1);
16978 return 0; /* not so much */
16982 q (vat_main_t * vam)
16984 return q_or_quit (vam);
16988 quit (vat_main_t * vam)
16990 return q_or_quit (vam);
16994 comment (vat_main_t * vam)
17000 cmd_cmp (void *a1, void *a2)
17005 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17009 help (vat_main_t * vam)
17014 unformat_input_t *i = vam->input;
17017 if (unformat (i, "%s", &name))
17021 vec_add1 (name, 0);
17023 hs = hash_get_mem (vam->help_by_name, name);
17025 print (vam->ofp, "usage: %s %s", name, hs[0]);
17027 print (vam->ofp, "No such msg / command '%s'", name);
17032 print (vam->ofp, "Help is available for the following:");
17035 hash_foreach_pair (p, vam->function_by_name,
17037 vec_add1 (cmds, (u8 *)(p->key));
17041 vec_sort_with_function (cmds, cmd_cmp);
17043 for (j = 0; j < vec_len (cmds); j++)
17044 print (vam->ofp, "%s", cmds[j]);
17051 set (vat_main_t * vam)
17053 u8 *name = 0, *value = 0;
17054 unformat_input_t *i = vam->input;
17056 if (unformat (i, "%s", &name))
17058 /* The input buffer is a vector, not a string. */
17059 value = vec_dup (i->buffer);
17060 vec_delete (value, i->index, 0);
17061 /* Almost certainly has a trailing newline */
17062 if (value[vec_len (value) - 1] == '\n')
17063 value[vec_len (value) - 1] = 0;
17064 /* Make sure it's a proper string, one way or the other */
17065 vec_add1 (value, 0);
17066 (void) clib_macro_set_value (&vam->macro_main,
17067 (char *) name, (char *) value);
17070 errmsg ("usage: set <name> <value>");
17078 unset (vat_main_t * vam)
17082 if (unformat (vam->input, "%s", &name))
17083 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17084 errmsg ("unset: %s wasn't set", name);
17097 macro_sort_cmp (void *a1, void *a2)
17099 macro_sort_t *s1 = a1;
17100 macro_sort_t *s2 = a2;
17102 return strcmp ((char *) (s1->name), (char *) (s2->name));
17106 dump_macro_table (vat_main_t * vam)
17108 macro_sort_t *sort_me = 0, *sm;
17113 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17115 vec_add2 (sort_me, sm, 1);
17116 sm->name = (u8 *)(p->key);
17117 sm->value = (u8 *) (p->value[0]);
17121 vec_sort_with_function (sort_me, macro_sort_cmp);
17123 if (vec_len (sort_me))
17124 print (vam->ofp, "%-15s%s", "Name", "Value");
17126 print (vam->ofp, "The macro table is empty...");
17128 for (i = 0; i < vec_len (sort_me); i++)
17129 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17134 dump_node_table (vat_main_t * vam)
17137 vlib_node_t *node, *next_node;
17139 if (vec_len (vam->graph_nodes) == 0)
17141 print (vam->ofp, "Node table empty, issue get_node_graph...");
17145 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17147 node = vam->graph_nodes[i];
17148 print (vam->ofp, "[%d] %s", i, node->name);
17149 for (j = 0; j < vec_len (node->next_nodes); j++)
17151 if (node->next_nodes[j] != ~0)
17153 next_node = vam->graph_nodes[node->next_nodes[j]];
17154 print (vam->ofp, " [%d] %s", j, next_node->name);
17162 value_sort_cmp (void *a1, void *a2)
17164 name_sort_t *n1 = a1;
17165 name_sort_t *n2 = a2;
17167 if (n1->value < n2->value)
17169 if (n1->value > n2->value)
17176 dump_msg_api_table (vat_main_t * vam)
17178 api_main_t *am = &api_main;
17179 name_sort_t *nses = 0, *ns;
17184 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17186 vec_add2 (nses, ns, 1);
17187 ns->name = (u8 *)(hp->key);
17188 ns->value = (u32) hp->value[0];
17192 vec_sort_with_function (nses, value_sort_cmp);
17194 for (i = 0; i < vec_len (nses); i++)
17195 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17201 get_msg_id (vat_main_t * vam)
17206 if (unformat (vam->input, "%s", &name_and_crc))
17208 message_index = vl_api_get_msg_index (name_and_crc);
17209 if (message_index == ~0)
17211 print (vam->ofp, " '%s' not found", name_and_crc);
17214 print (vam->ofp, " '%s' has message index %d",
17215 name_and_crc, message_index);
17218 errmsg ("name_and_crc required...");
17223 search_node_table (vat_main_t * vam)
17225 unformat_input_t *line_input = vam->input;
17228 vlib_node_t *node, *next_node;
17231 if (vam->graph_node_index_by_name == 0)
17233 print (vam->ofp, "Node table empty, issue get_node_graph...");
17237 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17239 if (unformat (line_input, "%s", &node_to_find))
17241 vec_add1 (node_to_find, 0);
17242 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17245 print (vam->ofp, "%s not found...", node_to_find);
17248 node = vam->graph_nodes[p[0]];
17249 print (vam->ofp, "[%d] %s", p[0], node->name);
17250 for (j = 0; j < vec_len (node->next_nodes); j++)
17252 if (node->next_nodes[j] != ~0)
17254 next_node = vam->graph_nodes[node->next_nodes[j]];
17255 print (vam->ofp, " [%d] %s", j, next_node->name);
17262 clib_warning ("parse error '%U'", format_unformat_error,
17268 vec_free (node_to_find);
17277 script (vat_main_t * vam)
17279 #if (VPP_API_TEST_BUILTIN==0)
17281 char *save_current_file;
17282 unformat_input_t save_input;
17283 jmp_buf save_jump_buf;
17284 u32 save_line_number;
17286 FILE *new_fp, *save_ifp;
17288 if (unformat (vam->input, "%s", &s))
17290 new_fp = fopen ((char *) s, "r");
17293 errmsg ("Couldn't open script file %s", s);
17300 errmsg ("Missing script name");
17304 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17305 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17306 save_ifp = vam->ifp;
17307 save_line_number = vam->input_line_number;
17308 save_current_file = (char *) vam->current_file;
17310 vam->input_line_number = 0;
17312 vam->current_file = s;
17315 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17316 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17317 vam->ifp = save_ifp;
17318 vam->input_line_number = save_line_number;
17319 vam->current_file = (u8 *) save_current_file;
17324 clib_warning ("use the exec command...");
17330 echo (vat_main_t * vam)
17332 print (vam->ofp, "%v", vam->input->buffer);
17336 /* List of API message constructors, CLI names map to api_xxx */
17337 #define foreach_vpe_api_msg \
17338 _(create_loopback,"[mac <mac-addr>]") \
17339 _(sw_interface_dump,"") \
17340 _(sw_interface_set_flags, \
17341 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17342 _(sw_interface_add_del_address, \
17343 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17344 _(sw_interface_set_table, \
17345 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17346 _(sw_interface_set_mpls_enable, \
17347 "<intfc> | sw_if_index [disable | dis]") \
17348 _(sw_interface_set_vpath, \
17349 "<intfc> | sw_if_index <id> enable | disable") \
17350 _(sw_interface_set_vxlan_bypass, \
17351 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17352 _(sw_interface_set_l2_xconnect, \
17353 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17354 "enable | disable") \
17355 _(sw_interface_set_l2_bridge, \
17356 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17357 "[shg <split-horizon-group>] [bvi]\n" \
17358 "enable | disable") \
17359 _(bridge_domain_add_del, \
17360 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17361 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17363 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17365 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17367 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17369 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17371 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17373 "<vpp-if-name> | sw_if_index <id>") \
17374 _(sw_interface_tap_dump, "") \
17375 _(ip_add_del_route, \
17376 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17377 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17378 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17379 "[multipath] [count <n>]") \
17380 _(mpls_route_add_del, \
17381 "<label> <eos> via <addr> [table-id <n>]\n" \
17382 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17383 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17384 "[multipath] [count <n>]") \
17385 _(mpls_ip_bind_unbind, \
17386 "<label> <addr/len>") \
17387 _(mpls_tunnel_add_del, \
17388 " via <addr> [table-id <n>]\n" \
17389 "sw_if_index <id>] [l2] [del]") \
17390 _(proxy_arp_add_del, \
17391 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17392 _(proxy_arp_intfc_enable_disable, \
17393 "<intfc> | sw_if_index <id> enable | disable") \
17394 _(sw_interface_set_unnumbered, \
17395 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17396 _(ip_neighbor_add_del, \
17397 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17398 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17399 _(reset_vrf, "vrf <id> [ipv6]") \
17400 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17401 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17402 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17403 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17404 "[outer_vlan_id_any][inner_vlan_id_any]") \
17405 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17406 _(reset_fib, "vrf <n> [ipv6]") \
17407 _(dhcp_proxy_config, \
17408 "svr <v46-address> src <v46-address>\n" \
17409 "insert-cid <n> [del]") \
17410 _(dhcp_proxy_config_2, \
17411 "svr <v46-address> src <v46-address>\n" \
17412 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17413 _(dhcp_proxy_set_vss, \
17414 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17415 _(dhcp_client_config, \
17416 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17417 _(set_ip_flow_hash, \
17418 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17419 _(sw_interface_ip6_enable_disable, \
17420 "<intfc> | sw_if_index <id> enable | disable") \
17421 _(sw_interface_ip6_set_link_local_address, \
17422 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17423 _(sw_interface_ip6nd_ra_prefix, \
17424 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17425 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17426 "[nolink] [isno]") \
17427 _(sw_interface_ip6nd_ra_config, \
17428 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17429 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17430 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17431 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17432 _(l2_patch_add_del, \
17433 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17434 "enable | disable") \
17435 _(sr_tunnel_add_del, \
17436 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17437 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17438 "[policy <policy_name>]") \
17439 _(sr_policy_add_del, \
17440 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17441 _(sr_multicast_map_add_del, \
17442 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17443 _(classify_add_del_table, \
17444 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17445 " [del] [del-chain] mask <mask-value>\n" \
17446 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17447 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17448 _(classify_add_del_session, \
17449 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17450 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17451 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17452 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17453 _(classify_set_interface_ip_table, \
17454 "<intfc> | sw_if_index <nn> table <nn>") \
17455 _(classify_set_interface_l2_tables, \
17456 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17457 " [other-table <nn>]") \
17458 _(get_node_index, "node <node-name") \
17459 _(add_node_next, "node <node-name> next <next-node-name>") \
17460 _(l2tpv3_create_tunnel, \
17461 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17462 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17463 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17464 _(l2tpv3_set_tunnel_cookies, \
17465 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17466 "[new_remote_cookie <nn>]\n") \
17467 _(l2tpv3_interface_enable_disable, \
17468 "<intfc> | sw_if_index <nn> enable | disable") \
17469 _(l2tpv3_set_lookup_key, \
17470 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17471 _(sw_if_l2tpv3_tunnel_dump, "") \
17472 _(vxlan_add_del_tunnel, \
17473 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17474 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17475 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17476 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17477 _(gre_add_del_tunnel, \
17478 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17479 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17480 _(l2_fib_clear_table, "") \
17481 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17482 _(l2_interface_vlan_tag_rewrite, \
17483 "<intfc> | sw_if_index <nn> \n" \
17484 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17485 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17486 _(create_vhost_user_if, \
17487 "socket <filename> [server] [renumber <dev_instance>] " \
17488 "[mac <mac_address>]") \
17489 _(modify_vhost_user_if, \
17490 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17491 "[server] [renumber <dev_instance>]") \
17492 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17493 _(sw_interface_vhost_user_dump, "") \
17494 _(show_version, "") \
17495 _(vxlan_gpe_add_del_tunnel, \
17496 "local <addr> remote <addr> vni <nn>\n" \
17497 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17498 "[next-ethernet] [next-nsh]\n") \
17499 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17500 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17501 _(interface_name_renumber, \
17502 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17503 _(input_acl_set_interface, \
17504 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17505 " [l2-table <nn>] [del]") \
17506 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17507 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17508 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17509 _(ip_dump, "ipv4 | ipv6") \
17510 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17511 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17513 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17514 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17515 " integ_alg <alg> integ_key <hex>") \
17516 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17517 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17518 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17519 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17520 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17521 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17522 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17523 "(auth_data 0x<data> | auth_data <data>)") \
17524 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17525 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17526 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17527 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17528 "(local|remote)") \
17529 _(ikev2_set_local_key, "file <absolute_file_path>") \
17530 _(delete_loopback,"sw_if_index <nn>") \
17531 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17532 _(map_add_domain, \
17533 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17534 "ip6-src <ip6addr> " \
17535 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17536 _(map_del_domain, "index <n>") \
17537 _(map_add_del_rule, \
17538 "index <n> psid <n> dst <ip6addr> [del]") \
17539 _(map_domain_dump, "") \
17540 _(map_rule_dump, "index <map-domain>") \
17541 _(want_interface_events, "enable|disable") \
17542 _(want_stats,"enable|disable") \
17543 _(get_first_msg_id, "client <name>") \
17544 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17545 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17546 "fib-id <nn> [ip4][ip6][default]") \
17547 _(get_node_graph, " ") \
17548 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17549 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17550 _(ioam_disable, "") \
17551 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17552 " sw_if_index <sw_if_index> p <priority> " \
17553 "w <weight>] [del]") \
17554 _(lisp_add_del_locator, "locator-set <locator_name> " \
17555 "iface <intf> | sw_if_index <sw_if_index> " \
17556 "p <priority> w <weight> [del]") \
17557 _(lisp_add_del_local_eid,"vni <vni> eid " \
17558 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17559 "locator-set <locator_name> [del]" \
17560 "[key-id sha1|sha256 secret-key <secret-key>]") \
17561 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
17562 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
17563 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17564 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17565 _(lisp_gpe_enable_disable, "enable|disable") \
17566 _(lisp_enable_disable, "enable|disable") \
17567 _(lisp_map_register_enable_disable, "enable|disable") \
17568 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17569 _(lisp_gpe_add_del_iface, "up|down") \
17570 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17572 "rloc <locator> p <prio> " \
17573 "w <weight> [rloc <loc> ... ] " \
17574 "action <action> [del-all]") \
17575 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17577 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17578 _(lisp_map_request_mode, "src-dst|dst-only") \
17579 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17580 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17581 _(lisp_locator_set_dump, "[local | remote]") \
17582 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17583 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17584 "[local] | [remote]") \
17585 _(lisp_eid_table_vni_dump, "") \
17586 _(lisp_eid_table_map_dump, "l2|l3") \
17587 _(lisp_map_resolver_dump, "") \
17588 _(lisp_map_server_dump, "") \
17589 _(lisp_adjacencies_get, "vni <vni>") \
17590 _(show_lisp_rloc_probe_state, "") \
17591 _(show_lisp_map_register_state, "") \
17592 _(show_lisp_status, "") \
17593 _(lisp_get_map_request_itr_rlocs, "") \
17594 _(show_lisp_pitr, "") \
17595 _(show_lisp_map_request_mode, "") \
17596 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17597 _(af_packet_delete, "name <host interface name>") \
17598 _(policer_add_del, "name <policer name> <params> [del]") \
17599 _(policer_dump, "[name <policer name>]") \
17600 _(policer_classify_set_interface, \
17601 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17602 " [l2-table <nn>] [del]") \
17603 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17604 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17605 "[master|slave]") \
17606 _(netmap_delete, "name <interface name>") \
17607 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17608 _(mpls_fib_dump, "") \
17609 _(classify_table_ids, "") \
17610 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17611 _(classify_table_info, "table_id <nn>") \
17612 _(classify_session_dump, "table_id <nn>") \
17613 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17614 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17615 "[template_interval <nn>] [udp_checksum]") \
17616 _(ipfix_exporter_dump, "") \
17617 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17618 _(ipfix_classify_stream_dump, "") \
17619 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17620 _(ipfix_classify_table_dump, "") \
17621 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17622 _(sw_interface_span_dump, "") \
17623 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17624 _(pg_create_interface, "if_id <nn>") \
17625 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17626 _(pg_enable_disable, "[stream <id>] disable") \
17627 _(ip_source_and_port_range_check_add_del, \
17628 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17629 _(ip_source_and_port_range_check_interface_add_del, \
17630 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17631 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17632 _(ipsec_gre_add_del_tunnel, \
17633 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17634 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17635 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17636 _(l2_interface_pbb_tag_rewrite, \
17637 "<intfc> | sw_if_index <nn> \n" \
17638 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17639 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17640 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17641 _(flow_classify_set_interface, \
17642 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17643 _(flow_classify_dump, "type [ip4|ip6]") \
17644 _(ip_fib_dump, "") \
17645 _(ip6_fib_dump, "") \
17646 _(feature_enable_disable, "arc_name <arc_name> " \
17647 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17648 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17650 _(l2_xconnect_dump, "") \
17651 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17652 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17653 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17656 #define foreach_vpe_dpdk_api_msg \
17657 _(sw_interface_set_dpdk_hqos_pipe, \
17658 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17659 "profile <profile-id>\n") \
17660 _(sw_interface_set_dpdk_hqos_subport, \
17661 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17662 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17663 _(sw_interface_set_dpdk_hqos_tctbl, \
17664 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
17667 /* List of command functions, CLI names map directly to functions */
17668 #define foreach_cli_function \
17669 _(comment, "usage: comment <ignore-rest-of-line>") \
17670 _(dump_interface_table, "usage: dump_interface_table") \
17671 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17672 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17673 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17674 _(dump_stats_table, "usage: dump_stats_table") \
17675 _(dump_macro_table, "usage: dump_macro_table ") \
17676 _(dump_node_table, "usage: dump_node_table") \
17677 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17678 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17679 _(echo, "usage: echo <message>") \
17680 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17681 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17682 _(help, "usage: help") \
17683 _(q, "usage: quit") \
17684 _(quit, "usage: quit") \
17685 _(search_node_table, "usage: search_node_table <name>...") \
17686 _(set, "usage: set <variable-name> <value>") \
17687 _(script, "usage: script <file-name>") \
17688 _(unset, "usage: unset <variable-name>")
17691 static void vl_api_##n##_t_handler_uni \
17692 (vl_api_##n##_t * mp) \
17694 vat_main_t * vam = &vat_main; \
17695 if (vam->json_output) { \
17696 vl_api_##n##_t_handler_json(mp); \
17698 vl_api_##n##_t_handler(mp); \
17701 foreach_vpe_api_reply_msg;
17706 static void vl_api_##n##_t_handler_uni \
17707 (vl_api_##n##_t * mp) \
17709 vat_main_t * vam = &vat_main; \
17710 if (vam->json_output) { \
17711 vl_api_##n##_t_handler_json(mp); \
17713 vl_api_##n##_t_handler(mp); \
17716 foreach_vpe_dpdk_api_reply_msg;
17721 vat_api_hookup (vat_main_t * vam)
17724 vl_msg_api_set_handlers(VL_API_##N, #n, \
17725 vl_api_##n##_t_handler_uni, \
17727 vl_api_##n##_t_endian, \
17728 vl_api_##n##_t_print, \
17729 sizeof(vl_api_##n##_t), 1);
17730 foreach_vpe_api_reply_msg;
17735 vl_msg_api_set_handlers(VL_API_##N, #n, \
17736 vl_api_##n##_t_handler_uni, \
17738 vl_api_##n##_t_endian, \
17739 vl_api_##n##_t_print, \
17740 sizeof(vl_api_##n##_t), 1);
17741 foreach_vpe_dpdk_api_reply_msg;
17745 #if (VPP_API_TEST_BUILTIN==0)
17746 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17749 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17751 vam->function_by_name = hash_create_string (0, sizeof (uword));
17753 vam->help_by_name = hash_create_string (0, sizeof (uword));
17755 /* API messages we can send */
17756 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17757 foreach_vpe_api_msg;
17760 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17761 foreach_vpe_dpdk_api_msg;
17766 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17767 foreach_vpe_api_msg;
17770 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17771 foreach_vpe_dpdk_api_msg;
17775 /* CLI functions */
17776 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17777 foreach_cli_function;
17781 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17782 foreach_cli_function;
17787 * fd.io coding-style-patch-verification: ON
17790 * eval: (c-set-style "gnu")