2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
53 #include "vat/json_format.h"
58 #define vl_typedefs /* define message structures */
59 #include <vpp/api/vpe_all_api_h.h>
62 /* declare message handlers for each api */
64 #define vl_endianfun /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* instantiate all the print functions we know about */
69 #define vl_print(handle, ...)
71 #include <vpp/api/vpe_all_api_h.h>
74 #define __plugin_msg_base 0
75 #include <vlibapi/vat_helper_macros.h>
78 vat_time_now (vat_main_t * vam)
80 #if VPP_API_TEST_BUILTIN
81 return vlib_time_now (vam->vlib_main);
83 return clib_time_now (&vam->clib_time);
88 errmsg (char *fmt, ...)
90 vat_main_t *vam = &vat_main;
95 s = va_format (0, fmt, &va);
100 #if VPP_API_TEST_BUILTIN
101 vlib_cli_output (vam->vlib_main, (char *) s);
104 if (vam->ifp != stdin)
105 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
106 vam->input_line_number);
107 fformat (vam->ofp, (char *) s);
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 #if VPP_API_TEST_BUILTIN == 0
134 /* Parse an IP4 address %d.%d.%d.%d. */
136 unformat_ip4_address (unformat_input_t * input, va_list * args)
138 u8 *result = va_arg (*args, u8 *);
141 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
144 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
156 unformat_ethernet_address (unformat_input_t * input, va_list * args)
158 u8 *result = va_arg (*args, u8 *);
161 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
162 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
166 for (i = 0; i < 6; i++)
167 if (a[i] >= (1 << 8))
170 for (i = 0; i < 6; i++)
176 /* Returns ethernet type as an int in host byte order. */
178 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
181 u16 *result = va_arg (*args, u16 *);
185 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
187 if (type >= (1 << 16))
195 /* Parse an IP6 address. */
197 unformat_ip6_address (unformat_input_t * input, va_list * args)
199 ip6_address_t *result = va_arg (*args, ip6_address_t *);
201 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
202 uword c, n_colon, double_colon_index;
204 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
205 double_colon_index = ARRAY_LEN (hex_quads);
206 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
209 if (c >= '0' && c <= '9')
211 else if (c >= 'a' && c <= 'f')
212 hex_digit = c + 10 - 'a';
213 else if (c >= 'A' && c <= 'F')
214 hex_digit = c + 10 - 'A';
215 else if (c == ':' && n_colon < 2)
219 unformat_put_input (input);
223 /* Too many hex quads. */
224 if (n_hex_quads >= ARRAY_LEN (hex_quads))
229 hex_quad = (hex_quad << 4) | hex_digit;
231 /* Hex quad must fit in 16 bits. */
232 if (n_hex_digits >= 4)
239 /* Save position of :: */
242 /* More than one :: ? */
243 if (double_colon_index < ARRAY_LEN (hex_quads))
245 double_colon_index = n_hex_quads;
248 if (n_colon > 0 && n_hex_digits > 0)
250 hex_quads[n_hex_quads++] = hex_quad;
256 if (n_hex_digits > 0)
257 hex_quads[n_hex_quads++] = hex_quad;
262 /* Expand :: to appropriate number of zero hex quads. */
263 if (double_colon_index < ARRAY_LEN (hex_quads))
265 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
267 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
268 hex_quads[n_zero + i] = hex_quads[i];
270 for (i = 0; i < n_zero; i++)
271 hex_quads[double_colon_index + i] = 0;
273 n_hex_quads = ARRAY_LEN (hex_quads);
276 /* Too few hex quads given. */
277 if (n_hex_quads < ARRAY_LEN (hex_quads))
280 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
281 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
288 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
290 u32 *r = va_arg (*args, u32 *);
293 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
294 foreach_ipsec_policy_action
302 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
304 u32 *r = va_arg (*args, u32 *);
307 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
308 foreach_ipsec_crypto_alg
316 format_ipsec_crypto_alg (u8 * s, va_list * args)
318 u32 i = va_arg (*args, u32);
323 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
324 foreach_ipsec_crypto_alg
327 return format (s, "unknown");
329 return format (s, "%s", t);
333 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
339 foreach_ipsec_integ_alg
347 format_ipsec_integ_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_integ_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ikev2_auth_method (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_AUTH_METHOD_##f;
370 foreach_ikev2_auth_method
378 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
380 u32 *r = va_arg (*args, u32 *);
383 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
384 foreach_ikev2_id_type
390 #endif /* VPP_API_TEST_BUILTIN */
393 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
395 u8 *r = va_arg (*args, u8 *);
397 if (unformat (input, "kbps"))
398 *r = SSE2_QOS_RATE_KBPS;
399 else if (unformat (input, "pps"))
400 *r = SSE2_QOS_RATE_PPS;
407 unformat_policer_round_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "closest"))
412 *r = SSE2_QOS_ROUND_TO_CLOSEST;
413 else if (unformat (input, "up"))
414 *r = SSE2_QOS_ROUND_TO_UP;
415 else if (unformat (input, "down"))
416 *r = SSE2_QOS_ROUND_TO_DOWN;
423 unformat_policer_type (unformat_input_t * input, va_list * args)
425 u8 *r = va_arg (*args, u8 *);
427 if (unformat (input, "1r2c"))
428 *r = SSE2_QOS_POLICER_TYPE_1R2C;
429 else if (unformat (input, "1r3c"))
430 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
431 else if (unformat (input, "2r3c-2698"))
432 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
433 else if (unformat (input, "2r3c-4115"))
434 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
435 else if (unformat (input, "2r3c-mef5cf1"))
436 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
443 unformat_dscp (unformat_input_t * input, va_list * va)
445 u8 *r = va_arg (*va, u8 *);
448 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
457 unformat_policer_action_type (unformat_input_t * input, va_list * va)
459 sse2_qos_pol_action_params_st *a
460 = va_arg (*va, sse2_qos_pol_action_params_st *);
462 if (unformat (input, "drop"))
463 a->action_type = SSE2_QOS_ACTION_DROP;
464 else if (unformat (input, "transmit"))
465 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
466 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
467 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
474 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
476 u32 *r = va_arg (*va, u32 *);
479 if (unformat (input, "ip4"))
480 tid = POLICER_CLASSIFY_TABLE_IP4;
481 else if (unformat (input, "ip6"))
482 tid = POLICER_CLASSIFY_TABLE_IP6;
483 else if (unformat (input, "l2"))
484 tid = POLICER_CLASSIFY_TABLE_L2;
493 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
495 u32 *r = va_arg (*va, u32 *);
498 if (unformat (input, "ip4"))
499 tid = FLOW_CLASSIFY_TABLE_IP4;
500 else if (unformat (input, "ip6"))
501 tid = FLOW_CLASSIFY_TABLE_IP6;
509 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
510 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
511 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
512 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
515 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
517 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
518 mfib_itf_attribute_t attr;
521 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
523 if (unformat (input, mfib_itf_flag_long_names[attr]))
524 *iflags |= (1 << attr);
526 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
528 if (unformat (input, mfib_itf_flag_names[attr]))
529 *iflags |= (1 << attr);
532 return (old == *iflags ? 0 : 1);
536 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
538 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
539 mfib_entry_attribute_t attr;
542 FOR_EACH_MFIB_ATTRIBUTE (attr)
544 if (unformat (input, mfib_flag_long_names[attr]))
545 *eflags |= (1 << attr);
547 FOR_EACH_MFIB_ATTRIBUTE (attr)
549 if (unformat (input, mfib_flag_names[attr]))
550 *eflags |= (1 << attr);
553 return (old == *eflags ? 0 : 1);
556 #if (VPP_API_TEST_BUILTIN==0)
558 format_ip4_address (u8 * s, va_list * args)
560 u8 *a = va_arg (*args, u8 *);
561 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
565 format_ip6_address (u8 * s, va_list * args)
567 ip6_address_t *a = va_arg (*args, ip6_address_t *);
568 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
570 i_max_n_zero = ARRAY_LEN (a->as_u16);
572 i_first_zero = i_max_n_zero;
574 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
576 u32 is_zero = a->as_u16[i] == 0;
577 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
583 if ((!is_zero && n_zeros > max_n_zeros)
584 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
586 i_max_n_zero = i_first_zero;
587 max_n_zeros = n_zeros;
588 i_first_zero = ARRAY_LEN (a->as_u16);
593 last_double_colon = 0;
594 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
596 if (i == i_max_n_zero && max_n_zeros > 1)
598 s = format (s, "::");
599 i += max_n_zeros - 1;
600 last_double_colon = 1;
604 s = format (s, "%s%x",
605 (last_double_colon || i == 0) ? "" : ":",
606 clib_net_to_host_u16 (a->as_u16[i]));
607 last_double_colon = 0;
614 /* Format an IP46 address. */
616 format_ip46_address (u8 * s, va_list * args)
618 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
619 ip46_type_t type = va_arg (*args, ip46_type_t);
625 is_ip4 = ip46_address_is_ip4 (ip46);
636 format (s, "%U", format_ip4_address, &ip46->ip4) :
637 format (s, "%U", format_ip6_address, &ip46->ip6);
641 format_ethernet_address (u8 * s, va_list * args)
643 u8 *a = va_arg (*args, u8 *);
645 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
646 a[0], a[1], a[2], a[3], a[4], a[5]);
651 increment_v4_address (ip4_address_t * a)
655 v = ntohl (a->as_u32) + 1;
656 a->as_u32 = ntohl (v);
660 increment_v6_address (ip6_address_t * a)
664 v0 = clib_net_to_host_u64 (a->as_u64[0]);
665 v1 = clib_net_to_host_u64 (a->as_u64[1]);
670 a->as_u64[0] = clib_net_to_host_u64 (v0);
671 a->as_u64[1] = clib_net_to_host_u64 (v1);
675 increment_mac_address (u64 * mac)
679 tmp = clib_net_to_host_u64 (tmp);
680 tmp += 1 << 16; /* skip unused (least significant) octets */
681 tmp = clib_host_to_net_u64 (tmp);
685 static void vl_api_create_loopback_reply_t_handler
686 (vl_api_create_loopback_reply_t * mp)
688 vat_main_t *vam = &vat_main;
689 i32 retval = ntohl (mp->retval);
691 vam->retval = retval;
692 vam->regenerate_interface_table = 1;
693 vam->sw_if_index = ntohl (mp->sw_if_index);
694 vam->result_ready = 1;
697 static void vl_api_create_loopback_reply_t_handler_json
698 (vl_api_create_loopback_reply_t * mp)
700 vat_main_t *vam = &vat_main;
701 vat_json_node_t node;
703 vat_json_init_object (&node);
704 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
705 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
707 vat_json_print (vam->ofp, &node);
708 vat_json_free (&node);
709 vam->retval = ntohl (mp->retval);
710 vam->result_ready = 1;
713 static void vl_api_af_packet_create_reply_t_handler
714 (vl_api_af_packet_create_reply_t * mp)
716 vat_main_t *vam = &vat_main;
717 i32 retval = ntohl (mp->retval);
719 vam->retval = retval;
720 vam->regenerate_interface_table = 1;
721 vam->sw_if_index = ntohl (mp->sw_if_index);
722 vam->result_ready = 1;
725 static void vl_api_af_packet_create_reply_t_handler_json
726 (vl_api_af_packet_create_reply_t * mp)
728 vat_main_t *vam = &vat_main;
729 vat_json_node_t node;
731 vat_json_init_object (&node);
732 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
733 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
735 vat_json_print (vam->ofp, &node);
736 vat_json_free (&node);
738 vam->retval = ntohl (mp->retval);
739 vam->result_ready = 1;
742 static void vl_api_create_vlan_subif_reply_t_handler
743 (vl_api_create_vlan_subif_reply_t * mp)
745 vat_main_t *vam = &vat_main;
746 i32 retval = ntohl (mp->retval);
748 vam->retval = retval;
749 vam->regenerate_interface_table = 1;
750 vam->sw_if_index = ntohl (mp->sw_if_index);
751 vam->result_ready = 1;
754 static void vl_api_create_vlan_subif_reply_t_handler_json
755 (vl_api_create_vlan_subif_reply_t * mp)
757 vat_main_t *vam = &vat_main;
758 vat_json_node_t node;
760 vat_json_init_object (&node);
761 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
762 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
764 vat_json_print (vam->ofp, &node);
765 vat_json_free (&node);
767 vam->retval = ntohl (mp->retval);
768 vam->result_ready = 1;
771 static void vl_api_create_subif_reply_t_handler
772 (vl_api_create_subif_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 i32 retval = ntohl (mp->retval);
777 vam->retval = retval;
778 vam->regenerate_interface_table = 1;
779 vam->sw_if_index = ntohl (mp->sw_if_index);
780 vam->result_ready = 1;
783 static void vl_api_create_subif_reply_t_handler_json
784 (vl_api_create_subif_reply_t * mp)
786 vat_main_t *vam = &vat_main;
787 vat_json_node_t node;
789 vat_json_init_object (&node);
790 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
791 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
793 vat_json_print (vam->ofp, &node);
794 vat_json_free (&node);
796 vam->retval = ntohl (mp->retval);
797 vam->result_ready = 1;
800 static void vl_api_interface_name_renumber_reply_t_handler
801 (vl_api_interface_name_renumber_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 i32 retval = ntohl (mp->retval);
806 vam->retval = retval;
807 vam->regenerate_interface_table = 1;
808 vam->result_ready = 1;
811 static void vl_api_interface_name_renumber_reply_t_handler_json
812 (vl_api_interface_name_renumber_reply_t * mp)
814 vat_main_t *vam = &vat_main;
815 vat_json_node_t node;
817 vat_json_init_object (&node);
818 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
820 vat_json_print (vam->ofp, &node);
821 vat_json_free (&node);
823 vam->retval = ntohl (mp->retval);
824 vam->result_ready = 1;
828 * Special-case: build the interface table, maintain
829 * the next loopback sw_if_index vbl.
831 static void vl_api_sw_interface_details_t_handler
832 (vl_api_sw_interface_details_t * mp)
834 vat_main_t *vam = &vat_main;
835 u8 *s = format (0, "%s%c", mp->interface_name, 0);
837 hash_set_mem (vam->sw_if_index_by_interface_name, s,
838 ntohl (mp->sw_if_index));
840 /* In sub interface case, fill the sub interface table entry */
841 if (mp->sw_if_index != mp->sup_sw_if_index)
843 sw_interface_subif_t *sub = NULL;
845 vec_add2 (vam->sw_if_subif_table, sub, 1);
847 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
848 strncpy ((char *) sub->interface_name, (char *) s,
849 vec_len (sub->interface_name));
850 sub->sw_if_index = ntohl (mp->sw_if_index);
851 sub->sub_id = ntohl (mp->sub_id);
853 sub->sub_dot1ad = mp->sub_dot1ad;
854 sub->sub_number_of_tags = mp->sub_number_of_tags;
855 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
856 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
857 sub->sub_exact_match = mp->sub_exact_match;
858 sub->sub_default = mp->sub_default;
859 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
860 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
862 /* vlan tag rewrite */
863 sub->vtr_op = ntohl (mp->vtr_op);
864 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
865 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
866 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
870 static void vl_api_sw_interface_details_t_handler_json
871 (vl_api_sw_interface_details_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t *node = NULL;
876 if (VAT_JSON_ARRAY != vam->json_tree.type)
878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
879 vat_json_init_array (&vam->json_tree);
881 node = vat_json_array_add (&vam->json_tree);
883 vat_json_init_object (node);
884 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
885 vat_json_object_add_uint (node, "sup_sw_if_index",
886 ntohl (mp->sup_sw_if_index));
887 vat_json_object_add_uint (node, "l2_address_length",
888 ntohl (mp->l2_address_length));
889 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
890 sizeof (mp->l2_address));
891 vat_json_object_add_string_copy (node, "interface_name",
893 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
894 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
895 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
896 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
897 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
898 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
899 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
900 vat_json_object_add_uint (node, "sub_number_of_tags",
901 mp->sub_number_of_tags);
902 vat_json_object_add_uint (node, "sub_outer_vlan_id",
903 ntohs (mp->sub_outer_vlan_id));
904 vat_json_object_add_uint (node, "sub_inner_vlan_id",
905 ntohs (mp->sub_inner_vlan_id));
906 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
907 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
908 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
909 mp->sub_outer_vlan_id_any);
910 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
911 mp->sub_inner_vlan_id_any);
912 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
913 vat_json_object_add_uint (node, "vtr_push_dot1q",
914 ntohl (mp->vtr_push_dot1q));
915 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
916 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
919 static void vl_api_sw_interface_set_flags_t_handler
920 (vl_api_sw_interface_set_flags_t * mp)
922 vat_main_t *vam = &vat_main;
923 if (vam->interface_event_display)
924 errmsg ("interface flags: sw_if_index %d %s %s",
925 ntohl (mp->sw_if_index),
926 mp->admin_up_down ? "admin-up" : "admin-down",
927 mp->link_up_down ? "link-up" : "link-down");
930 static void vl_api_sw_interface_set_flags_t_handler_json
931 (vl_api_sw_interface_set_flags_t * mp)
933 /* JSON output not supported */
937 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
939 vat_main_t *vam = &vat_main;
940 i32 retval = ntohl (mp->retval);
942 vam->retval = retval;
943 vam->shmem_result = (u8 *) mp->reply_in_shmem;
944 vam->result_ready = 1;
948 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
950 vat_main_t *vam = &vat_main;
951 vat_json_node_t node;
952 api_main_t *am = &api_main;
956 vat_json_init_object (&node);
957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
958 vat_json_object_add_uint (&node, "reply_in_shmem",
959 ntohl (mp->reply_in_shmem));
960 /* Toss the shared-memory original... */
961 pthread_mutex_lock (&am->vlib_rp->mutex);
962 oldheap = svm_push_data_heap (am->vlib_rp);
964 reply = (u8 *) (mp->reply_in_shmem);
967 svm_pop_heap (oldheap);
968 pthread_mutex_unlock (&am->vlib_rp->mutex);
970 vat_json_print (vam->ofp, &node);
971 vat_json_free (&node);
973 vam->retval = ntohl (mp->retval);
974 vam->result_ready = 1;
978 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
980 vat_main_t *vam = &vat_main;
981 i32 retval = ntohl (mp->retval);
983 vam->retval = retval;
984 vam->cmd_reply = mp->reply;
985 vam->result_ready = 1;
989 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
991 vat_main_t *vam = &vat_main;
992 vat_json_node_t node;
994 vat_json_init_object (&node);
995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
996 vat_json_object_add_string_copy (&node, "reply", mp->reply);
998 vat_json_print (vam->ofp, &node);
999 vat_json_free (&node);
1001 vam->retval = ntohl (mp->retval);
1002 vam->result_ready = 1;
1005 static void vl_api_classify_add_del_table_reply_t_handler
1006 (vl_api_classify_add_del_table_reply_t * mp)
1008 vat_main_t *vam = &vat_main;
1009 i32 retval = ntohl (mp->retval);
1010 if (vam->async_mode)
1012 vam->async_errors += (retval < 0);
1016 vam->retval = retval;
1018 ((mp->new_table_index != 0xFFFFFFFF) ||
1019 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1020 (mp->match_n_vectors != 0xFFFFFFFF)))
1022 * Note: this is just barely thread-safe, depends on
1023 * the main thread spinning waiting for an answer...
1025 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1026 ntohl (mp->new_table_index),
1027 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1028 vam->result_ready = 1;
1032 static void vl_api_classify_add_del_table_reply_t_handler_json
1033 (vl_api_classify_add_del_table_reply_t * mp)
1035 vat_main_t *vam = &vat_main;
1036 vat_json_node_t node;
1038 vat_json_init_object (&node);
1039 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1040 vat_json_object_add_uint (&node, "new_table_index",
1041 ntohl (mp->new_table_index));
1042 vat_json_object_add_uint (&node, "skip_n_vectors",
1043 ntohl (mp->skip_n_vectors));
1044 vat_json_object_add_uint (&node, "match_n_vectors",
1045 ntohl (mp->match_n_vectors));
1047 vat_json_print (vam->ofp, &node);
1048 vat_json_free (&node);
1050 vam->retval = ntohl (mp->retval);
1051 vam->result_ready = 1;
1054 static void vl_api_get_node_index_reply_t_handler
1055 (vl_api_get_node_index_reply_t * mp)
1057 vat_main_t *vam = &vat_main;
1058 i32 retval = ntohl (mp->retval);
1059 if (vam->async_mode)
1061 vam->async_errors += (retval < 0);
1065 vam->retval = retval;
1067 errmsg ("node index %d", ntohl (mp->node_index));
1068 vam->result_ready = 1;
1072 static void vl_api_get_node_index_reply_t_handler_json
1073 (vl_api_get_node_index_reply_t * mp)
1075 vat_main_t *vam = &vat_main;
1076 vat_json_node_t node;
1078 vat_json_init_object (&node);
1079 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1080 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1082 vat_json_print (vam->ofp, &node);
1083 vat_json_free (&node);
1085 vam->retval = ntohl (mp->retval);
1086 vam->result_ready = 1;
1089 static void vl_api_get_next_index_reply_t_handler
1090 (vl_api_get_next_index_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 i32 retval = ntohl (mp->retval);
1094 if (vam->async_mode)
1096 vam->async_errors += (retval < 0);
1100 vam->retval = retval;
1102 errmsg ("next node index %d", ntohl (mp->next_index));
1103 vam->result_ready = 1;
1107 static void vl_api_get_next_index_reply_t_handler_json
1108 (vl_api_get_next_index_reply_t * mp)
1110 vat_main_t *vam = &vat_main;
1111 vat_json_node_t node;
1113 vat_json_init_object (&node);
1114 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1115 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1117 vat_json_print (vam->ofp, &node);
1118 vat_json_free (&node);
1120 vam->retval = ntohl (mp->retval);
1121 vam->result_ready = 1;
1124 static void vl_api_add_node_next_reply_t_handler
1125 (vl_api_add_node_next_reply_t * mp)
1127 vat_main_t *vam = &vat_main;
1128 i32 retval = ntohl (mp->retval);
1129 if (vam->async_mode)
1131 vam->async_errors += (retval < 0);
1135 vam->retval = retval;
1137 errmsg ("next index %d", ntohl (mp->next_index));
1138 vam->result_ready = 1;
1142 static void vl_api_add_node_next_reply_t_handler_json
1143 (vl_api_add_node_next_reply_t * mp)
1145 vat_main_t *vam = &vat_main;
1146 vat_json_node_t node;
1148 vat_json_init_object (&node);
1149 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1150 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1152 vat_json_print (vam->ofp, &node);
1153 vat_json_free (&node);
1155 vam->retval = ntohl (mp->retval);
1156 vam->result_ready = 1;
1159 static void vl_api_show_version_reply_t_handler
1160 (vl_api_show_version_reply_t * mp)
1162 vat_main_t *vam = &vat_main;
1163 i32 retval = ntohl (mp->retval);
1167 errmsg (" program: %s", mp->program);
1168 errmsg (" version: %s", mp->version);
1169 errmsg (" build date: %s", mp->build_date);
1170 errmsg ("build directory: %s", mp->build_directory);
1172 vam->retval = retval;
1173 vam->result_ready = 1;
1176 static void vl_api_show_version_reply_t_handler_json
1177 (vl_api_show_version_reply_t * mp)
1179 vat_main_t *vam = &vat_main;
1180 vat_json_node_t node;
1182 vat_json_init_object (&node);
1183 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1184 vat_json_object_add_string_copy (&node, "program", mp->program);
1185 vat_json_object_add_string_copy (&node, "version", mp->version);
1186 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1187 vat_json_object_add_string_copy (&node, "build_directory",
1188 mp->build_directory);
1190 vat_json_print (vam->ofp, &node);
1191 vat_json_free (&node);
1193 vam->retval = ntohl (mp->retval);
1194 vam->result_ready = 1;
1198 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1200 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1201 mp->mac_ip ? "mac/ip binding" : "address resolution",
1202 format_ip4_address, &mp->address,
1203 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1207 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1209 /* JSON output not supported */
1213 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1215 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1216 mp->mac_ip ? "mac/ip binding" : "address resolution",
1217 format_ip6_address, mp->address,
1218 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1222 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1224 /* JSON output not supported */
1228 * Special-case: build the bridge domain table, maintain
1229 * the next bd id vbl.
1231 static void vl_api_bridge_domain_details_t_handler
1232 (vl_api_bridge_domain_details_t * mp)
1234 vat_main_t *vam = &vat_main;
1235 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1237 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1238 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1240 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1241 ntohl (mp->bd_id), mp->learn, mp->forward,
1242 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1245 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1248 static void vl_api_bridge_domain_details_t_handler_json
1249 (vl_api_bridge_domain_details_t * mp)
1251 vat_main_t *vam = &vat_main;
1252 vat_json_node_t *node, *array = NULL;
1254 if (VAT_JSON_ARRAY != vam->json_tree.type)
1256 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1257 vat_json_init_array (&vam->json_tree);
1259 node = vat_json_array_add (&vam->json_tree);
1261 vat_json_init_object (node);
1262 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1263 vat_json_object_add_uint (node, "flood", mp->flood);
1264 vat_json_object_add_uint (node, "forward", mp->forward);
1265 vat_json_object_add_uint (node, "learn", mp->learn);
1266 vat_json_object_add_uint (node, "bvi_sw_if_index",
1267 ntohl (mp->bvi_sw_if_index));
1268 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1269 array = vat_json_object_add (node, "sw_if");
1270 vat_json_init_array (array);
1274 * Special-case: build the bridge domain sw if table.
1276 static void vl_api_bridge_domain_sw_if_details_t_handler
1277 (vl_api_bridge_domain_sw_if_details_t * mp)
1279 vat_main_t *vam = &vat_main;
1284 sw_if_index = ntohl (mp->sw_if_index);
1286 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1288 if ((u32) p->value[0] == sw_if_index)
1290 sw_if_name = (u8 *)(p->key);
1296 print (vam->ofp, "%7d %3d %s", sw_if_index,
1297 mp->shg, sw_if_name ? (char *) sw_if_name :
1298 "sw_if_index not found!");
1301 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1302 (vl_api_bridge_domain_sw_if_details_t * mp)
1304 vat_main_t *vam = &vat_main;
1305 vat_json_node_t *node = NULL;
1306 uword last_index = 0;
1308 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1309 ASSERT (vec_len (vam->json_tree.array) >= 1);
1310 last_index = vec_len (vam->json_tree.array) - 1;
1311 node = &vam->json_tree.array[last_index];
1312 node = vat_json_object_get_element (node, "sw_if");
1313 ASSERT (NULL != node);
1314 node = vat_json_array_add (node);
1316 vat_json_init_object (node);
1317 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1318 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1319 vat_json_object_add_uint (node, "shg", mp->shg);
1322 static void vl_api_control_ping_reply_t_handler
1323 (vl_api_control_ping_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 i32 retval = ntohl (mp->retval);
1327 if (vam->async_mode)
1329 vam->async_errors += (retval < 0);
1333 vam->retval = retval;
1334 vam->result_ready = 1;
1338 static void vl_api_control_ping_reply_t_handler_json
1339 (vl_api_control_ping_reply_t * mp)
1341 vat_main_t *vam = &vat_main;
1342 i32 retval = ntohl (mp->retval);
1344 if (VAT_JSON_NONE != vam->json_tree.type)
1346 vat_json_print (vam->ofp, &vam->json_tree);
1347 vat_json_free (&vam->json_tree);
1348 vam->json_tree.type = VAT_JSON_NONE;
1353 vat_json_init_array (&vam->json_tree);
1354 vat_json_print (vam->ofp, &vam->json_tree);
1355 vam->json_tree.type = VAT_JSON_NONE;
1358 vam->retval = retval;
1359 vam->result_ready = 1;
1363 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1365 vat_main_t *vam = &vat_main;
1366 i32 retval = ntohl (mp->retval);
1367 if (vam->async_mode)
1369 vam->async_errors += (retval < 0);
1373 vam->retval = retval;
1374 vam->result_ready = 1;
1378 static void vl_api_l2_flags_reply_t_handler_json
1379 (vl_api_l2_flags_reply_t * mp)
1381 vat_main_t *vam = &vat_main;
1382 vat_json_node_t node;
1384 vat_json_init_object (&node);
1385 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1386 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1387 ntohl (mp->resulting_feature_bitmap));
1389 vat_json_print (vam->ofp, &node);
1390 vat_json_free (&node);
1392 vam->retval = ntohl (mp->retval);
1393 vam->result_ready = 1;
1396 static void vl_api_bridge_flags_reply_t_handler
1397 (vl_api_bridge_flags_reply_t * mp)
1399 vat_main_t *vam = &vat_main;
1400 i32 retval = ntohl (mp->retval);
1401 if (vam->async_mode)
1403 vam->async_errors += (retval < 0);
1407 vam->retval = retval;
1408 vam->result_ready = 1;
1412 static void vl_api_bridge_flags_reply_t_handler_json
1413 (vl_api_bridge_flags_reply_t * mp)
1415 vat_main_t *vam = &vat_main;
1416 vat_json_node_t node;
1418 vat_json_init_object (&node);
1419 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1420 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1421 ntohl (mp->resulting_feature_bitmap));
1423 vat_json_print (vam->ofp, &node);
1424 vat_json_free (&node);
1426 vam->retval = ntohl (mp->retval);
1427 vam->result_ready = 1;
1430 static void vl_api_tap_connect_reply_t_handler
1431 (vl_api_tap_connect_reply_t * mp)
1433 vat_main_t *vam = &vat_main;
1434 i32 retval = ntohl (mp->retval);
1435 if (vam->async_mode)
1437 vam->async_errors += (retval < 0);
1441 vam->retval = retval;
1442 vam->sw_if_index = ntohl (mp->sw_if_index);
1443 vam->result_ready = 1;
1448 static void vl_api_tap_connect_reply_t_handler_json
1449 (vl_api_tap_connect_reply_t * mp)
1451 vat_main_t *vam = &vat_main;
1452 vat_json_node_t node;
1454 vat_json_init_object (&node);
1455 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1456 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1458 vat_json_print (vam->ofp, &node);
1459 vat_json_free (&node);
1461 vam->retval = ntohl (mp->retval);
1462 vam->result_ready = 1;
1467 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1469 vat_main_t *vam = &vat_main;
1470 i32 retval = ntohl (mp->retval);
1471 if (vam->async_mode)
1473 vam->async_errors += (retval < 0);
1477 vam->retval = retval;
1478 vam->sw_if_index = ntohl (mp->sw_if_index);
1479 vam->result_ready = 1;
1483 static void vl_api_tap_modify_reply_t_handler_json
1484 (vl_api_tap_modify_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 vat_json_node_t node;
1489 vat_json_init_object (&node);
1490 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1491 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1493 vat_json_print (vam->ofp, &node);
1494 vat_json_free (&node);
1496 vam->retval = ntohl (mp->retval);
1497 vam->result_ready = 1;
1501 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1503 vat_main_t *vam = &vat_main;
1504 i32 retval = ntohl (mp->retval);
1505 if (vam->async_mode)
1507 vam->async_errors += (retval < 0);
1511 vam->retval = retval;
1512 vam->result_ready = 1;
1516 static void vl_api_tap_delete_reply_t_handler_json
1517 (vl_api_tap_delete_reply_t * mp)
1519 vat_main_t *vam = &vat_main;
1520 vat_json_node_t node;
1522 vat_json_init_object (&node);
1523 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1525 vat_json_print (vam->ofp, &node);
1526 vat_json_free (&node);
1528 vam->retval = ntohl (mp->retval);
1529 vam->result_ready = 1;
1532 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1533 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1535 vat_main_t *vam = &vat_main;
1536 i32 retval = ntohl (mp->retval);
1537 if (vam->async_mode)
1539 vam->async_errors += (retval < 0);
1543 vam->retval = retval;
1544 vam->result_ready = 1;
1548 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1549 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1551 vat_main_t *vam = &vat_main;
1552 vat_json_node_t node;
1554 vat_json_init_object (&node);
1555 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1556 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1557 ntohl (mp->sw_if_index));
1559 vat_json_print (vam->ofp, &node);
1560 vat_json_free (&node);
1562 vam->retval = ntohl (mp->retval);
1563 vam->result_ready = 1;
1566 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1567 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1569 vat_main_t *vam = &vat_main;
1570 i32 retval = ntohl (mp->retval);
1571 if (vam->async_mode)
1573 vam->async_errors += (retval < 0);
1577 vam->retval = retval;
1578 vam->sw_if_index = ntohl (mp->sw_if_index);
1579 vam->result_ready = 1;
1583 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1584 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1586 vat_main_t *vam = &vat_main;
1587 vat_json_node_t node;
1589 vat_json_init_object (&node);
1590 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1591 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1593 vat_json_print (vam->ofp, &node);
1594 vat_json_free (&node);
1596 vam->retval = ntohl (mp->retval);
1597 vam->result_ready = 1;
1601 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1602 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1604 vat_main_t *vam = &vat_main;
1605 i32 retval = ntohl (mp->retval);
1606 if (vam->async_mode)
1608 vam->async_errors += (retval < 0);
1612 vam->retval = retval;
1613 vam->result_ready = 1;
1617 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1618 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1620 vat_main_t *vam = &vat_main;
1621 vat_json_node_t node;
1623 vat_json_init_object (&node);
1624 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1625 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1627 vat_json_print (vam->ofp, &node);
1628 vat_json_free (&node);
1630 vam->retval = ntohl (mp->retval);
1631 vam->result_ready = 1;
1634 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1635 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1637 vat_main_t *vam = &vat_main;
1638 i32 retval = ntohl (mp->retval);
1639 if (vam->async_mode)
1641 vam->async_errors += (retval < 0);
1645 vam->retval = retval;
1646 vam->sw_if_index = ntohl (mp->sw_if_index);
1647 vam->result_ready = 1;
1651 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1652 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1654 vat_main_t *vam = &vat_main;
1655 vat_json_node_t node;
1657 vat_json_init_object (&node);
1658 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1659 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1661 vat_json_print (vam->ofp, &node);
1662 vat_json_free (&node);
1664 vam->retval = ntohl (mp->retval);
1665 vam->result_ready = 1;
1668 static void vl_api_gre_add_del_tunnel_reply_t_handler
1669 (vl_api_gre_add_del_tunnel_reply_t * mp)
1671 vat_main_t *vam = &vat_main;
1672 i32 retval = ntohl (mp->retval);
1673 if (vam->async_mode)
1675 vam->async_errors += (retval < 0);
1679 vam->retval = retval;
1680 vam->sw_if_index = ntohl (mp->sw_if_index);
1681 vam->result_ready = 1;
1685 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1686 (vl_api_gre_add_del_tunnel_reply_t * mp)
1688 vat_main_t *vam = &vat_main;
1689 vat_json_node_t node;
1691 vat_json_init_object (&node);
1692 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1693 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1695 vat_json_print (vam->ofp, &node);
1696 vat_json_free (&node);
1698 vam->retval = ntohl (mp->retval);
1699 vam->result_ready = 1;
1702 static void vl_api_create_vhost_user_if_reply_t_handler
1703 (vl_api_create_vhost_user_if_reply_t * mp)
1705 vat_main_t *vam = &vat_main;
1706 i32 retval = ntohl (mp->retval);
1707 if (vam->async_mode)
1709 vam->async_errors += (retval < 0);
1713 vam->retval = retval;
1714 vam->sw_if_index = ntohl (mp->sw_if_index);
1715 vam->result_ready = 1;
1719 static void vl_api_create_vhost_user_if_reply_t_handler_json
1720 (vl_api_create_vhost_user_if_reply_t * mp)
1722 vat_main_t *vam = &vat_main;
1723 vat_json_node_t node;
1725 vat_json_init_object (&node);
1726 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1727 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1729 vat_json_print (vam->ofp, &node);
1730 vat_json_free (&node);
1732 vam->retval = ntohl (mp->retval);
1733 vam->result_ready = 1;
1736 static void vl_api_ip_address_details_t_handler
1737 (vl_api_ip_address_details_t * mp)
1739 vat_main_t *vam = &vat_main;
1740 static ip_address_details_t empty_ip_address_details = { {0} };
1741 ip_address_details_t *address = NULL;
1742 ip_details_t *current_ip_details = NULL;
1743 ip_details_t *details = NULL;
1745 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1747 if (!details || vam->current_sw_if_index >= vec_len (details)
1748 || !details[vam->current_sw_if_index].present)
1750 errmsg ("ip address details arrived but not stored");
1751 errmsg ("ip_dump should be called first");
1755 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1757 #define addresses (current_ip_details->addr)
1759 vec_validate_init_empty (addresses, vec_len (addresses),
1760 empty_ip_address_details);
1762 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1764 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1765 address->prefix_length = mp->prefix_length;
1769 static void vl_api_ip_address_details_t_handler_json
1770 (vl_api_ip_address_details_t * mp)
1772 vat_main_t *vam = &vat_main;
1773 vat_json_node_t *node = NULL;
1774 struct in6_addr ip6;
1777 if (VAT_JSON_ARRAY != vam->json_tree.type)
1779 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1780 vat_json_init_array (&vam->json_tree);
1782 node = vat_json_array_add (&vam->json_tree);
1784 vat_json_init_object (node);
1787 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1788 vat_json_object_add_ip6 (node, "ip", ip6);
1792 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1793 vat_json_object_add_ip4 (node, "ip", ip4);
1795 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1799 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 static ip_details_t empty_ip_details = { 0 };
1803 ip_details_t *ip = NULL;
1804 u32 sw_if_index = ~0;
1806 sw_if_index = ntohl (mp->sw_if_index);
1808 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1809 sw_if_index, empty_ip_details);
1811 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1818 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1820 vat_main_t *vam = &vat_main;
1822 if (VAT_JSON_ARRAY != vam->json_tree.type)
1824 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1825 vat_json_init_array (&vam->json_tree);
1827 vat_json_array_add_uint (&vam->json_tree,
1828 clib_net_to_host_u32 (mp->sw_if_index));
1831 static void vl_api_map_domain_details_t_handler_json
1832 (vl_api_map_domain_details_t * mp)
1834 vat_json_node_t *node = NULL;
1835 vat_main_t *vam = &vat_main;
1836 struct in6_addr ip6;
1839 if (VAT_JSON_ARRAY != vam->json_tree.type)
1841 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1842 vat_json_init_array (&vam->json_tree);
1845 node = vat_json_array_add (&vam->json_tree);
1846 vat_json_init_object (node);
1848 vat_json_object_add_uint (node, "domain_index",
1849 clib_net_to_host_u32 (mp->domain_index));
1850 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1851 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1852 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1853 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1854 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1855 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1856 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1857 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1858 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1859 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1860 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1861 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1862 vat_json_object_add_uint (node, "flags", mp->flags);
1863 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1864 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1867 static void vl_api_map_domain_details_t_handler
1868 (vl_api_map_domain_details_t * mp)
1870 vat_main_t *vam = &vat_main;
1872 if (mp->is_translation)
1875 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1876 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1877 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1878 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1879 clib_net_to_host_u32 (mp->domain_index));
1884 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1885 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1886 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1887 format_ip6_address, mp->ip6_src,
1888 clib_net_to_host_u32 (mp->domain_index));
1890 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1891 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1892 mp->is_translation ? "map-t" : "");
1895 static void vl_api_map_rule_details_t_handler_json
1896 (vl_api_map_rule_details_t * mp)
1898 struct in6_addr ip6;
1899 vat_json_node_t *node = NULL;
1900 vat_main_t *vam = &vat_main;
1902 if (VAT_JSON_ARRAY != vam->json_tree.type)
1904 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1905 vat_json_init_array (&vam->json_tree);
1908 node = vat_json_array_add (&vam->json_tree);
1909 vat_json_init_object (node);
1911 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1912 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1913 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1917 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1921 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1925 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1927 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1928 "router_addr %U host_mac %U",
1929 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1930 format_ip4_address, &mp->host_address,
1931 format_ip4_address, &mp->router_address,
1932 format_ethernet_address, mp->host_mac);
1935 static void vl_api_dhcp_compl_event_t_handler_json
1936 (vl_api_dhcp_compl_event_t * mp)
1938 /* JSON output not supported */
1942 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1945 vat_main_t *vam = &vat_main;
1946 static u64 default_counter = 0;
1948 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1950 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1951 sw_if_index, default_counter);
1952 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1956 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1957 interface_counter_t counter)
1959 vat_main_t *vam = &vat_main;
1960 static interface_counter_t default_counter = { 0, };
1962 vec_validate_init_empty (vam->combined_interface_counters,
1963 vnet_counter_type, NULL);
1964 vec_validate_init_empty (vam->combined_interface_counters
1965 [vnet_counter_type], sw_if_index, default_counter);
1966 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1969 static void vl_api_vnet_interface_counters_t_handler
1970 (vl_api_vnet_interface_counters_t * mp)
1975 static void vl_api_vnet_interface_counters_t_handler_json
1976 (vl_api_vnet_interface_counters_t * mp)
1978 interface_counter_t counter;
1983 u32 first_sw_if_index;
1986 count = ntohl (mp->count);
1987 first_sw_if_index = ntohl (mp->first_sw_if_index);
1989 if (!mp->is_combined)
1991 v_packets = (u64 *) & mp->data;
1992 for (i = 0; i < count; i++)
1995 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1996 set_simple_interface_counter (mp->vnet_counter_type,
1997 first_sw_if_index + i, packets);
2003 v = (vlib_counter_t *) & mp->data;
2004 for (i = 0; i < count; i++)
2007 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2009 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2010 set_combined_interface_counter (mp->vnet_counter_type,
2011 first_sw_if_index + i, counter);
2018 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2020 vat_main_t *vam = &vat_main;
2023 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2025 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2034 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2036 vat_main_t *vam = &vat_main;
2039 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2041 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2049 static void vl_api_vnet_ip4_fib_counters_t_handler
2050 (vl_api_vnet_ip4_fib_counters_t * mp)
2055 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2056 (vl_api_vnet_ip4_fib_counters_t * mp)
2058 vat_main_t *vam = &vat_main;
2059 vl_api_ip4_fib_counter_t *v;
2060 ip4_fib_counter_t *counter;
2067 vrf_id = ntohl (mp->vrf_id);
2068 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2069 if (~0 == vrf_index)
2071 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2072 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2073 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2074 vec_validate (vam->ip4_fib_counters, vrf_index);
2075 vam->ip4_fib_counters[vrf_index] = NULL;
2078 vec_free (vam->ip4_fib_counters[vrf_index]);
2079 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2080 count = ntohl (mp->count);
2081 for (i = 0; i < count; i++)
2083 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2084 counter = &vam->ip4_fib_counters[vrf_index][i];
2085 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2086 counter->address = ip4;
2087 counter->address_length = v->address_length;
2088 counter->packets = clib_net_to_host_u64 (v->packets);
2089 counter->bytes = clib_net_to_host_u64 (v->bytes);
2094 static void vl_api_vnet_ip4_nbr_counters_t_handler
2095 (vl_api_vnet_ip4_nbr_counters_t * mp)
2100 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2101 (vl_api_vnet_ip4_nbr_counters_t * mp)
2103 vat_main_t *vam = &vat_main;
2104 vl_api_ip4_nbr_counter_t *v;
2105 ip4_nbr_counter_t *counter;
2110 sw_if_index = ntohl (mp->sw_if_index);
2111 count = ntohl (mp->count);
2112 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2115 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2117 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2118 for (i = 0; i < count; i++)
2120 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2121 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2122 counter->address.s_addr = v->address;
2123 counter->packets = clib_net_to_host_u64 (v->packets);
2124 counter->bytes = clib_net_to_host_u64 (v->bytes);
2125 counter->linkt = v->link_type;
2130 static void vl_api_vnet_ip6_fib_counters_t_handler
2131 (vl_api_vnet_ip6_fib_counters_t * mp)
2136 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2137 (vl_api_vnet_ip6_fib_counters_t * mp)
2139 vat_main_t *vam = &vat_main;
2140 vl_api_ip6_fib_counter_t *v;
2141 ip6_fib_counter_t *counter;
2142 struct in6_addr ip6;
2148 vrf_id = ntohl (mp->vrf_id);
2149 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2150 if (~0 == vrf_index)
2152 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2153 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2154 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2155 vec_validate (vam->ip6_fib_counters, vrf_index);
2156 vam->ip6_fib_counters[vrf_index] = NULL;
2159 vec_free (vam->ip6_fib_counters[vrf_index]);
2160 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2161 count = ntohl (mp->count);
2162 for (i = 0; i < count; i++)
2164 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2165 counter = &vam->ip6_fib_counters[vrf_index][i];
2166 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2167 counter->address = ip6;
2168 counter->address_length = v->address_length;
2169 counter->packets = clib_net_to_host_u64 (v->packets);
2170 counter->bytes = clib_net_to_host_u64 (v->bytes);
2175 static void vl_api_vnet_ip6_nbr_counters_t_handler
2176 (vl_api_vnet_ip6_nbr_counters_t * mp)
2181 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2182 (vl_api_vnet_ip6_nbr_counters_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 vl_api_ip6_nbr_counter_t *v;
2186 ip6_nbr_counter_t *counter;
2187 struct in6_addr ip6;
2192 sw_if_index = ntohl (mp->sw_if_index);
2193 count = ntohl (mp->count);
2194 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2197 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2199 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2200 for (i = 0; i < count; i++)
2202 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2203 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2204 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2205 counter->address = ip6;
2206 counter->packets = clib_net_to_host_u64 (v->packets);
2207 counter->bytes = clib_net_to_host_u64 (v->bytes);
2212 static void vl_api_get_first_msg_id_reply_t_handler
2213 (vl_api_get_first_msg_id_reply_t * mp)
2215 vat_main_t *vam = &vat_main;
2216 i32 retval = ntohl (mp->retval);
2218 if (vam->async_mode)
2220 vam->async_errors += (retval < 0);
2224 vam->retval = retval;
2225 vam->result_ready = 1;
2229 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2233 static void vl_api_get_first_msg_id_reply_t_handler_json
2234 (vl_api_get_first_msg_id_reply_t * mp)
2236 vat_main_t *vam = &vat_main;
2237 vat_json_node_t node;
2239 vat_json_init_object (&node);
2240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2241 vat_json_object_add_uint (&node, "first_msg_id",
2242 (uint) ntohs (mp->first_msg_id));
2244 vat_json_print (vam->ofp, &node);
2245 vat_json_free (&node);
2247 vam->retval = ntohl (mp->retval);
2248 vam->result_ready = 1;
2251 static void vl_api_get_node_graph_reply_t_handler
2252 (vl_api_get_node_graph_reply_t * mp)
2254 vat_main_t *vam = &vat_main;
2255 api_main_t *am = &api_main;
2256 i32 retval = ntohl (mp->retval);
2257 u8 *pvt_copy, *reply;
2262 if (vam->async_mode)
2264 vam->async_errors += (retval < 0);
2268 vam->retval = retval;
2269 vam->result_ready = 1;
2272 /* "Should never happen..." */
2276 reply = (u8 *) (mp->reply_in_shmem);
2277 pvt_copy = vec_dup (reply);
2279 /* Toss the shared-memory original... */
2280 pthread_mutex_lock (&am->vlib_rp->mutex);
2281 oldheap = svm_push_data_heap (am->vlib_rp);
2285 svm_pop_heap (oldheap);
2286 pthread_mutex_unlock (&am->vlib_rp->mutex);
2288 if (vam->graph_nodes)
2290 hash_free (vam->graph_node_index_by_name);
2292 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2294 node = vam->graph_nodes[i];
2295 vec_free (node->name);
2296 vec_free (node->next_nodes);
2299 vec_free (vam->graph_nodes);
2302 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2303 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2304 vec_free (pvt_copy);
2306 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2308 node = vam->graph_nodes[i];
2309 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2313 static void vl_api_get_node_graph_reply_t_handler_json
2314 (vl_api_get_node_graph_reply_t * mp)
2316 vat_main_t *vam = &vat_main;
2317 api_main_t *am = &api_main;
2319 vat_json_node_t node;
2322 /* $$$$ make this real? */
2323 vat_json_init_object (&node);
2324 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2325 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2327 reply = (u8 *) (mp->reply_in_shmem);
2329 /* Toss the shared-memory original... */
2330 pthread_mutex_lock (&am->vlib_rp->mutex);
2331 oldheap = svm_push_data_heap (am->vlib_rp);
2335 svm_pop_heap (oldheap);
2336 pthread_mutex_unlock (&am->vlib_rp->mutex);
2338 vat_json_print (vam->ofp, &node);
2339 vat_json_free (&node);
2341 vam->retval = ntohl (mp->retval);
2342 vam->result_ready = 1;
2346 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2348 vat_main_t *vam = &vat_main;
2353 s = format (s, "%=16d%=16d%=16d",
2354 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2358 s = format (s, "%=16U%=16d%=16d",
2359 mp->is_ipv6 ? format_ip6_address :
2361 mp->ip_address, mp->priority, mp->weight);
2364 print (vam->ofp, "%v", s);
2369 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2372 vat_main_t *vam = &vat_main;
2373 vat_json_node_t *node = NULL;
2374 struct in6_addr ip6;
2377 if (VAT_JSON_ARRAY != vam->json_tree.type)
2379 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2380 vat_json_init_array (&vam->json_tree);
2382 node = vat_json_array_add (&vam->json_tree);
2383 vat_json_init_object (node);
2385 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2386 vat_json_object_add_uint (node, "priority", mp->priority);
2387 vat_json_object_add_uint (node, "weight", mp->weight);
2390 vat_json_object_add_uint (node, "sw_if_index",
2391 clib_net_to_host_u32 (mp->sw_if_index));
2396 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2397 vat_json_object_add_ip6 (node, "address", ip6);
2401 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2402 vat_json_object_add_ip4 (node, "address", ip4);
2408 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2411 vat_main_t *vam = &vat_main;
2414 ls_name = format (0, "%s", mp->ls_name);
2416 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2422 vl_api_lisp_locator_set_details_t_handler_json
2423 (vl_api_lisp_locator_set_details_t * mp)
2425 vat_main_t *vam = &vat_main;
2426 vat_json_node_t *node = 0;
2429 ls_name = format (0, "%s", mp->ls_name);
2430 vec_add1 (ls_name, 0);
2432 if (VAT_JSON_ARRAY != vam->json_tree.type)
2434 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2435 vat_json_init_array (&vam->json_tree);
2437 node = vat_json_array_add (&vam->json_tree);
2439 vat_json_init_object (node);
2440 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2441 vat_json_object_add_uint (node, "ls_index",
2442 clib_net_to_host_u32 (mp->ls_index));
2447 format_lisp_flat_eid (u8 * s, va_list * args)
2449 u32 type = va_arg (*args, u32);
2450 u8 *eid = va_arg (*args, u8 *);
2451 u32 eid_len = va_arg (*args, u32);
2456 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2458 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2460 return format (s, "%U", format_ethernet_address, eid);
2466 format_lisp_eid_vat (u8 * s, va_list * args)
2468 u32 type = va_arg (*args, u32);
2469 u8 *eid = va_arg (*args, u8 *);
2470 u32 eid_len = va_arg (*args, u32);
2471 u8 *seid = va_arg (*args, u8 *);
2472 u32 seid_len = va_arg (*args, u32);
2473 u32 is_src_dst = va_arg (*args, u32);
2476 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2478 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2484 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2486 vat_main_t *vam = &vat_main;
2487 u8 *s = 0, *eid = 0;
2489 if (~0 == mp->locator_set_index)
2490 s = format (0, "action: %d", mp->action);
2492 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2494 eid = format (0, "%U", format_lisp_eid_vat,
2498 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2501 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2502 clib_net_to_host_u32 (mp->vni),
2504 mp->is_local ? "local" : "remote",
2505 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2506 clib_net_to_host_u16 (mp->key_id), mp->key);
2513 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2516 vat_main_t *vam = &vat_main;
2517 vat_json_node_t *node = 0;
2520 if (VAT_JSON_ARRAY != vam->json_tree.type)
2522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2523 vat_json_init_array (&vam->json_tree);
2525 node = vat_json_array_add (&vam->json_tree);
2527 vat_json_init_object (node);
2528 if (~0 == mp->locator_set_index)
2529 vat_json_object_add_uint (node, "action", mp->action);
2531 vat_json_object_add_uint (node, "locator_set_index",
2532 clib_net_to_host_u32 (mp->locator_set_index));
2534 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2535 eid = format (0, "%U", format_lisp_eid_vat,
2539 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2541 vat_json_object_add_string_copy (node, "eid", eid);
2542 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2543 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2544 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2548 vat_json_object_add_uint (node, "key_id",
2549 clib_net_to_host_u16 (mp->key_id));
2550 vat_json_object_add_string_copy (node, "key", mp->key);
2556 vl_api_lisp_eid_table_map_details_t_handler
2557 (vl_api_lisp_eid_table_map_details_t * mp)
2559 vat_main_t *vam = &vat_main;
2561 u8 *line = format (0, "%=10d%=10d",
2562 clib_net_to_host_u32 (mp->vni),
2563 clib_net_to_host_u32 (mp->dp_table));
2564 print (vam->ofp, "%v", line);
2569 vl_api_lisp_eid_table_map_details_t_handler_json
2570 (vl_api_lisp_eid_table_map_details_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 vat_json_node_t *node = NULL;
2575 if (VAT_JSON_ARRAY != vam->json_tree.type)
2577 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2578 vat_json_init_array (&vam->json_tree);
2580 node = vat_json_array_add (&vam->json_tree);
2581 vat_json_init_object (node);
2582 vat_json_object_add_uint (node, "dp_table",
2583 clib_net_to_host_u32 (mp->dp_table));
2584 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2588 vl_api_lisp_eid_table_vni_details_t_handler
2589 (vl_api_lisp_eid_table_vni_details_t * mp)
2591 vat_main_t *vam = &vat_main;
2593 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2594 print (vam->ofp, "%v", line);
2599 vl_api_lisp_eid_table_vni_details_t_handler_json
2600 (vl_api_lisp_eid_table_vni_details_t * mp)
2602 vat_main_t *vam = &vat_main;
2603 vat_json_node_t *node = NULL;
2605 if (VAT_JSON_ARRAY != vam->json_tree.type)
2607 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2608 vat_json_init_array (&vam->json_tree);
2610 node = vat_json_array_add (&vam->json_tree);
2611 vat_json_init_object (node);
2612 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2616 vl_api_show_lisp_map_register_state_reply_t_handler
2617 (vl_api_show_lisp_map_register_state_reply_t * mp)
2619 vat_main_t *vam = &vat_main;
2620 int retval = clib_net_to_host_u32 (mp->retval);
2622 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2624 vam->retval = retval;
2625 vam->result_ready = 1;
2629 vl_api_show_lisp_map_register_state_reply_t_handler_json
2630 (vl_api_show_lisp_map_register_state_reply_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 vat_json_node_t _node, *node = &_node;
2634 int retval = clib_net_to_host_u32 (mp->retval);
2636 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2638 vat_json_init_object (node);
2639 vat_json_object_add_string_copy (node, "state", s);
2641 vat_json_print (vam->ofp, node);
2642 vat_json_free (node);
2644 vam->retval = retval;
2645 vam->result_ready = 1;
2650 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2651 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2653 vat_main_t *vam = &vat_main;
2654 int retval = clib_net_to_host_u32 (mp->retval);
2659 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2661 vam->retval = retval;
2662 vam->result_ready = 1;
2666 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2667 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2669 vat_main_t *vam = &vat_main;
2670 vat_json_node_t _node, *node = &_node;
2671 int retval = clib_net_to_host_u32 (mp->retval);
2673 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2674 vat_json_init_object (node);
2675 vat_json_object_add_string_copy (node, "state", s);
2677 vat_json_print (vam->ofp, node);
2678 vat_json_free (node);
2680 vam->retval = retval;
2681 vam->result_ready = 1;
2686 api_lisp_gpe_fwd_entry_net_to_host (vl_api_lisp_gpe_fwd_entry_t * e)
2688 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2689 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2693 lisp_gpe_fwd_entries_get_reply_t_net_to_host
2694 (vl_api_lisp_gpe_fwd_entries_get_reply_t * mp)
2698 mp->count = clib_net_to_host_u32 (mp->count);
2699 for (i = 0; i < mp->count; i++)
2701 api_lisp_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2706 vl_api_lisp_gpe_fwd_entry_path_details_t_handler
2707 (vl_api_lisp_gpe_fwd_entry_path_details_t * mp)
2709 vat_main_t *vam = &vat_main;
2710 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2712 if (mp->lcl_loc.is_ip4)
2713 format_ip_address_fcn = format_ip4_address;
2715 format_ip_address_fcn = format_ip6_address;
2717 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2718 format_ip_address_fcn, &mp->lcl_loc,
2719 format_ip_address_fcn, &mp->rmt_loc);
2723 lisp_fill_locator_node (vat_json_node_t * n, vl_api_lisp_gpe_locator_t * loc)
2725 struct in6_addr ip6;
2730 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2731 vat_json_object_add_ip4 (n, "address", ip4);
2735 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2736 vat_json_object_add_ip6 (n, "address", ip6);
2738 vat_json_object_add_uint (n, "weight", loc->weight);
2742 vl_api_lisp_gpe_fwd_entry_path_details_t_handler_json
2743 (vl_api_lisp_gpe_fwd_entry_path_details_t * mp)
2745 vat_main_t *vam = &vat_main;
2746 vat_json_node_t *node = NULL;
2747 vat_json_node_t *loc_node;
2749 if (VAT_JSON_ARRAY != vam->json_tree.type)
2751 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2752 vat_json_init_array (&vam->json_tree);
2754 node = vat_json_array_add (&vam->json_tree);
2755 vat_json_init_object (node);
2757 loc_node = vat_json_object_add (node, "local_locator");
2758 vat_json_init_object (loc_node);
2759 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2761 loc_node = vat_json_object_add (node, "remote_locator");
2762 vat_json_init_object (loc_node);
2763 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2767 vl_api_lisp_gpe_fwd_entries_get_reply_t_handler
2768 (vl_api_lisp_gpe_fwd_entries_get_reply_t * mp)
2770 vat_main_t *vam = &vat_main;
2772 int retval = clib_net_to_host_u32 (mp->retval);
2773 vl_api_lisp_gpe_fwd_entry_t *e;
2778 lisp_gpe_fwd_entries_get_reply_t_net_to_host (mp);
2780 for (i = 0; i < mp->count; i++)
2782 e = &mp->entries[i];
2783 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2784 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2785 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2789 vam->retval = retval;
2790 vam->result_ready = 1;
2794 vl_api_lisp_gpe_fwd_entries_get_reply_t_handler_json
2795 (vl_api_lisp_gpe_fwd_entries_get_reply_t * mp)
2798 vat_main_t *vam = &vat_main;
2799 vat_json_node_t *e = 0, root;
2801 int retval = clib_net_to_host_u32 (mp->retval);
2802 vl_api_lisp_gpe_fwd_entry_t *fwd;
2807 lisp_gpe_fwd_entries_get_reply_t_net_to_host (mp);
2808 vat_json_init_array (&root);
2810 for (i = 0; i < mp->count; i++)
2812 e = vat_json_array_add (&root);
2813 fwd = &mp->entries[i];
2815 vat_json_init_object (e);
2816 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2817 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2819 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2820 fwd->leid_prefix_len);
2822 vat_json_object_add_string_copy (e, "leid", s);
2825 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2826 fwd->reid_prefix_len);
2828 vat_json_object_add_string_copy (e, "reid", s);
2832 vat_json_print (vam->ofp, &root);
2833 vat_json_free (&root);
2836 vam->retval = retval;
2837 vam->result_ready = 1;
2841 vl_api_lisp_adjacencies_get_reply_t_handler
2842 (vl_api_lisp_adjacencies_get_reply_t * mp)
2844 vat_main_t *vam = &vat_main;
2846 int retval = clib_net_to_host_u32 (mp->retval);
2847 vl_api_lisp_adjacency_t *a;
2852 n = clib_net_to_host_u32 (mp->count);
2854 for (i = 0; i < n; i++)
2856 a = &mp->adjacencies[i];
2857 print (vam->ofp, "%U %40U",
2858 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2859 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2863 vam->retval = retval;
2864 vam->result_ready = 1;
2868 vl_api_lisp_adjacencies_get_reply_t_handler_json
2869 (vl_api_lisp_adjacencies_get_reply_t * mp)
2872 vat_main_t *vam = &vat_main;
2873 vat_json_node_t *e = 0, root;
2875 int retval = clib_net_to_host_u32 (mp->retval);
2876 vl_api_lisp_adjacency_t *a;
2881 n = clib_net_to_host_u32 (mp->count);
2882 vat_json_init_array (&root);
2884 for (i = 0; i < n; i++)
2886 e = vat_json_array_add (&root);
2887 a = &mp->adjacencies[i];
2889 vat_json_init_object (e);
2890 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2891 a->leid_prefix_len);
2893 vat_json_object_add_string_copy (e, "leid", s);
2896 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2897 a->reid_prefix_len);
2899 vat_json_object_add_string_copy (e, "reid", s);
2903 vat_json_print (vam->ofp, &root);
2904 vat_json_free (&root);
2907 vam->retval = retval;
2908 vam->result_ready = 1;
2912 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2915 vat_main_t *vam = &vat_main;
2917 print (vam->ofp, "%=20U",
2918 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2923 vl_api_lisp_map_server_details_t_handler_json
2924 (vl_api_lisp_map_server_details_t * mp)
2926 vat_main_t *vam = &vat_main;
2927 vat_json_node_t *node = NULL;
2928 struct in6_addr ip6;
2931 if (VAT_JSON_ARRAY != vam->json_tree.type)
2933 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2934 vat_json_init_array (&vam->json_tree);
2936 node = vat_json_array_add (&vam->json_tree);
2938 vat_json_init_object (node);
2941 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2942 vat_json_object_add_ip6 (node, "map-server", ip6);
2946 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2947 vat_json_object_add_ip4 (node, "map-server", ip4);
2952 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2955 vat_main_t *vam = &vat_main;
2957 print (vam->ofp, "%=20U",
2958 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2963 vl_api_lisp_map_resolver_details_t_handler_json
2964 (vl_api_lisp_map_resolver_details_t * mp)
2966 vat_main_t *vam = &vat_main;
2967 vat_json_node_t *node = NULL;
2968 struct in6_addr ip6;
2971 if (VAT_JSON_ARRAY != vam->json_tree.type)
2973 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2974 vat_json_init_array (&vam->json_tree);
2976 node = vat_json_array_add (&vam->json_tree);
2978 vat_json_init_object (node);
2981 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2982 vat_json_object_add_ip6 (node, "map resolver", ip6);
2986 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2987 vat_json_object_add_ip4 (node, "map resolver", ip4);
2992 vl_api_show_lisp_status_reply_t_handler
2993 (vl_api_show_lisp_status_reply_t * mp)
2995 vat_main_t *vam = &vat_main;
2996 i32 retval = ntohl (mp->retval);
3000 print (vam->ofp, "feature: %s\ngpe: %s",
3001 mp->feature_status ? "enabled" : "disabled",
3002 mp->gpe_status ? "enabled" : "disabled");
3005 vam->retval = retval;
3006 vam->result_ready = 1;
3010 vl_api_show_lisp_status_reply_t_handler_json
3011 (vl_api_show_lisp_status_reply_t * mp)
3013 vat_main_t *vam = &vat_main;
3014 vat_json_node_t node;
3015 u8 *gpe_status = NULL;
3016 u8 *feature_status = NULL;
3018 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3019 feature_status = format (0, "%s",
3020 mp->feature_status ? "enabled" : "disabled");
3021 vec_add1 (gpe_status, 0);
3022 vec_add1 (feature_status, 0);
3024 vat_json_init_object (&node);
3025 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3026 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3028 vec_free (gpe_status);
3029 vec_free (feature_status);
3031 vat_json_print (vam->ofp, &node);
3032 vat_json_free (&node);
3034 vam->retval = ntohl (mp->retval);
3035 vam->result_ready = 1;
3039 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
3040 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
3042 vat_main_t *vam = &vat_main;
3043 i32 retval = ntohl (mp->retval);
3047 print (vam->ofp, "%=20s", mp->locator_set_name);
3050 vam->retval = retval;
3051 vam->result_ready = 1;
3055 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
3056 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
3058 vat_main_t *vam = &vat_main;
3059 vat_json_node_t *node = NULL;
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3071 vat_json_print (vam->ofp, node);
3072 vat_json_free (node);
3074 vam->retval = ntohl (mp->retval);
3075 vam->result_ready = 1;
3079 format_lisp_map_request_mode (u8 * s, va_list * args)
3081 u32 mode = va_arg (*args, u32);
3086 return format (0, "dst-only");
3088 return format (0, "src-dst");
3094 vl_api_show_lisp_map_request_mode_reply_t_handler
3095 (vl_api_show_lisp_map_request_mode_reply_t * mp)
3097 vat_main_t *vam = &vat_main;
3098 i32 retval = ntohl (mp->retval);
3102 u32 mode = mp->mode;
3103 print (vam->ofp, "map_request_mode: %U",
3104 format_lisp_map_request_mode, mode);
3107 vam->retval = retval;
3108 vam->result_ready = 1;
3112 vl_api_show_lisp_map_request_mode_reply_t_handler_json
3113 (vl_api_show_lisp_map_request_mode_reply_t * mp)
3115 vat_main_t *vam = &vat_main;
3116 vat_json_node_t node;
3121 s = format (0, "%U", format_lisp_map_request_mode, mode);
3124 vat_json_init_object (&node);
3125 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3126 vat_json_print (vam->ofp, &node);
3127 vat_json_free (&node);
3130 vam->retval = ntohl (mp->retval);
3131 vam->result_ready = 1;
3135 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
3137 vat_main_t *vam = &vat_main;
3138 i32 retval = ntohl (mp->retval);
3142 print (vam->ofp, "%-20s%-16s",
3143 mp->status ? "enabled" : "disabled",
3144 mp->status ? (char *) mp->locator_set_name : "");
3147 vam->retval = retval;
3148 vam->result_ready = 1;
3152 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
3155 vat_main_t *vam = &vat_main;
3156 vat_json_node_t node;
3159 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3160 vec_add1 (status, 0);
3162 vat_json_init_object (&node);
3163 vat_json_object_add_string_copy (&node, "status", status);
3166 vat_json_object_add_string_copy (&node, "locator_set",
3167 mp->locator_set_name);
3172 vat_json_print (vam->ofp, &node);
3173 vat_json_free (&node);
3175 vam->retval = ntohl (mp->retval);
3176 vam->result_ready = 1;
3180 format_policer_type (u8 * s, va_list * va)
3182 u32 i = va_arg (*va, u32);
3184 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3185 s = format (s, "1r2c");
3186 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3187 s = format (s, "1r3c");
3188 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3189 s = format (s, "2r3c-2698");
3190 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3191 s = format (s, "2r3c-4115");
3192 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3193 s = format (s, "2r3c-mef5cf1");
3195 s = format (s, "ILLEGAL");
3200 format_policer_rate_type (u8 * s, va_list * va)
3202 u32 i = va_arg (*va, u32);
3204 if (i == SSE2_QOS_RATE_KBPS)
3205 s = format (s, "kbps");
3206 else if (i == SSE2_QOS_RATE_PPS)
3207 s = format (s, "pps");
3209 s = format (s, "ILLEGAL");
3214 format_policer_round_type (u8 * s, va_list * va)
3216 u32 i = va_arg (*va, u32);
3218 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3219 s = format (s, "closest");
3220 else if (i == SSE2_QOS_ROUND_TO_UP)
3221 s = format (s, "up");
3222 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3223 s = format (s, "down");
3225 s = format (s, "ILLEGAL");
3230 format_policer_action_type (u8 * s, va_list * va)
3232 u32 i = va_arg (*va, u32);
3234 if (i == SSE2_QOS_ACTION_DROP)
3235 s = format (s, "drop");
3236 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3237 s = format (s, "transmit");
3238 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3239 s = format (s, "mark-and-transmit");
3241 s = format (s, "ILLEGAL");
3246 format_dscp (u8 * s, va_list * va)
3248 u32 i = va_arg (*va, u32);
3253 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3257 return format (s, "ILLEGAL");
3259 s = format (s, "%s", t);
3264 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3266 vat_main_t *vam = &vat_main;
3267 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3269 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3270 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3272 conform_dscp_str = format (0, "");
3274 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3275 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3277 exceed_dscp_str = format (0, "");
3279 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3280 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3282 violate_dscp_str = format (0, "");
3284 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3285 "rate type %U, round type %U, %s rate, %s color-aware, "
3286 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3287 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3288 "conform action %U%s, exceed action %U%s, violate action %U%s",
3290 format_policer_type, mp->type,
3293 clib_net_to_host_u64 (mp->cb),
3294 clib_net_to_host_u64 (mp->eb),
3295 format_policer_rate_type, mp->rate_type,
3296 format_policer_round_type, mp->round_type,
3297 mp->single_rate ? "single" : "dual",
3298 mp->color_aware ? "is" : "not",
3299 ntohl (mp->cir_tokens_per_period),
3300 ntohl (mp->pir_tokens_per_period),
3302 ntohl (mp->current_limit),
3303 ntohl (mp->current_bucket),
3304 ntohl (mp->extended_limit),
3305 ntohl (mp->extended_bucket),
3306 clib_net_to_host_u64 (mp->last_update_time),
3307 format_policer_action_type, mp->conform_action_type,
3309 format_policer_action_type, mp->exceed_action_type,
3311 format_policer_action_type, mp->violate_action_type,
3314 vec_free (conform_dscp_str);
3315 vec_free (exceed_dscp_str);
3316 vec_free (violate_dscp_str);
3319 static void vl_api_policer_details_t_handler_json
3320 (vl_api_policer_details_t * mp)
3322 vat_main_t *vam = &vat_main;
3323 vat_json_node_t *node;
3324 u8 *rate_type_str, *round_type_str, *type_str;
3325 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3327 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3329 format (0, "%U", format_policer_round_type, mp->round_type);
3330 type_str = format (0, "%U", format_policer_type, mp->type);
3331 conform_action_str = format (0, "%U", format_policer_action_type,
3332 mp->conform_action_type);
3333 exceed_action_str = format (0, "%U", format_policer_action_type,
3334 mp->exceed_action_type);
3335 violate_action_str = format (0, "%U", format_policer_action_type,
3336 mp->violate_action_type);
3338 if (VAT_JSON_ARRAY != vam->json_tree.type)
3340 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3341 vat_json_init_array (&vam->json_tree);
3343 node = vat_json_array_add (&vam->json_tree);
3345 vat_json_init_object (node);
3346 vat_json_object_add_string_copy (node, "name", mp->name);
3347 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3348 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3349 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3350 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3351 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3352 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3353 vat_json_object_add_string_copy (node, "type", type_str);
3354 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3355 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3356 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3357 vat_json_object_add_uint (node, "cir_tokens_per_period",
3358 ntohl (mp->cir_tokens_per_period));
3359 vat_json_object_add_uint (node, "eir_tokens_per_period",
3360 ntohl (mp->pir_tokens_per_period));
3361 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3362 vat_json_object_add_uint (node, "current_bucket",
3363 ntohl (mp->current_bucket));
3364 vat_json_object_add_uint (node, "extended_limit",
3365 ntohl (mp->extended_limit));
3366 vat_json_object_add_uint (node, "extended_bucket",
3367 ntohl (mp->extended_bucket));
3368 vat_json_object_add_uint (node, "last_update_time",
3369 ntohl (mp->last_update_time));
3370 vat_json_object_add_string_copy (node, "conform_action",
3371 conform_action_str);
3372 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3374 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3375 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3376 vec_free (dscp_str);
3378 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3379 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3381 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3382 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3383 vec_free (dscp_str);
3385 vat_json_object_add_string_copy (node, "violate_action",
3386 violate_action_str);
3387 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3389 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3390 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3391 vec_free (dscp_str);
3394 vec_free (rate_type_str);
3395 vec_free (round_type_str);
3396 vec_free (type_str);
3397 vec_free (conform_action_str);
3398 vec_free (exceed_action_str);
3399 vec_free (violate_action_str);
3403 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3406 vat_main_t *vam = &vat_main;
3407 int i, count = ntohl (mp->count);
3410 print (vam->ofp, "classify table ids (%d) : ", count);
3411 for (i = 0; i < count; i++)
3413 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3414 print (vam->ofp, (i < count - 1) ? "," : "");
3416 vam->retval = ntohl (mp->retval);
3417 vam->result_ready = 1;
3421 vl_api_classify_table_ids_reply_t_handler_json
3422 (vl_api_classify_table_ids_reply_t * mp)
3424 vat_main_t *vam = &vat_main;
3425 int i, count = ntohl (mp->count);
3429 vat_json_node_t node;
3431 vat_json_init_object (&node);
3432 for (i = 0; i < count; i++)
3434 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3436 vat_json_print (vam->ofp, &node);
3437 vat_json_free (&node);
3439 vam->retval = ntohl (mp->retval);
3440 vam->result_ready = 1;
3444 vl_api_classify_table_by_interface_reply_t_handler
3445 (vl_api_classify_table_by_interface_reply_t * mp)
3447 vat_main_t *vam = &vat_main;
3450 table_id = ntohl (mp->l2_table_id);
3452 print (vam->ofp, "l2 table id : %d", table_id);
3454 print (vam->ofp, "l2 table id : No input ACL tables configured");
3455 table_id = ntohl (mp->ip4_table_id);
3457 print (vam->ofp, "ip4 table id : %d", table_id);
3459 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3460 table_id = ntohl (mp->ip6_table_id);
3462 print (vam->ofp, "ip6 table id : %d", table_id);
3464 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3465 vam->retval = ntohl (mp->retval);
3466 vam->result_ready = 1;
3470 vl_api_classify_table_by_interface_reply_t_handler_json
3471 (vl_api_classify_table_by_interface_reply_t * mp)
3473 vat_main_t *vam = &vat_main;
3474 vat_json_node_t node;
3476 vat_json_init_object (&node);
3478 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3479 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3480 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3482 vat_json_print (vam->ofp, &node);
3483 vat_json_free (&node);
3485 vam->retval = ntohl (mp->retval);
3486 vam->result_ready = 1;
3489 static void vl_api_policer_add_del_reply_t_handler
3490 (vl_api_policer_add_del_reply_t * mp)
3492 vat_main_t *vam = &vat_main;
3493 i32 retval = ntohl (mp->retval);
3494 if (vam->async_mode)
3496 vam->async_errors += (retval < 0);
3500 vam->retval = retval;
3501 vam->result_ready = 1;
3502 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3504 * Note: this is just barely thread-safe, depends on
3505 * the main thread spinning waiting for an answer...
3507 errmsg ("policer index %d", ntohl (mp->policer_index));
3511 static void vl_api_policer_add_del_reply_t_handler_json
3512 (vl_api_policer_add_del_reply_t * mp)
3514 vat_main_t *vam = &vat_main;
3515 vat_json_node_t node;
3517 vat_json_init_object (&node);
3518 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3519 vat_json_object_add_uint (&node, "policer_index",
3520 ntohl (mp->policer_index));
3522 vat_json_print (vam->ofp, &node);
3523 vat_json_free (&node);
3525 vam->retval = ntohl (mp->retval);
3526 vam->result_ready = 1;
3529 /* Format hex dump. */
3531 format_hex_bytes (u8 * s, va_list * va)
3533 u8 *bytes = va_arg (*va, u8 *);
3534 int n_bytes = va_arg (*va, int);
3537 /* Print short or long form depending on byte count. */
3538 uword short_form = n_bytes <= 32;
3539 uword indent = format_get_indent (s);
3544 for (i = 0; i < n_bytes; i++)
3546 if (!short_form && (i % 32) == 0)
3547 s = format (s, "%08x: ", i);
3548 s = format (s, "%02x", bytes[i]);
3549 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3550 s = format (s, "\n%U", format_white_space, indent);
3557 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3560 vat_main_t *vam = &vat_main;
3561 i32 retval = ntohl (mp->retval);
3564 print (vam->ofp, "classify table info :");
3565 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3566 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3567 ntohl (mp->miss_next_index));
3568 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3569 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3570 ntohl (mp->match_n_vectors));
3571 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3572 ntohl (mp->mask_length));
3574 vam->retval = retval;
3575 vam->result_ready = 1;
3579 vl_api_classify_table_info_reply_t_handler_json
3580 (vl_api_classify_table_info_reply_t * mp)
3582 vat_main_t *vam = &vat_main;
3583 vat_json_node_t node;
3585 i32 retval = ntohl (mp->retval);
3588 vat_json_init_object (&node);
3590 vat_json_object_add_int (&node, "sessions",
3591 ntohl (mp->active_sessions));
3592 vat_json_object_add_int (&node, "nexttbl",
3593 ntohl (mp->next_table_index));
3594 vat_json_object_add_int (&node, "nextnode",
3595 ntohl (mp->miss_next_index));
3596 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3597 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3598 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3599 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3600 ntohl (mp->mask_length), 0);
3601 vat_json_object_add_string_copy (&node, "mask", s);
3603 vat_json_print (vam->ofp, &node);
3604 vat_json_free (&node);
3606 vam->retval = ntohl (mp->retval);
3607 vam->result_ready = 1;
3611 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3614 vat_main_t *vam = &vat_main;
3616 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3617 ntohl (mp->hit_next_index), ntohl (mp->advance),
3618 ntohl (mp->opaque_index));
3619 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3620 ntohl (mp->match_length));
3624 vl_api_classify_session_details_t_handler_json
3625 (vl_api_classify_session_details_t * mp)
3627 vat_main_t *vam = &vat_main;
3628 vat_json_node_t *node = NULL;
3630 if (VAT_JSON_ARRAY != vam->json_tree.type)
3632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3633 vat_json_init_array (&vam->json_tree);
3635 node = vat_json_array_add (&vam->json_tree);
3637 vat_json_init_object (node);
3638 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3639 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3640 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3642 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3644 vat_json_object_add_string_copy (node, "match", s);
3647 static void vl_api_pg_create_interface_reply_t_handler
3648 (vl_api_pg_create_interface_reply_t * mp)
3650 vat_main_t *vam = &vat_main;
3652 vam->retval = ntohl (mp->retval);
3653 vam->result_ready = 1;
3656 static void vl_api_pg_create_interface_reply_t_handler_json
3657 (vl_api_pg_create_interface_reply_t * mp)
3659 vat_main_t *vam = &vat_main;
3660 vat_json_node_t node;
3662 i32 retval = ntohl (mp->retval);
3665 vat_json_init_object (&node);
3667 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3669 vat_json_print (vam->ofp, &node);
3670 vat_json_free (&node);
3672 vam->retval = ntohl (mp->retval);
3673 vam->result_ready = 1;
3676 static void vl_api_policer_classify_details_t_handler
3677 (vl_api_policer_classify_details_t * mp)
3679 vat_main_t *vam = &vat_main;
3681 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3682 ntohl (mp->table_index));
3685 static void vl_api_policer_classify_details_t_handler_json
3686 (vl_api_policer_classify_details_t * mp)
3688 vat_main_t *vam = &vat_main;
3689 vat_json_node_t *node;
3691 if (VAT_JSON_ARRAY != vam->json_tree.type)
3693 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3694 vat_json_init_array (&vam->json_tree);
3696 node = vat_json_array_add (&vam->json_tree);
3698 vat_json_init_object (node);
3699 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3700 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3703 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3704 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3706 vat_main_t *vam = &vat_main;
3707 i32 retval = ntohl (mp->retval);
3708 if (vam->async_mode)
3710 vam->async_errors += (retval < 0);
3714 vam->retval = retval;
3715 vam->sw_if_index = ntohl (mp->sw_if_index);
3716 vam->result_ready = 1;
3720 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3721 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3723 vat_main_t *vam = &vat_main;
3724 vat_json_node_t node;
3726 vat_json_init_object (&node);
3727 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3728 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3730 vat_json_print (vam->ofp, &node);
3731 vat_json_free (&node);
3733 vam->retval = ntohl (mp->retval);
3734 vam->result_ready = 1;
3737 static void vl_api_flow_classify_details_t_handler
3738 (vl_api_flow_classify_details_t * mp)
3740 vat_main_t *vam = &vat_main;
3742 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3743 ntohl (mp->table_index));
3746 static void vl_api_flow_classify_details_t_handler_json
3747 (vl_api_flow_classify_details_t * mp)
3749 vat_main_t *vam = &vat_main;
3750 vat_json_node_t *node;
3752 if (VAT_JSON_ARRAY != vam->json_tree.type)
3754 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3755 vat_json_init_array (&vam->json_tree);
3757 node = vat_json_array_add (&vam->json_tree);
3759 vat_json_init_object (node);
3760 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3761 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3766 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3767 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3768 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3769 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3770 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3771 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3772 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3773 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3774 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3775 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3778 * Generate boilerplate reply handlers, which
3779 * dig the return value out of the xxx_reply_t API message,
3780 * stick it into vam->retval, and set vam->result_ready
3782 * Could also do this by pointing N message decode slots at
3783 * a single function, but that could break in subtle ways.
3786 #define foreach_standard_reply_retval_handler \
3787 _(sw_interface_set_flags_reply) \
3788 _(sw_interface_add_del_address_reply) \
3789 _(sw_interface_set_table_reply) \
3790 _(sw_interface_set_mpls_enable_reply) \
3791 _(sw_interface_set_vpath_reply) \
3792 _(sw_interface_set_vxlan_bypass_reply) \
3793 _(sw_interface_set_l2_bridge_reply) \
3794 _(bridge_domain_add_del_reply) \
3795 _(sw_interface_set_l2_xconnect_reply) \
3796 _(l2fib_add_del_reply) \
3797 _(ip_add_del_route_reply) \
3798 _(ip_mroute_add_del_reply) \
3799 _(mpls_route_add_del_reply) \
3800 _(mpls_ip_bind_unbind_reply) \
3801 _(proxy_arp_add_del_reply) \
3802 _(proxy_arp_intfc_enable_disable_reply) \
3803 _(sw_interface_set_unnumbered_reply) \
3804 _(ip_neighbor_add_del_reply) \
3805 _(reset_vrf_reply) \
3806 _(oam_add_del_reply) \
3807 _(reset_fib_reply) \
3808 _(dhcp_proxy_config_reply) \
3809 _(dhcp_proxy_config_2_reply) \
3810 _(dhcp_proxy_set_vss_reply) \
3811 _(dhcp_client_config_reply) \
3812 _(set_ip_flow_hash_reply) \
3813 _(sw_interface_ip6_enable_disable_reply) \
3814 _(sw_interface_ip6_set_link_local_address_reply) \
3815 _(sw_interface_ip6nd_ra_prefix_reply) \
3816 _(sw_interface_ip6nd_ra_config_reply) \
3817 _(set_arp_neighbor_limit_reply) \
3818 _(l2_patch_add_del_reply) \
3819 _(sr_tunnel_add_del_reply) \
3820 _(sr_policy_add_del_reply) \
3821 _(sr_multicast_map_add_del_reply) \
3822 _(classify_add_del_session_reply) \
3823 _(classify_set_interface_ip_table_reply) \
3824 _(classify_set_interface_l2_tables_reply) \
3825 _(l2tpv3_set_tunnel_cookies_reply) \
3826 _(l2tpv3_interface_enable_disable_reply) \
3827 _(l2tpv3_set_lookup_key_reply) \
3828 _(l2_fib_clear_table_reply) \
3829 _(l2_interface_efp_filter_reply) \
3830 _(l2_interface_vlan_tag_rewrite_reply) \
3831 _(modify_vhost_user_if_reply) \
3832 _(delete_vhost_user_if_reply) \
3833 _(want_ip4_arp_events_reply) \
3834 _(want_ip6_nd_events_reply) \
3835 _(input_acl_set_interface_reply) \
3836 _(ipsec_spd_add_del_reply) \
3837 _(ipsec_interface_add_del_spd_reply) \
3838 _(ipsec_spd_add_del_entry_reply) \
3839 _(ipsec_sad_add_del_entry_reply) \
3840 _(ipsec_sa_set_key_reply) \
3841 _(ikev2_profile_add_del_reply) \
3842 _(ikev2_profile_set_auth_reply) \
3843 _(ikev2_profile_set_id_reply) \
3844 _(ikev2_profile_set_ts_reply) \
3845 _(ikev2_set_local_key_reply) \
3846 _(delete_loopback_reply) \
3847 _(bd_ip_mac_add_del_reply) \
3848 _(map_del_domain_reply) \
3849 _(map_add_del_rule_reply) \
3850 _(want_interface_events_reply) \
3851 _(want_stats_reply) \
3852 _(cop_interface_enable_disable_reply) \
3853 _(cop_whitelist_enable_disable_reply) \
3854 _(sw_interface_clear_stats_reply) \
3855 _(ioam_enable_reply) \
3856 _(ioam_disable_reply) \
3857 _(lisp_add_del_locator_reply) \
3858 _(lisp_add_del_local_eid_reply) \
3859 _(lisp_add_del_remote_mapping_reply) \
3860 _(lisp_add_del_adjacency_reply) \
3861 _(lisp_gpe_add_del_fwd_entry_reply) \
3862 _(lisp_add_del_map_resolver_reply) \
3863 _(lisp_add_del_map_server_reply) \
3864 _(lisp_gpe_enable_disable_reply) \
3865 _(lisp_gpe_add_del_iface_reply) \
3866 _(lisp_enable_disable_reply) \
3867 _(lisp_rloc_probe_enable_disable_reply) \
3868 _(lisp_map_register_enable_disable_reply) \
3869 _(lisp_pitr_set_locator_set_reply) \
3870 _(lisp_map_request_mode_reply) \
3871 _(lisp_add_del_map_request_itr_rlocs_reply) \
3872 _(lisp_eid_table_add_del_map_reply) \
3873 _(vxlan_gpe_add_del_tunnel_reply) \
3874 _(af_packet_delete_reply) \
3875 _(policer_classify_set_interface_reply) \
3876 _(netmap_create_reply) \
3877 _(netmap_delete_reply) \
3878 _(set_ipfix_exporter_reply) \
3879 _(set_ipfix_classify_stream_reply) \
3880 _(ipfix_classify_table_add_del_reply) \
3881 _(flow_classify_set_interface_reply) \
3882 _(sw_interface_span_enable_disable_reply) \
3883 _(pg_capture_reply) \
3884 _(pg_enable_disable_reply) \
3885 _(ip_source_and_port_range_check_add_del_reply) \
3886 _(ip_source_and_port_range_check_interface_add_del_reply)\
3887 _(delete_subif_reply) \
3888 _(l2_interface_pbb_tag_rewrite_reply) \
3890 _(feature_enable_disable_reply) \
3891 _(sw_interface_tag_add_del_reply) \
3892 _(sw_interface_set_mtu_reply)
3895 #define foreach_standard_dpdk_reply_retval_handler \
3896 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3897 _(sw_interface_set_dpdk_hqos_subport_reply) \
3898 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3902 static void vl_api_##n##_t_handler \
3903 (vl_api_##n##_t * mp) \
3905 vat_main_t * vam = &vat_main; \
3906 i32 retval = ntohl(mp->retval); \
3907 if (vam->async_mode) { \
3908 vam->async_errors += (retval < 0); \
3910 vam->retval = retval; \
3911 vam->result_ready = 1; \
3914 foreach_standard_reply_retval_handler;
3918 static void vl_api_##n##_t_handler_json \
3919 (vl_api_##n##_t * mp) \
3921 vat_main_t * vam = &vat_main; \
3922 vat_json_node_t node; \
3923 vat_json_init_object(&node); \
3924 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3925 vat_json_print(vam->ofp, &node); \
3926 vam->retval = ntohl(mp->retval); \
3927 vam->result_ready = 1; \
3929 foreach_standard_reply_retval_handler;
3934 static void vl_api_##n##_t_handler \
3935 (vl_api_##n##_t * mp) \
3937 vat_main_t * vam = &vat_main; \
3938 i32 retval = ntohl(mp->retval); \
3939 if (vam->async_mode) { \
3940 vam->async_errors += (retval < 0); \
3942 vam->retval = retval; \
3943 vam->result_ready = 1; \
3946 foreach_standard_dpdk_reply_retval_handler;
3950 static void vl_api_##n##_t_handler_json \
3951 (vl_api_##n##_t * mp) \
3953 vat_main_t * vam = &vat_main; \
3954 vat_json_node_t node; \
3955 vat_json_init_object(&node); \
3956 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3957 vat_json_print(vam->ofp, &node); \
3958 vam->retval = ntohl(mp->retval); \
3959 vam->result_ready = 1; \
3961 foreach_standard_dpdk_reply_retval_handler;
3966 * Table of message reply handlers, must include boilerplate handlers
3970 #define foreach_vpe_api_reply_msg \
3971 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3972 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3973 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3974 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3975 _(CONTROL_PING_REPLY, control_ping_reply) \
3976 _(CLI_REPLY, cli_reply) \
3977 _(CLI_INBAND_REPLY, cli_inband_reply) \
3978 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3979 sw_interface_add_del_address_reply) \
3980 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3981 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3982 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3983 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3984 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3985 sw_interface_set_l2_xconnect_reply) \
3986 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3987 sw_interface_set_l2_bridge_reply) \
3988 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3989 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3990 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3991 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3992 _(L2_FLAGS_REPLY, l2_flags_reply) \
3993 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3994 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3995 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3996 _(TAP_DELETE_REPLY, tap_delete_reply) \
3997 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3998 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3999 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4000 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4001 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4002 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4003 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4004 proxy_arp_intfc_enable_disable_reply) \
4005 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4006 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4007 sw_interface_set_unnumbered_reply) \
4008 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4009 _(RESET_VRF_REPLY, reset_vrf_reply) \
4010 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4011 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4012 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4013 _(RESET_FIB_REPLY, reset_fib_reply) \
4014 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4015 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
4016 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4017 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4018 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4019 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4020 sw_interface_ip6_enable_disable_reply) \
4021 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4022 sw_interface_ip6_set_link_local_address_reply) \
4023 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4024 sw_interface_ip6nd_ra_prefix_reply) \
4025 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4026 sw_interface_ip6nd_ra_config_reply) \
4027 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4028 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4029 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4030 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4031 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4032 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4033 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4034 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4035 classify_set_interface_ip_table_reply) \
4036 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4037 classify_set_interface_l2_tables_reply) \
4038 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4039 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4040 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4041 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4042 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4043 l2tpv3_interface_enable_disable_reply) \
4044 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4045 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4046 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4047 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4048 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4049 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4050 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4051 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4052 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4053 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4054 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4055 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4056 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4057 _(SHOW_VERSION_REPLY, show_version_reply) \
4058 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4059 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4060 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4061 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4062 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4063 _(IP4_ARP_EVENT, ip4_arp_event) \
4064 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4065 _(IP6_ND_EVENT, ip6_nd_event) \
4066 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4067 _(IP_ADDRESS_DETAILS, ip_address_details) \
4068 _(IP_DETAILS, ip_details) \
4069 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4070 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4071 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4072 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4073 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4074 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4075 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4076 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4077 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4078 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4079 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4080 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4081 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4082 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4083 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4084 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4085 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4086 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4087 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4088 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4089 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4090 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4091 _(MAP_RULE_DETAILS, map_rule_details) \
4092 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4093 _(WANT_STATS_REPLY, want_stats_reply) \
4094 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4095 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4096 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4097 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4098 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4099 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4100 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4101 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
4102 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
4103 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
4104 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
4105 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
4106 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
4107 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
4108 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
4109 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
4110 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
4111 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4112 lisp_map_register_enable_disable_reply) \
4113 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4114 lisp_rloc_probe_enable_disable_reply) \
4115 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
4116 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
4117 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
4118 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
4119 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
4120 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
4121 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
4122 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
4123 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
4124 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
4125 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
4126 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
4127 _(LISP_GPE_FWD_ENTRIES_GET_REPLY, lisp_gpe_fwd_entries_get_reply) \
4128 _(LISP_GPE_FWD_ENTRY_PATH_DETAILS, \
4129 lisp_gpe_fwd_entry_path_details) \
4130 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
4131 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4132 lisp_add_del_map_request_itr_rlocs_reply) \
4133 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4134 lisp_get_map_request_itr_rlocs_reply) \
4135 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
4136 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
4137 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
4138 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
4139 show_lisp_map_register_state_reply) \
4140 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4141 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4142 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4143 _(POLICER_DETAILS, policer_details) \
4144 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4145 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4146 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4147 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4148 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4149 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4150 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4151 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4152 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4153 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4154 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4155 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4156 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4157 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4158 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4159 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4160 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4161 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4162 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4163 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4164 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4165 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4166 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4167 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4168 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4169 ip_source_and_port_range_check_add_del_reply) \
4170 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4171 ip_source_and_port_range_check_interface_add_del_reply) \
4172 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4173 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4174 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4175 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4176 _(PUNT_REPLY, punt_reply) \
4177 _(IP_FIB_DETAILS, ip_fib_details) \
4178 _(IP6_FIB_DETAILS, ip6_fib_details) \
4179 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4180 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4181 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4182 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4183 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4184 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4187 #define foreach_vpe_dpdk_api_reply_msg \
4188 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4189 sw_interface_set_dpdk_hqos_pipe_reply) \
4190 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4191 sw_interface_set_dpdk_hqos_subport_reply) \
4192 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4193 sw_interface_set_dpdk_hqos_tctbl_reply)
4203 #define STR_VTR_OP_CASE(op) \
4204 case L2_VTR_ ## op: \
4208 str_vtr_op (u32 vtr_op)
4212 STR_VTR_OP_CASE (DISABLED);
4213 STR_VTR_OP_CASE (PUSH_1);
4214 STR_VTR_OP_CASE (PUSH_2);
4215 STR_VTR_OP_CASE (POP_1);
4216 STR_VTR_OP_CASE (POP_2);
4217 STR_VTR_OP_CASE (TRANSLATE_1_1);
4218 STR_VTR_OP_CASE (TRANSLATE_1_2);
4219 STR_VTR_OP_CASE (TRANSLATE_2_1);
4220 STR_VTR_OP_CASE (TRANSLATE_2_2);
4227 dump_sub_interface_table (vat_main_t * vam)
4229 const sw_interface_subif_t *sub = NULL;
4231 if (vam->json_output)
4234 ("JSON output supported only for VPE API calls and dump_stats_table");
4239 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4240 "Interface", "sw_if_index",
4241 "sub id", "dot1ad", "tags", "outer id",
4242 "inner id", "exact", "default", "outer any", "inner any");
4244 vec_foreach (sub, vam->sw_if_subif_table)
4247 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4248 sub->interface_name,
4250 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4251 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4252 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4253 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4254 if (sub->vtr_op != L2_VTR_DISABLED)
4257 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4258 "tag1: %d tag2: %d ]",
4259 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4260 sub->vtr_tag1, sub->vtr_tag2);
4268 name_sort_cmp (void *a1, void *a2)
4270 name_sort_t *n1 = a1;
4271 name_sort_t *n2 = a2;
4273 return strcmp ((char *) n1->name, (char *) n2->name);
4277 dump_interface_table (vat_main_t * vam)
4280 name_sort_t *nses = 0, *ns;
4282 if (vam->json_output)
4285 ("JSON output supported only for VPE API calls and dump_stats_table");
4290 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4292 vec_add2 (nses, ns, 1);
4293 ns->name = (u8 *)(p->key);
4294 ns->value = (u32) p->value[0];
4298 vec_sort_with_function (nses, name_sort_cmp);
4300 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4301 vec_foreach (ns, nses)
4303 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4310 dump_ip_table (vat_main_t * vam, int is_ipv6)
4312 const ip_details_t *det = NULL;
4313 const ip_address_details_t *address = NULL;
4316 print (vam->ofp, "%-12s", "sw_if_index");
4318 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4325 print (vam->ofp, "%-12d", i);
4326 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4331 vec_foreach (address, det->addr)
4335 is_ipv6 ? format_ip6_address : format_ip4_address,
4336 address->ip, address->prefix_length);
4344 dump_ipv4_table (vat_main_t * vam)
4346 if (vam->json_output)
4349 ("JSON output supported only for VPE API calls and dump_stats_table");
4353 return dump_ip_table (vam, 0);
4357 dump_ipv6_table (vat_main_t * vam)
4359 if (vam->json_output)
4362 ("JSON output supported only for VPE API calls and dump_stats_table");
4366 return dump_ip_table (vam, 1);
4370 counter_type_to_str (u8 counter_type, u8 is_combined)
4374 switch (counter_type)
4376 case VNET_INTERFACE_COUNTER_DROP:
4378 case VNET_INTERFACE_COUNTER_PUNT:
4380 case VNET_INTERFACE_COUNTER_IP4:
4382 case VNET_INTERFACE_COUNTER_IP6:
4384 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4386 case VNET_INTERFACE_COUNTER_RX_MISS:
4388 case VNET_INTERFACE_COUNTER_RX_ERROR:
4390 case VNET_INTERFACE_COUNTER_TX_ERROR:
4393 return "INVALID-COUNTER-TYPE";
4398 switch (counter_type)
4400 case VNET_INTERFACE_COUNTER_RX:
4402 case VNET_INTERFACE_COUNTER_TX:
4405 return "INVALID-COUNTER-TYPE";
4411 dump_stats_table (vat_main_t * vam)
4413 vat_json_node_t node;
4414 vat_json_node_t *msg_array;
4415 vat_json_node_t *msg;
4416 vat_json_node_t *counter_array;
4417 vat_json_node_t *counter;
4418 interface_counter_t c;
4420 ip4_fib_counter_t *c4;
4421 ip6_fib_counter_t *c6;
4422 ip4_nbr_counter_t *n4;
4423 ip6_nbr_counter_t *n6;
4426 if (!vam->json_output)
4428 clib_warning ("dump_stats_table supported only in JSON format");
4432 vat_json_init_object (&node);
4434 /* interface counters */
4435 msg_array = vat_json_object_add (&node, "interface_counters");
4436 vat_json_init_array (msg_array);
4437 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4439 msg = vat_json_array_add (msg_array);
4440 vat_json_init_object (msg);
4441 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4442 (u8 *) counter_type_to_str (i, 0));
4443 vat_json_object_add_int (msg, "is_combined", 0);
4444 counter_array = vat_json_object_add (msg, "data");
4445 vat_json_init_array (counter_array);
4446 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4448 packets = vam->simple_interface_counters[i][j];
4449 vat_json_array_add_uint (counter_array, packets);
4452 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4454 msg = vat_json_array_add (msg_array);
4455 vat_json_init_object (msg);
4456 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4457 (u8 *) counter_type_to_str (i, 1));
4458 vat_json_object_add_int (msg, "is_combined", 1);
4459 counter_array = vat_json_object_add (msg, "data");
4460 vat_json_init_array (counter_array);
4461 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4463 c = vam->combined_interface_counters[i][j];
4464 counter = vat_json_array_add (counter_array);
4465 vat_json_init_object (counter);
4466 vat_json_object_add_uint (counter, "packets", c.packets);
4467 vat_json_object_add_uint (counter, "bytes", c.bytes);
4471 /* ip4 fib counters */
4472 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4473 vat_json_init_array (msg_array);
4474 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4476 msg = vat_json_array_add (msg_array);
4477 vat_json_init_object (msg);
4478 vat_json_object_add_uint (msg, "vrf_id",
4479 vam->ip4_fib_counters_vrf_id_by_index[i]);
4480 counter_array = vat_json_object_add (msg, "c");
4481 vat_json_init_array (counter_array);
4482 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4484 counter = vat_json_array_add (counter_array);
4485 vat_json_init_object (counter);
4486 c4 = &vam->ip4_fib_counters[i][j];
4487 vat_json_object_add_ip4 (counter, "address", c4->address);
4488 vat_json_object_add_uint (counter, "address_length",
4489 c4->address_length);
4490 vat_json_object_add_uint (counter, "packets", c4->packets);
4491 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4495 /* ip6 fib counters */
4496 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4497 vat_json_init_array (msg_array);
4498 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4500 msg = vat_json_array_add (msg_array);
4501 vat_json_init_object (msg);
4502 vat_json_object_add_uint (msg, "vrf_id",
4503 vam->ip6_fib_counters_vrf_id_by_index[i]);
4504 counter_array = vat_json_object_add (msg, "c");
4505 vat_json_init_array (counter_array);
4506 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4508 counter = vat_json_array_add (counter_array);
4509 vat_json_init_object (counter);
4510 c6 = &vam->ip6_fib_counters[i][j];
4511 vat_json_object_add_ip6 (counter, "address", c6->address);
4512 vat_json_object_add_uint (counter, "address_length",
4513 c6->address_length);
4514 vat_json_object_add_uint (counter, "packets", c6->packets);
4515 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4519 /* ip4 nbr counters */
4520 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4521 vat_json_init_array (msg_array);
4522 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4524 msg = vat_json_array_add (msg_array);
4525 vat_json_init_object (msg);
4526 vat_json_object_add_uint (msg, "sw_if_index", i);
4527 counter_array = vat_json_object_add (msg, "c");
4528 vat_json_init_array (counter_array);
4529 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4531 counter = vat_json_array_add (counter_array);
4532 vat_json_init_object (counter);
4533 n4 = &vam->ip4_nbr_counters[i][j];
4534 vat_json_object_add_ip4 (counter, "address", n4->address);
4535 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4536 vat_json_object_add_uint (counter, "packets", n4->packets);
4537 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4541 /* ip6 nbr counters */
4542 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4543 vat_json_init_array (msg_array);
4544 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4546 msg = vat_json_array_add (msg_array);
4547 vat_json_init_object (msg);
4548 vat_json_object_add_uint (msg, "sw_if_index", i);
4549 counter_array = vat_json_object_add (msg, "c");
4550 vat_json_init_array (counter_array);
4551 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4553 counter = vat_json_array_add (counter_array);
4554 vat_json_init_object (counter);
4555 n6 = &vam->ip6_nbr_counters[i][j];
4556 vat_json_object_add_ip6 (counter, "address", n6->address);
4557 vat_json_object_add_uint (counter, "packets", n6->packets);
4558 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4562 vat_json_print (vam->ofp, &node);
4563 vat_json_free (&node);
4569 exec (vat_main_t * vam)
4571 api_main_t *am = &api_main;
4572 vl_api_cli_request_t *mp;
4576 unformat_input_t *i = vam->input;
4578 if (vec_len (i->buffer) == 0)
4581 if (vam->exec_mode == 0 && unformat (i, "mode"))
4586 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4593 M (CLI_REQUEST, mp);
4596 * Copy cmd into shared memory.
4597 * In order for the CLI command to work, it
4598 * must be a vector ending in \n, not a C-string ending
4601 pthread_mutex_lock (&am->vlib_rp->mutex);
4602 oldheap = svm_push_data_heap (am->vlib_rp);
4604 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4605 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4607 svm_pop_heap (oldheap);
4608 pthread_mutex_unlock (&am->vlib_rp->mutex);
4610 mp->cmd_in_shmem = (u64) cmd;
4612 timeout = vat_time_now (vam) + 10.0;
4614 while (vat_time_now (vam) < timeout)
4616 if (vam->result_ready == 1)
4619 if (vam->shmem_result != NULL)
4620 print (vam->ofp, "%s", vam->shmem_result);
4621 pthread_mutex_lock (&am->vlib_rp->mutex);
4622 oldheap = svm_push_data_heap (am->vlib_rp);
4624 free_me = (u8 *) vam->shmem_result;
4627 svm_pop_heap (oldheap);
4628 pthread_mutex_unlock (&am->vlib_rp->mutex);
4636 * Future replacement of exec() that passes CLI buffers directly in
4637 * the API messages instead of an additional shared memory area.
4640 exec_inband (vat_main_t * vam)
4642 vl_api_cli_inband_t *mp;
4644 unformat_input_t *i = vam->input;
4646 if (vec_len (i->buffer) == 0)
4649 if (vam->exec_mode == 0 && unformat (i, "mode"))
4654 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4661 * In order for the CLI command to work, it
4662 * must be a vector ending in \n, not a C-string ending
4665 u32 len = vec_len (vam->input->buffer);
4666 M2 (CLI_INBAND, mp, len);
4667 clib_memcpy (mp->cmd, vam->input->buffer, len);
4668 mp->length = htonl (len);
4671 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4675 api_create_loopback (vat_main_t * vam)
4677 unformat_input_t *i = vam->input;
4678 vl_api_create_loopback_t *mp;
4683 memset (mac_address, 0, sizeof (mac_address));
4685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4687 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4693 /* Construct the API message */
4694 M (CREATE_LOOPBACK, mp);
4696 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4703 api_delete_loopback (vat_main_t * vam)
4705 unformat_input_t *i = vam->input;
4706 vl_api_delete_loopback_t *mp;
4708 u32 sw_if_index = ~0;
4710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4712 if (unformat (i, "sw_if_index %d", &sw_if_index))
4718 if (sw_if_index == ~0)
4720 errmsg ("missing sw_if_index");
4724 /* Construct the API message */
4725 M (DELETE_LOOPBACK, mp);
4726 mp->sw_if_index = ntohl (sw_if_index);
4733 api_want_stats (vat_main_t * vam)
4735 unformat_input_t *i = vam->input;
4736 vl_api_want_stats_t *mp;
4740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4742 if (unformat (i, "enable"))
4744 else if (unformat (i, "disable"))
4752 errmsg ("missing enable|disable");
4757 mp->enable_disable = enable;
4764 api_want_interface_events (vat_main_t * vam)
4766 unformat_input_t *i = vam->input;
4767 vl_api_want_interface_events_t *mp;
4771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4773 if (unformat (i, "enable"))
4775 else if (unformat (i, "disable"))
4783 errmsg ("missing enable|disable");
4787 M (WANT_INTERFACE_EVENTS, mp);
4788 mp->enable_disable = enable;
4790 vam->interface_event_display = enable;
4797 /* Note: non-static, called once to set up the initial intfc table */
4799 api_sw_interface_dump (vat_main_t * vam)
4801 vl_api_sw_interface_dump_t *mp;
4804 name_sort_t *nses = 0, *ns;
4805 sw_interface_subif_t *sub = NULL;
4807 /* Toss the old name table */
4809 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4811 vec_add2 (nses, ns, 1);
4812 ns->name = (u8 *)(p->key);
4813 ns->value = (u32) p->value[0];
4817 hash_free (vam->sw_if_index_by_interface_name);
4819 vec_foreach (ns, nses) vec_free (ns->name);
4823 vec_foreach (sub, vam->sw_if_subif_table)
4825 vec_free (sub->interface_name);
4827 vec_free (vam->sw_if_subif_table);
4829 /* recreate the interface name hash table */
4830 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4832 /* Get list of ethernets */
4833 M (SW_INTERFACE_DUMP, mp);
4834 mp->name_filter_valid = 1;
4835 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4838 /* and local / loopback interfaces */
4839 M (SW_INTERFACE_DUMP, mp);
4840 mp->name_filter_valid = 1;
4841 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4844 /* and packet-generator interfaces */
4845 M (SW_INTERFACE_DUMP, mp);
4846 mp->name_filter_valid = 1;
4847 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4850 /* and vxlan-gpe tunnel interfaces */
4851 M (SW_INTERFACE_DUMP, mp);
4852 mp->name_filter_valid = 1;
4853 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4854 sizeof (mp->name_filter) - 1);
4857 /* and vxlan tunnel interfaces */
4858 M (SW_INTERFACE_DUMP, mp);
4859 mp->name_filter_valid = 1;
4860 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4863 /* and host (af_packet) interfaces */
4864 M (SW_INTERFACE_DUMP, mp);
4865 mp->name_filter_valid = 1;
4866 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4869 /* and l2tpv3 tunnel interfaces */
4870 M (SW_INTERFACE_DUMP, mp);
4871 mp->name_filter_valid = 1;
4872 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4873 sizeof (mp->name_filter) - 1);
4876 /* and GRE tunnel interfaces */
4877 M (SW_INTERFACE_DUMP, mp);
4878 mp->name_filter_valid = 1;
4879 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4882 /* and LISP-GPE interfaces */
4883 M (SW_INTERFACE_DUMP, mp);
4884 mp->name_filter_valid = 1;
4885 strncpy ((char *) mp->name_filter, "lisp_gpe",
4886 sizeof (mp->name_filter) - 1);
4889 /* and IPSEC tunnel interfaces */
4890 M (SW_INTERFACE_DUMP, mp);
4891 mp->name_filter_valid = 1;
4892 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4895 /* Use a control ping for synchronization */
4897 vl_api_control_ping_t *mp;
4898 M (CONTROL_PING, mp);
4905 api_sw_interface_set_flags (vat_main_t * vam)
4907 unformat_input_t *i = vam->input;
4908 vl_api_sw_interface_set_flags_t *mp;
4911 u8 sw_if_index_set = 0;
4912 u8 admin_up = 0, link_up = 0;
4914 /* Parse args required to build the message */
4915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4917 if (unformat (i, "admin-up"))
4919 else if (unformat (i, "admin-down"))
4921 else if (unformat (i, "link-up"))
4923 else if (unformat (i, "link-down"))
4926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4927 sw_if_index_set = 1;
4928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4929 sw_if_index_set = 1;
4934 if (sw_if_index_set == 0)
4936 errmsg ("missing interface name or sw_if_index");
4940 /* Construct the API message */
4941 M (SW_INTERFACE_SET_FLAGS, mp);
4942 mp->sw_if_index = ntohl (sw_if_index);
4943 mp->admin_up_down = admin_up;
4944 mp->link_up_down = link_up;
4949 /* Wait for a reply, return the good/bad news... */
4954 api_sw_interface_clear_stats (vat_main_t * vam)
4956 unformat_input_t *i = vam->input;
4957 vl_api_sw_interface_clear_stats_t *mp;
4960 u8 sw_if_index_set = 0;
4962 /* Parse args required to build the message */
4963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4966 sw_if_index_set = 1;
4967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4968 sw_if_index_set = 1;
4973 /* Construct the API message */
4974 M (SW_INTERFACE_CLEAR_STATS, mp);
4976 if (sw_if_index_set == 1)
4977 mp->sw_if_index = ntohl (sw_if_index);
4979 mp->sw_if_index = ~0;
4984 /* Wait for a reply, return the good/bad news... */
4990 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4992 unformat_input_t *i = vam->input;
4993 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4996 u8 sw_if_index_set = 0;
5004 /* Parse args required to build the message */
5005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5007 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5008 sw_if_index_set = 1;
5009 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5010 sw_if_index_set = 1;
5011 else if (unformat (i, "subport %u", &subport))
5014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5015 sw_if_index_set = 1;
5016 else if (unformat (i, "pipe %u", &pipe))
5018 else if (unformat (i, "profile %u", &profile))
5024 if (sw_if_index_set == 0)
5026 errmsg ("missing interface name or sw_if_index");
5030 if (subport_set == 0)
5032 errmsg ("missing subport ");
5038 errmsg ("missing pipe");
5042 if (profile_set == 0)
5044 errmsg ("missing profile");
5048 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
5050 mp->sw_if_index = ntohl (sw_if_index);
5051 mp->subport = ntohl (subport);
5052 mp->pipe = ntohl (pipe);
5053 mp->profile = ntohl (profile);
5063 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
5065 unformat_input_t *i = vam->input;
5066 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
5069 u8 sw_if_index_set = 0;
5072 u32 tb_rate = 1250000000; /* 10GbE */
5073 u32 tb_size = 1000000;
5074 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
5077 /* Parse args required to build the message */
5078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5080 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5081 sw_if_index_set = 1;
5082 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5083 sw_if_index_set = 1;
5084 else if (unformat (i, "subport %u", &subport))
5087 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5088 sw_if_index_set = 1;
5089 else if (unformat (i, "rate %u", &tb_rate))
5093 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
5095 tc_rate[tc_id] = tb_rate;
5097 else if (unformat (i, "bktsize %u", &tb_size))
5099 else if (unformat (i, "tc0 %u", &tc_rate[0]))
5101 else if (unformat (i, "tc1 %u", &tc_rate[1]))
5103 else if (unformat (i, "tc2 %u", &tc_rate[2]))
5105 else if (unformat (i, "tc3 %u", &tc_rate[3]))
5107 else if (unformat (i, "period %u", &tc_period))
5113 if (sw_if_index_set == 0)
5115 errmsg ("missing interface name or sw_if_index");
5119 if (subport_set == 0)
5121 errmsg ("missing subport ");
5125 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
5127 mp->sw_if_index = ntohl (sw_if_index);
5128 mp->subport = ntohl (subport);
5129 mp->tb_rate = ntohl (tb_rate);
5130 mp->tb_size = ntohl (tb_size);
5131 mp->tc_rate[0] = ntohl (tc_rate[0]);
5132 mp->tc_rate[1] = ntohl (tc_rate[1]);
5133 mp->tc_rate[2] = ntohl (tc_rate[2]);
5134 mp->tc_rate[3] = ntohl (tc_rate[3]);
5135 mp->tc_period = ntohl (tc_period);
5144 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
5146 unformat_input_t *i = vam->input;
5147 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
5150 u8 sw_if_index_set = 0;
5154 u32 entry, tc, queue;
5156 /* Parse args required to build the message */
5157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5159 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5160 sw_if_index_set = 1;
5161 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5162 sw_if_index_set = 1;
5163 else if (unformat (i, "entry %d", &entry))
5165 else if (unformat (i, "tc %d", &tc))
5167 else if (unformat (i, "queue %d", &queue))
5173 if (sw_if_index_set == 0)
5175 errmsg ("missing interface name or sw_if_index");
5181 errmsg ("missing entry ");
5187 errmsg ("missing traffic class ");
5193 errmsg ("missing queue ");
5197 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
5199 mp->sw_if_index = ntohl (sw_if_index);
5200 mp->entry = ntohl (entry);
5201 mp->tc = ntohl (tc);
5202 mp->queue = ntohl (queue);
5212 api_sw_interface_add_del_address (vat_main_t * vam)
5214 unformat_input_t *i = vam->input;
5215 vl_api_sw_interface_add_del_address_t *mp;
5218 u8 sw_if_index_set = 0;
5219 u8 is_add = 1, del_all = 0;
5220 u32 address_length = 0;
5221 u8 v4_address_set = 0;
5222 u8 v6_address_set = 0;
5223 ip4_address_t v4address;
5224 ip6_address_t v6address;
5226 /* Parse args required to build the message */
5227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5229 if (unformat (i, "del-all"))
5231 else if (unformat (i, "del"))
5234 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5235 sw_if_index_set = 1;
5236 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5237 sw_if_index_set = 1;
5238 else if (unformat (i, "%U/%d",
5239 unformat_ip4_address, &v4address, &address_length))
5241 else if (unformat (i, "%U/%d",
5242 unformat_ip6_address, &v6address, &address_length))
5248 if (sw_if_index_set == 0)
5250 errmsg ("missing interface name or sw_if_index");
5253 if (v4_address_set && v6_address_set)
5255 errmsg ("both v4 and v6 addresses set");
5258 if (!v4_address_set && !v6_address_set && !del_all)
5260 errmsg ("no addresses set");
5264 /* Construct the API message */
5265 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5267 mp->sw_if_index = ntohl (sw_if_index);
5268 mp->is_add = is_add;
5269 mp->del_all = del_all;
5273 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5277 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5279 mp->address_length = address_length;
5284 /* Wait for a reply, return good/bad news */
5289 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5291 unformat_input_t *i = vam->input;
5292 vl_api_sw_interface_set_mpls_enable_t *mp;
5295 u8 sw_if_index_set = 0;
5298 /* Parse args required to build the message */
5299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5302 sw_if_index_set = 1;
5303 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5304 sw_if_index_set = 1;
5305 else if (unformat (i, "disable"))
5307 else if (unformat (i, "dis"))
5313 if (sw_if_index_set == 0)
5315 errmsg ("missing interface name or sw_if_index");
5319 /* Construct the API message */
5320 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5322 mp->sw_if_index = ntohl (sw_if_index);
5323 mp->enable = enable;
5328 /* Wait for a reply... */
5333 api_sw_interface_set_table (vat_main_t * vam)
5335 unformat_input_t *i = vam->input;
5336 vl_api_sw_interface_set_table_t *mp;
5338 u32 sw_if_index, vrf_id = 0;
5339 u8 sw_if_index_set = 0;
5342 /* Parse args required to build the message */
5343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5345 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5346 sw_if_index_set = 1;
5347 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5348 sw_if_index_set = 1;
5349 else if (unformat (i, "vrf %d", &vrf_id))
5351 else if (unformat (i, "ipv6"))
5357 if (sw_if_index_set == 0)
5359 errmsg ("missing interface name or sw_if_index");
5363 /* Construct the API message */
5364 M (SW_INTERFACE_SET_TABLE, mp);
5366 mp->sw_if_index = ntohl (sw_if_index);
5367 mp->is_ipv6 = is_ipv6;
5368 mp->vrf_id = ntohl (vrf_id);
5373 /* Wait for a reply... */
5377 static void vl_api_sw_interface_get_table_reply_t_handler
5378 (vl_api_sw_interface_get_table_reply_t * mp)
5380 vat_main_t *vam = &vat_main;
5382 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5384 vam->retval = ntohl (mp->retval);
5385 vam->result_ready = 1;
5389 static void vl_api_sw_interface_get_table_reply_t_handler_json
5390 (vl_api_sw_interface_get_table_reply_t * mp)
5392 vat_main_t *vam = &vat_main;
5393 vat_json_node_t node;
5395 vat_json_init_object (&node);
5396 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5397 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5399 vat_json_print (vam->ofp, &node);
5400 vat_json_free (&node);
5402 vam->retval = ntohl (mp->retval);
5403 vam->result_ready = 1;
5407 api_sw_interface_get_table (vat_main_t * vam)
5409 unformat_input_t *i = vam->input;
5410 vl_api_sw_interface_get_table_t *mp;
5412 u8 sw_if_index_set = 0;
5416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5418 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5419 sw_if_index_set = 1;
5420 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5421 sw_if_index_set = 1;
5422 else if (unformat (i, "ipv6"))
5428 if (sw_if_index_set == 0)
5430 errmsg ("missing interface name or sw_if_index");
5434 M (SW_INTERFACE_GET_TABLE, mp);
5435 mp->sw_if_index = htonl (sw_if_index);
5436 mp->is_ipv6 = is_ipv6;
5443 api_sw_interface_set_vpath (vat_main_t * vam)
5445 unformat_input_t *i = vam->input;
5446 vl_api_sw_interface_set_vpath_t *mp;
5448 u32 sw_if_index = 0;
5449 u8 sw_if_index_set = 0;
5452 /* Parse args required to build the message */
5453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5455 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5456 sw_if_index_set = 1;
5457 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5458 sw_if_index_set = 1;
5459 else if (unformat (i, "enable"))
5461 else if (unformat (i, "disable"))
5467 if (sw_if_index_set == 0)
5469 errmsg ("missing interface name or sw_if_index");
5473 /* Construct the API message */
5474 M (SW_INTERFACE_SET_VPATH, mp);
5476 mp->sw_if_index = ntohl (sw_if_index);
5477 mp->enable = is_enable;
5482 /* Wait for a reply... */
5487 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5489 unformat_input_t *i = vam->input;
5490 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5492 u32 sw_if_index = 0;
5493 u8 sw_if_index_set = 0;
5497 /* Parse args required to build the message */
5498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5501 sw_if_index_set = 1;
5502 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5503 sw_if_index_set = 1;
5504 else if (unformat (i, "enable"))
5506 else if (unformat (i, "disable"))
5508 else if (unformat (i, "ip4"))
5510 else if (unformat (i, "ip6"))
5516 if (sw_if_index_set == 0)
5518 errmsg ("missing interface name or sw_if_index");
5522 /* Construct the API message */
5523 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5525 mp->sw_if_index = ntohl (sw_if_index);
5526 mp->enable = is_enable;
5527 mp->is_ipv6 = is_ipv6;
5532 /* Wait for a reply... */
5537 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5539 unformat_input_t *i = vam->input;
5540 vl_api_sw_interface_set_l2_xconnect_t *mp;
5543 u8 rx_sw_if_index_set = 0;
5545 u8 tx_sw_if_index_set = 0;
5548 /* Parse args required to build the message */
5549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5551 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5552 rx_sw_if_index_set = 1;
5553 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5554 tx_sw_if_index_set = 1;
5555 else if (unformat (i, "rx"))
5557 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5559 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5561 rx_sw_if_index_set = 1;
5566 else if (unformat (i, "tx"))
5568 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5570 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5572 tx_sw_if_index_set = 1;
5577 else if (unformat (i, "enable"))
5579 else if (unformat (i, "disable"))
5585 if (rx_sw_if_index_set == 0)
5587 errmsg ("missing rx interface name or rx_sw_if_index");
5591 if (enable && (tx_sw_if_index_set == 0))
5593 errmsg ("missing tx interface name or tx_sw_if_index");
5597 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5599 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5600 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5601 mp->enable = enable;
5610 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5612 unformat_input_t *i = vam->input;
5613 vl_api_sw_interface_set_l2_bridge_t *mp;
5616 u8 rx_sw_if_index_set = 0;
5623 /* Parse args required to build the message */
5624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5626 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5627 rx_sw_if_index_set = 1;
5628 else if (unformat (i, "bd_id %d", &bd_id))
5632 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5633 rx_sw_if_index_set = 1;
5634 else if (unformat (i, "shg %d", &shg))
5636 else if (unformat (i, "bvi"))
5638 else if (unformat (i, "enable"))
5640 else if (unformat (i, "disable"))
5646 if (rx_sw_if_index_set == 0)
5648 errmsg ("missing rx interface name or sw_if_index");
5652 if (enable && (bd_id_set == 0))
5654 errmsg ("missing bridge domain");
5658 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5660 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5661 mp->bd_id = ntohl (bd_id);
5664 mp->enable = enable;
5673 api_bridge_domain_dump (vat_main_t * vam)
5675 unformat_input_t *i = vam->input;
5676 vl_api_bridge_domain_dump_t *mp;
5680 /* Parse args required to build the message */
5681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5683 if (unformat (i, "bd_id %d", &bd_id))
5689 M (BRIDGE_DOMAIN_DUMP, mp);
5690 mp->bd_id = ntohl (bd_id);
5693 /* Use a control ping for synchronization */
5695 vl_api_control_ping_t *mp;
5696 M (CONTROL_PING, mp);
5706 api_bridge_domain_add_del (vat_main_t * vam)
5708 unformat_input_t *i = vam->input;
5709 vl_api_bridge_domain_add_del_t *mp;
5713 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5716 /* Parse args required to build the message */
5717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5719 if (unformat (i, "bd_id %d", &bd_id))
5721 else if (unformat (i, "flood %d", &flood))
5723 else if (unformat (i, "uu-flood %d", &uu_flood))
5725 else if (unformat (i, "forward %d", &forward))
5727 else if (unformat (i, "learn %d", &learn))
5729 else if (unformat (i, "arp-term %d", &arp_term))
5731 else if (unformat (i, "mac-age %d", &mac_age))
5733 else if (unformat (i, "del"))
5736 flood = uu_flood = forward = learn = 0;
5744 errmsg ("missing bridge domain");
5750 errmsg ("mac age must be less than 256 ");
5754 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5756 mp->bd_id = ntohl (bd_id);
5758 mp->uu_flood = uu_flood;
5759 mp->forward = forward;
5761 mp->arp_term = arp_term;
5762 mp->is_add = is_add;
5763 mp->mac_age = (u8) mac_age;
5772 api_l2fib_add_del (vat_main_t * vam)
5774 unformat_input_t *i = vam->input;
5775 vl_api_l2fib_add_del_t *mp;
5781 u32 sw_if_index = ~0;
5782 u8 sw_if_index_set = 0;
5791 /* Parse args required to build the message */
5792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5794 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5796 else if (unformat (i, "bd_id %d", &bd_id))
5798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5799 sw_if_index_set = 1;
5800 else if (unformat (i, "sw_if"))
5802 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5805 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5806 sw_if_index_set = 1;
5811 else if (unformat (i, "static"))
5813 else if (unformat (i, "filter"))
5818 else if (unformat (i, "bvi"))
5823 else if (unformat (i, "del"))
5825 else if (unformat (i, "count %d", &count))
5833 errmsg ("missing mac address");
5839 errmsg ("missing bridge domain");
5843 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5845 errmsg ("missing interface name or sw_if_index");
5851 /* Turn on async mode */
5852 vam->async_mode = 1;
5853 vam->async_errors = 0;
5854 before = vat_time_now (vam);
5857 for (j = 0; j < count; j++)
5859 M (L2FIB_ADD_DEL, mp);
5862 mp->bd_id = ntohl (bd_id);
5863 mp->is_add = is_add;
5867 mp->sw_if_index = ntohl (sw_if_index);
5868 mp->static_mac = static_mac;
5869 mp->filter_mac = filter_mac;
5870 mp->bvi_mac = bvi_mac;
5872 increment_mac_address (&mac);
5879 vl_api_control_ping_t *mp;
5882 /* Shut off async mode */
5883 vam->async_mode = 0;
5885 M (CONTROL_PING, mp);
5888 timeout = vat_time_now (vam) + 1.0;
5889 while (vat_time_now (vam) < timeout)
5890 if (vam->result_ready == 1)
5895 if (vam->retval == -99)
5898 if (vam->async_errors > 0)
5900 errmsg ("%d asynchronous errors", vam->async_errors);
5903 vam->async_errors = 0;
5904 after = vat_time_now (vam);
5906 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5907 count, after - before, count / (after - before));
5911 /* Wait for a reply... */
5914 /* Return the good/bad news */
5915 return (vam->retval);
5919 api_l2_flags (vat_main_t * vam)
5921 unformat_input_t *i = vam->input;
5922 vl_api_l2_flags_t *mp;
5925 u32 feature_bitmap = 0;
5926 u8 sw_if_index_set = 0;
5928 /* Parse args required to build the message */
5929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5931 if (unformat (i, "sw_if_index %d", &sw_if_index))
5932 sw_if_index_set = 1;
5933 else if (unformat (i, "sw_if"))
5935 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5938 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5939 sw_if_index_set = 1;
5944 else if (unformat (i, "learn"))
5945 feature_bitmap |= L2INPUT_FEAT_LEARN;
5946 else if (unformat (i, "forward"))
5947 feature_bitmap |= L2INPUT_FEAT_FWD;
5948 else if (unformat (i, "flood"))
5949 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5950 else if (unformat (i, "uu-flood"))
5951 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5956 if (sw_if_index_set == 0)
5958 errmsg ("missing interface name or sw_if_index");
5964 mp->sw_if_index = ntohl (sw_if_index);
5965 mp->feature_bitmap = ntohl (feature_bitmap);
5974 api_bridge_flags (vat_main_t * vam)
5976 unformat_input_t *i = vam->input;
5977 vl_api_bridge_flags_t *mp;
5984 /* Parse args required to build the message */
5985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5987 if (unformat (i, "bd_id %d", &bd_id))
5989 else if (unformat (i, "learn"))
5991 else if (unformat (i, "forward"))
5993 else if (unformat (i, "flood"))
5995 else if (unformat (i, "uu-flood"))
5996 flags |= L2_UU_FLOOD;
5997 else if (unformat (i, "arp-term"))
5998 flags |= L2_ARP_TERM;
5999 else if (unformat (i, "off"))
6001 else if (unformat (i, "disable"))
6009 errmsg ("missing bridge domain");
6013 M (BRIDGE_FLAGS, mp);
6015 mp->bd_id = ntohl (bd_id);
6016 mp->feature_bitmap = ntohl (flags);
6017 mp->is_set = is_set;
6026 api_bd_ip_mac_add_del (vat_main_t * vam)
6028 unformat_input_t *i = vam->input;
6029 vl_api_bd_ip_mac_add_del_t *mp;
6037 ip4_address_t v4addr;
6038 ip6_address_t v6addr;
6042 /* Parse args required to build the message */
6043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6045 if (unformat (i, "bd_id %d", &bd_id))
6049 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6053 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6058 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6062 else if (unformat (i, "del"))
6070 errmsg ("missing bridge domain");
6073 else if (ip_set == 0)
6075 errmsg ("missing IP address");
6078 else if (mac_set == 0)
6080 errmsg ("missing MAC address");
6084 M (BD_IP_MAC_ADD_DEL, mp);
6086 mp->bd_id = ntohl (bd_id);
6087 mp->is_ipv6 = is_ipv6;
6088 mp->is_add = is_add;
6090 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6092 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6093 clib_memcpy (mp->mac_address, macaddr, 6);
6101 api_tap_connect (vat_main_t * vam)
6103 unformat_input_t *i = vam->input;
6104 vl_api_tap_connect_t *mp;
6111 ip4_address_t ip4_address;
6113 int ip4_address_set = 0;
6114 ip6_address_t ip6_address;
6116 int ip6_address_set = 0;
6118 memset (mac_address, 0, sizeof (mac_address));
6120 /* Parse args required to build the message */
6121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6123 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6127 else if (unformat (i, "random-mac"))
6129 else if (unformat (i, "tapname %s", &tap_name))
6131 else if (unformat (i, "tag %s", &tag))
6133 else if (unformat (i, "address %U/%d",
6134 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6135 ip4_address_set = 1;
6136 else if (unformat (i, "address %U/%d",
6137 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6138 ip6_address_set = 1;
6145 errmsg ("missing tap name");
6148 if (vec_len (tap_name) > 63)
6150 errmsg ("tap name too long");
6153 vec_add1 (tap_name, 0);
6155 if (vec_len (tag) > 63)
6157 errmsg ("tag too long");
6161 /* Construct the API message */
6162 M (TAP_CONNECT, mp);
6164 mp->use_random_mac = random_mac;
6165 clib_memcpy (mp->mac_address, mac_address, 6);
6166 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6168 clib_memcpy (mp->tag, tag, vec_len (tag));
6170 if (ip4_address_set)
6172 mp->ip4_address_set = 1;
6173 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6174 mp->ip4_mask_width = ip4_mask_width;
6176 if (ip6_address_set)
6178 mp->ip6_address_set = 1;
6179 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6180 mp->ip6_mask_width = ip6_mask_width;
6183 vec_free (tap_name);
6189 /* Wait for a reply... */
6194 api_tap_modify (vat_main_t * vam)
6196 unformat_input_t *i = vam->input;
6197 vl_api_tap_modify_t *mp;
6203 u32 sw_if_index = ~0;
6204 u8 sw_if_index_set = 0;
6206 memset (mac_address, 0, sizeof (mac_address));
6208 /* Parse args required to build the message */
6209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6211 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6212 sw_if_index_set = 1;
6213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6214 sw_if_index_set = 1;
6215 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6219 else if (unformat (i, "random-mac"))
6221 else if (unformat (i, "tapname %s", &tap_name))
6227 if (sw_if_index_set == 0)
6229 errmsg ("missing vpp interface name");
6234 errmsg ("missing tap name");
6237 if (vec_len (tap_name) > 63)
6239 errmsg ("tap name too long");
6241 vec_add1 (tap_name, 0);
6243 /* Construct the API message */
6246 mp->use_random_mac = random_mac;
6247 mp->sw_if_index = ntohl (sw_if_index);
6248 clib_memcpy (mp->mac_address, mac_address, 6);
6249 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6250 vec_free (tap_name);
6255 /* Wait for a reply... */
6260 api_tap_delete (vat_main_t * vam)
6262 unformat_input_t *i = vam->input;
6263 vl_api_tap_delete_t *mp;
6265 u32 sw_if_index = ~0;
6266 u8 sw_if_index_set = 0;
6268 /* Parse args required to build the message */
6269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6272 sw_if_index_set = 1;
6273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6274 sw_if_index_set = 1;
6279 if (sw_if_index_set == 0)
6281 errmsg ("missing vpp interface name");
6285 /* Construct the API message */
6288 mp->sw_if_index = ntohl (sw_if_index);
6293 /* Wait for a reply... */
6298 api_ip_add_del_route (vat_main_t * vam)
6300 unformat_input_t *i = vam->input;
6301 vl_api_ip_add_del_route_t *mp;
6303 u32 sw_if_index = ~0, vrf_id = 0;
6305 u8 is_local = 0, is_drop = 0;
6306 u8 is_unreach = 0, is_prohibit = 0;
6307 u8 create_vrf_if_needed = 0;
6309 u32 next_hop_weight = 1;
6311 u8 is_multipath = 0;
6313 u8 address_length_set = 0;
6314 u32 next_hop_table_id = 0;
6315 u32 resolve_attempts = 0;
6316 u32 dst_address_length = 0;
6317 u8 next_hop_set = 0;
6318 ip4_address_t v4_dst_address, v4_next_hop_address;
6319 ip6_address_t v6_dst_address, v6_next_hop_address;
6323 u32 random_add_del = 0;
6324 u32 *random_vector = 0;
6326 u32 random_seed = 0xdeaddabe;
6327 u32 classify_table_index = ~0;
6329 u8 resolve_host = 0, resolve_attached = 0;
6330 mpls_label_t *next_hop_out_label_stack = NULL;
6331 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6332 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6334 /* Parse args required to build the message */
6335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6341 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6346 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6351 else if (unformat (i, "/%d", &dst_address_length))
6353 address_length_set = 1;
6356 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6357 &v4_next_hop_address))
6361 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6362 &v6_next_hop_address))
6366 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6368 else if (unformat (i, "weight %d", &next_hop_weight))
6370 else if (unformat (i, "drop"))
6374 else if (unformat (i, "null-send-unreach"))
6378 else if (unformat (i, "null-send-prohibit"))
6382 else if (unformat (i, "local"))
6386 else if (unformat (i, "classify %d", &classify_table_index))
6390 else if (unformat (i, "del"))
6392 else if (unformat (i, "add"))
6394 else if (unformat (i, "not-last"))
6396 else if (unformat (i, "resolve-via-host"))
6398 else if (unformat (i, "resolve-via-attached"))
6399 resolve_attached = 1;
6400 else if (unformat (i, "multipath"))
6402 else if (unformat (i, "vrf %d", &vrf_id))
6404 else if (unformat (i, "create-vrf"))
6405 create_vrf_if_needed = 1;
6406 else if (unformat (i, "count %d", &count))
6408 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6410 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6412 else if (unformat (i, "out-label %d", &next_hop_out_label))
6413 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6414 else if (unformat (i, "via-label %d", &next_hop_via_label))
6416 else if (unformat (i, "random"))
6418 else if (unformat (i, "seed %d", &random_seed))
6422 clib_warning ("parse error '%U'", format_unformat_error, i);
6427 if (!next_hop_set && !is_drop && !is_local &&
6428 !is_classify && !is_unreach && !is_prohibit &&
6429 MPLS_LABEL_INVALID == next_hop_via_label)
6432 ("next hop / local / drop / unreach / prohibit / classify not set");
6436 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6438 errmsg ("next hop and next-hop via label set");
6441 if (address_set == 0)
6443 errmsg ("missing addresses");
6447 if (address_length_set == 0)
6449 errmsg ("missing address length");
6453 /* Generate a pile of unique, random routes */
6456 u32 this_random_address;
6457 random_hash = hash_create (count, sizeof (uword));
6459 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6460 for (j = 0; j <= count; j++)
6464 this_random_address = random_u32 (&random_seed);
6465 this_random_address =
6466 clib_host_to_net_u32 (this_random_address);
6468 while (hash_get (random_hash, this_random_address));
6469 vec_add1 (random_vector, this_random_address);
6470 hash_set (random_hash, this_random_address, 1);
6472 hash_free (random_hash);
6473 v4_dst_address.as_u32 = random_vector[0];
6478 /* Turn on async mode */
6479 vam->async_mode = 1;
6480 vam->async_errors = 0;
6481 before = vat_time_now (vam);
6484 for (j = 0; j < count; j++)
6486 /* Construct the API message */
6487 M2 (IP_ADD_DEL_ROUTE, mp,
6488 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6490 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6491 mp->table_id = ntohl (vrf_id);
6492 mp->create_vrf_if_needed = create_vrf_if_needed;
6494 mp->is_add = is_add;
6495 mp->is_drop = is_drop;
6496 mp->is_unreach = is_unreach;
6497 mp->is_prohibit = is_prohibit;
6498 mp->is_ipv6 = is_ipv6;
6499 mp->is_local = is_local;
6500 mp->is_classify = is_classify;
6501 mp->is_multipath = is_multipath;
6502 mp->is_resolve_host = resolve_host;
6503 mp->is_resolve_attached = resolve_attached;
6504 mp->not_last = not_last;
6505 mp->next_hop_weight = next_hop_weight;
6506 mp->dst_address_length = dst_address_length;
6507 mp->next_hop_table_id = ntohl (next_hop_table_id);
6508 mp->classify_table_index = ntohl (classify_table_index);
6509 mp->next_hop_via_label = ntohl (next_hop_via_label);
6510 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6511 if (0 != mp->next_hop_n_out_labels)
6513 memcpy (mp->next_hop_out_label_stack,
6514 next_hop_out_label_stack,
6515 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6516 vec_free (next_hop_out_label_stack);
6521 clib_memcpy (mp->dst_address, &v6_dst_address,
6522 sizeof (v6_dst_address));
6524 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6525 sizeof (v6_next_hop_address));
6526 increment_v6_address (&v6_dst_address);
6530 clib_memcpy (mp->dst_address, &v4_dst_address,
6531 sizeof (v4_dst_address));
6533 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6534 sizeof (v4_next_hop_address));
6536 v4_dst_address.as_u32 = random_vector[j + 1];
6538 increment_v4_address (&v4_dst_address);
6542 /* If we receive SIGTERM, stop now... */
6547 /* When testing multiple add/del ops, use a control-ping to sync */
6550 vl_api_control_ping_t *mp;
6553 /* Shut off async mode */
6554 vam->async_mode = 0;
6556 M (CONTROL_PING, mp);
6559 timeout = vat_time_now (vam) + 1.0;
6560 while (vat_time_now (vam) < timeout)
6561 if (vam->result_ready == 1)
6566 if (vam->retval == -99)
6569 if (vam->async_errors > 0)
6571 errmsg ("%d asynchronous errors", vam->async_errors);
6574 vam->async_errors = 0;
6575 after = vat_time_now (vam);
6577 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6581 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6582 count, after - before, count / (after - before));
6586 /* Wait for a reply... */
6590 /* Return the good/bad news */
6591 return (vam->retval);
6595 api_ip_mroute_add_del (vat_main_t * vam)
6597 unformat_input_t *i = vam->input;
6598 vl_api_ip_mroute_add_del_t *mp;
6600 u32 sw_if_index = ~0, vrf_id = 0;
6603 u8 create_vrf_if_needed = 0;
6606 u32 grp_address_length = 0;
6607 ip4_address_t v4_grp_address, v4_src_address;
6608 ip6_address_t v6_grp_address, v6_src_address;
6609 mfib_itf_flags_t iflags = 0;
6610 mfib_entry_flags_t eflags = 0;
6612 /* Parse args required to build the message */
6613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6615 if (unformat (i, "sw_if_index %d", &sw_if_index))
6617 else if (unformat (i, "%U %U",
6618 unformat_ip4_address, &v4_src_address,
6619 unformat_ip4_address, &v4_grp_address))
6621 grp_address_length = 64;
6625 else if (unformat (i, "%U %U",
6626 unformat_ip6_address, &v6_src_address,
6627 unformat_ip6_address, &v6_grp_address))
6629 grp_address_length = 256;
6633 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6635 memset (&v4_src_address, 0, sizeof (v4_src_address));
6636 grp_address_length = 32;
6640 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6642 memset (&v6_src_address, 0, sizeof (v6_src_address));
6643 grp_address_length = 128;
6647 else if (unformat (i, "/%d", &grp_address_length))
6649 else if (unformat (i, "local"))
6653 else if (unformat (i, "del"))
6655 else if (unformat (i, "add"))
6657 else if (unformat (i, "vrf %d", &vrf_id))
6659 else if (unformat (i, "create-vrf"))
6660 create_vrf_if_needed = 1;
6661 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6663 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6667 clib_warning ("parse error '%U'", format_unformat_error, i);
6672 if (address_set == 0)
6674 errmsg ("missing addresses\n");
6678 /* Construct the API message */
6679 M (IP_MROUTE_ADD_DEL, mp);
6681 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6682 mp->table_id = ntohl (vrf_id);
6683 mp->create_vrf_if_needed = create_vrf_if_needed;
6685 mp->is_add = is_add;
6686 mp->is_ipv6 = is_ipv6;
6687 mp->is_local = is_local;
6688 mp->itf_flags = ntohl (iflags);
6689 mp->entry_flags = ntohl (eflags);
6690 mp->grp_address_length = grp_address_length;
6691 mp->grp_address_length = ntohs (mp->grp_address_length);
6695 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6696 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6700 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6701 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6707 /* Wait for a reply... */
6712 api_mpls_route_add_del (vat_main_t * vam)
6714 unformat_input_t *i = vam->input;
6715 vl_api_mpls_route_add_del_t *mp;
6717 u32 sw_if_index = ~0, table_id = 0;
6718 u8 create_table_if_needed = 0;
6720 u32 next_hop_weight = 1;
6721 u8 is_multipath = 0;
6722 u32 next_hop_table_id = 0;
6723 u8 next_hop_set = 0;
6724 ip4_address_t v4_next_hop_address = {
6727 ip6_address_t v6_next_hop_address = { {0} };
6731 u32 classify_table_index = ~0;
6733 u8 resolve_host = 0, resolve_attached = 0;
6734 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6735 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6736 mpls_label_t *next_hop_out_label_stack = NULL;
6737 mpls_label_t local_label = MPLS_LABEL_INVALID;
6739 u8 next_hop_proto_is_ip4 = 1;
6741 /* Parse args required to build the message */
6742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6748 else if (unformat (i, "%d", &local_label))
6750 else if (unformat (i, "eos"))
6752 else if (unformat (i, "non-eos"))
6754 else if (unformat (i, "via %U", unformat_ip4_address,
6755 &v4_next_hop_address))
6758 next_hop_proto_is_ip4 = 1;
6760 else if (unformat (i, "via %U", unformat_ip6_address,
6761 &v6_next_hop_address))
6764 next_hop_proto_is_ip4 = 0;
6766 else if (unformat (i, "weight %d", &next_hop_weight))
6768 else if (unformat (i, "create-table"))
6769 create_table_if_needed = 1;
6770 else if (unformat (i, "classify %d", &classify_table_index))
6774 else if (unformat (i, "del"))
6776 else if (unformat (i, "add"))
6778 else if (unformat (i, "resolve-via-host"))
6780 else if (unformat (i, "resolve-via-attached"))
6781 resolve_attached = 1;
6782 else if (unformat (i, "multipath"))
6784 else if (unformat (i, "count %d", &count))
6786 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6789 next_hop_proto_is_ip4 = 1;
6791 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6794 next_hop_proto_is_ip4 = 0;
6796 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6798 else if (unformat (i, "via-label %d", &next_hop_via_label))
6800 else if (unformat (i, "out-label %d", &next_hop_out_label))
6801 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6804 clib_warning ("parse error '%U'", format_unformat_error, i);
6809 if (!next_hop_set && !is_classify)
6811 errmsg ("next hop / classify not set");
6815 if (MPLS_LABEL_INVALID == local_label)
6817 errmsg ("missing label");
6823 /* Turn on async mode */
6824 vam->async_mode = 1;
6825 vam->async_errors = 0;
6826 before = vat_time_now (vam);
6829 for (j = 0; j < count; j++)
6831 /* Construct the API message */
6832 M2 (MPLS_ROUTE_ADD_DEL, mp,
6833 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6835 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6836 mp->mr_table_id = ntohl (table_id);
6837 mp->mr_create_table_if_needed = create_table_if_needed;
6839 mp->mr_is_add = is_add;
6840 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6841 mp->mr_is_classify = is_classify;
6842 mp->mr_is_multipath = is_multipath;
6843 mp->mr_is_resolve_host = resolve_host;
6844 mp->mr_is_resolve_attached = resolve_attached;
6845 mp->mr_next_hop_weight = next_hop_weight;
6846 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6847 mp->mr_classify_table_index = ntohl (classify_table_index);
6848 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6849 mp->mr_label = ntohl (local_label);
6850 mp->mr_eos = is_eos;
6852 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6853 if (0 != mp->mr_next_hop_n_out_labels)
6855 memcpy (mp->mr_next_hop_out_label_stack,
6856 next_hop_out_label_stack,
6857 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6858 vec_free (next_hop_out_label_stack);
6863 if (next_hop_proto_is_ip4)
6865 clib_memcpy (mp->mr_next_hop,
6866 &v4_next_hop_address,
6867 sizeof (v4_next_hop_address));
6871 clib_memcpy (mp->mr_next_hop,
6872 &v6_next_hop_address,
6873 sizeof (v6_next_hop_address));
6880 /* If we receive SIGTERM, stop now... */
6885 /* When testing multiple add/del ops, use a control-ping to sync */
6888 vl_api_control_ping_t *mp;
6891 /* Shut off async mode */
6892 vam->async_mode = 0;
6894 M (CONTROL_PING, mp);
6897 timeout = vat_time_now (vam) + 1.0;
6898 while (vat_time_now (vam) < timeout)
6899 if (vam->result_ready == 1)
6904 if (vam->retval == -99)
6907 if (vam->async_errors > 0)
6909 errmsg ("%d asynchronous errors", vam->async_errors);
6912 vam->async_errors = 0;
6913 after = vat_time_now (vam);
6915 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6919 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6920 count, after - before, count / (after - before));
6924 /* Wait for a reply... */
6928 /* Return the good/bad news */
6929 return (vam->retval);
6933 api_mpls_ip_bind_unbind (vat_main_t * vam)
6935 unformat_input_t *i = vam->input;
6936 vl_api_mpls_ip_bind_unbind_t *mp;
6938 u32 ip_table_id = 0;
6939 u8 create_table_if_needed = 0;
6942 ip4_address_t v4_address;
6943 ip6_address_t v6_address;
6946 mpls_label_t local_label = MPLS_LABEL_INVALID;
6948 /* Parse args required to build the message */
6949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6951 if (unformat (i, "%U/%d", unformat_ip4_address,
6952 &v4_address, &address_length))
6957 else if (unformat (i, "%U/%d", unformat_ip6_address,
6958 &v6_address, &address_length))
6963 else if (unformat (i, "%d", &local_label))
6965 else if (unformat (i, "create-table"))
6966 create_table_if_needed = 1;
6967 else if (unformat (i, "table-id %d", &ip_table_id))
6969 else if (unformat (i, "unbind"))
6971 else if (unformat (i, "bind"))
6975 clib_warning ("parse error '%U'", format_unformat_error, i);
6982 errmsg ("IP addres not set");
6986 if (MPLS_LABEL_INVALID == local_label)
6988 errmsg ("missing label");
6992 /* Construct the API message */
6993 M (MPLS_IP_BIND_UNBIND, mp);
6995 mp->mb_create_table_if_needed = create_table_if_needed;
6996 mp->mb_is_bind = is_bind;
6997 mp->mb_is_ip4 = is_ip4;
6998 mp->mb_ip_table_id = ntohl (ip_table_id);
6999 mp->mb_mpls_table_id = 0;
7000 mp->mb_label = ntohl (local_label);
7001 mp->mb_address_length = address_length;
7004 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7006 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7011 /* Wait for a reply... */
7016 api_proxy_arp_add_del (vat_main_t * vam)
7018 unformat_input_t *i = vam->input;
7019 vl_api_proxy_arp_add_del_t *mp;
7023 ip4_address_t lo, hi;
7026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7028 if (unformat (i, "vrf %d", &vrf_id))
7030 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7031 unformat_ip4_address, &hi))
7033 else if (unformat (i, "del"))
7037 clib_warning ("parse error '%U'", format_unformat_error, i);
7044 errmsg ("address range not set");
7048 M (PROXY_ARP_ADD_DEL, mp);
7050 mp->vrf_id = ntohl (vrf_id);
7051 mp->is_add = is_add;
7052 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7053 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7062 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7064 unformat_input_t *i = vam->input;
7065 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7069 u8 sw_if_index_set = 0;
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7074 sw_if_index_set = 1;
7075 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7076 sw_if_index_set = 1;
7077 else if (unformat (i, "enable"))
7079 else if (unformat (i, "disable"))
7083 clib_warning ("parse error '%U'", format_unformat_error, i);
7088 if (sw_if_index_set == 0)
7090 errmsg ("missing interface name or sw_if_index");
7094 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7096 mp->sw_if_index = ntohl (sw_if_index);
7097 mp->enable_disable = enable;
7106 api_mpls_tunnel_add_del (vat_main_t * vam)
7108 unformat_input_t *i = vam->input;
7109 vl_api_mpls_tunnel_add_del_t *mp;
7114 u32 sw_if_index = ~0;
7115 u32 next_hop_sw_if_index = ~0;
7116 u32 next_hop_proto_is_ip4 = 1;
7118 u32 next_hop_table_id = 0;
7119 ip4_address_t v4_next_hop_address = {
7122 ip6_address_t v6_next_hop_address = { {0} };
7123 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7127 if (unformat (i, "add"))
7129 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7131 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7133 else if (unformat (i, "via %U",
7134 unformat_ip4_address, &v4_next_hop_address))
7136 next_hop_proto_is_ip4 = 1;
7138 else if (unformat (i, "via %U",
7139 unformat_ip6_address, &v6_next_hop_address))
7141 next_hop_proto_is_ip4 = 0;
7143 else if (unformat (i, "l2-only"))
7145 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7147 else if (unformat (i, "out-label %d", &next_hop_out_label))
7148 vec_add1 (labels, ntohl (next_hop_out_label));
7151 clib_warning ("parse error '%U'", format_unformat_error, i);
7156 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7158 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7159 mp->mt_sw_if_index = ntohl (sw_if_index);
7160 mp->mt_is_add = is_add;
7161 mp->mt_l2_only = l2_only;
7162 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7163 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7165 mp->mt_next_hop_n_out_labels = vec_len (labels);
7167 if (0 != mp->mt_next_hop_n_out_labels)
7169 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7170 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7174 if (next_hop_proto_is_ip4)
7176 clib_memcpy (mp->mt_next_hop,
7177 &v4_next_hop_address, sizeof (v4_next_hop_address));
7181 clib_memcpy (mp->mt_next_hop,
7182 &v6_next_hop_address, sizeof (v6_next_hop_address));
7192 api_sw_interface_set_unnumbered (vat_main_t * vam)
7194 unformat_input_t *i = vam->input;
7195 vl_api_sw_interface_set_unnumbered_t *mp;
7198 u32 unnum_sw_index = ~0;
7200 u8 sw_if_index_set = 0;
7202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7204 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7205 sw_if_index_set = 1;
7206 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7207 sw_if_index_set = 1;
7208 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7210 else if (unformat (i, "del"))
7214 clib_warning ("parse error '%U'", format_unformat_error, i);
7219 if (sw_if_index_set == 0)
7221 errmsg ("missing interface name or sw_if_index");
7225 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7227 mp->sw_if_index = ntohl (sw_if_index);
7228 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7229 mp->is_add = is_add;
7238 api_ip_neighbor_add_del (vat_main_t * vam)
7240 unformat_input_t *i = vam->input;
7241 vl_api_ip_neighbor_add_del_t *mp;
7244 u8 sw_if_index_set = 0;
7250 u8 v4_address_set = 0;
7251 u8 v6_address_set = 0;
7252 ip4_address_t v4address;
7253 ip6_address_t v6address;
7255 memset (mac_address, 0, sizeof (mac_address));
7257 /* Parse args required to build the message */
7258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7260 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7264 else if (unformat (i, "del"))
7267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7268 sw_if_index_set = 1;
7269 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7270 sw_if_index_set = 1;
7271 else if (unformat (i, "is_static"))
7273 else if (unformat (i, "vrf %d", &vrf_id))
7275 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7277 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7281 clib_warning ("parse error '%U'", format_unformat_error, i);
7286 if (sw_if_index_set == 0)
7288 errmsg ("missing interface name or sw_if_index");
7291 if (v4_address_set && v6_address_set)
7293 errmsg ("both v4 and v6 addresses set");
7296 if (!v4_address_set && !v6_address_set)
7298 errmsg ("no address set");
7302 /* Construct the API message */
7303 M (IP_NEIGHBOR_ADD_DEL, mp);
7305 mp->sw_if_index = ntohl (sw_if_index);
7306 mp->is_add = is_add;
7307 mp->vrf_id = ntohl (vrf_id);
7308 mp->is_static = is_static;
7310 clib_memcpy (mp->mac_address, mac_address, 6);
7314 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7318 /* mp->is_ipv6 = 0; via memset in M macro above */
7319 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7325 /* Wait for a reply, return good/bad news */
7333 api_reset_vrf (vat_main_t * vam)
7335 unformat_input_t *i = vam->input;
7336 vl_api_reset_vrf_t *mp;
7342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7344 if (unformat (i, "vrf %d", &vrf_id))
7346 else if (unformat (i, "ipv6"))
7350 clib_warning ("parse error '%U'", format_unformat_error, i);
7355 if (vrf_id_set == 0)
7357 errmsg ("missing vrf id");
7363 mp->vrf_id = ntohl (vrf_id);
7364 mp->is_ipv6 = is_ipv6;
7373 api_create_vlan_subif (vat_main_t * vam)
7375 unformat_input_t *i = vam->input;
7376 vl_api_create_vlan_subif_t *mp;
7379 u8 sw_if_index_set = 0;
7383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7385 if (unformat (i, "sw_if_index %d", &sw_if_index))
7386 sw_if_index_set = 1;
7388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7389 sw_if_index_set = 1;
7390 else if (unformat (i, "vlan %d", &vlan_id))
7394 clib_warning ("parse error '%U'", format_unformat_error, i);
7399 if (sw_if_index_set == 0)
7401 errmsg ("missing interface name or sw_if_index");
7405 if (vlan_id_set == 0)
7407 errmsg ("missing vlan_id");
7410 M (CREATE_VLAN_SUBIF, mp);
7412 mp->sw_if_index = ntohl (sw_if_index);
7413 mp->vlan_id = ntohl (vlan_id);
7421 #define foreach_create_subif_bit \
7428 _(outer_vlan_id_any) \
7429 _(inner_vlan_id_any)
7432 api_create_subif (vat_main_t * vam)
7434 unformat_input_t *i = vam->input;
7435 vl_api_create_subif_t *mp;
7438 u8 sw_if_index_set = 0;
7445 u32 exact_match = 0;
7446 u32 default_sub = 0;
7447 u32 outer_vlan_id_any = 0;
7448 u32 inner_vlan_id_any = 0;
7450 u16 outer_vlan_id = 0;
7451 u16 inner_vlan_id = 0;
7453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7455 if (unformat (i, "sw_if_index %d", &sw_if_index))
7456 sw_if_index_set = 1;
7458 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7459 sw_if_index_set = 1;
7460 else if (unformat (i, "sub_id %d", &sub_id))
7462 else if (unformat (i, "outer_vlan_id %d", &tmp))
7463 outer_vlan_id = tmp;
7464 else if (unformat (i, "inner_vlan_id %d", &tmp))
7465 inner_vlan_id = tmp;
7467 #define _(a) else if (unformat (i, #a)) a = 1 ;
7468 foreach_create_subif_bit
7472 clib_warning ("parse error '%U'", format_unformat_error, i);
7477 if (sw_if_index_set == 0)
7479 errmsg ("missing interface name or sw_if_index");
7483 if (sub_id_set == 0)
7485 errmsg ("missing sub_id");
7488 M (CREATE_SUBIF, mp);
7490 mp->sw_if_index = ntohl (sw_if_index);
7491 mp->sub_id = ntohl (sub_id);
7493 #define _(a) mp->a = a;
7494 foreach_create_subif_bit;
7497 mp->outer_vlan_id = ntohs (outer_vlan_id);
7498 mp->inner_vlan_id = ntohs (inner_vlan_id);
7507 api_oam_add_del (vat_main_t * vam)
7509 unformat_input_t *i = vam->input;
7510 vl_api_oam_add_del_t *mp;
7514 ip4_address_t src, dst;
7518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7520 if (unformat (i, "vrf %d", &vrf_id))
7522 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7524 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7526 else if (unformat (i, "del"))
7530 clib_warning ("parse error '%U'", format_unformat_error, i);
7537 errmsg ("missing src addr");
7543 errmsg ("missing dst addr");
7547 M (OAM_ADD_DEL, mp);
7549 mp->vrf_id = ntohl (vrf_id);
7550 mp->is_add = is_add;
7551 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7552 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7561 api_reset_fib (vat_main_t * vam)
7563 unformat_input_t *i = vam->input;
7564 vl_api_reset_fib_t *mp;
7570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7572 if (unformat (i, "vrf %d", &vrf_id))
7574 else if (unformat (i, "ipv6"))
7578 clib_warning ("parse error '%U'", format_unformat_error, i);
7583 if (vrf_id_set == 0)
7585 errmsg ("missing vrf id");
7591 mp->vrf_id = ntohl (vrf_id);
7592 mp->is_ipv6 = is_ipv6;
7601 api_dhcp_proxy_config (vat_main_t * vam)
7603 unformat_input_t *i = vam->input;
7604 vl_api_dhcp_proxy_config_t *mp;
7609 u8 v4_address_set = 0;
7610 u8 v6_address_set = 0;
7611 ip4_address_t v4address;
7612 ip6_address_t v6address;
7613 u8 v4_src_address_set = 0;
7614 u8 v6_src_address_set = 0;
7615 ip4_address_t v4srcaddress;
7616 ip6_address_t v6srcaddress;
7618 /* Parse args required to build the message */
7619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7621 if (unformat (i, "del"))
7623 else if (unformat (i, "vrf %d", &vrf_id))
7625 else if (unformat (i, "insert-cid %d", &insert_cid))
7627 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7629 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7631 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7632 v4_src_address_set = 1;
7633 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7634 v6_src_address_set = 1;
7639 if (v4_address_set && v6_address_set)
7641 errmsg ("both v4 and v6 server addresses set");
7644 if (!v4_address_set && !v6_address_set)
7646 errmsg ("no server addresses set");
7650 if (v4_src_address_set && v6_src_address_set)
7652 errmsg ("both v4 and v6 src addresses set");
7655 if (!v4_src_address_set && !v6_src_address_set)
7657 errmsg ("no src addresses set");
7661 if (!(v4_src_address_set && v4_address_set) &&
7662 !(v6_src_address_set && v6_address_set))
7664 errmsg ("no matching server and src addresses set");
7668 /* Construct the API message */
7669 M (DHCP_PROXY_CONFIG, mp);
7671 mp->insert_circuit_id = insert_cid;
7672 mp->is_add = is_add;
7673 mp->vrf_id = ntohl (vrf_id);
7677 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7678 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7682 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7683 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7689 /* Wait for a reply, return good/bad news */
7696 api_dhcp_proxy_config_2 (vat_main_t * vam)
7698 unformat_input_t *i = vam->input;
7699 vl_api_dhcp_proxy_config_2_t *mp;
7702 u32 server_vrf_id = 0;
7705 u8 v4_address_set = 0;
7706 u8 v6_address_set = 0;
7707 ip4_address_t v4address;
7708 ip6_address_t v6address;
7709 u8 v4_src_address_set = 0;
7710 u8 v6_src_address_set = 0;
7711 ip4_address_t v4srcaddress;
7712 ip6_address_t v6srcaddress;
7714 /* Parse args required to build the message */
7715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7717 if (unformat (i, "del"))
7719 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7721 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7723 else if (unformat (i, "insert-cid %d", &insert_cid))
7725 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7727 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7729 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7730 v4_src_address_set = 1;
7731 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7732 v6_src_address_set = 1;
7737 if (v4_address_set && v6_address_set)
7739 errmsg ("both v4 and v6 server addresses set");
7742 if (!v4_address_set && !v6_address_set)
7744 errmsg ("no server addresses set");
7748 if (v4_src_address_set && v6_src_address_set)
7750 errmsg ("both v4 and v6 src addresses set");
7753 if (!v4_src_address_set && !v6_src_address_set)
7755 errmsg ("no src addresses set");
7759 if (!(v4_src_address_set && v4_address_set) &&
7760 !(v6_src_address_set && v6_address_set))
7762 errmsg ("no matching server and src addresses set");
7766 /* Construct the API message */
7767 M (DHCP_PROXY_CONFIG_2, mp);
7769 mp->insert_circuit_id = insert_cid;
7770 mp->is_add = is_add;
7771 mp->rx_vrf_id = ntohl (rx_vrf_id);
7772 mp->server_vrf_id = ntohl (server_vrf_id);
7776 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7777 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7781 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7782 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7788 /* Wait for a reply, return good/bad news */
7795 api_dhcp_proxy_set_vss (vat_main_t * vam)
7797 unformat_input_t *i = vam->input;
7798 vl_api_dhcp_proxy_set_vss_t *mp;
7809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7811 if (unformat (i, "tbl_id %d", &tbl_id))
7813 if (unformat (i, "fib_id %d", &fib_id))
7815 if (unformat (i, "oui %d", &oui))
7817 else if (unformat (i, "ipv6"))
7819 else if (unformat (i, "del"))
7823 clib_warning ("parse error '%U'", format_unformat_error, i);
7828 if (tbl_id_set == 0)
7830 errmsg ("missing tbl id");
7834 if (fib_id_set == 0)
7836 errmsg ("missing fib id");
7841 errmsg ("missing oui");
7845 M (DHCP_PROXY_SET_VSS, mp);
7846 mp->tbl_id = ntohl (tbl_id);
7847 mp->fib_id = ntohl (fib_id);
7848 mp->oui = ntohl (oui);
7849 mp->is_ipv6 = is_ipv6;
7850 mp->is_add = is_add;
7859 api_dhcp_client_config (vat_main_t * vam)
7861 unformat_input_t *i = vam->input;
7862 vl_api_dhcp_client_config_t *mp;
7865 u8 sw_if_index_set = 0;
7868 u8 disable_event = 0;
7870 /* Parse args required to build the message */
7871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7873 if (unformat (i, "del"))
7876 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7877 sw_if_index_set = 1;
7878 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7879 sw_if_index_set = 1;
7880 else if (unformat (i, "hostname %s", &hostname))
7882 else if (unformat (i, "disable_event"))
7888 if (sw_if_index_set == 0)
7890 errmsg ("missing interface name or sw_if_index");
7894 if (vec_len (hostname) > 63)
7896 errmsg ("hostname too long");
7898 vec_add1 (hostname, 0);
7900 /* Construct the API message */
7901 M (DHCP_CLIENT_CONFIG, mp);
7903 mp->sw_if_index = ntohl (sw_if_index);
7904 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7905 vec_free (hostname);
7906 mp->is_add = is_add;
7907 mp->want_dhcp_event = disable_event ? 0 : 1;
7908 mp->pid = getpid ();
7913 /* Wait for a reply, return good/bad news */
7920 api_set_ip_flow_hash (vat_main_t * vam)
7922 unformat_input_t *i = vam->input;
7923 vl_api_set_ip_flow_hash_t *mp;
7935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7937 if (unformat (i, "vrf %d", &vrf_id))
7939 else if (unformat (i, "ipv6"))
7941 else if (unformat (i, "src"))
7943 else if (unformat (i, "dst"))
7945 else if (unformat (i, "sport"))
7947 else if (unformat (i, "dport"))
7949 else if (unformat (i, "proto"))
7951 else if (unformat (i, "reverse"))
7956 clib_warning ("parse error '%U'", format_unformat_error, i);
7961 if (vrf_id_set == 0)
7963 errmsg ("missing vrf id");
7967 M (SET_IP_FLOW_HASH, mp);
7973 mp->reverse = reverse;
7974 mp->vrf_id = ntohl (vrf_id);
7975 mp->is_ipv6 = is_ipv6;
7984 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7986 unformat_input_t *i = vam->input;
7987 vl_api_sw_interface_ip6_enable_disable_t *mp;
7990 u8 sw_if_index_set = 0;
7993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7996 sw_if_index_set = 1;
7997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7998 sw_if_index_set = 1;
7999 else if (unformat (i, "enable"))
8001 else if (unformat (i, "disable"))
8005 clib_warning ("parse error '%U'", format_unformat_error, i);
8010 if (sw_if_index_set == 0)
8012 errmsg ("missing interface name or sw_if_index");
8016 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8018 mp->sw_if_index = ntohl (sw_if_index);
8019 mp->enable = enable;
8028 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8030 unformat_input_t *i = vam->input;
8031 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8034 u8 sw_if_index_set = 0;
8035 u8 v6_address_set = 0;
8036 ip6_address_t v6address;
8038 /* Parse args required to build the message */
8039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8042 sw_if_index_set = 1;
8043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8044 sw_if_index_set = 1;
8045 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8051 if (sw_if_index_set == 0)
8053 errmsg ("missing interface name or sw_if_index");
8056 if (!v6_address_set)
8058 errmsg ("no address set");
8062 /* Construct the API message */
8063 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8065 mp->sw_if_index = ntohl (sw_if_index);
8066 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8071 /* Wait for a reply, return good/bad news */
8080 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8082 unformat_input_t *i = vam->input;
8083 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8086 u8 sw_if_index_set = 0;
8087 u32 address_length = 0;
8088 u8 v6_address_set = 0;
8089 ip6_address_t v6address;
8091 u8 no_advertise = 0;
8093 u8 no_autoconfig = 0;
8096 u32 val_lifetime = 0;
8097 u32 pref_lifetime = 0;
8099 /* Parse args required to build the message */
8100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8102 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8103 sw_if_index_set = 1;
8104 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8105 sw_if_index_set = 1;
8106 else if (unformat (i, "%U/%d",
8107 unformat_ip6_address, &v6address, &address_length))
8109 else if (unformat (i, "val_life %d", &val_lifetime))
8111 else if (unformat (i, "pref_life %d", &pref_lifetime))
8113 else if (unformat (i, "def"))
8115 else if (unformat (i, "noadv"))
8117 else if (unformat (i, "offl"))
8119 else if (unformat (i, "noauto"))
8121 else if (unformat (i, "nolink"))
8123 else if (unformat (i, "isno"))
8127 clib_warning ("parse error '%U'", format_unformat_error, i);
8132 if (sw_if_index_set == 0)
8134 errmsg ("missing interface name or sw_if_index");
8137 if (!v6_address_set)
8139 errmsg ("no address set");
8143 /* Construct the API message */
8144 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8146 mp->sw_if_index = ntohl (sw_if_index);
8147 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8148 mp->address_length = address_length;
8149 mp->use_default = use_default;
8150 mp->no_advertise = no_advertise;
8151 mp->off_link = off_link;
8152 mp->no_autoconfig = no_autoconfig;
8153 mp->no_onlink = no_onlink;
8155 mp->val_lifetime = ntohl (val_lifetime);
8156 mp->pref_lifetime = ntohl (pref_lifetime);
8161 /* Wait for a reply, return good/bad news */
8169 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8171 unformat_input_t *i = vam->input;
8172 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8175 u8 sw_if_index_set = 0;
8180 u8 send_unicast = 0;
8183 u8 default_router = 0;
8184 u32 max_interval = 0;
8185 u32 min_interval = 0;
8187 u32 initial_count = 0;
8188 u32 initial_interval = 0;
8191 /* Parse args required to build the message */
8192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8195 sw_if_index_set = 1;
8196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8197 sw_if_index_set = 1;
8198 else if (unformat (i, "maxint %d", &max_interval))
8200 else if (unformat (i, "minint %d", &min_interval))
8202 else if (unformat (i, "life %d", &lifetime))
8204 else if (unformat (i, "count %d", &initial_count))
8206 else if (unformat (i, "interval %d", &initial_interval))
8208 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8210 else if (unformat (i, "managed"))
8212 else if (unformat (i, "other"))
8214 else if (unformat (i, "ll"))
8216 else if (unformat (i, "send"))
8218 else if (unformat (i, "cease"))
8220 else if (unformat (i, "isno"))
8222 else if (unformat (i, "def"))
8226 clib_warning ("parse error '%U'", format_unformat_error, i);
8231 if (sw_if_index_set == 0)
8233 errmsg ("missing interface name or sw_if_index");
8237 /* Construct the API message */
8238 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8240 mp->sw_if_index = ntohl (sw_if_index);
8241 mp->max_interval = ntohl (max_interval);
8242 mp->min_interval = ntohl (min_interval);
8243 mp->lifetime = ntohl (lifetime);
8244 mp->initial_count = ntohl (initial_count);
8245 mp->initial_interval = ntohl (initial_interval);
8246 mp->suppress = suppress;
8247 mp->managed = managed;
8249 mp->ll_option = ll_option;
8250 mp->send_unicast = send_unicast;
8253 mp->default_router = default_router;
8258 /* Wait for a reply, return good/bad news */
8266 api_set_arp_neighbor_limit (vat_main_t * vam)
8268 unformat_input_t *i = vam->input;
8269 vl_api_set_arp_neighbor_limit_t *mp;
8275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8277 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8279 else if (unformat (i, "ipv6"))
8283 clib_warning ("parse error '%U'", format_unformat_error, i);
8290 errmsg ("missing limit value");
8294 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8296 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8297 mp->is_ipv6 = is_ipv6;
8306 api_l2_patch_add_del (vat_main_t * vam)
8308 unformat_input_t *i = vam->input;
8309 vl_api_l2_patch_add_del_t *mp;
8312 u8 rx_sw_if_index_set = 0;
8314 u8 tx_sw_if_index_set = 0;
8317 /* Parse args required to build the message */
8318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8320 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8321 rx_sw_if_index_set = 1;
8322 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8323 tx_sw_if_index_set = 1;
8324 else if (unformat (i, "rx"))
8326 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8328 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8330 rx_sw_if_index_set = 1;
8335 else if (unformat (i, "tx"))
8337 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8339 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8341 tx_sw_if_index_set = 1;
8346 else if (unformat (i, "del"))
8352 if (rx_sw_if_index_set == 0)
8354 errmsg ("missing rx interface name or rx_sw_if_index");
8358 if (tx_sw_if_index_set == 0)
8360 errmsg ("missing tx interface name or tx_sw_if_index");
8364 M (L2_PATCH_ADD_DEL, mp);
8366 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8367 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8368 mp->is_add = is_add;
8377 api_ioam_enable (vat_main_t * vam)
8379 unformat_input_t *input = vam->input;
8380 vl_api_ioam_enable_t *mp;
8383 int has_trace_option = 0;
8384 int has_pot_option = 0;
8385 int has_seqno_option = 0;
8386 int has_analyse_option = 0;
8388 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8390 if (unformat (input, "trace"))
8391 has_trace_option = 1;
8392 else if (unformat (input, "pot"))
8394 else if (unformat (input, "seqno"))
8395 has_seqno_option = 1;
8396 else if (unformat (input, "analyse"))
8397 has_analyse_option = 1;
8401 M (IOAM_ENABLE, mp);
8402 mp->id = htons (id);
8403 mp->seqno = has_seqno_option;
8404 mp->analyse = has_analyse_option;
8405 mp->pot_enable = has_pot_option;
8406 mp->trace_enable = has_trace_option;
8417 api_ioam_disable (vat_main_t * vam)
8419 vl_api_ioam_disable_t *mp;
8422 M (IOAM_DISABLE, mp);
8429 api_sr_tunnel_add_del (vat_main_t * vam)
8431 unformat_input_t *i = vam->input;
8432 vl_api_sr_tunnel_add_del_t *mp;
8436 ip6_address_t src_address;
8437 int src_address_set = 0;
8438 ip6_address_t dst_address;
8440 int dst_address_set = 0;
8442 u32 rx_table_id = 0;
8443 u32 tx_table_id = 0;
8444 ip6_address_t *segments = 0;
8445 ip6_address_t *this_seg;
8446 ip6_address_t *tags = 0;
8447 ip6_address_t *this_tag;
8448 ip6_address_t next_address, tag;
8450 u8 *policy_name = 0;
8452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8454 if (unformat (i, "del"))
8456 else if (unformat (i, "name %s", &name))
8458 else if (unformat (i, "policy %s", &policy_name))
8460 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8462 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8464 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8465 src_address_set = 1;
8466 else if (unformat (i, "dst %U/%d",
8467 unformat_ip6_address, &dst_address, &dst_mask_width))
8468 dst_address_set = 1;
8469 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8471 vec_add2 (segments, this_seg, 1);
8472 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8473 sizeof (*this_seg));
8475 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8477 vec_add2 (tags, this_tag, 1);
8478 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8480 else if (unformat (i, "clean"))
8481 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8482 else if (unformat (i, "protected"))
8483 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8484 else if (unformat (i, "InPE %d", &pl_index))
8486 if (pl_index <= 0 || pl_index > 4)
8488 pl_index_range_error:
8489 errmsg ("pl index %d out of range", pl_index);
8493 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8495 else if (unformat (i, "EgPE %d", &pl_index))
8497 if (pl_index <= 0 || pl_index > 4)
8498 goto pl_index_range_error;
8500 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8502 else if (unformat (i, "OrgSrc %d", &pl_index))
8504 if (pl_index <= 0 || pl_index > 4)
8505 goto pl_index_range_error;
8507 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8513 if (!src_address_set)
8515 errmsg ("src address required");
8519 if (!dst_address_set)
8521 errmsg ("dst address required");
8527 errmsg ("at least one sr segment required");
8531 M2 (SR_TUNNEL_ADD_DEL, mp,
8532 vec_len (segments) * sizeof (ip6_address_t)
8533 + vec_len (tags) * sizeof (ip6_address_t));
8535 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8536 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8537 mp->dst_mask_width = dst_mask_width;
8538 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8539 mp->n_segments = vec_len (segments);
8540 mp->n_tags = vec_len (tags);
8541 mp->is_add = is_del == 0;
8542 clib_memcpy (mp->segs_and_tags, segments,
8543 vec_len (segments) * sizeof (ip6_address_t));
8544 clib_memcpy (mp->segs_and_tags +
8545 vec_len (segments) * sizeof (ip6_address_t), tags,
8546 vec_len (tags) * sizeof (ip6_address_t));
8548 mp->outer_vrf_id = ntohl (rx_table_id);
8549 mp->inner_vrf_id = ntohl (tx_table_id);
8550 memcpy (mp->name, name, vec_len (name));
8551 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8553 vec_free (segments);
8562 api_sr_policy_add_del (vat_main_t * vam)
8564 unformat_input_t *input = vam->input;
8565 vl_api_sr_policy_add_del_t *mp;
8569 u8 *tunnel_name = 0;
8570 u8 **tunnel_names = 0;
8575 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8576 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8580 if (unformat (input, "del"))
8582 else if (unformat (input, "name %s", &name))
8584 else if (unformat (input, "tunnel %s", &tunnel_name))
8588 vec_add1 (tunnel_names, tunnel_name);
8590 - length = #bytes to store in serial vector
8591 - +1 = byte to store that length
8593 tunnel_names_length += (vec_len (tunnel_name) + 1);
8604 errmsg ("policy name required");
8608 if ((!tunnel_set) && (!is_del))
8610 errmsg ("tunnel name required");
8614 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8618 mp->is_add = !is_del;
8620 memcpy (mp->name, name, vec_len (name));
8621 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8622 u8 *serial_orig = 0;
8623 vec_validate (serial_orig, tunnel_names_length);
8624 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8625 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8627 for (j = 0; j < vec_len (tunnel_names); j++)
8629 tun_name_len = vec_len (tunnel_names[j]);
8630 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8631 serial_orig += 1; // Move along one byte to store the actual tunnel name
8632 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8633 serial_orig += tun_name_len; // Advance past the copy
8635 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8637 vec_free (tunnel_names);
8638 vec_free (tunnel_name);
8646 api_sr_multicast_map_add_del (vat_main_t * vam)
8648 unformat_input_t *input = vam->input;
8649 vl_api_sr_multicast_map_add_del_t *mp;
8652 ip6_address_t multicast_address;
8653 u8 *policy_name = 0;
8654 int multicast_address_set = 0;
8656 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8658 if (unformat (input, "del"))
8662 (input, "address %U", unformat_ip6_address, &multicast_address))
8663 multicast_address_set = 1;
8664 else if (unformat (input, "sr-policy %s", &policy_name))
8670 if (!is_del && !policy_name)
8672 errmsg ("sr-policy name required");
8677 if (!multicast_address_set)
8679 errmsg ("address required");
8683 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8685 mp->is_add = !is_del;
8686 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8687 clib_memcpy (mp->multicast_address, &multicast_address,
8688 sizeof (mp->multicast_address));
8691 vec_free (policy_name);
8699 #define foreach_tcp_proto_field \
8703 #define foreach_udp_proto_field \
8707 #define foreach_ip4_proto_field \
8718 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8720 u8 **maskp = va_arg (*args, u8 **);
8722 u8 found_something = 0;
8725 #define _(a) u8 a=0;
8726 foreach_tcp_proto_field;
8729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8732 #define _(a) else if (unformat (input, #a)) a=1;
8733 foreach_tcp_proto_field
8739 #define _(a) found_something += a;
8740 foreach_tcp_proto_field;
8743 if (found_something == 0)
8746 vec_validate (mask, sizeof (*tcp) - 1);
8748 tcp = (tcp_header_t *) mask;
8750 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8751 foreach_tcp_proto_field;
8759 unformat_udp_mask (unformat_input_t * input, va_list * args)
8761 u8 **maskp = va_arg (*args, u8 **);
8763 u8 found_something = 0;
8766 #define _(a) u8 a=0;
8767 foreach_udp_proto_field;
8770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8773 #define _(a) else if (unformat (input, #a)) a=1;
8774 foreach_udp_proto_field
8780 #define _(a) found_something += a;
8781 foreach_udp_proto_field;
8784 if (found_something == 0)
8787 vec_validate (mask, sizeof (*udp) - 1);
8789 udp = (udp_header_t *) mask;
8791 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8792 foreach_udp_proto_field;
8801 u16 src_port, dst_port;
8805 unformat_l4_mask (unformat_input_t * input, va_list * args)
8807 u8 **maskp = va_arg (*args, u8 **);
8808 u16 src_port = 0, dst_port = 0;
8809 tcpudp_header_t *tcpudp;
8811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8813 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8815 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8817 else if (unformat (input, "src_port"))
8819 else if (unformat (input, "dst_port"))
8825 if (!src_port && !dst_port)
8829 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8831 tcpudp = (tcpudp_header_t *) mask;
8832 tcpudp->src_port = src_port;
8833 tcpudp->dst_port = dst_port;
8841 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8843 u8 **maskp = va_arg (*args, u8 **);
8845 u8 found_something = 0;
8848 #define _(a) u8 a=0;
8849 foreach_ip4_proto_field;
8855 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8857 if (unformat (input, "version"))
8859 else if (unformat (input, "hdr_length"))
8861 else if (unformat (input, "src"))
8863 else if (unformat (input, "dst"))
8865 else if (unformat (input, "proto"))
8868 #define _(a) else if (unformat (input, #a)) a=1;
8869 foreach_ip4_proto_field
8875 #define _(a) found_something += a;
8876 foreach_ip4_proto_field;
8879 if (found_something == 0)
8882 vec_validate (mask, sizeof (*ip) - 1);
8884 ip = (ip4_header_t *) mask;
8886 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8887 foreach_ip4_proto_field;
8890 ip->ip_version_and_header_length = 0;
8893 ip->ip_version_and_header_length |= 0xF0;
8896 ip->ip_version_and_header_length |= 0x0F;
8902 #define foreach_ip6_proto_field \
8910 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8912 u8 **maskp = va_arg (*args, u8 **);
8914 u8 found_something = 0;
8916 u32 ip_version_traffic_class_and_flow_label;
8918 #define _(a) u8 a=0;
8919 foreach_ip6_proto_field;
8922 u8 traffic_class = 0;
8925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8927 if (unformat (input, "version"))
8929 else if (unformat (input, "traffic-class"))
8931 else if (unformat (input, "flow-label"))
8933 else if (unformat (input, "src"))
8935 else if (unformat (input, "dst"))
8937 else if (unformat (input, "proto"))
8940 #define _(a) else if (unformat (input, #a)) a=1;
8941 foreach_ip6_proto_field
8947 #define _(a) found_something += a;
8948 foreach_ip6_proto_field;
8951 if (found_something == 0)
8954 vec_validate (mask, sizeof (*ip) - 1);
8956 ip = (ip6_header_t *) mask;
8958 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8959 foreach_ip6_proto_field;
8962 ip_version_traffic_class_and_flow_label = 0;
8965 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8968 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8971 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8973 ip->ip_version_traffic_class_and_flow_label =
8974 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8981 unformat_l3_mask (unformat_input_t * input, va_list * args)
8983 u8 **maskp = va_arg (*args, u8 **);
8985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8987 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8989 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8998 unformat_l2_mask (unformat_input_t * input, va_list * args)
9000 u8 **maskp = va_arg (*args, u8 **);
9015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9017 if (unformat (input, "src"))
9019 else if (unformat (input, "dst"))
9021 else if (unformat (input, "proto"))
9023 else if (unformat (input, "tag1"))
9025 else if (unformat (input, "tag2"))
9027 else if (unformat (input, "ignore-tag1"))
9029 else if (unformat (input, "ignore-tag2"))
9031 else if (unformat (input, "cos1"))
9033 else if (unformat (input, "cos2"))
9035 else if (unformat (input, "dot1q"))
9037 else if (unformat (input, "dot1ad"))
9042 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9043 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9046 if (tag1 || ignore_tag1 || cos1 || dot1q)
9048 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9051 vec_validate (mask, len - 1);
9054 memset (mask, 0xff, 6);
9057 memset (mask + 6, 0xff, 6);
9061 /* inner vlan tag */
9070 mask[21] = mask[20] = 0xff;
9091 mask[16] = mask[17] = 0xff;
9101 mask[12] = mask[13] = 0xff;
9108 unformat_classify_mask (unformat_input_t * input, va_list * args)
9110 u8 **maskp = va_arg (*args, u8 **);
9111 u32 *skipp = va_arg (*args, u32 *);
9112 u32 *matchp = va_arg (*args, u32 *);
9120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9122 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9124 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9126 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9128 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9142 if (mask || l2 || l3 || l4)
9146 /* "With a free Ethernet header in every package" */
9148 vec_validate (l2, 13);
9152 vec_append (mask, l3);
9157 vec_append (mask, l4);
9162 /* Scan forward looking for the first significant mask octet */
9163 for (i = 0; i < vec_len (mask); i++)
9167 /* compute (skip, match) params */
9168 *skipp = i / sizeof (u32x4);
9169 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9171 /* Pad mask to an even multiple of the vector size */
9172 while (vec_len (mask) % sizeof (u32x4))
9175 match = vec_len (mask) / sizeof (u32x4);
9177 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9179 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9180 if (*tmp || *(tmp + 1))
9185 clib_warning ("BUG: match 0");
9187 _vec_len (mask) = match * sizeof (u32x4);
9198 #define foreach_l2_next \
9200 _(ethernet, ETHERNET_INPUT) \
9205 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9207 u32 *miss_next_indexp = va_arg (*args, u32 *);
9212 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9216 if (unformat (input, "%d", &tmp))
9225 *miss_next_indexp = next_index;
9229 #define foreach_ip_next \
9235 unformat_ip_next_index (unformat_input_t * input, va_list * args)
9237 u32 *miss_next_indexp = va_arg (*args, u32 *);
9242 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9246 if (unformat (input, "%d", &tmp))
9255 *miss_next_indexp = next_index;
9259 #define foreach_acl_next \
9263 unformat_acl_next_index (unformat_input_t * input, va_list * args)
9265 u32 *miss_next_indexp = va_arg (*args, u32 *);
9270 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9274 if (unformat (input, "permit"))
9279 else if (unformat (input, "%d", &tmp))
9288 *miss_next_indexp = next_index;
9293 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9295 u32 *r = va_arg (*args, u32 *);
9297 if (unformat (input, "conform-color"))
9298 *r = POLICE_CONFORM;
9299 else if (unformat (input, "exceed-color"))
9308 api_classify_add_del_table (vat_main_t * vam)
9310 unformat_input_t *i = vam->input;
9311 vl_api_classify_add_del_table_t *mp;
9318 u32 table_index = ~0;
9319 u32 next_table_index = ~0;
9320 u32 miss_next_index = ~0;
9321 u32 memory_size = 32 << 20;
9324 u32 current_data_flag = 0;
9325 int current_data_offset = 0;
9327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9329 if (unformat (i, "del"))
9331 else if (unformat (i, "del-chain"))
9336 else if (unformat (i, "buckets %d", &nbuckets))
9338 else if (unformat (i, "memory_size %d", &memory_size))
9340 else if (unformat (i, "skip %d", &skip))
9342 else if (unformat (i, "match %d", &match))
9344 else if (unformat (i, "table %d", &table_index))
9346 else if (unformat (i, "mask %U", unformat_classify_mask,
9347 &mask, &skip, &match))
9349 else if (unformat (i, "next-table %d", &next_table_index))
9351 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
9354 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9357 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9360 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9362 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9368 if (is_add && mask == 0)
9370 errmsg ("Mask required");
9374 if (is_add && skip == ~0)
9376 errmsg ("skip count required");
9380 if (is_add && match == ~0)
9382 errmsg ("match count required");
9386 if (!is_add && table_index == ~0)
9388 errmsg ("table index required for delete");
9392 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9394 mp->is_add = is_add;
9395 mp->del_chain = del_chain;
9396 mp->table_index = ntohl (table_index);
9397 mp->nbuckets = ntohl (nbuckets);
9398 mp->memory_size = ntohl (memory_size);
9399 mp->skip_n_vectors = ntohl (skip);
9400 mp->match_n_vectors = ntohl (match);
9401 mp->next_table_index = ntohl (next_table_index);
9402 mp->miss_next_index = ntohl (miss_next_index);
9403 mp->current_data_flag = ntohl (current_data_flag);
9404 mp->current_data_offset = ntohl (current_data_offset);
9405 clib_memcpy (mp->mask, mask, vec_len (mask));
9415 unformat_l4_match (unformat_input_t * input, va_list * args)
9417 u8 **matchp = va_arg (*args, u8 **);
9419 u8 *proto_header = 0;
9425 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9427 if (unformat (input, "src_port %d", &src_port))
9429 else if (unformat (input, "dst_port %d", &dst_port))
9435 h.src_port = clib_host_to_net_u16 (src_port);
9436 h.dst_port = clib_host_to_net_u16 (dst_port);
9437 vec_validate (proto_header, sizeof (h) - 1);
9438 memcpy (proto_header, &h, sizeof (h));
9440 *matchp = proto_header;
9446 unformat_ip4_match (unformat_input_t * input, va_list * args)
9448 u8 **matchp = va_arg (*args, u8 **);
9455 int src = 0, dst = 0;
9456 ip4_address_t src_val, dst_val;
9463 int fragment_id = 0;
9464 u32 fragment_id_val;
9470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9472 if (unformat (input, "version %d", &version_val))
9474 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9476 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9478 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9480 else if (unformat (input, "proto %d", &proto_val))
9482 else if (unformat (input, "tos %d", &tos_val))
9484 else if (unformat (input, "length %d", &length_val))
9486 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9488 else if (unformat (input, "ttl %d", &ttl_val))
9490 else if (unformat (input, "checksum %d", &checksum_val))
9496 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9497 + ttl + checksum == 0)
9501 * Aligned because we use the real comparison functions
9503 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9505 ip = (ip4_header_t *) match;
9507 /* These are realistically matched in practice */
9509 ip->src_address.as_u32 = src_val.as_u32;
9512 ip->dst_address.as_u32 = dst_val.as_u32;
9515 ip->protocol = proto_val;
9518 /* These are not, but they're included for completeness */
9520 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9523 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9529 ip->length = clib_host_to_net_u16 (length_val);
9535 ip->checksum = clib_host_to_net_u16 (checksum_val);
9542 unformat_ip6_match (unformat_input_t * input, va_list * args)
9544 u8 **matchp = va_arg (*args, u8 **);
9549 u8 traffic_class = 0;
9550 u32 traffic_class_val = 0;
9553 int src = 0, dst = 0;
9554 ip6_address_t src_val, dst_val;
9557 int payload_length = 0;
9558 u32 payload_length_val;
9561 u32 ip_version_traffic_class_and_flow_label;
9563 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9565 if (unformat (input, "version %d", &version_val))
9567 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9569 else if (unformat (input, "flow_label %d", &flow_label_val))
9571 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9573 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9575 else if (unformat (input, "proto %d", &proto_val))
9577 else if (unformat (input, "payload_length %d", &payload_length_val))
9579 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9585 if (version + traffic_class + flow_label + src + dst + proto +
9586 payload_length + hop_limit == 0)
9590 * Aligned because we use the real comparison functions
9592 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9594 ip = (ip6_header_t *) match;
9597 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9600 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9603 ip->protocol = proto_val;
9605 ip_version_traffic_class_and_flow_label = 0;
9608 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9611 ip_version_traffic_class_and_flow_label |=
9612 (traffic_class_val & 0xFF) << 20;
9615 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9617 ip->ip_version_traffic_class_and_flow_label =
9618 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9621 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9624 ip->hop_limit = hop_limit_val;
9631 unformat_l3_match (unformat_input_t * input, va_list * args)
9633 u8 **matchp = va_arg (*args, u8 **);
9635 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9637 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9639 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9648 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9650 u8 *tagp = va_arg (*args, u8 *);
9653 if (unformat (input, "%d", &tag))
9655 tagp[0] = (tag >> 8) & 0x0F;
9656 tagp[1] = tag & 0xFF;
9664 unformat_l2_match (unformat_input_t * input, va_list * args)
9666 u8 **matchp = va_arg (*args, u8 **);
9686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9688 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9691 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9693 else if (unformat (input, "proto %U",
9694 unformat_ethernet_type_host_byte_order, &proto_val))
9696 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9698 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9700 else if (unformat (input, "ignore-tag1"))
9702 else if (unformat (input, "ignore-tag2"))
9704 else if (unformat (input, "cos1 %d", &cos1_val))
9706 else if (unformat (input, "cos2 %d", &cos2_val))
9711 if ((src + dst + proto + tag1 + tag2 +
9712 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9715 if (tag1 || ignore_tag1 || cos1)
9717 if (tag2 || ignore_tag2 || cos2)
9720 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9723 clib_memcpy (match, dst_val, 6);
9726 clib_memcpy (match + 6, src_val, 6);
9730 /* inner vlan tag */
9731 match[19] = tag2_val[1];
9732 match[18] = tag2_val[0];
9734 match[18] |= (cos2_val & 0x7) << 5;
9737 match[21] = proto_val & 0xff;
9738 match[20] = proto_val >> 8;
9742 match[15] = tag1_val[1];
9743 match[14] = tag1_val[0];
9746 match[14] |= (cos1_val & 0x7) << 5;
9752 match[15] = tag1_val[1];
9753 match[14] = tag1_val[0];
9756 match[17] = proto_val & 0xff;
9757 match[16] = proto_val >> 8;
9760 match[14] |= (cos1_val & 0x7) << 5;
9766 match[18] |= (cos2_val & 0x7) << 5;
9768 match[14] |= (cos1_val & 0x7) << 5;
9771 match[13] = proto_val & 0xff;
9772 match[12] = proto_val >> 8;
9781 unformat_classify_match (unformat_input_t * input, va_list * args)
9783 u8 **matchp = va_arg (*args, u8 **);
9784 u32 skip_n_vectors = va_arg (*args, u32);
9785 u32 match_n_vectors = va_arg (*args, u32);
9792 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9794 if (unformat (input, "hex %U", unformat_hex_string, &match))
9796 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9798 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9800 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9814 if (match || l2 || l3 || l4)
9818 /* "Win a free Ethernet header in every packet" */
9820 vec_validate_aligned (l2, 13, sizeof (u32x4));
9824 vec_append_aligned (match, l3, sizeof (u32x4));
9829 vec_append_aligned (match, l4, sizeof (u32x4));
9834 /* Make sure the vector is big enough even if key is all 0's */
9835 vec_validate_aligned
9836 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9839 /* Set size, include skipped vectors */
9840 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9851 api_classify_add_del_session (vat_main_t * vam)
9853 unformat_input_t *i = vam->input;
9854 vl_api_classify_add_del_session_t *mp;
9856 u32 table_index = ~0;
9857 u32 hit_next_index = ~0;
9858 u32 opaque_index = ~0;
9862 u32 skip_n_vectors = 0;
9863 u32 match_n_vectors = 0;
9868 * Warning: you have to supply skip_n and match_n
9869 * because the API client cant simply look at the classify
9873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9875 if (unformat (i, "del"))
9877 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9880 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9883 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9886 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9888 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9890 else if (unformat (i, "opaque-index %d", &opaque_index))
9892 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9894 else if (unformat (i, "match_n %d", &match_n_vectors))
9896 else if (unformat (i, "match %U", unformat_classify_match,
9897 &match, skip_n_vectors, match_n_vectors))
9899 else if (unformat (i, "advance %d", &advance))
9901 else if (unformat (i, "table-index %d", &table_index))
9903 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9905 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9907 else if (unformat (i, "action %d", &action))
9909 else if (unformat (i, "metadata %d", &metadata))
9915 if (table_index == ~0)
9917 errmsg ("Table index required");
9921 if (is_add && match == 0)
9923 errmsg ("Match value required");
9927 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9929 mp->is_add = is_add;
9930 mp->table_index = ntohl (table_index);
9931 mp->hit_next_index = ntohl (hit_next_index);
9932 mp->opaque_index = ntohl (opaque_index);
9933 mp->advance = ntohl (advance);
9934 mp->action = action;
9935 mp->metadata = ntohl (metadata);
9936 clib_memcpy (mp->match, match, vec_len (match));
9945 api_classify_set_interface_ip_table (vat_main_t * vam)
9947 unformat_input_t *i = vam->input;
9948 vl_api_classify_set_interface_ip_table_t *mp;
9951 int sw_if_index_set;
9952 u32 table_index = ~0;
9955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9957 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9958 sw_if_index_set = 1;
9959 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9960 sw_if_index_set = 1;
9961 else if (unformat (i, "table %d", &table_index))
9965 clib_warning ("parse error '%U'", format_unformat_error, i);
9970 if (sw_if_index_set == 0)
9972 errmsg ("missing interface name or sw_if_index");
9977 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9979 mp->sw_if_index = ntohl (sw_if_index);
9980 mp->table_index = ntohl (table_index);
9981 mp->is_ipv6 = is_ipv6;
9990 api_classify_set_interface_l2_tables (vat_main_t * vam)
9992 unformat_input_t *i = vam->input;
9993 vl_api_classify_set_interface_l2_tables_t *mp;
9996 int sw_if_index_set;
9997 u32 ip4_table_index = ~0;
9998 u32 ip6_table_index = ~0;
9999 u32 other_table_index = ~0;
10002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10004 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10005 sw_if_index_set = 1;
10006 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10007 sw_if_index_set = 1;
10008 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10010 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10012 else if (unformat (i, "other-table %d", &other_table_index))
10014 else if (unformat (i, "is-input %d", &is_input))
10018 clib_warning ("parse error '%U'", format_unformat_error, i);
10023 if (sw_if_index_set == 0)
10025 errmsg ("missing interface name or sw_if_index");
10030 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10032 mp->sw_if_index = ntohl (sw_if_index);
10033 mp->ip4_table_index = ntohl (ip4_table_index);
10034 mp->ip6_table_index = ntohl (ip6_table_index);
10035 mp->other_table_index = ntohl (other_table_index);
10036 mp->is_input = (u8) is_input;
10045 api_set_ipfix_exporter (vat_main_t * vam)
10047 unformat_input_t *i = vam->input;
10048 vl_api_set_ipfix_exporter_t *mp;
10049 ip4_address_t collector_address;
10050 u8 collector_address_set = 0;
10051 u32 collector_port = ~0;
10052 ip4_address_t src_address;
10053 u8 src_address_set = 0;
10056 u32 template_interval = ~0;
10057 u8 udp_checksum = 0;
10060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10062 if (unformat (i, "collector_address %U", unformat_ip4_address,
10063 &collector_address))
10064 collector_address_set = 1;
10065 else if (unformat (i, "collector_port %d", &collector_port))
10067 else if (unformat (i, "src_address %U", unformat_ip4_address,
10069 src_address_set = 1;
10070 else if (unformat (i, "vrf_id %d", &vrf_id))
10072 else if (unformat (i, "path_mtu %d", &path_mtu))
10074 else if (unformat (i, "template_interval %d", &template_interval))
10076 else if (unformat (i, "udp_checksum"))
10082 if (collector_address_set == 0)
10084 errmsg ("collector_address required");
10088 if (src_address_set == 0)
10090 errmsg ("src_address required");
10094 M (SET_IPFIX_EXPORTER, mp);
10096 memcpy (mp->collector_address, collector_address.data,
10097 sizeof (collector_address.data));
10098 mp->collector_port = htons ((u16) collector_port);
10099 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10100 mp->vrf_id = htonl (vrf_id);
10101 mp->path_mtu = htonl (path_mtu);
10102 mp->template_interval = htonl (template_interval);
10103 mp->udp_checksum = udp_checksum;
10111 api_set_ipfix_classify_stream (vat_main_t * vam)
10113 unformat_input_t *i = vam->input;
10114 vl_api_set_ipfix_classify_stream_t *mp;
10116 u32 src_port = UDP_DST_PORT_ipfix;
10119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10121 if (unformat (i, "domain %d", &domain_id))
10123 else if (unformat (i, "src_port %d", &src_port))
10127 errmsg ("unknown input `%U'", format_unformat_error, i);
10132 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10134 mp->domain_id = htonl (domain_id);
10135 mp->src_port = htons ((u16) src_port);
10143 api_ipfix_classify_table_add_del (vat_main_t * vam)
10145 unformat_input_t *i = vam->input;
10146 vl_api_ipfix_classify_table_add_del_t *mp;
10148 u32 classify_table_index = ~0;
10150 u8 transport_protocol = 255;
10153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10155 if (unformat (i, "add"))
10157 else if (unformat (i, "del"))
10159 else if (unformat (i, "table %d", &classify_table_index))
10161 else if (unformat (i, "ip4"))
10163 else if (unformat (i, "ip6"))
10165 else if (unformat (i, "tcp"))
10166 transport_protocol = 6;
10167 else if (unformat (i, "udp"))
10168 transport_protocol = 17;
10171 errmsg ("unknown input `%U'", format_unformat_error, i);
10178 errmsg ("expecting: add|del");
10181 if (classify_table_index == ~0)
10183 errmsg ("classifier table not specified");
10186 if (ip_version == 0)
10188 errmsg ("IP version not specified");
10192 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10194 mp->is_add = is_add;
10195 mp->table_id = htonl (classify_table_index);
10196 mp->ip_version = ip_version;
10197 mp->transport_protocol = transport_protocol;
10205 api_get_node_index (vat_main_t * vam)
10207 unformat_input_t *i = vam->input;
10208 vl_api_get_node_index_t *mp;
10212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10214 if (unformat (i, "node %s", &name))
10221 errmsg ("node name required");
10224 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10226 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10230 M (GET_NODE_INDEX, mp);
10231 clib_memcpy (mp->node_name, name, vec_len (name));
10241 api_get_next_index (vat_main_t * vam)
10243 unformat_input_t *i = vam->input;
10244 vl_api_get_next_index_t *mp;
10246 u8 *node_name = 0, *next_node_name = 0;
10248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10250 if (unformat (i, "node-name %s", &node_name))
10252 else if (unformat (i, "next-node-name %s", &next_node_name))
10256 if (node_name == 0)
10258 errmsg ("node name required");
10261 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10263 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10267 if (next_node_name == 0)
10269 errmsg ("next node name required");
10272 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10274 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10278 M (GET_NEXT_INDEX, mp);
10279 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10280 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10281 vec_free (node_name);
10282 vec_free (next_node_name);
10291 api_add_node_next (vat_main_t * vam)
10293 unformat_input_t *i = vam->input;
10294 vl_api_add_node_next_t *mp;
10299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10301 if (unformat (i, "node %s", &name))
10303 else if (unformat (i, "next %s", &next))
10310 errmsg ("node name required");
10313 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10315 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10320 errmsg ("next node required");
10323 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10325 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10329 M (ADD_NODE_NEXT, mp);
10330 clib_memcpy (mp->node_name, name, vec_len (name));
10331 clib_memcpy (mp->next_name, next, vec_len (next));
10342 api_l2tpv3_create_tunnel (vat_main_t * vam)
10344 unformat_input_t *i = vam->input;
10345 ip6_address_t client_address, our_address;
10346 int client_address_set = 0;
10347 int our_address_set = 0;
10348 u32 local_session_id = 0;
10349 u32 remote_session_id = 0;
10350 u64 local_cookie = 0;
10351 u64 remote_cookie = 0;
10352 u8 l2_sublayer_present = 0;
10353 vl_api_l2tpv3_create_tunnel_t *mp;
10356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10358 if (unformat (i, "client_address %U", unformat_ip6_address,
10360 client_address_set = 1;
10361 else if (unformat (i, "our_address %U", unformat_ip6_address,
10363 our_address_set = 1;
10364 else if (unformat (i, "local_session_id %d", &local_session_id))
10366 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10368 else if (unformat (i, "local_cookie %lld", &local_cookie))
10370 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10372 else if (unformat (i, "l2-sublayer-present"))
10373 l2_sublayer_present = 1;
10378 if (client_address_set == 0)
10380 errmsg ("client_address required");
10384 if (our_address_set == 0)
10386 errmsg ("our_address required");
10390 M (L2TPV3_CREATE_TUNNEL, mp);
10392 clib_memcpy (mp->client_address, client_address.as_u8,
10393 sizeof (mp->client_address));
10395 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10397 mp->local_session_id = ntohl (local_session_id);
10398 mp->remote_session_id = ntohl (remote_session_id);
10399 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10400 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10401 mp->l2_sublayer_present = l2_sublayer_present;
10411 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10413 unformat_input_t *i = vam->input;
10415 u8 sw_if_index_set = 0;
10416 u64 new_local_cookie = 0;
10417 u64 new_remote_cookie = 0;
10418 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10423 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10424 sw_if_index_set = 1;
10425 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10426 sw_if_index_set = 1;
10427 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10429 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10435 if (sw_if_index_set == 0)
10437 errmsg ("missing interface name or sw_if_index");
10441 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10443 mp->sw_if_index = ntohl (sw_if_index);
10444 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10445 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10454 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10456 unformat_input_t *i = vam->input;
10457 vl_api_l2tpv3_interface_enable_disable_t *mp;
10460 u8 sw_if_index_set = 0;
10461 u8 enable_disable = 1;
10463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10466 sw_if_index_set = 1;
10467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10468 sw_if_index_set = 1;
10469 else if (unformat (i, "enable"))
10470 enable_disable = 1;
10471 else if (unformat (i, "disable"))
10472 enable_disable = 0;
10477 if (sw_if_index_set == 0)
10479 errmsg ("missing interface name or sw_if_index");
10483 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10485 mp->sw_if_index = ntohl (sw_if_index);
10486 mp->enable_disable = enable_disable;
10495 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10497 unformat_input_t *i = vam->input;
10498 vl_api_l2tpv3_set_lookup_key_t *mp;
10502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10504 if (unformat (i, "lookup_v6_src"))
10505 key = L2T_LOOKUP_SRC_ADDRESS;
10506 else if (unformat (i, "lookup_v6_dst"))
10507 key = L2T_LOOKUP_DST_ADDRESS;
10508 else if (unformat (i, "lookup_session_id"))
10509 key = L2T_LOOKUP_SESSION_ID;
10514 if (key == (u8) ~ 0)
10516 errmsg ("l2tp session lookup key unset");
10520 M (L2TPV3_SET_LOOKUP_KEY, mp);
10530 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10531 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10533 vat_main_t *vam = &vat_main;
10535 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10536 format_ip6_address, mp->our_address,
10537 format_ip6_address, mp->client_address,
10538 clib_net_to_host_u32 (mp->sw_if_index));
10541 " local cookies %016llx %016llx remote cookie %016llx",
10542 clib_net_to_host_u64 (mp->local_cookie[0]),
10543 clib_net_to_host_u64 (mp->local_cookie[1]),
10544 clib_net_to_host_u64 (mp->remote_cookie));
10546 print (vam->ofp, " local session-id %d remote session-id %d",
10547 clib_net_to_host_u32 (mp->local_session_id),
10548 clib_net_to_host_u32 (mp->remote_session_id));
10550 print (vam->ofp, " l2 specific sublayer %s\n",
10551 mp->l2_sublayer_present ? "preset" : "absent");
10555 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10556 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10558 vat_main_t *vam = &vat_main;
10559 vat_json_node_t *node = NULL;
10560 struct in6_addr addr;
10562 if (VAT_JSON_ARRAY != vam->json_tree.type)
10564 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10565 vat_json_init_array (&vam->json_tree);
10567 node = vat_json_array_add (&vam->json_tree);
10569 vat_json_init_object (node);
10571 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10572 vat_json_object_add_ip6 (node, "our_address", addr);
10573 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10574 vat_json_object_add_ip6 (node, "client_address", addr);
10576 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10577 vat_json_init_array (lc);
10578 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10579 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10580 vat_json_object_add_uint (node, "remote_cookie",
10581 clib_net_to_host_u64 (mp->remote_cookie));
10583 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10584 vat_json_object_add_uint (node, "local_session_id",
10585 clib_net_to_host_u32 (mp->local_session_id));
10586 vat_json_object_add_uint (node, "remote_session_id",
10587 clib_net_to_host_u32 (mp->remote_session_id));
10588 vat_json_object_add_string_copy (node, "l2_sublayer",
10589 mp->l2_sublayer_present ? (u8 *) "present"
10590 : (u8 *) "absent");
10594 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10596 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10599 /* Get list of l2tpv3-tunnel interfaces */
10600 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10603 /* Use a control ping for synchronization */
10605 vl_api_control_ping_t *mp;
10606 M (CONTROL_PING, mp);
10613 static void vl_api_sw_interface_tap_details_t_handler
10614 (vl_api_sw_interface_tap_details_t * mp)
10616 vat_main_t *vam = &vat_main;
10618 print (vam->ofp, "%-16s %d",
10619 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10622 static void vl_api_sw_interface_tap_details_t_handler_json
10623 (vl_api_sw_interface_tap_details_t * mp)
10625 vat_main_t *vam = &vat_main;
10626 vat_json_node_t *node = NULL;
10628 if (VAT_JSON_ARRAY != vam->json_tree.type)
10630 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10631 vat_json_init_array (&vam->json_tree);
10633 node = vat_json_array_add (&vam->json_tree);
10635 vat_json_init_object (node);
10636 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10637 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10641 api_sw_interface_tap_dump (vat_main_t * vam)
10643 vl_api_sw_interface_tap_dump_t *mp;
10646 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10647 /* Get list of tap interfaces */
10648 M (SW_INTERFACE_TAP_DUMP, mp);
10651 /* Use a control ping for synchronization */
10653 vl_api_control_ping_t *mp;
10654 M (CONTROL_PING, mp);
10660 static uword unformat_vxlan_decap_next
10661 (unformat_input_t * input, va_list * args)
10663 u32 *result = va_arg (*args, u32 *);
10666 if (unformat (input, "l2"))
10667 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10668 else if (unformat (input, "%d", &tmp))
10676 api_vxlan_add_del_tunnel (vat_main_t * vam)
10678 unformat_input_t *line_input = vam->input;
10679 vl_api_vxlan_add_del_tunnel_t *mp;
10681 ip46_address_t src, dst;
10683 u8 ipv4_set = 0, ipv6_set = 0;
10687 u32 mcast_sw_if_index = ~0;
10688 u32 encap_vrf_id = 0;
10689 u32 decap_next_index = ~0;
10692 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10693 memset (&src, 0, sizeof src);
10694 memset (&dst, 0, sizeof dst);
10696 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10698 if (unformat (line_input, "del"))
10701 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10707 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10713 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10719 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10724 else if (unformat (line_input, "group %U %U",
10725 unformat_ip4_address, &dst.ip4,
10726 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10728 grp_set = dst_set = 1;
10731 else if (unformat (line_input, "group %U",
10732 unformat_ip4_address, &dst.ip4))
10734 grp_set = dst_set = 1;
10737 else if (unformat (line_input, "group %U %U",
10738 unformat_ip6_address, &dst.ip6,
10739 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10741 grp_set = dst_set = 1;
10744 else if (unformat (line_input, "group %U",
10745 unformat_ip6_address, &dst.ip6))
10747 grp_set = dst_set = 1;
10751 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10753 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10755 else if (unformat (line_input, "decap-next %U",
10756 unformat_vxlan_decap_next, &decap_next_index))
10758 else if (unformat (line_input, "vni %d", &vni))
10762 errmsg ("parse error '%U'", format_unformat_error, line_input);
10769 errmsg ("tunnel src address not specified");
10774 errmsg ("tunnel dst address not specified");
10778 if (grp_set && !ip46_address_is_multicast (&dst))
10780 errmsg ("tunnel group address not multicast");
10783 if (grp_set && mcast_sw_if_index == ~0)
10785 errmsg ("tunnel nonexistent multicast device");
10788 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10790 errmsg ("tunnel dst address must be unicast");
10795 if (ipv4_set && ipv6_set)
10797 errmsg ("both IPv4 and IPv6 addresses specified");
10801 if ((vni == 0) || (vni >> 24))
10803 errmsg ("vni not specified or out of range");
10807 M (VXLAN_ADD_DEL_TUNNEL, mp);
10811 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10812 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10816 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10817 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10819 mp->encap_vrf_id = ntohl (encap_vrf_id);
10820 mp->decap_next_index = ntohl (decap_next_index);
10821 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10822 mp->vni = ntohl (vni);
10823 mp->is_add = is_add;
10824 mp->is_ipv6 = ipv6_set;
10832 static void vl_api_vxlan_tunnel_details_t_handler
10833 (vl_api_vxlan_tunnel_details_t * mp)
10835 vat_main_t *vam = &vat_main;
10836 ip46_address_t src, dst;
10838 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10839 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10841 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10842 ntohl (mp->sw_if_index),
10843 format_ip46_address, &src, IP46_TYPE_ANY,
10844 format_ip46_address, &dst, IP46_TYPE_ANY,
10845 ntohl (mp->encap_vrf_id),
10846 ntohl (mp->decap_next_index), ntohl (mp->vni),
10847 ntohl (mp->mcast_sw_if_index));
10850 static void vl_api_vxlan_tunnel_details_t_handler_json
10851 (vl_api_vxlan_tunnel_details_t * mp)
10853 vat_main_t *vam = &vat_main;
10854 vat_json_node_t *node = NULL;
10856 if (VAT_JSON_ARRAY != vam->json_tree.type)
10858 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10859 vat_json_init_array (&vam->json_tree);
10861 node = vat_json_array_add (&vam->json_tree);
10863 vat_json_init_object (node);
10864 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10867 struct in6_addr ip6;
10869 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10870 vat_json_object_add_ip6 (node, "src_address", ip6);
10871 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10872 vat_json_object_add_ip6 (node, "dst_address", ip6);
10876 struct in_addr ip4;
10878 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10879 vat_json_object_add_ip4 (node, "src_address", ip4);
10880 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10881 vat_json_object_add_ip4 (node, "dst_address", ip4);
10883 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10884 vat_json_object_add_uint (node, "decap_next_index",
10885 ntohl (mp->decap_next_index));
10886 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10887 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10888 vat_json_object_add_uint (node, "mcast_sw_if_index",
10889 ntohl (mp->mcast_sw_if_index));
10893 api_vxlan_tunnel_dump (vat_main_t * vam)
10895 unformat_input_t *i = vam->input;
10896 vl_api_vxlan_tunnel_dump_t *mp;
10899 u8 sw_if_index_set = 0;
10901 /* Parse args required to build the message */
10902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10904 if (unformat (i, "sw_if_index %d", &sw_if_index))
10905 sw_if_index_set = 1;
10910 if (sw_if_index_set == 0)
10915 if (!vam->json_output)
10917 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10918 "sw_if_index", "src_address", "dst_address",
10919 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10922 /* Get list of vxlan-tunnel interfaces */
10923 M (VXLAN_TUNNEL_DUMP, mp);
10925 mp->sw_if_index = htonl (sw_if_index);
10929 /* Use a control ping for synchronization */
10931 vl_api_control_ping_t *mp;
10932 M (CONTROL_PING, mp);
10939 api_gre_add_del_tunnel (vat_main_t * vam)
10941 unformat_input_t *line_input = vam->input;
10942 vl_api_gre_add_del_tunnel_t *mp;
10944 ip4_address_t src4, dst4;
10949 u32 outer_fib_id = 0;
10951 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10953 if (unformat (line_input, "del"))
10955 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10957 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10959 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10961 else if (unformat (line_input, "teb"))
10965 errmsg ("parse error '%U'", format_unformat_error, line_input);
10972 errmsg ("tunnel src address not specified");
10977 errmsg ("tunnel dst address not specified");
10982 M (GRE_ADD_DEL_TUNNEL, mp);
10984 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10985 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10986 mp->outer_fib_id = ntohl (outer_fib_id);
10987 mp->is_add = is_add;
10996 static void vl_api_gre_tunnel_details_t_handler
10997 (vl_api_gre_tunnel_details_t * mp)
10999 vat_main_t *vam = &vat_main;
11001 print (vam->ofp, "%11d%15U%15U%6d%14d",
11002 ntohl (mp->sw_if_index),
11003 format_ip4_address, &mp->src_address,
11004 format_ip4_address, &mp->dst_address,
11005 mp->teb, ntohl (mp->outer_fib_id));
11008 static void vl_api_gre_tunnel_details_t_handler_json
11009 (vl_api_gre_tunnel_details_t * mp)
11011 vat_main_t *vam = &vat_main;
11012 vat_json_node_t *node = NULL;
11013 struct in_addr ip4;
11015 if (VAT_JSON_ARRAY != vam->json_tree.type)
11017 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11018 vat_json_init_array (&vam->json_tree);
11020 node = vat_json_array_add (&vam->json_tree);
11022 vat_json_init_object (node);
11023 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11024 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11025 vat_json_object_add_ip4 (node, "src_address", ip4);
11026 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11027 vat_json_object_add_ip4 (node, "dst_address", ip4);
11028 vat_json_object_add_uint (node, "teb", mp->teb);
11029 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11033 api_gre_tunnel_dump (vat_main_t * vam)
11035 unformat_input_t *i = vam->input;
11036 vl_api_gre_tunnel_dump_t *mp;
11039 u8 sw_if_index_set = 0;
11041 /* Parse args required to build the message */
11042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11044 if (unformat (i, "sw_if_index %d", &sw_if_index))
11045 sw_if_index_set = 1;
11050 if (sw_if_index_set == 0)
11055 if (!vam->json_output)
11057 print (vam->ofp, "%11s%15s%15s%6s%14s",
11058 "sw_if_index", "src_address", "dst_address", "teb",
11062 /* Get list of gre-tunnel interfaces */
11063 M (GRE_TUNNEL_DUMP, mp);
11065 mp->sw_if_index = htonl (sw_if_index);
11069 /* Use a control ping for synchronization */
11071 vl_api_control_ping_t *mp;
11072 M (CONTROL_PING, mp);
11079 api_l2_fib_clear_table (vat_main_t * vam)
11081 // unformat_input_t * i = vam->input;
11082 vl_api_l2_fib_clear_table_t *mp;
11085 M (L2_FIB_CLEAR_TABLE, mp);
11094 api_l2_interface_efp_filter (vat_main_t * vam)
11096 unformat_input_t *i = vam->input;
11097 vl_api_l2_interface_efp_filter_t *mp;
11101 u8 sw_if_index_set = 0;
11103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11106 sw_if_index_set = 1;
11107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11108 sw_if_index_set = 1;
11109 else if (unformat (i, "enable"))
11111 else if (unformat (i, "disable"))
11115 clib_warning ("parse error '%U'", format_unformat_error, i);
11120 if (sw_if_index_set == 0)
11122 errmsg ("missing sw_if_index");
11126 M (L2_INTERFACE_EFP_FILTER, mp);
11128 mp->sw_if_index = ntohl (sw_if_index);
11129 mp->enable_disable = enable;
11137 #define foreach_vtr_op \
11138 _("disable", L2_VTR_DISABLED) \
11139 _("push-1", L2_VTR_PUSH_1) \
11140 _("push-2", L2_VTR_PUSH_2) \
11141 _("pop-1", L2_VTR_POP_1) \
11142 _("pop-2", L2_VTR_POP_2) \
11143 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11144 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11145 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11146 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11149 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11151 unformat_input_t *i = vam->input;
11152 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11155 u8 sw_if_index_set = 0;
11158 u32 push_dot1q = 1;
11162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11164 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11165 sw_if_index_set = 1;
11166 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11167 sw_if_index_set = 1;
11168 else if (unformat (i, "vtr_op %d", &vtr_op))
11170 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11173 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11175 else if (unformat (i, "tag1 %d", &tag1))
11177 else if (unformat (i, "tag2 %d", &tag2))
11181 clib_warning ("parse error '%U'", format_unformat_error, i);
11186 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11188 errmsg ("missing vtr operation or sw_if_index");
11192 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11193 mp->sw_if_index = ntohl (sw_if_index);
11194 mp->vtr_op = ntohl (vtr_op);
11195 mp->push_dot1q = ntohl (push_dot1q);
11196 mp->tag1 = ntohl (tag1);
11197 mp->tag2 = ntohl (tag2);
11206 api_create_vhost_user_if (vat_main_t * vam)
11208 unformat_input_t *i = vam->input;
11209 vl_api_create_vhost_user_if_t *mp;
11213 u8 file_name_set = 0;
11214 u32 custom_dev_instance = ~0;
11216 u8 use_custom_mac = 0;
11219 /* Shut up coverity */
11220 memset (hwaddr, 0, sizeof (hwaddr));
11222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11224 if (unformat (i, "socket %s", &file_name))
11228 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11230 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11231 use_custom_mac = 1;
11232 else if (unformat (i, "server"))
11234 else if (unformat (i, "tag %s", &tag))
11240 if (file_name_set == 0)
11242 errmsg ("missing socket file name");
11246 if (vec_len (file_name) > 255)
11248 errmsg ("socket file name too long");
11251 vec_add1 (file_name, 0);
11253 M (CREATE_VHOST_USER_IF, mp);
11255 mp->is_server = is_server;
11256 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11257 vec_free (file_name);
11258 if (custom_dev_instance != ~0)
11261 mp->custom_dev_instance = ntohl (custom_dev_instance);
11263 mp->use_custom_mac = use_custom_mac;
11264 clib_memcpy (mp->mac_address, hwaddr, 6);
11266 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11276 api_modify_vhost_user_if (vat_main_t * vam)
11278 unformat_input_t *i = vam->input;
11279 vl_api_modify_vhost_user_if_t *mp;
11283 u8 file_name_set = 0;
11284 u32 custom_dev_instance = ~0;
11285 u8 sw_if_index_set = 0;
11286 u32 sw_if_index = (u32) ~ 0;
11288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11291 sw_if_index_set = 1;
11292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11293 sw_if_index_set = 1;
11294 else if (unformat (i, "socket %s", &file_name))
11298 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11300 else if (unformat (i, "server"))
11306 if (sw_if_index_set == 0)
11308 errmsg ("missing sw_if_index or interface name");
11312 if (file_name_set == 0)
11314 errmsg ("missing socket file name");
11318 if (vec_len (file_name) > 255)
11320 errmsg ("socket file name too long");
11323 vec_add1 (file_name, 0);
11325 M (MODIFY_VHOST_USER_IF, mp);
11327 mp->sw_if_index = ntohl (sw_if_index);
11328 mp->is_server = is_server;
11329 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11330 vec_free (file_name);
11331 if (custom_dev_instance != ~0)
11334 mp->custom_dev_instance = ntohl (custom_dev_instance);
11344 api_delete_vhost_user_if (vat_main_t * vam)
11346 unformat_input_t *i = vam->input;
11347 vl_api_delete_vhost_user_if_t *mp;
11349 u32 sw_if_index = ~0;
11350 u8 sw_if_index_set = 0;
11352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11355 sw_if_index_set = 1;
11356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11357 sw_if_index_set = 1;
11362 if (sw_if_index_set == 0)
11364 errmsg ("missing sw_if_index or interface name");
11369 M (DELETE_VHOST_USER_IF, mp);
11371 mp->sw_if_index = ntohl (sw_if_index);
11379 static void vl_api_sw_interface_vhost_user_details_t_handler
11380 (vl_api_sw_interface_vhost_user_details_t * mp)
11382 vat_main_t *vam = &vat_main;
11384 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11385 (char *) mp->interface_name,
11386 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11387 clib_net_to_host_u64 (mp->features), mp->is_server,
11388 ntohl (mp->num_regions), (char *) mp->sock_filename);
11389 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11392 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11393 (vl_api_sw_interface_vhost_user_details_t * mp)
11395 vat_main_t *vam = &vat_main;
11396 vat_json_node_t *node = NULL;
11398 if (VAT_JSON_ARRAY != vam->json_tree.type)
11400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11401 vat_json_init_array (&vam->json_tree);
11403 node = vat_json_array_add (&vam->json_tree);
11405 vat_json_init_object (node);
11406 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11407 vat_json_object_add_string_copy (node, "interface_name",
11408 mp->interface_name);
11409 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11410 ntohl (mp->virtio_net_hdr_sz));
11411 vat_json_object_add_uint (node, "features",
11412 clib_net_to_host_u64 (mp->features));
11413 vat_json_object_add_uint (node, "is_server", mp->is_server);
11414 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11415 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11416 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11420 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11422 vl_api_sw_interface_vhost_user_dump_t *mp;
11425 "Interface name idx hdr_sz features server regions filename");
11427 /* Get list of vhost-user interfaces */
11428 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11431 /* Use a control ping for synchronization */
11433 vl_api_control_ping_t *mp;
11434 M (CONTROL_PING, mp);
11441 api_show_version (vat_main_t * vam)
11443 vl_api_show_version_t *mp;
11446 M (SHOW_VERSION, mp);
11456 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11458 unformat_input_t *line_input = vam->input;
11459 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11461 ip4_address_t local4, remote4;
11462 ip6_address_t local6, remote6;
11464 u8 ipv4_set = 0, ipv6_set = 0;
11467 u32 encap_vrf_id = 0;
11468 u32 decap_vrf_id = 0;
11473 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11475 if (unformat (line_input, "del"))
11477 else if (unformat (line_input, "local %U",
11478 unformat_ip4_address, &local4))
11483 else if (unformat (line_input, "remote %U",
11484 unformat_ip4_address, &remote4))
11489 else if (unformat (line_input, "local %U",
11490 unformat_ip6_address, &local6))
11495 else if (unformat (line_input, "remote %U",
11496 unformat_ip6_address, &remote6))
11501 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11503 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11505 else if (unformat (line_input, "vni %d", &vni))
11507 else if (unformat (line_input, "next-ip4"))
11509 else if (unformat (line_input, "next-ip6"))
11511 else if (unformat (line_input, "next-ethernet"))
11513 else if (unformat (line_input, "next-nsh"))
11517 errmsg ("parse error '%U'", format_unformat_error, line_input);
11522 if (local_set == 0)
11524 errmsg ("tunnel local address not specified");
11527 if (remote_set == 0)
11529 errmsg ("tunnel remote address not specified");
11532 if (ipv4_set && ipv6_set)
11534 errmsg ("both IPv4 and IPv6 addresses specified");
11540 errmsg ("vni not specified");
11544 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11549 clib_memcpy (&mp->local, &local6, sizeof (local6));
11550 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11554 clib_memcpy (&mp->local, &local4, sizeof (local4));
11555 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11558 mp->encap_vrf_id = ntohl (encap_vrf_id);
11559 mp->decap_vrf_id = ntohl (decap_vrf_id);
11560 mp->protocol = protocol;
11561 mp->vni = ntohl (vni);
11562 mp->is_add = is_add;
11563 mp->is_ipv6 = ipv6_set;
11571 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11572 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11574 vat_main_t *vam = &vat_main;
11576 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11577 ntohl (mp->sw_if_index),
11578 format_ip46_address, &(mp->local[0]),
11579 format_ip46_address, &(mp->remote[0]),
11581 ntohl (mp->protocol),
11582 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11585 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11586 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11588 vat_main_t *vam = &vat_main;
11589 vat_json_node_t *node = NULL;
11590 struct in_addr ip4;
11591 struct in6_addr ip6;
11593 if (VAT_JSON_ARRAY != vam->json_tree.type)
11595 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11596 vat_json_init_array (&vam->json_tree);
11598 node = vat_json_array_add (&vam->json_tree);
11600 vat_json_init_object (node);
11601 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11604 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11605 vat_json_object_add_ip6 (node, "local", ip6);
11606 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11607 vat_json_object_add_ip6 (node, "remote", ip6);
11611 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11612 vat_json_object_add_ip4 (node, "local", ip4);
11613 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11614 vat_json_object_add_ip4 (node, "remote", ip4);
11616 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11617 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11618 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11619 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11620 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11624 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11626 unformat_input_t *i = vam->input;
11627 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11630 u8 sw_if_index_set = 0;
11632 /* Parse args required to build the message */
11633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11635 if (unformat (i, "sw_if_index %d", &sw_if_index))
11636 sw_if_index_set = 1;
11641 if (sw_if_index_set == 0)
11646 if (!vam->json_output)
11648 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11649 "sw_if_index", "local", "remote", "vni",
11650 "protocol", "encap_vrf_id", "decap_vrf_id");
11653 /* Get list of vxlan-tunnel interfaces */
11654 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11656 mp->sw_if_index = htonl (sw_if_index);
11660 /* Use a control ping for synchronization */
11662 vl_api_control_ping_t *mp;
11663 M (CONTROL_PING, mp);
11670 format_l2_fib_mac_address (u8 * s, va_list * args)
11672 u8 *a = va_arg (*args, u8 *);
11674 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11675 a[2], a[3], a[4], a[5], a[6], a[7]);
11678 static void vl_api_l2_fib_table_entry_t_handler
11679 (vl_api_l2_fib_table_entry_t * mp)
11681 vat_main_t *vam = &vat_main;
11683 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11685 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11686 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11690 static void vl_api_l2_fib_table_entry_t_handler_json
11691 (vl_api_l2_fib_table_entry_t * mp)
11693 vat_main_t *vam = &vat_main;
11694 vat_json_node_t *node = NULL;
11696 if (VAT_JSON_ARRAY != vam->json_tree.type)
11698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11699 vat_json_init_array (&vam->json_tree);
11701 node = vat_json_array_add (&vam->json_tree);
11703 vat_json_init_object (node);
11704 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11705 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11706 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11707 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11708 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11709 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11713 api_l2_fib_table_dump (vat_main_t * vam)
11715 unformat_input_t *i = vam->input;
11716 vl_api_l2_fib_table_dump_t *mp;
11721 /* Parse args required to build the message */
11722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11724 if (unformat (i, "bd_id %d", &bd_id))
11730 if (bd_id_set == 0)
11732 errmsg ("missing bridge domain");
11736 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11738 /* Get list of l2 fib entries */
11739 M (L2_FIB_TABLE_DUMP, mp);
11741 mp->bd_id = ntohl (bd_id);
11744 /* Use a control ping for synchronization */
11746 vl_api_control_ping_t *mp;
11747 M (CONTROL_PING, mp);
11755 api_interface_name_renumber (vat_main_t * vam)
11757 unformat_input_t *line_input = vam->input;
11758 vl_api_interface_name_renumber_t *mp;
11759 u32 sw_if_index = ~0;
11761 u32 new_show_dev_instance = ~0;
11763 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11765 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11768 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11770 else if (unformat (line_input, "new_show_dev_instance %d",
11771 &new_show_dev_instance))
11777 if (sw_if_index == ~0)
11779 errmsg ("missing interface name or sw_if_index");
11783 if (new_show_dev_instance == ~0)
11785 errmsg ("missing new_show_dev_instance");
11789 M (INTERFACE_NAME_RENUMBER, mp);
11791 mp->sw_if_index = ntohl (sw_if_index);
11792 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11799 api_want_ip4_arp_events (vat_main_t * vam)
11801 unformat_input_t *line_input = vam->input;
11802 vl_api_want_ip4_arp_events_t *mp;
11804 ip4_address_t address;
11805 int address_set = 0;
11806 u32 enable_disable = 1;
11808 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11810 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11812 else if (unformat (line_input, "del"))
11813 enable_disable = 0;
11818 if (address_set == 0)
11820 errmsg ("missing addresses");
11824 M (WANT_IP4_ARP_EVENTS, mp);
11825 mp->enable_disable = enable_disable;
11826 mp->pid = getpid ();
11827 mp->address = address.as_u32;
11834 api_want_ip6_nd_events (vat_main_t * vam)
11836 unformat_input_t *line_input = vam->input;
11837 vl_api_want_ip6_nd_events_t *mp;
11839 ip6_address_t address;
11840 int address_set = 0;
11841 u32 enable_disable = 1;
11843 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11845 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11847 else if (unformat (line_input, "del"))
11848 enable_disable = 0;
11853 if (address_set == 0)
11855 errmsg ("missing addresses");
11859 M (WANT_IP6_ND_EVENTS, mp);
11860 mp->enable_disable = enable_disable;
11861 mp->pid = getpid ();
11862 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11869 api_input_acl_set_interface (vat_main_t * vam)
11871 unformat_input_t *i = vam->input;
11872 vl_api_input_acl_set_interface_t *mp;
11875 int sw_if_index_set;
11876 u32 ip4_table_index = ~0;
11877 u32 ip6_table_index = ~0;
11878 u32 l2_table_index = ~0;
11881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11883 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11884 sw_if_index_set = 1;
11885 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11886 sw_if_index_set = 1;
11887 else if (unformat (i, "del"))
11889 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11891 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11893 else if (unformat (i, "l2-table %d", &l2_table_index))
11897 clib_warning ("parse error '%U'", format_unformat_error, i);
11902 if (sw_if_index_set == 0)
11904 errmsg ("missing interface name or sw_if_index");
11908 M (INPUT_ACL_SET_INTERFACE, mp);
11910 mp->sw_if_index = ntohl (sw_if_index);
11911 mp->ip4_table_index = ntohl (ip4_table_index);
11912 mp->ip6_table_index = ntohl (ip6_table_index);
11913 mp->l2_table_index = ntohl (l2_table_index);
11914 mp->is_add = is_add;
11923 api_ip_address_dump (vat_main_t * vam)
11925 unformat_input_t *i = vam->input;
11926 vl_api_ip_address_dump_t *mp;
11927 u32 sw_if_index = ~0;
11928 u8 sw_if_index_set = 0;
11933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11935 if (unformat (i, "sw_if_index %d", &sw_if_index))
11936 sw_if_index_set = 1;
11938 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11939 sw_if_index_set = 1;
11940 else if (unformat (i, "ipv4"))
11942 else if (unformat (i, "ipv6"))
11948 if (ipv4_set && ipv6_set)
11950 errmsg ("ipv4 and ipv6 flags cannot be both set");
11954 if ((!ipv4_set) && (!ipv6_set))
11956 errmsg ("no ipv4 nor ipv6 flag set");
11960 if (sw_if_index_set == 0)
11962 errmsg ("missing interface name or sw_if_index");
11966 vam->current_sw_if_index = sw_if_index;
11967 vam->is_ipv6 = ipv6_set;
11969 M (IP_ADDRESS_DUMP, mp);
11970 mp->sw_if_index = ntohl (sw_if_index);
11971 mp->is_ipv6 = ipv6_set;
11974 /* Use a control ping for synchronization */
11976 vl_api_control_ping_t *mp;
11977 M (CONTROL_PING, mp);
11984 api_ip_dump (vat_main_t * vam)
11986 vl_api_ip_dump_t *mp;
11987 unformat_input_t *in = vam->input;
11994 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11996 if (unformat (in, "ipv4"))
11998 else if (unformat (in, "ipv6"))
12004 if (ipv4_set && ipv6_set)
12006 errmsg ("ipv4 and ipv6 flags cannot be both set");
12010 if ((!ipv4_set) && (!ipv6_set))
12012 errmsg ("no ipv4 nor ipv6 flag set");
12016 is_ipv6 = ipv6_set;
12017 vam->is_ipv6 = is_ipv6;
12019 /* free old data */
12020 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12022 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12024 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12027 mp->is_ipv6 = ipv6_set;
12030 /* Use a control ping for synchronization */
12032 vl_api_control_ping_t *mp;
12033 M (CONTROL_PING, mp);
12040 api_ipsec_spd_add_del (vat_main_t * vam)
12042 unformat_input_t *i = vam->input;
12043 vl_api_ipsec_spd_add_del_t *mp;
12048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12050 if (unformat (i, "spd_id %d", &spd_id))
12052 else if (unformat (i, "del"))
12056 clib_warning ("parse error '%U'", format_unformat_error, i);
12062 errmsg ("spd_id must be set");
12066 M (IPSEC_SPD_ADD_DEL, mp);
12068 mp->spd_id = ntohl (spd_id);
12069 mp->is_add = is_add;
12078 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12080 unformat_input_t *i = vam->input;
12081 vl_api_ipsec_interface_add_del_spd_t *mp;
12084 u8 sw_if_index_set = 0;
12085 u32 spd_id = (u32) ~ 0;
12088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12090 if (unformat (i, "del"))
12092 else if (unformat (i, "spd_id %d", &spd_id))
12095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12096 sw_if_index_set = 1;
12097 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12098 sw_if_index_set = 1;
12101 clib_warning ("parse error '%U'", format_unformat_error, i);
12107 if (spd_id == (u32) ~ 0)
12109 errmsg ("spd_id must be set");
12113 if (sw_if_index_set == 0)
12115 errmsg ("missing interface name or sw_if_index");
12119 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12121 mp->spd_id = ntohl (spd_id);
12122 mp->sw_if_index = ntohl (sw_if_index);
12123 mp->is_add = is_add;
12132 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12134 unformat_input_t *i = vam->input;
12135 vl_api_ipsec_spd_add_del_entry_t *mp;
12137 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12138 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12140 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12141 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12142 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12143 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12145 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12146 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12147 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12148 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12149 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12150 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12154 if (unformat (i, "del"))
12156 if (unformat (i, "outbound"))
12158 if (unformat (i, "inbound"))
12160 else if (unformat (i, "spd_id %d", &spd_id))
12162 else if (unformat (i, "sa_id %d", &sa_id))
12164 else if (unformat (i, "priority %d", &priority))
12166 else if (unformat (i, "protocol %d", &protocol))
12168 else if (unformat (i, "lport_start %d", &lport_start))
12170 else if (unformat (i, "lport_stop %d", &lport_stop))
12172 else if (unformat (i, "rport_start %d", &rport_start))
12174 else if (unformat (i, "rport_stop %d", &rport_stop))
12178 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12184 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12191 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12197 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12204 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12210 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12217 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12223 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12229 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12231 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12233 clib_warning ("unsupported action: 'resolve'");
12239 clib_warning ("parse error '%U'", format_unformat_error, i);
12245 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12247 mp->spd_id = ntohl (spd_id);
12248 mp->priority = ntohl (priority);
12249 mp->is_outbound = is_outbound;
12251 mp->is_ipv6 = is_ipv6;
12252 if (is_ipv6 || is_ip_any)
12254 clib_memcpy (mp->remote_address_start, &raddr6_start,
12255 sizeof (ip6_address_t));
12256 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12257 sizeof (ip6_address_t));
12258 clib_memcpy (mp->local_address_start, &laddr6_start,
12259 sizeof (ip6_address_t));
12260 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12261 sizeof (ip6_address_t));
12265 clib_memcpy (mp->remote_address_start, &raddr4_start,
12266 sizeof (ip4_address_t));
12267 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12268 sizeof (ip4_address_t));
12269 clib_memcpy (mp->local_address_start, &laddr4_start,
12270 sizeof (ip4_address_t));
12271 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12272 sizeof (ip4_address_t));
12274 mp->protocol = (u8) protocol;
12275 mp->local_port_start = ntohs ((u16) lport_start);
12276 mp->local_port_stop = ntohs ((u16) lport_stop);
12277 mp->remote_port_start = ntohs ((u16) rport_start);
12278 mp->remote_port_stop = ntohs ((u16) rport_stop);
12279 mp->policy = (u8) policy;
12280 mp->sa_id = ntohl (sa_id);
12281 mp->is_add = is_add;
12282 mp->is_ip_any = is_ip_any;
12290 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12292 unformat_input_t *i = vam->input;
12293 vl_api_ipsec_sad_add_del_entry_t *mp;
12295 u32 sad_id = 0, spi = 0;
12296 u8 *ck = 0, *ik = 0;
12299 u8 protocol = IPSEC_PROTOCOL_AH;
12300 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12301 u32 crypto_alg = 0, integ_alg = 0;
12302 ip4_address_t tun_src4;
12303 ip4_address_t tun_dst4;
12304 ip6_address_t tun_src6;
12305 ip6_address_t tun_dst6;
12307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12309 if (unformat (i, "del"))
12311 else if (unformat (i, "sad_id %d", &sad_id))
12313 else if (unformat (i, "spi %d", &spi))
12315 else if (unformat (i, "esp"))
12316 protocol = IPSEC_PROTOCOL_ESP;
12317 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12320 is_tunnel_ipv6 = 0;
12322 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12325 is_tunnel_ipv6 = 0;
12327 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12330 is_tunnel_ipv6 = 1;
12332 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12335 is_tunnel_ipv6 = 1;
12339 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12341 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12342 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12344 clib_warning ("unsupported crypto-alg: '%U'",
12345 format_ipsec_crypto_alg, crypto_alg);
12349 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12353 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12355 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12356 integ_alg >= IPSEC_INTEG_N_ALG)
12358 clib_warning ("unsupported integ-alg: '%U'",
12359 format_ipsec_integ_alg, integ_alg);
12363 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12367 clib_warning ("parse error '%U'", format_unformat_error, i);
12373 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12375 mp->sad_id = ntohl (sad_id);
12376 mp->is_add = is_add;
12377 mp->protocol = protocol;
12378 mp->spi = ntohl (spi);
12379 mp->is_tunnel = is_tunnel;
12380 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12381 mp->crypto_algorithm = crypto_alg;
12382 mp->integrity_algorithm = integ_alg;
12383 mp->crypto_key_length = vec_len (ck);
12384 mp->integrity_key_length = vec_len (ik);
12386 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12387 mp->crypto_key_length = sizeof (mp->crypto_key);
12389 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12390 mp->integrity_key_length = sizeof (mp->integrity_key);
12393 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12395 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12399 if (is_tunnel_ipv6)
12401 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12402 sizeof (ip6_address_t));
12403 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12404 sizeof (ip6_address_t));
12408 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12409 sizeof (ip4_address_t));
12410 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12411 sizeof (ip4_address_t));
12422 api_ipsec_sa_set_key (vat_main_t * vam)
12424 unformat_input_t *i = vam->input;
12425 vl_api_ipsec_sa_set_key_t *mp;
12428 u8 *ck = 0, *ik = 0;
12430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12432 if (unformat (i, "sa_id %d", &sa_id))
12434 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12436 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12440 clib_warning ("parse error '%U'", format_unformat_error, i);
12445 M (IPSEC_SA_SET_KEY, mp);
12447 mp->sa_id = ntohl (sa_id);
12448 mp->crypto_key_length = vec_len (ck);
12449 mp->integrity_key_length = vec_len (ik);
12451 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12452 mp->crypto_key_length = sizeof (mp->crypto_key);
12454 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12455 mp->integrity_key_length = sizeof (mp->integrity_key);
12458 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12460 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12469 api_ikev2_profile_add_del (vat_main_t * vam)
12471 unformat_input_t *i = vam->input;
12472 vl_api_ikev2_profile_add_del_t *mp;
12477 const char *valid_chars = "a-zA-Z0-9_";
12479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12481 if (unformat (i, "del"))
12483 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12484 vec_add1 (name, 0);
12487 errmsg ("parse error '%U'", format_unformat_error, i);
12492 if (!vec_len (name))
12494 errmsg ("profile name must be specified");
12498 if (vec_len (name) > 64)
12500 errmsg ("profile name too long");
12504 M (IKEV2_PROFILE_ADD_DEL, mp);
12506 clib_memcpy (mp->name, name, vec_len (name));
12507 mp->is_add = is_add;
12517 api_ikev2_profile_set_auth (vat_main_t * vam)
12519 unformat_input_t *i = vam->input;
12520 vl_api_ikev2_profile_set_auth_t *mp;
12524 u32 auth_method = 0;
12527 const char *valid_chars = "a-zA-Z0-9_";
12529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12531 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12532 vec_add1 (name, 0);
12533 else if (unformat (i, "auth_method %U",
12534 unformat_ikev2_auth_method, &auth_method))
12536 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12538 else if (unformat (i, "auth_data %v", &data))
12542 errmsg ("parse error '%U'", format_unformat_error, i);
12547 if (!vec_len (name))
12549 errmsg ("profile name must be specified");
12553 if (vec_len (name) > 64)
12555 errmsg ("profile name too long");
12559 if (!vec_len (data))
12561 errmsg ("auth_data must be specified");
12567 errmsg ("auth_method must be specified");
12571 M (IKEV2_PROFILE_SET_AUTH, mp);
12573 mp->is_hex = is_hex;
12574 mp->auth_method = (u8) auth_method;
12575 mp->data_len = vec_len (data);
12576 clib_memcpy (mp->name, name, vec_len (name));
12577 clib_memcpy (mp->data, data, vec_len (data));
12588 api_ikev2_profile_set_id (vat_main_t * vam)
12590 unformat_input_t *i = vam->input;
12591 vl_api_ikev2_profile_set_id_t *mp;
12599 const char *valid_chars = "a-zA-Z0-9_";
12601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12603 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12604 vec_add1 (name, 0);
12605 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12607 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12609 data = vec_new (u8, 4);
12610 clib_memcpy (data, ip4.as_u8, 4);
12612 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12614 else if (unformat (i, "id_data %v", &data))
12616 else if (unformat (i, "local"))
12618 else if (unformat (i, "remote"))
12622 errmsg ("parse error '%U'", format_unformat_error, i);
12627 if (!vec_len (name))
12629 errmsg ("profile name must be specified");
12633 if (vec_len (name) > 64)
12635 errmsg ("profile name too long");
12639 if (!vec_len (data))
12641 errmsg ("id_data must be specified");
12647 errmsg ("id_type must be specified");
12651 M (IKEV2_PROFILE_SET_ID, mp);
12653 mp->is_local = is_local;
12654 mp->id_type = (u8) id_type;
12655 mp->data_len = vec_len (data);
12656 clib_memcpy (mp->name, name, vec_len (name));
12657 clib_memcpy (mp->data, data, vec_len (data));
12668 api_ikev2_profile_set_ts (vat_main_t * vam)
12670 unformat_input_t *i = vam->input;
12671 vl_api_ikev2_profile_set_ts_t *mp;
12675 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12676 ip4_address_t start_addr, end_addr;
12678 const char *valid_chars = "a-zA-Z0-9_";
12680 start_addr.as_u32 = 0;
12681 end_addr.as_u32 = (u32) ~ 0;
12683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12685 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12686 vec_add1 (name, 0);
12687 else if (unformat (i, "protocol %d", &proto))
12689 else if (unformat (i, "start_port %d", &start_port))
12691 else if (unformat (i, "end_port %d", &end_port))
12694 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12696 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12698 else if (unformat (i, "local"))
12700 else if (unformat (i, "remote"))
12704 errmsg ("parse error '%U'", format_unformat_error, i);
12709 if (!vec_len (name))
12711 errmsg ("profile name must be specified");
12715 if (vec_len (name) > 64)
12717 errmsg ("profile name too long");
12721 M (IKEV2_PROFILE_SET_TS, mp);
12723 mp->is_local = is_local;
12724 mp->proto = (u8) proto;
12725 mp->start_port = (u16) start_port;
12726 mp->end_port = (u16) end_port;
12727 mp->start_addr = start_addr.as_u32;
12728 mp->end_addr = end_addr.as_u32;
12729 clib_memcpy (mp->name, name, vec_len (name));
12739 api_ikev2_set_local_key (vat_main_t * vam)
12741 unformat_input_t *i = vam->input;
12742 vl_api_ikev2_set_local_key_t *mp;
12746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12748 if (unformat (i, "file %v", &file))
12749 vec_add1 (file, 0);
12752 errmsg ("parse error '%U'", format_unformat_error, i);
12757 if (!vec_len (file))
12759 errmsg ("RSA key file must be specified");
12763 if (vec_len (file) > 256)
12765 errmsg ("file name too long");
12769 M (IKEV2_SET_LOCAL_KEY, mp);
12771 clib_memcpy (mp->key_file, file, vec_len (file));
12784 api_map_add_domain (vat_main_t * vam)
12786 unformat_input_t *i = vam->input;
12787 vl_api_map_add_domain_t *mp;
12790 ip4_address_t ip4_prefix;
12791 ip6_address_t ip6_prefix;
12792 ip6_address_t ip6_src;
12793 u32 num_m_args = 0;
12794 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12795 0, psid_length = 0;
12796 u8 is_translation = 0;
12798 u32 ip6_src_len = 128;
12800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12802 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12803 &ip4_prefix, &ip4_prefix_len))
12805 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12806 &ip6_prefix, &ip6_prefix_len))
12810 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12813 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12815 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12817 else if (unformat (i, "psid-offset %d", &psid_offset))
12819 else if (unformat (i, "psid-len %d", &psid_length))
12821 else if (unformat (i, "mtu %d", &mtu))
12823 else if (unformat (i, "map-t"))
12824 is_translation = 1;
12827 clib_warning ("parse error '%U'", format_unformat_error, i);
12832 if (num_m_args < 3)
12834 errmsg ("mandatory argument(s) missing");
12838 /* Construct the API message */
12839 M (MAP_ADD_DOMAIN, mp);
12841 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12842 mp->ip4_prefix_len = ip4_prefix_len;
12844 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12845 mp->ip6_prefix_len = ip6_prefix_len;
12847 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12848 mp->ip6_src_prefix_len = ip6_src_len;
12850 mp->ea_bits_len = ea_bits_len;
12851 mp->psid_offset = psid_offset;
12852 mp->psid_length = psid_length;
12853 mp->is_translation = is_translation;
12854 mp->mtu = htons (mtu);
12859 /* Wait for a reply, return good/bad news */
12864 api_map_del_domain (vat_main_t * vam)
12866 unformat_input_t *i = vam->input;
12867 vl_api_map_del_domain_t *mp;
12870 u32 num_m_args = 0;
12873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12875 if (unformat (i, "index %d", &index))
12879 clib_warning ("parse error '%U'", format_unformat_error, i);
12884 if (num_m_args != 1)
12886 errmsg ("mandatory argument(s) missing");
12890 /* Construct the API message */
12891 M (MAP_DEL_DOMAIN, mp);
12893 mp->index = ntohl (index);
12898 /* Wait for a reply, return good/bad news */
12903 api_map_add_del_rule (vat_main_t * vam)
12905 unformat_input_t *i = vam->input;
12906 vl_api_map_add_del_rule_t *mp;
12909 ip6_address_t ip6_dst;
12910 u32 num_m_args = 0, index, psid = 0;
12912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12914 if (unformat (i, "index %d", &index))
12916 else if (unformat (i, "psid %d", &psid))
12918 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12920 else if (unformat (i, "del"))
12926 clib_warning ("parse error '%U'", format_unformat_error, i);
12931 /* Construct the API message */
12932 M (MAP_ADD_DEL_RULE, mp);
12934 mp->index = ntohl (index);
12935 mp->is_add = is_add;
12936 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12937 mp->psid = ntohs (psid);
12942 /* Wait for a reply, return good/bad news */
12947 api_map_domain_dump (vat_main_t * vam)
12949 vl_api_map_domain_dump_t *mp;
12952 /* Construct the API message */
12953 M (MAP_DOMAIN_DUMP, mp);
12958 /* Use a control ping for synchronization */
12960 vl_api_control_ping_t *mp;
12961 M (CONTROL_PING, mp);
12968 api_map_rule_dump (vat_main_t * vam)
12970 unformat_input_t *i = vam->input;
12971 vl_api_map_rule_dump_t *mp;
12973 u32 domain_index = ~0;
12975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12977 if (unformat (i, "index %u", &domain_index))
12983 if (domain_index == ~0)
12985 clib_warning ("parse error: domain index expected");
12989 /* Construct the API message */
12990 M (MAP_RULE_DUMP, mp);
12992 mp->domain_index = htonl (domain_index);
12997 /* Use a control ping for synchronization */
12999 vl_api_control_ping_t *mp;
13000 M (CONTROL_PING, mp);
13006 static void vl_api_map_add_domain_reply_t_handler
13007 (vl_api_map_add_domain_reply_t * mp)
13009 vat_main_t *vam = &vat_main;
13010 i32 retval = ntohl (mp->retval);
13012 if (vam->async_mode)
13014 vam->async_errors += (retval < 0);
13018 vam->retval = retval;
13019 vam->result_ready = 1;
13023 static void vl_api_map_add_domain_reply_t_handler_json
13024 (vl_api_map_add_domain_reply_t * mp)
13026 vat_main_t *vam = &vat_main;
13027 vat_json_node_t node;
13029 vat_json_init_object (&node);
13030 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13031 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13033 vat_json_print (vam->ofp, &node);
13034 vat_json_free (&node);
13036 vam->retval = ntohl (mp->retval);
13037 vam->result_ready = 1;
13041 api_get_first_msg_id (vat_main_t * vam)
13043 vl_api_get_first_msg_id_t *mp;
13045 unformat_input_t *i = vam->input;
13049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13051 if (unformat (i, "client %s", &name))
13059 errmsg ("missing client name");
13062 vec_add1 (name, 0);
13064 if (vec_len (name) > 63)
13066 errmsg ("client name too long");
13070 M (GET_FIRST_MSG_ID, mp);
13071 clib_memcpy (mp->name, name, vec_len (name));
13079 api_cop_interface_enable_disable (vat_main_t * vam)
13081 unformat_input_t *line_input = vam->input;
13082 vl_api_cop_interface_enable_disable_t *mp;
13084 u32 sw_if_index = ~0;
13085 u8 enable_disable = 1;
13087 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13089 if (unformat (line_input, "disable"))
13090 enable_disable = 0;
13091 if (unformat (line_input, "enable"))
13092 enable_disable = 1;
13093 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13094 vam, &sw_if_index))
13096 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13102 if (sw_if_index == ~0)
13104 errmsg ("missing interface name or sw_if_index");
13108 /* Construct the API message */
13109 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13110 mp->sw_if_index = ntohl (sw_if_index);
13111 mp->enable_disable = enable_disable;
13115 /* Wait for the reply */
13120 api_cop_whitelist_enable_disable (vat_main_t * vam)
13122 unformat_input_t *line_input = vam->input;
13123 vl_api_cop_whitelist_enable_disable_t *mp;
13125 u32 sw_if_index = ~0;
13126 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13129 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13131 if (unformat (line_input, "ip4"))
13133 else if (unformat (line_input, "ip6"))
13135 else if (unformat (line_input, "default"))
13137 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13138 vam, &sw_if_index))
13140 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13142 else if (unformat (line_input, "fib-id %d", &fib_id))
13148 if (sw_if_index == ~0)
13150 errmsg ("missing interface name or sw_if_index");
13154 /* Construct the API message */
13155 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13156 mp->sw_if_index = ntohl (sw_if_index);
13157 mp->fib_id = ntohl (fib_id);
13160 mp->default_cop = default_cop;
13164 /* Wait for the reply */
13169 api_get_node_graph (vat_main_t * vam)
13171 vl_api_get_node_graph_t *mp;
13174 M (GET_NODE_GRAPH, mp);
13178 /* Wait for the reply */
13183 /** Used for parsing LISP eids */
13184 typedef CLIB_PACKED(struct{
13185 u8 addr[16]; /**< eid address */
13186 u32 len; /**< prefix length if IP */
13187 u8 type; /**< type of eid */
13192 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13194 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13196 memset (a, 0, sizeof (a[0]));
13198 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13200 a->type = 0; /* ipv4 type */
13202 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13204 a->type = 1; /* ipv6 type */
13206 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13208 a->type = 2; /* mac type */
13215 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13224 lisp_eid_size_vat (u8 type)
13239 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13241 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13245 api_lisp_add_del_locator_set (vat_main_t * vam)
13247 unformat_input_t *input = vam->input;
13248 vl_api_lisp_add_del_locator_set_t *mp;
13251 u8 *locator_set_name = NULL;
13252 u8 locator_set_name_set = 0;
13253 vl_api_local_locator_t locator, *locators = 0;
13254 u32 sw_if_index, priority, weight;
13257 /* Parse args required to build the message */
13258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13260 if (unformat (input, "del"))
13264 else if (unformat (input, "locator-set %s", &locator_set_name))
13266 locator_set_name_set = 1;
13268 else if (unformat (input, "sw_if_index %u p %u w %u",
13269 &sw_if_index, &priority, &weight))
13271 locator.sw_if_index = htonl (sw_if_index);
13272 locator.priority = priority;
13273 locator.weight = weight;
13274 vec_add1 (locators, locator);
13278 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13279 &sw_if_index, &priority, &weight))
13281 locator.sw_if_index = htonl (sw_if_index);
13282 locator.priority = priority;
13283 locator.weight = weight;
13284 vec_add1 (locators, locator);
13290 if (locator_set_name_set == 0)
13292 errmsg ("missing locator-set name");
13293 vec_free (locators);
13297 if (vec_len (locator_set_name) > 64)
13299 errmsg ("locator-set name too long");
13300 vec_free (locator_set_name);
13301 vec_free (locators);
13304 vec_add1 (locator_set_name, 0);
13306 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13308 /* Construct the API message */
13309 M2 (LISP_ADD_DEL_LOCATOR_SET, mp, data_len);
13311 mp->is_add = is_add;
13312 clib_memcpy (mp->locator_set_name, locator_set_name,
13313 vec_len (locator_set_name));
13314 vec_free (locator_set_name);
13316 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13318 clib_memcpy (mp->locators, locators, data_len);
13319 vec_free (locators);
13324 /* Wait for a reply... */
13332 api_lisp_add_del_locator (vat_main_t * vam)
13334 unformat_input_t *input = vam->input;
13335 vl_api_lisp_add_del_locator_t *mp;
13337 u32 tmp_if_index = ~0;
13338 u32 sw_if_index = ~0;
13339 u8 sw_if_index_set = 0;
13340 u8 sw_if_index_if_name_set = 0;
13342 u8 priority_set = 0;
13346 u8 *locator_set_name = NULL;
13347 u8 locator_set_name_set = 0;
13349 /* Parse args required to build the message */
13350 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13352 if (unformat (input, "del"))
13356 else if (unformat (input, "locator-set %s", &locator_set_name))
13358 locator_set_name_set = 1;
13360 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13363 sw_if_index_if_name_set = 1;
13364 sw_if_index = tmp_if_index;
13366 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13368 sw_if_index_set = 1;
13369 sw_if_index = tmp_if_index;
13371 else if (unformat (input, "p %d", &priority))
13375 else if (unformat (input, "w %d", &weight))
13383 if (locator_set_name_set == 0)
13385 errmsg ("missing locator-set name");
13389 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13391 errmsg ("missing sw_if_index");
13392 vec_free (locator_set_name);
13396 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13398 errmsg ("cannot use both params interface name and sw_if_index");
13399 vec_free (locator_set_name);
13403 if (priority_set == 0)
13405 errmsg ("missing locator-set priority");
13406 vec_free (locator_set_name);
13410 if (weight_set == 0)
13412 errmsg ("missing locator-set weight");
13413 vec_free (locator_set_name);
13417 if (vec_len (locator_set_name) > 64)
13419 errmsg ("locator-set name too long");
13420 vec_free (locator_set_name);
13423 vec_add1 (locator_set_name, 0);
13425 /* Construct the API message */
13426 M (LISP_ADD_DEL_LOCATOR, mp);
13428 mp->is_add = is_add;
13429 mp->sw_if_index = ntohl (sw_if_index);
13430 mp->priority = priority;
13431 mp->weight = weight;
13432 clib_memcpy (mp->locator_set_name, locator_set_name,
13433 vec_len (locator_set_name));
13434 vec_free (locator_set_name);
13439 /* Wait for a reply... */
13447 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13449 u32 *key_id = va_arg (*args, u32 *);
13452 if (unformat (input, "%s", &s))
13454 if (!strcmp ((char *) s, "sha1"))
13455 key_id[0] = HMAC_SHA_1_96;
13456 else if (!strcmp ((char *) s, "sha256"))
13457 key_id[0] = HMAC_SHA_256_128;
13460 clib_warning ("invalid key_id: '%s'", s);
13461 key_id[0] = HMAC_NO_KEY;
13472 api_lisp_add_del_local_eid (vat_main_t * vam)
13474 unformat_input_t *input = vam->input;
13475 vl_api_lisp_add_del_local_eid_t *mp;
13479 lisp_eid_vat_t _eid, *eid = &_eid;
13480 u8 *locator_set_name = 0;
13481 u8 locator_set_name_set = 0;
13486 /* Parse args required to build the message */
13487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13489 if (unformat (input, "del"))
13493 else if (unformat (input, "vni %d", &vni))
13497 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13501 else if (unformat (input, "locator-set %s", &locator_set_name))
13503 locator_set_name_set = 1;
13505 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13507 else if (unformat (input, "secret-key %_%v%_", &key))
13513 if (locator_set_name_set == 0)
13515 errmsg ("missing locator-set name");
13521 errmsg ("EID address not set!");
13522 vec_free (locator_set_name);
13526 if (key && (0 == key_id))
13528 errmsg ("invalid key_id!");
13532 if (vec_len (key) > 64)
13534 errmsg ("key too long");
13539 if (vec_len (locator_set_name) > 64)
13541 errmsg ("locator-set name too long");
13542 vec_free (locator_set_name);
13545 vec_add1 (locator_set_name, 0);
13547 /* Construct the API message */
13548 M (LISP_ADD_DEL_LOCAL_EID, mp);
13550 mp->is_add = is_add;
13551 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13552 mp->eid_type = eid->type;
13553 mp->prefix_len = eid->len;
13554 mp->vni = clib_host_to_net_u32 (vni);
13555 mp->key_id = clib_host_to_net_u16 (key_id);
13556 clib_memcpy (mp->locator_set_name, locator_set_name,
13557 vec_len (locator_set_name));
13558 clib_memcpy (mp->key, key, vec_len (key));
13560 vec_free (locator_set_name);
13566 /* Wait for a reply... */
13574 /** Used for transferring locators via VPP API */
13575 typedef CLIB_PACKED(struct
13577 u8 is_ip4; /**< is locator an IPv4 address? */
13578 u8 priority; /**< locator priority */
13579 u8 weight; /**< locator weight */
13580 u8 addr[16]; /**< IPv4/IPv6 address */
13585 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13587 u32 dp_table = 0, vni = 0;;
13588 unformat_input_t *input = vam->input;
13589 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13592 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13593 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13594 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13595 u32 action = ~0, w;
13596 ip4_address_t rmt_rloc4, lcl_rloc4;
13597 ip6_address_t rmt_rloc6, lcl_rloc6;
13598 vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc =
13601 memset (&rloc, 0, sizeof (rloc));
13603 /* Parse args required to build the message */
13604 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13606 if (unformat (input, "del"))
13608 else if (unformat (input, "add"))
13610 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13614 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13618 else if (unformat (input, "vrf %d", &dp_table))
13620 else if (unformat (input, "bd %d", &dp_table))
13622 else if (unformat (input, "vni %d", &vni))
13624 else if (unformat (input, "w %d", &w))
13628 errmsg ("No RLOC configured for setting priority/weight!");
13631 curr_rloc->weight = w;
13633 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13634 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13638 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13640 vec_add1 (lcl_locs, rloc);
13642 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13643 vec_add1 (rmt_locs, rloc);
13644 /* weight saved in rmt loc */
13645 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13647 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13648 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13651 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13653 vec_add1 (lcl_locs, rloc);
13655 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13656 vec_add1 (rmt_locs, rloc);
13657 /* weight saved in rmt loc */
13658 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13660 else if (unformat (input, "action %d", &action))
13666 clib_warning ("parse error '%U'", format_unformat_error, input);
13673 errmsg ("remote eid addresses not set");
13677 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13679 errmsg ("eid types don't match");
13683 if (0 == rmt_locs && (u32) ~ 0 == action)
13685 errmsg ("action not set for negative mapping");
13689 /* Construct the API message */
13690 M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, mp,
13691 sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2);
13693 mp->is_add = is_add;
13694 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13695 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13696 mp->eid_type = rmt_eid->type;
13697 mp->dp_table = clib_host_to_net_u32 (dp_table);
13698 mp->vni = clib_host_to_net_u32 (vni);
13699 mp->rmt_len = rmt_eid->len;
13700 mp->lcl_len = lcl_eid->len;
13701 mp->action = action;
13703 if (0 != rmt_locs && 0 != lcl_locs)
13705 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13706 clib_memcpy (mp->locs, lcl_locs,
13707 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs)));
13709 u32 offset = sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs);
13710 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13711 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs)));
13713 vec_free (lcl_locs);
13714 vec_free (rmt_locs);
13719 /* Wait for a reply... */
13727 api_lisp_add_del_map_server (vat_main_t * vam)
13729 unformat_input_t *input = vam->input;
13730 vl_api_lisp_add_del_map_server_t *mp;
13735 ip4_address_t ipv4;
13736 ip6_address_t ipv6;
13738 /* Parse args required to build the message */
13739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13741 if (unformat (input, "del"))
13745 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13749 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13757 if (ipv4_set && ipv6_set)
13759 errmsg ("both eid v4 and v6 addresses set");
13763 if (!ipv4_set && !ipv6_set)
13765 errmsg ("eid addresses not set");
13769 /* Construct the API message */
13770 M (LISP_ADD_DEL_MAP_SERVER, mp);
13772 mp->is_add = is_add;
13776 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13781 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13787 /* Wait for a reply... */
13795 api_lisp_add_del_map_resolver (vat_main_t * vam)
13797 unformat_input_t *input = vam->input;
13798 vl_api_lisp_add_del_map_resolver_t *mp;
13803 ip4_address_t ipv4;
13804 ip6_address_t ipv6;
13806 /* Parse args required to build the message */
13807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13809 if (unformat (input, "del"))
13813 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13817 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13825 if (ipv4_set && ipv6_set)
13827 errmsg ("both eid v4 and v6 addresses set");
13831 if (!ipv4_set && !ipv6_set)
13833 errmsg ("eid addresses not set");
13837 /* Construct the API message */
13838 M (LISP_ADD_DEL_MAP_RESOLVER, mp);
13840 mp->is_add = is_add;
13844 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13849 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13855 /* Wait for a reply... */
13863 api_lisp_gpe_enable_disable (vat_main_t * vam)
13865 unformat_input_t *input = vam->input;
13866 vl_api_lisp_gpe_enable_disable_t *mp;
13871 /* Parse args required to build the message */
13872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13874 if (unformat (input, "enable"))
13879 else if (unformat (input, "disable"))
13890 errmsg ("Value not set");
13894 /* Construct the API message */
13895 M (LISP_GPE_ENABLE_DISABLE, mp);
13902 /* Wait for a reply... */
13910 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13912 unformat_input_t *input = vam->input;
13913 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13918 /* Parse args required to build the message */
13919 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13921 if (unformat (input, "enable"))
13926 else if (unformat (input, "disable"))
13934 errmsg ("Value not set");
13938 /* Construct the API message */
13939 M (LISP_RLOC_PROBE_ENABLE_DISABLE, mp);
13941 mp->is_enabled = is_en;
13946 /* Wait for a reply... */
13954 api_lisp_map_register_enable_disable (vat_main_t * vam)
13956 unformat_input_t *input = vam->input;
13957 vl_api_lisp_map_register_enable_disable_t *mp;
13962 /* Parse args required to build the message */
13963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13965 if (unformat (input, "enable"))
13970 else if (unformat (input, "disable"))
13978 errmsg ("Value not set");
13982 /* Construct the API message */
13983 M (LISP_MAP_REGISTER_ENABLE_DISABLE, mp);
13985 mp->is_enabled = is_en;
13990 /* Wait for a reply... */
13998 api_lisp_enable_disable (vat_main_t * vam)
14000 unformat_input_t *input = vam->input;
14001 vl_api_lisp_enable_disable_t *mp;
14006 /* Parse args required to build the message */
14007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14009 if (unformat (input, "enable"))
14014 else if (unformat (input, "disable"))
14024 errmsg ("Value not set");
14028 /* Construct the API message */
14029 M (LISP_ENABLE_DISABLE, mp);
14036 /* Wait for a reply... */
14044 api_show_lisp_map_register_state (vat_main_t * vam)
14047 vl_api_show_lisp_map_register_state_t *mp;
14049 M (SHOW_LISP_MAP_REGISTER_STATE, mp);
14054 /* wait for reply */
14061 api_show_lisp_rloc_probe_state (vat_main_t * vam)
14064 vl_api_show_lisp_rloc_probe_state_t *mp;
14066 M (SHOW_LISP_RLOC_PROBE_STATE, mp);
14071 /* wait for reply */
14078 api_show_lisp_map_request_mode (vat_main_t * vam)
14081 vl_api_show_lisp_map_request_mode_t *mp;
14083 M (SHOW_LISP_MAP_REQUEST_MODE, mp);
14088 /* wait for reply */
14095 api_lisp_map_request_mode (vat_main_t * vam)
14098 unformat_input_t *input = vam->input;
14099 vl_api_lisp_map_request_mode_t *mp;
14102 /* Parse args required to build the message */
14103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14105 if (unformat (input, "dst-only"))
14107 else if (unformat (input, "src-dst"))
14111 errmsg ("parse error '%U'", format_unformat_error, input);
14116 M (LISP_MAP_REQUEST_MODE, mp);
14123 /* wait for reply */
14131 * Enable/disable LISP proxy ITR.
14133 * @param vam vpp API test context
14134 * @return return code
14137 api_lisp_pitr_set_locator_set (vat_main_t * vam)
14140 u8 ls_name_set = 0;
14141 unformat_input_t *input = vam->input;
14142 vl_api_lisp_pitr_set_locator_set_t *mp;
14146 /* Parse args required to build the message */
14147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14149 if (unformat (input, "del"))
14151 else if (unformat (input, "locator-set %s", &ls_name))
14155 errmsg ("parse error '%U'", format_unformat_error, input);
14162 errmsg ("locator-set name not set!");
14166 M (LISP_PITR_SET_LOCATOR_SET, mp);
14168 mp->is_add = is_add;
14169 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14170 vec_free (ls_name);
14175 /* wait for reply */
14183 api_show_lisp_pitr (vat_main_t * vam)
14185 vl_api_show_lisp_pitr_t *mp;
14188 if (!vam->json_output)
14190 print (vam->ofp, "%=20s", "lisp status:");
14193 M (SHOW_LISP_PITR, mp);
14197 /* Wait for a reply... */
14205 * Add/delete mapping between vni and vrf
14208 api_lisp_eid_table_add_del_map (vat_main_t * vam)
14211 unformat_input_t *input = vam->input;
14212 vl_api_lisp_eid_table_add_del_map_t *mp;
14213 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14214 u32 vni, vrf, bd_index;
14216 /* Parse args required to build the message */
14217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14219 if (unformat (input, "del"))
14221 else if (unformat (input, "vrf %d", &vrf))
14223 else if (unformat (input, "bd_index %d", &bd_index))
14225 else if (unformat (input, "vni %d", &vni))
14231 if (!vni_set || (!vrf_set && !bd_index_set))
14233 errmsg ("missing arguments!");
14237 if (vrf_set && bd_index_set)
14239 errmsg ("error: both vrf and bd entered!");
14243 M (LISP_EID_TABLE_ADD_DEL_MAP, mp);
14245 mp->is_add = is_add;
14246 mp->vni = htonl (vni);
14247 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14248 mp->is_l2 = bd_index_set;
14253 /* wait for reply */
14261 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14263 u32 *action = va_arg (*args, u32 *);
14266 if (unformat (input, "%s", &s))
14268 if (!strcmp ((char *) s, "no-action"))
14270 else if (!strcmp ((char *) s, "natively-forward"))
14272 else if (!strcmp ((char *) s, "send-map-request"))
14274 else if (!strcmp ((char *) s, "drop"))
14278 clib_warning ("invalid action: '%s'", s);
14290 * Add/del remote mapping to/from LISP control plane
14292 * @param vam vpp API test context
14293 * @return return code
14296 api_lisp_add_del_remote_mapping (vat_main_t * vam)
14298 unformat_input_t *input = vam->input;
14299 vl_api_lisp_add_del_remote_mapping_t *mp;
14302 lisp_eid_vat_t _eid, *eid = &_eid;
14303 lisp_eid_vat_t _seid, *seid = &_seid;
14304 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14305 u32 action = ~0, p, w, data_len;
14306 ip4_address_t rloc4;
14307 ip6_address_t rloc6;
14308 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14310 memset (&rloc, 0, sizeof (rloc));
14312 /* Parse args required to build the message */
14313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14315 if (unformat (input, "del-all"))
14319 else if (unformat (input, "del"))
14323 else if (unformat (input, "add"))
14327 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14331 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14335 else if (unformat (input, "vni %d", &vni))
14339 else if (unformat (input, "p %d w %d", &p, &w))
14343 errmsg ("No RLOC configured for setting priority/weight!");
14346 curr_rloc->priority = p;
14347 curr_rloc->weight = w;
14349 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14352 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14353 vec_add1 (rlocs, rloc);
14354 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14356 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14359 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14360 vec_add1 (rlocs, rloc);
14361 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14363 else if (unformat (input, "action %U",
14364 unformat_negative_mapping_action, &action))
14370 clib_warning ("parse error '%U'", format_unformat_error, input);
14377 errmsg ("missing params!");
14381 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14383 errmsg ("no action set for negative map-reply!");
14387 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14389 M2 (LISP_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14390 mp->is_add = is_add;
14391 mp->vni = htonl (vni);
14392 mp->action = (u8) action;
14393 mp->is_src_dst = seid_set;
14394 mp->eid_len = eid->len;
14395 mp->seid_len = seid->len;
14396 mp->del_all = del_all;
14397 mp->eid_type = eid->type;
14398 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14399 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14401 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14402 clib_memcpy (mp->rlocs, rlocs, data_len);
14408 /* Wait for a reply... */
14416 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14417 * forwarding entries in data-plane accordingly.
14419 * @param vam vpp API test context
14420 * @return return code
14423 api_lisp_add_del_adjacency (vat_main_t * vam)
14425 unformat_input_t *input = vam->input;
14426 vl_api_lisp_add_del_adjacency_t *mp;
14429 ip4_address_t leid4, reid4;
14430 ip6_address_t leid6, reid6;
14431 u8 reid_mac[6] = { 0 };
14432 u8 leid_mac[6] = { 0 };
14433 u8 reid_type, leid_type;
14434 u32 leid_len = 0, reid_len = 0, len;
14437 leid_type = reid_type = (u8) ~ 0;
14439 /* Parse args required to build the message */
14440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14442 if (unformat (input, "del"))
14446 else if (unformat (input, "add"))
14450 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14453 reid_type = 0; /* ipv4 */
14456 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14459 reid_type = 1; /* ipv6 */
14462 else if (unformat (input, "reid %U", unformat_ethernet_address,
14465 reid_type = 2; /* mac */
14467 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14470 leid_type = 0; /* ipv4 */
14473 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14476 leid_type = 1; /* ipv6 */
14479 else if (unformat (input, "leid %U", unformat_ethernet_address,
14482 leid_type = 2; /* mac */
14484 else if (unformat (input, "vni %d", &vni))
14490 errmsg ("parse error '%U'", format_unformat_error, input);
14495 if ((u8) ~ 0 == reid_type)
14497 errmsg ("missing params!");
14501 if (leid_type != reid_type)
14503 errmsg ("remote and local EIDs are of different types!");
14507 M (LISP_ADD_DEL_ADJACENCY, mp);
14508 mp->is_add = is_add;
14509 mp->vni = htonl (vni);
14510 mp->leid_len = leid_len;
14511 mp->reid_len = reid_len;
14512 mp->eid_type = reid_type;
14514 switch (mp->eid_type)
14517 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14518 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14521 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14522 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14525 clib_memcpy (mp->leid, leid_mac, 6);
14526 clib_memcpy (mp->reid, reid_mac, 6);
14529 errmsg ("unknown EID type %d!", mp->eid_type);
14536 /* Wait for a reply... */
14544 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14546 unformat_input_t *input = vam->input;
14547 vl_api_lisp_gpe_add_del_iface_t *mp;
14549 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14550 u32 dp_table = 0, vni = 0;
14552 /* Parse args required to build the message */
14553 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14555 if (unformat (input, "up"))
14560 else if (unformat (input, "down"))
14565 else if (unformat (input, "table_id %d", &dp_table))
14569 else if (unformat (input, "bd_id %d", &dp_table))
14574 else if (unformat (input, "vni %d", &vni))
14582 if (action_set == 0)
14584 errmsg ("Action not set");
14587 if (dp_table_set == 0 || vni_set == 0)
14589 errmsg ("vni and dp_table must be set");
14593 /* Construct the API message */
14594 M (LISP_GPE_ADD_DEL_IFACE, mp);
14596 mp->is_add = is_add;
14597 mp->dp_table = dp_table;
14604 /* Wait for a reply... */
14612 * Add/del map request itr rlocs from LISP control plane and updates
14614 * @param vam vpp API test context
14615 * @return return code
14618 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14620 unformat_input_t *input = vam->input;
14621 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14623 u8 *locator_set_name = 0;
14624 u8 locator_set_name_set = 0;
14627 /* Parse args required to build the message */
14628 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14630 if (unformat (input, "del"))
14634 else if (unformat (input, "%_%v%_", &locator_set_name))
14636 locator_set_name_set = 1;
14640 clib_warning ("parse error '%U'", format_unformat_error, input);
14645 if (is_add && !locator_set_name_set)
14647 errmsg ("itr-rloc is not set!");
14651 if (is_add && vec_len (locator_set_name) > 64)
14653 errmsg ("itr-rloc locator-set name too long");
14654 vec_free (locator_set_name);
14658 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14659 mp->is_add = is_add;
14662 clib_memcpy (mp->locator_set_name, locator_set_name,
14663 vec_len (locator_set_name));
14667 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14669 vec_free (locator_set_name);
14674 /* Wait for a reply... */
14682 api_lisp_locator_dump (vat_main_t * vam)
14684 unformat_input_t *input = vam->input;
14685 vl_api_lisp_locator_dump_t *mp;
14687 u8 is_index_set = 0, is_name_set = 0;
14691 /* Parse args required to build the message */
14692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14694 if (unformat (input, "ls_name %_%v%_", &ls_name))
14698 else if (unformat (input, "ls_index %d", &ls_index))
14704 errmsg ("parse error '%U'", format_unformat_error, input);
14709 if (!is_index_set && !is_name_set)
14711 errmsg ("error: expected one of index or name!");
14715 if (is_index_set && is_name_set)
14717 errmsg ("error: only one param expected!");
14721 if (vec_len (ls_name) > 62)
14723 errmsg ("error: locator set name too long!");
14727 if (!vam->json_output)
14729 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14732 M (LISP_LOCATOR_DUMP, mp);
14733 mp->is_index_set = is_index_set;
14736 mp->ls_index = clib_host_to_net_u32 (ls_index);
14739 vec_add1 (ls_name, 0);
14740 strncpy ((char *) mp->ls_name, (char *) ls_name,
14741 sizeof (mp->ls_name) - 1);
14747 /* Use a control ping for synchronization */
14749 vl_api_control_ping_t *mp;
14750 M (CONTROL_PING, mp);
14753 /* Wait for a reply... */
14761 api_lisp_locator_set_dump (vat_main_t * vam)
14763 vl_api_lisp_locator_set_dump_t *mp;
14764 unformat_input_t *input = vam->input;
14768 /* Parse args required to build the message */
14769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14771 if (unformat (input, "local"))
14775 else if (unformat (input, "remote"))
14781 errmsg ("parse error '%U'", format_unformat_error, input);
14786 if (!vam->json_output)
14788 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14791 M (LISP_LOCATOR_SET_DUMP, mp);
14793 mp->filter = filter;
14798 /* Use a control ping for synchronization */
14800 vl_api_control_ping_t *mp;
14801 M (CONTROL_PING, mp);
14804 /* Wait for a reply... */
14812 api_lisp_eid_table_map_dump (vat_main_t * vam)
14816 unformat_input_t *input = vam->input;
14817 vl_api_lisp_eid_table_map_dump_t *mp;
14820 /* Parse args required to build the message */
14821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14823 if (unformat (input, "l2"))
14828 else if (unformat (input, "l3"))
14835 errmsg ("parse error '%U'", format_unformat_error, input);
14842 errmsg ("expected one of 'l2' or 'l3' parameter!");
14846 if (!vam->json_output)
14848 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14851 M (LISP_EID_TABLE_MAP_DUMP, mp);
14857 /* Use a control ping for synchronization */
14859 vl_api_control_ping_t *mp;
14860 M (CONTROL_PING, mp);
14863 /* Wait for a reply... */
14871 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14873 vl_api_lisp_eid_table_vni_dump_t *mp;
14876 if (!vam->json_output)
14878 print (vam->ofp, "VNI");
14881 M (LISP_EID_TABLE_VNI_DUMP, mp);
14886 /* Use a control ping for synchronization */
14888 vl_api_control_ping_t *mp;
14889 M (CONTROL_PING, mp);
14892 /* Wait for a reply... */
14900 api_lisp_eid_table_dump (vat_main_t * vam)
14902 unformat_input_t *i = vam->input;
14903 vl_api_lisp_eid_table_dump_t *mp;
14905 struct in_addr ip4;
14906 struct in6_addr ip6;
14908 u8 eid_type = ~0, eid_set = 0;
14909 u32 prefix_length = ~0, t, vni = 0;
14912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14914 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14920 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14926 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14931 else if (unformat (i, "vni %d", &t))
14935 else if (unformat (i, "local"))
14939 else if (unformat (i, "remote"))
14945 errmsg ("parse error '%U'", format_unformat_error, i);
14950 if (!vam->json_output)
14952 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14953 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14956 M (LISP_EID_TABLE_DUMP, mp);
14958 mp->filter = filter;
14962 mp->vni = htonl (vni);
14963 mp->eid_type = eid_type;
14967 mp->prefix_length = prefix_length;
14968 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14971 mp->prefix_length = prefix_length;
14972 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14975 clib_memcpy (mp->eid, mac, sizeof (mac));
14978 errmsg ("unknown EID type %d!", eid_type);
14986 /* Use a control ping for synchronization */
14988 vl_api_control_ping_t *mp;
14989 M (CONTROL_PING, mp);
14993 /* Wait for a reply... */
15001 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15003 unformat_input_t *i = vam->input;
15004 vl_api_lisp_gpe_fwd_entries_get_t *mp;
15009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15011 if (unformat (i, "vni %d", &vni))
15017 errmsg ("parse error '%U'", format_unformat_error, i);
15024 errmsg ("vni not set!");
15028 if (!vam->json_output)
15030 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15034 M (LISP_GPE_FWD_ENTRIES_GET, mp);
15035 mp->vni = clib_host_to_net_u32 (vni);
15040 /* Wait for a reply... */
15047 #define vl_api_lisp_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15048 #define vl_api_lisp_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15049 #define vl_api_lisp_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15050 #define vl_api_lisp_gpe_fwd_entry_path_details_t_print vl_noop_handler
15053 api_lisp_adjacencies_get (vat_main_t * vam)
15055 unformat_input_t *i = vam->input;
15056 vl_api_lisp_adjacencies_get_t *mp;
15061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15063 if (unformat (i, "vni %d", &vni))
15069 errmsg ("parse error '%U'", format_unformat_error, i);
15076 errmsg ("vni not set!");
15080 if (!vam->json_output)
15082 print (vam->ofp, "%s %40s", "leid", "reid");
15085 M (LISP_ADJACENCIES_GET, mp);
15086 mp->vni = clib_host_to_net_u32 (vni);
15091 /* Wait for a reply... */
15099 api_lisp_map_server_dump (vat_main_t * vam)
15101 vl_api_lisp_map_server_dump_t *mp;
15104 if (!vam->json_output)
15106 print (vam->ofp, "%=20s", "Map server");
15109 M (LISP_MAP_SERVER_DUMP, mp);
15113 /* Use a control ping for synchronization */
15115 vl_api_control_ping_t *mp;
15116 M (CONTROL_PING, mp);
15119 /* Wait for a reply... */
15127 api_lisp_map_resolver_dump (vat_main_t * vam)
15129 vl_api_lisp_map_resolver_dump_t *mp;
15132 if (!vam->json_output)
15134 print (vam->ofp, "%=20s", "Map resolver");
15137 M (LISP_MAP_RESOLVER_DUMP, mp);
15141 /* Use a control ping for synchronization */
15143 vl_api_control_ping_t *mp;
15144 M (CONTROL_PING, mp);
15147 /* Wait for a reply... */
15155 api_show_lisp_status (vat_main_t * vam)
15157 vl_api_show_lisp_status_t *mp;
15160 if (!vam->json_output)
15162 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
15165 M (SHOW_LISP_STATUS, mp);
15168 /* Wait for a reply... */
15176 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15178 vl_api_lisp_gpe_fwd_entry_path_dump_t *mp;
15180 unformat_input_t *i = vam->input;
15181 u32 fwd_entry_index = ~0;
15183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15185 if (unformat (i, "index %d", &fwd_entry_index))
15191 if (~0 == fwd_entry_index)
15193 errmsg ("no index specified!");
15197 if (!vam->json_output)
15199 print (vam->ofp, "first line");
15202 M (LISP_GPE_FWD_ENTRY_PATH_DUMP, mp);
15206 /* Use a control ping for synchronization */
15208 vl_api_control_ping_t *mp;
15209 M (CONTROL_PING, mp);
15212 /* Wait for a reply... */
15220 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
15222 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
15225 if (!vam->json_output)
15227 print (vam->ofp, "%=20s", "itr-rlocs:");
15230 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, mp);
15233 /* Wait for a reply... */
15241 api_af_packet_create (vat_main_t * vam)
15243 unformat_input_t *i = vam->input;
15244 vl_api_af_packet_create_t *mp;
15246 u8 *host_if_name = 0;
15248 u8 random_hw_addr = 1;
15250 memset (hw_addr, 0, sizeof (hw_addr));
15252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15254 if (unformat (i, "name %s", &host_if_name))
15255 vec_add1 (host_if_name, 0);
15256 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15257 random_hw_addr = 0;
15262 if (!vec_len (host_if_name))
15264 errmsg ("host-interface name must be specified");
15268 if (vec_len (host_if_name) > 64)
15270 errmsg ("host-interface name too long");
15274 M (AF_PACKET_CREATE, mp);
15276 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15277 clib_memcpy (mp->hw_addr, hw_addr, 6);
15278 mp->use_random_hw_addr = random_hw_addr;
15279 vec_free (host_if_name);
15282 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15288 api_af_packet_delete (vat_main_t * vam)
15290 unformat_input_t *i = vam->input;
15291 vl_api_af_packet_delete_t *mp;
15293 u8 *host_if_name = 0;
15295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15297 if (unformat (i, "name %s", &host_if_name))
15298 vec_add1 (host_if_name, 0);
15303 if (!vec_len (host_if_name))
15305 errmsg ("host-interface name must be specified");
15309 if (vec_len (host_if_name) > 64)
15311 errmsg ("host-interface name too long");
15315 M (AF_PACKET_DELETE, mp);
15317 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15318 vec_free (host_if_name);
15327 api_policer_add_del (vat_main_t * vam)
15329 unformat_input_t *i = vam->input;
15330 vl_api_policer_add_del_t *mp;
15341 u8 color_aware = 0;
15342 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15344 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15345 conform_action.dscp = 0;
15346 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15347 exceed_action.dscp = 0;
15348 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15349 violate_action.dscp = 0;
15351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15353 if (unformat (i, "del"))
15355 else if (unformat (i, "name %s", &name))
15356 vec_add1 (name, 0);
15357 else if (unformat (i, "cir %u", &cir))
15359 else if (unformat (i, "eir %u", &eir))
15361 else if (unformat (i, "cb %u", &cb))
15363 else if (unformat (i, "eb %u", &eb))
15365 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15368 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15371 else if (unformat (i, "type %U", unformat_policer_type, &type))
15373 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15376 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15379 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15382 else if (unformat (i, "color-aware"))
15388 if (!vec_len (name))
15390 errmsg ("policer name must be specified");
15394 if (vec_len (name) > 64)
15396 errmsg ("policer name too long");
15400 M (POLICER_ADD_DEL, mp);
15402 clib_memcpy (mp->name, name, vec_len (name));
15404 mp->is_add = is_add;
15409 mp->rate_type = rate_type;
15410 mp->round_type = round_type;
15412 mp->conform_action_type = conform_action.action_type;
15413 mp->conform_dscp = conform_action.dscp;
15414 mp->exceed_action_type = exceed_action.action_type;
15415 mp->exceed_dscp = exceed_action.dscp;
15416 mp->violate_action_type = violate_action.action_type;
15417 mp->violate_dscp = violate_action.dscp;
15418 mp->color_aware = color_aware;
15427 api_policer_dump (vat_main_t * vam)
15429 unformat_input_t *i = vam->input;
15430 vl_api_policer_dump_t *mp;
15432 u8 *match_name = 0;
15433 u8 match_name_valid = 0;
15435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15437 if (unformat (i, "name %s", &match_name))
15439 vec_add1 (match_name, 0);
15440 match_name_valid = 1;
15446 M (POLICER_DUMP, mp);
15447 mp->match_name_valid = match_name_valid;
15448 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15449 vec_free (match_name);
15453 /* Use a control ping for synchronization */
15455 vl_api_control_ping_t *mp;
15456 M (CONTROL_PING, mp);
15459 /* Wait for a reply... */
15467 api_policer_classify_set_interface (vat_main_t * vam)
15469 unformat_input_t *i = vam->input;
15470 vl_api_policer_classify_set_interface_t *mp;
15473 int sw_if_index_set;
15474 u32 ip4_table_index = ~0;
15475 u32 ip6_table_index = ~0;
15476 u32 l2_table_index = ~0;
15479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15482 sw_if_index_set = 1;
15483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15484 sw_if_index_set = 1;
15485 else if (unformat (i, "del"))
15487 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15489 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15491 else if (unformat (i, "l2-table %d", &l2_table_index))
15495 clib_warning ("parse error '%U'", format_unformat_error, i);
15500 if (sw_if_index_set == 0)
15502 errmsg ("missing interface name or sw_if_index");
15506 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15508 mp->sw_if_index = ntohl (sw_if_index);
15509 mp->ip4_table_index = ntohl (ip4_table_index);
15510 mp->ip6_table_index = ntohl (ip6_table_index);
15511 mp->l2_table_index = ntohl (l2_table_index);
15512 mp->is_add = is_add;
15521 api_policer_classify_dump (vat_main_t * vam)
15523 unformat_input_t *i = vam->input;
15524 vl_api_policer_classify_dump_t *mp;
15526 u8 type = POLICER_CLASSIFY_N_TABLES;
15528 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15532 errmsg ("classify table type must be specified");
15536 if (!vam->json_output)
15538 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15541 M (POLICER_CLASSIFY_DUMP, mp);
15546 /* Use a control ping for synchronization */
15548 vl_api_control_ping_t *mp;
15549 M (CONTROL_PING, mp);
15552 /* Wait for a reply... */
15560 api_netmap_create (vat_main_t * vam)
15562 unformat_input_t *i = vam->input;
15563 vl_api_netmap_create_t *mp;
15567 u8 random_hw_addr = 1;
15571 memset (hw_addr, 0, sizeof (hw_addr));
15573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15575 if (unformat (i, "name %s", &if_name))
15576 vec_add1 (if_name, 0);
15577 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15578 random_hw_addr = 0;
15579 else if (unformat (i, "pipe"))
15581 else if (unformat (i, "master"))
15583 else if (unformat (i, "slave"))
15589 if (!vec_len (if_name))
15591 errmsg ("interface name must be specified");
15595 if (vec_len (if_name) > 64)
15597 errmsg ("interface name too long");
15601 M (NETMAP_CREATE, mp);
15603 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15604 clib_memcpy (mp->hw_addr, hw_addr, 6);
15605 mp->use_random_hw_addr = random_hw_addr;
15606 mp->is_pipe = is_pipe;
15607 mp->is_master = is_master;
15608 vec_free (if_name);
15617 api_netmap_delete (vat_main_t * vam)
15619 unformat_input_t *i = vam->input;
15620 vl_api_netmap_delete_t *mp;
15624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15626 if (unformat (i, "name %s", &if_name))
15627 vec_add1 (if_name, 0);
15632 if (!vec_len (if_name))
15634 errmsg ("interface name must be specified");
15638 if (vec_len (if_name) > 64)
15640 errmsg ("interface name too long");
15644 M (NETMAP_DELETE, mp);
15646 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15647 vec_free (if_name);
15655 static void vl_api_mpls_tunnel_details_t_handler
15656 (vl_api_mpls_tunnel_details_t * mp)
15658 vat_main_t *vam = &vat_main;
15659 i32 len = mp->mt_next_hop_n_labels;
15662 print (vam->ofp, "[%d]: via %U %d labels ",
15664 format_ip4_address, mp->mt_next_hop,
15665 ntohl (mp->mt_next_hop_sw_if_index));
15666 for (i = 0; i < len; i++)
15668 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15670 print (vam->ofp, "");
15673 static void vl_api_mpls_tunnel_details_t_handler_json
15674 (vl_api_mpls_tunnel_details_t * mp)
15676 vat_main_t *vam = &vat_main;
15677 vat_json_node_t *node = NULL;
15678 struct in_addr ip4;
15680 i32 len = mp->mt_next_hop_n_labels;
15682 if (VAT_JSON_ARRAY != vam->json_tree.type)
15684 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15685 vat_json_init_array (&vam->json_tree);
15687 node = vat_json_array_add (&vam->json_tree);
15689 vat_json_init_object (node);
15690 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15691 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15692 vat_json_object_add_ip4 (node, "next_hop", ip4);
15693 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15694 ntohl (mp->mt_next_hop_sw_if_index));
15695 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15696 vat_json_object_add_uint (node, "label_count", len);
15697 for (i = 0; i < len; i++)
15699 vat_json_object_add_uint (node, "label",
15700 ntohl (mp->mt_next_hop_out_labels[i]));
15705 api_mpls_tunnel_dump (vat_main_t * vam)
15707 vl_api_mpls_tunnel_dump_t *mp;
15711 /* Parse args required to build the message */
15712 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15714 if (!unformat (vam->input, "tunnel_index %d", &index))
15721 print (vam->ofp, " tunnel_index %d", index);
15723 M (MPLS_TUNNEL_DUMP, mp);
15724 mp->tunnel_index = htonl (index);
15727 /* Use a control ping for synchronization */
15729 vl_api_control_ping_t *mp;
15730 M (CONTROL_PING, mp);
15736 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15737 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15740 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15742 vat_main_t *vam = &vat_main;
15743 int count = ntohl (mp->count);
15744 vl_api_fib_path2_t *fp;
15748 "table-id %d, label %u, ess_bit %u",
15749 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15751 for (i = 0; i < count; i++)
15753 if (fp->afi == IP46_TYPE_IP6)
15755 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15756 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15757 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15758 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15759 format_ip6_address, fp->next_hop);
15760 else if (fp->afi == IP46_TYPE_IP4)
15762 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15763 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15764 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15765 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15766 format_ip4_address, fp->next_hop);
15771 static void vl_api_mpls_fib_details_t_handler_json
15772 (vl_api_mpls_fib_details_t * mp)
15774 vat_main_t *vam = &vat_main;
15775 int count = ntohl (mp->count);
15776 vat_json_node_t *node = NULL;
15777 struct in_addr ip4;
15778 struct in6_addr ip6;
15779 vl_api_fib_path2_t *fp;
15782 if (VAT_JSON_ARRAY != vam->json_tree.type)
15784 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15785 vat_json_init_array (&vam->json_tree);
15787 node = vat_json_array_add (&vam->json_tree);
15789 vat_json_init_object (node);
15790 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15791 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15792 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15793 vat_json_object_add_uint (node, "path_count", count);
15795 for (i = 0; i < count; i++)
15797 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15798 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15799 vat_json_object_add_uint (node, "is_local", fp->is_local);
15800 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15801 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15802 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15803 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15804 if (fp->afi == IP46_TYPE_IP4)
15806 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15807 vat_json_object_add_ip4 (node, "next_hop", ip4);
15809 else if (fp->afi == IP46_TYPE_IP6)
15811 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15812 vat_json_object_add_ip6 (node, "next_hop", ip6);
15818 api_mpls_fib_dump (vat_main_t * vam)
15820 vl_api_mpls_fib_dump_t *mp;
15823 M (MPLS_FIB_DUMP, mp);
15826 /* Use a control ping for synchronization */
15828 vl_api_control_ping_t *mp;
15829 M (CONTROL_PING, mp);
15835 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15836 #define vl_api_ip_fib_details_t_print vl_noop_handler
15839 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15841 vat_main_t *vam = &vat_main;
15842 int count = ntohl (mp->count);
15843 vl_api_fib_path_t *fp;
15847 "table-id %d, prefix %U/%d",
15848 ntohl (mp->table_id), format_ip4_address, mp->address,
15849 mp->address_length);
15851 for (i = 0; i < count; i++)
15853 if (fp->afi == IP46_TYPE_IP6)
15855 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15856 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15857 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15858 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15859 format_ip6_address, fp->next_hop);
15860 else if (fp->afi == IP46_TYPE_IP4)
15862 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15863 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15864 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15865 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15866 format_ip4_address, fp->next_hop);
15871 static void vl_api_ip_fib_details_t_handler_json
15872 (vl_api_ip_fib_details_t * mp)
15874 vat_main_t *vam = &vat_main;
15875 int count = ntohl (mp->count);
15876 vat_json_node_t *node = NULL;
15877 struct in_addr ip4;
15878 struct in6_addr ip6;
15879 vl_api_fib_path_t *fp;
15882 if (VAT_JSON_ARRAY != vam->json_tree.type)
15884 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15885 vat_json_init_array (&vam->json_tree);
15887 node = vat_json_array_add (&vam->json_tree);
15889 vat_json_init_object (node);
15890 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15891 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15892 vat_json_object_add_ip4 (node, "prefix", ip4);
15893 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15894 vat_json_object_add_uint (node, "path_count", count);
15896 for (i = 0; i < count; i++)
15898 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15899 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15900 vat_json_object_add_uint (node, "is_local", fp->is_local);
15901 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15902 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15903 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15904 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15905 if (fp->afi == IP46_TYPE_IP4)
15907 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15908 vat_json_object_add_ip4 (node, "next_hop", ip4);
15910 else if (fp->afi == IP46_TYPE_IP6)
15912 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15913 vat_json_object_add_ip6 (node, "next_hop", ip6);
15919 api_ip_fib_dump (vat_main_t * vam)
15921 vl_api_ip_fib_dump_t *mp;
15924 M (IP_FIB_DUMP, mp);
15927 /* Use a control ping for synchronization */
15929 vl_api_control_ping_t *mp;
15930 M (CONTROL_PING, mp);
15936 static void vl_api_ip_neighbor_details_t_handler
15937 (vl_api_ip_neighbor_details_t * mp)
15939 vat_main_t *vam = &vat_main;
15941 print (vam->ofp, "%c %U %U",
15942 (mp->is_static) ? 'S' : 'D',
15943 format_ethernet_address, &mp->mac_address,
15944 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15948 static void vl_api_ip_neighbor_details_t_handler_json
15949 (vl_api_ip_neighbor_details_t * mp)
15952 vat_main_t *vam = &vat_main;
15953 vat_json_node_t *node;
15954 struct in_addr ip4;
15955 struct in6_addr ip6;
15957 if (VAT_JSON_ARRAY != vam->json_tree.type)
15959 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15960 vat_json_init_array (&vam->json_tree);
15962 node = vat_json_array_add (&vam->json_tree);
15964 vat_json_init_object (node);
15965 vat_json_object_add_string_copy (node, "flag",
15966 (mp->is_static) ? (u8 *) "static" : (u8 *)
15969 vat_json_object_add_string_copy (node, "link_layer",
15970 format (0, "%U", format_ethernet_address,
15971 &mp->mac_address));
15975 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15976 vat_json_object_add_ip6 (node, "ip_address", ip6);
15980 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15981 vat_json_object_add_ip4 (node, "ip_address", ip4);
15986 api_ip_neighbor_dump (vat_main_t * vam)
15988 unformat_input_t *i = vam->input;
15989 vl_api_ip_neighbor_dump_t *mp;
15992 u32 sw_if_index = ~0;
15994 /* Parse args required to build the message */
15995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15997 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15999 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16001 else if (unformat (i, "ip6"))
16007 if (sw_if_index == ~0)
16009 errmsg ("missing interface name or sw_if_index");
16013 M (IP_NEIGHBOR_DUMP, mp);
16014 mp->is_ipv6 = (u8) is_ipv6;
16015 mp->sw_if_index = ntohl (sw_if_index);
16018 /* Use a control ping for synchronization */
16020 vl_api_control_ping_t *mp;
16021 M (CONTROL_PING, mp);
16027 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16028 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16031 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16033 vat_main_t *vam = &vat_main;
16034 int count = ntohl (mp->count);
16035 vl_api_fib_path_t *fp;
16039 "table-id %d, prefix %U/%d",
16040 ntohl (mp->table_id), format_ip6_address, mp->address,
16041 mp->address_length);
16043 for (i = 0; i < count; i++)
16045 if (fp->afi == IP46_TYPE_IP6)
16047 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16048 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16049 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16050 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16051 format_ip6_address, fp->next_hop);
16052 else if (fp->afi == IP46_TYPE_IP4)
16054 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16055 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16056 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16057 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16058 format_ip4_address, fp->next_hop);
16063 static void vl_api_ip6_fib_details_t_handler_json
16064 (vl_api_ip6_fib_details_t * mp)
16066 vat_main_t *vam = &vat_main;
16067 int count = ntohl (mp->count);
16068 vat_json_node_t *node = NULL;
16069 struct in_addr ip4;
16070 struct in6_addr ip6;
16071 vl_api_fib_path_t *fp;
16074 if (VAT_JSON_ARRAY != vam->json_tree.type)
16076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16077 vat_json_init_array (&vam->json_tree);
16079 node = vat_json_array_add (&vam->json_tree);
16081 vat_json_init_object (node);
16082 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16083 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16084 vat_json_object_add_ip6 (node, "prefix", ip6);
16085 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16086 vat_json_object_add_uint (node, "path_count", count);
16088 for (i = 0; i < count; i++)
16090 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16091 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16092 vat_json_object_add_uint (node, "is_local", fp->is_local);
16093 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16094 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16095 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16096 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16097 if (fp->afi == IP46_TYPE_IP4)
16099 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16100 vat_json_object_add_ip4 (node, "next_hop", ip4);
16102 else if (fp->afi == IP46_TYPE_IP6)
16104 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16105 vat_json_object_add_ip6 (node, "next_hop", ip6);
16111 api_ip6_fib_dump (vat_main_t * vam)
16113 vl_api_ip6_fib_dump_t *mp;
16116 M (IP6_FIB_DUMP, mp);
16119 /* Use a control ping for synchronization */
16121 vl_api_control_ping_t *mp;
16122 M (CONTROL_PING, mp);
16129 api_classify_table_ids (vat_main_t * vam)
16131 vl_api_classify_table_ids_t *mp;
16134 /* Construct the API message */
16135 M (CLASSIFY_TABLE_IDS, mp);
16145 api_classify_table_by_interface (vat_main_t * vam)
16147 unformat_input_t *input = vam->input;
16148 vl_api_classify_table_by_interface_t *mp;
16151 u32 sw_if_index = ~0;
16152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16154 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16156 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16161 if (sw_if_index == ~0)
16163 errmsg ("missing interface name or sw_if_index");
16167 /* Construct the API message */
16168 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16170 mp->sw_if_index = ntohl (sw_if_index);
16179 api_classify_table_info (vat_main_t * vam)
16181 unformat_input_t *input = vam->input;
16182 vl_api_classify_table_info_t *mp;
16186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16188 if (unformat (input, "table_id %d", &table_id))
16193 if (table_id == ~0)
16195 errmsg ("missing table id");
16199 /* Construct the API message */
16200 M (CLASSIFY_TABLE_INFO, mp);
16202 mp->table_id = ntohl (table_id);
16211 api_classify_session_dump (vat_main_t * vam)
16213 unformat_input_t *input = vam->input;
16214 vl_api_classify_session_dump_t *mp;
16218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16220 if (unformat (input, "table_id %d", &table_id))
16225 if (table_id == ~0)
16227 errmsg ("missing table id");
16231 /* Construct the API message */
16232 M (CLASSIFY_SESSION_DUMP, mp);
16234 mp->table_id = ntohl (table_id);
16237 /* Use a control ping for synchronization */
16239 vl_api_control_ping_t *mp;
16240 M (CONTROL_PING, mp);
16249 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16251 vat_main_t *vam = &vat_main;
16253 print (vam->ofp, "collector_address %U, collector_port %d, "
16254 "src_address %U, vrf_id %d, path_mtu %u, "
16255 "template_interval %u, udp_checksum %d",
16256 format_ip4_address, mp->collector_address,
16257 ntohs (mp->collector_port),
16258 format_ip4_address, mp->src_address,
16259 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16260 ntohl (mp->template_interval), mp->udp_checksum);
16263 vam->result_ready = 1;
16267 vl_api_ipfix_exporter_details_t_handler_json
16268 (vl_api_ipfix_exporter_details_t * mp)
16270 vat_main_t *vam = &vat_main;
16271 vat_json_node_t node;
16272 struct in_addr collector_address;
16273 struct in_addr src_address;
16275 vat_json_init_object (&node);
16276 clib_memcpy (&collector_address, &mp->collector_address,
16277 sizeof (collector_address));
16278 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16279 vat_json_object_add_uint (&node, "collector_port",
16280 ntohs (mp->collector_port));
16281 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16282 vat_json_object_add_ip4 (&node, "src_address", src_address);
16283 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16284 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16285 vat_json_object_add_uint (&node, "template_interval",
16286 ntohl (mp->template_interval));
16287 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16289 vat_json_print (vam->ofp, &node);
16290 vat_json_free (&node);
16292 vam->result_ready = 1;
16296 api_ipfix_exporter_dump (vat_main_t * vam)
16298 vl_api_ipfix_exporter_dump_t *mp;
16301 /* Construct the API message */
16302 M (IPFIX_EXPORTER_DUMP, mp);
16312 api_ipfix_classify_stream_dump (vat_main_t * vam)
16314 vl_api_ipfix_classify_stream_dump_t *mp;
16317 /* Construct the API message */
16318 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16328 vl_api_ipfix_classify_stream_details_t_handler
16329 (vl_api_ipfix_classify_stream_details_t * mp)
16331 vat_main_t *vam = &vat_main;
16332 print (vam->ofp, "domain_id %d, src_port %d",
16333 ntohl (mp->domain_id), ntohs (mp->src_port));
16335 vam->result_ready = 1;
16339 vl_api_ipfix_classify_stream_details_t_handler_json
16340 (vl_api_ipfix_classify_stream_details_t * mp)
16342 vat_main_t *vam = &vat_main;
16343 vat_json_node_t node;
16345 vat_json_init_object (&node);
16346 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16347 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16349 vat_json_print (vam->ofp, &node);
16350 vat_json_free (&node);
16352 vam->result_ready = 1;
16356 api_ipfix_classify_table_dump (vat_main_t * vam)
16358 vl_api_ipfix_classify_table_dump_t *mp;
16361 if (!vam->json_output)
16363 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16364 "transport_protocol");
16367 /* Construct the API message */
16368 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16373 /* Use a control ping for synchronization */
16375 vl_api_control_ping_t *mp;
16376 M (CONTROL_PING, mp);
16383 vl_api_ipfix_classify_table_details_t_handler
16384 (vl_api_ipfix_classify_table_details_t * mp)
16386 vat_main_t *vam = &vat_main;
16387 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16388 mp->transport_protocol);
16392 vl_api_ipfix_classify_table_details_t_handler_json
16393 (vl_api_ipfix_classify_table_details_t * mp)
16395 vat_json_node_t *node = NULL;
16396 vat_main_t *vam = &vat_main;
16398 if (VAT_JSON_ARRAY != vam->json_tree.type)
16400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16401 vat_json_init_array (&vam->json_tree);
16404 node = vat_json_array_add (&vam->json_tree);
16405 vat_json_init_object (node);
16407 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16408 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16409 vat_json_object_add_uint (node, "transport_protocol",
16410 mp->transport_protocol);
16414 api_sw_interface_span_enable_disable (vat_main_t * vam)
16416 unformat_input_t *i = vam->input;
16417 vl_api_sw_interface_span_enable_disable_t *mp;
16419 u32 src_sw_if_index = ~0;
16420 u32 dst_sw_if_index = ~0;
16423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16426 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16428 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16432 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16434 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16436 else if (unformat (i, "disable"))
16438 else if (unformat (i, "rx"))
16440 else if (unformat (i, "tx"))
16442 else if (unformat (i, "both"))
16448 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16450 mp->sw_if_index_from = htonl (src_sw_if_index);
16451 mp->sw_if_index_to = htonl (dst_sw_if_index);
16461 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16464 vat_main_t *vam = &vat_main;
16465 u8 *sw_if_from_name = 0;
16466 u8 *sw_if_to_name = 0;
16467 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16468 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16469 char *states[] = { "none", "rx", "tx", "both" };
16473 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16475 if ((u32) p->value[0] == sw_if_index_from)
16477 sw_if_from_name = (u8 *)(p->key);
16481 if ((u32) p->value[0] == sw_if_index_to)
16483 sw_if_to_name = (u8 *)(p->key);
16484 if (sw_if_from_name)
16489 print (vam->ofp, "%20s => %20s (%s)",
16490 sw_if_from_name, sw_if_to_name, states[mp->state]);
16494 vl_api_sw_interface_span_details_t_handler_json
16495 (vl_api_sw_interface_span_details_t * mp)
16497 vat_main_t *vam = &vat_main;
16498 vat_json_node_t *node = NULL;
16499 u8 *sw_if_from_name = 0;
16500 u8 *sw_if_to_name = 0;
16501 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16502 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16506 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16508 if ((u32) p->value[0] == sw_if_index_from)
16510 sw_if_from_name = (u8 *)(p->key);
16514 if ((u32) p->value[0] == sw_if_index_to)
16516 sw_if_to_name = (u8 *)(p->key);
16517 if (sw_if_from_name)
16523 if (VAT_JSON_ARRAY != vam->json_tree.type)
16525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16526 vat_json_init_array (&vam->json_tree);
16528 node = vat_json_array_add (&vam->json_tree);
16530 vat_json_init_object (node);
16531 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16532 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16533 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16534 if (0 != sw_if_to_name)
16536 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16538 vat_json_object_add_uint (node, "state", mp->state);
16542 api_sw_interface_span_dump (vat_main_t * vam)
16544 vl_api_sw_interface_span_dump_t *mp;
16547 M (SW_INTERFACE_SPAN_DUMP, mp);
16550 /* Use a control ping for synchronization */
16552 vl_api_control_ping_t *mp;
16553 M (CONTROL_PING, mp);
16560 api_pg_create_interface (vat_main_t * vam)
16562 unformat_input_t *input = vam->input;
16563 vl_api_pg_create_interface_t *mp;
16567 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16569 if (unformat (input, "if_id %d", &if_id))
16576 errmsg ("missing pg interface index");
16580 /* Construct the API message */
16581 M (PG_CREATE_INTERFACE, mp);
16583 mp->interface_id = ntohl (if_id);
16592 api_pg_capture (vat_main_t * vam)
16594 unformat_input_t *input = vam->input;
16595 vl_api_pg_capture_t *mp;
16601 u8 pcap_file_set = 0;
16603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16605 if (unformat (input, "if_id %d", &if_id))
16607 else if (unformat (input, "pcap %s", &pcap_file))
16609 else if (unformat (input, "count %d", &count))
16611 else if (unformat (input, "disable"))
16618 errmsg ("missing pg interface index");
16621 if (pcap_file_set > 0)
16623 if (vec_len (pcap_file) > 255)
16625 errmsg ("pcap file name is too long");
16630 u32 name_len = vec_len (pcap_file);
16631 /* Construct the API message */
16632 M (PG_CAPTURE, mp);
16634 mp->interface_id = ntohl (if_id);
16635 mp->is_enabled = enable;
16636 mp->count = ntohl (count);
16637 mp->pcap_name_length = ntohl (name_len);
16638 if (pcap_file_set != 0)
16640 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16642 vec_free (pcap_file);
16651 api_pg_enable_disable (vat_main_t * vam)
16653 unformat_input_t *input = vam->input;
16654 vl_api_pg_enable_disable_t *mp;
16658 u8 stream_name_set = 0;
16659 u8 *stream_name = 0;
16660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16662 if (unformat (input, "stream %s", &stream_name))
16663 stream_name_set = 1;
16664 else if (unformat (input, "disable"))
16670 if (stream_name_set > 0)
16672 if (vec_len (stream_name) > 255)
16674 errmsg ("stream name too long");
16679 u32 name_len = vec_len (stream_name);
16680 /* Construct the API message */
16681 M (PG_ENABLE_DISABLE, mp);
16683 mp->is_enabled = enable;
16684 if (stream_name_set != 0)
16686 mp->stream_name_length = ntohl (name_len);
16687 clib_memcpy (mp->stream_name, stream_name, name_len);
16689 vec_free (stream_name);
16698 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16700 unformat_input_t *input = vam->input;
16701 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16704 u16 *low_ports = 0;
16705 u16 *high_ports = 0;
16708 ip4_address_t ip4_addr;
16709 ip6_address_t ip6_addr;
16717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16719 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16725 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16730 else if (unformat (input, "vrf %d", &vrf_id))
16732 else if (unformat (input, "del"))
16734 else if (unformat (input, "port %d", &tmp))
16736 if (tmp == 0 || tmp > 65535)
16738 errmsg ("port %d out of range", tmp);
16742 this_hi = this_low + 1;
16743 vec_add1 (low_ports, this_low);
16744 vec_add1 (high_ports, this_hi);
16746 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16748 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16750 errmsg ("incorrect range parameters");
16754 /* Note: in debug CLI +1 is added to high before
16755 passing to real fn that does "the work"
16756 (ip_source_and_port_range_check_add_del).
16757 This fn is a wrapper around the binary API fn a
16758 control plane will call, which expects this increment
16759 to have occurred. Hence letting the binary API control
16760 plane fn do the increment for consistency between VAT
16761 and other control planes.
16764 vec_add1 (low_ports, this_low);
16765 vec_add1 (high_ports, this_hi);
16771 if (prefix_set == 0)
16773 errmsg ("<address>/<mask> not specified");
16779 errmsg ("VRF ID required, not specified");
16786 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16790 if (vec_len (low_ports) == 0)
16792 errmsg ("At least one port or port range required");
16796 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16798 mp->is_add = is_add;
16803 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16808 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16811 mp->mask_length = length;
16812 mp->number_of_ranges = vec_len (low_ports);
16814 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16815 vec_free (low_ports);
16817 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16818 vec_free (high_ports);
16820 mp->vrf_id = ntohl (vrf_id);
16829 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16831 unformat_input_t *input = vam->input;
16832 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16834 u32 sw_if_index = ~0;
16836 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16837 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16842 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16844 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16846 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16848 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16850 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16852 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16854 else if (unformat (input, "del"))
16860 if (sw_if_index == ~0)
16862 errmsg ("Interface required but not specified");
16868 errmsg ("VRF ID required but not specified");
16872 if (tcp_out_vrf_id == 0
16873 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16876 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16880 /* Construct the API message */
16881 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
16883 mp->sw_if_index = ntohl (sw_if_index);
16884 mp->is_add = is_add;
16885 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16886 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16887 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16888 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16893 /* Wait for a reply... */
16898 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16900 unformat_input_t *i = vam->input;
16901 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16903 u32 local_sa_id = 0;
16904 u32 remote_sa_id = 0;
16905 ip4_address_t src_address;
16906 ip4_address_t dst_address;
16909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16911 if (unformat (i, "local_sa %d", &local_sa_id))
16913 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16915 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16917 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16919 else if (unformat (i, "del"))
16923 clib_warning ("parse error '%U'", format_unformat_error, i);
16928 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
16930 mp->local_sa_id = ntohl (local_sa_id);
16931 mp->remote_sa_id = ntohl (remote_sa_id);
16932 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16933 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16934 mp->is_add = is_add;
16943 api_punt (vat_main_t * vam)
16945 unformat_input_t *i = vam->input;
16953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16955 if (unformat (i, "ip %d", &ipv))
16957 else if (unformat (i, "protocol %d", &protocol))
16959 else if (unformat (i, "port %d", &port))
16961 else if (unformat (i, "del"))
16965 clib_warning ("parse error '%U'", format_unformat_error, i);
16972 mp->is_add = (u8) is_add;
16973 mp->ipv = (u8) ipv;
16974 mp->l4_protocol = (u8) protocol;
16975 mp->l4_port = htons ((u16) port);
16983 static void vl_api_ipsec_gre_tunnel_details_t_handler
16984 (vl_api_ipsec_gre_tunnel_details_t * mp)
16986 vat_main_t *vam = &vat_main;
16988 print (vam->ofp, "%11d%15U%15U%14d%14d",
16989 ntohl (mp->sw_if_index),
16990 format_ip4_address, &mp->src_address,
16991 format_ip4_address, &mp->dst_address,
16992 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16995 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16996 (vl_api_ipsec_gre_tunnel_details_t * mp)
16998 vat_main_t *vam = &vat_main;
16999 vat_json_node_t *node = NULL;
17000 struct in_addr ip4;
17002 if (VAT_JSON_ARRAY != vam->json_tree.type)
17004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17005 vat_json_init_array (&vam->json_tree);
17007 node = vat_json_array_add (&vam->json_tree);
17009 vat_json_init_object (node);
17010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17011 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17012 vat_json_object_add_ip4 (node, "src_address", ip4);
17013 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17014 vat_json_object_add_ip4 (node, "dst_address", ip4);
17015 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17016 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17020 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17022 unformat_input_t *i = vam->input;
17023 vl_api_ipsec_gre_tunnel_dump_t *mp;
17026 u8 sw_if_index_set = 0;
17028 /* Parse args required to build the message */
17029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17031 if (unformat (i, "sw_if_index %d", &sw_if_index))
17032 sw_if_index_set = 1;
17037 if (sw_if_index_set == 0)
17042 if (!vam->json_output)
17044 print (vam->ofp, "%11s%15s%15s%14s%14s",
17045 "sw_if_index", "src_address", "dst_address",
17046 "local_sa_id", "remote_sa_id");
17049 /* Get list of gre-tunnel interfaces */
17050 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17052 mp->sw_if_index = htonl (sw_if_index);
17056 /* Use a control ping for synchronization */
17058 vl_api_control_ping_t *mp;
17059 M (CONTROL_PING, mp);
17066 api_delete_subif (vat_main_t * vam)
17068 unformat_input_t *i = vam->input;
17069 vl_api_delete_subif_t *mp;
17071 u32 sw_if_index = ~0;
17073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17075 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17077 if (unformat (i, "sw_if_index %d", &sw_if_index))
17083 if (sw_if_index == ~0)
17085 errmsg ("missing sw_if_index");
17089 /* Construct the API message */
17090 M (DELETE_SUBIF, mp);
17091 mp->sw_if_index = ntohl (sw_if_index);
17097 #define foreach_pbb_vtr_op \
17098 _("disable", L2_VTR_DISABLED) \
17099 _("pop", L2_VTR_POP_2) \
17100 _("push", L2_VTR_PUSH_2)
17103 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17105 unformat_input_t *i = vam->input;
17106 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17108 u32 sw_if_index = ~0, vtr_op = ~0;
17109 u16 outer_tag = ~0;
17110 u8 dmac[6], smac[6];
17111 u8 dmac_set = 0, smac_set = 0;
17116 /* Shut up coverity */
17117 memset (dmac, 0, sizeof (dmac));
17118 memset (smac, 0, sizeof (smac));
17120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17126 else if (unformat (i, "vtr_op %d", &vtr_op))
17128 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17131 else if (unformat (i, "translate_pbb_stag"))
17133 if (unformat (i, "%d", &tmp))
17135 vtr_op = L2_VTR_TRANSLATE_2_1;
17141 ("translate_pbb_stag operation requires outer tag definition");
17145 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17147 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17149 else if (unformat (i, "sid %d", &sid))
17151 else if (unformat (i, "vlanid %d", &tmp))
17155 clib_warning ("parse error '%U'", format_unformat_error, i);
17160 if ((sw_if_index == ~0) || (vtr_op == ~0))
17162 errmsg ("missing sw_if_index or vtr operation");
17165 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17166 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17169 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17173 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17174 mp->sw_if_index = ntohl (sw_if_index);
17175 mp->vtr_op = ntohl (vtr_op);
17176 mp->outer_tag = ntohs (outer_tag);
17177 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17178 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17179 mp->b_vlanid = ntohs (vlanid);
17180 mp->i_sid = ntohl (sid);
17189 api_flow_classify_set_interface (vat_main_t * vam)
17191 unformat_input_t *i = vam->input;
17192 vl_api_flow_classify_set_interface_t *mp;
17195 int sw_if_index_set;
17196 u32 ip4_table_index = ~0;
17197 u32 ip6_table_index = ~0;
17200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17203 sw_if_index_set = 1;
17204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17205 sw_if_index_set = 1;
17206 else if (unformat (i, "del"))
17208 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17210 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17214 clib_warning ("parse error '%U'", format_unformat_error, i);
17219 if (sw_if_index_set == 0)
17221 errmsg ("missing interface name or sw_if_index");
17225 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17227 mp->sw_if_index = ntohl (sw_if_index);
17228 mp->ip4_table_index = ntohl (ip4_table_index);
17229 mp->ip6_table_index = ntohl (ip6_table_index);
17230 mp->is_add = is_add;
17239 api_flow_classify_dump (vat_main_t * vam)
17241 unformat_input_t *i = vam->input;
17242 vl_api_flow_classify_dump_t *mp;
17244 u8 type = FLOW_CLASSIFY_N_TABLES;
17246 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17250 errmsg ("classify table type must be specified");
17254 if (!vam->json_output)
17256 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17259 M (FLOW_CLASSIFY_DUMP, mp);
17264 /* Use a control ping for synchronization */
17266 vl_api_control_ping_t *mp;
17267 M (CONTROL_PING, mp);
17270 /* Wait for a reply... */
17278 api_feature_enable_disable (vat_main_t * vam)
17280 unformat_input_t *i = vam->input;
17281 vl_api_feature_enable_disable_t *mp;
17284 u8 *feature_name = 0;
17285 u32 sw_if_index = ~0;
17288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17290 if (unformat (i, "arc_name %s", &arc_name))
17292 else if (unformat (i, "feature_name %s", &feature_name))
17295 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17299 else if (unformat (i, "disable"))
17307 errmsg ("missing arc name");
17310 if (vec_len (arc_name) > 63)
17312 errmsg ("arc name too long");
17315 if (feature_name == 0)
17317 errmsg ("missing feature name");
17320 if (vec_len (feature_name) > 63)
17322 errmsg ("feature name too long");
17325 if (sw_if_index == ~0)
17327 errmsg ("missing interface name or sw_if_index");
17331 /* Construct the API message */
17332 M (FEATURE_ENABLE_DISABLE, mp);
17333 mp->sw_if_index = ntohl (sw_if_index);
17334 mp->enable = enable;
17335 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17336 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17337 vec_free (arc_name);
17338 vec_free (feature_name);
17345 api_sw_interface_tag_add_del (vat_main_t * vam)
17347 unformat_input_t *i = vam->input;
17348 vl_api_sw_interface_tag_add_del_t *mp;
17350 u32 sw_if_index = ~0;
17354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17356 if (unformat (i, "tag %s", &tag))
17358 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17360 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17362 else if (unformat (i, "del"))
17368 if (sw_if_index == ~0)
17370 errmsg ("missing interface name or sw_if_index");
17374 if (enable && (tag == 0))
17376 errmsg ("no tag specified");
17380 /* Construct the API message */
17381 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17382 mp->sw_if_index = ntohl (sw_if_index);
17383 mp->is_add = enable;
17385 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17392 static void vl_api_l2_xconnect_details_t_handler
17393 (vl_api_l2_xconnect_details_t * mp)
17395 vat_main_t *vam = &vat_main;
17397 print (vam->ofp, "%15d%15d",
17398 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17401 static void vl_api_l2_xconnect_details_t_handler_json
17402 (vl_api_l2_xconnect_details_t * mp)
17404 vat_main_t *vam = &vat_main;
17405 vat_json_node_t *node = NULL;
17407 if (VAT_JSON_ARRAY != vam->json_tree.type)
17409 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17410 vat_json_init_array (&vam->json_tree);
17412 node = vat_json_array_add (&vam->json_tree);
17414 vat_json_init_object (node);
17415 vat_json_object_add_uint (node, "rx_sw_if_index",
17416 ntohl (mp->rx_sw_if_index));
17417 vat_json_object_add_uint (node, "tx_sw_if_index",
17418 ntohl (mp->tx_sw_if_index));
17422 api_l2_xconnect_dump (vat_main_t * vam)
17424 vl_api_l2_xconnect_dump_t *mp;
17427 if (!vam->json_output)
17429 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17432 M (L2_XCONNECT_DUMP, mp);
17436 /* Use a control ping for synchronization */
17438 vl_api_control_ping_t *mp;
17439 M (CONTROL_PING, mp);
17446 api_sw_interface_set_mtu (vat_main_t * vam)
17448 unformat_input_t *i = vam->input;
17449 vl_api_sw_interface_set_mtu_t *mp;
17451 u32 sw_if_index = ~0;
17454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17456 if (unformat (i, "mtu %d", &mtu))
17458 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17460 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17466 if (sw_if_index == ~0)
17468 errmsg ("missing interface name or sw_if_index");
17474 errmsg ("no mtu specified");
17478 /* Construct the API message */
17479 M (SW_INTERFACE_SET_MTU, mp);
17480 mp->sw_if_index = ntohl (sw_if_index);
17481 mp->mtu = ntohs ((u16) mtu);
17489 q_or_quit (vat_main_t * vam)
17491 longjmp (vam->jump_buf, 1);
17492 return 0; /* not so much */
17496 q (vat_main_t * vam)
17498 return q_or_quit (vam);
17502 quit (vat_main_t * vam)
17504 return q_or_quit (vam);
17508 comment (vat_main_t * vam)
17514 cmd_cmp (void *a1, void *a2)
17519 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17523 help (vat_main_t * vam)
17528 unformat_input_t *i = vam->input;
17531 if (unformat (i, "%s", &name))
17535 vec_add1 (name, 0);
17537 hs = hash_get_mem (vam->help_by_name, name);
17539 print (vam->ofp, "usage: %s %s", name, hs[0]);
17541 print (vam->ofp, "No such msg / command '%s'", name);
17546 print (vam->ofp, "Help is available for the following:");
17549 hash_foreach_pair (p, vam->function_by_name,
17551 vec_add1 (cmds, (u8 *)(p->key));
17555 vec_sort_with_function (cmds, cmd_cmp);
17557 for (j = 0; j < vec_len (cmds); j++)
17558 print (vam->ofp, "%s", cmds[j]);
17565 set (vat_main_t * vam)
17567 u8 *name = 0, *value = 0;
17568 unformat_input_t *i = vam->input;
17570 if (unformat (i, "%s", &name))
17572 /* The input buffer is a vector, not a string. */
17573 value = vec_dup (i->buffer);
17574 vec_delete (value, i->index, 0);
17575 /* Almost certainly has a trailing newline */
17576 if (value[vec_len (value) - 1] == '\n')
17577 value[vec_len (value) - 1] = 0;
17578 /* Make sure it's a proper string, one way or the other */
17579 vec_add1 (value, 0);
17580 (void) clib_macro_set_value (&vam->macro_main,
17581 (char *) name, (char *) value);
17584 errmsg ("usage: set <name> <value>");
17592 unset (vat_main_t * vam)
17596 if (unformat (vam->input, "%s", &name))
17597 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17598 errmsg ("unset: %s wasn't set", name);
17611 macro_sort_cmp (void *a1, void *a2)
17613 macro_sort_t *s1 = a1;
17614 macro_sort_t *s2 = a2;
17616 return strcmp ((char *) (s1->name), (char *) (s2->name));
17620 dump_macro_table (vat_main_t * vam)
17622 macro_sort_t *sort_me = 0, *sm;
17627 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17629 vec_add2 (sort_me, sm, 1);
17630 sm->name = (u8 *)(p->key);
17631 sm->value = (u8 *) (p->value[0]);
17635 vec_sort_with_function (sort_me, macro_sort_cmp);
17637 if (vec_len (sort_me))
17638 print (vam->ofp, "%-15s%s", "Name", "Value");
17640 print (vam->ofp, "The macro table is empty...");
17642 for (i = 0; i < vec_len (sort_me); i++)
17643 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17648 dump_node_table (vat_main_t * vam)
17651 vlib_node_t *node, *next_node;
17653 if (vec_len (vam->graph_nodes) == 0)
17655 print (vam->ofp, "Node table empty, issue get_node_graph...");
17659 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17661 node = vam->graph_nodes[i];
17662 print (vam->ofp, "[%d] %s", i, node->name);
17663 for (j = 0; j < vec_len (node->next_nodes); j++)
17665 if (node->next_nodes[j] != ~0)
17667 next_node = vam->graph_nodes[node->next_nodes[j]];
17668 print (vam->ofp, " [%d] %s", j, next_node->name);
17676 value_sort_cmp (void *a1, void *a2)
17678 name_sort_t *n1 = a1;
17679 name_sort_t *n2 = a2;
17681 if (n1->value < n2->value)
17683 if (n1->value > n2->value)
17690 dump_msg_api_table (vat_main_t * vam)
17692 api_main_t *am = &api_main;
17693 name_sort_t *nses = 0, *ns;
17698 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17700 vec_add2 (nses, ns, 1);
17701 ns->name = (u8 *)(hp->key);
17702 ns->value = (u32) hp->value[0];
17706 vec_sort_with_function (nses, value_sort_cmp);
17708 for (i = 0; i < vec_len (nses); i++)
17709 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17715 get_msg_id (vat_main_t * vam)
17720 if (unformat (vam->input, "%s", &name_and_crc))
17722 message_index = vl_api_get_msg_index (name_and_crc);
17723 if (message_index == ~0)
17725 print (vam->ofp, " '%s' not found", name_and_crc);
17728 print (vam->ofp, " '%s' has message index %d",
17729 name_and_crc, message_index);
17732 errmsg ("name_and_crc required...");
17737 search_node_table (vat_main_t * vam)
17739 unformat_input_t *line_input = vam->input;
17742 vlib_node_t *node, *next_node;
17745 if (vam->graph_node_index_by_name == 0)
17747 print (vam->ofp, "Node table empty, issue get_node_graph...");
17751 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17753 if (unformat (line_input, "%s", &node_to_find))
17755 vec_add1 (node_to_find, 0);
17756 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17759 print (vam->ofp, "%s not found...", node_to_find);
17762 node = vam->graph_nodes[p[0]];
17763 print (vam->ofp, "[%d] %s", p[0], node->name);
17764 for (j = 0; j < vec_len (node->next_nodes); j++)
17766 if (node->next_nodes[j] != ~0)
17768 next_node = vam->graph_nodes[node->next_nodes[j]];
17769 print (vam->ofp, " [%d] %s", j, next_node->name);
17776 clib_warning ("parse error '%U'", format_unformat_error,
17782 vec_free (node_to_find);
17791 script (vat_main_t * vam)
17793 #if (VPP_API_TEST_BUILTIN==0)
17795 char *save_current_file;
17796 unformat_input_t save_input;
17797 jmp_buf save_jump_buf;
17798 u32 save_line_number;
17800 FILE *new_fp, *save_ifp;
17802 if (unformat (vam->input, "%s", &s))
17804 new_fp = fopen ((char *) s, "r");
17807 errmsg ("Couldn't open script file %s", s);
17814 errmsg ("Missing script name");
17818 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17819 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17820 save_ifp = vam->ifp;
17821 save_line_number = vam->input_line_number;
17822 save_current_file = (char *) vam->current_file;
17824 vam->input_line_number = 0;
17826 vam->current_file = s;
17829 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17830 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17831 vam->ifp = save_ifp;
17832 vam->input_line_number = save_line_number;
17833 vam->current_file = (u8 *) save_current_file;
17838 clib_warning ("use the exec command...");
17844 echo (vat_main_t * vam)
17846 print (vam->ofp, "%v", vam->input->buffer);
17850 /* List of API message constructors, CLI names map to api_xxx */
17851 #define foreach_vpe_api_msg \
17852 _(create_loopback,"[mac <mac-addr>]") \
17853 _(sw_interface_dump,"") \
17854 _(sw_interface_set_flags, \
17855 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17856 _(sw_interface_add_del_address, \
17857 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17858 _(sw_interface_set_table, \
17859 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17860 _(sw_interface_set_mpls_enable, \
17861 "<intfc> | sw_if_index [disable | dis]") \
17862 _(sw_interface_set_vpath, \
17863 "<intfc> | sw_if_index <id> enable | disable") \
17864 _(sw_interface_set_vxlan_bypass, \
17865 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
17866 _(sw_interface_set_l2_xconnect, \
17867 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17868 "enable | disable") \
17869 _(sw_interface_set_l2_bridge, \
17870 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17871 "[shg <split-horizon-group>] [bvi]\n" \
17872 "enable | disable") \
17873 _(bridge_domain_add_del, \
17874 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17875 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17877 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17879 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17881 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17883 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17885 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17887 "<vpp-if-name> | sw_if_index <id>") \
17888 _(sw_interface_tap_dump, "") \
17889 _(ip_add_del_route, \
17890 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17891 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17892 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17893 "[multipath] [count <n>]") \
17894 _(ip_mroute_add_del, \
17895 "<src> <grp>/<mask> [table-id <n>]\n" \
17896 "[<intfc> | sw_if_index <id>] [local] [del]") \
17897 _(mpls_route_add_del, \
17898 "<label> <eos> via <addr> [table-id <n>]\n" \
17899 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17900 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17901 "[multipath] [count <n>]") \
17902 _(mpls_ip_bind_unbind, \
17903 "<label> <addr/len>") \
17904 _(mpls_tunnel_add_del, \
17905 " via <addr> [table-id <n>]\n" \
17906 "sw_if_index <id>] [l2] [del]") \
17907 _(proxy_arp_add_del, \
17908 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17909 _(proxy_arp_intfc_enable_disable, \
17910 "<intfc> | sw_if_index <id> enable | disable") \
17911 _(sw_interface_set_unnumbered, \
17912 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17913 _(ip_neighbor_add_del, \
17914 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17915 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17916 _(reset_vrf, "vrf <id> [ipv6]") \
17917 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17918 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17919 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17920 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17921 "[outer_vlan_id_any][inner_vlan_id_any]") \
17922 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17923 _(reset_fib, "vrf <n> [ipv6]") \
17924 _(dhcp_proxy_config, \
17925 "svr <v46-address> src <v46-address>\n" \
17926 "insert-cid <n> [del]") \
17927 _(dhcp_proxy_config_2, \
17928 "svr <v46-address> src <v46-address>\n" \
17929 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17930 _(dhcp_proxy_set_vss, \
17931 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17932 _(dhcp_client_config, \
17933 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17934 _(set_ip_flow_hash, \
17935 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17936 _(sw_interface_ip6_enable_disable, \
17937 "<intfc> | sw_if_index <id> enable | disable") \
17938 _(sw_interface_ip6_set_link_local_address, \
17939 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17940 _(sw_interface_ip6nd_ra_prefix, \
17941 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17942 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17943 "[nolink] [isno]") \
17944 _(sw_interface_ip6nd_ra_config, \
17945 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17946 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17947 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17948 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17949 _(l2_patch_add_del, \
17950 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17951 "enable | disable") \
17952 _(sr_tunnel_add_del, \
17953 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17954 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17955 "[policy <policy_name>]") \
17956 _(sr_policy_add_del, \
17957 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17958 _(sr_multicast_map_add_del, \
17959 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17960 _(classify_add_del_table, \
17961 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17962 " [del] [del-chain] mask <mask-value>\n" \
17963 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17964 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17965 _(classify_add_del_session, \
17966 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17967 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17968 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17969 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17970 _(classify_set_interface_ip_table, \
17971 "<intfc> | sw_if_index <nn> table <nn>") \
17972 _(classify_set_interface_l2_tables, \
17973 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17974 " [other-table <nn>]") \
17975 _(get_node_index, "node <node-name") \
17976 _(add_node_next, "node <node-name> next <next-node-name>") \
17977 _(l2tpv3_create_tunnel, \
17978 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17979 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17980 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17981 _(l2tpv3_set_tunnel_cookies, \
17982 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17983 "[new_remote_cookie <nn>]\n") \
17984 _(l2tpv3_interface_enable_disable, \
17985 "<intfc> | sw_if_index <nn> enable | disable") \
17986 _(l2tpv3_set_lookup_key, \
17987 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17988 _(sw_if_l2tpv3_tunnel_dump, "") \
17989 _(vxlan_add_del_tunnel, \
17990 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17991 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17992 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17993 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17994 _(gre_add_del_tunnel, \
17995 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17996 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17997 _(l2_fib_clear_table, "") \
17998 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17999 _(l2_interface_vlan_tag_rewrite, \
18000 "<intfc> | sw_if_index <nn> \n" \
18001 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18002 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18003 _(create_vhost_user_if, \
18004 "socket <filename> [server] [renumber <dev_instance>] " \
18005 "[mac <mac_address>]") \
18006 _(modify_vhost_user_if, \
18007 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18008 "[server] [renumber <dev_instance>]") \
18009 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18010 _(sw_interface_vhost_user_dump, "") \
18011 _(show_version, "") \
18012 _(vxlan_gpe_add_del_tunnel, \
18013 "local <addr> remote <addr> vni <nn>\n" \
18014 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18015 "[next-ethernet] [next-nsh]\n") \
18016 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18017 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18018 _(interface_name_renumber, \
18019 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18020 _(input_acl_set_interface, \
18021 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18022 " [l2-table <nn>] [del]") \
18023 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18024 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18025 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18026 _(ip_dump, "ipv4 | ipv6") \
18027 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18028 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18030 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18031 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18032 " integ_alg <alg> integ_key <hex>") \
18033 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18034 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18035 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18036 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18037 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18038 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18039 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18040 "(auth_data 0x<data> | auth_data <data>)") \
18041 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18042 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18043 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18044 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18045 "(local|remote)") \
18046 _(ikev2_set_local_key, "file <absolute_file_path>") \
18047 _(delete_loopback,"sw_if_index <nn>") \
18048 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18049 _(map_add_domain, \
18050 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18051 "ip6-src <ip6addr> " \
18052 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18053 _(map_del_domain, "index <n>") \
18054 _(map_add_del_rule, \
18055 "index <n> psid <n> dst <ip6addr> [del]") \
18056 _(map_domain_dump, "") \
18057 _(map_rule_dump, "index <map-domain>") \
18058 _(want_interface_events, "enable|disable") \
18059 _(want_stats,"enable|disable") \
18060 _(get_first_msg_id, "client <name>") \
18061 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18062 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18063 "fib-id <nn> [ip4][ip6][default]") \
18064 _(get_node_graph, " ") \
18065 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18066 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18067 _(ioam_disable, "") \
18068 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18069 " sw_if_index <sw_if_index> p <priority> " \
18070 "w <weight>] [del]") \
18071 _(lisp_add_del_locator, "locator-set <locator_name> " \
18072 "iface <intf> | sw_if_index <sw_if_index> " \
18073 "p <priority> w <weight> [del]") \
18074 _(lisp_add_del_local_eid,"vni <vni> eid " \
18075 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18076 "locator-set <locator_name> [del]" \
18077 "[key-id sha1|sha256 secret-key <secret-key>]") \
18078 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18079 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18080 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18081 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18082 _(lisp_gpe_enable_disable, "enable|disable") \
18083 _(lisp_enable_disable, "enable|disable") \
18084 _(lisp_map_register_enable_disable, "enable|disable") \
18085 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18086 _(lisp_gpe_add_del_iface, "up|down") \
18087 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18089 "rloc <locator> p <prio> " \
18090 "w <weight> [rloc <loc> ... ] " \
18091 "action <action> [del-all]") \
18092 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18094 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18095 _(lisp_map_request_mode, "src-dst|dst-only") \
18096 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18097 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18098 _(lisp_locator_set_dump, "[local | remote]") \
18099 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18100 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18101 "[local] | [remote]") \
18102 _(lisp_eid_table_vni_dump, "") \
18103 _(lisp_eid_table_map_dump, "l2|l3") \
18104 _(lisp_map_resolver_dump, "") \
18105 _(lisp_map_server_dump, "") \
18106 _(lisp_adjacencies_get, "vni <vni>") \
18107 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18108 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18109 _(show_lisp_rloc_probe_state, "") \
18110 _(show_lisp_map_register_state, "") \
18111 _(show_lisp_status, "") \
18112 _(lisp_get_map_request_itr_rlocs, "") \
18113 _(show_lisp_pitr, "") \
18114 _(show_lisp_map_request_mode, "") \
18115 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18116 _(af_packet_delete, "name <host interface name>") \
18117 _(policer_add_del, "name <policer name> <params> [del]") \
18118 _(policer_dump, "[name <policer name>]") \
18119 _(policer_classify_set_interface, \
18120 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18121 " [l2-table <nn>] [del]") \
18122 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18123 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18124 "[master|slave]") \
18125 _(netmap_delete, "name <interface name>") \
18126 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18127 _(mpls_fib_dump, "") \
18128 _(classify_table_ids, "") \
18129 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18130 _(classify_table_info, "table_id <nn>") \
18131 _(classify_session_dump, "table_id <nn>") \
18132 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18133 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18134 "[template_interval <nn>] [udp_checksum]") \
18135 _(ipfix_exporter_dump, "") \
18136 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18137 _(ipfix_classify_stream_dump, "") \
18138 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18139 _(ipfix_classify_table_dump, "") \
18140 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18141 _(sw_interface_span_dump, "") \
18142 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18143 _(pg_create_interface, "if_id <nn>") \
18144 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18145 _(pg_enable_disable, "[stream <id>] disable") \
18146 _(ip_source_and_port_range_check_add_del, \
18147 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18148 _(ip_source_and_port_range_check_interface_add_del, \
18149 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18150 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18151 _(ipsec_gre_add_del_tunnel, \
18152 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18153 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18154 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18155 _(l2_interface_pbb_tag_rewrite, \
18156 "<intfc> | sw_if_index <nn> \n" \
18157 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18158 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18159 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18160 _(flow_classify_set_interface, \
18161 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18162 _(flow_classify_dump, "type [ip4|ip6]") \
18163 _(ip_fib_dump, "") \
18164 _(ip6_fib_dump, "") \
18165 _(feature_enable_disable, "arc_name <arc_name> " \
18166 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18167 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18169 _(l2_xconnect_dump, "") \
18170 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18171 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18172 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18175 #define foreach_vpe_dpdk_api_msg \
18176 _(sw_interface_set_dpdk_hqos_pipe, \
18177 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
18178 "profile <profile-id>\n") \
18179 _(sw_interface_set_dpdk_hqos_subport, \
18180 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
18181 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
18182 _(sw_interface_set_dpdk_hqos_tctbl, \
18183 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
18186 /* List of command functions, CLI names map directly to functions */
18187 #define foreach_cli_function \
18188 _(comment, "usage: comment <ignore-rest-of-line>") \
18189 _(dump_interface_table, "usage: dump_interface_table") \
18190 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18191 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18192 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18193 _(dump_stats_table, "usage: dump_stats_table") \
18194 _(dump_macro_table, "usage: dump_macro_table ") \
18195 _(dump_node_table, "usage: dump_node_table") \
18196 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18197 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18198 _(echo, "usage: echo <message>") \
18199 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18200 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18201 _(help, "usage: help") \
18202 _(q, "usage: quit") \
18203 _(quit, "usage: quit") \
18204 _(search_node_table, "usage: search_node_table <name>...") \
18205 _(set, "usage: set <variable-name> <value>") \
18206 _(script, "usage: script <file-name>") \
18207 _(unset, "usage: unset <variable-name>")
18210 static void vl_api_##n##_t_handler_uni \
18211 (vl_api_##n##_t * mp) \
18213 vat_main_t * vam = &vat_main; \
18214 if (vam->json_output) { \
18215 vl_api_##n##_t_handler_json(mp); \
18217 vl_api_##n##_t_handler(mp); \
18220 foreach_vpe_api_reply_msg;
18225 static void vl_api_##n##_t_handler_uni \
18226 (vl_api_##n##_t * mp) \
18228 vat_main_t * vam = &vat_main; \
18229 if (vam->json_output) { \
18230 vl_api_##n##_t_handler_json(mp); \
18232 vl_api_##n##_t_handler(mp); \
18235 foreach_vpe_dpdk_api_reply_msg;
18240 vat_api_hookup (vat_main_t * vam)
18243 vl_msg_api_set_handlers(VL_API_##N, #n, \
18244 vl_api_##n##_t_handler_uni, \
18246 vl_api_##n##_t_endian, \
18247 vl_api_##n##_t_print, \
18248 sizeof(vl_api_##n##_t), 1);
18249 foreach_vpe_api_reply_msg;
18254 vl_msg_api_set_handlers(VL_API_##N, #n, \
18255 vl_api_##n##_t_handler_uni, \
18257 vl_api_##n##_t_endian, \
18258 vl_api_##n##_t_print, \
18259 sizeof(vl_api_##n##_t), 1);
18260 foreach_vpe_dpdk_api_reply_msg;
18264 #if (VPP_API_TEST_BUILTIN==0)
18265 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18268 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18270 vam->function_by_name = hash_create_string (0, sizeof (uword));
18272 vam->help_by_name = hash_create_string (0, sizeof (uword));
18274 /* API messages we can send */
18275 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18276 foreach_vpe_api_msg;
18279 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18280 foreach_vpe_dpdk_api_msg;
18285 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18286 foreach_vpe_api_msg;
18289 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18290 foreach_vpe_dpdk_api_msg;
18294 /* CLI functions */
18295 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18296 foreach_cli_function;
18300 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18301 foreach_cli_function;
18306 * fd.io coding-style-patch-verification: ON
18309 * eval: (c-set-style "gnu")