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>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
46 #include <vnet/map/map.h>
47 #include <vnet/cop/cop.h>
48 #include <vnet/ip/ip6_hop_by_hop.h>
49 #include <vnet/ip/ip_source_and_port_range_check.h>
50 #include <vnet/policer/xlate.h>
51 #include <vnet/span/span.h>
52 #include <vnet/policer/policer.h>
53 #include <vnet/policer/police.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp-api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp-api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp-api/vpe_all_api_h.h>
77 unformat_sw_if_index (unformat_input_t * input, va_list * args)
79 vat_main_t *vam = va_arg (*args, vat_main_t *);
80 u32 *result = va_arg (*args, u32 *);
84 if (!unformat (input, "%s", &if_name))
87 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
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)
117 unformat_ethernet_address (unformat_input_t * input, va_list * args)
119 u8 *result = va_arg (*args, u8 *);
122 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
123 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
127 for (i = 0; i < 6; i++)
128 if (a[i] >= (1 << 8))
131 for (i = 0; i < 6; i++)
137 /* Returns ethernet type as an int in host byte order. */
139 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
142 u16 *result = va_arg (*args, u16 *);
146 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
148 if (type >= (1 << 16))
156 /* Parse an IP6 address. */
158 unformat_ip6_address (unformat_input_t * input, va_list * args)
160 ip6_address_t *result = va_arg (*args, ip6_address_t *);
162 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
163 uword c, n_colon, double_colon_index;
165 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
166 double_colon_index = ARRAY_LEN (hex_quads);
167 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
170 if (c >= '0' && c <= '9')
172 else if (c >= 'a' && c <= 'f')
173 hex_digit = c + 10 - 'a';
174 else if (c >= 'A' && c <= 'F')
175 hex_digit = c + 10 - 'A';
176 else if (c == ':' && n_colon < 2)
180 unformat_put_input (input);
184 /* Too many hex quads. */
185 if (n_hex_quads >= ARRAY_LEN (hex_quads))
190 hex_quad = (hex_quad << 4) | hex_digit;
192 /* Hex quad must fit in 16 bits. */
193 if (n_hex_digits >= 4)
200 /* Save position of :: */
203 /* More than one :: ? */
204 if (double_colon_index < ARRAY_LEN (hex_quads))
206 double_colon_index = n_hex_quads;
209 if (n_colon > 0 && n_hex_digits > 0)
211 hex_quads[n_hex_quads++] = hex_quad;
217 if (n_hex_digits > 0)
218 hex_quads[n_hex_quads++] = hex_quad;
223 /* Expand :: to appropriate number of zero hex quads. */
224 if (double_colon_index < ARRAY_LEN (hex_quads))
226 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
228 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
229 hex_quads[n_zero + i] = hex_quads[i];
231 for (i = 0; i < n_zero; i++)
232 hex_quads[double_colon_index + i] = 0;
234 n_hex_quads = ARRAY_LEN (hex_quads);
237 /* Too few hex quads given. */
238 if (n_hex_quads < ARRAY_LEN (hex_quads))
241 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
242 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
249 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
252 u32 *r = va_arg (*args, u32 *);
255 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
256 foreach_ipsec_policy_action
267 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
270 u32 *r = va_arg (*args, u32 *);
273 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
274 foreach_ipsec_crypto_alg
285 format_ipsec_crypto_alg (u8 * s, va_list * args)
288 u32 i = va_arg (*args, u32);
293 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
294 foreach_ipsec_crypto_alg
297 return format (s, "unknown");
299 return format (s, "%s", t);
301 return format (s, "Unimplemented");
306 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
309 u32 *r = va_arg (*args, u32 *);
312 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
313 foreach_ipsec_integ_alg
324 format_ipsec_integ_alg (u8 * s, va_list * args)
327 u32 i = va_arg (*args, u32);
332 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
333 foreach_ipsec_integ_alg
336 return format (s, "unknown");
338 return format (s, "%s", t);
340 return format (s, "Unsupported");
345 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
348 u32 *r = va_arg (*args, u32 *);
351 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
352 foreach_ikev2_auth_method
363 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
370 foreach_ikev2_id_type
381 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
383 u8 *r = va_arg (*args, u8 *);
385 if (unformat (input, "kbps"))
386 *r = SSE2_QOS_RATE_KBPS;
387 else if (unformat (input, "pps"))
388 *r = SSE2_QOS_RATE_PPS;
395 unformat_policer_round_type (unformat_input_t * input, va_list * args)
397 u8 *r = va_arg (*args, u8 *);
399 if (unformat (input, "closest"))
400 *r = SSE2_QOS_ROUND_TO_CLOSEST;
401 else if (unformat (input, "up"))
402 *r = SSE2_QOS_ROUND_TO_UP;
403 else if (unformat (input, "down"))
404 *r = SSE2_QOS_ROUND_TO_DOWN;
411 unformat_policer_type (unformat_input_t * input, va_list * args)
413 u8 *r = va_arg (*args, u8 *);
415 if (unformat (input, "1r2c"))
416 *r = SSE2_QOS_POLICER_TYPE_1R2C;
417 else if (unformat (input, "1r3c"))
418 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
419 else if (unformat (input, "2r3c-2698"))
420 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
421 else if (unformat (input, "2r3c-4115"))
422 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
423 else if (unformat (input, "2r3c-mef5cf1"))
424 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
431 unformat_dscp (unformat_input_t * input, va_list * va)
433 u8 *r = va_arg (*va, u8 *);
436 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
445 unformat_policer_action_type (unformat_input_t * input, va_list * va)
447 sse2_qos_pol_action_params_st *a
448 = va_arg (*va, sse2_qos_pol_action_params_st *);
450 if (unformat (input, "drop"))
451 a->action_type = SSE2_QOS_ACTION_DROP;
452 else if (unformat (input, "transmit"))
453 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
454 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
455 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
462 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
464 u32 *r = va_arg (*va, u32 *);
467 if (unformat (input, "ip4"))
468 tid = POLICER_CLASSIFY_TABLE_IP4;
469 else if (unformat (input, "ip6"))
470 tid = POLICER_CLASSIFY_TABLE_IP6;
471 else if (unformat (input, "l2"))
472 tid = POLICER_CLASSIFY_TABLE_L2;
481 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
483 u32 *r = va_arg (*va, u32 *);
486 if (unformat (input, "ip4"))
487 tid = FLOW_CLASSIFY_TABLE_IP4;
488 else if (unformat (input, "ip6"))
489 tid = FLOW_CLASSIFY_TABLE_IP6;
498 format_ip4_address (u8 * s, va_list * args)
500 u8 *a = va_arg (*args, u8 *);
501 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
505 format_ip6_address (u8 * s, va_list * args)
507 ip6_address_t *a = va_arg (*args, ip6_address_t *);
508 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
510 i_max_n_zero = ARRAY_LEN (a->as_u16);
512 i_first_zero = i_max_n_zero;
514 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
516 u32 is_zero = a->as_u16[i] == 0;
517 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
523 if ((!is_zero && n_zeros > max_n_zeros)
524 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
526 i_max_n_zero = i_first_zero;
527 max_n_zeros = n_zeros;
528 i_first_zero = ARRAY_LEN (a->as_u16);
533 last_double_colon = 0;
534 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
536 if (i == i_max_n_zero && max_n_zeros > 1)
538 s = format (s, "::");
539 i += max_n_zeros - 1;
540 last_double_colon = 1;
544 s = format (s, "%s%x",
545 (last_double_colon || i == 0) ? "" : ":",
546 clib_net_to_host_u16 (a->as_u16[i]));
547 last_double_colon = 0;
554 /* Format an IP46 address. */
556 format_ip46_address (u8 * s, va_list * args)
558 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
559 ip46_type_t type = va_arg (*args, ip46_type_t);
565 is_ip4 = ip46_address_is_ip4 (ip46);
576 format (s, "%U", format_ip4_address, &ip46->ip4) :
577 format (s, "%U", format_ip6_address, &ip46->ip6);
581 format_ethernet_address (u8 * s, va_list * args)
583 u8 *a = va_arg (*args, u8 *);
585 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
586 a[0], a[1], a[2], a[3], a[4], a[5]);
590 increment_v4_address (ip4_address_t * a)
594 v = ntohl (a->as_u32) + 1;
595 a->as_u32 = ntohl (v);
599 increment_v6_address (ip6_address_t * a)
603 v0 = clib_net_to_host_u64 (a->as_u64[0]);
604 v1 = clib_net_to_host_u64 (a->as_u64[1]);
609 a->as_u64[0] = clib_net_to_host_u64 (v0);
610 a->as_u64[1] = clib_net_to_host_u64 (v1);
614 increment_mac_address (u64 * mac)
618 tmp = clib_net_to_host_u64 (tmp);
619 tmp += 1 << 16; /* skip unused (least significant) octets */
620 tmp = clib_host_to_net_u64 (tmp);
624 static void vl_api_create_loopback_reply_t_handler
625 (vl_api_create_loopback_reply_t * mp)
627 vat_main_t *vam = &vat_main;
628 i32 retval = ntohl (mp->retval);
630 vam->retval = retval;
631 vam->regenerate_interface_table = 1;
632 vam->sw_if_index = ntohl (mp->sw_if_index);
633 vam->result_ready = 1;
636 static void vl_api_create_loopback_reply_t_handler_json
637 (vl_api_create_loopback_reply_t * mp)
639 vat_main_t *vam = &vat_main;
640 vat_json_node_t node;
642 vat_json_init_object (&node);
643 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
644 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
646 vat_json_print (vam->ofp, &node);
647 vat_json_free (&node);
648 vam->retval = ntohl (mp->retval);
649 vam->result_ready = 1;
652 static void vl_api_af_packet_create_reply_t_handler
653 (vl_api_af_packet_create_reply_t * mp)
655 vat_main_t *vam = &vat_main;
656 i32 retval = ntohl (mp->retval);
658 vam->retval = retval;
659 vam->regenerate_interface_table = 1;
660 vam->sw_if_index = ntohl (mp->sw_if_index);
661 vam->result_ready = 1;
664 static void vl_api_af_packet_create_reply_t_handler_json
665 (vl_api_af_packet_create_reply_t * mp)
667 vat_main_t *vam = &vat_main;
668 vat_json_node_t node;
670 vat_json_init_object (&node);
671 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
672 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
674 vat_json_print (vam->ofp, &node);
675 vat_json_free (&node);
677 vam->retval = ntohl (mp->retval);
678 vam->result_ready = 1;
681 static void vl_api_create_vlan_subif_reply_t_handler
682 (vl_api_create_vlan_subif_reply_t * mp)
684 vat_main_t *vam = &vat_main;
685 i32 retval = ntohl (mp->retval);
687 vam->retval = retval;
688 vam->regenerate_interface_table = 1;
689 vam->sw_if_index = ntohl (mp->sw_if_index);
690 vam->result_ready = 1;
693 static void vl_api_create_vlan_subif_reply_t_handler_json
694 (vl_api_create_vlan_subif_reply_t * mp)
696 vat_main_t *vam = &vat_main;
697 vat_json_node_t node;
699 vat_json_init_object (&node);
700 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
701 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
703 vat_json_print (vam->ofp, &node);
704 vat_json_free (&node);
706 vam->retval = ntohl (mp->retval);
707 vam->result_ready = 1;
710 static void vl_api_create_subif_reply_t_handler
711 (vl_api_create_subif_reply_t * mp)
713 vat_main_t *vam = &vat_main;
714 i32 retval = ntohl (mp->retval);
716 vam->retval = retval;
717 vam->regenerate_interface_table = 1;
718 vam->sw_if_index = ntohl (mp->sw_if_index);
719 vam->result_ready = 1;
722 static void vl_api_create_subif_reply_t_handler_json
723 (vl_api_create_subif_reply_t * mp)
725 vat_main_t *vam = &vat_main;
726 vat_json_node_t node;
728 vat_json_init_object (&node);
729 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
730 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
732 vat_json_print (vam->ofp, &node);
733 vat_json_free (&node);
735 vam->retval = ntohl (mp->retval);
736 vam->result_ready = 1;
739 static void vl_api_interface_name_renumber_reply_t_handler
740 (vl_api_interface_name_renumber_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 i32 retval = ntohl (mp->retval);
745 vam->retval = retval;
746 vam->regenerate_interface_table = 1;
747 vam->result_ready = 1;
750 static void vl_api_interface_name_renumber_reply_t_handler_json
751 (vl_api_interface_name_renumber_reply_t * mp)
753 vat_main_t *vam = &vat_main;
754 vat_json_node_t node;
756 vat_json_init_object (&node);
757 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
759 vat_json_print (vam->ofp, &node);
760 vat_json_free (&node);
762 vam->retval = ntohl (mp->retval);
763 vam->result_ready = 1;
767 * Special-case: build the interface table, maintain
768 * the next loopback sw_if_index vbl.
770 static void vl_api_sw_interface_details_t_handler
771 (vl_api_sw_interface_details_t * mp)
773 vat_main_t *vam = &vat_main;
774 u8 *s = format (0, "%s%c", mp->interface_name, 0);
776 hash_set_mem (vam->sw_if_index_by_interface_name, s,
777 ntohl (mp->sw_if_index));
779 /* In sub interface case, fill the sub interface table entry */
780 if (mp->sw_if_index != mp->sup_sw_if_index)
782 sw_interface_subif_t *sub = NULL;
784 vec_add2 (vam->sw_if_subif_table, sub, 1);
786 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
787 strncpy ((char *) sub->interface_name, (char *) s,
788 vec_len (sub->interface_name));
789 sub->sw_if_index = ntohl (mp->sw_if_index);
790 sub->sub_id = ntohl (mp->sub_id);
792 sub->sub_dot1ad = mp->sub_dot1ad;
793 sub->sub_number_of_tags = mp->sub_number_of_tags;
794 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
795 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
796 sub->sub_exact_match = mp->sub_exact_match;
797 sub->sub_default = mp->sub_default;
798 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
799 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
801 /* vlan tag rewrite */
802 sub->vtr_op = ntohl (mp->vtr_op);
803 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
804 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
805 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
809 static void vl_api_sw_interface_details_t_handler_json
810 (vl_api_sw_interface_details_t * mp)
812 vat_main_t *vam = &vat_main;
813 vat_json_node_t *node = NULL;
815 if (VAT_JSON_ARRAY != vam->json_tree.type)
817 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
818 vat_json_init_array (&vam->json_tree);
820 node = vat_json_array_add (&vam->json_tree);
822 vat_json_init_object (node);
823 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
824 vat_json_object_add_uint (node, "sup_sw_if_index",
825 ntohl (mp->sup_sw_if_index));
826 vat_json_object_add_uint (node, "l2_address_length",
827 ntohl (mp->l2_address_length));
828 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
829 sizeof (mp->l2_address));
830 vat_json_object_add_string_copy (node, "interface_name",
832 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
833 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
834 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
835 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
836 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
837 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
838 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
839 vat_json_object_add_uint (node, "sub_number_of_tags",
840 mp->sub_number_of_tags);
841 vat_json_object_add_uint (node, "sub_outer_vlan_id",
842 ntohs (mp->sub_outer_vlan_id));
843 vat_json_object_add_uint (node, "sub_inner_vlan_id",
844 ntohs (mp->sub_inner_vlan_id));
845 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
846 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
847 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
848 mp->sub_outer_vlan_id_any);
849 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
850 mp->sub_inner_vlan_id_any);
851 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
852 vat_json_object_add_uint (node, "vtr_push_dot1q",
853 ntohl (mp->vtr_push_dot1q));
854 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
855 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
858 static void vl_api_sw_interface_set_flags_t_handler
859 (vl_api_sw_interface_set_flags_t * mp)
861 vat_main_t *vam = &vat_main;
862 if (vam->interface_event_display)
863 errmsg ("interface flags: sw_if_index %d %s %s\n",
864 ntohl (mp->sw_if_index),
865 mp->admin_up_down ? "admin-up" : "admin-down",
866 mp->link_up_down ? "link-up" : "link-down");
869 static void vl_api_sw_interface_set_flags_t_handler_json
870 (vl_api_sw_interface_set_flags_t * mp)
872 /* JSON output not supported */
876 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
878 vat_main_t *vam = &vat_main;
879 i32 retval = ntohl (mp->retval);
881 vam->retval = retval;
882 vam->shmem_result = (u8 *) mp->reply_in_shmem;
883 vam->result_ready = 1;
887 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
889 vat_main_t *vam = &vat_main;
890 vat_json_node_t node;
891 api_main_t *am = &api_main;
895 vat_json_init_object (&node);
896 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
897 vat_json_object_add_uint (&node, "reply_in_shmem",
898 ntohl (mp->reply_in_shmem));
899 /* Toss the shared-memory original... */
900 pthread_mutex_lock (&am->vlib_rp->mutex);
901 oldheap = svm_push_data_heap (am->vlib_rp);
903 reply = (u8 *) (mp->reply_in_shmem);
906 svm_pop_heap (oldheap);
907 pthread_mutex_unlock (&am->vlib_rp->mutex);
909 vat_json_print (vam->ofp, &node);
910 vat_json_free (&node);
912 vam->retval = ntohl (mp->retval);
913 vam->result_ready = 1;
917 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
919 vat_main_t *vam = &vat_main;
920 i32 retval = ntohl (mp->retval);
922 vam->retval = retval;
923 vam->cmd_reply = mp->reply;
924 vam->result_ready = 1;
928 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
930 vat_main_t *vam = &vat_main;
931 vat_json_node_t node;
933 vat_json_init_object (&node);
934 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
935 vat_json_object_add_string_copy (&node, "reply", mp->reply);
937 vat_json_print (vam->ofp, &node);
938 vat_json_free (&node);
940 vam->retval = ntohl (mp->retval);
941 vam->result_ready = 1;
944 static void vl_api_classify_add_del_table_reply_t_handler
945 (vl_api_classify_add_del_table_reply_t * mp)
947 vat_main_t *vam = &vat_main;
948 i32 retval = ntohl (mp->retval);
951 vam->async_errors += (retval < 0);
955 vam->retval = retval;
957 ((mp->new_table_index != 0xFFFFFFFF) ||
958 (mp->skip_n_vectors != 0xFFFFFFFF) ||
959 (mp->match_n_vectors != 0xFFFFFFFF)))
961 * Note: this is just barely thread-safe, depends on
962 * the main thread spinning waiting for an answer...
964 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
965 ntohl (mp->new_table_index),
966 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
967 vam->result_ready = 1;
971 static void vl_api_classify_add_del_table_reply_t_handler_json
972 (vl_api_classify_add_del_table_reply_t * mp)
974 vat_main_t *vam = &vat_main;
975 vat_json_node_t node;
977 vat_json_init_object (&node);
978 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
979 vat_json_object_add_uint (&node, "new_table_index",
980 ntohl (mp->new_table_index));
981 vat_json_object_add_uint (&node, "skip_n_vectors",
982 ntohl (mp->skip_n_vectors));
983 vat_json_object_add_uint (&node, "match_n_vectors",
984 ntohl (mp->match_n_vectors));
986 vat_json_print (vam->ofp, &node);
987 vat_json_free (&node);
989 vam->retval = ntohl (mp->retval);
990 vam->result_ready = 1;
993 static void vl_api_get_node_index_reply_t_handler
994 (vl_api_get_node_index_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
1000 vam->async_errors += (retval < 0);
1004 vam->retval = retval;
1006 errmsg ("node index %d\n", ntohl (mp->node_index));
1007 vam->result_ready = 1;
1011 static void vl_api_get_node_index_reply_t_handler_json
1012 (vl_api_get_node_index_reply_t * mp)
1014 vat_main_t *vam = &vat_main;
1015 vat_json_node_t node;
1017 vat_json_init_object (&node);
1018 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1019 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1021 vat_json_print (vam->ofp, &node);
1022 vat_json_free (&node);
1024 vam->retval = ntohl (mp->retval);
1025 vam->result_ready = 1;
1028 static void vl_api_get_next_index_reply_t_handler
1029 (vl_api_get_next_index_reply_t * mp)
1031 vat_main_t *vam = &vat_main;
1032 i32 retval = ntohl (mp->retval);
1033 if (vam->async_mode)
1035 vam->async_errors += (retval < 0);
1039 vam->retval = retval;
1041 errmsg ("next node index %d\n", ntohl (mp->next_index));
1042 vam->result_ready = 1;
1046 static void vl_api_get_next_index_reply_t_handler_json
1047 (vl_api_get_next_index_reply_t * mp)
1049 vat_main_t *vam = &vat_main;
1050 vat_json_node_t node;
1052 vat_json_init_object (&node);
1053 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1054 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1056 vat_json_print (vam->ofp, &node);
1057 vat_json_free (&node);
1059 vam->retval = ntohl (mp->retval);
1060 vam->result_ready = 1;
1063 static void vl_api_add_node_next_reply_t_handler
1064 (vl_api_add_node_next_reply_t * mp)
1066 vat_main_t *vam = &vat_main;
1067 i32 retval = ntohl (mp->retval);
1068 if (vam->async_mode)
1070 vam->async_errors += (retval < 0);
1074 vam->retval = retval;
1076 errmsg ("next index %d\n", ntohl (mp->next_index));
1077 vam->result_ready = 1;
1081 static void vl_api_add_node_next_reply_t_handler_json
1082 (vl_api_add_node_next_reply_t * mp)
1084 vat_main_t *vam = &vat_main;
1085 vat_json_node_t node;
1087 vat_json_init_object (&node);
1088 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1089 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1091 vat_json_print (vam->ofp, &node);
1092 vat_json_free (&node);
1094 vam->retval = ntohl (mp->retval);
1095 vam->result_ready = 1;
1098 static void vl_api_show_version_reply_t_handler
1099 (vl_api_show_version_reply_t * mp)
1101 vat_main_t *vam = &vat_main;
1102 i32 retval = ntohl (mp->retval);
1106 errmsg (" program: %s\n", mp->program);
1107 errmsg (" version: %s\n", mp->version);
1108 errmsg (" build date: %s\n", mp->build_date);
1109 errmsg ("build directory: %s\n", mp->build_directory);
1111 vam->retval = retval;
1112 vam->result_ready = 1;
1115 static void vl_api_show_version_reply_t_handler_json
1116 (vl_api_show_version_reply_t * mp)
1118 vat_main_t *vam = &vat_main;
1119 vat_json_node_t node;
1121 vat_json_init_object (&node);
1122 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1123 vat_json_object_add_string_copy (&node, "program", mp->program);
1124 vat_json_object_add_string_copy (&node, "version", mp->version);
1125 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1126 vat_json_object_add_string_copy (&node, "build_directory",
1127 mp->build_directory);
1129 vat_json_print (vam->ofp, &node);
1130 vat_json_free (&node);
1132 vam->retval = ntohl (mp->retval);
1133 vam->result_ready = 1;
1137 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1139 vat_main_t *vam = &vat_main;
1140 errmsg ("arp %s event: address %U new mac %U sw_if_index %d\n",
1141 mp->mac_ip ? "mac/ip binding" : "address resolution",
1142 format_ip4_address, &mp->address,
1143 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1147 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1149 /* JSON output not supported */
1153 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1155 vat_main_t *vam = &vat_main;
1156 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d\n",
1157 mp->mac_ip ? "mac/ip binding" : "address resolution",
1158 format_ip6_address, mp->address,
1159 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1163 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1165 /* JSON output not supported */
1169 * Special-case: build the bridge domain table, maintain
1170 * the next bd id vbl.
1172 static void vl_api_bridge_domain_details_t_handler
1173 (vl_api_bridge_domain_details_t * mp)
1175 vat_main_t *vam = &vat_main;
1176 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1178 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1179 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1181 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1182 ntohl (mp->bd_id), mp->learn, mp->forward,
1183 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1186 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1190 static void vl_api_bridge_domain_details_t_handler_json
1191 (vl_api_bridge_domain_details_t * mp)
1193 vat_main_t *vam = &vat_main;
1194 vat_json_node_t *node, *array = NULL;
1196 if (VAT_JSON_ARRAY != vam->json_tree.type)
1198 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1199 vat_json_init_array (&vam->json_tree);
1201 node = vat_json_array_add (&vam->json_tree);
1203 vat_json_init_object (node);
1204 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1205 vat_json_object_add_uint (node, "flood", mp->flood);
1206 vat_json_object_add_uint (node, "forward", mp->forward);
1207 vat_json_object_add_uint (node, "learn", mp->learn);
1208 vat_json_object_add_uint (node, "bvi_sw_if_index",
1209 ntohl (mp->bvi_sw_if_index));
1210 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1211 array = vat_json_object_add (node, "sw_if");
1212 vat_json_init_array (array);
1216 * Special-case: build the bridge domain sw if table.
1218 static void vl_api_bridge_domain_sw_if_details_t_handler
1219 (vl_api_bridge_domain_sw_if_details_t * mp)
1221 vat_main_t *vam = &vat_main;
1226 sw_if_index = ntohl (mp->sw_if_index);
1228 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1230 if ((u32) p->value[0] == sw_if_index)
1232 sw_if_name = (u8 *)(p->key);
1238 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1239 mp->shg, sw_if_name ? (char *) sw_if_name :
1240 "sw_if_index not found!");
1243 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1244 (vl_api_bridge_domain_sw_if_details_t * mp)
1246 vat_main_t *vam = &vat_main;
1247 vat_json_node_t *node = NULL;
1248 uword last_index = 0;
1250 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1251 ASSERT (vec_len (vam->json_tree.array) >= 1);
1252 last_index = vec_len (vam->json_tree.array) - 1;
1253 node = &vam->json_tree.array[last_index];
1254 node = vat_json_object_get_element (node, "sw_if");
1255 ASSERT (NULL != node);
1256 node = vat_json_array_add (node);
1258 vat_json_init_object (node);
1259 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1260 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1261 vat_json_object_add_uint (node, "shg", mp->shg);
1264 static void vl_api_control_ping_reply_t_handler
1265 (vl_api_control_ping_reply_t * mp)
1267 vat_main_t *vam = &vat_main;
1268 i32 retval = ntohl (mp->retval);
1269 if (vam->async_mode)
1271 vam->async_errors += (retval < 0);
1275 vam->retval = retval;
1276 vam->result_ready = 1;
1280 static void vl_api_control_ping_reply_t_handler_json
1281 (vl_api_control_ping_reply_t * mp)
1283 vat_main_t *vam = &vat_main;
1284 i32 retval = ntohl (mp->retval);
1286 if (VAT_JSON_NONE != vam->json_tree.type)
1288 vat_json_print (vam->ofp, &vam->json_tree);
1289 vat_json_free (&vam->json_tree);
1290 vam->json_tree.type = VAT_JSON_NONE;
1295 vat_json_init_array (&vam->json_tree);
1296 vat_json_print (vam->ofp, &vam->json_tree);
1297 vam->json_tree.type = VAT_JSON_NONE;
1300 vam->retval = retval;
1301 vam->result_ready = 1;
1305 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1307 vat_main_t *vam = &vat_main;
1308 i32 retval = ntohl (mp->retval);
1309 if (vam->async_mode)
1311 vam->async_errors += (retval < 0);
1315 vam->retval = retval;
1316 vam->result_ready = 1;
1320 static void vl_api_l2_flags_reply_t_handler_json
1321 (vl_api_l2_flags_reply_t * mp)
1323 vat_main_t *vam = &vat_main;
1324 vat_json_node_t node;
1326 vat_json_init_object (&node);
1327 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1328 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1329 ntohl (mp->resulting_feature_bitmap));
1331 vat_json_print (vam->ofp, &node);
1332 vat_json_free (&node);
1334 vam->retval = ntohl (mp->retval);
1335 vam->result_ready = 1;
1338 static void vl_api_bridge_flags_reply_t_handler
1339 (vl_api_bridge_flags_reply_t * mp)
1341 vat_main_t *vam = &vat_main;
1342 i32 retval = ntohl (mp->retval);
1343 if (vam->async_mode)
1345 vam->async_errors += (retval < 0);
1349 vam->retval = retval;
1350 vam->result_ready = 1;
1354 static void vl_api_bridge_flags_reply_t_handler_json
1355 (vl_api_bridge_flags_reply_t * mp)
1357 vat_main_t *vam = &vat_main;
1358 vat_json_node_t node;
1360 vat_json_init_object (&node);
1361 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1362 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1363 ntohl (mp->resulting_feature_bitmap));
1365 vat_json_print (vam->ofp, &node);
1366 vat_json_free (&node);
1368 vam->retval = ntohl (mp->retval);
1369 vam->result_ready = 1;
1372 static void vl_api_tap_connect_reply_t_handler
1373 (vl_api_tap_connect_reply_t * mp)
1375 vat_main_t *vam = &vat_main;
1376 i32 retval = ntohl (mp->retval);
1377 if (vam->async_mode)
1379 vam->async_errors += (retval < 0);
1383 vam->retval = retval;
1384 vam->sw_if_index = ntohl (mp->sw_if_index);
1385 vam->result_ready = 1;
1390 static void vl_api_tap_connect_reply_t_handler_json
1391 (vl_api_tap_connect_reply_t * mp)
1393 vat_main_t *vam = &vat_main;
1394 vat_json_node_t node;
1396 vat_json_init_object (&node);
1397 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1398 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1400 vat_json_print (vam->ofp, &node);
1401 vat_json_free (&node);
1403 vam->retval = ntohl (mp->retval);
1404 vam->result_ready = 1;
1409 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1411 vat_main_t *vam = &vat_main;
1412 i32 retval = ntohl (mp->retval);
1413 if (vam->async_mode)
1415 vam->async_errors += (retval < 0);
1419 vam->retval = retval;
1420 vam->sw_if_index = ntohl (mp->sw_if_index);
1421 vam->result_ready = 1;
1425 static void vl_api_tap_modify_reply_t_handler_json
1426 (vl_api_tap_modify_reply_t * mp)
1428 vat_main_t *vam = &vat_main;
1429 vat_json_node_t node;
1431 vat_json_init_object (&node);
1432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1433 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1435 vat_json_print (vam->ofp, &node);
1436 vat_json_free (&node);
1438 vam->retval = ntohl (mp->retval);
1439 vam->result_ready = 1;
1443 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1445 vat_main_t *vam = &vat_main;
1446 i32 retval = ntohl (mp->retval);
1447 if (vam->async_mode)
1449 vam->async_errors += (retval < 0);
1453 vam->retval = retval;
1454 vam->result_ready = 1;
1458 static void vl_api_tap_delete_reply_t_handler_json
1459 (vl_api_tap_delete_reply_t * mp)
1461 vat_main_t *vam = &vat_main;
1462 vat_json_node_t node;
1464 vat_json_init_object (&node);
1465 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1467 vat_json_print (vam->ofp, &node);
1468 vat_json_free (&node);
1470 vam->retval = ntohl (mp->retval);
1471 vam->result_ready = 1;
1474 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler
1475 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1477 vat_main_t *vam = &vat_main;
1478 i32 retval = ntohl (mp->retval);
1479 if (vam->async_mode)
1481 vam->async_errors += (retval < 0);
1485 vam->retval = retval;
1486 vam->result_ready = 1;
1490 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler_json
1491 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1493 vat_main_t *vam = &vat_main;
1494 vat_json_node_t node;
1496 vat_json_init_object (&node);
1497 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1498 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1499 ntohl (mp->tunnel_sw_if_index));
1501 vat_json_print (vam->ofp, &node);
1502 vat_json_free (&node);
1504 vam->retval = ntohl (mp->retval);
1505 vam->result_ready = 1;
1508 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1509 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1511 vat_main_t *vam = &vat_main;
1512 i32 retval = ntohl (mp->retval);
1513 if (vam->async_mode)
1515 vam->async_errors += (retval < 0);
1519 vam->retval = retval;
1520 vam->sw_if_index = ntohl (mp->sw_if_index);
1521 vam->result_ready = 1;
1525 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1526 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 vat_json_node_t node;
1531 vat_json_init_object (&node);
1532 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1533 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1535 vat_json_print (vam->ofp, &node);
1536 vat_json_free (&node);
1538 vam->retval = ntohl (mp->retval);
1539 vam->result_ready = 1;
1543 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1544 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1546 vat_main_t *vam = &vat_main;
1547 i32 retval = ntohl (mp->retval);
1548 if (vam->async_mode)
1550 vam->async_errors += (retval < 0);
1554 vam->retval = retval;
1555 vam->result_ready = 1;
1559 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1560 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 vat_json_node_t node;
1565 vat_json_init_object (&node);
1566 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1567 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1569 vat_json_print (vam->ofp, &node);
1570 vat_json_free (&node);
1572 vam->retval = ntohl (mp->retval);
1573 vam->result_ready = 1;
1576 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1577 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 i32 retval = ntohl (mp->retval);
1581 if (vam->async_mode)
1583 vam->async_errors += (retval < 0);
1587 vam->retval = retval;
1588 vam->sw_if_index = ntohl (mp->sw_if_index);
1589 vam->result_ready = 1;
1593 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1594 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1596 vat_main_t *vam = &vat_main;
1597 vat_json_node_t node;
1599 vat_json_init_object (&node);
1600 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1601 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1603 vat_json_print (vam->ofp, &node);
1604 vat_json_free (&node);
1606 vam->retval = ntohl (mp->retval);
1607 vam->result_ready = 1;
1610 static void vl_api_gre_add_del_tunnel_reply_t_handler
1611 (vl_api_gre_add_del_tunnel_reply_t * mp)
1613 vat_main_t *vam = &vat_main;
1614 i32 retval = ntohl (mp->retval);
1615 if (vam->async_mode)
1617 vam->async_errors += (retval < 0);
1621 vam->retval = retval;
1622 vam->sw_if_index = ntohl (mp->sw_if_index);
1623 vam->result_ready = 1;
1627 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1628 (vl_api_gre_add_del_tunnel_reply_t * mp)
1630 vat_main_t *vam = &vat_main;
1631 vat_json_node_t node;
1633 vat_json_init_object (&node);
1634 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1635 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1637 vat_json_print (vam->ofp, &node);
1638 vat_json_free (&node);
1640 vam->retval = ntohl (mp->retval);
1641 vam->result_ready = 1;
1644 static void vl_api_create_vhost_user_if_reply_t_handler
1645 (vl_api_create_vhost_user_if_reply_t * mp)
1647 vat_main_t *vam = &vat_main;
1648 i32 retval = ntohl (mp->retval);
1649 if (vam->async_mode)
1651 vam->async_errors += (retval < 0);
1655 vam->retval = retval;
1656 vam->sw_if_index = ntohl (mp->sw_if_index);
1657 vam->result_ready = 1;
1661 static void vl_api_create_vhost_user_if_reply_t_handler_json
1662 (vl_api_create_vhost_user_if_reply_t * mp)
1664 vat_main_t *vam = &vat_main;
1665 vat_json_node_t node;
1667 vat_json_init_object (&node);
1668 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1669 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1671 vat_json_print (vam->ofp, &node);
1672 vat_json_free (&node);
1674 vam->retval = ntohl (mp->retval);
1675 vam->result_ready = 1;
1678 static void vl_api_ip_address_details_t_handler
1679 (vl_api_ip_address_details_t * mp)
1681 vat_main_t *vam = &vat_main;
1682 static ip_address_details_t empty_ip_address_details = { {0} };
1683 ip_address_details_t *address = NULL;
1684 ip_details_t *current_ip_details = NULL;
1685 ip_details_t *details = NULL;
1687 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1689 if (!details || vam->current_sw_if_index >= vec_len (details)
1690 || !details[vam->current_sw_if_index].present)
1692 errmsg ("ip address details arrived but not stored\n");
1693 errmsg ("ip_dump should be called first\n");
1697 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1699 #define addresses (current_ip_details->addr)
1701 vec_validate_init_empty (addresses, vec_len (addresses),
1702 empty_ip_address_details);
1704 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1706 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1707 address->prefix_length = mp->prefix_length;
1711 static void vl_api_ip_address_details_t_handler_json
1712 (vl_api_ip_address_details_t * mp)
1714 vat_main_t *vam = &vat_main;
1715 vat_json_node_t *node = NULL;
1716 struct in6_addr ip6;
1719 if (VAT_JSON_ARRAY != vam->json_tree.type)
1721 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1722 vat_json_init_array (&vam->json_tree);
1724 node = vat_json_array_add (&vam->json_tree);
1726 vat_json_init_object (node);
1729 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1730 vat_json_object_add_ip6 (node, "ip", ip6);
1734 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1735 vat_json_object_add_ip4 (node, "ip", ip4);
1737 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1741 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1743 vat_main_t *vam = &vat_main;
1744 static ip_details_t empty_ip_details = { 0 };
1745 ip_details_t *ip = NULL;
1746 u32 sw_if_index = ~0;
1748 sw_if_index = ntohl (mp->sw_if_index);
1750 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1751 sw_if_index, empty_ip_details);
1753 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1760 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1762 vat_main_t *vam = &vat_main;
1764 if (VAT_JSON_ARRAY != vam->json_tree.type)
1766 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1767 vat_json_init_array (&vam->json_tree);
1769 vat_json_array_add_uint (&vam->json_tree,
1770 clib_net_to_host_u32 (mp->sw_if_index));
1773 static void vl_api_map_domain_details_t_handler_json
1774 (vl_api_map_domain_details_t * mp)
1776 vat_json_node_t *node = NULL;
1777 vat_main_t *vam = &vat_main;
1778 struct in6_addr ip6;
1781 if (VAT_JSON_ARRAY != vam->json_tree.type)
1783 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1784 vat_json_init_array (&vam->json_tree);
1787 node = vat_json_array_add (&vam->json_tree);
1788 vat_json_init_object (node);
1790 vat_json_object_add_uint (node, "domain_index",
1791 clib_net_to_host_u32 (mp->domain_index));
1792 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1793 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1794 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1795 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1796 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1797 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1798 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1799 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1800 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1801 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1802 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1803 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1804 vat_json_object_add_uint (node, "flags", mp->flags);
1805 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1806 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1809 static void vl_api_map_domain_details_t_handler
1810 (vl_api_map_domain_details_t * mp)
1812 vat_main_t *vam = &vat_main;
1814 if (mp->is_translation)
1817 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1818 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1819 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1820 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1821 clib_net_to_host_u32 (mp->domain_index));
1826 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1827 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1828 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1829 format_ip6_address, mp->ip6_src,
1830 clib_net_to_host_u32 (mp->domain_index));
1832 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1833 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1834 mp->is_translation ? "map-t" : "");
1837 static void vl_api_map_rule_details_t_handler_json
1838 (vl_api_map_rule_details_t * mp)
1840 struct in6_addr ip6;
1841 vat_json_node_t *node = NULL;
1842 vat_main_t *vam = &vat_main;
1844 if (VAT_JSON_ARRAY != vam->json_tree.type)
1846 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1847 vat_json_init_array (&vam->json_tree);
1850 node = vat_json_array_add (&vam->json_tree);
1851 vat_json_init_object (node);
1853 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1854 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1855 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1859 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1861 vat_main_t *vam = &vat_main;
1862 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1863 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1867 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1869 vat_main_t *vam = &vat_main;
1870 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1871 "router_addr %U host_mac %U\n",
1872 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1873 format_ip4_address, &mp->host_address,
1874 format_ip4_address, &mp->router_address,
1875 format_ethernet_address, mp->host_mac);
1878 static void vl_api_dhcp_compl_event_t_handler_json
1879 (vl_api_dhcp_compl_event_t * mp)
1881 /* JSON output not supported */
1885 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1888 vat_main_t *vam = &vat_main;
1889 static u64 default_counter = 0;
1891 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1893 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1894 sw_if_index, default_counter);
1895 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1899 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1900 interface_counter_t counter)
1902 vat_main_t *vam = &vat_main;
1903 static interface_counter_t default_counter = { 0, };
1905 vec_validate_init_empty (vam->combined_interface_counters,
1906 vnet_counter_type, NULL);
1907 vec_validate_init_empty (vam->combined_interface_counters
1908 [vnet_counter_type], sw_if_index, default_counter);
1909 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1912 static void vl_api_vnet_interface_counters_t_handler
1913 (vl_api_vnet_interface_counters_t * mp)
1918 static void vl_api_vnet_interface_counters_t_handler_json
1919 (vl_api_vnet_interface_counters_t * mp)
1921 interface_counter_t counter;
1926 u32 first_sw_if_index;
1929 count = ntohl (mp->count);
1930 first_sw_if_index = ntohl (mp->first_sw_if_index);
1932 if (!mp->is_combined)
1934 v_packets = (u64 *) & mp->data;
1935 for (i = 0; i < count; i++)
1938 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1939 set_simple_interface_counter (mp->vnet_counter_type,
1940 first_sw_if_index + i, packets);
1946 v = (vlib_counter_t *) & mp->data;
1947 for (i = 0; i < count; i++)
1950 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1952 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1953 set_combined_interface_counter (mp->vnet_counter_type,
1954 first_sw_if_index + i, counter);
1961 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1963 vat_main_t *vam = &vat_main;
1966 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1968 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1977 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1979 vat_main_t *vam = &vat_main;
1982 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1984 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
1992 static void vl_api_vnet_ip4_fib_counters_t_handler
1993 (vl_api_vnet_ip4_fib_counters_t * mp)
1998 static void vl_api_vnet_ip4_fib_counters_t_handler_json
1999 (vl_api_vnet_ip4_fib_counters_t * mp)
2001 vat_main_t *vam = &vat_main;
2002 vl_api_ip4_fib_counter_t *v;
2003 ip4_fib_counter_t *counter;
2010 vrf_id = ntohl (mp->vrf_id);
2011 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2012 if (~0 == vrf_index)
2014 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2015 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2016 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2017 vec_validate (vam->ip4_fib_counters, vrf_index);
2018 vam->ip4_fib_counters[vrf_index] = NULL;
2021 vec_free (vam->ip4_fib_counters[vrf_index]);
2022 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2023 count = ntohl (mp->count);
2024 for (i = 0; i < count; i++)
2026 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2027 counter = &vam->ip4_fib_counters[vrf_index][i];
2028 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2029 counter->address = ip4;
2030 counter->address_length = v->address_length;
2031 counter->packets = clib_net_to_host_u64 (v->packets);
2032 counter->bytes = clib_net_to_host_u64 (v->bytes);
2037 static void vl_api_vnet_ip6_fib_counters_t_handler
2038 (vl_api_vnet_ip6_fib_counters_t * mp)
2043 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2044 (vl_api_vnet_ip6_fib_counters_t * mp)
2046 vat_main_t *vam = &vat_main;
2047 vl_api_ip6_fib_counter_t *v;
2048 ip6_fib_counter_t *counter;
2049 struct in6_addr ip6;
2055 vrf_id = ntohl (mp->vrf_id);
2056 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2057 if (~0 == vrf_index)
2059 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2060 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2061 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2062 vec_validate (vam->ip6_fib_counters, vrf_index);
2063 vam->ip6_fib_counters[vrf_index] = NULL;
2066 vec_free (vam->ip6_fib_counters[vrf_index]);
2067 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2068 count = ntohl (mp->count);
2069 for (i = 0; i < count; i++)
2071 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2072 counter = &vam->ip6_fib_counters[vrf_index][i];
2073 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2074 counter->address = ip6;
2075 counter->address_length = v->address_length;
2076 counter->packets = clib_net_to_host_u64 (v->packets);
2077 counter->bytes = clib_net_to_host_u64 (v->bytes);
2082 static void vl_api_get_first_msg_id_reply_t_handler
2083 (vl_api_get_first_msg_id_reply_t * mp)
2085 vat_main_t *vam = &vat_main;
2086 i32 retval = ntohl (mp->retval);
2088 if (vam->async_mode)
2090 vam->async_errors += (retval < 0);
2094 vam->retval = retval;
2095 vam->result_ready = 1;
2099 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2103 static void vl_api_get_first_msg_id_reply_t_handler_json
2104 (vl_api_get_first_msg_id_reply_t * mp)
2106 vat_main_t *vam = &vat_main;
2107 vat_json_node_t node;
2109 vat_json_init_object (&node);
2110 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2111 vat_json_object_add_uint (&node, "first_msg_id",
2112 (uint) ntohs (mp->first_msg_id));
2114 vat_json_print (vam->ofp, &node);
2115 vat_json_free (&node);
2117 vam->retval = ntohl (mp->retval);
2118 vam->result_ready = 1;
2121 static void vl_api_get_node_graph_reply_t_handler
2122 (vl_api_get_node_graph_reply_t * mp)
2124 vat_main_t *vam = &vat_main;
2125 api_main_t *am = &api_main;
2126 i32 retval = ntohl (mp->retval);
2127 u8 *pvt_copy, *reply;
2132 if (vam->async_mode)
2134 vam->async_errors += (retval < 0);
2138 vam->retval = retval;
2139 vam->result_ready = 1;
2142 /* "Should never happen..." */
2146 reply = (u8 *) (mp->reply_in_shmem);
2147 pvt_copy = vec_dup (reply);
2149 /* Toss the shared-memory original... */
2150 pthread_mutex_lock (&am->vlib_rp->mutex);
2151 oldheap = svm_push_data_heap (am->vlib_rp);
2155 svm_pop_heap (oldheap);
2156 pthread_mutex_unlock (&am->vlib_rp->mutex);
2158 if (vam->graph_nodes)
2160 hash_free (vam->graph_node_index_by_name);
2162 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2164 node = vam->graph_nodes[i];
2165 vec_free (node->name);
2166 vec_free (node->next_nodes);
2169 vec_free (vam->graph_nodes);
2172 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2173 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2174 vec_free (pvt_copy);
2176 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2178 node = vam->graph_nodes[i];
2179 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2183 static void vl_api_get_node_graph_reply_t_handler_json
2184 (vl_api_get_node_graph_reply_t * mp)
2186 vat_main_t *vam = &vat_main;
2187 api_main_t *am = &api_main;
2189 vat_json_node_t node;
2192 /* $$$$ make this real? */
2193 vat_json_init_object (&node);
2194 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2195 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2197 reply = (u8 *) (mp->reply_in_shmem);
2199 /* Toss the shared-memory original... */
2200 pthread_mutex_lock (&am->vlib_rp->mutex);
2201 oldheap = svm_push_data_heap (am->vlib_rp);
2205 svm_pop_heap (oldheap);
2206 pthread_mutex_unlock (&am->vlib_rp->mutex);
2208 vat_json_print (vam->ofp, &node);
2209 vat_json_free (&node);
2211 vam->retval = ntohl (mp->retval);
2212 vam->result_ready = 1;
2216 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2218 vat_main_t *vam = &vat_main;
2223 s = format (s, "%=16d%=16d%=16d\n",
2224 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2228 s = format (s, "%=16U%=16d%=16d\n",
2229 mp->is_ipv6 ? format_ip6_address :
2231 mp->ip_address, mp->priority, mp->weight);
2234 fformat (vam->ofp, "%v", s);
2239 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2242 vat_main_t *vam = &vat_main;
2243 vat_json_node_t *node = NULL;
2244 struct in6_addr ip6;
2247 if (VAT_JSON_ARRAY != vam->json_tree.type)
2249 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2250 vat_json_init_array (&vam->json_tree);
2252 node = vat_json_array_add (&vam->json_tree);
2253 vat_json_init_object (node);
2255 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2256 vat_json_object_add_uint (node, "priority", mp->priority);
2257 vat_json_object_add_uint (node, "weight", mp->weight);
2260 vat_json_object_add_uint (node, "sw_if_index",
2261 clib_net_to_host_u32 (mp->sw_if_index));
2266 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2267 vat_json_object_add_ip6 (node, "address", ip6);
2271 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2272 vat_json_object_add_ip4 (node, "address", ip4);
2278 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2281 vat_main_t *vam = &vat_main;
2284 ls_name = format (0, "%s", mp->ls_name);
2286 fformat (vam->ofp, "%=10d%=15v\n", clib_net_to_host_u32 (mp->ls_index),
2292 vl_api_lisp_locator_set_details_t_handler_json
2293 (vl_api_lisp_locator_set_details_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t *node = 0;
2299 ls_name = format (0, "%s", mp->ls_name);
2300 vec_add1 (ls_name, 0);
2302 if (VAT_JSON_ARRAY != vam->json_tree.type)
2304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2305 vat_json_init_array (&vam->json_tree);
2307 node = vat_json_array_add (&vam->json_tree);
2309 vat_json_init_object (node);
2310 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2311 vat_json_object_add_uint (node, "ls_index",
2312 clib_net_to_host_u32 (mp->ls_index));
2317 format_lisp_flat_eid (u8 * s, va_list * args)
2319 u32 type = va_arg (*args, u32);
2320 u8 *eid = va_arg (*args, u8 *);
2321 u32 eid_len = va_arg (*args, u32);
2326 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2328 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2330 return format (s, "%U", format_ethernet_address, eid);
2336 format_lisp_eid_vat (u8 * s, va_list * args)
2338 u32 type = va_arg (*args, u32);
2339 u8 *eid = va_arg (*args, u8 *);
2340 u32 eid_len = va_arg (*args, u32);
2341 u8 *seid = va_arg (*args, u8 *);
2342 u32 seid_len = va_arg (*args, u32);
2343 u32 is_src_dst = va_arg (*args, u32);
2346 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2348 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2354 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2356 vat_main_t *vam = &vat_main;
2357 u8 *s = 0, *eid = 0;
2359 if (~0 == mp->locator_set_index)
2360 s = format (0, "action: %d", mp->action);
2362 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2364 eid = format (0, "%U", format_lisp_eid_vat,
2368 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2371 fformat (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-d\n",
2372 clib_net_to_host_u32 (mp->vni),
2374 mp->is_local ? "local" : "remote",
2375 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative);
2381 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2384 vat_main_t *vam = &vat_main;
2385 vat_json_node_t *node = 0;
2388 if (VAT_JSON_ARRAY != vam->json_tree.type)
2390 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2391 vat_json_init_array (&vam->json_tree);
2393 node = vat_json_array_add (&vam->json_tree);
2395 vat_json_init_object (node);
2396 if (~0 == mp->locator_set_index)
2397 vat_json_object_add_uint (node, "action", mp->action);
2399 vat_json_object_add_uint (node, "locator_set_index",
2400 clib_net_to_host_u32 (mp->locator_set_index));
2402 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2403 eid = format (0, "%U", format_lisp_eid_vat,
2407 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2409 vat_json_object_add_string_copy (node, "eid", eid);
2410 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2411 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2412 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2417 vl_api_lisp_eid_table_map_details_t_handler
2418 (vl_api_lisp_eid_table_map_details_t * mp)
2420 vat_main_t *vam = &vat_main;
2422 u8 *line = format (0, "%=10d%=10d",
2423 clib_net_to_host_u32 (mp->vni),
2424 clib_net_to_host_u32 (mp->dp_table));
2425 fformat (vam->ofp, "%v\n", line);
2430 vl_api_lisp_eid_table_map_details_t_handler_json
2431 (vl_api_lisp_eid_table_map_details_t * mp)
2433 vat_main_t *vam = &vat_main;
2434 vat_json_node_t *node = NULL;
2436 if (VAT_JSON_ARRAY != vam->json_tree.type)
2438 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2439 vat_json_init_array (&vam->json_tree);
2441 node = vat_json_array_add (&vam->json_tree);
2442 vat_json_init_object (node);
2443 vat_json_object_add_uint (node, "dp_table",
2444 clib_net_to_host_u32 (mp->dp_table));
2445 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2449 vl_api_lisp_eid_table_vni_details_t_handler
2450 (vl_api_lisp_eid_table_vni_details_t * mp)
2452 vat_main_t *vam = &vat_main;
2454 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2455 fformat (vam->ofp, "%v\n", line);
2460 vl_api_lisp_eid_table_vni_details_t_handler_json
2461 (vl_api_lisp_eid_table_vni_details_t * mp)
2463 vat_main_t *vam = &vat_main;
2464 vat_json_node_t *node = NULL;
2466 if (VAT_JSON_ARRAY != vam->json_tree.type)
2468 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2469 vat_json_init_array (&vam->json_tree);
2471 node = vat_json_array_add (&vam->json_tree);
2472 vat_json_init_object (node);
2473 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2477 format_decap_next (u8 * s, va_list * args)
2479 u32 next_index = va_arg (*args, u32);
2483 case LISP_GPE_INPUT_NEXT_DROP:
2484 return format (s, "drop");
2485 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2486 return format (s, "ip4");
2487 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2488 return format (s, "ip6");
2490 return format (s, "unknown %d", next_index);
2496 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2499 vat_main_t *vam = &vat_main;
2501 u8 *flag_str = NULL;
2503 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2505 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2506 foreach_lisp_gpe_flag_bit;
2509 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2510 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2512 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2514 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2516 ntohl (mp->encap_fib_id),
2517 ntohl (mp->decap_fib_id),
2518 format_decap_next, ntohl (mp->dcap_next),
2520 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2526 vl_api_lisp_gpe_tunnel_details_t_handler_json
2527 (vl_api_lisp_gpe_tunnel_details_t * mp)
2529 vat_main_t *vam = &vat_main;
2530 vat_json_node_t *node = NULL;
2531 struct in6_addr ip6;
2535 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2537 if (VAT_JSON_ARRAY != vam->json_tree.type)
2539 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2540 vat_json_init_array (&vam->json_tree);
2542 node = vat_json_array_add (&vam->json_tree);
2544 vat_json_init_object (node);
2545 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2548 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2549 vat_json_object_add_ip6 (node, "source address", ip6);
2550 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2551 vat_json_object_add_ip6 (node, "destination address", ip6);
2555 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2556 vat_json_object_add_ip4 (node, "source address", ip4);
2557 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2558 vat_json_object_add_ip4 (node, "destination address", ip4);
2560 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2561 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2562 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2563 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2564 vat_json_object_add_uint (node, "flags", mp->flags);
2565 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2566 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2567 vat_json_object_add_uint (node, "res", mp->res);
2568 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2570 vec_free (next_decap_str);
2574 vl_api_lisp_adjacencies_get_reply_t_handler
2575 (vl_api_lisp_adjacencies_get_reply_t * mp)
2577 vat_main_t *vam = &vat_main;
2579 int retval = clib_net_to_host_u32 (mp->retval);
2580 vl_api_lisp_adjacency_t *a;
2585 n = clib_net_to_host_u32 (mp->count);
2587 for (i = 0; i < n; i++)
2589 a = &mp->adjacencies[i];
2590 fformat (vam->ofp, "%U %40U\n",
2591 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2592 format_lisp_flat_eid, a->eid_type, a->reid,
2593 a->reid_prefix_len);
2597 vam->retval = retval;
2598 vam->result_ready = 1;
2602 vl_api_lisp_adjacencies_get_reply_t_handler_json
2603 (vl_api_lisp_adjacencies_get_reply_t * mp)
2606 vat_main_t *vam = &vat_main;
2607 vat_json_node_t *e = 0, root;
2609 int retval = clib_net_to_host_u32 (mp->retval);
2610 vl_api_lisp_adjacency_t *a;
2615 n = clib_net_to_host_u32 (mp->count);
2616 vat_json_init_array (&root);
2618 for (i = 0; i < n; i++)
2620 e = vat_json_array_add (&root);
2621 a = &mp->adjacencies[i];
2623 vat_json_init_object (e);
2624 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2625 a->leid_prefix_len);
2627 vat_json_object_add_string_copy (e, "leid", s);
2630 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2631 a->reid_prefix_len);
2633 vat_json_object_add_string_copy (e, "reid", s);
2637 vat_json_print (vam->ofp, &root);
2638 vat_json_free (&root);
2641 vam->retval = retval;
2642 vam->result_ready = 1;
2646 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2649 vat_main_t *vam = &vat_main;
2651 fformat (vam->ofp, "%=20U\n",
2652 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2657 vl_api_lisp_map_resolver_details_t_handler_json
2658 (vl_api_lisp_map_resolver_details_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 vat_json_node_t *node = NULL;
2662 struct in6_addr ip6;
2665 if (VAT_JSON_ARRAY != vam->json_tree.type)
2667 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2668 vat_json_init_array (&vam->json_tree);
2670 node = vat_json_array_add (&vam->json_tree);
2672 vat_json_init_object (node);
2675 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2676 vat_json_object_add_ip6 (node, "map resolver", ip6);
2680 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2681 vat_json_object_add_ip4 (node, "map resolver", ip4);
2686 vl_api_show_lisp_status_reply_t_handler
2687 (vl_api_show_lisp_status_reply_t * mp)
2689 vat_main_t *vam = &vat_main;
2690 i32 retval = ntohl (mp->retval);
2694 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2695 mp->feature_status ? "enabled" : "disabled",
2696 mp->gpe_status ? "enabled" : "disabled");
2699 vam->retval = retval;
2700 vam->result_ready = 1;
2704 vl_api_show_lisp_status_reply_t_handler_json
2705 (vl_api_show_lisp_status_reply_t * mp)
2707 vat_main_t *vam = &vat_main;
2708 vat_json_node_t node;
2709 u8 *gpe_status = NULL;
2710 u8 *feature_status = NULL;
2712 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2713 feature_status = format (0, "%s",
2714 mp->feature_status ? "enabled" : "disabled");
2715 vec_add1 (gpe_status, 0);
2716 vec_add1 (feature_status, 0);
2718 vat_json_init_object (&node);
2719 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2720 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2722 vec_free (gpe_status);
2723 vec_free (feature_status);
2725 vat_json_print (vam->ofp, &node);
2726 vat_json_free (&node);
2728 vam->retval = ntohl (mp->retval);
2729 vam->result_ready = 1;
2733 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2734 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2736 vat_main_t *vam = &vat_main;
2737 i32 retval = ntohl (mp->retval);
2741 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2744 vam->retval = retval;
2745 vam->result_ready = 1;
2749 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2750 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2752 vat_main_t *vam = &vat_main;
2753 vat_json_node_t *node = NULL;
2755 if (VAT_JSON_ARRAY != vam->json_tree.type)
2757 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2758 vat_json_init_array (&vam->json_tree);
2760 node = vat_json_array_add (&vam->json_tree);
2762 vat_json_init_object (node);
2763 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2765 vat_json_print (vam->ofp, node);
2766 vat_json_free (node);
2768 vam->retval = ntohl (mp->retval);
2769 vam->result_ready = 1;
2773 format_lisp_map_request_mode (u8 * s, va_list * args)
2775 u32 mode = va_arg (*args, u32);
2780 return format (0, "dst-only");
2782 return format (0, "src-dst");
2788 vl_api_show_lisp_map_request_mode_reply_t_handler
2789 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2791 vat_main_t *vam = &vat_main;
2792 i32 retval = ntohl (mp->retval);
2796 u32 mode = mp->mode;
2797 fformat (vam->ofp, "map_request_mode: %U\n",
2798 format_lisp_map_request_mode, mode);
2801 vam->retval = retval;
2802 vam->result_ready = 1;
2806 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2807 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2809 vat_main_t *vam = &vat_main;
2810 vat_json_node_t node;
2815 s = format (0, "%U", format_lisp_map_request_mode, mode);
2818 vat_json_init_object (&node);
2819 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2820 vat_json_print (vam->ofp, &node);
2821 vat_json_free (&node);
2824 vam->retval = ntohl (mp->retval);
2825 vam->result_ready = 1;
2829 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2831 vat_main_t *vam = &vat_main;
2832 i32 retval = ntohl (mp->retval);
2836 fformat (vam->ofp, "%-20s%-16s\n",
2837 mp->status ? "enabled" : "disabled",
2838 mp->status ? (char *) mp->locator_set_name : "");
2841 vam->retval = retval;
2842 vam->result_ready = 1;
2846 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2849 vat_main_t *vam = &vat_main;
2850 vat_json_node_t node;
2853 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2854 vec_add1 (status, 0);
2856 vat_json_init_object (&node);
2857 vat_json_object_add_string_copy (&node, "status", status);
2860 vat_json_object_add_string_copy (&node, "locator_set",
2861 mp->locator_set_name);
2866 vat_json_print (vam->ofp, &node);
2867 vat_json_free (&node);
2869 vam->retval = ntohl (mp->retval);
2870 vam->result_ready = 1;
2874 format_policer_type (u8 * s, va_list * va)
2876 u32 i = va_arg (*va, u32);
2878 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2879 s = format (s, "1r2c");
2880 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2881 s = format (s, "1r3c");
2882 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2883 s = format (s, "2r3c-2698");
2884 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2885 s = format (s, "2r3c-4115");
2886 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2887 s = format (s, "2r3c-mef5cf1");
2889 s = format (s, "ILLEGAL");
2894 format_policer_rate_type (u8 * s, va_list * va)
2896 u32 i = va_arg (*va, u32);
2898 if (i == SSE2_QOS_RATE_KBPS)
2899 s = format (s, "kbps");
2900 else if (i == SSE2_QOS_RATE_PPS)
2901 s = format (s, "pps");
2903 s = format (s, "ILLEGAL");
2908 format_policer_round_type (u8 * s, va_list * va)
2910 u32 i = va_arg (*va, u32);
2912 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2913 s = format (s, "closest");
2914 else if (i == SSE2_QOS_ROUND_TO_UP)
2915 s = format (s, "up");
2916 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2917 s = format (s, "down");
2919 s = format (s, "ILLEGAL");
2924 format_policer_action_type (u8 * s, va_list * va)
2926 u32 i = va_arg (*va, u32);
2928 if (i == SSE2_QOS_ACTION_DROP)
2929 s = format (s, "drop");
2930 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2931 s = format (s, "transmit");
2932 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2933 s = format (s, "mark-and-transmit");
2935 s = format (s, "ILLEGAL");
2940 format_dscp (u8 * s, va_list * va)
2942 u32 i = va_arg (*va, u32);
2947 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2951 return format (s, "ILLEGAL");
2953 s = format (s, "%s", t);
2958 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2960 vat_main_t *vam = &vat_main;
2961 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2963 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2964 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2966 conform_dscp_str = format (0, "");
2968 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2969 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2971 exceed_dscp_str = format (0, "");
2973 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2974 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2976 violate_dscp_str = format (0, "");
2978 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2979 "rate type %U, round type %U, %s rate, %s color-aware, "
2980 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2981 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2982 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2984 format_policer_type, mp->type,
2987 clib_net_to_host_u64 (mp->cb),
2988 clib_net_to_host_u64 (mp->eb),
2989 format_policer_rate_type, mp->rate_type,
2990 format_policer_round_type, mp->round_type,
2991 mp->single_rate ? "single" : "dual",
2992 mp->color_aware ? "is" : "not",
2993 ntohl (mp->cir_tokens_per_period),
2994 ntohl (mp->pir_tokens_per_period),
2996 ntohl (mp->current_limit),
2997 ntohl (mp->current_bucket),
2998 ntohl (mp->extended_limit),
2999 ntohl (mp->extended_bucket),
3000 clib_net_to_host_u64 (mp->last_update_time),
3001 format_policer_action_type, mp->conform_action_type,
3003 format_policer_action_type, mp->exceed_action_type,
3005 format_policer_action_type, mp->violate_action_type,
3008 vec_free (conform_dscp_str);
3009 vec_free (exceed_dscp_str);
3010 vec_free (violate_dscp_str);
3013 static void vl_api_policer_details_t_handler_json
3014 (vl_api_policer_details_t * mp)
3016 vat_main_t *vam = &vat_main;
3017 vat_json_node_t *node;
3018 u8 *rate_type_str, *round_type_str, *type_str;
3019 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3021 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3023 format (0, "%U", format_policer_round_type, mp->round_type);
3024 type_str = format (0, "%U", format_policer_type, mp->type);
3025 conform_action_str = format (0, "%U", format_policer_action_type,
3026 mp->conform_action_type);
3027 exceed_action_str = format (0, "%U", format_policer_action_type,
3028 mp->exceed_action_type);
3029 violate_action_str = format (0, "%U", format_policer_action_type,
3030 mp->violate_action_type);
3032 if (VAT_JSON_ARRAY != vam->json_tree.type)
3034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3035 vat_json_init_array (&vam->json_tree);
3037 node = vat_json_array_add (&vam->json_tree);
3039 vat_json_init_object (node);
3040 vat_json_object_add_string_copy (node, "name", mp->name);
3041 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3042 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3043 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3044 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3045 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3046 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3047 vat_json_object_add_string_copy (node, "type", type_str);
3048 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3049 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3050 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3051 vat_json_object_add_uint (node, "cir_tokens_per_period",
3052 ntohl (mp->cir_tokens_per_period));
3053 vat_json_object_add_uint (node, "eir_tokens_per_period",
3054 ntohl (mp->pir_tokens_per_period));
3055 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3056 vat_json_object_add_uint (node, "current_bucket",
3057 ntohl (mp->current_bucket));
3058 vat_json_object_add_uint (node, "extended_limit",
3059 ntohl (mp->extended_limit));
3060 vat_json_object_add_uint (node, "extended_bucket",
3061 ntohl (mp->extended_bucket));
3062 vat_json_object_add_uint (node, "last_update_time",
3063 ntohl (mp->last_update_time));
3064 vat_json_object_add_string_copy (node, "conform_action",
3065 conform_action_str);
3066 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3068 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3069 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3070 vec_free (dscp_str);
3072 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3073 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3075 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3076 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3077 vec_free (dscp_str);
3079 vat_json_object_add_string_copy (node, "violate_action",
3080 violate_action_str);
3081 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3083 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3084 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3085 vec_free (dscp_str);
3088 vec_free (rate_type_str);
3089 vec_free (round_type_str);
3090 vec_free (type_str);
3091 vec_free (conform_action_str);
3092 vec_free (exceed_action_str);
3093 vec_free (violate_action_str);
3097 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3100 vat_main_t *vam = &vat_main;
3101 int i, count = ntohl (mp->count);
3104 fformat (vam->ofp, "classify table ids (%d) : ", count);
3105 for (i = 0; i < count; i++)
3107 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3108 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3110 vam->retval = ntohl (mp->retval);
3111 vam->result_ready = 1;
3115 vl_api_classify_table_ids_reply_t_handler_json
3116 (vl_api_classify_table_ids_reply_t * mp)
3118 vat_main_t *vam = &vat_main;
3119 int i, count = ntohl (mp->count);
3123 vat_json_node_t node;
3125 vat_json_init_object (&node);
3126 for (i = 0; i < count; i++)
3128 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3130 vat_json_print (vam->ofp, &node);
3131 vat_json_free (&node);
3133 vam->retval = ntohl (mp->retval);
3134 vam->result_ready = 1;
3138 vl_api_classify_table_by_interface_reply_t_handler
3139 (vl_api_classify_table_by_interface_reply_t * mp)
3141 vat_main_t *vam = &vat_main;
3144 table_id = ntohl (mp->l2_table_id);
3146 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3148 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3149 table_id = ntohl (mp->ip4_table_id);
3151 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3153 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3154 table_id = ntohl (mp->ip6_table_id);
3156 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3158 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3159 vam->retval = ntohl (mp->retval);
3160 vam->result_ready = 1;
3164 vl_api_classify_table_by_interface_reply_t_handler_json
3165 (vl_api_classify_table_by_interface_reply_t * mp)
3167 vat_main_t *vam = &vat_main;
3168 vat_json_node_t node;
3170 vat_json_init_object (&node);
3172 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3173 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3174 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3176 vat_json_print (vam->ofp, &node);
3177 vat_json_free (&node);
3179 vam->retval = ntohl (mp->retval);
3180 vam->result_ready = 1;
3183 static void vl_api_policer_add_del_reply_t_handler
3184 (vl_api_policer_add_del_reply_t * mp)
3186 vat_main_t *vam = &vat_main;
3187 i32 retval = ntohl (mp->retval);
3188 if (vam->async_mode)
3190 vam->async_errors += (retval < 0);
3194 vam->retval = retval;
3195 vam->result_ready = 1;
3196 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3198 * Note: this is just barely thread-safe, depends on
3199 * the main thread spinning waiting for an answer...
3201 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3205 static void vl_api_policer_add_del_reply_t_handler_json
3206 (vl_api_policer_add_del_reply_t * mp)
3208 vat_main_t *vam = &vat_main;
3209 vat_json_node_t node;
3211 vat_json_init_object (&node);
3212 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3213 vat_json_object_add_uint (&node, "policer_index",
3214 ntohl (mp->policer_index));
3216 vat_json_print (vam->ofp, &node);
3217 vat_json_free (&node);
3219 vam->retval = ntohl (mp->retval);
3220 vam->result_ready = 1;
3223 /* Format hex dump. */
3225 format_hex_bytes (u8 * s, va_list * va)
3227 u8 *bytes = va_arg (*va, u8 *);
3228 int n_bytes = va_arg (*va, int);
3231 /* Print short or long form depending on byte count. */
3232 uword short_form = n_bytes <= 32;
3233 uword indent = format_get_indent (s);
3238 for (i = 0; i < n_bytes; i++)
3240 if (!short_form && (i % 32) == 0)
3241 s = format (s, "%08x: ", i);
3242 s = format (s, "%02x", bytes[i]);
3243 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3244 s = format (s, "\n%U", format_white_space, indent);
3251 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3254 vat_main_t *vam = &vat_main;
3255 i32 retval = ntohl (mp->retval);
3258 fformat (vam->ofp, "classify table info :\n");
3259 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3260 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3261 ntohl (mp->miss_next_index));
3262 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3263 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3264 ntohl (mp->match_n_vectors));
3265 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3266 ntohl (mp->mask_length));
3268 vam->retval = retval;
3269 vam->result_ready = 1;
3273 vl_api_classify_table_info_reply_t_handler_json
3274 (vl_api_classify_table_info_reply_t * mp)
3276 vat_main_t *vam = &vat_main;
3277 vat_json_node_t node;
3279 i32 retval = ntohl (mp->retval);
3282 vat_json_init_object (&node);
3284 vat_json_object_add_int (&node, "sessions",
3285 ntohl (mp->active_sessions));
3286 vat_json_object_add_int (&node, "nexttbl",
3287 ntohl (mp->next_table_index));
3288 vat_json_object_add_int (&node, "nextnode",
3289 ntohl (mp->miss_next_index));
3290 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3291 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3292 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3293 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3294 ntohl (mp->mask_length), 0);
3295 vat_json_object_add_string_copy (&node, "mask", s);
3297 vat_json_print (vam->ofp, &node);
3298 vat_json_free (&node);
3300 vam->retval = ntohl (mp->retval);
3301 vam->result_ready = 1;
3305 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3308 vat_main_t *vam = &vat_main;
3310 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3311 ntohl (mp->hit_next_index), ntohl (mp->advance),
3312 ntohl (mp->opaque_index));
3313 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3314 ntohl (mp->match_length));
3318 vl_api_classify_session_details_t_handler_json
3319 (vl_api_classify_session_details_t * mp)
3321 vat_main_t *vam = &vat_main;
3322 vat_json_node_t *node = NULL;
3324 if (VAT_JSON_ARRAY != vam->json_tree.type)
3326 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3327 vat_json_init_array (&vam->json_tree);
3329 node = vat_json_array_add (&vam->json_tree);
3331 vat_json_init_object (node);
3332 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3333 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3334 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3336 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3338 vat_json_object_add_string_copy (node, "match", s);
3341 static void vl_api_pg_create_interface_reply_t_handler
3342 (vl_api_pg_create_interface_reply_t * mp)
3344 vat_main_t *vam = &vat_main;
3346 vam->retval = ntohl (mp->retval);
3347 vam->result_ready = 1;
3350 static void vl_api_pg_create_interface_reply_t_handler_json
3351 (vl_api_pg_create_interface_reply_t * mp)
3353 vat_main_t *vam = &vat_main;
3354 vat_json_node_t node;
3356 i32 retval = ntohl (mp->retval);
3359 vat_json_init_object (&node);
3361 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3363 vat_json_print (vam->ofp, &node);
3364 vat_json_free (&node);
3366 vam->retval = ntohl (mp->retval);
3367 vam->result_ready = 1;
3370 static void vl_api_policer_classify_details_t_handler
3371 (vl_api_policer_classify_details_t * mp)
3373 vat_main_t *vam = &vat_main;
3375 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3376 ntohl (mp->table_index));
3379 static void vl_api_policer_classify_details_t_handler_json
3380 (vl_api_policer_classify_details_t * mp)
3382 vat_main_t *vam = &vat_main;
3383 vat_json_node_t *node;
3385 if (VAT_JSON_ARRAY != vam->json_tree.type)
3387 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3388 vat_json_init_array (&vam->json_tree);
3390 node = vat_json_array_add (&vam->json_tree);
3392 vat_json_init_object (node);
3393 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3394 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3397 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3398 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3400 vat_main_t *vam = &vat_main;
3401 i32 retval = ntohl (mp->retval);
3402 if (vam->async_mode)
3404 vam->async_errors += (retval < 0);
3408 vam->retval = retval;
3409 vam->sw_if_index = ntohl (mp->sw_if_index);
3410 vam->result_ready = 1;
3414 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3415 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3417 vat_main_t *vam = &vat_main;
3418 vat_json_node_t node;
3420 vat_json_init_object (&node);
3421 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3422 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3424 vat_json_print (vam->ofp, &node);
3425 vat_json_free (&node);
3427 vam->retval = ntohl (mp->retval);
3428 vam->result_ready = 1;
3431 static void vl_api_flow_classify_details_t_handler
3432 (vl_api_flow_classify_details_t * mp)
3434 vat_main_t *vam = &vat_main;
3436 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3437 ntohl (mp->table_index));
3440 static void vl_api_flow_classify_details_t_handler_json
3441 (vl_api_flow_classify_details_t * mp)
3443 vat_main_t *vam = &vat_main;
3444 vat_json_node_t *node;
3446 if (VAT_JSON_ARRAY != vam->json_tree.type)
3448 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3449 vat_json_init_array (&vam->json_tree);
3451 node = vat_json_array_add (&vam->json_tree);
3453 vat_json_init_object (node);
3454 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3455 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3460 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3461 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3462 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3463 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3464 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3465 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3468 * Generate boilerplate reply handlers, which
3469 * dig the return value out of the xxx_reply_t API message,
3470 * stick it into vam->retval, and set vam->result_ready
3472 * Could also do this by pointing N message decode slots at
3473 * a single function, but that could break in subtle ways.
3476 #define foreach_standard_reply_retval_handler \
3477 _(sw_interface_set_flags_reply) \
3478 _(sw_interface_add_del_address_reply) \
3479 _(sw_interface_set_table_reply) \
3480 _(sw_interface_set_mpls_enable_reply) \
3481 _(sw_interface_set_vpath_reply) \
3482 _(sw_interface_set_l2_bridge_reply) \
3483 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3484 _(sw_interface_set_dpdk_hqos_subport_reply) \
3485 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3486 _(bridge_domain_add_del_reply) \
3487 _(sw_interface_set_l2_xconnect_reply) \
3488 _(l2fib_add_del_reply) \
3489 _(ip_add_del_route_reply) \
3490 _(mpls_route_add_del_reply) \
3491 _(mpls_ip_bind_unbind_reply) \
3492 _(proxy_arp_add_del_reply) \
3493 _(proxy_arp_intfc_enable_disable_reply) \
3494 _(mpls_add_del_encap_reply) \
3495 _(mpls_ethernet_add_del_tunnel_2_reply) \
3496 _(sw_interface_set_unnumbered_reply) \
3497 _(ip_neighbor_add_del_reply) \
3498 _(reset_vrf_reply) \
3499 _(oam_add_del_reply) \
3500 _(reset_fib_reply) \
3501 _(dhcp_proxy_config_reply) \
3502 _(dhcp_proxy_config_2_reply) \
3503 _(dhcp_proxy_set_vss_reply) \
3504 _(dhcp_client_config_reply) \
3505 _(set_ip_flow_hash_reply) \
3506 _(sw_interface_ip6_enable_disable_reply) \
3507 _(sw_interface_ip6_set_link_local_address_reply) \
3508 _(sw_interface_ip6nd_ra_prefix_reply) \
3509 _(sw_interface_ip6nd_ra_config_reply) \
3510 _(set_arp_neighbor_limit_reply) \
3511 _(l2_patch_add_del_reply) \
3512 _(sr_tunnel_add_del_reply) \
3513 _(sr_policy_add_del_reply) \
3514 _(sr_multicast_map_add_del_reply) \
3515 _(classify_add_del_session_reply) \
3516 _(classify_set_interface_ip_table_reply) \
3517 _(classify_set_interface_l2_tables_reply) \
3518 _(l2tpv3_set_tunnel_cookies_reply) \
3519 _(l2tpv3_interface_enable_disable_reply) \
3520 _(l2tpv3_set_lookup_key_reply) \
3521 _(l2_fib_clear_table_reply) \
3522 _(l2_interface_efp_filter_reply) \
3523 _(l2_interface_vlan_tag_rewrite_reply) \
3524 _(modify_vhost_user_if_reply) \
3525 _(delete_vhost_user_if_reply) \
3526 _(want_ip4_arp_events_reply) \
3527 _(want_ip6_nd_events_reply) \
3528 _(input_acl_set_interface_reply) \
3529 _(ipsec_spd_add_del_reply) \
3530 _(ipsec_interface_add_del_spd_reply) \
3531 _(ipsec_spd_add_del_entry_reply) \
3532 _(ipsec_sad_add_del_entry_reply) \
3533 _(ipsec_sa_set_key_reply) \
3534 _(ikev2_profile_add_del_reply) \
3535 _(ikev2_profile_set_auth_reply) \
3536 _(ikev2_profile_set_id_reply) \
3537 _(ikev2_profile_set_ts_reply) \
3538 _(ikev2_set_local_key_reply) \
3539 _(delete_loopback_reply) \
3540 _(bd_ip_mac_add_del_reply) \
3541 _(map_del_domain_reply) \
3542 _(map_add_del_rule_reply) \
3543 _(want_interface_events_reply) \
3544 _(want_stats_reply) \
3545 _(cop_interface_enable_disable_reply) \
3546 _(cop_whitelist_enable_disable_reply) \
3547 _(sw_interface_clear_stats_reply) \
3548 _(ioam_enable_reply) \
3549 _(ioam_disable_reply) \
3550 _(lisp_add_del_locator_reply) \
3551 _(lisp_add_del_local_eid_reply) \
3552 _(lisp_add_del_remote_mapping_reply) \
3553 _(lisp_add_del_adjacency_reply) \
3554 _(lisp_gpe_add_del_fwd_entry_reply) \
3555 _(lisp_add_del_map_resolver_reply) \
3556 _(lisp_gpe_enable_disable_reply) \
3557 _(lisp_gpe_add_del_iface_reply) \
3558 _(lisp_enable_disable_reply) \
3559 _(lisp_pitr_set_locator_set_reply) \
3560 _(lisp_map_request_mode_reply) \
3561 _(lisp_add_del_map_request_itr_rlocs_reply) \
3562 _(lisp_eid_table_add_del_map_reply) \
3563 _(vxlan_gpe_add_del_tunnel_reply) \
3564 _(af_packet_delete_reply) \
3565 _(policer_classify_set_interface_reply) \
3566 _(netmap_create_reply) \
3567 _(netmap_delete_reply) \
3568 _(set_ipfix_exporter_reply) \
3569 _(set_ipfix_classify_stream_reply) \
3570 _(ipfix_classify_table_add_del_reply) \
3571 _(flow_classify_set_interface_reply) \
3572 _(sw_interface_span_enable_disable_reply) \
3573 _(pg_capture_reply) \
3574 _(pg_enable_disable_reply) \
3575 _(ip_source_and_port_range_check_add_del_reply) \
3576 _(ip_source_and_port_range_check_interface_add_del_reply)\
3577 _(delete_subif_reply) \
3578 _(l2_interface_pbb_tag_rewrite_reply) \
3580 _(feature_enable_disable_reply)
3583 static void vl_api_##n##_t_handler \
3584 (vl_api_##n##_t * mp) \
3586 vat_main_t * vam = &vat_main; \
3587 i32 retval = ntohl(mp->retval); \
3588 if (vam->async_mode) { \
3589 vam->async_errors += (retval < 0); \
3591 vam->retval = retval; \
3592 vam->result_ready = 1; \
3595 foreach_standard_reply_retval_handler;
3599 static void vl_api_##n##_t_handler_json \
3600 (vl_api_##n##_t * mp) \
3602 vat_main_t * vam = &vat_main; \
3603 vat_json_node_t node; \
3604 vat_json_init_object(&node); \
3605 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3606 vat_json_print(vam->ofp, &node); \
3607 vam->retval = ntohl(mp->retval); \
3608 vam->result_ready = 1; \
3610 foreach_standard_reply_retval_handler;
3614 * Table of message reply handlers, must include boilerplate handlers
3618 #define foreach_vpe_api_reply_msg \
3619 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3620 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3621 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3622 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3623 _(CONTROL_PING_REPLY, control_ping_reply) \
3624 _(CLI_REPLY, cli_reply) \
3625 _(CLI_INBAND_REPLY, cli_inband_reply) \
3626 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3627 sw_interface_add_del_address_reply) \
3628 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3629 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3630 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3631 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3632 sw_interface_set_l2_xconnect_reply) \
3633 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3634 sw_interface_set_l2_bridge_reply) \
3635 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3636 sw_interface_set_dpdk_hqos_pipe_reply) \
3637 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3638 sw_interface_set_dpdk_hqos_subport_reply) \
3639 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3640 sw_interface_set_dpdk_hqos_tctbl_reply) \
3641 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3642 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3643 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3644 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3645 _(L2_FLAGS_REPLY, l2_flags_reply) \
3646 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3647 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3648 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3649 _(TAP_DELETE_REPLY, tap_delete_reply) \
3650 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3651 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3652 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3653 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3654 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3655 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3656 proxy_arp_intfc_enable_disable_reply) \
3657 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3658 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3659 mpls_ethernet_add_del_tunnel_reply) \
3660 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3661 mpls_ethernet_add_del_tunnel_2_reply) \
3662 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3663 sw_interface_set_unnumbered_reply) \
3664 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3665 _(RESET_VRF_REPLY, reset_vrf_reply) \
3666 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3667 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3668 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3669 _(RESET_FIB_REPLY, reset_fib_reply) \
3670 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3671 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3672 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3673 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3674 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3675 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3676 sw_interface_ip6_enable_disable_reply) \
3677 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3678 sw_interface_ip6_set_link_local_address_reply) \
3679 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3680 sw_interface_ip6nd_ra_prefix_reply) \
3681 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3682 sw_interface_ip6nd_ra_config_reply) \
3683 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3684 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3685 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3686 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3687 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3688 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3689 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3690 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3691 classify_set_interface_ip_table_reply) \
3692 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3693 classify_set_interface_l2_tables_reply) \
3694 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3695 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3696 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3697 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3698 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3699 l2tpv3_interface_enable_disable_reply) \
3700 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3701 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3702 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3703 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3704 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3705 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3706 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3707 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3708 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3709 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3710 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3711 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3712 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3713 _(SHOW_VERSION_REPLY, show_version_reply) \
3714 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3715 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3716 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3717 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3718 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3719 _(IP4_ARP_EVENT, ip4_arp_event) \
3720 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3721 _(IP6_ND_EVENT, ip6_nd_event) \
3722 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3723 _(IP_ADDRESS_DETAILS, ip_address_details) \
3724 _(IP_DETAILS, ip_details) \
3725 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3726 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3727 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3728 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3729 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3730 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3731 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3732 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3733 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3734 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3735 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3736 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3737 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3738 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3739 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3740 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3741 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3742 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3743 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3744 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3745 _(MAP_RULE_DETAILS, map_rule_details) \
3746 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3747 _(WANT_STATS_REPLY, want_stats_reply) \
3748 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3749 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3750 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3751 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3752 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3753 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3754 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3755 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3756 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3757 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3758 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3759 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3760 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3761 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3762 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3763 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3764 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3765 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3766 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3767 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3768 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3769 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3770 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3771 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3772 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3773 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3774 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3775 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3776 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3777 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3778 lisp_add_del_map_request_itr_rlocs_reply) \
3779 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3780 lisp_get_map_request_itr_rlocs_reply) \
3781 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3782 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3783 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3784 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3785 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3786 _(POLICER_DETAILS, policer_details) \
3787 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3788 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3789 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3790 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3791 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3792 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3793 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3794 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3795 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3796 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3797 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3798 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3799 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3800 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3801 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3802 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3803 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3804 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3805 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3806 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3807 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3808 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3809 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3810 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3811 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3812 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3813 ip_source_and_port_range_check_add_del_reply) \
3814 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3815 ip_source_and_port_range_check_interface_add_del_reply) \
3816 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3817 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3818 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3819 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3820 _(PUNT_REPLY, punt_reply) \
3821 _(IP_FIB_DETAILS, ip_fib_details) \
3822 _(IP6_FIB_DETAILS, ip6_fib_details) \
3823 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply)
3825 /* M: construct, but don't yet send a message */
3829 vam->result_ready = 0; \
3830 mp = vl_msg_api_alloc(sizeof(*mp)); \
3831 memset (mp, 0, sizeof (*mp)); \
3832 mp->_vl_msg_id = ntohs (VL_API_##T); \
3833 mp->client_index = vam->my_client_index; \
3838 vam->result_ready = 0; \
3839 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3840 memset (mp, 0, sizeof (*mp)); \
3841 mp->_vl_msg_id = ntohs (VL_API_##T); \
3842 mp->client_index = vam->my_client_index; \
3846 /* S: send a message */
3847 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3849 /* W: wait for results, with timeout */
3852 timeout = vat_time_now (vam) + 1.0; \
3854 while (vat_time_now (vam) < timeout) { \
3855 if (vam->result_ready == 1) { \
3856 return (vam->retval); \
3862 /* W2: wait for results, with timeout */
3865 timeout = vat_time_now (vam) + 1.0; \
3867 while (vat_time_now (vam) < timeout) { \
3868 if (vam->result_ready == 1) { \
3870 return (vam->retval); \
3883 #define STR_VTR_OP_CASE(op) \
3884 case L2_VTR_ ## op: \
3888 str_vtr_op (u32 vtr_op)
3892 STR_VTR_OP_CASE (DISABLED);
3893 STR_VTR_OP_CASE (PUSH_1);
3894 STR_VTR_OP_CASE (PUSH_2);
3895 STR_VTR_OP_CASE (POP_1);
3896 STR_VTR_OP_CASE (POP_2);
3897 STR_VTR_OP_CASE (TRANSLATE_1_1);
3898 STR_VTR_OP_CASE (TRANSLATE_1_2);
3899 STR_VTR_OP_CASE (TRANSLATE_2_1);
3900 STR_VTR_OP_CASE (TRANSLATE_2_2);
3907 dump_sub_interface_table (vat_main_t * vam)
3909 const sw_interface_subif_t *sub = NULL;
3911 if (vam->json_output)
3914 ("JSON output supported only for VPE API calls and dump_stats_table");
3919 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3920 "Interface", "sw_if_index",
3921 "sub id", "dot1ad", "tags", "outer id",
3922 "inner id", "exact", "default", "outer any", "inner any");
3924 vec_foreach (sub, vam->sw_if_subif_table)
3927 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3928 sub->interface_name,
3930 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3931 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3932 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3933 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3934 if (sub->vtr_op != L2_VTR_DISABLED)
3937 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3938 "tag1: %d tag2: %d ]\n",
3939 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3940 sub->vtr_tag1, sub->vtr_tag2);
3948 name_sort_cmp (void *a1, void *a2)
3950 name_sort_t *n1 = a1;
3951 name_sort_t *n2 = a2;
3953 return strcmp ((char *) n1->name, (char *) n2->name);
3957 dump_interface_table (vat_main_t * vam)
3960 name_sort_t *nses = 0, *ns;
3962 if (vam->json_output)
3965 ("JSON output supported only for VPE API calls and dump_stats_table");
3970 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3972 vec_add2 (nses, ns, 1);
3973 ns->name = (u8 *)(p->key);
3974 ns->value = (u32) p->value[0];
3978 vec_sort_with_function (nses, name_sort_cmp);
3980 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3981 vec_foreach (ns, nses)
3983 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3990 dump_ip_table (vat_main_t * vam, int is_ipv6)
3992 const ip_details_t *det = NULL;
3993 const ip_address_details_t *address = NULL;
3996 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3998 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4005 fformat (vam->ofp, "%-12d\n", i);
4007 " %-30s%-13s\n", "Address", "Prefix length");
4012 vec_foreach (address, det->addr)
4016 is_ipv6 ? format_ip6_address : format_ip4_address,
4017 address->ip, address->prefix_length);
4025 dump_ipv4_table (vat_main_t * vam)
4027 if (vam->json_output)
4030 ("JSON output supported only for VPE API calls and dump_stats_table");
4034 return dump_ip_table (vam, 0);
4038 dump_ipv6_table (vat_main_t * vam)
4040 if (vam->json_output)
4043 ("JSON output supported only for VPE API calls and dump_stats_table");
4047 return dump_ip_table (vam, 1);
4051 counter_type_to_str (u8 counter_type, u8 is_combined)
4055 switch (counter_type)
4057 case VNET_INTERFACE_COUNTER_DROP:
4059 case VNET_INTERFACE_COUNTER_PUNT:
4061 case VNET_INTERFACE_COUNTER_IP4:
4063 case VNET_INTERFACE_COUNTER_IP6:
4065 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4067 case VNET_INTERFACE_COUNTER_RX_MISS:
4069 case VNET_INTERFACE_COUNTER_RX_ERROR:
4071 case VNET_INTERFACE_COUNTER_TX_ERROR:
4074 return "INVALID-COUNTER-TYPE";
4079 switch (counter_type)
4081 case VNET_INTERFACE_COUNTER_RX:
4083 case VNET_INTERFACE_COUNTER_TX:
4086 return "INVALID-COUNTER-TYPE";
4092 dump_stats_table (vat_main_t * vam)
4094 vat_json_node_t node;
4095 vat_json_node_t *msg_array;
4096 vat_json_node_t *msg;
4097 vat_json_node_t *counter_array;
4098 vat_json_node_t *counter;
4099 interface_counter_t c;
4101 ip4_fib_counter_t *c4;
4102 ip6_fib_counter_t *c6;
4105 if (!vam->json_output)
4107 clib_warning ("dump_stats_table supported only in JSON format");
4111 vat_json_init_object (&node);
4113 /* interface counters */
4114 msg_array = vat_json_object_add (&node, "interface_counters");
4115 vat_json_init_array (msg_array);
4116 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4118 msg = vat_json_array_add (msg_array);
4119 vat_json_init_object (msg);
4120 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4121 (u8 *) counter_type_to_str (i, 0));
4122 vat_json_object_add_int (msg, "is_combined", 0);
4123 counter_array = vat_json_object_add (msg, "data");
4124 vat_json_init_array (counter_array);
4125 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4127 packets = vam->simple_interface_counters[i][j];
4128 vat_json_array_add_uint (counter_array, packets);
4131 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4133 msg = vat_json_array_add (msg_array);
4134 vat_json_init_object (msg);
4135 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4136 (u8 *) counter_type_to_str (i, 1));
4137 vat_json_object_add_int (msg, "is_combined", 1);
4138 counter_array = vat_json_object_add (msg, "data");
4139 vat_json_init_array (counter_array);
4140 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4142 c = vam->combined_interface_counters[i][j];
4143 counter = vat_json_array_add (counter_array);
4144 vat_json_init_object (counter);
4145 vat_json_object_add_uint (counter, "packets", c.packets);
4146 vat_json_object_add_uint (counter, "bytes", c.bytes);
4150 /* ip4 fib counters */
4151 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4152 vat_json_init_array (msg_array);
4153 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4155 msg = vat_json_array_add (msg_array);
4156 vat_json_init_object (msg);
4157 vat_json_object_add_uint (msg, "vrf_id",
4158 vam->ip4_fib_counters_vrf_id_by_index[i]);
4159 counter_array = vat_json_object_add (msg, "c");
4160 vat_json_init_array (counter_array);
4161 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4163 counter = vat_json_array_add (counter_array);
4164 vat_json_init_object (counter);
4165 c4 = &vam->ip4_fib_counters[i][j];
4166 vat_json_object_add_ip4 (counter, "address", c4->address);
4167 vat_json_object_add_uint (counter, "address_length",
4168 c4->address_length);
4169 vat_json_object_add_uint (counter, "packets", c4->packets);
4170 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4174 /* ip6 fib counters */
4175 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4176 vat_json_init_array (msg_array);
4177 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4179 msg = vat_json_array_add (msg_array);
4180 vat_json_init_object (msg);
4181 vat_json_object_add_uint (msg, "vrf_id",
4182 vam->ip6_fib_counters_vrf_id_by_index[i]);
4183 counter_array = vat_json_object_add (msg, "c");
4184 vat_json_init_array (counter_array);
4185 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4187 counter = vat_json_array_add (counter_array);
4188 vat_json_init_object (counter);
4189 c6 = &vam->ip6_fib_counters[i][j];
4190 vat_json_object_add_ip6 (counter, "address", c6->address);
4191 vat_json_object_add_uint (counter, "address_length",
4192 c6->address_length);
4193 vat_json_object_add_uint (counter, "packets", c6->packets);
4194 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4198 vat_json_print (vam->ofp, &node);
4199 vat_json_free (&node);
4205 exec (vat_main_t * vam)
4207 api_main_t *am = &api_main;
4208 vl_api_cli_request_t *mp;
4212 unformat_input_t *i = vam->input;
4214 if (vec_len (i->buffer) == 0)
4217 if (vam->exec_mode == 0 && unformat (i, "mode"))
4222 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4229 M (CLI_REQUEST, cli_request);
4232 * Copy cmd into shared memory.
4233 * In order for the CLI command to work, it
4234 * must be a vector ending in \n, not a C-string ending
4237 pthread_mutex_lock (&am->vlib_rp->mutex);
4238 oldheap = svm_push_data_heap (am->vlib_rp);
4240 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4241 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4243 svm_pop_heap (oldheap);
4244 pthread_mutex_unlock (&am->vlib_rp->mutex);
4246 mp->cmd_in_shmem = (u64) cmd;
4248 timeout = vat_time_now (vam) + 10.0;
4250 while (vat_time_now (vam) < timeout)
4252 if (vam->result_ready == 1)
4255 if (vam->shmem_result != NULL)
4256 fformat (vam->ofp, "%s", vam->shmem_result);
4257 pthread_mutex_lock (&am->vlib_rp->mutex);
4258 oldheap = svm_push_data_heap (am->vlib_rp);
4260 free_me = (u8 *) vam->shmem_result;
4263 svm_pop_heap (oldheap);
4264 pthread_mutex_unlock (&am->vlib_rp->mutex);
4272 * Future replacement of exec() that passes CLI buffers directly in
4273 * the API messages instead of an additional shared memory area.
4276 exec_inband (vat_main_t * vam)
4278 vl_api_cli_inband_t *mp;
4280 unformat_input_t *i = vam->input;
4282 if (vec_len (i->buffer) == 0)
4285 if (vam->exec_mode == 0 && unformat (i, "mode"))
4290 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4297 * In order for the CLI command to work, it
4298 * must be a vector ending in \n, not a C-string ending
4301 u32 len = vec_len (vam->input->buffer);
4302 M2 (CLI_INBAND, cli_inband, len);
4303 clib_memcpy (mp->cmd, vam->input->buffer, len);
4304 mp->length = htonl (len);
4307 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4311 api_create_loopback (vat_main_t * vam)
4313 unformat_input_t *i = vam->input;
4314 vl_api_create_loopback_t *mp;
4319 memset (mac_address, 0, sizeof (mac_address));
4321 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4323 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4329 /* Construct the API message */
4330 M (CREATE_LOOPBACK, create_loopback);
4332 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4339 api_delete_loopback (vat_main_t * vam)
4341 unformat_input_t *i = vam->input;
4342 vl_api_delete_loopback_t *mp;
4344 u32 sw_if_index = ~0;
4346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4348 if (unformat (i, "sw_if_index %d", &sw_if_index))
4354 if (sw_if_index == ~0)
4356 errmsg ("missing sw_if_index\n");
4360 /* Construct the API message */
4361 M (DELETE_LOOPBACK, delete_loopback);
4362 mp->sw_if_index = ntohl (sw_if_index);
4369 api_want_stats (vat_main_t * vam)
4371 unformat_input_t *i = vam->input;
4372 vl_api_want_stats_t *mp;
4376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4378 if (unformat (i, "enable"))
4380 else if (unformat (i, "disable"))
4388 errmsg ("missing enable|disable\n");
4392 M (WANT_STATS, want_stats);
4393 mp->enable_disable = enable;
4400 api_want_interface_events (vat_main_t * vam)
4402 unformat_input_t *i = vam->input;
4403 vl_api_want_interface_events_t *mp;
4407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4409 if (unformat (i, "enable"))
4411 else if (unformat (i, "disable"))
4419 errmsg ("missing enable|disable\n");
4423 M (WANT_INTERFACE_EVENTS, want_interface_events);
4424 mp->enable_disable = enable;
4426 vam->interface_event_display = enable;
4433 /* Note: non-static, called once to set up the initial intfc table */
4435 api_sw_interface_dump (vat_main_t * vam)
4437 vl_api_sw_interface_dump_t *mp;
4440 name_sort_t *nses = 0, *ns;
4441 sw_interface_subif_t *sub = NULL;
4443 /* Toss the old name table */
4445 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4447 vec_add2 (nses, ns, 1);
4448 ns->name = (u8 *)(p->key);
4449 ns->value = (u32) p->value[0];
4453 hash_free (vam->sw_if_index_by_interface_name);
4455 vec_foreach (ns, nses) vec_free (ns->name);
4459 vec_foreach (sub, vam->sw_if_subif_table)
4461 vec_free (sub->interface_name);
4463 vec_free (vam->sw_if_subif_table);
4465 /* recreate the interface name hash table */
4466 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4468 /* Get list of ethernets */
4469 M (SW_INTERFACE_DUMP, sw_interface_dump);
4470 mp->name_filter_valid = 1;
4471 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4474 /* and local / loopback interfaces */
4475 M (SW_INTERFACE_DUMP, sw_interface_dump);
4476 mp->name_filter_valid = 1;
4477 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4480 /* and packet-generator interfaces */
4481 M (SW_INTERFACE_DUMP, sw_interface_dump);
4482 mp->name_filter_valid = 1;
4483 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4486 /* and vxlan-gpe tunnel interfaces */
4487 M (SW_INTERFACE_DUMP, sw_interface_dump);
4488 mp->name_filter_valid = 1;
4489 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4490 sizeof (mp->name_filter) - 1);
4493 /* and vxlan tunnel interfaces */
4494 M (SW_INTERFACE_DUMP, sw_interface_dump);
4495 mp->name_filter_valid = 1;
4496 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4499 /* and host (af_packet) interfaces */
4500 M (SW_INTERFACE_DUMP, sw_interface_dump);
4501 mp->name_filter_valid = 1;
4502 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4505 /* and l2tpv3 tunnel interfaces */
4506 M (SW_INTERFACE_DUMP, sw_interface_dump);
4507 mp->name_filter_valid = 1;
4508 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4509 sizeof (mp->name_filter) - 1);
4512 /* and GRE tunnel interfaces */
4513 M (SW_INTERFACE_DUMP, sw_interface_dump);
4514 mp->name_filter_valid = 1;
4515 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4518 /* and LISP-GPE interfaces */
4519 M (SW_INTERFACE_DUMP, sw_interface_dump);
4520 mp->name_filter_valid = 1;
4521 strncpy ((char *) mp->name_filter, "lisp_gpe",
4522 sizeof (mp->name_filter) - 1);
4525 /* and IPSEC tunnel interfaces */
4526 M (SW_INTERFACE_DUMP, sw_interface_dump);
4527 mp->name_filter_valid = 1;
4528 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4531 /* Use a control ping for synchronization */
4533 vl_api_control_ping_t *mp;
4534 M (CONTROL_PING, control_ping);
4541 api_sw_interface_set_flags (vat_main_t * vam)
4543 unformat_input_t *i = vam->input;
4544 vl_api_sw_interface_set_flags_t *mp;
4547 u8 sw_if_index_set = 0;
4548 u8 admin_up = 0, link_up = 0;
4550 /* Parse args required to build the message */
4551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4553 if (unformat (i, "admin-up"))
4555 else if (unformat (i, "admin-down"))
4557 else if (unformat (i, "link-up"))
4559 else if (unformat (i, "link-down"))
4561 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4562 sw_if_index_set = 1;
4563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4564 sw_if_index_set = 1;
4569 if (sw_if_index_set == 0)
4571 errmsg ("missing interface name or sw_if_index\n");
4575 /* Construct the API message */
4576 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4577 mp->sw_if_index = ntohl (sw_if_index);
4578 mp->admin_up_down = admin_up;
4579 mp->link_up_down = link_up;
4584 /* Wait for a reply, return the good/bad news... */
4589 api_sw_interface_clear_stats (vat_main_t * vam)
4591 unformat_input_t *i = vam->input;
4592 vl_api_sw_interface_clear_stats_t *mp;
4595 u8 sw_if_index_set = 0;
4597 /* Parse args required to build the message */
4598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4600 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4601 sw_if_index_set = 1;
4602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4603 sw_if_index_set = 1;
4608 /* Construct the API message */
4609 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4611 if (sw_if_index_set == 1)
4612 mp->sw_if_index = ntohl (sw_if_index);
4614 mp->sw_if_index = ~0;
4619 /* Wait for a reply, return the good/bad news... */
4624 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4626 unformat_input_t *i = vam->input;
4627 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4630 u8 sw_if_index_set = 0;
4638 /* Parse args required to build the message */
4639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4641 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4642 sw_if_index_set = 1;
4643 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4644 sw_if_index_set = 1;
4645 else if (unformat (i, "subport %u", &subport))
4647 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4648 sw_if_index_set = 1;
4649 else if (unformat (i, "pipe %u", &pipe))
4651 else if (unformat (i, "profile %u", &profile))
4657 if (sw_if_index_set == 0)
4659 errmsg ("missing interface name or sw_if_index\n");
4663 if (subport_set == 0)
4665 errmsg ("missing subport \n");
4671 errmsg ("missing pipe\n");
4675 if (profile_set == 0)
4677 errmsg ("missing profile\n");
4681 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4683 mp->sw_if_index = ntohl (sw_if_index);
4684 mp->subport = ntohl (subport);
4685 mp->pipe = ntohl (pipe);
4686 mp->profile = ntohl (profile);
4696 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4698 unformat_input_t *i = vam->input;
4699 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4702 u8 sw_if_index_set = 0;
4705 u32 tb_rate = 1250000000; /* 10GbE */
4706 u32 tb_size = 1000000;
4707 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4710 /* Parse args required to build the message */
4711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4713 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4714 sw_if_index_set = 1;
4715 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4716 sw_if_index_set = 1;
4717 else if (unformat (i, "subport %u", &subport))
4719 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4720 sw_if_index_set = 1;
4721 else if (unformat (i, "rate %u", &tb_rate))
4725 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4727 tc_rate[tc_id] = tb_rate;
4729 else if (unformat (i, "bktsize %u", &tb_size))
4731 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4733 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4735 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4737 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4739 else if (unformat (i, "period %u", &tc_period))
4745 if (sw_if_index_set == 0)
4747 errmsg ("missing interface name or sw_if_index\n");
4751 if (subport_set == 0)
4753 errmsg ("missing subport \n");
4757 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4759 mp->sw_if_index = ntohl (sw_if_index);
4760 mp->subport = ntohl (subport);
4761 mp->tb_rate = ntohl (tb_rate);
4762 mp->tb_size = ntohl (tb_size);
4763 mp->tc_rate[0] = ntohl (tc_rate[0]);
4764 mp->tc_rate[1] = ntohl (tc_rate[1]);
4765 mp->tc_rate[2] = ntohl (tc_rate[2]);
4766 mp->tc_rate[3] = ntohl (tc_rate[3]);
4767 mp->tc_period = ntohl (tc_period);
4776 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4778 unformat_input_t *i = vam->input;
4779 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4782 u8 sw_if_index_set = 0;
4786 u32 entry, tc, queue;
4788 /* Parse args required to build the message */
4789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4791 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4792 sw_if_index_set = 1;
4793 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4794 sw_if_index_set = 1;
4795 else if (unformat (i, "entry %d", &entry))
4797 else if (unformat (i, "tc %d", &tc))
4799 else if (unformat (i, "queue %d", &queue))
4805 if (sw_if_index_set == 0)
4807 errmsg ("missing interface name or sw_if_index\n");
4813 errmsg ("missing entry \n");
4819 errmsg ("missing traffic class \n");
4825 errmsg ("missing queue \n");
4829 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4831 mp->sw_if_index = ntohl (sw_if_index);
4832 mp->entry = ntohl (entry);
4833 mp->tc = ntohl (tc);
4834 mp->queue = ntohl (queue);
4843 api_sw_interface_add_del_address (vat_main_t * vam)
4845 unformat_input_t *i = vam->input;
4846 vl_api_sw_interface_add_del_address_t *mp;
4849 u8 sw_if_index_set = 0;
4850 u8 is_add = 1, del_all = 0;
4851 u32 address_length = 0;
4852 u8 v4_address_set = 0;
4853 u8 v6_address_set = 0;
4854 ip4_address_t v4address;
4855 ip6_address_t v6address;
4857 /* Parse args required to build the message */
4858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4860 if (unformat (i, "del-all"))
4862 else if (unformat (i, "del"))
4864 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4865 sw_if_index_set = 1;
4866 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4867 sw_if_index_set = 1;
4868 else if (unformat (i, "%U/%d",
4869 unformat_ip4_address, &v4address, &address_length))
4871 else if (unformat (i, "%U/%d",
4872 unformat_ip6_address, &v6address, &address_length))
4878 if (sw_if_index_set == 0)
4880 errmsg ("missing interface name or sw_if_index\n");
4883 if (v4_address_set && v6_address_set)
4885 errmsg ("both v4 and v6 addresses set\n");
4888 if (!v4_address_set && !v6_address_set && !del_all)
4890 errmsg ("no addresses set\n");
4894 /* Construct the API message */
4895 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4897 mp->sw_if_index = ntohl (sw_if_index);
4898 mp->is_add = is_add;
4899 mp->del_all = del_all;
4903 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4907 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4909 mp->address_length = address_length;
4914 /* Wait for a reply, return good/bad news */
4919 api_sw_interface_set_mpls_enable (vat_main_t * vam)
4921 unformat_input_t *i = vam->input;
4922 vl_api_sw_interface_set_mpls_enable_t *mp;
4925 u8 sw_if_index_set = 0;
4928 /* Parse args required to build the message */
4929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4931 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4932 sw_if_index_set = 1;
4933 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4934 sw_if_index_set = 1;
4935 else if (unformat (i, "disable"))
4937 else if (unformat (i, "dis"))
4943 if (sw_if_index_set == 0)
4945 errmsg ("missing interface name or sw_if_index\n");
4949 /* Construct the API message */
4950 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
4952 mp->sw_if_index = ntohl (sw_if_index);
4953 mp->enable = enable;
4958 /* Wait for a reply... */
4963 api_sw_interface_set_table (vat_main_t * vam)
4965 unformat_input_t *i = vam->input;
4966 vl_api_sw_interface_set_table_t *mp;
4968 u32 sw_if_index, vrf_id = 0;
4969 u8 sw_if_index_set = 0;
4972 /* Parse args required to build the message */
4973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4975 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4976 sw_if_index_set = 1;
4977 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4978 sw_if_index_set = 1;
4979 else if (unformat (i, "vrf %d", &vrf_id))
4981 else if (unformat (i, "ipv6"))
4987 if (sw_if_index_set == 0)
4989 errmsg ("missing interface name or sw_if_index\n");
4993 /* Construct the API message */
4994 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4996 mp->sw_if_index = ntohl (sw_if_index);
4997 mp->is_ipv6 = is_ipv6;
4998 mp->vrf_id = ntohl (vrf_id);
5003 /* Wait for a reply... */
5008 api_sw_interface_set_vpath (vat_main_t * vam)
5010 unformat_input_t *i = vam->input;
5011 vl_api_sw_interface_set_vpath_t *mp;
5013 u32 sw_if_index = 0;
5014 u8 sw_if_index_set = 0;
5017 /* Parse args required to build the message */
5018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5020 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5021 sw_if_index_set = 1;
5022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5023 sw_if_index_set = 1;
5024 else if (unformat (i, "enable"))
5026 else if (unformat (i, "disable"))
5032 if (sw_if_index_set == 0)
5034 errmsg ("missing interface name or sw_if_index\n");
5038 /* Construct the API message */
5039 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5041 mp->sw_if_index = ntohl (sw_if_index);
5042 mp->enable = is_enable;
5047 /* Wait for a reply... */
5052 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5054 unformat_input_t *i = vam->input;
5055 vl_api_sw_interface_set_l2_xconnect_t *mp;
5058 u8 rx_sw_if_index_set = 0;
5060 u8 tx_sw_if_index_set = 0;
5063 /* Parse args required to build the message */
5064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5066 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5067 rx_sw_if_index_set = 1;
5068 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5069 tx_sw_if_index_set = 1;
5070 else if (unformat (i, "rx"))
5072 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5074 if (unformat (i, "%U", unformat_sw_if_index, vam,
5076 rx_sw_if_index_set = 1;
5081 else if (unformat (i, "tx"))
5083 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5085 if (unformat (i, "%U", unformat_sw_if_index, vam,
5087 tx_sw_if_index_set = 1;
5092 else if (unformat (i, "enable"))
5094 else if (unformat (i, "disable"))
5100 if (rx_sw_if_index_set == 0)
5102 errmsg ("missing rx interface name or rx_sw_if_index\n");
5106 if (enable && (tx_sw_if_index_set == 0))
5108 errmsg ("missing tx interface name or tx_sw_if_index\n");
5112 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5114 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5115 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5116 mp->enable = enable;
5125 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5127 unformat_input_t *i = vam->input;
5128 vl_api_sw_interface_set_l2_bridge_t *mp;
5131 u8 rx_sw_if_index_set = 0;
5138 /* Parse args required to build the message */
5139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5141 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5142 rx_sw_if_index_set = 1;
5143 else if (unformat (i, "bd_id %d", &bd_id))
5145 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5146 rx_sw_if_index_set = 1;
5147 else if (unformat (i, "shg %d", &shg))
5149 else if (unformat (i, "bvi"))
5151 else if (unformat (i, "enable"))
5153 else if (unformat (i, "disable"))
5159 if (rx_sw_if_index_set == 0)
5161 errmsg ("missing rx interface name or sw_if_index\n");
5165 if (enable && (bd_id_set == 0))
5167 errmsg ("missing bridge domain\n");
5171 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5173 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5174 mp->bd_id = ntohl (bd_id);
5177 mp->enable = enable;
5186 api_bridge_domain_dump (vat_main_t * vam)
5188 unformat_input_t *i = vam->input;
5189 vl_api_bridge_domain_dump_t *mp;
5193 /* Parse args required to build the message */
5194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5196 if (unformat (i, "bd_id %d", &bd_id))
5202 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5203 mp->bd_id = ntohl (bd_id);
5206 /* Use a control ping for synchronization */
5208 vl_api_control_ping_t *mp;
5209 M (CONTROL_PING, control_ping);
5219 api_bridge_domain_add_del (vat_main_t * vam)
5221 unformat_input_t *i = vam->input;
5222 vl_api_bridge_domain_add_del_t *mp;
5226 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5228 /* Parse args required to build the message */
5229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5231 if (unformat (i, "bd_id %d", &bd_id))
5233 else if (unformat (i, "flood %d", &flood))
5235 else if (unformat (i, "uu-flood %d", &uu_flood))
5237 else if (unformat (i, "forward %d", &forward))
5239 else if (unformat (i, "learn %d", &learn))
5241 else if (unformat (i, "arp-term %d", &arp_term))
5243 else if (unformat (i, "del"))
5246 flood = uu_flood = forward = learn = 0;
5254 errmsg ("missing bridge domain\n");
5258 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5260 mp->bd_id = ntohl (bd_id);
5262 mp->uu_flood = uu_flood;
5263 mp->forward = forward;
5265 mp->arp_term = arp_term;
5266 mp->is_add = is_add;
5275 api_l2fib_add_del (vat_main_t * vam)
5277 unformat_input_t *i = vam->input;
5278 vl_api_l2fib_add_del_t *mp;
5285 u8 sw_if_index_set = 0;
5294 /* Parse args required to build the message */
5295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5297 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5299 else if (unformat (i, "bd_id %d", &bd_id))
5301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5302 sw_if_index_set = 1;
5303 else if (unformat (i, "sw_if"))
5305 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5307 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5308 sw_if_index_set = 1;
5313 else if (unformat (i, "static"))
5315 else if (unformat (i, "filter"))
5320 else if (unformat (i, "bvi"))
5325 else if (unformat (i, "del"))
5327 else if (unformat (i, "count %d", &count))
5335 errmsg ("missing mac address\n");
5341 errmsg ("missing bridge domain\n");
5345 if (is_add && (sw_if_index_set == 0))
5347 errmsg ("missing interface name or sw_if_index\n");
5353 /* Turn on async mode */
5354 vam->async_mode = 1;
5355 vam->async_errors = 0;
5356 before = vat_time_now (vam);
5359 for (j = 0; j < count; j++)
5361 M (L2FIB_ADD_DEL, l2fib_add_del);
5364 mp->bd_id = ntohl (bd_id);
5365 mp->is_add = is_add;
5369 mp->sw_if_index = ntohl (sw_if_index);
5370 mp->static_mac = static_mac;
5371 mp->filter_mac = filter_mac;
5372 mp->bvi_mac = bvi_mac;
5374 increment_mac_address (&mac);
5381 vl_api_control_ping_t *mp;
5384 /* Shut off async mode */
5385 vam->async_mode = 0;
5387 M (CONTROL_PING, control_ping);
5390 timeout = vat_time_now (vam) + 1.0;
5391 while (vat_time_now (vam) < timeout)
5392 if (vam->result_ready == 1)
5397 if (vam->retval == -99)
5398 errmsg ("timeout\n");
5400 if (vam->async_errors > 0)
5402 errmsg ("%d asynchronous errors\n", vam->async_errors);
5405 vam->async_errors = 0;
5406 after = vat_time_now (vam);
5408 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5409 count, after - before, count / (after - before));
5413 /* Wait for a reply... */
5416 /* Return the good/bad news */
5417 return (vam->retval);
5421 api_l2_flags (vat_main_t * vam)
5423 unformat_input_t *i = vam->input;
5424 vl_api_l2_flags_t *mp;
5427 u32 feature_bitmap = 0;
5428 u8 sw_if_index_set = 0;
5430 /* Parse args required to build the message */
5431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5433 if (unformat (i, "sw_if_index %d", &sw_if_index))
5434 sw_if_index_set = 1;
5435 else if (unformat (i, "sw_if"))
5437 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5439 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5440 sw_if_index_set = 1;
5445 else if (unformat (i, "learn"))
5446 feature_bitmap |= L2INPUT_FEAT_LEARN;
5447 else if (unformat (i, "forward"))
5448 feature_bitmap |= L2INPUT_FEAT_FWD;
5449 else if (unformat (i, "flood"))
5450 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5451 else if (unformat (i, "uu-flood"))
5452 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5457 if (sw_if_index_set == 0)
5459 errmsg ("missing interface name or sw_if_index\n");
5463 M (L2_FLAGS, l2_flags);
5465 mp->sw_if_index = ntohl (sw_if_index);
5466 mp->feature_bitmap = ntohl (feature_bitmap);
5475 api_bridge_flags (vat_main_t * vam)
5477 unformat_input_t *i = vam->input;
5478 vl_api_bridge_flags_t *mp;
5485 /* Parse args required to build the message */
5486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5488 if (unformat (i, "bd_id %d", &bd_id))
5490 else if (unformat (i, "learn"))
5492 else if (unformat (i, "forward"))
5494 else if (unformat (i, "flood"))
5496 else if (unformat (i, "uu-flood"))
5497 flags |= L2_UU_FLOOD;
5498 else if (unformat (i, "arp-term"))
5499 flags |= L2_ARP_TERM;
5500 else if (unformat (i, "off"))
5502 else if (unformat (i, "disable"))
5510 errmsg ("missing bridge domain\n");
5514 M (BRIDGE_FLAGS, bridge_flags);
5516 mp->bd_id = ntohl (bd_id);
5517 mp->feature_bitmap = ntohl (flags);
5518 mp->is_set = is_set;
5527 api_bd_ip_mac_add_del (vat_main_t * vam)
5529 unformat_input_t *i = vam->input;
5530 vl_api_bd_ip_mac_add_del_t *mp;
5538 ip4_address_t v4addr;
5539 ip6_address_t v6addr;
5543 /* Parse args required to build the message */
5544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5546 if (unformat (i, "bd_id %d", &bd_id))
5550 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5554 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5559 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5563 else if (unformat (i, "del"))
5571 errmsg ("missing bridge domain\n");
5574 else if (ip_set == 0)
5576 errmsg ("missing IP address\n");
5579 else if (mac_set == 0)
5581 errmsg ("missing MAC address\n");
5585 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5587 mp->bd_id = ntohl (bd_id);
5588 mp->is_ipv6 = is_ipv6;
5589 mp->is_add = is_add;
5591 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5593 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5594 clib_memcpy (mp->mac_address, macaddr, 6);
5602 api_tap_connect (vat_main_t * vam)
5604 unformat_input_t *i = vam->input;
5605 vl_api_tap_connect_t *mp;
5612 memset (mac_address, 0, sizeof (mac_address));
5614 /* Parse args required to build the message */
5615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5617 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5621 else if (unformat (i, "random-mac"))
5623 else if (unformat (i, "tapname %s", &tap_name))
5631 errmsg ("missing tap name\n");
5634 if (vec_len (tap_name) > 63)
5636 errmsg ("tap name too long\n");
5638 vec_add1 (tap_name, 0);
5640 /* Construct the API message */
5641 M (TAP_CONNECT, tap_connect);
5643 mp->use_random_mac = random_mac;
5644 clib_memcpy (mp->mac_address, mac_address, 6);
5645 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5646 vec_free (tap_name);
5651 /* Wait for a reply... */
5656 api_tap_modify (vat_main_t * vam)
5658 unformat_input_t *i = vam->input;
5659 vl_api_tap_modify_t *mp;
5665 u32 sw_if_index = ~0;
5666 u8 sw_if_index_set = 0;
5668 memset (mac_address, 0, sizeof (mac_address));
5670 /* Parse args required to build the message */
5671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5673 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5674 sw_if_index_set = 1;
5675 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5676 sw_if_index_set = 1;
5677 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5681 else if (unformat (i, "random-mac"))
5683 else if (unformat (i, "tapname %s", &tap_name))
5689 if (sw_if_index_set == 0)
5691 errmsg ("missing vpp interface name");
5696 errmsg ("missing tap name\n");
5699 if (vec_len (tap_name) > 63)
5701 errmsg ("tap name too long\n");
5703 vec_add1 (tap_name, 0);
5705 /* Construct the API message */
5706 M (TAP_MODIFY, tap_modify);
5708 mp->use_random_mac = random_mac;
5709 mp->sw_if_index = ntohl (sw_if_index);
5710 clib_memcpy (mp->mac_address, mac_address, 6);
5711 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5712 vec_free (tap_name);
5717 /* Wait for a reply... */
5722 api_tap_delete (vat_main_t * vam)
5724 unformat_input_t *i = vam->input;
5725 vl_api_tap_delete_t *mp;
5727 u32 sw_if_index = ~0;
5728 u8 sw_if_index_set = 0;
5730 /* Parse args required to build the message */
5731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5733 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5734 sw_if_index_set = 1;
5735 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5736 sw_if_index_set = 1;
5741 if (sw_if_index_set == 0)
5743 errmsg ("missing vpp interface name");
5747 /* Construct the API message */
5748 M (TAP_DELETE, tap_delete);
5750 mp->sw_if_index = ntohl (sw_if_index);
5755 /* Wait for a reply... */
5760 api_ip_add_del_route (vat_main_t * vam)
5762 unformat_input_t *i = vam->input;
5763 vl_api_ip_add_del_route_t *mp;
5765 u32 sw_if_index = ~0, vrf_id = 0;
5766 u8 sw_if_index_set = 0;
5768 u8 is_local = 0, is_drop = 0;
5769 u8 is_unreach = 0, is_prohibit = 0;
5770 u8 create_vrf_if_needed = 0;
5772 u32 next_hop_weight = 1;
5774 u8 is_multipath = 0;
5776 u8 address_length_set = 0;
5777 u32 next_hop_table_id = 0;
5778 u32 resolve_attempts = 0;
5779 u32 dst_address_length = 0;
5780 u8 next_hop_set = 0;
5781 ip4_address_t v4_dst_address, v4_next_hop_address;
5782 ip6_address_t v6_dst_address, v6_next_hop_address;
5786 u32 random_add_del = 0;
5787 u32 *random_vector = 0;
5789 u32 random_seed = 0xdeaddabe;
5790 u32 classify_table_index = ~0;
5792 u8 resolve_host = 0, resolve_attached = 0;
5793 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
5795 /* Parse args required to build the message */
5796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5798 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5799 sw_if_index_set = 1;
5800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5801 sw_if_index_set = 1;
5802 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5807 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5812 else if (unformat (i, "/%d", &dst_address_length))
5814 address_length_set = 1;
5817 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5818 &v4_next_hop_address))
5822 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5823 &v6_next_hop_address))
5827 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5829 else if (unformat (i, "weight %d", &next_hop_weight))
5831 else if (unformat (i, "drop"))
5835 else if (unformat (i, "null-send-unreach"))
5839 else if (unformat (i, "null-send-prohibit"))
5843 else if (unformat (i, "local"))
5847 else if (unformat (i, "classify %d", &classify_table_index))
5851 else if (unformat (i, "del"))
5853 else if (unformat (i, "add"))
5855 else if (unformat (i, "not-last"))
5857 else if (unformat (i, "resolve-via-host"))
5859 else if (unformat (i, "resolve-via-attached"))
5860 resolve_attached = 1;
5861 else if (unformat (i, "multipath"))
5863 else if (unformat (i, "vrf %d", &vrf_id))
5865 else if (unformat (i, "create-vrf"))
5866 create_vrf_if_needed = 1;
5867 else if (unformat (i, "count %d", &count))
5869 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
5871 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
5873 else if (unformat (i, "out-label %d", &next_hop_out_label))
5875 else if (unformat (i, "random"))
5877 else if (unformat (i, "seed %d", &random_seed))
5881 clib_warning ("parse error '%U'", format_unformat_error, i);
5886 if (resolve_attempts > 0 && sw_if_index_set == 0)
5888 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5892 if (!next_hop_set && !is_drop && !is_local &&
5893 !is_classify && !is_unreach && !is_prohibit)
5896 ("next hop / local / drop / unreach / prohibit / classify not set\n");
5900 if (address_set == 0)
5902 errmsg ("missing addresses\n");
5906 if (address_length_set == 0)
5908 errmsg ("missing address length\n");
5912 /* Generate a pile of unique, random routes */
5915 u32 this_random_address;
5916 random_hash = hash_create (count, sizeof (uword));
5918 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5919 for (j = 0; j <= count; j++)
5923 this_random_address = random_u32 (&random_seed);
5924 this_random_address =
5925 clib_host_to_net_u32 (this_random_address);
5927 while (hash_get (random_hash, this_random_address));
5928 vec_add1 (random_vector, this_random_address);
5929 hash_set (random_hash, this_random_address, 1);
5931 hash_free (random_hash);
5932 v4_dst_address.as_u32 = random_vector[0];
5937 /* Turn on async mode */
5938 vam->async_mode = 1;
5939 vam->async_errors = 0;
5940 before = vat_time_now (vam);
5943 for (j = 0; j < count; j++)
5945 /* Construct the API message */
5946 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5948 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5949 mp->table_id = ntohl (vrf_id);
5950 if (resolve_attempts > 0)
5952 mp->resolve_attempts = ntohl (resolve_attempts);
5953 mp->resolve_if_needed = 1;
5955 mp->create_vrf_if_needed = create_vrf_if_needed;
5957 mp->is_add = is_add;
5958 mp->is_drop = is_drop;
5959 mp->is_unreach = is_unreach;
5960 mp->is_prohibit = is_prohibit;
5961 mp->is_ipv6 = is_ipv6;
5962 mp->is_local = is_local;
5963 mp->is_classify = is_classify;
5964 mp->is_multipath = is_multipath;
5965 mp->is_resolve_host = resolve_host;
5966 mp->is_resolve_attached = resolve_attached;
5967 mp->not_last = not_last;
5968 mp->next_hop_weight = next_hop_weight;
5969 mp->dst_address_length = dst_address_length;
5970 mp->next_hop_table_id = ntohl (next_hop_table_id);
5971 mp->classify_table_index = ntohl (classify_table_index);
5972 mp->next_hop_out_label = ntohl (next_hop_out_label);
5976 clib_memcpy (mp->dst_address, &v6_dst_address,
5977 sizeof (v6_dst_address));
5979 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5980 sizeof (v6_next_hop_address));
5981 increment_v6_address (&v6_dst_address);
5985 clib_memcpy (mp->dst_address, &v4_dst_address,
5986 sizeof (v4_dst_address));
5988 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5989 sizeof (v4_next_hop_address));
5991 v4_dst_address.as_u32 = random_vector[j + 1];
5993 increment_v4_address (&v4_dst_address);
5997 /* If we receive SIGTERM, stop now... */
6002 /* When testing multiple add/del ops, use a control-ping to sync */
6005 vl_api_control_ping_t *mp;
6008 /* Shut off async mode */
6009 vam->async_mode = 0;
6011 M (CONTROL_PING, control_ping);
6014 timeout = vat_time_now (vam) + 1.0;
6015 while (vat_time_now (vam) < timeout)
6016 if (vam->result_ready == 1)
6021 if (vam->retval == -99)
6022 errmsg ("timeout\n");
6024 if (vam->async_errors > 0)
6026 errmsg ("%d asynchronous errors\n", vam->async_errors);
6029 vam->async_errors = 0;
6030 after = vat_time_now (vam);
6032 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6036 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6037 count, after - before, count / (after - before));
6041 /* Wait for a reply... */
6045 /* Return the good/bad news */
6046 return (vam->retval);
6050 api_mpls_route_add_del (vat_main_t * vam)
6052 unformat_input_t *i = vam->input;
6053 vl_api_mpls_route_add_del_t *mp;
6055 u32 sw_if_index = ~0, table_id = 0;
6056 u8 create_table_if_needed = 0;
6058 u32 next_hop_weight = 1;
6059 u8 is_multipath = 0;
6060 u32 next_hop_table_id = 0;
6061 u8 next_hop_set = 0;
6062 ip4_address_t v4_next_hop_address = {
6065 ip6_address_t v6_next_hop_address = { {0} };
6069 u32 classify_table_index = ~0;
6071 u8 resolve_host = 0, resolve_attached = 0;
6072 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6073 mpls_label_t local_label = MPLS_LABEL_INVALID;
6075 u8 next_hop_proto_is_ip4 = 1;
6077 /* Parse args required to build the message */
6078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6080 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6082 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6084 else if (unformat (i, "%d", &local_label))
6086 else if (unformat (i, "eos"))
6088 else if (unformat (i, "non-eos"))
6090 else if (unformat (i, "via %U", unformat_ip4_address,
6091 &v4_next_hop_address))
6094 next_hop_proto_is_ip4 = 1;
6096 else if (unformat (i, "via %U", unformat_ip6_address,
6097 &v6_next_hop_address))
6100 next_hop_proto_is_ip4 = 0;
6102 else if (unformat (i, "weight %d", &next_hop_weight))
6104 else if (unformat (i, "create-table"))
6105 create_table_if_needed = 1;
6106 else if (unformat (i, "classify %d", &classify_table_index))
6110 else if (unformat (i, "del"))
6112 else if (unformat (i, "add"))
6114 else if (unformat (i, "resolve-via-host"))
6116 else if (unformat (i, "resolve-via-attached"))
6117 resolve_attached = 1;
6118 else if (unformat (i, "multipath"))
6120 else if (unformat (i, "count %d", &count))
6122 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6125 next_hop_proto_is_ip4 = 1;
6127 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6130 next_hop_proto_is_ip4 = 0;
6132 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6134 else if (unformat (i, "out-label %d", &next_hop_out_label))
6138 clib_warning ("parse error '%U'", format_unformat_error, i);
6143 if (!next_hop_set && !is_classify)
6145 errmsg ("next hop / classify not set\n");
6149 if (MPLS_LABEL_INVALID == local_label)
6151 errmsg ("missing label\n");
6157 /* Turn on async mode */
6158 vam->async_mode = 1;
6159 vam->async_errors = 0;
6160 before = vat_time_now (vam);
6163 for (j = 0; j < count; j++)
6165 /* Construct the API message */
6166 M (MPLS_ROUTE_ADD_DEL, mpls_route_add_del);
6168 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6169 mp->mr_table_id = ntohl (table_id);
6170 mp->mr_create_table_if_needed = create_table_if_needed;
6172 mp->mr_is_add = is_add;
6173 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6174 mp->mr_is_classify = is_classify;
6175 mp->mr_is_multipath = is_multipath;
6176 mp->mr_is_resolve_host = resolve_host;
6177 mp->mr_is_resolve_attached = resolve_attached;
6178 mp->mr_next_hop_weight = next_hop_weight;
6179 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6180 mp->mr_classify_table_index = ntohl (classify_table_index);
6181 mp->mr_next_hop_out_label = ntohl (next_hop_out_label);
6182 mp->mr_label = ntohl (local_label);
6183 mp->mr_eos = is_eos;
6187 if (next_hop_proto_is_ip4)
6189 clib_memcpy (mp->mr_next_hop,
6190 &v4_next_hop_address,
6191 sizeof (v4_next_hop_address));
6195 clib_memcpy (mp->mr_next_hop,
6196 &v6_next_hop_address,
6197 sizeof (v6_next_hop_address));
6204 /* If we receive SIGTERM, stop now... */
6209 /* When testing multiple add/del ops, use a control-ping to sync */
6212 vl_api_control_ping_t *mp;
6215 /* Shut off async mode */
6216 vam->async_mode = 0;
6218 M (CONTROL_PING, control_ping);
6221 timeout = vat_time_now (vam) + 1.0;
6222 while (vat_time_now (vam) < timeout)
6223 if (vam->result_ready == 1)
6228 if (vam->retval == -99)
6229 errmsg ("timeout\n");
6231 if (vam->async_errors > 0)
6233 errmsg ("%d asynchronous errors\n", vam->async_errors);
6236 vam->async_errors = 0;
6237 after = vat_time_now (vam);
6239 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6243 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6244 count, after - before, count / (after - before));
6248 /* Wait for a reply... */
6252 /* Return the good/bad news */
6253 return (vam->retval);
6257 api_mpls_ip_bind_unbind (vat_main_t * vam)
6259 unformat_input_t *i = vam->input;
6260 vl_api_mpls_ip_bind_unbind_t *mp;
6262 u32 ip_table_id = 0;
6263 u8 create_table_if_needed = 0;
6266 ip4_address_t v4_address;
6267 ip6_address_t v6_address;
6270 mpls_label_t local_label = MPLS_LABEL_INVALID;
6272 /* Parse args required to build the message */
6273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6275 if (unformat (i, "%U/%d", unformat_ip4_address,
6276 &v4_address, &address_length))
6281 else if (unformat (i, "%U/%d", unformat_ip6_address,
6282 &v6_address, &address_length))
6287 else if (unformat (i, "%d", &local_label))
6289 else if (unformat (i, "create-table"))
6290 create_table_if_needed = 1;
6291 else if (unformat (i, "table-id %d", &ip_table_id))
6293 else if (unformat (i, "unbind"))
6295 else if (unformat (i, "bind"))
6299 clib_warning ("parse error '%U'", format_unformat_error, i);
6306 errmsg ("IP addres not set\n");
6310 if (MPLS_LABEL_INVALID == local_label)
6312 errmsg ("missing label\n");
6316 /* Construct the API message */
6317 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6319 mp->mb_create_table_if_needed = create_table_if_needed;
6320 mp->mb_is_bind = is_bind;
6321 mp->mb_is_ip4 = is_ip4;
6322 mp->mb_ip_table_id = ntohl (ip_table_id);
6323 mp->mb_mpls_table_id = 0;
6324 mp->mb_label = ntohl (local_label);
6325 mp->mb_address_length = address_length;
6328 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6330 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6335 /* Wait for a reply... */
6340 api_proxy_arp_add_del (vat_main_t * vam)
6342 unformat_input_t *i = vam->input;
6343 vl_api_proxy_arp_add_del_t *mp;
6347 ip4_address_t lo, hi;
6350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6352 if (unformat (i, "vrf %d", &vrf_id))
6354 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6355 unformat_ip4_address, &hi))
6357 else if (unformat (i, "del"))
6361 clib_warning ("parse error '%U'", format_unformat_error, i);
6368 errmsg ("address range not set\n");
6372 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6374 mp->vrf_id = ntohl (vrf_id);
6375 mp->is_add = is_add;
6376 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6377 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6386 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6388 unformat_input_t *i = vam->input;
6389 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6393 u8 sw_if_index_set = 0;
6395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6397 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6398 sw_if_index_set = 1;
6399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6400 sw_if_index_set = 1;
6401 else if (unformat (i, "enable"))
6403 else if (unformat (i, "disable"))
6407 clib_warning ("parse error '%U'", format_unformat_error, i);
6412 if (sw_if_index_set == 0)
6414 errmsg ("missing interface name or sw_if_index\n");
6418 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6420 mp->sw_if_index = ntohl (sw_if_index);
6421 mp->enable_disable = enable;
6430 api_mpls_add_del_encap (vat_main_t * vam)
6432 unformat_input_t *i = vam->input;
6433 vl_api_mpls_add_del_encap_t *mp;
6438 ip4_address_t dst_address;
6441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6443 if (unformat (i, "vrf %d", &vrf_id))
6445 else if (unformat (i, "label %d", &label))
6446 vec_add1 (labels, ntohl (label));
6447 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6449 else if (unformat (i, "del"))
6453 clib_warning ("parse error '%U'", format_unformat_error, i);
6458 if (vec_len (labels) == 0)
6460 errmsg ("missing encap label stack\n");
6464 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
6465 sizeof (u32) * vec_len (labels));
6467 mp->vrf_id = ntohl (vrf_id);
6468 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6469 mp->is_add = is_add;
6470 mp->nlabels = vec_len (labels);
6471 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
6482 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
6484 unformat_input_t *i = vam->input;
6485 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
6487 u32 inner_vrf_id = 0;
6488 ip4_address_t intfc_address;
6489 u8 dst_mac_address[6];
6492 u8 intfc_address_length = 0;
6496 int tx_sw_if_index_set = 0;
6498 /* Shut up coverity */
6499 memset (dst_mac_address, 0, sizeof (dst_mac_address));
6501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6503 if (unformat (i, "vrf %d", &inner_vrf_id))
6505 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6506 &intfc_address, &tmp))
6507 intfc_address_length = tmp;
6508 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
6509 tx_sw_if_index_set = 1;
6510 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6511 tx_sw_if_index_set = 1;
6512 else if (unformat (i, "dst %U", unformat_ethernet_address,
6515 else if (unformat (i, "l2-only"))
6517 else if (unformat (i, "del"))
6521 clib_warning ("parse error '%U'", format_unformat_error, i);
6528 errmsg ("dst (mac address) not set\n");
6531 if (!tx_sw_if_index_set)
6533 errmsg ("tx-intfc not set\n");
6537 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
6539 mp->vrf_id = ntohl (inner_vrf_id);
6540 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
6541 mp->adj_address_length = intfc_address_length;
6542 clib_memcpy (mp->dst_mac_address, dst_mac_address,
6543 sizeof (dst_mac_address));
6544 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6545 mp->l2_only = l2_only;
6546 mp->is_add = is_add;
6555 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
6557 unformat_input_t *i = vam->input;
6558 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
6560 u32 inner_vrf_id = 0;
6561 u32 outer_vrf_id = 0;
6562 ip4_address_t adj_address;
6563 int adj_address_set = 0;
6564 ip4_address_t next_hop_address;
6565 int next_hop_address_set = 0;
6567 u8 adj_address_length = 0;
6570 u32 resolve_attempts = 5;
6571 u8 resolve_if_needed = 1;
6573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6575 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6577 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6579 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6580 &adj_address, &tmp))
6582 adj_address_length = tmp;
6583 adj_address_set = 1;
6585 else if (unformat (i, "next-hop %U", unformat_ip4_address,
6587 next_hop_address_set = 1;
6588 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6590 else if (unformat (i, "resolve-if-needed %d", &tmp))
6591 resolve_if_needed = tmp;
6592 else if (unformat (i, "l2-only"))
6594 else if (unformat (i, "del"))
6598 clib_warning ("parse error '%U'", format_unformat_error, i);
6603 if (!adj_address_set)
6605 errmsg ("adjacency address/mask not set\n");
6608 if (!next_hop_address_set)
6610 errmsg ("ip4 next hop address (in outer fib) not set\n");
6614 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
6616 mp->inner_vrf_id = ntohl (inner_vrf_id);
6617 mp->outer_vrf_id = ntohl (outer_vrf_id);
6618 mp->resolve_attempts = ntohl (resolve_attempts);
6619 mp->resolve_if_needed = resolve_if_needed;
6620 mp->is_add = is_add;
6621 mp->l2_only = l2_only;
6622 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
6623 mp->adj_address_length = adj_address_length;
6624 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
6625 sizeof (next_hop_address));
6634 api_sw_interface_set_unnumbered (vat_main_t * vam)
6636 unformat_input_t *i = vam->input;
6637 vl_api_sw_interface_set_unnumbered_t *mp;
6640 u32 unnum_sw_index = ~0;
6642 u8 sw_if_index_set = 0;
6644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6646 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6647 sw_if_index_set = 1;
6648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6649 sw_if_index_set = 1;
6650 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6652 else if (unformat (i, "del"))
6656 clib_warning ("parse error '%U'", format_unformat_error, i);
6661 if (sw_if_index_set == 0)
6663 errmsg ("missing interface name or sw_if_index\n");
6667 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6669 mp->sw_if_index = ntohl (sw_if_index);
6670 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6671 mp->is_add = is_add;
6680 api_ip_neighbor_add_del (vat_main_t * vam)
6682 unformat_input_t *i = vam->input;
6683 vl_api_ip_neighbor_add_del_t *mp;
6686 u8 sw_if_index_set = 0;
6692 u8 v4_address_set = 0;
6693 u8 v6_address_set = 0;
6694 ip4_address_t v4address;
6695 ip6_address_t v6address;
6697 memset (mac_address, 0, sizeof (mac_address));
6699 /* Parse args required to build the message */
6700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6702 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6706 else if (unformat (i, "del"))
6708 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6709 sw_if_index_set = 1;
6710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6711 sw_if_index_set = 1;
6712 else if (unformat (i, "is_static"))
6714 else if (unformat (i, "vrf %d", &vrf_id))
6716 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6718 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6722 clib_warning ("parse error '%U'", format_unformat_error, i);
6727 if (sw_if_index_set == 0)
6729 errmsg ("missing interface name or sw_if_index\n");
6732 if (v4_address_set && v6_address_set)
6734 errmsg ("both v4 and v6 addresses set\n");
6737 if (!v4_address_set && !v6_address_set)
6739 errmsg ("no address set\n");
6743 /* Construct the API message */
6744 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6746 mp->sw_if_index = ntohl (sw_if_index);
6747 mp->is_add = is_add;
6748 mp->vrf_id = ntohl (vrf_id);
6749 mp->is_static = is_static;
6751 clib_memcpy (mp->mac_address, mac_address, 6);
6755 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6759 /* mp->is_ipv6 = 0; via memset in M macro above */
6760 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6766 /* Wait for a reply, return good/bad news */
6774 api_reset_vrf (vat_main_t * vam)
6776 unformat_input_t *i = vam->input;
6777 vl_api_reset_vrf_t *mp;
6783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6785 if (unformat (i, "vrf %d", &vrf_id))
6787 else if (unformat (i, "ipv6"))
6791 clib_warning ("parse error '%U'", format_unformat_error, i);
6796 if (vrf_id_set == 0)
6798 errmsg ("missing vrf id\n");
6802 M (RESET_VRF, reset_vrf);
6804 mp->vrf_id = ntohl (vrf_id);
6805 mp->is_ipv6 = is_ipv6;
6814 api_create_vlan_subif (vat_main_t * vam)
6816 unformat_input_t *i = vam->input;
6817 vl_api_create_vlan_subif_t *mp;
6820 u8 sw_if_index_set = 0;
6824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6826 if (unformat (i, "sw_if_index %d", &sw_if_index))
6827 sw_if_index_set = 1;
6828 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6829 sw_if_index_set = 1;
6830 else if (unformat (i, "vlan %d", &vlan_id))
6834 clib_warning ("parse error '%U'", format_unformat_error, i);
6839 if (sw_if_index_set == 0)
6841 errmsg ("missing interface name or sw_if_index\n");
6845 if (vlan_id_set == 0)
6847 errmsg ("missing vlan_id\n");
6850 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6852 mp->sw_if_index = ntohl (sw_if_index);
6853 mp->vlan_id = ntohl (vlan_id);
6861 #define foreach_create_subif_bit \
6868 _(outer_vlan_id_any) \
6869 _(inner_vlan_id_any)
6872 api_create_subif (vat_main_t * vam)
6874 unformat_input_t *i = vam->input;
6875 vl_api_create_subif_t *mp;
6878 u8 sw_if_index_set = 0;
6885 u32 exact_match = 0;
6886 u32 default_sub = 0;
6887 u32 outer_vlan_id_any = 0;
6888 u32 inner_vlan_id_any = 0;
6890 u16 outer_vlan_id = 0;
6891 u16 inner_vlan_id = 0;
6893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6895 if (unformat (i, "sw_if_index %d", &sw_if_index))
6896 sw_if_index_set = 1;
6897 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6898 sw_if_index_set = 1;
6899 else if (unformat (i, "sub_id %d", &sub_id))
6901 else if (unformat (i, "outer_vlan_id %d", &tmp))
6902 outer_vlan_id = tmp;
6903 else if (unformat (i, "inner_vlan_id %d", &tmp))
6904 inner_vlan_id = tmp;
6906 #define _(a) else if (unformat (i, #a)) a = 1 ;
6907 foreach_create_subif_bit
6911 clib_warning ("parse error '%U'", format_unformat_error, i);
6916 if (sw_if_index_set == 0)
6918 errmsg ("missing interface name or sw_if_index\n");
6922 if (sub_id_set == 0)
6924 errmsg ("missing sub_id\n");
6927 M (CREATE_SUBIF, create_subif);
6929 mp->sw_if_index = ntohl (sw_if_index);
6930 mp->sub_id = ntohl (sub_id);
6932 #define _(a) mp->a = a;
6933 foreach_create_subif_bit;
6936 mp->outer_vlan_id = ntohs (outer_vlan_id);
6937 mp->inner_vlan_id = ntohs (inner_vlan_id);
6946 api_oam_add_del (vat_main_t * vam)
6948 unformat_input_t *i = vam->input;
6949 vl_api_oam_add_del_t *mp;
6953 ip4_address_t src, dst;
6957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6959 if (unformat (i, "vrf %d", &vrf_id))
6961 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6963 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6965 else if (unformat (i, "del"))
6969 clib_warning ("parse error '%U'", format_unformat_error, i);
6976 errmsg ("missing src addr\n");
6982 errmsg ("missing dst addr\n");
6986 M (OAM_ADD_DEL, oam_add_del);
6988 mp->vrf_id = ntohl (vrf_id);
6989 mp->is_add = is_add;
6990 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6991 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7000 api_reset_fib (vat_main_t * vam)
7002 unformat_input_t *i = vam->input;
7003 vl_api_reset_fib_t *mp;
7009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7011 if (unformat (i, "vrf %d", &vrf_id))
7013 else if (unformat (i, "ipv6"))
7017 clib_warning ("parse error '%U'", format_unformat_error, i);
7022 if (vrf_id_set == 0)
7024 errmsg ("missing vrf id\n");
7028 M (RESET_FIB, reset_fib);
7030 mp->vrf_id = ntohl (vrf_id);
7031 mp->is_ipv6 = is_ipv6;
7040 api_dhcp_proxy_config (vat_main_t * vam)
7042 unformat_input_t *i = vam->input;
7043 vl_api_dhcp_proxy_config_t *mp;
7048 u8 v4_address_set = 0;
7049 u8 v6_address_set = 0;
7050 ip4_address_t v4address;
7051 ip6_address_t v6address;
7052 u8 v4_src_address_set = 0;
7053 u8 v6_src_address_set = 0;
7054 ip4_address_t v4srcaddress;
7055 ip6_address_t v6srcaddress;
7057 /* Parse args required to build the message */
7058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7060 if (unformat (i, "del"))
7062 else if (unformat (i, "vrf %d", &vrf_id))
7064 else if (unformat (i, "insert-cid %d", &insert_cid))
7066 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7068 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7070 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7071 v4_src_address_set = 1;
7072 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7073 v6_src_address_set = 1;
7078 if (v4_address_set && v6_address_set)
7080 errmsg ("both v4 and v6 server addresses set\n");
7083 if (!v4_address_set && !v6_address_set)
7085 errmsg ("no server addresses set\n");
7089 if (v4_src_address_set && v6_src_address_set)
7091 errmsg ("both v4 and v6 src addresses set\n");
7094 if (!v4_src_address_set && !v6_src_address_set)
7096 errmsg ("no src addresses set\n");
7100 if (!(v4_src_address_set && v4_address_set) &&
7101 !(v6_src_address_set && v6_address_set))
7103 errmsg ("no matching server and src addresses set\n");
7107 /* Construct the API message */
7108 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7110 mp->insert_circuit_id = insert_cid;
7111 mp->is_add = is_add;
7112 mp->vrf_id = ntohl (vrf_id);
7116 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7117 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7121 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7122 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7128 /* Wait for a reply, return good/bad news */
7135 api_dhcp_proxy_config_2 (vat_main_t * vam)
7137 unformat_input_t *i = vam->input;
7138 vl_api_dhcp_proxy_config_2_t *mp;
7141 u32 server_vrf_id = 0;
7144 u8 v4_address_set = 0;
7145 u8 v6_address_set = 0;
7146 ip4_address_t v4address;
7147 ip6_address_t v6address;
7148 u8 v4_src_address_set = 0;
7149 u8 v6_src_address_set = 0;
7150 ip4_address_t v4srcaddress;
7151 ip6_address_t v6srcaddress;
7153 /* Parse args required to build the message */
7154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7156 if (unformat (i, "del"))
7158 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7160 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7162 else if (unformat (i, "insert-cid %d", &insert_cid))
7164 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7166 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7168 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7169 v4_src_address_set = 1;
7170 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7171 v6_src_address_set = 1;
7176 if (v4_address_set && v6_address_set)
7178 errmsg ("both v4 and v6 server addresses set\n");
7181 if (!v4_address_set && !v6_address_set)
7183 errmsg ("no server addresses set\n");
7187 if (v4_src_address_set && v6_src_address_set)
7189 errmsg ("both v4 and v6 src addresses set\n");
7192 if (!v4_src_address_set && !v6_src_address_set)
7194 errmsg ("no src addresses set\n");
7198 if (!(v4_src_address_set && v4_address_set) &&
7199 !(v6_src_address_set && v6_address_set))
7201 errmsg ("no matching server and src addresses set\n");
7205 /* Construct the API message */
7206 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7208 mp->insert_circuit_id = insert_cid;
7209 mp->is_add = is_add;
7210 mp->rx_vrf_id = ntohl (rx_vrf_id);
7211 mp->server_vrf_id = ntohl (server_vrf_id);
7215 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7216 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7220 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7221 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7227 /* Wait for a reply, return good/bad news */
7234 api_dhcp_proxy_set_vss (vat_main_t * vam)
7236 unformat_input_t *i = vam->input;
7237 vl_api_dhcp_proxy_set_vss_t *mp;
7248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7250 if (unformat (i, "tbl_id %d", &tbl_id))
7252 if (unformat (i, "fib_id %d", &fib_id))
7254 if (unformat (i, "oui %d", &oui))
7256 else if (unformat (i, "ipv6"))
7258 else if (unformat (i, "del"))
7262 clib_warning ("parse error '%U'", format_unformat_error, i);
7267 if (tbl_id_set == 0)
7269 errmsg ("missing tbl id\n");
7273 if (fib_id_set == 0)
7275 errmsg ("missing fib id\n");
7280 errmsg ("missing oui\n");
7284 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7285 mp->tbl_id = ntohl (tbl_id);
7286 mp->fib_id = ntohl (fib_id);
7287 mp->oui = ntohl (oui);
7288 mp->is_ipv6 = is_ipv6;
7289 mp->is_add = is_add;
7298 api_dhcp_client_config (vat_main_t * vam)
7300 unformat_input_t *i = vam->input;
7301 vl_api_dhcp_client_config_t *mp;
7304 u8 sw_if_index_set = 0;
7307 u8 disable_event = 0;
7309 /* Parse args required to build the message */
7310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7312 if (unformat (i, "del"))
7314 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7315 sw_if_index_set = 1;
7316 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7317 sw_if_index_set = 1;
7318 else if (unformat (i, "hostname %s", &hostname))
7320 else if (unformat (i, "disable_event"))
7326 if (sw_if_index_set == 0)
7328 errmsg ("missing interface name or sw_if_index\n");
7332 if (vec_len (hostname) > 63)
7334 errmsg ("hostname too long\n");
7336 vec_add1 (hostname, 0);
7338 /* Construct the API message */
7339 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7341 mp->sw_if_index = ntohl (sw_if_index);
7342 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7343 vec_free (hostname);
7344 mp->is_add = is_add;
7345 mp->want_dhcp_event = disable_event ? 0 : 1;
7346 mp->pid = getpid ();
7351 /* Wait for a reply, return good/bad news */
7358 api_set_ip_flow_hash (vat_main_t * vam)
7360 unformat_input_t *i = vam->input;
7361 vl_api_set_ip_flow_hash_t *mp;
7373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7375 if (unformat (i, "vrf %d", &vrf_id))
7377 else if (unformat (i, "ipv6"))
7379 else if (unformat (i, "src"))
7381 else if (unformat (i, "dst"))
7383 else if (unformat (i, "sport"))
7385 else if (unformat (i, "dport"))
7387 else if (unformat (i, "proto"))
7389 else if (unformat (i, "reverse"))
7394 clib_warning ("parse error '%U'", format_unformat_error, i);
7399 if (vrf_id_set == 0)
7401 errmsg ("missing vrf id\n");
7405 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7411 mp->reverse = reverse;
7412 mp->vrf_id = ntohl (vrf_id);
7413 mp->is_ipv6 = is_ipv6;
7422 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7424 unformat_input_t *i = vam->input;
7425 vl_api_sw_interface_ip6_enable_disable_t *mp;
7428 u8 sw_if_index_set = 0;
7431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7433 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7434 sw_if_index_set = 1;
7435 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7436 sw_if_index_set = 1;
7437 else if (unformat (i, "enable"))
7439 else if (unformat (i, "disable"))
7443 clib_warning ("parse error '%U'", format_unformat_error, i);
7448 if (sw_if_index_set == 0)
7450 errmsg ("missing interface name or sw_if_index\n");
7454 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7456 mp->sw_if_index = ntohl (sw_if_index);
7457 mp->enable = enable;
7466 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7468 unformat_input_t *i = vam->input;
7469 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7472 u8 sw_if_index_set = 0;
7473 u32 address_length = 0;
7474 u8 v6_address_set = 0;
7475 ip6_address_t v6address;
7477 /* Parse args required to build the message */
7478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7480 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7481 sw_if_index_set = 1;
7482 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7483 sw_if_index_set = 1;
7484 else if (unformat (i, "%U/%d",
7485 unformat_ip6_address, &v6address, &address_length))
7491 if (sw_if_index_set == 0)
7493 errmsg ("missing interface name or sw_if_index\n");
7496 if (!v6_address_set)
7498 errmsg ("no address set\n");
7502 /* Construct the API message */
7503 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7504 sw_interface_ip6_set_link_local_address);
7506 mp->sw_if_index = ntohl (sw_if_index);
7507 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7508 mp->address_length = address_length;
7513 /* Wait for a reply, return good/bad news */
7522 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7524 unformat_input_t *i = vam->input;
7525 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7528 u8 sw_if_index_set = 0;
7529 u32 address_length = 0;
7530 u8 v6_address_set = 0;
7531 ip6_address_t v6address;
7533 u8 no_advertise = 0;
7535 u8 no_autoconfig = 0;
7538 u32 val_lifetime = 0;
7539 u32 pref_lifetime = 0;
7541 /* Parse args required to build the message */
7542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7544 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7545 sw_if_index_set = 1;
7546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7547 sw_if_index_set = 1;
7548 else if (unformat (i, "%U/%d",
7549 unformat_ip6_address, &v6address, &address_length))
7551 else if (unformat (i, "val_life %d", &val_lifetime))
7553 else if (unformat (i, "pref_life %d", &pref_lifetime))
7555 else if (unformat (i, "def"))
7557 else if (unformat (i, "noadv"))
7559 else if (unformat (i, "offl"))
7561 else if (unformat (i, "noauto"))
7563 else if (unformat (i, "nolink"))
7565 else if (unformat (i, "isno"))
7569 clib_warning ("parse error '%U'", format_unformat_error, i);
7574 if (sw_if_index_set == 0)
7576 errmsg ("missing interface name or sw_if_index\n");
7579 if (!v6_address_set)
7581 errmsg ("no address set\n");
7585 /* Construct the API message */
7586 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7588 mp->sw_if_index = ntohl (sw_if_index);
7589 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7590 mp->address_length = address_length;
7591 mp->use_default = use_default;
7592 mp->no_advertise = no_advertise;
7593 mp->off_link = off_link;
7594 mp->no_autoconfig = no_autoconfig;
7595 mp->no_onlink = no_onlink;
7597 mp->val_lifetime = ntohl (val_lifetime);
7598 mp->pref_lifetime = ntohl (pref_lifetime);
7603 /* Wait for a reply, return good/bad news */
7611 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7613 unformat_input_t *i = vam->input;
7614 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7617 u8 sw_if_index_set = 0;
7622 u8 send_unicast = 0;
7625 u8 default_router = 0;
7626 u32 max_interval = 0;
7627 u32 min_interval = 0;
7629 u32 initial_count = 0;
7630 u32 initial_interval = 0;
7633 /* Parse args required to build the message */
7634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7636 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7637 sw_if_index_set = 1;
7638 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7639 sw_if_index_set = 1;
7640 else if (unformat (i, "maxint %d", &max_interval))
7642 else if (unformat (i, "minint %d", &min_interval))
7644 else if (unformat (i, "life %d", &lifetime))
7646 else if (unformat (i, "count %d", &initial_count))
7648 else if (unformat (i, "interval %d", &initial_interval))
7650 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7652 else if (unformat (i, "managed"))
7654 else if (unformat (i, "other"))
7656 else if (unformat (i, "ll"))
7658 else if (unformat (i, "send"))
7660 else if (unformat (i, "cease"))
7662 else if (unformat (i, "isno"))
7664 else if (unformat (i, "def"))
7668 clib_warning ("parse error '%U'", format_unformat_error, i);
7673 if (sw_if_index_set == 0)
7675 errmsg ("missing interface name or sw_if_index\n");
7679 /* Construct the API message */
7680 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7682 mp->sw_if_index = ntohl (sw_if_index);
7683 mp->max_interval = ntohl (max_interval);
7684 mp->min_interval = ntohl (min_interval);
7685 mp->lifetime = ntohl (lifetime);
7686 mp->initial_count = ntohl (initial_count);
7687 mp->initial_interval = ntohl (initial_interval);
7688 mp->suppress = suppress;
7689 mp->managed = managed;
7691 mp->ll_option = ll_option;
7692 mp->send_unicast = send_unicast;
7695 mp->default_router = default_router;
7700 /* Wait for a reply, return good/bad news */
7708 api_set_arp_neighbor_limit (vat_main_t * vam)
7710 unformat_input_t *i = vam->input;
7711 vl_api_set_arp_neighbor_limit_t *mp;
7717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7719 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7721 else if (unformat (i, "ipv6"))
7725 clib_warning ("parse error '%U'", format_unformat_error, i);
7732 errmsg ("missing limit value\n");
7736 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7738 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7739 mp->is_ipv6 = is_ipv6;
7748 api_l2_patch_add_del (vat_main_t * vam)
7750 unformat_input_t *i = vam->input;
7751 vl_api_l2_patch_add_del_t *mp;
7754 u8 rx_sw_if_index_set = 0;
7756 u8 tx_sw_if_index_set = 0;
7759 /* Parse args required to build the message */
7760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7762 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7763 rx_sw_if_index_set = 1;
7764 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7765 tx_sw_if_index_set = 1;
7766 else if (unformat (i, "rx"))
7768 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7770 if (unformat (i, "%U", unformat_sw_if_index, vam,
7772 rx_sw_if_index_set = 1;
7777 else if (unformat (i, "tx"))
7779 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7781 if (unformat (i, "%U", unformat_sw_if_index, vam,
7783 tx_sw_if_index_set = 1;
7788 else if (unformat (i, "del"))
7794 if (rx_sw_if_index_set == 0)
7796 errmsg ("missing rx interface name or rx_sw_if_index\n");
7800 if (tx_sw_if_index_set == 0)
7802 errmsg ("missing tx interface name or tx_sw_if_index\n");
7806 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7808 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7809 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7810 mp->is_add = is_add;
7819 api_ioam_enable (vat_main_t * vam)
7821 unformat_input_t *input = vam->input;
7822 vl_api_ioam_enable_t *mp;
7825 int has_trace_option = 0;
7826 int has_pot_option = 0;
7827 int has_seqno_option = 0;
7828 int has_analyse_option = 0;
7830 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7832 if (unformat (input, "trace"))
7833 has_trace_option = 1;
7834 else if (unformat (input, "pot"))
7836 else if (unformat (input, "seqno"))
7837 has_seqno_option = 1;
7838 else if (unformat (input, "analyse"))
7839 has_analyse_option = 1;
7843 M (IOAM_ENABLE, ioam_enable);
7844 mp->id = htons (id);
7845 mp->seqno = has_seqno_option;
7846 mp->analyse = has_analyse_option;
7847 mp->pot_enable = has_pot_option;
7848 mp->trace_enable = has_trace_option;
7859 api_ioam_disable (vat_main_t * vam)
7861 vl_api_ioam_disable_t *mp;
7864 M (IOAM_DISABLE, ioam_disable);
7871 api_sr_tunnel_add_del (vat_main_t * vam)
7873 unformat_input_t *i = vam->input;
7874 vl_api_sr_tunnel_add_del_t *mp;
7878 ip6_address_t src_address;
7879 int src_address_set = 0;
7880 ip6_address_t dst_address;
7882 int dst_address_set = 0;
7884 u32 rx_table_id = 0;
7885 u32 tx_table_id = 0;
7886 ip6_address_t *segments = 0;
7887 ip6_address_t *this_seg;
7888 ip6_address_t *tags = 0;
7889 ip6_address_t *this_tag;
7890 ip6_address_t next_address, tag;
7892 u8 *policy_name = 0;
7894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7896 if (unformat (i, "del"))
7898 else if (unformat (i, "name %s", &name))
7900 else if (unformat (i, "policy %s", &policy_name))
7902 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7904 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7906 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7907 src_address_set = 1;
7908 else if (unformat (i, "dst %U/%d",
7909 unformat_ip6_address, &dst_address, &dst_mask_width))
7910 dst_address_set = 1;
7911 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7913 vec_add2 (segments, this_seg, 1);
7914 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7915 sizeof (*this_seg));
7917 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7919 vec_add2 (tags, this_tag, 1);
7920 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7922 else if (unformat (i, "clean"))
7923 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7924 else if (unformat (i, "protected"))
7925 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7926 else if (unformat (i, "InPE %d", &pl_index))
7928 if (pl_index <= 0 || pl_index > 4)
7930 pl_index_range_error:
7931 errmsg ("pl index %d out of range\n", pl_index);
7935 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7937 else if (unformat (i, "EgPE %d", &pl_index))
7939 if (pl_index <= 0 || pl_index > 4)
7940 goto pl_index_range_error;
7942 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7944 else if (unformat (i, "OrgSrc %d", &pl_index))
7946 if (pl_index <= 0 || pl_index > 4)
7947 goto pl_index_range_error;
7949 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7955 if (!src_address_set)
7957 errmsg ("src address required\n");
7961 if (!dst_address_set)
7963 errmsg ("dst address required\n");
7969 errmsg ("at least one sr segment required\n");
7973 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7974 vec_len (segments) * sizeof (ip6_address_t)
7975 + vec_len (tags) * sizeof (ip6_address_t));
7977 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7978 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7979 mp->dst_mask_width = dst_mask_width;
7980 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7981 mp->n_segments = vec_len (segments);
7982 mp->n_tags = vec_len (tags);
7983 mp->is_add = is_del == 0;
7984 clib_memcpy (mp->segs_and_tags, segments,
7985 vec_len (segments) * sizeof (ip6_address_t));
7986 clib_memcpy (mp->segs_and_tags +
7987 vec_len (segments) * sizeof (ip6_address_t), tags,
7988 vec_len (tags) * sizeof (ip6_address_t));
7990 mp->outer_vrf_id = ntohl (rx_table_id);
7991 mp->inner_vrf_id = ntohl (tx_table_id);
7992 memcpy (mp->name, name, vec_len (name));
7993 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7995 vec_free (segments);
8004 api_sr_policy_add_del (vat_main_t * vam)
8006 unformat_input_t *input = vam->input;
8007 vl_api_sr_policy_add_del_t *mp;
8011 u8 *tunnel_name = 0;
8012 u8 **tunnel_names = 0;
8017 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8018 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8022 if (unformat (input, "del"))
8024 else if (unformat (input, "name %s", &name))
8026 else if (unformat (input, "tunnel %s", &tunnel_name))
8030 vec_add1 (tunnel_names, tunnel_name);
8032 - length = #bytes to store in serial vector
8033 - +1 = byte to store that length
8035 tunnel_names_length += (vec_len (tunnel_name) + 1);
8046 errmsg ("policy name required\n");
8050 if ((!tunnel_set) && (!is_del))
8052 errmsg ("tunnel name required\n");
8056 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8060 mp->is_add = !is_del;
8062 memcpy (mp->name, name, vec_len (name));
8063 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8064 u8 *serial_orig = 0;
8065 vec_validate (serial_orig, tunnel_names_length);
8066 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8067 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8069 for (j = 0; j < vec_len (tunnel_names); j++)
8071 tun_name_len = vec_len (tunnel_names[j]);
8072 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8073 serial_orig += 1; // Move along one byte to store the actual tunnel name
8074 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8075 serial_orig += tun_name_len; // Advance past the copy
8077 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8079 vec_free (tunnel_names);
8080 vec_free (tunnel_name);
8088 api_sr_multicast_map_add_del (vat_main_t * vam)
8090 unformat_input_t *input = vam->input;
8091 vl_api_sr_multicast_map_add_del_t *mp;
8094 ip6_address_t multicast_address;
8095 u8 *policy_name = 0;
8096 int multicast_address_set = 0;
8098 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8100 if (unformat (input, "del"))
8104 (input, "address %U", unformat_ip6_address, &multicast_address))
8105 multicast_address_set = 1;
8106 else if (unformat (input, "sr-policy %s", &policy_name))
8112 if (!is_del && !policy_name)
8114 errmsg ("sr-policy name required\n");
8119 if (!multicast_address_set)
8121 errmsg ("address required\n");
8125 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8127 mp->is_add = !is_del;
8128 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8129 clib_memcpy (mp->multicast_address, &multicast_address,
8130 sizeof (mp->multicast_address));
8133 vec_free (policy_name);
8141 #define foreach_tcp_proto_field \
8145 #define foreach_udp_proto_field \
8149 #define foreach_ip4_proto_field \
8160 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8162 u8 **maskp = va_arg (*args, u8 **);
8164 u8 found_something = 0;
8167 #define _(a) u8 a=0;
8168 foreach_tcp_proto_field;
8171 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8174 #define _(a) else if (unformat (input, #a)) a=1;
8175 foreach_tcp_proto_field
8181 #define _(a) found_something += a;
8182 foreach_tcp_proto_field;
8185 if (found_something == 0)
8188 vec_validate (mask, sizeof (*tcp) - 1);
8190 tcp = (tcp_header_t *) mask;
8192 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8193 foreach_tcp_proto_field;
8201 unformat_udp_mask (unformat_input_t * input, va_list * args)
8203 u8 **maskp = va_arg (*args, u8 **);
8205 u8 found_something = 0;
8208 #define _(a) u8 a=0;
8209 foreach_udp_proto_field;
8212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8215 #define _(a) else if (unformat (input, #a)) a=1;
8216 foreach_udp_proto_field
8222 #define _(a) found_something += a;
8223 foreach_udp_proto_field;
8226 if (found_something == 0)
8229 vec_validate (mask, sizeof (*udp) - 1);
8231 udp = (udp_header_t *) mask;
8233 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8234 foreach_udp_proto_field;
8243 u16 src_port, dst_port;
8247 unformat_l4_mask (unformat_input_t * input, va_list * args)
8249 u8 **maskp = va_arg (*args, u8 **);
8250 u16 src_port = 0, dst_port = 0;
8251 tcpudp_header_t *tcpudp;
8253 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8255 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8257 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8259 else if (unformat (input, "src_port"))
8261 else if (unformat (input, "dst_port"))
8267 if (!src_port && !dst_port)
8271 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8273 tcpudp = (tcpudp_header_t *) mask;
8274 tcpudp->src_port = src_port;
8275 tcpudp->dst_port = dst_port;
8283 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8285 u8 **maskp = va_arg (*args, u8 **);
8287 u8 found_something = 0;
8290 #define _(a) u8 a=0;
8291 foreach_ip4_proto_field;
8297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8299 if (unformat (input, "version"))
8301 else if (unformat (input, "hdr_length"))
8303 else if (unformat (input, "src"))
8305 else if (unformat (input, "dst"))
8307 else if (unformat (input, "proto"))
8310 #define _(a) else if (unformat (input, #a)) a=1;
8311 foreach_ip4_proto_field
8317 #define _(a) found_something += a;
8318 foreach_ip4_proto_field;
8321 if (found_something == 0)
8324 vec_validate (mask, sizeof (*ip) - 1);
8326 ip = (ip4_header_t *) mask;
8328 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8329 foreach_ip4_proto_field;
8332 ip->ip_version_and_header_length = 0;
8335 ip->ip_version_and_header_length |= 0xF0;
8338 ip->ip_version_and_header_length |= 0x0F;
8344 #define foreach_ip6_proto_field \
8352 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8354 u8 **maskp = va_arg (*args, u8 **);
8356 u8 found_something = 0;
8358 u32 ip_version_traffic_class_and_flow_label;
8360 #define _(a) u8 a=0;
8361 foreach_ip6_proto_field;
8364 u8 traffic_class = 0;
8367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8369 if (unformat (input, "version"))
8371 else if (unformat (input, "traffic-class"))
8373 else if (unformat (input, "flow-label"))
8375 else if (unformat (input, "src"))
8377 else if (unformat (input, "dst"))
8379 else if (unformat (input, "proto"))
8382 #define _(a) else if (unformat (input, #a)) a=1;
8383 foreach_ip6_proto_field
8389 #define _(a) found_something += a;
8390 foreach_ip6_proto_field;
8393 if (found_something == 0)
8396 vec_validate (mask, sizeof (*ip) - 1);
8398 ip = (ip6_header_t *) mask;
8400 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8401 foreach_ip6_proto_field;
8404 ip_version_traffic_class_and_flow_label = 0;
8407 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8410 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8413 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8415 ip->ip_version_traffic_class_and_flow_label =
8416 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8423 unformat_l3_mask (unformat_input_t * input, va_list * args)
8425 u8 **maskp = va_arg (*args, u8 **);
8427 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8429 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8431 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8440 unformat_l2_mask (unformat_input_t * input, va_list * args)
8442 u8 **maskp = va_arg (*args, u8 **);
8457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8459 if (unformat (input, "src"))
8461 else if (unformat (input, "dst"))
8463 else if (unformat (input, "proto"))
8465 else if (unformat (input, "tag1"))
8467 else if (unformat (input, "tag2"))
8469 else if (unformat (input, "ignore-tag1"))
8471 else if (unformat (input, "ignore-tag2"))
8473 else if (unformat (input, "cos1"))
8475 else if (unformat (input, "cos2"))
8477 else if (unformat (input, "dot1q"))
8479 else if (unformat (input, "dot1ad"))
8484 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8485 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8488 if (tag1 || ignore_tag1 || cos1 || dot1q)
8490 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8493 vec_validate (mask, len - 1);
8496 memset (mask, 0xff, 6);
8499 memset (mask + 6, 0xff, 6);
8503 /* inner vlan tag */
8512 mask[21] = mask[20] = 0xff;
8533 mask[16] = mask[17] = 0xff;
8543 mask[12] = mask[13] = 0xff;
8550 unformat_classify_mask (unformat_input_t * input, va_list * args)
8552 u8 **maskp = va_arg (*args, u8 **);
8553 u32 *skipp = va_arg (*args, u32 *);
8554 u32 *matchp = va_arg (*args, u32 *);
8562 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8564 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8566 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8568 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8570 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8584 if (mask || l2 || l3 || l4)
8588 /* "With a free Ethernet header in every package" */
8590 vec_validate (l2, 13);
8594 vec_append (mask, l3);
8599 vec_append (mask, l4);
8604 /* Scan forward looking for the first significant mask octet */
8605 for (i = 0; i < vec_len (mask); i++)
8609 /* compute (skip, match) params */
8610 *skipp = i / sizeof (u32x4);
8611 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8613 /* Pad mask to an even multiple of the vector size */
8614 while (vec_len (mask) % sizeof (u32x4))
8617 match = vec_len (mask) / sizeof (u32x4);
8619 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8621 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8622 if (*tmp || *(tmp + 1))
8627 clib_warning ("BUG: match 0");
8629 _vec_len (mask) = match * sizeof (u32x4);
8640 #define foreach_l2_next \
8642 _(ethernet, ETHERNET_INPUT) \
8647 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8649 u32 *miss_next_indexp = va_arg (*args, u32 *);
8654 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8658 if (unformat (input, "%d", &tmp))
8667 *miss_next_indexp = next_index;
8671 #define foreach_ip_next \
8677 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8679 u32 *miss_next_indexp = va_arg (*args, u32 *);
8684 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8688 if (unformat (input, "%d", &tmp))
8697 *miss_next_indexp = next_index;
8701 #define foreach_acl_next \
8705 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8707 u32 *miss_next_indexp = va_arg (*args, u32 *);
8712 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8716 if (unformat (input, "permit"))
8721 else if (unformat (input, "%d", &tmp))
8730 *miss_next_indexp = next_index;
8735 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8737 u32 *r = va_arg (*args, u32 *);
8739 if (unformat (input, "conform-color"))
8740 *r = POLICE_CONFORM;
8741 else if (unformat (input, "exceed-color"))
8750 api_classify_add_del_table (vat_main_t * vam)
8752 unformat_input_t *i = vam->input;
8753 vl_api_classify_add_del_table_t *mp;
8759 u32 table_index = ~0;
8760 u32 next_table_index = ~0;
8761 u32 miss_next_index = ~0;
8762 u32 memory_size = 32 << 20;
8765 u32 current_data_flag = 0;
8766 int current_data_offset = 0;
8768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8770 if (unformat (i, "del"))
8772 else if (unformat (i, "buckets %d", &nbuckets))
8774 else if (unformat (i, "memory_size %d", &memory_size))
8776 else if (unformat (i, "skip %d", &skip))
8778 else if (unformat (i, "match %d", &match))
8780 else if (unformat (i, "table %d", &table_index))
8782 else if (unformat (i, "mask %U", unformat_classify_mask,
8783 &mask, &skip, &match))
8785 else if (unformat (i, "next-table %d", &next_table_index))
8787 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8790 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8793 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8796 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8798 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8804 if (is_add && mask == 0)
8806 errmsg ("Mask required\n");
8810 if (is_add && skip == ~0)
8812 errmsg ("skip count required\n");
8816 if (is_add && match == ~0)
8818 errmsg ("match count required\n");
8822 if (!is_add && table_index == ~0)
8824 errmsg ("table index required for delete\n");
8828 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8830 mp->is_add = is_add;
8831 mp->table_index = ntohl (table_index);
8832 mp->nbuckets = ntohl (nbuckets);
8833 mp->memory_size = ntohl (memory_size);
8834 mp->skip_n_vectors = ntohl (skip);
8835 mp->match_n_vectors = ntohl (match);
8836 mp->next_table_index = ntohl (next_table_index);
8837 mp->miss_next_index = ntohl (miss_next_index);
8838 mp->current_data_flag = ntohl (current_data_flag);
8839 mp->current_data_offset = ntohl (current_data_offset);
8840 clib_memcpy (mp->mask, mask, vec_len (mask));
8850 unformat_l4_match (unformat_input_t * input, va_list * args)
8852 u8 **matchp = va_arg (*args, u8 **);
8854 u8 *proto_header = 0;
8860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8862 if (unformat (input, "src_port %d", &src_port))
8864 else if (unformat (input, "dst_port %d", &dst_port))
8870 h.src_port = clib_host_to_net_u16 (src_port);
8871 h.dst_port = clib_host_to_net_u16 (dst_port);
8872 vec_validate (proto_header, sizeof (h) - 1);
8873 memcpy (proto_header, &h, sizeof (h));
8875 *matchp = proto_header;
8881 unformat_ip4_match (unformat_input_t * input, va_list * args)
8883 u8 **matchp = va_arg (*args, u8 **);
8890 int src = 0, dst = 0;
8891 ip4_address_t src_val, dst_val;
8898 int fragment_id = 0;
8899 u32 fragment_id_val;
8905 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8907 if (unformat (input, "version %d", &version_val))
8909 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8911 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8913 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8915 else if (unformat (input, "proto %d", &proto_val))
8917 else if (unformat (input, "tos %d", &tos_val))
8919 else if (unformat (input, "length %d", &length_val))
8921 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8923 else if (unformat (input, "ttl %d", &ttl_val))
8925 else if (unformat (input, "checksum %d", &checksum_val))
8931 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8932 + ttl + checksum == 0)
8936 * Aligned because we use the real comparison functions
8938 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8940 ip = (ip4_header_t *) match;
8942 /* These are realistically matched in practice */
8944 ip->src_address.as_u32 = src_val.as_u32;
8947 ip->dst_address.as_u32 = dst_val.as_u32;
8950 ip->protocol = proto_val;
8953 /* These are not, but they're included for completeness */
8955 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8958 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8964 ip->length = clib_host_to_net_u16 (length_val);
8970 ip->checksum = clib_host_to_net_u16 (checksum_val);
8977 unformat_ip6_match (unformat_input_t * input, va_list * args)
8979 u8 **matchp = va_arg (*args, u8 **);
8984 u8 traffic_class = 0;
8985 u32 traffic_class_val = 0;
8988 int src = 0, dst = 0;
8989 ip6_address_t src_val, dst_val;
8992 int payload_length = 0;
8993 u32 payload_length_val;
8996 u32 ip_version_traffic_class_and_flow_label;
8998 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9000 if (unformat (input, "version %d", &version_val))
9002 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9004 else if (unformat (input, "flow_label %d", &flow_label_val))
9006 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9008 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9010 else if (unformat (input, "proto %d", &proto_val))
9012 else if (unformat (input, "payload_length %d", &payload_length_val))
9014 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9020 if (version + traffic_class + flow_label + src + dst + proto +
9021 payload_length + hop_limit == 0)
9025 * Aligned because we use the real comparison functions
9027 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9029 ip = (ip6_header_t *) match;
9032 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9035 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9038 ip->protocol = proto_val;
9040 ip_version_traffic_class_and_flow_label = 0;
9043 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9046 ip_version_traffic_class_and_flow_label |=
9047 (traffic_class_val & 0xFF) << 20;
9050 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9052 ip->ip_version_traffic_class_and_flow_label =
9053 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9056 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9059 ip->hop_limit = hop_limit_val;
9066 unformat_l3_match (unformat_input_t * input, va_list * args)
9068 u8 **matchp = va_arg (*args, u8 **);
9070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9072 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9074 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9083 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9085 u8 *tagp = va_arg (*args, u8 *);
9088 if (unformat (input, "%d", &tag))
9090 tagp[0] = (tag >> 8) & 0x0F;
9091 tagp[1] = tag & 0xFF;
9099 unformat_l2_match (unformat_input_t * input, va_list * args)
9101 u8 **matchp = va_arg (*args, u8 **);
9121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9123 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9126 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9128 else if (unformat (input, "proto %U",
9129 unformat_ethernet_type_host_byte_order, &proto_val))
9131 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9133 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9135 else if (unformat (input, "ignore-tag1"))
9137 else if (unformat (input, "ignore-tag2"))
9139 else if (unformat (input, "cos1 %d", &cos1_val))
9141 else if (unformat (input, "cos2 %d", &cos2_val))
9146 if ((src + dst + proto + tag1 + tag2 +
9147 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9150 if (tag1 || ignore_tag1 || cos1)
9152 if (tag2 || ignore_tag2 || cos2)
9155 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9158 clib_memcpy (match, dst_val, 6);
9161 clib_memcpy (match + 6, src_val, 6);
9165 /* inner vlan tag */
9166 match[19] = tag2_val[1];
9167 match[18] = tag2_val[0];
9169 match[18] |= (cos2_val & 0x7) << 5;
9172 match[21] = proto_val & 0xff;
9173 match[20] = proto_val >> 8;
9177 match[15] = tag1_val[1];
9178 match[14] = tag1_val[0];
9181 match[14] |= (cos1_val & 0x7) << 5;
9187 match[15] = tag1_val[1];
9188 match[14] = tag1_val[0];
9191 match[17] = proto_val & 0xff;
9192 match[16] = proto_val >> 8;
9195 match[14] |= (cos1_val & 0x7) << 5;
9201 match[18] |= (cos2_val & 0x7) << 5;
9203 match[14] |= (cos1_val & 0x7) << 5;
9206 match[13] = proto_val & 0xff;
9207 match[12] = proto_val >> 8;
9216 unformat_classify_match (unformat_input_t * input, va_list * args)
9218 u8 **matchp = va_arg (*args, u8 **);
9219 u32 skip_n_vectors = va_arg (*args, u32);
9220 u32 match_n_vectors = va_arg (*args, u32);
9227 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9229 if (unformat (input, "hex %U", unformat_hex_string, &match))
9231 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9233 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9235 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9249 if (match || l2 || l3 || l4)
9253 /* "Win a free Ethernet header in every packet" */
9255 vec_validate_aligned (l2, 13, sizeof (u32x4));
9259 vec_append_aligned (match, l3, sizeof (u32x4));
9264 vec_append_aligned (match, l4, sizeof (u32x4));
9269 /* Make sure the vector is big enough even if key is all 0's */
9270 vec_validate_aligned
9271 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9274 /* Set size, include skipped vectors */
9275 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9286 api_classify_add_del_session (vat_main_t * vam)
9288 unformat_input_t *i = vam->input;
9289 vl_api_classify_add_del_session_t *mp;
9291 u32 table_index = ~0;
9292 u32 hit_next_index = ~0;
9293 u32 opaque_index = ~0;
9297 u32 skip_n_vectors = 0;
9298 u32 match_n_vectors = 0;
9303 * Warning: you have to supply skip_n and match_n
9304 * because the API client cant simply look at the classify
9308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9310 if (unformat (i, "del"))
9312 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9315 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9318 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9321 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9323 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9325 else if (unformat (i, "opaque-index %d", &opaque_index))
9327 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9329 else if (unformat (i, "match_n %d", &match_n_vectors))
9331 else if (unformat (i, "match %U", unformat_classify_match,
9332 &match, skip_n_vectors, match_n_vectors))
9334 else if (unformat (i, "advance %d", &advance))
9336 else if (unformat (i, "table-index %d", &table_index))
9338 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9340 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9342 else if (unformat (i, "action %d", &action))
9344 else if (unformat (i, "metadata %d", &metadata))
9350 if (table_index == ~0)
9352 errmsg ("Table index required\n");
9356 if (is_add && match == 0)
9358 errmsg ("Match value required\n");
9362 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9364 mp->is_add = is_add;
9365 mp->table_index = ntohl (table_index);
9366 mp->hit_next_index = ntohl (hit_next_index);
9367 mp->opaque_index = ntohl (opaque_index);
9368 mp->advance = ntohl (advance);
9369 mp->action = action;
9370 mp->metadata = ntohl (metadata);
9371 clib_memcpy (mp->match, match, vec_len (match));
9380 api_classify_set_interface_ip_table (vat_main_t * vam)
9382 unformat_input_t *i = vam->input;
9383 vl_api_classify_set_interface_ip_table_t *mp;
9386 int sw_if_index_set;
9387 u32 table_index = ~0;
9390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9392 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9393 sw_if_index_set = 1;
9394 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9395 sw_if_index_set = 1;
9396 else if (unformat (i, "table %d", &table_index))
9400 clib_warning ("parse error '%U'", format_unformat_error, i);
9405 if (sw_if_index_set == 0)
9407 errmsg ("missing interface name or sw_if_index\n");
9412 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9414 mp->sw_if_index = ntohl (sw_if_index);
9415 mp->table_index = ntohl (table_index);
9416 mp->is_ipv6 = is_ipv6;
9425 api_classify_set_interface_l2_tables (vat_main_t * vam)
9427 unformat_input_t *i = vam->input;
9428 vl_api_classify_set_interface_l2_tables_t *mp;
9431 int sw_if_index_set;
9432 u32 ip4_table_index = ~0;
9433 u32 ip6_table_index = ~0;
9434 u32 other_table_index = ~0;
9437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9439 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9440 sw_if_index_set = 1;
9441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9442 sw_if_index_set = 1;
9443 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9445 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9447 else if (unformat (i, "other-table %d", &other_table_index))
9449 else if (unformat (i, "is-input %d", &is_input))
9453 clib_warning ("parse error '%U'", format_unformat_error, i);
9458 if (sw_if_index_set == 0)
9460 errmsg ("missing interface name or sw_if_index\n");
9465 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9467 mp->sw_if_index = ntohl (sw_if_index);
9468 mp->ip4_table_index = ntohl (ip4_table_index);
9469 mp->ip6_table_index = ntohl (ip6_table_index);
9470 mp->other_table_index = ntohl (other_table_index);
9471 mp->is_input = (u8) is_input;
9480 api_set_ipfix_exporter (vat_main_t * vam)
9482 unformat_input_t *i = vam->input;
9483 vl_api_set_ipfix_exporter_t *mp;
9484 ip4_address_t collector_address;
9485 u8 collector_address_set = 0;
9486 u32 collector_port = ~0;
9487 ip4_address_t src_address;
9488 u8 src_address_set = 0;
9491 u32 template_interval = ~0;
9492 u8 udp_checksum = 0;
9495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9497 if (unformat (i, "collector_address %U", unformat_ip4_address,
9498 &collector_address))
9499 collector_address_set = 1;
9500 else if (unformat (i, "collector_port %d", &collector_port))
9502 else if (unformat (i, "src_address %U", unformat_ip4_address,
9504 src_address_set = 1;
9505 else if (unformat (i, "vrf_id %d", &vrf_id))
9507 else if (unformat (i, "path_mtu %d", &path_mtu))
9509 else if (unformat (i, "template_interval %d", &template_interval))
9511 else if (unformat (i, "udp_checksum"))
9517 if (collector_address_set == 0)
9519 errmsg ("collector_address required\n");
9523 if (src_address_set == 0)
9525 errmsg ("src_address required\n");
9529 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9531 memcpy (mp->collector_address, collector_address.data,
9532 sizeof (collector_address.data));
9533 mp->collector_port = htons ((u16) collector_port);
9534 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9535 mp->vrf_id = htonl (vrf_id);
9536 mp->path_mtu = htonl (path_mtu);
9537 mp->template_interval = htonl (template_interval);
9538 mp->udp_checksum = udp_checksum;
9546 api_set_ipfix_classify_stream (vat_main_t * vam)
9548 unformat_input_t *i = vam->input;
9549 vl_api_set_ipfix_classify_stream_t *mp;
9551 u32 src_port = UDP_DST_PORT_ipfix;
9554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9556 if (unformat (i, "domain %d", &domain_id))
9558 else if (unformat (i, "src_port %d", &src_port))
9562 errmsg ("unknown input `%U'", format_unformat_error, i);
9567 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9569 mp->domain_id = htonl (domain_id);
9570 mp->src_port = htons ((u16) src_port);
9578 api_ipfix_classify_table_add_del (vat_main_t * vam)
9580 unformat_input_t *i = vam->input;
9581 vl_api_ipfix_classify_table_add_del_t *mp;
9583 u32 classify_table_index = ~0;
9585 u8 transport_protocol = 255;
9588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9590 if (unformat (i, "add"))
9592 else if (unformat (i, "del"))
9594 else if (unformat (i, "table %d", &classify_table_index))
9596 else if (unformat (i, "ip4"))
9598 else if (unformat (i, "ip6"))
9600 else if (unformat (i, "tcp"))
9601 transport_protocol = 6;
9602 else if (unformat (i, "udp"))
9603 transport_protocol = 17;
9606 errmsg ("unknown input `%U'", format_unformat_error, i);
9613 errmsg ("expecting: add|del");
9616 if (classify_table_index == ~0)
9618 errmsg ("classifier table not specified");
9621 if (ip_version == 0)
9623 errmsg ("IP version not specified");
9627 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9629 mp->is_add = is_add;
9630 mp->table_id = htonl (classify_table_index);
9631 mp->ip_version = ip_version;
9632 mp->transport_protocol = transport_protocol;
9640 api_get_node_index (vat_main_t * vam)
9642 unformat_input_t *i = vam->input;
9643 vl_api_get_node_index_t *mp;
9647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9649 if (unformat (i, "node %s", &name))
9656 errmsg ("node name required\n");
9659 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9661 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9665 M (GET_NODE_INDEX, get_node_index);
9666 clib_memcpy (mp->node_name, name, vec_len (name));
9676 api_get_next_index (vat_main_t * vam)
9678 unformat_input_t *i = vam->input;
9679 vl_api_get_next_index_t *mp;
9681 u8 *node_name = 0, *next_node_name = 0;
9683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9685 if (unformat (i, "node-name %s", &node_name))
9687 else if (unformat (i, "next-node-name %s", &next_node_name))
9693 errmsg ("node name required\n");
9696 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9698 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9702 if (next_node_name == 0)
9704 errmsg ("next node name required\n");
9707 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9709 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9713 M (GET_NEXT_INDEX, get_next_index);
9714 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9715 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9716 vec_free (node_name);
9717 vec_free (next_node_name);
9726 api_add_node_next (vat_main_t * vam)
9728 unformat_input_t *i = vam->input;
9729 vl_api_add_node_next_t *mp;
9734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9736 if (unformat (i, "node %s", &name))
9738 else if (unformat (i, "next %s", &next))
9745 errmsg ("node name required\n");
9748 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9750 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9755 errmsg ("next node required\n");
9758 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9760 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9764 M (ADD_NODE_NEXT, add_node_next);
9765 clib_memcpy (mp->node_name, name, vec_len (name));
9766 clib_memcpy (mp->next_name, next, vec_len (next));
9777 api_l2tpv3_create_tunnel (vat_main_t * vam)
9779 unformat_input_t *i = vam->input;
9780 ip6_address_t client_address, our_address;
9781 int client_address_set = 0;
9782 int our_address_set = 0;
9783 u32 local_session_id = 0;
9784 u32 remote_session_id = 0;
9785 u64 local_cookie = 0;
9786 u64 remote_cookie = 0;
9787 u8 l2_sublayer_present = 0;
9788 vl_api_l2tpv3_create_tunnel_t *mp;
9791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9793 if (unformat (i, "client_address %U", unformat_ip6_address,
9795 client_address_set = 1;
9796 else if (unformat (i, "our_address %U", unformat_ip6_address,
9798 our_address_set = 1;
9799 else if (unformat (i, "local_session_id %d", &local_session_id))
9801 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9803 else if (unformat (i, "local_cookie %lld", &local_cookie))
9805 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9807 else if (unformat (i, "l2-sublayer-present"))
9808 l2_sublayer_present = 1;
9813 if (client_address_set == 0)
9815 errmsg ("client_address required\n");
9819 if (our_address_set == 0)
9821 errmsg ("our_address required\n");
9825 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9827 clib_memcpy (mp->client_address, client_address.as_u8,
9828 sizeof (mp->client_address));
9830 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9832 mp->local_session_id = ntohl (local_session_id);
9833 mp->remote_session_id = ntohl (remote_session_id);
9834 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9835 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9836 mp->l2_sublayer_present = l2_sublayer_present;
9846 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9848 unformat_input_t *i = vam->input;
9850 u8 sw_if_index_set = 0;
9851 u64 new_local_cookie = 0;
9852 u64 new_remote_cookie = 0;
9853 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9858 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9859 sw_if_index_set = 1;
9860 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9861 sw_if_index_set = 1;
9862 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9864 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9870 if (sw_if_index_set == 0)
9872 errmsg ("missing interface name or sw_if_index\n");
9876 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9878 mp->sw_if_index = ntohl (sw_if_index);
9879 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9880 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9889 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9891 unformat_input_t *i = vam->input;
9892 vl_api_l2tpv3_interface_enable_disable_t *mp;
9895 u8 sw_if_index_set = 0;
9896 u8 enable_disable = 1;
9898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9900 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9901 sw_if_index_set = 1;
9902 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9903 sw_if_index_set = 1;
9904 else if (unformat (i, "enable"))
9906 else if (unformat (i, "disable"))
9912 if (sw_if_index_set == 0)
9914 errmsg ("missing interface name or sw_if_index\n");
9918 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9920 mp->sw_if_index = ntohl (sw_if_index);
9921 mp->enable_disable = enable_disable;
9930 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9932 unformat_input_t *i = vam->input;
9933 vl_api_l2tpv3_set_lookup_key_t *mp;
9937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9939 if (unformat (i, "lookup_v6_src"))
9940 key = L2T_LOOKUP_SRC_ADDRESS;
9941 else if (unformat (i, "lookup_v6_dst"))
9942 key = L2T_LOOKUP_DST_ADDRESS;
9943 else if (unformat (i, "lookup_session_id"))
9944 key = L2T_LOOKUP_SESSION_ID;
9949 if (key == (u8) ~ 0)
9951 errmsg ("l2tp session lookup key unset\n");
9955 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9965 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9966 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9968 vat_main_t *vam = &vat_main;
9970 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9971 format_ip6_address, mp->our_address,
9972 format_ip6_address, mp->client_address,
9973 clib_net_to_host_u32 (mp->sw_if_index));
9976 " local cookies %016llx %016llx remote cookie %016llx\n",
9977 clib_net_to_host_u64 (mp->local_cookie[0]),
9978 clib_net_to_host_u64 (mp->local_cookie[1]),
9979 clib_net_to_host_u64 (mp->remote_cookie));
9981 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9982 clib_net_to_host_u32 (mp->local_session_id),
9983 clib_net_to_host_u32 (mp->remote_session_id));
9985 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9986 mp->l2_sublayer_present ? "preset" : "absent");
9990 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9991 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9993 vat_main_t *vam = &vat_main;
9994 vat_json_node_t *node = NULL;
9995 struct in6_addr addr;
9997 if (VAT_JSON_ARRAY != vam->json_tree.type)
9999 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10000 vat_json_init_array (&vam->json_tree);
10002 node = vat_json_array_add (&vam->json_tree);
10004 vat_json_init_object (node);
10006 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10007 vat_json_object_add_ip6 (node, "our_address", addr);
10008 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10009 vat_json_object_add_ip6 (node, "client_address", addr);
10011 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10012 vat_json_init_array (lc);
10013 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10014 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10015 vat_json_object_add_uint (node, "remote_cookie",
10016 clib_net_to_host_u64 (mp->remote_cookie));
10018 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10019 vat_json_object_add_uint (node, "local_session_id",
10020 clib_net_to_host_u32 (mp->local_session_id));
10021 vat_json_object_add_uint (node, "remote_session_id",
10022 clib_net_to_host_u32 (mp->remote_session_id));
10023 vat_json_object_add_string_copy (node, "l2_sublayer",
10024 mp->l2_sublayer_present ? (u8 *) "present"
10025 : (u8 *) "absent");
10029 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10031 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10034 /* Get list of l2tpv3-tunnel interfaces */
10035 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10038 /* Use a control ping for synchronization */
10040 vl_api_control_ping_t *mp;
10041 M (CONTROL_PING, control_ping);
10048 static void vl_api_sw_interface_tap_details_t_handler
10049 (vl_api_sw_interface_tap_details_t * mp)
10051 vat_main_t *vam = &vat_main;
10053 fformat (vam->ofp, "%-16s %d\n",
10054 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10057 static void vl_api_sw_interface_tap_details_t_handler_json
10058 (vl_api_sw_interface_tap_details_t * mp)
10060 vat_main_t *vam = &vat_main;
10061 vat_json_node_t *node = NULL;
10063 if (VAT_JSON_ARRAY != vam->json_tree.type)
10065 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10066 vat_json_init_array (&vam->json_tree);
10068 node = vat_json_array_add (&vam->json_tree);
10070 vat_json_init_object (node);
10071 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10072 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10076 api_sw_interface_tap_dump (vat_main_t * vam)
10078 vl_api_sw_interface_tap_dump_t *mp;
10081 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
10082 /* Get list of tap interfaces */
10083 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10086 /* Use a control ping for synchronization */
10088 vl_api_control_ping_t *mp;
10089 M (CONTROL_PING, control_ping);
10095 static uword unformat_vxlan_decap_next
10096 (unformat_input_t * input, va_list * args)
10098 u32 *result = va_arg (*args, u32 *);
10101 if (unformat (input, "l2"))
10102 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10103 else if (unformat (input, "%d", &tmp))
10111 api_vxlan_add_del_tunnel (vat_main_t * vam)
10113 unformat_input_t *line_input = vam->input;
10114 vl_api_vxlan_add_del_tunnel_t *mp;
10116 ip4_address_t src4, dst4;
10117 ip6_address_t src6, dst6;
10119 u8 ipv4_set = 0, ipv6_set = 0;
10122 u32 encap_vrf_id = 0;
10123 u32 decap_next_index = ~0;
10126 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10128 if (unformat (line_input, "del"))
10130 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10135 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10140 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
10145 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
10150 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10152 else if (unformat (line_input, "decap-next %U",
10153 unformat_vxlan_decap_next, &decap_next_index))
10155 else if (unformat (line_input, "vni %d", &vni))
10159 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10166 errmsg ("tunnel src address not specified\n");
10171 errmsg ("tunnel dst address not specified\n");
10175 if (ipv4_set && ipv6_set)
10177 errmsg ("both IPv4 and IPv6 addresses specified");
10181 if ((vni == 0) || (vni >> 24))
10183 errmsg ("vni not specified or out of range\n");
10187 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10191 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
10192 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
10196 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10197 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10199 mp->encap_vrf_id = ntohl (encap_vrf_id);
10200 mp->decap_next_index = ntohl (decap_next_index);
10201 mp->vni = ntohl (vni);
10202 mp->is_add = is_add;
10203 mp->is_ipv6 = ipv6_set;
10211 static void vl_api_vxlan_tunnel_details_t_handler
10212 (vl_api_vxlan_tunnel_details_t * mp)
10214 vat_main_t *vam = &vat_main;
10216 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
10217 ntohl (mp->sw_if_index),
10218 format_ip46_address, &(mp->src_address[0]),
10220 format_ip46_address, &(mp->dst_address[0]),
10222 ntohl (mp->encap_vrf_id),
10223 ntohl (mp->decap_next_index), ntohl (mp->vni));
10226 static void vl_api_vxlan_tunnel_details_t_handler_json
10227 (vl_api_vxlan_tunnel_details_t * mp)
10229 vat_main_t *vam = &vat_main;
10230 vat_json_node_t *node = NULL;
10231 struct in_addr ip4;
10232 struct in6_addr ip6;
10234 if (VAT_JSON_ARRAY != vam->json_tree.type)
10236 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10237 vat_json_init_array (&vam->json_tree);
10239 node = vat_json_array_add (&vam->json_tree);
10241 vat_json_init_object (node);
10242 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10245 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
10246 vat_json_object_add_ip6 (node, "src_address", ip6);
10247 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
10248 vat_json_object_add_ip6 (node, "dst_address", ip6);
10252 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
10253 vat_json_object_add_ip4 (node, "src_address", ip4);
10254 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
10255 vat_json_object_add_ip4 (node, "dst_address", ip4);
10257 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10258 vat_json_object_add_uint (node, "decap_next_index",
10259 ntohl (mp->decap_next_index));
10260 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10261 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10265 api_vxlan_tunnel_dump (vat_main_t * vam)
10267 unformat_input_t *i = vam->input;
10268 vl_api_vxlan_tunnel_dump_t *mp;
10271 u8 sw_if_index_set = 0;
10273 /* Parse args required to build the message */
10274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10276 if (unformat (i, "sw_if_index %d", &sw_if_index))
10277 sw_if_index_set = 1;
10282 if (sw_if_index_set == 0)
10287 if (!vam->json_output)
10289 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
10290 "sw_if_index", "src_address", "dst_address",
10291 "encap_vrf_id", "decap_next_index", "vni");
10294 /* Get list of vxlan-tunnel interfaces */
10295 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10297 mp->sw_if_index = htonl (sw_if_index);
10301 /* Use a control ping for synchronization */
10303 vl_api_control_ping_t *mp;
10304 M (CONTROL_PING, control_ping);
10311 api_gre_add_del_tunnel (vat_main_t * vam)
10313 unformat_input_t *line_input = vam->input;
10314 vl_api_gre_add_del_tunnel_t *mp;
10316 ip4_address_t src4, dst4;
10321 u32 outer_fib_id = 0;
10323 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10325 if (unformat (line_input, "del"))
10327 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10329 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10331 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10333 else if (unformat (line_input, "teb"))
10337 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10344 errmsg ("tunnel src address not specified\n");
10349 errmsg ("tunnel dst address not specified\n");
10354 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10356 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10357 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10358 mp->outer_fib_id = ntohl (outer_fib_id);
10359 mp->is_add = is_add;
10368 static void vl_api_gre_tunnel_details_t_handler
10369 (vl_api_gre_tunnel_details_t * mp)
10371 vat_main_t *vam = &vat_main;
10373 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
10374 ntohl (mp->sw_if_index),
10375 format_ip4_address, &mp->src_address,
10376 format_ip4_address, &mp->dst_address,
10377 mp->teb, ntohl (mp->outer_fib_id));
10380 static void vl_api_gre_tunnel_details_t_handler_json
10381 (vl_api_gre_tunnel_details_t * mp)
10383 vat_main_t *vam = &vat_main;
10384 vat_json_node_t *node = NULL;
10385 struct in_addr ip4;
10387 if (VAT_JSON_ARRAY != vam->json_tree.type)
10389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10390 vat_json_init_array (&vam->json_tree);
10392 node = vat_json_array_add (&vam->json_tree);
10394 vat_json_init_object (node);
10395 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10396 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10397 vat_json_object_add_ip4 (node, "src_address", ip4);
10398 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10399 vat_json_object_add_ip4 (node, "dst_address", ip4);
10400 vat_json_object_add_uint (node, "teb", mp->teb);
10401 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10405 api_gre_tunnel_dump (vat_main_t * vam)
10407 unformat_input_t *i = vam->input;
10408 vl_api_gre_tunnel_dump_t *mp;
10411 u8 sw_if_index_set = 0;
10413 /* Parse args required to build the message */
10414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10416 if (unformat (i, "sw_if_index %d", &sw_if_index))
10417 sw_if_index_set = 1;
10422 if (sw_if_index_set == 0)
10427 if (!vam->json_output)
10429 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
10430 "sw_if_index", "src_address", "dst_address", "teb",
10434 /* Get list of gre-tunnel interfaces */
10435 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10437 mp->sw_if_index = htonl (sw_if_index);
10441 /* Use a control ping for synchronization */
10443 vl_api_control_ping_t *mp;
10444 M (CONTROL_PING, control_ping);
10451 api_l2_fib_clear_table (vat_main_t * vam)
10453 // unformat_input_t * i = vam->input;
10454 vl_api_l2_fib_clear_table_t *mp;
10457 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10466 api_l2_interface_efp_filter (vat_main_t * vam)
10468 unformat_input_t *i = vam->input;
10469 vl_api_l2_interface_efp_filter_t *mp;
10473 u8 sw_if_index_set = 0;
10475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10477 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10478 sw_if_index_set = 1;
10479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10480 sw_if_index_set = 1;
10481 else if (unformat (i, "enable"))
10483 else if (unformat (i, "disable"))
10487 clib_warning ("parse error '%U'", format_unformat_error, i);
10492 if (sw_if_index_set == 0)
10494 errmsg ("missing sw_if_index\n");
10498 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10500 mp->sw_if_index = ntohl (sw_if_index);
10501 mp->enable_disable = enable;
10509 #define foreach_vtr_op \
10510 _("disable", L2_VTR_DISABLED) \
10511 _("push-1", L2_VTR_PUSH_1) \
10512 _("push-2", L2_VTR_PUSH_2) \
10513 _("pop-1", L2_VTR_POP_1) \
10514 _("pop-2", L2_VTR_POP_2) \
10515 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10516 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10517 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10518 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10521 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10523 unformat_input_t *i = vam->input;
10524 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10527 u8 sw_if_index_set = 0;
10530 u32 push_dot1q = 1;
10534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10536 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10537 sw_if_index_set = 1;
10538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10539 sw_if_index_set = 1;
10540 else if (unformat (i, "vtr_op %d", &vtr_op))
10542 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10545 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10547 else if (unformat (i, "tag1 %d", &tag1))
10549 else if (unformat (i, "tag2 %d", &tag2))
10553 clib_warning ("parse error '%U'", format_unformat_error, i);
10558 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10560 errmsg ("missing vtr operation or sw_if_index\n");
10564 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10565 mp->sw_if_index = ntohl (sw_if_index);
10566 mp->vtr_op = ntohl (vtr_op);
10567 mp->push_dot1q = ntohl (push_dot1q);
10568 mp->tag1 = ntohl (tag1);
10569 mp->tag2 = ntohl (tag2);
10578 api_create_vhost_user_if (vat_main_t * vam)
10580 unformat_input_t *i = vam->input;
10581 vl_api_create_vhost_user_if_t *mp;
10585 u8 file_name_set = 0;
10586 u32 custom_dev_instance = ~0;
10588 u8 use_custom_mac = 0;
10590 /* Shut up coverity */
10591 memset (hwaddr, 0, sizeof (hwaddr));
10593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10595 if (unformat (i, "socket %s", &file_name))
10599 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10601 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10602 use_custom_mac = 1;
10603 else if (unformat (i, "server"))
10609 if (file_name_set == 0)
10611 errmsg ("missing socket file name\n");
10615 if (vec_len (file_name) > 255)
10617 errmsg ("socket file name too long\n");
10620 vec_add1 (file_name, 0);
10622 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10624 mp->is_server = is_server;
10625 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10626 vec_free (file_name);
10627 if (custom_dev_instance != ~0)
10630 mp->custom_dev_instance = ntohl (custom_dev_instance);
10632 mp->use_custom_mac = use_custom_mac;
10633 clib_memcpy (mp->mac_address, hwaddr, 6);
10642 api_modify_vhost_user_if (vat_main_t * vam)
10644 unformat_input_t *i = vam->input;
10645 vl_api_modify_vhost_user_if_t *mp;
10649 u8 file_name_set = 0;
10650 u32 custom_dev_instance = ~0;
10651 u8 sw_if_index_set = 0;
10652 u32 sw_if_index = (u32) ~ 0;
10654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10656 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10657 sw_if_index_set = 1;
10658 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10659 sw_if_index_set = 1;
10660 else if (unformat (i, "socket %s", &file_name))
10664 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10666 else if (unformat (i, "server"))
10672 if (sw_if_index_set == 0)
10674 errmsg ("missing sw_if_index or interface name\n");
10678 if (file_name_set == 0)
10680 errmsg ("missing socket file name\n");
10684 if (vec_len (file_name) > 255)
10686 errmsg ("socket file name too long\n");
10689 vec_add1 (file_name, 0);
10691 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10693 mp->sw_if_index = ntohl (sw_if_index);
10694 mp->is_server = is_server;
10695 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10696 vec_free (file_name);
10697 if (custom_dev_instance != ~0)
10700 mp->custom_dev_instance = ntohl (custom_dev_instance);
10710 api_delete_vhost_user_if (vat_main_t * vam)
10712 unformat_input_t *i = vam->input;
10713 vl_api_delete_vhost_user_if_t *mp;
10715 u32 sw_if_index = ~0;
10716 u8 sw_if_index_set = 0;
10718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10720 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10721 sw_if_index_set = 1;
10722 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10723 sw_if_index_set = 1;
10728 if (sw_if_index_set == 0)
10730 errmsg ("missing sw_if_index or interface name\n");
10735 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10737 mp->sw_if_index = ntohl (sw_if_index);
10745 static void vl_api_sw_interface_vhost_user_details_t_handler
10746 (vl_api_sw_interface_vhost_user_details_t * mp)
10748 vat_main_t *vam = &vat_main;
10750 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10751 (char *) mp->interface_name,
10752 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10753 clib_net_to_host_u64 (mp->features), mp->is_server,
10754 ntohl (mp->num_regions), (char *) mp->sock_filename);
10755 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10758 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10759 (vl_api_sw_interface_vhost_user_details_t * mp)
10761 vat_main_t *vam = &vat_main;
10762 vat_json_node_t *node = NULL;
10764 if (VAT_JSON_ARRAY != vam->json_tree.type)
10766 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10767 vat_json_init_array (&vam->json_tree);
10769 node = vat_json_array_add (&vam->json_tree);
10771 vat_json_init_object (node);
10772 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10773 vat_json_object_add_string_copy (node, "interface_name",
10774 mp->interface_name);
10775 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10776 ntohl (mp->virtio_net_hdr_sz));
10777 vat_json_object_add_uint (node, "features",
10778 clib_net_to_host_u64 (mp->features));
10779 vat_json_object_add_uint (node, "is_server", mp->is_server);
10780 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10781 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10782 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10786 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10788 vl_api_sw_interface_vhost_user_dump_t *mp;
10791 "Interface name idx hdr_sz features server regions filename\n");
10793 /* Get list of vhost-user interfaces */
10794 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10797 /* Use a control ping for synchronization */
10799 vl_api_control_ping_t *mp;
10800 M (CONTROL_PING, control_ping);
10807 api_show_version (vat_main_t * vam)
10809 vl_api_show_version_t *mp;
10812 M (SHOW_VERSION, show_version);
10822 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10824 unformat_input_t *line_input = vam->input;
10825 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10827 ip4_address_t local4, remote4;
10828 ip6_address_t local6, remote6;
10830 u8 ipv4_set = 0, ipv6_set = 0;
10833 u32 encap_vrf_id = 0;
10834 u32 decap_vrf_id = 0;
10839 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10841 if (unformat (line_input, "del"))
10843 else if (unformat (line_input, "local %U",
10844 unformat_ip4_address, &local4))
10849 else if (unformat (line_input, "remote %U",
10850 unformat_ip4_address, &remote4))
10855 else if (unformat (line_input, "local %U",
10856 unformat_ip6_address, &local6))
10861 else if (unformat (line_input, "remote %U",
10862 unformat_ip6_address, &remote6))
10867 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10869 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10871 else if (unformat (line_input, "vni %d", &vni))
10873 else if (unformat (line_input, "next-ip4"))
10875 else if (unformat (line_input, "next-ip6"))
10877 else if (unformat (line_input, "next-ethernet"))
10879 else if (unformat (line_input, "next-nsh"))
10883 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10888 if (local_set == 0)
10890 errmsg ("tunnel local address not specified\n");
10893 if (remote_set == 0)
10895 errmsg ("tunnel remote address not specified\n");
10898 if (ipv4_set && ipv6_set)
10900 errmsg ("both IPv4 and IPv6 addresses specified");
10906 errmsg ("vni not specified\n");
10910 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10915 clib_memcpy (&mp->local, &local6, sizeof (local6));
10916 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
10920 clib_memcpy (&mp->local, &local4, sizeof (local4));
10921 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
10924 mp->encap_vrf_id = ntohl (encap_vrf_id);
10925 mp->decap_vrf_id = ntohl (decap_vrf_id);
10926 mp->protocol = ntohl (protocol);
10927 mp->vni = ntohl (vni);
10928 mp->is_add = is_add;
10929 mp->is_ipv6 = ipv6_set;
10937 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10938 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10940 vat_main_t *vam = &vat_main;
10942 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
10943 ntohl (mp->sw_if_index),
10944 format_ip46_address, &(mp->local[0]),
10945 format_ip46_address, &(mp->remote[0]),
10947 ntohl (mp->protocol),
10948 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10951 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10952 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10954 vat_main_t *vam = &vat_main;
10955 vat_json_node_t *node = NULL;
10956 struct in_addr ip4;
10957 struct in6_addr ip6;
10959 if (VAT_JSON_ARRAY != vam->json_tree.type)
10961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10962 vat_json_init_array (&vam->json_tree);
10964 node = vat_json_array_add (&vam->json_tree);
10966 vat_json_init_object (node);
10967 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10970 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10971 vat_json_object_add_ip6 (node, "local", ip6);
10972 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10973 vat_json_object_add_ip6 (node, "remote", ip6);
10977 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10978 vat_json_object_add_ip4 (node, "local", ip4);
10979 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10980 vat_json_object_add_ip4 (node, "remote", ip4);
10982 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10983 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10984 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10985 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10986 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10990 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10992 unformat_input_t *i = vam->input;
10993 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10996 u8 sw_if_index_set = 0;
10998 /* Parse args required to build the message */
10999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11001 if (unformat (i, "sw_if_index %d", &sw_if_index))
11002 sw_if_index_set = 1;
11007 if (sw_if_index_set == 0)
11012 if (!vam->json_output)
11014 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
11015 "sw_if_index", "local", "remote", "vni",
11016 "protocol", "encap_vrf_id", "decap_vrf_id");
11019 /* Get list of vxlan-tunnel interfaces */
11020 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11022 mp->sw_if_index = htonl (sw_if_index);
11026 /* Use a control ping for synchronization */
11028 vl_api_control_ping_t *mp;
11029 M (CONTROL_PING, control_ping);
11036 format_l2_fib_mac_address (u8 * s, va_list * args)
11038 u8 *a = va_arg (*args, u8 *);
11040 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11041 a[2], a[3], a[4], a[5], a[6], a[7]);
11044 static void vl_api_l2_fib_table_entry_t_handler
11045 (vl_api_l2_fib_table_entry_t * mp)
11047 vat_main_t *vam = &vat_main;
11049 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11051 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11052 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11056 static void vl_api_l2_fib_table_entry_t_handler_json
11057 (vl_api_l2_fib_table_entry_t * mp)
11059 vat_main_t *vam = &vat_main;
11060 vat_json_node_t *node = NULL;
11062 if (VAT_JSON_ARRAY != vam->json_tree.type)
11064 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11065 vat_json_init_array (&vam->json_tree);
11067 node = vat_json_array_add (&vam->json_tree);
11069 vat_json_init_object (node);
11070 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11071 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11073 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11074 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11075 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11079 api_l2_fib_table_dump (vat_main_t * vam)
11081 unformat_input_t *i = vam->input;
11082 vl_api_l2_fib_table_dump_t *mp;
11087 /* Parse args required to build the message */
11088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11090 if (unformat (i, "bd_id %d", &bd_id))
11096 if (bd_id_set == 0)
11098 errmsg ("missing bridge domain\n");
11103 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
11105 /* Get list of l2 fib entries */
11106 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11108 mp->bd_id = ntohl (bd_id);
11111 /* Use a control ping for synchronization */
11113 vl_api_control_ping_t *mp;
11114 M (CONTROL_PING, control_ping);
11122 api_interface_name_renumber (vat_main_t * vam)
11124 unformat_input_t *line_input = vam->input;
11125 vl_api_interface_name_renumber_t *mp;
11126 u32 sw_if_index = ~0;
11128 u32 new_show_dev_instance = ~0;
11130 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11132 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
11135 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11137 else if (unformat (line_input, "new_show_dev_instance %d",
11138 &new_show_dev_instance))
11144 if (sw_if_index == ~0)
11146 errmsg ("missing interface name or sw_if_index\n");
11150 if (new_show_dev_instance == ~0)
11152 errmsg ("missing new_show_dev_instance\n");
11156 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11158 mp->sw_if_index = ntohl (sw_if_index);
11159 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11166 api_want_ip4_arp_events (vat_main_t * vam)
11168 unformat_input_t *line_input = vam->input;
11169 vl_api_want_ip4_arp_events_t *mp;
11171 ip4_address_t address;
11172 int address_set = 0;
11173 u32 enable_disable = 1;
11175 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11177 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11179 else if (unformat (line_input, "del"))
11180 enable_disable = 0;
11185 if (address_set == 0)
11187 errmsg ("missing addresses\n");
11191 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11192 mp->enable_disable = enable_disable;
11193 mp->pid = getpid ();
11194 mp->address = address.as_u32;
11201 api_want_ip6_nd_events (vat_main_t * vam)
11203 unformat_input_t *line_input = vam->input;
11204 vl_api_want_ip6_nd_events_t *mp;
11206 ip6_address_t address;
11207 int address_set = 0;
11208 u32 enable_disable = 1;
11210 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11212 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11214 else if (unformat (line_input, "del"))
11215 enable_disable = 0;
11220 if (address_set == 0)
11222 errmsg ("missing addresses\n");
11226 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11227 mp->enable_disable = enable_disable;
11228 mp->pid = getpid ();
11229 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11236 api_input_acl_set_interface (vat_main_t * vam)
11238 unformat_input_t *i = vam->input;
11239 vl_api_input_acl_set_interface_t *mp;
11242 int sw_if_index_set;
11243 u32 ip4_table_index = ~0;
11244 u32 ip6_table_index = ~0;
11245 u32 l2_table_index = ~0;
11248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11250 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11251 sw_if_index_set = 1;
11252 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11253 sw_if_index_set = 1;
11254 else if (unformat (i, "del"))
11256 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11258 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11260 else if (unformat (i, "l2-table %d", &l2_table_index))
11264 clib_warning ("parse error '%U'", format_unformat_error, i);
11269 if (sw_if_index_set == 0)
11271 errmsg ("missing interface name or sw_if_index\n");
11275 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11277 mp->sw_if_index = ntohl (sw_if_index);
11278 mp->ip4_table_index = ntohl (ip4_table_index);
11279 mp->ip6_table_index = ntohl (ip6_table_index);
11280 mp->l2_table_index = ntohl (l2_table_index);
11281 mp->is_add = is_add;
11290 api_ip_address_dump (vat_main_t * vam)
11292 unformat_input_t *i = vam->input;
11293 vl_api_ip_address_dump_t *mp;
11294 u32 sw_if_index = ~0;
11295 u8 sw_if_index_set = 0;
11300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11302 if (unformat (i, "sw_if_index %d", &sw_if_index))
11303 sw_if_index_set = 1;
11304 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11305 sw_if_index_set = 1;
11306 else if (unformat (i, "ipv4"))
11308 else if (unformat (i, "ipv6"))
11314 if (ipv4_set && ipv6_set)
11316 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11320 if ((!ipv4_set) && (!ipv6_set))
11322 errmsg ("no ipv4 nor ipv6 flag set\n");
11326 if (sw_if_index_set == 0)
11328 errmsg ("missing interface name or sw_if_index\n");
11332 vam->current_sw_if_index = sw_if_index;
11333 vam->is_ipv6 = ipv6_set;
11335 M (IP_ADDRESS_DUMP, ip_address_dump);
11336 mp->sw_if_index = ntohl (sw_if_index);
11337 mp->is_ipv6 = ipv6_set;
11340 /* Use a control ping for synchronization */
11342 vl_api_control_ping_t *mp;
11343 M (CONTROL_PING, control_ping);
11350 api_ip_dump (vat_main_t * vam)
11352 vl_api_ip_dump_t *mp;
11353 unformat_input_t *in = vam->input;
11360 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11362 if (unformat (in, "ipv4"))
11364 else if (unformat (in, "ipv6"))
11370 if (ipv4_set && ipv6_set)
11372 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11376 if ((!ipv4_set) && (!ipv6_set))
11378 errmsg ("no ipv4 nor ipv6 flag set\n");
11382 is_ipv6 = ipv6_set;
11383 vam->is_ipv6 = is_ipv6;
11385 /* free old data */
11386 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11388 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11390 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11392 M (IP_DUMP, ip_dump);
11393 mp->is_ipv6 = ipv6_set;
11396 /* Use a control ping for synchronization */
11398 vl_api_control_ping_t *mp;
11399 M (CONTROL_PING, control_ping);
11406 api_ipsec_spd_add_del (vat_main_t * vam)
11409 unformat_input_t *i = vam->input;
11410 vl_api_ipsec_spd_add_del_t *mp;
11415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11417 if (unformat (i, "spd_id %d", &spd_id))
11419 else if (unformat (i, "del"))
11423 clib_warning ("parse error '%U'", format_unformat_error, i);
11429 errmsg ("spd_id must be set\n");
11433 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11435 mp->spd_id = ntohl (spd_id);
11436 mp->is_add = is_add;
11443 clib_warning ("unsupported (no dpdk)");
11449 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11452 unformat_input_t *i = vam->input;
11453 vl_api_ipsec_interface_add_del_spd_t *mp;
11456 u8 sw_if_index_set = 0;
11457 u32 spd_id = (u32) ~ 0;
11460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11462 if (unformat (i, "del"))
11464 else if (unformat (i, "spd_id %d", &spd_id))
11466 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11467 sw_if_index_set = 1;
11468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11469 sw_if_index_set = 1;
11472 clib_warning ("parse error '%U'", format_unformat_error, i);
11478 if (spd_id == (u32) ~ 0)
11480 errmsg ("spd_id must be set\n");
11484 if (sw_if_index_set == 0)
11486 errmsg ("missing interface name or sw_if_index\n");
11490 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11492 mp->spd_id = ntohl (spd_id);
11493 mp->sw_if_index = ntohl (sw_if_index);
11494 mp->is_add = is_add;
11501 clib_warning ("unsupported (no dpdk)");
11507 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11510 unformat_input_t *i = vam->input;
11511 vl_api_ipsec_spd_add_del_entry_t *mp;
11513 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11514 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11516 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11517 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11518 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11519 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11521 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11522 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11523 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11524 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11525 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11526 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11530 if (unformat (i, "del"))
11532 if (unformat (i, "outbound"))
11534 if (unformat (i, "inbound"))
11536 else if (unformat (i, "spd_id %d", &spd_id))
11538 else if (unformat (i, "sa_id %d", &sa_id))
11540 else if (unformat (i, "priority %d", &priority))
11542 else if (unformat (i, "protocol %d", &protocol))
11544 else if (unformat (i, "lport_start %d", &lport_start))
11546 else if (unformat (i, "lport_stop %d", &lport_stop))
11548 else if (unformat (i, "rport_start %d", &rport_start))
11550 else if (unformat (i, "rport_stop %d", &rport_stop))
11554 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11560 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11567 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11573 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11580 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11586 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11593 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11599 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11605 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11607 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11609 clib_warning ("unsupported action: 'resolve'");
11615 clib_warning ("parse error '%U'", format_unformat_error, i);
11621 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11623 mp->spd_id = ntohl (spd_id);
11624 mp->priority = ntohl (priority);
11625 mp->is_outbound = is_outbound;
11627 mp->is_ipv6 = is_ipv6;
11628 if (is_ipv6 || is_ip_any)
11630 clib_memcpy (mp->remote_address_start, &raddr6_start,
11631 sizeof (ip6_address_t));
11632 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11633 sizeof (ip6_address_t));
11634 clib_memcpy (mp->local_address_start, &laddr6_start,
11635 sizeof (ip6_address_t));
11636 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11637 sizeof (ip6_address_t));
11641 clib_memcpy (mp->remote_address_start, &raddr4_start,
11642 sizeof (ip4_address_t));
11643 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11644 sizeof (ip4_address_t));
11645 clib_memcpy (mp->local_address_start, &laddr4_start,
11646 sizeof (ip4_address_t));
11647 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11648 sizeof (ip4_address_t));
11650 mp->protocol = (u8) protocol;
11651 mp->local_port_start = ntohs ((u16) lport_start);
11652 mp->local_port_stop = ntohs ((u16) lport_stop);
11653 mp->remote_port_start = ntohs ((u16) rport_start);
11654 mp->remote_port_stop = ntohs ((u16) rport_stop);
11655 mp->policy = (u8) policy;
11656 mp->sa_id = ntohl (sa_id);
11657 mp->is_add = is_add;
11658 mp->is_ip_any = is_ip_any;
11664 clib_warning ("unsupported (no dpdk)");
11670 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11673 unformat_input_t *i = vam->input;
11674 vl_api_ipsec_sad_add_del_entry_t *mp;
11676 u32 sad_id = 0, spi = 0;
11677 u8 *ck = 0, *ik = 0;
11680 u8 protocol = IPSEC_PROTOCOL_AH;
11681 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11682 u32 crypto_alg = 0, integ_alg = 0;
11683 ip4_address_t tun_src4;
11684 ip4_address_t tun_dst4;
11685 ip6_address_t tun_src6;
11686 ip6_address_t tun_dst6;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "del"))
11692 else if (unformat (i, "sad_id %d", &sad_id))
11694 else if (unformat (i, "spi %d", &spi))
11696 else if (unformat (i, "esp"))
11697 protocol = IPSEC_PROTOCOL_ESP;
11698 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11701 is_tunnel_ipv6 = 0;
11703 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11706 is_tunnel_ipv6 = 0;
11708 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11711 is_tunnel_ipv6 = 1;
11713 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11716 is_tunnel_ipv6 = 1;
11720 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11722 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11723 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
11725 clib_warning ("unsupported crypto-alg: '%U'",
11726 format_ipsec_crypto_alg, crypto_alg);
11730 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11734 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11736 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11737 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
11739 clib_warning ("unsupported integ-alg: '%U'",
11740 format_ipsec_integ_alg, integ_alg);
11744 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11748 clib_warning ("parse error '%U'", format_unformat_error, i);
11754 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11756 mp->sad_id = ntohl (sad_id);
11757 mp->is_add = is_add;
11758 mp->protocol = protocol;
11759 mp->spi = ntohl (spi);
11760 mp->is_tunnel = is_tunnel;
11761 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11762 mp->crypto_algorithm = crypto_alg;
11763 mp->integrity_algorithm = integ_alg;
11764 mp->crypto_key_length = vec_len (ck);
11765 mp->integrity_key_length = vec_len (ik);
11767 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11768 mp->crypto_key_length = sizeof (mp->crypto_key);
11770 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11771 mp->integrity_key_length = sizeof (mp->integrity_key);
11774 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11776 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11780 if (is_tunnel_ipv6)
11782 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11783 sizeof (ip6_address_t));
11784 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11785 sizeof (ip6_address_t));
11789 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11790 sizeof (ip4_address_t));
11791 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11792 sizeof (ip4_address_t));
11801 clib_warning ("unsupported (no dpdk)");
11807 api_ipsec_sa_set_key (vat_main_t * vam)
11810 unformat_input_t *i = vam->input;
11811 vl_api_ipsec_sa_set_key_t *mp;
11814 u8 *ck = 0, *ik = 0;
11816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11818 if (unformat (i, "sa_id %d", &sa_id))
11820 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11822 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11826 clib_warning ("parse error '%U'", format_unformat_error, i);
11831 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11833 mp->sa_id = ntohl (sa_id);
11834 mp->crypto_key_length = vec_len (ck);
11835 mp->integrity_key_length = vec_len (ik);
11837 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11838 mp->crypto_key_length = sizeof (mp->crypto_key);
11840 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11841 mp->integrity_key_length = sizeof (mp->integrity_key);
11844 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11846 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11853 clib_warning ("unsupported (no dpdk)");
11859 api_ikev2_profile_add_del (vat_main_t * vam)
11862 unformat_input_t *i = vam->input;
11863 vl_api_ikev2_profile_add_del_t *mp;
11868 const char *valid_chars = "a-zA-Z0-9_";
11870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11872 if (unformat (i, "del"))
11874 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11875 vec_add1 (name, 0);
11878 errmsg ("parse error '%U'", format_unformat_error, i);
11883 if (!vec_len (name))
11885 errmsg ("profile name must be specified");
11889 if (vec_len (name) > 64)
11891 errmsg ("profile name too long");
11895 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11897 clib_memcpy (mp->name, name, vec_len (name));
11898 mp->is_add = is_add;
11906 clib_warning ("unsupported (no dpdk)");
11912 api_ikev2_profile_set_auth (vat_main_t * vam)
11915 unformat_input_t *i = vam->input;
11916 vl_api_ikev2_profile_set_auth_t *mp;
11920 u32 auth_method = 0;
11923 const char *valid_chars = "a-zA-Z0-9_";
11925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11927 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11928 vec_add1 (name, 0);
11929 else if (unformat (i, "auth_method %U",
11930 unformat_ikev2_auth_method, &auth_method))
11932 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
11934 else if (unformat (i, "auth_data %v", &data))
11938 errmsg ("parse error '%U'", format_unformat_error, i);
11943 if (!vec_len (name))
11945 errmsg ("profile name must be specified");
11949 if (vec_len (name) > 64)
11951 errmsg ("profile name too long");
11955 if (!vec_len (data))
11957 errmsg ("auth_data must be specified");
11963 errmsg ("auth_method must be specified");
11967 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11969 mp->is_hex = is_hex;
11970 mp->auth_method = (u8) auth_method;
11971 mp->data_len = vec_len (data);
11972 clib_memcpy (mp->name, name, vec_len (name));
11973 clib_memcpy (mp->data, data, vec_len (data));
11982 clib_warning ("unsupported (no dpdk)");
11988 api_ikev2_profile_set_id (vat_main_t * vam)
11991 unformat_input_t *i = vam->input;
11992 vl_api_ikev2_profile_set_id_t *mp;
12000 const char *valid_chars = "a-zA-Z0-9_";
12002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12004 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12005 vec_add1 (name, 0);
12006 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12008 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12010 data = vec_new (u8, 4);
12011 clib_memcpy (data, ip4.as_u8, 4);
12013 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12015 else if (unformat (i, "id_data %v", &data))
12017 else if (unformat (i, "local"))
12019 else if (unformat (i, "remote"))
12023 errmsg ("parse error '%U'", format_unformat_error, i);
12028 if (!vec_len (name))
12030 errmsg ("profile name must be specified");
12034 if (vec_len (name) > 64)
12036 errmsg ("profile name too long");
12040 if (!vec_len (data))
12042 errmsg ("id_data must be specified");
12048 errmsg ("id_type must be specified");
12052 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12054 mp->is_local = is_local;
12055 mp->id_type = (u8) id_type;
12056 mp->data_len = vec_len (data);
12057 clib_memcpy (mp->name, name, vec_len (name));
12058 clib_memcpy (mp->data, data, vec_len (data));
12067 clib_warning ("unsupported (no dpdk)");
12073 api_ikev2_profile_set_ts (vat_main_t * vam)
12076 unformat_input_t *i = vam->input;
12077 vl_api_ikev2_profile_set_ts_t *mp;
12081 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12082 ip4_address_t start_addr, end_addr;
12084 const char *valid_chars = "a-zA-Z0-9_";
12086 start_addr.as_u32 = 0;
12087 end_addr.as_u32 = (u32) ~ 0;
12089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12091 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12092 vec_add1 (name, 0);
12093 else if (unformat (i, "protocol %d", &proto))
12095 else if (unformat (i, "start_port %d", &start_port))
12097 else if (unformat (i, "end_port %d", &end_port))
12100 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12102 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12104 else if (unformat (i, "local"))
12106 else if (unformat (i, "remote"))
12110 errmsg ("parse error '%U'", format_unformat_error, i);
12115 if (!vec_len (name))
12117 errmsg ("profile name must be specified");
12121 if (vec_len (name) > 64)
12123 errmsg ("profile name too long");
12127 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12129 mp->is_local = is_local;
12130 mp->proto = (u8) proto;
12131 mp->start_port = (u16) start_port;
12132 mp->end_port = (u16) end_port;
12133 mp->start_addr = start_addr.as_u32;
12134 mp->end_addr = end_addr.as_u32;
12135 clib_memcpy (mp->name, name, vec_len (name));
12143 clib_warning ("unsupported (no dpdk)");
12149 api_ikev2_set_local_key (vat_main_t * vam)
12152 unformat_input_t *i = vam->input;
12153 vl_api_ikev2_set_local_key_t *mp;
12157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12159 if (unformat (i, "file %v", &file))
12160 vec_add1 (file, 0);
12163 errmsg ("parse error '%U'", format_unformat_error, i);
12168 if (!vec_len (file))
12170 errmsg ("RSA key file must be specified");
12174 if (vec_len (file) > 256)
12176 errmsg ("file name too long");
12180 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12182 clib_memcpy (mp->key_file, file, vec_len (file));
12190 clib_warning ("unsupported (no dpdk)");
12199 api_map_add_domain (vat_main_t * vam)
12201 unformat_input_t *i = vam->input;
12202 vl_api_map_add_domain_t *mp;
12205 ip4_address_t ip4_prefix;
12206 ip6_address_t ip6_prefix;
12207 ip6_address_t ip6_src;
12208 u32 num_m_args = 0;
12209 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12210 0, psid_length = 0;
12211 u8 is_translation = 0;
12213 u32 ip6_src_len = 128;
12215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12217 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12218 &ip4_prefix, &ip4_prefix_len))
12220 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12221 &ip6_prefix, &ip6_prefix_len))
12225 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12228 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12230 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12232 else if (unformat (i, "psid-offset %d", &psid_offset))
12234 else if (unformat (i, "psid-len %d", &psid_length))
12236 else if (unformat (i, "mtu %d", &mtu))
12238 else if (unformat (i, "map-t"))
12239 is_translation = 1;
12242 clib_warning ("parse error '%U'", format_unformat_error, i);
12247 if (num_m_args < 3)
12249 errmsg ("mandatory argument(s) missing\n");
12253 /* Construct the API message */
12254 M (MAP_ADD_DOMAIN, map_add_domain);
12256 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12257 mp->ip4_prefix_len = ip4_prefix_len;
12259 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12260 mp->ip6_prefix_len = ip6_prefix_len;
12262 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12263 mp->ip6_src_prefix_len = ip6_src_len;
12265 mp->ea_bits_len = ea_bits_len;
12266 mp->psid_offset = psid_offset;
12267 mp->psid_length = psid_length;
12268 mp->is_translation = is_translation;
12269 mp->mtu = htons (mtu);
12274 /* Wait for a reply, return good/bad news */
12279 api_map_del_domain (vat_main_t * vam)
12281 unformat_input_t *i = vam->input;
12282 vl_api_map_del_domain_t *mp;
12285 u32 num_m_args = 0;
12288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12290 if (unformat (i, "index %d", &index))
12294 clib_warning ("parse error '%U'", format_unformat_error, i);
12299 if (num_m_args != 1)
12301 errmsg ("mandatory argument(s) missing\n");
12305 /* Construct the API message */
12306 M (MAP_DEL_DOMAIN, map_del_domain);
12308 mp->index = ntohl (index);
12313 /* Wait for a reply, return good/bad news */
12318 api_map_add_del_rule (vat_main_t * vam)
12320 unformat_input_t *i = vam->input;
12321 vl_api_map_add_del_rule_t *mp;
12324 ip6_address_t ip6_dst;
12325 u32 num_m_args = 0, index, psid = 0;
12327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12329 if (unformat (i, "index %d", &index))
12331 else if (unformat (i, "psid %d", &psid))
12333 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12335 else if (unformat (i, "del"))
12341 clib_warning ("parse error '%U'", format_unformat_error, i);
12346 /* Construct the API message */
12347 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12349 mp->index = ntohl (index);
12350 mp->is_add = is_add;
12351 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12352 mp->psid = ntohs (psid);
12357 /* Wait for a reply, return good/bad news */
12362 api_map_domain_dump (vat_main_t * vam)
12364 vl_api_map_domain_dump_t *mp;
12367 /* Construct the API message */
12368 M (MAP_DOMAIN_DUMP, map_domain_dump);
12373 /* Use a control ping for synchronization */
12375 vl_api_control_ping_t *mp;
12376 M (CONTROL_PING, control_ping);
12383 api_map_rule_dump (vat_main_t * vam)
12385 unformat_input_t *i = vam->input;
12386 vl_api_map_rule_dump_t *mp;
12388 u32 domain_index = ~0;
12390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12392 if (unformat (i, "index %u", &domain_index))
12398 if (domain_index == ~0)
12400 clib_warning ("parse error: domain index expected");
12404 /* Construct the API message */
12405 M (MAP_RULE_DUMP, map_rule_dump);
12407 mp->domain_index = htonl (domain_index);
12412 /* Use a control ping for synchronization */
12414 vl_api_control_ping_t *mp;
12415 M (CONTROL_PING, control_ping);
12421 static void vl_api_map_add_domain_reply_t_handler
12422 (vl_api_map_add_domain_reply_t * mp)
12424 vat_main_t *vam = &vat_main;
12425 i32 retval = ntohl (mp->retval);
12427 if (vam->async_mode)
12429 vam->async_errors += (retval < 0);
12433 vam->retval = retval;
12434 vam->result_ready = 1;
12438 static void vl_api_map_add_domain_reply_t_handler_json
12439 (vl_api_map_add_domain_reply_t * mp)
12441 vat_main_t *vam = &vat_main;
12442 vat_json_node_t node;
12444 vat_json_init_object (&node);
12445 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12446 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12448 vat_json_print (vam->ofp, &node);
12449 vat_json_free (&node);
12451 vam->retval = ntohl (mp->retval);
12452 vam->result_ready = 1;
12456 api_get_first_msg_id (vat_main_t * vam)
12458 vl_api_get_first_msg_id_t *mp;
12460 unformat_input_t *i = vam->input;
12464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12466 if (unformat (i, "client %s", &name))
12474 errmsg ("missing client name\n");
12477 vec_add1 (name, 0);
12479 if (vec_len (name) > 63)
12481 errmsg ("client name too long\n");
12485 M (GET_FIRST_MSG_ID, get_first_msg_id);
12486 clib_memcpy (mp->name, name, vec_len (name));
12494 api_cop_interface_enable_disable (vat_main_t * vam)
12496 unformat_input_t *line_input = vam->input;
12497 vl_api_cop_interface_enable_disable_t *mp;
12499 u32 sw_if_index = ~0;
12500 u8 enable_disable = 1;
12502 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12504 if (unformat (line_input, "disable"))
12505 enable_disable = 0;
12506 if (unformat (line_input, "enable"))
12507 enable_disable = 1;
12508 else if (unformat (line_input, "%U", unformat_sw_if_index,
12509 vam, &sw_if_index))
12511 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12517 if (sw_if_index == ~0)
12519 errmsg ("missing interface name or sw_if_index\n");
12523 /* Construct the API message */
12524 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12525 mp->sw_if_index = ntohl (sw_if_index);
12526 mp->enable_disable = enable_disable;
12530 /* Wait for the reply */
12535 api_cop_whitelist_enable_disable (vat_main_t * vam)
12537 unformat_input_t *line_input = vam->input;
12538 vl_api_cop_whitelist_enable_disable_t *mp;
12540 u32 sw_if_index = ~0;
12541 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12544 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12546 if (unformat (line_input, "ip4"))
12548 else if (unformat (line_input, "ip6"))
12550 else if (unformat (line_input, "default"))
12552 else if (unformat (line_input, "%U", unformat_sw_if_index,
12553 vam, &sw_if_index))
12555 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12557 else if (unformat (line_input, "fib-id %d", &fib_id))
12563 if (sw_if_index == ~0)
12565 errmsg ("missing interface name or sw_if_index\n");
12569 /* Construct the API message */
12570 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12571 mp->sw_if_index = ntohl (sw_if_index);
12572 mp->fib_id = ntohl (fib_id);
12575 mp->default_cop = default_cop;
12579 /* Wait for the reply */
12584 api_get_node_graph (vat_main_t * vam)
12586 vl_api_get_node_graph_t *mp;
12589 M (GET_NODE_GRAPH, get_node_graph);
12593 /* Wait for the reply */
12598 /** Used for parsing LISP eids */
12599 typedef CLIB_PACKED(struct{
12600 u8 addr[16]; /**< eid address */
12601 u32 len; /**< prefix length if IP */
12602 u8 type; /**< type of eid */
12607 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12609 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12611 memset (a, 0, sizeof (a[0]));
12613 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12615 a->type = 0; /* ipv4 type */
12617 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12619 a->type = 1; /* ipv6 type */
12621 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12623 a->type = 2; /* mac type */
12630 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12639 lisp_eid_size_vat (u8 type)
12654 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12656 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12660 /** Used for transferring locators via VPP API */
12661 typedef CLIB_PACKED(struct
12663 u32 sw_if_index; /**< locator sw_if_index */
12664 u8 priority; /**< locator priority */
12665 u8 weight; /**< locator weight */
12670 api_lisp_add_del_locator_set (vat_main_t * vam)
12672 unformat_input_t *input = vam->input;
12673 vl_api_lisp_add_del_locator_set_t *mp;
12676 u8 *locator_set_name = NULL;
12677 u8 locator_set_name_set = 0;
12678 ls_locator_t locator, *locators = 0;
12679 u32 sw_if_index, priority, weight;
12682 /* Parse args required to build the message */
12683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12685 if (unformat (input, "del"))
12689 else if (unformat (input, "locator-set %s", &locator_set_name))
12691 locator_set_name_set = 1;
12693 else if (unformat (input, "sw_if_index %u p %u w %u",
12694 &sw_if_index, &priority, &weight))
12696 locator.sw_if_index = htonl (sw_if_index);
12697 locator.priority = priority;
12698 locator.weight = weight;
12699 vec_add1 (locators, locator);
12701 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12702 vam, &sw_if_index, &priority, &weight))
12704 locator.sw_if_index = htonl (sw_if_index);
12705 locator.priority = priority;
12706 locator.weight = weight;
12707 vec_add1 (locators, locator);
12713 if (locator_set_name_set == 0)
12715 errmsg ("missing locator-set name");
12716 vec_free (locators);
12720 if (vec_len (locator_set_name) > 64)
12722 errmsg ("locator-set name too long\n");
12723 vec_free (locator_set_name);
12724 vec_free (locators);
12727 vec_add1 (locator_set_name, 0);
12729 data_len = sizeof (ls_locator_t) * vec_len (locators);
12731 /* Construct the API message */
12732 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12734 mp->is_add = is_add;
12735 clib_memcpy (mp->locator_set_name, locator_set_name,
12736 vec_len (locator_set_name));
12737 vec_free (locator_set_name);
12739 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12741 clib_memcpy (mp->locators, locators, data_len);
12742 vec_free (locators);
12747 /* Wait for a reply... */
12755 api_lisp_add_del_locator (vat_main_t * vam)
12757 unformat_input_t *input = vam->input;
12758 vl_api_lisp_add_del_locator_t *mp;
12760 u32 tmp_if_index = ~0;
12761 u32 sw_if_index = ~0;
12762 u8 sw_if_index_set = 0;
12763 u8 sw_if_index_if_name_set = 0;
12765 u8 priority_set = 0;
12769 u8 *locator_set_name = NULL;
12770 u8 locator_set_name_set = 0;
12772 /* Parse args required to build the message */
12773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12775 if (unformat (input, "del"))
12779 else if (unformat (input, "locator-set %s", &locator_set_name))
12781 locator_set_name_set = 1;
12783 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12786 sw_if_index_if_name_set = 1;
12787 sw_if_index = tmp_if_index;
12789 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12791 sw_if_index_set = 1;
12792 sw_if_index = tmp_if_index;
12794 else if (unformat (input, "p %d", &priority))
12798 else if (unformat (input, "w %d", &weight))
12806 if (locator_set_name_set == 0)
12808 errmsg ("missing locator-set name");
12812 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12814 errmsg ("missing sw_if_index");
12815 vec_free (locator_set_name);
12819 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12821 errmsg ("cannot use both params interface name and sw_if_index");
12822 vec_free (locator_set_name);
12826 if (priority_set == 0)
12828 errmsg ("missing locator-set priority\n");
12829 vec_free (locator_set_name);
12833 if (weight_set == 0)
12835 errmsg ("missing locator-set weight\n");
12836 vec_free (locator_set_name);
12840 if (vec_len (locator_set_name) > 64)
12842 errmsg ("locator-set name too long\n");
12843 vec_free (locator_set_name);
12846 vec_add1 (locator_set_name, 0);
12848 /* Construct the API message */
12849 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12851 mp->is_add = is_add;
12852 mp->sw_if_index = ntohl (sw_if_index);
12853 mp->priority = priority;
12854 mp->weight = weight;
12855 clib_memcpy (mp->locator_set_name, locator_set_name,
12856 vec_len (locator_set_name));
12857 vec_free (locator_set_name);
12862 /* Wait for a reply... */
12870 api_lisp_add_del_local_eid (vat_main_t * vam)
12872 unformat_input_t *input = vam->input;
12873 vl_api_lisp_add_del_local_eid_t *mp;
12877 lisp_eid_vat_t _eid, *eid = &_eid;
12878 u8 *locator_set_name = 0;
12879 u8 locator_set_name_set = 0;
12882 /* Parse args required to build the message */
12883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12885 if (unformat (input, "del"))
12889 else if (unformat (input, "vni %d", &vni))
12893 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12897 else if (unformat (input, "locator-set %s", &locator_set_name))
12899 locator_set_name_set = 1;
12905 if (locator_set_name_set == 0)
12907 errmsg ("missing locator-set name\n");
12913 errmsg ("EID address not set!");
12914 vec_free (locator_set_name);
12918 if (vec_len (locator_set_name) > 64)
12920 errmsg ("locator-set name too long\n");
12921 vec_free (locator_set_name);
12924 vec_add1 (locator_set_name, 0);
12926 /* Construct the API message */
12927 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12929 mp->is_add = is_add;
12930 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12931 mp->eid_type = eid->type;
12932 mp->prefix_len = eid->len;
12933 mp->vni = clib_host_to_net_u32 (vni);
12934 clib_memcpy (mp->locator_set_name, locator_set_name,
12935 vec_len (locator_set_name));
12937 vec_free (locator_set_name);
12942 /* Wait for a reply... */
12950 /** Used for transferring locators via VPP API */
12951 typedef CLIB_PACKED(struct
12953 u8 is_ip4; /**< is locator an IPv4 address? */
12954 u8 priority; /**< locator priority */
12955 u8 weight; /**< locator weight */
12956 u8 addr[16]; /**< IPv4/IPv6 address */
12961 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12963 unformat_input_t *input = vam->input;
12964 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12967 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12968 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12969 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12970 u32 action = ~0, p, w;
12971 ip4_address_t rmt_rloc4, lcl_rloc4;
12972 ip6_address_t rmt_rloc6, lcl_rloc6;
12973 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12975 memset (&rloc, 0, sizeof (rloc));
12977 /* Parse args required to build the message */
12978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12980 if (unformat (input, "del"))
12984 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12988 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12992 else if (unformat (input, "p %d w %d", &p, &w))
12996 errmsg ("No RLOC configured for setting priority/weight!");
12999 curr_rloc->priority = p;
13000 curr_rloc->weight = w;
13002 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13003 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13007 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13008 rloc.priority = rloc.weight = 0;
13009 vec_add1 (lcl_locs, rloc);
13011 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13012 vec_add1 (rmt_locs, rloc);
13013 /* priority and weight saved in rmt loc */
13014 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13016 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13017 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13020 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13021 rloc.priority = rloc.weight = 0;
13022 vec_add1 (lcl_locs, rloc);
13024 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13025 vec_add1 (rmt_locs, rloc);
13026 /* priority and weight saved in rmt loc */
13027 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13029 else if (unformat (input, "action %d", &action))
13035 clib_warning ("parse error '%U'", format_unformat_error, input);
13042 errmsg ("remote eid addresses not set\n");
13046 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13048 errmsg ("eid types don't match\n");
13052 if (0 == rmt_locs && (u32) ~ 0 == action)
13054 errmsg ("action not set for negative mapping\n");
13058 /* Construct the API message */
13059 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13061 mp->is_add = is_add;
13062 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13063 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13064 mp->eid_type = rmt_eid->type;
13065 mp->rmt_len = rmt_eid->len;
13066 mp->lcl_len = lcl_eid->len;
13067 mp->action = action;
13069 if (0 != rmt_locs && 0 != lcl_locs)
13071 mp->loc_num = vec_len (rmt_locs);
13072 clib_memcpy (mp->lcl_locs, lcl_locs,
13073 (sizeof (rloc_t) * vec_len (lcl_locs)));
13074 clib_memcpy (mp->rmt_locs, rmt_locs,
13075 (sizeof (rloc_t) * vec_len (rmt_locs)));
13077 vec_free (lcl_locs);
13078 vec_free (rmt_locs);
13083 /* Wait for a reply... */
13091 api_lisp_add_del_map_resolver (vat_main_t * vam)
13093 unformat_input_t *input = vam->input;
13094 vl_api_lisp_add_del_map_resolver_t *mp;
13099 ip4_address_t ipv4;
13100 ip6_address_t ipv6;
13102 /* Parse args required to build the message */
13103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13105 if (unformat (input, "del"))
13109 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13113 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13121 if (ipv4_set && ipv6_set)
13123 errmsg ("both eid v4 and v6 addresses set\n");
13127 if (!ipv4_set && !ipv6_set)
13129 errmsg ("eid addresses not set\n");
13133 /* Construct the API message */
13134 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13136 mp->is_add = is_add;
13140 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13145 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13151 /* Wait for a reply... */
13159 api_lisp_gpe_enable_disable (vat_main_t * vam)
13161 unformat_input_t *input = vam->input;
13162 vl_api_lisp_gpe_enable_disable_t *mp;
13167 /* Parse args required to build the message */
13168 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13170 if (unformat (input, "enable"))
13175 else if (unformat (input, "disable"))
13186 errmsg ("Value not set\n");
13190 /* Construct the API message */
13191 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13198 /* Wait for a reply... */
13206 api_lisp_enable_disable (vat_main_t * vam)
13208 unformat_input_t *input = vam->input;
13209 vl_api_lisp_enable_disable_t *mp;
13214 /* Parse args required to build the message */
13215 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13217 if (unformat (input, "enable"))
13222 else if (unformat (input, "disable"))
13232 errmsg ("Value not set\n");
13236 /* Construct the API message */
13237 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13244 /* Wait for a reply... */
13252 api_show_lisp_map_request_mode (vat_main_t * vam)
13255 vl_api_show_lisp_map_request_mode_t *mp;
13257 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13262 /* wait for reply */
13269 api_lisp_map_request_mode (vat_main_t * vam)
13272 unformat_input_t *input = vam->input;
13273 vl_api_lisp_map_request_mode_t *mp;
13276 /* Parse args required to build the message */
13277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13279 if (unformat (input, "dst-only"))
13281 else if (unformat (input, "src-dst"))
13285 errmsg ("parse error '%U'", format_unformat_error, input);
13290 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13297 /* wait for reply */
13305 * Enable/disable LISP proxy ITR.
13307 * @param vam vpp API test context
13308 * @return return code
13311 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13314 u8 ls_name_set = 0;
13315 unformat_input_t *input = vam->input;
13316 vl_api_lisp_pitr_set_locator_set_t *mp;
13320 /* Parse args required to build the message */
13321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13323 if (unformat (input, "del"))
13325 else if (unformat (input, "locator-set %s", &ls_name))
13329 errmsg ("parse error '%U'", format_unformat_error, input);
13336 errmsg ("locator-set name not set!");
13340 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13342 mp->is_add = is_add;
13343 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13344 vec_free (ls_name);
13349 /* wait for reply */
13357 api_show_lisp_pitr (vat_main_t * vam)
13359 vl_api_show_lisp_pitr_t *mp;
13362 if (!vam->json_output)
13364 fformat (vam->ofp, "%=20s\n", "lisp status:");
13367 M (SHOW_LISP_PITR, show_lisp_pitr);
13371 /* Wait for a reply... */
13379 * Add/delete mapping between vni and vrf
13382 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13385 unformat_input_t *input = vam->input;
13386 vl_api_lisp_eid_table_add_del_map_t *mp;
13387 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13388 u32 vni, vrf, bd_index;
13390 /* Parse args required to build the message */
13391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13393 if (unformat (input, "del"))
13395 else if (unformat (input, "vrf %d", &vrf))
13397 else if (unformat (input, "bd_index %d", &bd_index))
13399 else if (unformat (input, "vni %d", &vni))
13405 if (!vni_set || (!vrf_set && !bd_index_set))
13407 errmsg ("missing arguments!");
13411 if (vrf_set && bd_index_set)
13413 errmsg ("error: both vrf and bd entered!");
13417 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13419 mp->is_add = is_add;
13420 mp->vni = htonl (vni);
13421 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13422 mp->is_l2 = bd_index_set;
13427 /* wait for reply */
13435 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13437 u32 *action = va_arg (*args, u32 *);
13440 if (unformat (input, "%s", &s))
13442 if (!strcmp ((char *) s, "no-action"))
13444 else if (!strcmp ((char *) s, "natively-forward"))
13446 else if (!strcmp ((char *) s, "send-map-request"))
13448 else if (!strcmp ((char *) s, "drop"))
13452 clib_warning ("invalid action: '%s'", s);
13464 * Add/del remote mapping to/from LISP control plane
13466 * @param vam vpp API test context
13467 * @return return code
13470 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13472 unformat_input_t *input = vam->input;
13473 vl_api_lisp_add_del_remote_mapping_t *mp;
13476 lisp_eid_vat_t _eid, *eid = &_eid;
13477 lisp_eid_vat_t _seid, *seid = &_seid;
13478 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13479 u32 action = ~0, p, w, data_len;
13480 ip4_address_t rloc4;
13481 ip6_address_t rloc6;
13482 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13484 memset (&rloc, 0, sizeof (rloc));
13486 /* Parse args required to build the message */
13487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13489 if (unformat (input, "del-all"))
13493 else if (unformat (input, "del"))
13497 else if (unformat (input, "add"))
13501 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13505 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13509 else if (unformat (input, "vni %d", &vni))
13513 else if (unformat (input, "p %d w %d", &p, &w))
13517 errmsg ("No RLOC configured for setting priority/weight!");
13520 curr_rloc->priority = p;
13521 curr_rloc->weight = w;
13523 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13526 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13527 vec_add1 (rlocs, rloc);
13528 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13530 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13533 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13534 vec_add1 (rlocs, rloc);
13535 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13537 else if (unformat (input, "action %U",
13538 unformat_negative_mapping_action, &action))
13544 clib_warning ("parse error '%U'", format_unformat_error, input);
13551 errmsg ("missing params!");
13555 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13557 errmsg ("no action set for negative map-reply!");
13561 data_len = vec_len (rlocs) * sizeof (rloc_t);
13563 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13564 mp->is_add = is_add;
13565 mp->vni = htonl (vni);
13566 mp->action = (u8) action;
13567 mp->is_src_dst = seid_set;
13568 mp->eid_len = eid->len;
13569 mp->seid_len = seid->len;
13570 mp->del_all = del_all;
13571 mp->eid_type = eid->type;
13572 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13573 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13575 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13576 clib_memcpy (mp->rlocs, rlocs, data_len);
13582 /* Wait for a reply... */
13590 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13591 * forwarding entries in data-plane accordingly.
13593 * @param vam vpp API test context
13594 * @return return code
13597 api_lisp_add_del_adjacency (vat_main_t * vam)
13599 unformat_input_t *input = vam->input;
13600 vl_api_lisp_add_del_adjacency_t *mp;
13603 ip4_address_t leid4, reid4;
13604 ip6_address_t leid6, reid6;
13605 u8 reid_mac[6] = { 0 };
13606 u8 leid_mac[6] = { 0 };
13607 u8 reid_type, leid_type;
13608 u32 leid_len = 0, reid_len = 0, len;
13611 leid_type = reid_type = (u8) ~ 0;
13613 /* Parse args required to build the message */
13614 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13616 if (unformat (input, "del"))
13620 else if (unformat (input, "add"))
13624 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13627 reid_type = 0; /* ipv4 */
13630 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13633 reid_type = 1; /* ipv6 */
13636 else if (unformat (input, "reid %U", unformat_ethernet_address,
13639 reid_type = 2; /* mac */
13641 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13644 leid_type = 0; /* ipv4 */
13647 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
13650 leid_type = 1; /* ipv6 */
13653 else if (unformat (input, "leid %U", unformat_ethernet_address,
13656 leid_type = 2; /* mac */
13658 else if (unformat (input, "vni %d", &vni))
13664 errmsg ("parse error '%U'", format_unformat_error, input);
13669 if ((u8) ~ 0 == reid_type)
13671 errmsg ("missing params!");
13675 if (leid_type != reid_type)
13677 errmsg ("remote and local EIDs are of different types!");
13681 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
13682 mp->is_add = is_add;
13683 mp->vni = htonl (vni);
13684 mp->leid_len = leid_len;
13685 mp->reid_len = reid_len;
13686 mp->eid_type = reid_type;
13688 switch (mp->eid_type)
13691 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
13692 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
13695 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
13696 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
13699 clib_memcpy (mp->leid, leid_mac, 6);
13700 clib_memcpy (mp->reid, reid_mac, 6);
13703 errmsg ("unknown EID type %d!", mp->eid_type);
13710 /* Wait for a reply... */
13718 api_lisp_gpe_add_del_iface (vat_main_t * vam)
13720 unformat_input_t *input = vam->input;
13721 vl_api_lisp_gpe_add_del_iface_t *mp;
13723 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
13724 u32 dp_table = 0, vni = 0;
13726 /* Parse args required to build the message */
13727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13729 if (unformat (input, "up"))
13734 else if (unformat (input, "down"))
13739 else if (unformat (input, "table_id %d", &dp_table))
13743 else if (unformat (input, "bd_id %d", &dp_table))
13748 else if (unformat (input, "vni %d", &vni))
13756 if (action_set == 0)
13758 errmsg ("Action not set\n");
13761 if (dp_table_set == 0 || vni_set == 0)
13763 errmsg ("vni and dp_table must be set\n");
13767 /* Construct the API message */
13768 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
13770 mp->is_add = is_add;
13771 mp->dp_table = dp_table;
13778 /* Wait for a reply... */
13786 * Add/del map request itr rlocs from LISP control plane and updates
13788 * @param vam vpp API test context
13789 * @return return code
13792 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
13794 unformat_input_t *input = vam->input;
13795 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
13797 u8 *locator_set_name = 0;
13798 u8 locator_set_name_set = 0;
13801 /* Parse args required to build the message */
13802 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13804 if (unformat (input, "del"))
13808 else if (unformat (input, "%_%v%_", &locator_set_name))
13810 locator_set_name_set = 1;
13814 clib_warning ("parse error '%U'", format_unformat_error, input);
13819 if (is_add && !locator_set_name_set)
13821 errmsg ("itr-rloc is not set!");
13825 if (is_add && vec_len (locator_set_name) > 64)
13827 errmsg ("itr-rloc locator-set name too long\n");
13828 vec_free (locator_set_name);
13832 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
13833 mp->is_add = is_add;
13836 clib_memcpy (mp->locator_set_name, locator_set_name,
13837 vec_len (locator_set_name));
13841 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
13843 vec_free (locator_set_name);
13848 /* Wait for a reply... */
13856 api_lisp_locator_dump (vat_main_t * vam)
13858 unformat_input_t *input = vam->input;
13859 vl_api_lisp_locator_dump_t *mp;
13861 u8 is_index_set = 0, is_name_set = 0;
13865 /* Parse args required to build the message */
13866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13868 if (unformat (input, "ls_name %_%v%_", &ls_name))
13872 else if (unformat (input, "ls_index %d", &ls_index))
13878 errmsg ("parse error '%U'", format_unformat_error, input);
13883 if (!is_index_set && !is_name_set)
13885 errmsg ("error: expected one of index or name!\n");
13889 if (is_index_set && is_name_set)
13891 errmsg ("error: only one param expected!\n");
13895 if (vec_len (ls_name) > 62)
13897 errmsg ("error: locator set name too long!");
13901 if (!vam->json_output)
13903 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
13907 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
13908 mp->is_index_set = is_index_set;
13911 mp->ls_index = clib_host_to_net_u32 (ls_index);
13914 vec_add1 (ls_name, 0);
13915 strncpy ((char *) mp->ls_name, (char *) ls_name,
13916 sizeof (mp->ls_name) - 1);
13922 /* Use a control ping for synchronization */
13924 vl_api_control_ping_t *mp;
13925 M (CONTROL_PING, control_ping);
13928 /* Wait for a reply... */
13936 api_lisp_locator_set_dump (vat_main_t * vam)
13938 vl_api_lisp_locator_set_dump_t *mp;
13939 unformat_input_t *input = vam->input;
13943 /* Parse args required to build the message */
13944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13946 if (unformat (input, "local"))
13950 else if (unformat (input, "remote"))
13956 errmsg ("parse error '%U'", format_unformat_error, input);
13961 if (!vam->json_output)
13963 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
13966 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13968 mp->filter = filter;
13973 /* Use a control ping for synchronization */
13975 vl_api_control_ping_t *mp;
13976 M (CONTROL_PING, control_ping);
13979 /* Wait for a reply... */
13987 api_lisp_eid_table_map_dump (vat_main_t * vam)
13991 unformat_input_t *input = vam->input;
13992 vl_api_lisp_eid_table_map_dump_t *mp;
13995 /* Parse args required to build the message */
13996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13998 if (unformat (input, "l2"))
14003 else if (unformat (input, "l3"))
14010 errmsg ("parse error '%U'", format_unformat_error, input);
14017 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
14021 if (!vam->json_output)
14023 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
14026 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14032 /* Use a control ping for synchronization */
14034 vl_api_control_ping_t *mp;
14035 M (CONTROL_PING, control_ping);
14038 /* Wait for a reply... */
14046 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14048 vl_api_lisp_eid_table_vni_dump_t *mp;
14051 if (!vam->json_output)
14053 fformat (vam->ofp, "VNI\n");
14056 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14061 /* Use a control ping for synchronization */
14063 vl_api_control_ping_t *mp;
14064 M (CONTROL_PING, control_ping);
14067 /* Wait for a reply... */
14075 api_lisp_eid_table_dump (vat_main_t * vam)
14077 unformat_input_t *i = vam->input;
14078 vl_api_lisp_eid_table_dump_t *mp;
14080 struct in_addr ip4;
14081 struct in6_addr ip6;
14083 u8 eid_type = ~0, eid_set = 0;
14084 u32 prefix_length = ~0, t, vni = 0;
14087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14089 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14095 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14101 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14106 else if (unformat (i, "vni %d", &t))
14110 else if (unformat (i, "local"))
14114 else if (unformat (i, "remote"))
14120 errmsg ("parse error '%U'", format_unformat_error, i);
14125 if (!vam->json_output)
14127 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
14128 "ls_index", "ttl", "authoritative");
14131 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14133 mp->filter = filter;
14137 mp->vni = htonl (vni);
14138 mp->eid_type = eid_type;
14142 mp->prefix_length = prefix_length;
14143 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14146 mp->prefix_length = prefix_length;
14147 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14150 clib_memcpy (mp->eid, mac, sizeof (mac));
14153 errmsg ("unknown EID type %d!", eid_type);
14161 /* Use a control ping for synchronization */
14163 vl_api_control_ping_t *mp;
14164 M (CONTROL_PING, control_ping);
14168 /* Wait for a reply... */
14176 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14178 vl_api_lisp_gpe_tunnel_dump_t *mp;
14181 if (!vam->json_output)
14183 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14184 "%=16s%=16s%=16s%=16s%=16s\n",
14185 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14186 "Decap next", "Lisp version", "Flags", "Next protocol",
14187 "ver_res", "res", "iid");
14190 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14194 /* Use a control ping for synchronization */
14196 vl_api_control_ping_t *mp;
14197 M (CONTROL_PING, control_ping);
14200 /* Wait for a reply... */
14208 api_lisp_adjacencies_get (vat_main_t * vam)
14210 unformat_input_t *i = vam->input;
14211 vl_api_lisp_adjacencies_get_t *mp;
14216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14218 if (unformat (i, "vni %d", &vni))
14224 errmsg ("parse error '%U'\n", format_unformat_error, i);
14231 errmsg ("vni not set!\n");
14235 if (!vam->json_output)
14237 fformat (vam->ofp, "%s %40s\n", "leid", "reid");
14240 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14241 mp->vni = clib_host_to_net_u32 (vni);
14246 /* Wait for a reply... */
14254 api_lisp_map_resolver_dump (vat_main_t * vam)
14256 vl_api_lisp_map_resolver_dump_t *mp;
14259 if (!vam->json_output)
14261 fformat (vam->ofp, "%=20s\n", "Map resolver");
14264 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14268 /* Use a control ping for synchronization */
14270 vl_api_control_ping_t *mp;
14271 M (CONTROL_PING, control_ping);
14274 /* Wait for a reply... */
14282 api_show_lisp_status (vat_main_t * vam)
14284 vl_api_show_lisp_status_t *mp;
14287 if (!vam->json_output)
14289 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
14292 M (SHOW_LISP_STATUS, show_lisp_status);
14295 /* Wait for a reply... */
14303 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14305 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14308 if (!vam->json_output)
14310 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
14313 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14316 /* Wait for a reply... */
14324 api_af_packet_create (vat_main_t * vam)
14326 unformat_input_t *i = vam->input;
14327 vl_api_af_packet_create_t *mp;
14329 u8 *host_if_name = 0;
14331 u8 random_hw_addr = 1;
14333 memset (hw_addr, 0, sizeof (hw_addr));
14335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14337 if (unformat (i, "name %s", &host_if_name))
14338 vec_add1 (host_if_name, 0);
14339 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14340 random_hw_addr = 0;
14345 if (!vec_len (host_if_name))
14347 errmsg ("host-interface name must be specified");
14351 if (vec_len (host_if_name) > 64)
14353 errmsg ("host-interface name too long");
14357 M (AF_PACKET_CREATE, af_packet_create);
14359 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14360 clib_memcpy (mp->hw_addr, hw_addr, 6);
14361 mp->use_random_hw_addr = random_hw_addr;
14362 vec_free (host_if_name);
14365 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14371 api_af_packet_delete (vat_main_t * vam)
14373 unformat_input_t *i = vam->input;
14374 vl_api_af_packet_delete_t *mp;
14376 u8 *host_if_name = 0;
14378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14380 if (unformat (i, "name %s", &host_if_name))
14381 vec_add1 (host_if_name, 0);
14386 if (!vec_len (host_if_name))
14388 errmsg ("host-interface name must be specified");
14392 if (vec_len (host_if_name) > 64)
14394 errmsg ("host-interface name too long");
14398 M (AF_PACKET_DELETE, af_packet_delete);
14400 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14401 vec_free (host_if_name);
14410 api_policer_add_del (vat_main_t * vam)
14412 unformat_input_t *i = vam->input;
14413 vl_api_policer_add_del_t *mp;
14424 u8 color_aware = 0;
14425 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14427 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14428 conform_action.dscp = 0;
14429 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14430 exceed_action.dscp = 0;
14431 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14432 violate_action.dscp = 0;
14434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14436 if (unformat (i, "del"))
14438 else if (unformat (i, "name %s", &name))
14439 vec_add1 (name, 0);
14440 else if (unformat (i, "cir %u", &cir))
14442 else if (unformat (i, "eir %u", &eir))
14444 else if (unformat (i, "cb %u", &cb))
14446 else if (unformat (i, "eb %u", &eb))
14448 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14451 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14454 else if (unformat (i, "type %U", unformat_policer_type, &type))
14456 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14459 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14462 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14465 else if (unformat (i, "color-aware"))
14471 if (!vec_len (name))
14473 errmsg ("policer name must be specified");
14477 if (vec_len (name) > 64)
14479 errmsg ("policer name too long");
14483 M (POLICER_ADD_DEL, policer_add_del);
14485 clib_memcpy (mp->name, name, vec_len (name));
14487 mp->is_add = is_add;
14492 mp->rate_type = rate_type;
14493 mp->round_type = round_type;
14495 mp->conform_action_type = conform_action.action_type;
14496 mp->conform_dscp = conform_action.dscp;
14497 mp->exceed_action_type = exceed_action.action_type;
14498 mp->exceed_dscp = exceed_action.dscp;
14499 mp->violate_action_type = violate_action.action_type;
14500 mp->violate_dscp = violate_action.dscp;
14501 mp->color_aware = color_aware;
14510 api_policer_dump (vat_main_t * vam)
14512 unformat_input_t *i = vam->input;
14513 vl_api_policer_dump_t *mp;
14515 u8 *match_name = 0;
14516 u8 match_name_valid = 0;
14518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14520 if (unformat (i, "name %s", &match_name))
14522 vec_add1 (match_name, 0);
14523 match_name_valid = 1;
14529 M (POLICER_DUMP, policer_dump);
14530 mp->match_name_valid = match_name_valid;
14531 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14532 vec_free (match_name);
14536 /* Use a control ping for synchronization */
14538 vl_api_control_ping_t *mp;
14539 M (CONTROL_PING, control_ping);
14542 /* Wait for a reply... */
14550 api_policer_classify_set_interface (vat_main_t * vam)
14552 unformat_input_t *i = vam->input;
14553 vl_api_policer_classify_set_interface_t *mp;
14556 int sw_if_index_set;
14557 u32 ip4_table_index = ~0;
14558 u32 ip6_table_index = ~0;
14559 u32 l2_table_index = ~0;
14562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14564 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14565 sw_if_index_set = 1;
14566 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14567 sw_if_index_set = 1;
14568 else if (unformat (i, "del"))
14570 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14572 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14574 else if (unformat (i, "l2-table %d", &l2_table_index))
14578 clib_warning ("parse error '%U'", format_unformat_error, i);
14583 if (sw_if_index_set == 0)
14585 errmsg ("missing interface name or sw_if_index\n");
14589 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14591 mp->sw_if_index = ntohl (sw_if_index);
14592 mp->ip4_table_index = ntohl (ip4_table_index);
14593 mp->ip6_table_index = ntohl (ip6_table_index);
14594 mp->l2_table_index = ntohl (l2_table_index);
14595 mp->is_add = is_add;
14604 api_policer_classify_dump (vat_main_t * vam)
14606 unformat_input_t *i = vam->input;
14607 vl_api_policer_classify_dump_t *mp;
14609 u8 type = POLICER_CLASSIFY_N_TABLES;
14611 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
14615 errmsg ("classify table type must be specified\n");
14619 if (!vam->json_output)
14621 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14624 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14629 /* Use a control ping for synchronization */
14631 vl_api_control_ping_t *mp;
14632 M (CONTROL_PING, control_ping);
14635 /* Wait for a reply... */
14643 api_netmap_create (vat_main_t * vam)
14645 unformat_input_t *i = vam->input;
14646 vl_api_netmap_create_t *mp;
14650 u8 random_hw_addr = 1;
14654 memset (hw_addr, 0, sizeof (hw_addr));
14656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14658 if (unformat (i, "name %s", &if_name))
14659 vec_add1 (if_name, 0);
14660 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14661 random_hw_addr = 0;
14662 else if (unformat (i, "pipe"))
14664 else if (unformat (i, "master"))
14666 else if (unformat (i, "slave"))
14672 if (!vec_len (if_name))
14674 errmsg ("interface name must be specified");
14678 if (vec_len (if_name) > 64)
14680 errmsg ("interface name too long");
14684 M (NETMAP_CREATE, netmap_create);
14686 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14687 clib_memcpy (mp->hw_addr, hw_addr, 6);
14688 mp->use_random_hw_addr = random_hw_addr;
14689 mp->is_pipe = is_pipe;
14690 mp->is_master = is_master;
14691 vec_free (if_name);
14700 api_netmap_delete (vat_main_t * vam)
14702 unformat_input_t *i = vam->input;
14703 vl_api_netmap_delete_t *mp;
14707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14709 if (unformat (i, "name %s", &if_name))
14710 vec_add1 (if_name, 0);
14715 if (!vec_len (if_name))
14717 errmsg ("interface name must be specified");
14721 if (vec_len (if_name) > 64)
14723 errmsg ("interface name too long");
14727 M (NETMAP_DELETE, netmap_delete);
14729 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14730 vec_free (if_name);
14738 static void vl_api_mpls_eth_tunnel_details_t_handler
14739 (vl_api_mpls_eth_tunnel_details_t * mp)
14741 vat_main_t *vam = &vat_main;
14743 i32 len = ntohl (mp->nlabels);
14745 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14746 ntohl (mp->tunnel_index),
14747 format_ethernet_address, &mp->tunnel_dst_mac,
14748 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14749 for (i = 0; i < len; i++)
14751 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14753 fformat (vam->ofp, "\n");
14754 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14755 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14758 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14759 (vl_api_mpls_eth_tunnel_details_t * mp)
14761 vat_main_t *vam = &vat_main;
14762 vat_json_node_t *node = NULL;
14763 struct in_addr ip4;
14765 i32 len = ntohl (mp->nlabels);
14767 if (VAT_JSON_ARRAY != vam->json_tree.type)
14769 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14770 vat_json_init_array (&vam->json_tree);
14772 node = vat_json_array_add (&vam->json_tree);
14774 vat_json_init_object (node);
14775 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14776 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14777 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14778 vat_json_object_add_uint (node, "inner_fib_index",
14779 ntohl (mp->inner_fib_index));
14780 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14781 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14782 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14783 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14784 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14785 format (0, "%U", format_ethernet_address,
14786 &mp->tunnel_dst_mac));
14787 vat_json_object_add_uint (node, "tx_sw_if_index",
14788 ntohl (mp->tx_sw_if_index));
14789 vat_json_object_add_uint (node, "label_count", len);
14790 for (i = 0; i < len; i++)
14792 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14797 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14799 vl_api_mpls_eth_tunnel_dump_t *mp;
14803 /* Parse args required to build the message */
14804 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14806 if (!unformat (vam->input, "tunnel_index %d", &index))
14813 fformat (vam->ofp, " tunnel_index %d\n", index);
14815 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14816 mp->tunnel_index = htonl (index);
14819 /* Use a control ping for synchronization */
14821 vl_api_control_ping_t *mp;
14822 M (CONTROL_PING, control_ping);
14828 static void vl_api_mpls_fib_encap_details_t_handler
14829 (vl_api_mpls_fib_encap_details_t * mp)
14831 vat_main_t *vam = &vat_main;
14833 i32 len = ntohl (mp->nlabels);
14835 fformat (vam->ofp, "table %d, dest %U, label ",
14836 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14837 for (i = 0; i < len; i++)
14839 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14841 fformat (vam->ofp, "\n");
14844 static void vl_api_mpls_fib_encap_details_t_handler_json
14845 (vl_api_mpls_fib_encap_details_t * mp)
14847 vat_main_t *vam = &vat_main;
14848 vat_json_node_t *node = NULL;
14850 i32 len = ntohl (mp->nlabels);
14851 struct in_addr ip4;
14853 if (VAT_JSON_ARRAY != vam->json_tree.type)
14855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14856 vat_json_init_array (&vam->json_tree);
14858 node = vat_json_array_add (&vam->json_tree);
14860 vat_json_init_object (node);
14861 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14862 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14863 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14864 vat_json_object_add_ip4 (node, "dest", ip4);
14865 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14866 vat_json_object_add_uint (node, "label_count", len);
14867 for (i = 0; i < len; i++)
14869 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14874 api_mpls_fib_encap_dump (vat_main_t * vam)
14876 vl_api_mpls_fib_encap_dump_t *mp;
14879 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14882 /* Use a control ping for synchronization */
14884 vl_api_control_ping_t *mp;
14885 M (CONTROL_PING, control_ping);
14891 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
14892 #define vl_api_mpls_fib_details_t_print vl_noop_handler
14895 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
14897 vat_main_t *vam = &vat_main;
14898 int count = ntohl (mp->count);
14899 vl_api_fib_path_t *fp;
14903 "table-id %d, label %u, ess_bit %u\n",
14904 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
14906 for (i = 0; i < count; i++)
14908 if (fp->afi == IP46_TYPE_IP6)
14910 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14911 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14912 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14913 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14914 format_ip6_address, fp->next_hop);
14915 else if (fp->afi == IP46_TYPE_IP4)
14917 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14918 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14919 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14920 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14921 format_ip4_address, fp->next_hop);
14926 static void vl_api_mpls_fib_details_t_handler_json
14927 (vl_api_mpls_fib_details_t * mp)
14929 vat_main_t *vam = &vat_main;
14930 int count = ntohl (mp->count);
14931 vat_json_node_t *node = NULL;
14932 struct in_addr ip4;
14933 struct in6_addr ip6;
14934 vl_api_fib_path_t *fp;
14937 if (VAT_JSON_ARRAY != vam->json_tree.type)
14939 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14940 vat_json_init_array (&vam->json_tree);
14942 node = vat_json_array_add (&vam->json_tree);
14944 vat_json_init_object (node);
14945 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
14946 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
14947 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14948 vat_json_object_add_uint (node, "path_count", count);
14950 for (i = 0; i < count; i++)
14952 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
14953 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
14954 vat_json_object_add_uint (node, "is_local", fp->is_local);
14955 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
14956 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
14957 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
14958 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
14959 if (fp->afi == IP46_TYPE_IP4)
14961 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
14962 vat_json_object_add_ip4 (node, "next_hop", ip4);
14964 else if (fp->afi == IP46_TYPE_IP6)
14966 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
14967 vat_json_object_add_ip6 (node, "next_hop", ip6);
14973 api_mpls_fib_dump (vat_main_t * vam)
14975 vl_api_mpls_fib_dump_t *mp;
14978 M (MPLS_FIB_DUMP, mpls_fib_dump);
14981 /* Use a control ping for synchronization */
14983 vl_api_control_ping_t *mp;
14984 M (CONTROL_PING, control_ping);
14990 #define vl_api_ip_fib_details_t_endian vl_noop_handler
14991 #define vl_api_ip_fib_details_t_print vl_noop_handler
14994 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
14996 vat_main_t *vam = &vat_main;
14997 int count = ntohl (mp->count);
14998 vl_api_fib_path_t *fp;
15002 "table-id %d, prefix %U/%d\n",
15003 ntohl (mp->table_id), format_ip4_address, mp->address,
15004 mp->address_length);
15006 for (i = 0; i < count; i++)
15008 if (fp->afi == IP46_TYPE_IP6)
15010 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15011 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15012 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15013 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15014 format_ip6_address, fp->next_hop);
15015 else if (fp->afi == IP46_TYPE_IP4)
15017 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15018 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15019 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15020 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15021 format_ip4_address, fp->next_hop);
15026 static void vl_api_ip_fib_details_t_handler_json
15027 (vl_api_ip_fib_details_t * mp)
15029 vat_main_t *vam = &vat_main;
15030 int count = ntohl (mp->count);
15031 vat_json_node_t *node = NULL;
15032 struct in_addr ip4;
15033 struct in6_addr ip6;
15034 vl_api_fib_path_t *fp;
15037 if (VAT_JSON_ARRAY != vam->json_tree.type)
15039 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15040 vat_json_init_array (&vam->json_tree);
15042 node = vat_json_array_add (&vam->json_tree);
15044 vat_json_init_object (node);
15045 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15046 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15047 vat_json_object_add_ip4 (node, "prefix", ip4);
15048 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15049 vat_json_object_add_uint (node, "path_count", count);
15051 for (i = 0; i < count; i++)
15053 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15054 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15055 vat_json_object_add_uint (node, "is_local", fp->is_local);
15056 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15057 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15058 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15059 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15060 if (fp->afi == IP46_TYPE_IP4)
15062 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15063 vat_json_object_add_ip4 (node, "next_hop", ip4);
15065 else if (fp->afi == IP46_TYPE_IP6)
15067 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15068 vat_json_object_add_ip6 (node, "next_hop", ip6);
15074 api_ip_fib_dump (vat_main_t * vam)
15076 vl_api_ip_fib_dump_t *mp;
15079 M (IP_FIB_DUMP, ip_fib_dump);
15082 /* Use a control ping for synchronization */
15084 vl_api_control_ping_t *mp;
15085 M (CONTROL_PING, control_ping);
15091 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15092 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15095 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15097 vat_main_t *vam = &vat_main;
15098 int count = ntohl (mp->count);
15099 vl_api_fib_path_t *fp;
15103 "table-id %d, prefix %U/%d\n",
15104 ntohl (mp->table_id), format_ip6_address, mp->address,
15105 mp->address_length);
15107 for (i = 0; i < count; i++)
15109 if (fp->afi == IP46_TYPE_IP6)
15111 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15112 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15113 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15114 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15115 format_ip6_address, fp->next_hop);
15116 else if (fp->afi == IP46_TYPE_IP4)
15118 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15119 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15120 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15121 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15122 format_ip4_address, fp->next_hop);
15127 static void vl_api_ip6_fib_details_t_handler_json
15128 (vl_api_ip6_fib_details_t * mp)
15130 vat_main_t *vam = &vat_main;
15131 int count = ntohl (mp->count);
15132 vat_json_node_t *node = NULL;
15133 struct in_addr ip4;
15134 struct in6_addr ip6;
15135 vl_api_fib_path_t *fp;
15138 if (VAT_JSON_ARRAY != vam->json_tree.type)
15140 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15141 vat_json_init_array (&vam->json_tree);
15143 node = vat_json_array_add (&vam->json_tree);
15145 vat_json_init_object (node);
15146 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15147 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15148 vat_json_object_add_ip6 (node, "prefix", ip6);
15149 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15150 vat_json_object_add_uint (node, "path_count", count);
15152 for (i = 0; i < count; i++)
15154 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15155 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15156 vat_json_object_add_uint (node, "is_local", fp->is_local);
15157 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15158 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15159 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15160 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15161 if (fp->afi == IP46_TYPE_IP4)
15163 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15164 vat_json_object_add_ip4 (node, "next_hop", ip4);
15166 else if (fp->afi == IP46_TYPE_IP6)
15168 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15169 vat_json_object_add_ip6 (node, "next_hop", ip6);
15175 api_ip6_fib_dump (vat_main_t * vam)
15177 vl_api_ip6_fib_dump_t *mp;
15180 M (IP6_FIB_DUMP, ip6_fib_dump);
15183 /* Use a control ping for synchronization */
15185 vl_api_control_ping_t *mp;
15186 M (CONTROL_PING, control_ping);
15193 api_classify_table_ids (vat_main_t * vam)
15195 vl_api_classify_table_ids_t *mp;
15198 /* Construct the API message */
15199 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15209 api_classify_table_by_interface (vat_main_t * vam)
15211 unformat_input_t *input = vam->input;
15212 vl_api_classify_table_by_interface_t *mp;
15215 u32 sw_if_index = ~0;
15216 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15218 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15220 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15225 if (sw_if_index == ~0)
15227 errmsg ("missing interface name or sw_if_index\n");
15231 /* Construct the API message */
15232 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15234 mp->sw_if_index = ntohl (sw_if_index);
15243 api_classify_table_info (vat_main_t * vam)
15245 unformat_input_t *input = vam->input;
15246 vl_api_classify_table_info_t *mp;
15250 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15252 if (unformat (input, "table_id %d", &table_id))
15257 if (table_id == ~0)
15259 errmsg ("missing table id\n");
15263 /* Construct the API message */
15264 M (CLASSIFY_TABLE_INFO, classify_table_info);
15266 mp->table_id = ntohl (table_id);
15275 api_classify_session_dump (vat_main_t * vam)
15277 unformat_input_t *input = vam->input;
15278 vl_api_classify_session_dump_t *mp;
15282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15284 if (unformat (input, "table_id %d", &table_id))
15289 if (table_id == ~0)
15291 errmsg ("missing table id\n");
15295 /* Construct the API message */
15296 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15298 mp->table_id = ntohl (table_id);
15301 /* Use a control ping for synchronization */
15303 vl_api_control_ping_t *mp;
15304 M (CONTROL_PING, control_ping);
15313 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15315 vat_main_t *vam = &vat_main;
15317 fformat (vam->ofp, "collector_address %U, collector_port %d, "
15318 "src_address %U, vrf_id %d, path_mtu %u, "
15319 "template_interval %u, udp_checksum %d\n",
15320 format_ip4_address, mp->collector_address,
15321 ntohs (mp->collector_port),
15322 format_ip4_address, mp->src_address,
15323 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15324 ntohl (mp->template_interval), mp->udp_checksum);
15327 vam->result_ready = 1;
15331 vl_api_ipfix_exporter_details_t_handler_json
15332 (vl_api_ipfix_exporter_details_t * mp)
15334 vat_main_t *vam = &vat_main;
15335 vat_json_node_t node;
15336 struct in_addr collector_address;
15337 struct in_addr src_address;
15339 vat_json_init_object (&node);
15340 clib_memcpy (&collector_address, &mp->collector_address,
15341 sizeof (collector_address));
15342 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15343 vat_json_object_add_uint (&node, "collector_port",
15344 ntohs (mp->collector_port));
15345 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15346 vat_json_object_add_ip4 (&node, "src_address", src_address);
15347 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15348 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15349 vat_json_object_add_uint (&node, "template_interval",
15350 ntohl (mp->template_interval));
15351 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15353 vat_json_print (vam->ofp, &node);
15354 vat_json_free (&node);
15356 vam->result_ready = 1;
15360 api_ipfix_exporter_dump (vat_main_t * vam)
15362 vl_api_ipfix_exporter_dump_t *mp;
15365 /* Construct the API message */
15366 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15376 api_ipfix_classify_stream_dump (vat_main_t * vam)
15378 vl_api_ipfix_classify_stream_dump_t *mp;
15381 /* Construct the API message */
15382 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15392 vl_api_ipfix_classify_stream_details_t_handler
15393 (vl_api_ipfix_classify_stream_details_t * mp)
15395 vat_main_t *vam = &vat_main;
15396 fformat (vam->ofp, "domain_id %d, src_port %d\n",
15397 ntohl (mp->domain_id), ntohs (mp->src_port));
15399 vam->result_ready = 1;
15403 vl_api_ipfix_classify_stream_details_t_handler_json
15404 (vl_api_ipfix_classify_stream_details_t * mp)
15406 vat_main_t *vam = &vat_main;
15407 vat_json_node_t node;
15409 vat_json_init_object (&node);
15410 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15411 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15413 vat_json_print (vam->ofp, &node);
15414 vat_json_free (&node);
15416 vam->result_ready = 1;
15420 api_ipfix_classify_table_dump (vat_main_t * vam)
15422 vl_api_ipfix_classify_table_dump_t *mp;
15425 if (!vam->json_output)
15427 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
15428 "transport_protocol");
15431 /* Construct the API message */
15432 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15437 /* Use a control ping for synchronization */
15439 vl_api_control_ping_t *mp;
15440 M (CONTROL_PING, control_ping);
15447 vl_api_ipfix_classify_table_details_t_handler
15448 (vl_api_ipfix_classify_table_details_t * mp)
15450 vat_main_t *vam = &vat_main;
15451 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
15452 mp->transport_protocol);
15456 vl_api_ipfix_classify_table_details_t_handler_json
15457 (vl_api_ipfix_classify_table_details_t * mp)
15459 vat_json_node_t *node = NULL;
15460 vat_main_t *vam = &vat_main;
15462 if (VAT_JSON_ARRAY != vam->json_tree.type)
15464 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15465 vat_json_init_array (&vam->json_tree);
15468 node = vat_json_array_add (&vam->json_tree);
15469 vat_json_init_object (node);
15471 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15472 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15473 vat_json_object_add_uint (node, "transport_protocol",
15474 mp->transport_protocol);
15478 api_sw_interface_span_enable_disable (vat_main_t * vam)
15480 unformat_input_t *i = vam->input;
15481 vl_api_sw_interface_span_enable_disable_t *mp;
15483 u32 src_sw_if_index = ~0;
15484 u32 dst_sw_if_index = ~0;
15487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15489 if (unformat (i, "src %U", unformat_sw_if_index, vam, &src_sw_if_index))
15491 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15495 (i, "dst %U", unformat_sw_if_index, vam, &dst_sw_if_index))
15497 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15499 else if (unformat (i, "disable"))
15505 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
15507 mp->sw_if_index_from = htonl (src_sw_if_index);
15508 mp->sw_if_index_to = htonl (dst_sw_if_index);
15509 mp->enable = enable;
15518 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
15521 vat_main_t *vam = &vat_main;
15523 fformat (vam->ofp, "%u => %u\n",
15524 ntohl (mp->sw_if_index_from), ntohl (mp->sw_if_index_to));
15528 vl_api_sw_interface_span_details_t_handler_json
15529 (vl_api_sw_interface_span_details_t * mp)
15531 vat_main_t *vam = &vat_main;
15532 vat_json_node_t *node = NULL;
15534 if (VAT_JSON_ARRAY != vam->json_tree.type)
15536 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15537 vat_json_init_array (&vam->json_tree);
15539 node = vat_json_array_add (&vam->json_tree);
15541 vat_json_init_object (node);
15542 vat_json_object_add_uint (node, "src-if-index",
15543 ntohl (mp->sw_if_index_from));
15544 vat_json_object_add_uint (node, "dst-if-index", ntohl (mp->sw_if_index_to));
15548 api_sw_interface_span_dump (vat_main_t * vam)
15550 vl_api_sw_interface_span_dump_t *mp;
15553 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
15556 /* Use a control ping for synchronization */
15558 vl_api_control_ping_t *mp;
15559 M (CONTROL_PING, control_ping);
15566 api_pg_create_interface (vat_main_t * vam)
15568 unformat_input_t *input = vam->input;
15569 vl_api_pg_create_interface_t *mp;
15573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15575 if (unformat (input, "if_id %d", &if_id))
15582 errmsg ("missing pg interface index\n");
15586 /* Construct the API message */
15587 M (PG_CREATE_INTERFACE, pg_create_interface);
15589 mp->interface_id = ntohl (if_id);
15598 api_pg_capture (vat_main_t * vam)
15600 unformat_input_t *input = vam->input;
15601 vl_api_pg_capture_t *mp;
15607 u8 pcap_file_set = 0;
15609 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15611 if (unformat (input, "if_id %d", &if_id))
15613 else if (unformat (input, "pcap %s", &pcap_file))
15615 else if (unformat (input, "count %d", &count))
15617 else if (unformat (input, "disable"))
15624 errmsg ("missing pg interface index\n");
15627 if (pcap_file_set > 0)
15629 if (vec_len (pcap_file) > 255)
15631 errmsg ("pcap file name is too long\n");
15636 u32 name_len = vec_len (pcap_file);
15637 /* Construct the API message */
15638 M (PG_CAPTURE, pg_capture);
15640 mp->interface_id = ntohl (if_id);
15641 mp->is_enabled = enable;
15642 mp->count = ntohl (count);
15643 mp->pcap_name_length = ntohl (name_len);
15644 if (pcap_file_set != 0)
15646 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
15648 vec_free (pcap_file);
15657 api_pg_enable_disable (vat_main_t * vam)
15659 unformat_input_t *input = vam->input;
15660 vl_api_pg_enable_disable_t *mp;
15664 u8 stream_name_set = 0;
15665 u8 *stream_name = 0;
15666 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15668 if (unformat (input, "stream %s", &stream_name))
15669 stream_name_set = 1;
15670 else if (unformat (input, "disable"))
15676 if (stream_name_set > 0)
15678 if (vec_len (stream_name) > 255)
15680 errmsg ("stream name too long\n");
15685 u32 name_len = vec_len (stream_name);
15686 /* Construct the API message */
15687 M (PG_ENABLE_DISABLE, pg_enable_disable);
15689 mp->is_enabled = enable;
15690 if (stream_name_set != 0)
15692 mp->stream_name_length = ntohl (name_len);
15693 clib_memcpy (mp->stream_name, stream_name, name_len);
15695 vec_free (stream_name);
15704 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
15706 unformat_input_t *input = vam->input;
15707 vl_api_ip_source_and_port_range_check_add_del_t *mp;
15710 u16 *low_ports = 0;
15711 u16 *high_ports = 0;
15714 ip4_address_t ip4_addr;
15715 ip6_address_t ip6_addr;
15723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15725 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
15731 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
15736 else if (unformat (input, "vrf %d", &vrf_id))
15738 else if (unformat (input, "del"))
15740 else if (unformat (input, "port %d", &tmp))
15742 if (tmp == 0 || tmp > 65535)
15744 errmsg ("port %d out of range", tmp);
15748 this_hi = this_low + 1;
15749 vec_add1 (low_ports, this_low);
15750 vec_add1 (high_ports, this_hi);
15752 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
15754 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
15756 errmsg ("incorrect range parameters\n");
15760 /* Note: in debug CLI +1 is added to high before
15761 passing to real fn that does "the work"
15762 (ip_source_and_port_range_check_add_del).
15763 This fn is a wrapper around the binary API fn a
15764 control plane will call, which expects this increment
15765 to have occurred. Hence letting the binary API control
15766 plane fn do the increment for consistency between VAT
15767 and other control planes.
15770 vec_add1 (low_ports, this_low);
15771 vec_add1 (high_ports, this_hi);
15777 if (prefix_set == 0)
15779 errmsg ("<address>/<mask> not specified\n");
15785 errmsg ("VRF ID required, not specified\n");
15792 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15796 if (vec_len (low_ports) == 0)
15798 errmsg ("At least one port or port range required\n");
15802 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15803 ip_source_and_port_range_check_add_del);
15805 mp->is_add = is_add;
15810 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15815 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15818 mp->mask_length = length;
15819 mp->number_of_ranges = vec_len (low_ports);
15821 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15822 vec_free (low_ports);
15824 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15825 vec_free (high_ports);
15827 mp->vrf_id = ntohl (vrf_id);
15836 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15838 unformat_input_t *input = vam->input;
15839 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15841 u32 sw_if_index = ~0;
15843 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15844 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15849 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15851 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15853 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15855 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15857 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15859 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15861 else if (unformat (input, "del"))
15867 if (sw_if_index == ~0)
15869 errmsg ("Interface required but not specified\n");
15875 errmsg ("VRF ID required but not specified\n");
15879 if (tcp_out_vrf_id == 0
15880 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15883 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15887 /* Construct the API message */
15888 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15889 ip_source_and_port_range_check_interface_add_del);
15891 mp->sw_if_index = ntohl (sw_if_index);
15892 mp->is_add = is_add;
15893 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15894 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15895 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15896 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15901 /* Wait for a reply... */
15906 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15908 unformat_input_t *i = vam->input;
15909 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15911 u32 local_sa_id = 0;
15912 u32 remote_sa_id = 0;
15913 ip4_address_t src_address;
15914 ip4_address_t dst_address;
15917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15919 if (unformat (i, "local_sa %d", &local_sa_id))
15921 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15923 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15925 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15927 else if (unformat (i, "del"))
15931 clib_warning ("parse error '%U'", format_unformat_error, i);
15936 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15938 mp->local_sa_id = ntohl (local_sa_id);
15939 mp->remote_sa_id = ntohl (remote_sa_id);
15940 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15941 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15942 mp->is_add = is_add;
15951 api_punt (vat_main_t * vam)
15953 unformat_input_t *i = vam->input;
15961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15963 if (unformat (i, "ip %d", &ipv))
15965 else if (unformat (i, "protocol %d", &protocol))
15967 else if (unformat (i, "port %d", &port))
15969 else if (unformat (i, "del"))
15973 clib_warning ("parse error '%U'", format_unformat_error, i);
15980 mp->is_add = (u8) is_add;
15981 mp->ipv = (u8) ipv;
15982 mp->l4_protocol = (u8) protocol;
15983 mp->l4_port = htons ((u16) port);
15991 static void vl_api_ipsec_gre_tunnel_details_t_handler
15992 (vl_api_ipsec_gre_tunnel_details_t * mp)
15994 vat_main_t *vam = &vat_main;
15996 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15997 ntohl (mp->sw_if_index),
15998 format_ip4_address, &mp->src_address,
15999 format_ip4_address, &mp->dst_address,
16000 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16003 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16004 (vl_api_ipsec_gre_tunnel_details_t * mp)
16006 vat_main_t *vam = &vat_main;
16007 vat_json_node_t *node = NULL;
16008 struct in_addr ip4;
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, "sw_if_index", ntohl (mp->sw_if_index));
16019 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16020 vat_json_object_add_ip4 (node, "src_address", ip4);
16021 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16022 vat_json_object_add_ip4 (node, "dst_address", ip4);
16023 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16024 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16028 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16030 unformat_input_t *i = vam->input;
16031 vl_api_ipsec_gre_tunnel_dump_t *mp;
16034 u8 sw_if_index_set = 0;
16036 /* Parse args required to build the message */
16037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16039 if (unformat (i, "sw_if_index %d", &sw_if_index))
16040 sw_if_index_set = 1;
16045 if (sw_if_index_set == 0)
16050 if (!vam->json_output)
16052 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
16053 "sw_if_index", "src_address", "dst_address",
16054 "local_sa_id", "remote_sa_id");
16057 /* Get list of gre-tunnel interfaces */
16058 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16060 mp->sw_if_index = htonl (sw_if_index);
16064 /* Use a control ping for synchronization */
16066 vl_api_control_ping_t *mp;
16067 M (CONTROL_PING, control_ping);
16074 api_delete_subif (vat_main_t * vam)
16076 unformat_input_t *i = vam->input;
16077 vl_api_delete_subif_t *mp;
16079 u32 sw_if_index = ~0;
16081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16083 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16085 if (unformat (i, "sw_if_index %d", &sw_if_index))
16091 if (sw_if_index == ~0)
16093 errmsg ("missing sw_if_index\n");
16097 /* Construct the API message */
16098 M (DELETE_SUBIF, delete_subif);
16099 mp->sw_if_index = ntohl (sw_if_index);
16105 #define foreach_pbb_vtr_op \
16106 _("disable", L2_VTR_DISABLED) \
16107 _("pop", L2_VTR_POP_2) \
16108 _("push", L2_VTR_PUSH_2)
16111 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16113 unformat_input_t *i = vam->input;
16114 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16116 u32 sw_if_index = ~0, vtr_op = ~0;
16117 u16 outer_tag = ~0;
16118 u8 dmac[6], smac[6];
16119 u8 dmac_set = 0, smac_set = 0;
16124 /* Shut up coverity */
16125 memset (dmac, 0, sizeof (dmac));
16126 memset (smac, 0, sizeof (smac));
16128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16130 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16134 else if (unformat (i, "vtr_op %d", &vtr_op))
16136 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16139 else if (unformat (i, "translate_pbb_stag"))
16141 if (unformat (i, "%d", &tmp))
16143 vtr_op = L2_VTR_TRANSLATE_2_1;
16149 ("translate_pbb_stag operation requires outer tag definition\n");
16153 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16155 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16157 else if (unformat (i, "sid %d", &sid))
16159 else if (unformat (i, "vlanid %d", &tmp))
16163 clib_warning ("parse error '%U'", format_unformat_error, i);
16168 if ((sw_if_index == ~0) || (vtr_op == ~0))
16170 errmsg ("missing sw_if_index or vtr operation\n");
16173 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16174 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16177 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
16181 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16182 mp->sw_if_index = ntohl (sw_if_index);
16183 mp->vtr_op = ntohl (vtr_op);
16184 mp->outer_tag = ntohs (outer_tag);
16185 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16186 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16187 mp->b_vlanid = ntohs (vlanid);
16188 mp->i_sid = ntohl (sid);
16197 api_flow_classify_set_interface (vat_main_t * vam)
16199 unformat_input_t *i = vam->input;
16200 vl_api_flow_classify_set_interface_t *mp;
16203 int sw_if_index_set;
16204 u32 ip4_table_index = ~0;
16205 u32 ip6_table_index = ~0;
16208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16210 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16211 sw_if_index_set = 1;
16212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16213 sw_if_index_set = 1;
16214 else if (unformat (i, "del"))
16216 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16218 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16222 clib_warning ("parse error '%U'", format_unformat_error, i);
16227 if (sw_if_index_set == 0)
16229 errmsg ("missing interface name or sw_if_index\n");
16233 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16235 mp->sw_if_index = ntohl (sw_if_index);
16236 mp->ip4_table_index = ntohl (ip4_table_index);
16237 mp->ip6_table_index = ntohl (ip6_table_index);
16238 mp->is_add = is_add;
16247 api_flow_classify_dump (vat_main_t * vam)
16249 unformat_input_t *i = vam->input;
16250 vl_api_flow_classify_dump_t *mp;
16252 u8 type = FLOW_CLASSIFY_N_TABLES;
16254 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16258 errmsg ("classify table type must be specified\n");
16262 if (!vam->json_output)
16264 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
16267 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16272 /* Use a control ping for synchronization */
16274 vl_api_control_ping_t *mp;
16275 M (CONTROL_PING, control_ping);
16278 /* Wait for a reply... */
16286 api_feature_enable_disable (vat_main_t * vam)
16288 unformat_input_t *i = vam->input;
16289 vl_api_feature_enable_disable_t *mp;
16292 u8 *feature_name = 0;
16293 u32 sw_if_index = ~0;
16296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16298 if (unformat (i, "arc_name %s", &arc_name))
16300 else if (unformat (i, "feature_name %s", &feature_name))
16302 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16304 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16306 else if (unformat (i, "disable"))
16314 errmsg ("missing arc name\n");
16317 if (vec_len (arc_name) > 63)
16319 errmsg ("arc name too long\n");
16322 if (feature_name == 0)
16324 errmsg ("missing feature name\n");
16327 if (vec_len (feature_name) > 63)
16329 errmsg ("feature name too long\n");
16332 if (sw_if_index == ~0)
16334 errmsg ("missing interface name or sw_if_index\n");
16338 /* Construct the API message */
16339 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16340 mp->sw_if_index = ntohl (sw_if_index);
16341 mp->enable = enable;
16342 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16343 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16344 vec_free (arc_name);
16345 vec_free (feature_name);
16352 q_or_quit (vat_main_t * vam)
16354 longjmp (vam->jump_buf, 1);
16355 return 0; /* not so much */
16359 q (vat_main_t * vam)
16361 return q_or_quit (vam);
16365 quit (vat_main_t * vam)
16367 return q_or_quit (vam);
16371 comment (vat_main_t * vam)
16377 cmd_cmp (void *a1, void *a2)
16382 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
16386 help (vat_main_t * vam)
16391 unformat_input_t *i = vam->input;
16394 if (unformat (i, "%s", &name))
16398 vec_add1 (name, 0);
16400 hs = hash_get_mem (vam->help_by_name, name);
16402 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
16404 fformat (vam->ofp, "No such msg / command '%s'\n", name);
16409 fformat (vam->ofp, "Help is available for the following:\n");
16412 hash_foreach_pair (p, vam->function_by_name,
16414 vec_add1 (cmds, (u8 *)(p->key));
16418 vec_sort_with_function (cmds, cmd_cmp);
16420 for (j = 0; j < vec_len (cmds); j++)
16421 fformat (vam->ofp, "%s\n", cmds[j]);
16428 set (vat_main_t * vam)
16430 u8 *name = 0, *value = 0;
16431 unformat_input_t *i = vam->input;
16433 if (unformat (i, "%s", &name))
16435 /* The input buffer is a vector, not a string. */
16436 value = vec_dup (i->buffer);
16437 vec_delete (value, i->index, 0);
16438 /* Almost certainly has a trailing newline */
16439 if (value[vec_len (value) - 1] == '\n')
16440 value[vec_len (value) - 1] = 0;
16441 /* Make sure it's a proper string, one way or the other */
16442 vec_add1 (value, 0);
16443 (void) clib_macro_set_value (&vam->macro_main,
16444 (char *) name, (char *) value);
16447 errmsg ("usage: set <name> <value>\n");
16455 unset (vat_main_t * vam)
16459 if (unformat (vam->input, "%s", &name))
16460 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
16461 errmsg ("unset: %s wasn't set\n", name);
16474 macro_sort_cmp (void *a1, void *a2)
16476 macro_sort_t *s1 = a1;
16477 macro_sort_t *s2 = a2;
16479 return strcmp ((char *) (s1->name), (char *) (s2->name));
16483 dump_macro_table (vat_main_t * vam)
16485 macro_sort_t *sort_me = 0, *sm;
16490 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
16492 vec_add2 (sort_me, sm, 1);
16493 sm->name = (u8 *)(p->key);
16494 sm->value = (u8 *) (p->value[0]);
16498 vec_sort_with_function (sort_me, macro_sort_cmp);
16500 if (vec_len (sort_me))
16501 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
16503 fformat (vam->ofp, "The macro table is empty...\n");
16505 for (i = 0; i < vec_len (sort_me); i++)
16506 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
16511 dump_node_table (vat_main_t * vam)
16514 vlib_node_t *node, *next_node;
16516 if (vec_len (vam->graph_nodes) == 0)
16518 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16522 for (i = 0; i < vec_len (vam->graph_nodes); i++)
16524 node = vam->graph_nodes[i];
16525 fformat (vam->ofp, "[%d] %s\n", i, node->name);
16526 for (j = 0; j < vec_len (node->next_nodes); j++)
16528 if (node->next_nodes[j] != ~0)
16530 next_node = vam->graph_nodes[node->next_nodes[j]];
16531 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16539 value_sort_cmp (void *a1, void *a2)
16541 name_sort_t *n1 = a1;
16542 name_sort_t *n2 = a2;
16544 if (n1->value < n2->value)
16546 if (n1->value > n2->value)
16553 dump_msg_api_table (vat_main_t * vam)
16555 api_main_t *am = &api_main;
16556 name_sort_t *nses = 0, *ns;
16561 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
16563 vec_add2 (nses, ns, 1);
16564 ns->name = (u8 *)(hp->key);
16565 ns->value = (u32) hp->value[0];
16569 vec_sort_with_function (nses, value_sort_cmp);
16571 for (i = 0; i < vec_len (nses); i++)
16572 fformat (vam->ofp, " [%d]: %s\n", nses[i].value, nses[i].name);
16578 get_msg_id (vat_main_t * vam)
16583 if (unformat (vam->input, "%s", &name_and_crc))
16585 message_index = vl_api_get_msg_index (name_and_crc);
16586 if (message_index == ~0)
16588 fformat (vam->ofp, " '%s' not found\n", name_and_crc);
16591 fformat (vam->ofp, " '%s' has message index %d\n",
16592 name_and_crc, message_index);
16595 errmsg ("name_and_crc required...\n");
16600 search_node_table (vat_main_t * vam)
16602 unformat_input_t *line_input = vam->input;
16605 vlib_node_t *node, *next_node;
16608 if (vam->graph_node_index_by_name == 0)
16610 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16614 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16616 if (unformat (line_input, "%s", &node_to_find))
16618 vec_add1 (node_to_find, 0);
16619 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
16622 fformat (vam->ofp, "%s not found...\n", node_to_find);
16625 node = vam->graph_nodes[p[0]];
16626 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
16627 for (j = 0; j < vec_len (node->next_nodes); j++)
16629 if (node->next_nodes[j] != ~0)
16631 next_node = vam->graph_nodes[node->next_nodes[j]];
16632 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16639 clib_warning ("parse error '%U'", format_unformat_error,
16645 vec_free (node_to_find);
16654 script (vat_main_t * vam)
16657 char *save_current_file;
16658 unformat_input_t save_input;
16659 jmp_buf save_jump_buf;
16660 u32 save_line_number;
16662 FILE *new_fp, *save_ifp;
16664 if (unformat (vam->input, "%s", &s))
16666 new_fp = fopen ((char *) s, "r");
16669 errmsg ("Couldn't open script file %s\n", s);
16676 errmsg ("Missing script name\n");
16680 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
16681 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
16682 save_ifp = vam->ifp;
16683 save_line_number = vam->input_line_number;
16684 save_current_file = (char *) vam->current_file;
16686 vam->input_line_number = 0;
16688 vam->current_file = s;
16691 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
16692 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
16693 vam->ifp = save_ifp;
16694 vam->input_line_number = save_line_number;
16695 vam->current_file = (u8 *) save_current_file;
16702 echo (vat_main_t * vam)
16704 fformat (vam->ofp, "%v", vam->input->buffer);
16708 /* List of API message constructors, CLI names map to api_xxx */
16709 #define foreach_vpe_api_msg \
16710 _(create_loopback,"[mac <mac-addr>]") \
16711 _(sw_interface_dump,"") \
16712 _(sw_interface_set_flags, \
16713 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
16714 _(sw_interface_add_del_address, \
16715 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
16716 _(sw_interface_set_table, \
16717 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
16718 _(sw_interface_set_mpls_enable, \
16719 "<intfc> | sw_if_index [disable | dis]") \
16720 _(sw_interface_set_vpath, \
16721 "<intfc> | sw_if_index <id> enable | disable") \
16722 _(sw_interface_set_l2_xconnect, \
16723 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16724 "enable | disable") \
16725 _(sw_interface_set_l2_bridge, \
16726 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
16727 "[shg <split-horizon-group>] [bvi]\n" \
16728 "enable | disable") \
16729 _(sw_interface_set_dpdk_hqos_pipe, \
16730 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
16731 "profile <profile-id>\n") \
16732 _(sw_interface_set_dpdk_hqos_subport, \
16733 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
16734 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
16735 _(sw_interface_set_dpdk_hqos_tctbl, \
16736 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
16737 _(bridge_domain_add_del, \
16738 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
16739 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
16741 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
16743 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
16745 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
16747 "tapname <name> mac <mac-addr> | random-mac") \
16749 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
16751 "<vpp-if-name> | sw_if_index <id>") \
16752 _(sw_interface_tap_dump, "") \
16753 _(ip_add_del_route, \
16754 "<addr>/<mask> via <addr> [table-id <n>]\n" \
16755 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16756 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16757 "[multipath] [count <n>]") \
16758 _(mpls_route_add_del, \
16759 "<label> <eos> via <addr> [table-id <n>]\n" \
16760 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16761 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16762 "[multipath] [count <n>]") \
16763 _(mpls_ip_bind_unbind, \
16764 "<label> <addr/len>") \
16765 _(proxy_arp_add_del, \
16766 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
16767 _(proxy_arp_intfc_enable_disable, \
16768 "<intfc> | sw_if_index <id> enable | disable") \
16769 _(mpls_add_del_encap, \
16770 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
16771 _(sw_interface_set_unnumbered, \
16772 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
16773 _(ip_neighbor_add_del, \
16774 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
16775 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
16776 _(reset_vrf, "vrf <id> [ipv6]") \
16777 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
16778 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
16779 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
16780 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
16781 "[outer_vlan_id_any][inner_vlan_id_any]") \
16782 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
16783 _(reset_fib, "vrf <n> [ipv6]") \
16784 _(dhcp_proxy_config, \
16785 "svr <v46-address> src <v46-address>\n" \
16786 "insert-cid <n> [del]") \
16787 _(dhcp_proxy_config_2, \
16788 "svr <v46-address> src <v46-address>\n" \
16789 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
16790 _(dhcp_proxy_set_vss, \
16791 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
16792 _(dhcp_client_config, \
16793 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
16794 _(set_ip_flow_hash, \
16795 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
16796 _(sw_interface_ip6_enable_disable, \
16797 "<intfc> | sw_if_index <id> enable | disable") \
16798 _(sw_interface_ip6_set_link_local_address, \
16799 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
16800 _(sw_interface_ip6nd_ra_prefix, \
16801 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
16802 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
16803 "[nolink] [isno]") \
16804 _(sw_interface_ip6nd_ra_config, \
16805 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
16806 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
16807 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
16808 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
16809 _(l2_patch_add_del, \
16810 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16811 "enable | disable") \
16812 _(mpls_ethernet_add_del_tunnel, \
16813 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
16814 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
16815 _(mpls_ethernet_add_del_tunnel_2, \
16816 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
16817 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
16818 _(sr_tunnel_add_del, \
16819 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
16820 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
16821 "[policy <policy_name>]") \
16822 _(sr_policy_add_del, \
16823 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
16824 _(sr_multicast_map_add_del, \
16825 "address [ip6 multicast address] sr-policy [policy name] [del]") \
16826 _(classify_add_del_table, \
16827 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
16828 " [del] mask <mask-value>\n" \
16829 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
16830 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
16831 _(classify_add_del_session, \
16832 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
16833 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
16834 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
16835 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
16836 _(classify_set_interface_ip_table, \
16837 "<intfc> | sw_if_index <nn> table <nn>") \
16838 _(classify_set_interface_l2_tables, \
16839 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16840 " [other-table <nn>]") \
16841 _(get_node_index, "node <node-name") \
16842 _(add_node_next, "node <node-name> next <next-node-name>") \
16843 _(l2tpv3_create_tunnel, \
16844 "client_address <ip6-addr> our_address <ip6-addr>\n" \
16845 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
16846 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
16847 _(l2tpv3_set_tunnel_cookies, \
16848 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
16849 "[new_remote_cookie <nn>]\n") \
16850 _(l2tpv3_interface_enable_disable, \
16851 "<intfc> | sw_if_index <nn> enable | disable") \
16852 _(l2tpv3_set_lookup_key, \
16853 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
16854 _(sw_if_l2tpv3_tunnel_dump, "") \
16855 _(vxlan_add_del_tunnel, \
16856 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
16857 " [decap-next l2|ip4|ip6] [del]") \
16858 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16859 _(gre_add_del_tunnel, \
16860 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
16861 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16862 _(l2_fib_clear_table, "") \
16863 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
16864 _(l2_interface_vlan_tag_rewrite, \
16865 "<intfc> | sw_if_index <nn> \n" \
16866 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
16867 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
16868 _(create_vhost_user_if, \
16869 "socket <filename> [server] [renumber <dev_instance>] " \
16870 "[mac <mac_address>]") \
16871 _(modify_vhost_user_if, \
16872 "<intfc> | sw_if_index <nn> socket <filename>\n" \
16873 "[server] [renumber <dev_instance>]") \
16874 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
16875 _(sw_interface_vhost_user_dump, "") \
16876 _(show_version, "") \
16877 _(vxlan_gpe_add_del_tunnel, \
16878 "local <addr> remote <addr> vni <nn>\n" \
16879 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
16880 "[next-ethernet] [next-nsh]\n") \
16881 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16882 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
16883 _(interface_name_renumber, \
16884 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
16885 _(input_acl_set_interface, \
16886 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16887 " [l2-table <nn>] [del]") \
16888 _(want_ip4_arp_events, "address <ip4-address> [del]") \
16889 _(want_ip6_nd_events, "address <ip6-address> [del]") \
16890 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
16891 _(ip_dump, "ipv4 | ipv6") \
16892 _(ipsec_spd_add_del, "spd_id <n> [del]") \
16893 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
16895 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
16896 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
16897 " integ_alg <alg> integ_key <hex>") \
16898 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
16899 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
16900 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
16901 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
16902 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
16903 _(ikev2_profile_add_del, "name <profile_name> [del]") \
16904 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
16905 "(auth_data 0x<data> | auth_data <data>)") \
16906 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
16907 "(id_data 0x<data> | id_data <data>) (local|remote)") \
16908 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
16909 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
16910 "(local|remote)") \
16911 _(ikev2_set_local_key, "file <absolute_file_path>") \
16912 _(delete_loopback,"sw_if_index <nn>") \
16913 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
16914 _(map_add_domain, \
16915 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
16916 "ip6-src <ip6addr> " \
16917 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
16918 _(map_del_domain, "index <n>") \
16919 _(map_add_del_rule, \
16920 "index <n> psid <n> dst <ip6addr> [del]") \
16921 _(map_domain_dump, "") \
16922 _(map_rule_dump, "index <map-domain>") \
16923 _(want_interface_events, "enable|disable") \
16924 _(want_stats,"enable|disable") \
16925 _(get_first_msg_id, "client <name>") \
16926 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
16927 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
16928 "fib-id <nn> [ip4][ip6][default]") \
16929 _(get_node_graph, " ") \
16930 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
16931 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
16932 _(ioam_disable, "") \
16933 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
16934 " sw_if_index <sw_if_index> p <priority> " \
16935 "w <weight>] [del]") \
16936 _(lisp_add_del_locator, "locator-set <locator_name> " \
16937 "iface <intf> | sw_if_index <sw_if_index> " \
16938 "p <priority> w <weight> [del]") \
16939 _(lisp_add_del_local_eid,"vni <vni> eid " \
16940 "<ipv4|ipv6>/<prefix> | <L2 address> " \
16941 "locator-set <locator_name> [del]") \
16942 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
16943 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
16944 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
16945 _(lisp_gpe_enable_disable, "enable|disable") \
16946 _(lisp_enable_disable, "enable|disable") \
16947 _(lisp_gpe_add_del_iface, "up|down") \
16948 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
16950 "rloc <locator> p <prio> " \
16951 "w <weight> [rloc <loc> ... ] " \
16952 "action <action> [del-all]") \
16953 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
16955 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
16956 _(lisp_map_request_mode, "src-dst|dst-only") \
16957 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
16958 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
16959 _(lisp_locator_set_dump, "[local | remote]") \
16960 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
16961 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
16962 "[local] | [remote]") \
16963 _(lisp_eid_table_vni_dump, "") \
16964 _(lisp_eid_table_map_dump, "l2|l3") \
16965 _(lisp_gpe_tunnel_dump, "") \
16966 _(lisp_map_resolver_dump, "") \
16967 _(lisp_adjacencies_get, "vni <vni>") \
16968 _(show_lisp_status, "") \
16969 _(lisp_get_map_request_itr_rlocs, "") \
16970 _(show_lisp_pitr, "") \
16971 _(show_lisp_map_request_mode, "") \
16972 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
16973 _(af_packet_delete, "name <host interface name>") \
16974 _(policer_add_del, "name <policer name> <params> [del]") \
16975 _(policer_dump, "[name <policer name>]") \
16976 _(policer_classify_set_interface, \
16977 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16978 " [l2-table <nn>] [del]") \
16979 _(policer_classify_dump, "type [ip4|ip6|l2]") \
16980 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
16981 "[master|slave]") \
16982 _(netmap_delete, "name <interface name>") \
16983 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
16984 _(mpls_fib_encap_dump, "") \
16985 _(mpls_fib_dump, "") \
16986 _(classify_table_ids, "") \
16987 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
16988 _(classify_table_info, "table_id <nn>") \
16989 _(classify_session_dump, "table_id <nn>") \
16990 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
16991 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
16992 "[template_interval <nn>] [udp_checksum]") \
16993 _(ipfix_exporter_dump, "") \
16994 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
16995 _(ipfix_classify_stream_dump, "") \
16996 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
16997 _(ipfix_classify_table_dump, "") \
16998 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [[dst <intfc> | dst_sw_if_index <id>] | disable]") \
16999 _(sw_interface_span_dump, "") \
17000 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17001 _(pg_create_interface, "if_id <nn>") \
17002 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17003 _(pg_enable_disable, "[stream <id>] disable") \
17004 _(ip_source_and_port_range_check_add_del, \
17005 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17006 _(ip_source_and_port_range_check_interface_add_del, \
17007 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17008 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17009 _(ipsec_gre_add_del_tunnel, \
17010 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17011 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17012 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17013 _(l2_interface_pbb_tag_rewrite, \
17014 "<intfc> | sw_if_index <nn> \n" \
17015 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17016 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17017 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17018 _(flow_classify_set_interface, \
17019 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17020 _(flow_classify_dump, "type [ip4|ip6]") \
17021 _(ip_fib_dump, "") \
17022 _(ip6_fib_dump, "") \
17023 _(feature_enable_disable, "arc_name <arc_name> " \
17024 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]")
17026 /* List of command functions, CLI names map directly to functions */
17027 #define foreach_cli_function \
17028 _(comment, "usage: comment <ignore-rest-of-line>") \
17029 _(dump_interface_table, "usage: dump_interface_table") \
17030 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17031 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17032 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17033 _(dump_stats_table, "usage: dump_stats_table") \
17034 _(dump_macro_table, "usage: dump_macro_table ") \
17035 _(dump_node_table, "usage: dump_node_table") \
17036 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17037 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17038 _(echo, "usage: echo <message>") \
17039 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17040 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17041 _(help, "usage: help") \
17042 _(q, "usage: quit") \
17043 _(quit, "usage: quit") \
17044 _(search_node_table, "usage: search_node_table <name>...") \
17045 _(set, "usage: set <variable-name> <value>") \
17046 _(script, "usage: script <file-name>") \
17047 _(unset, "usage: unset <variable-name>")
17050 static void vl_api_##n##_t_handler_uni \
17051 (vl_api_##n##_t * mp) \
17053 vat_main_t * vam = &vat_main; \
17054 if (vam->json_output) { \
17055 vl_api_##n##_t_handler_json(mp); \
17057 vl_api_##n##_t_handler(mp); \
17060 foreach_vpe_api_reply_msg;
17064 vat_api_hookup (vat_main_t * vam)
17067 vl_msg_api_set_handlers(VL_API_##N, #n, \
17068 vl_api_##n##_t_handler_uni, \
17070 vl_api_##n##_t_endian, \
17071 vl_api_##n##_t_print, \
17072 sizeof(vl_api_##n##_t), 1);
17073 foreach_vpe_api_reply_msg;
17076 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17078 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17080 vam->function_by_name = hash_create_string (0, sizeof (uword));
17082 vam->help_by_name = hash_create_string (0, sizeof (uword));
17084 /* API messages we can send */
17085 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17086 foreach_vpe_api_msg;
17090 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17091 foreach_vpe_api_msg;
17094 /* CLI functions */
17095 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17096 foreach_cli_function;
17100 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17101 foreach_cli_function;
17105 #undef vl_api_version
17106 #define vl_api_version(n,v) static u32 vpe_api_version = v;
17107 #include <vpp-api/vpe.api.h>
17108 #undef vl_api_version
17111 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
17114 * Send the main API signature in slot 0. This bit of code must
17115 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
17117 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
17121 * fd.io coding-style-patch-verification: ON
17124 * eval: (c-set-style "gnu")