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 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
921 format_ethernet_address,
923 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
925 format_ethernet_address,
927 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
928 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
932 static void vl_api_sw_interface_set_flags_t_handler
933 (vl_api_sw_interface_set_flags_t * mp)
935 vat_main_t *vam = &vat_main;
936 if (vam->interface_event_display)
937 errmsg ("interface flags: sw_if_index %d %s %s",
938 ntohl (mp->sw_if_index),
939 mp->admin_up_down ? "admin-up" : "admin-down",
940 mp->link_up_down ? "link-up" : "link-down");
943 static void vl_api_sw_interface_set_flags_t_handler_json
944 (vl_api_sw_interface_set_flags_t * mp)
946 /* JSON output not supported */
950 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
952 vat_main_t *vam = &vat_main;
953 i32 retval = ntohl (mp->retval);
955 vam->retval = retval;
956 vam->shmem_result = (u8 *) mp->reply_in_shmem;
957 vam->result_ready = 1;
961 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
963 vat_main_t *vam = &vat_main;
964 vat_json_node_t node;
965 api_main_t *am = &api_main;
969 vat_json_init_object (&node);
970 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
971 vat_json_object_add_uint (&node, "reply_in_shmem",
972 ntohl (mp->reply_in_shmem));
973 /* Toss the shared-memory original... */
974 pthread_mutex_lock (&am->vlib_rp->mutex);
975 oldheap = svm_push_data_heap (am->vlib_rp);
977 reply = (u8 *) (mp->reply_in_shmem);
980 svm_pop_heap (oldheap);
981 pthread_mutex_unlock (&am->vlib_rp->mutex);
983 vat_json_print (vam->ofp, &node);
984 vat_json_free (&node);
986 vam->retval = ntohl (mp->retval);
987 vam->result_ready = 1;
991 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
993 vat_main_t *vam = &vat_main;
994 i32 retval = ntohl (mp->retval);
996 vam->retval = retval;
997 vam->cmd_reply = mp->reply;
998 vam->result_ready = 1;
1002 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1004 vat_main_t *vam = &vat_main;
1005 vat_json_node_t node;
1007 vat_json_init_object (&node);
1008 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1009 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1011 vat_json_print (vam->ofp, &node);
1012 vat_json_free (&node);
1014 vam->retval = ntohl (mp->retval);
1015 vam->result_ready = 1;
1018 static void vl_api_classify_add_del_table_reply_t_handler
1019 (vl_api_classify_add_del_table_reply_t * mp)
1021 vat_main_t *vam = &vat_main;
1022 i32 retval = ntohl (mp->retval);
1023 if (vam->async_mode)
1025 vam->async_errors += (retval < 0);
1029 vam->retval = retval;
1031 ((mp->new_table_index != 0xFFFFFFFF) ||
1032 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1033 (mp->match_n_vectors != 0xFFFFFFFF)))
1035 * Note: this is just barely thread-safe, depends on
1036 * the main thread spinning waiting for an answer...
1038 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1039 ntohl (mp->new_table_index),
1040 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1041 vam->result_ready = 1;
1045 static void vl_api_classify_add_del_table_reply_t_handler_json
1046 (vl_api_classify_add_del_table_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_uint (&node, "new_table_index",
1054 ntohl (mp->new_table_index));
1055 vat_json_object_add_uint (&node, "skip_n_vectors",
1056 ntohl (mp->skip_n_vectors));
1057 vat_json_object_add_uint (&node, "match_n_vectors",
1058 ntohl (mp->match_n_vectors));
1060 vat_json_print (vam->ofp, &node);
1061 vat_json_free (&node);
1063 vam->retval = ntohl (mp->retval);
1064 vam->result_ready = 1;
1067 static void vl_api_get_node_index_reply_t_handler
1068 (vl_api_get_node_index_reply_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 i32 retval = ntohl (mp->retval);
1072 if (vam->async_mode)
1074 vam->async_errors += (retval < 0);
1078 vam->retval = retval;
1080 errmsg ("node index %d", ntohl (mp->node_index));
1081 vam->result_ready = 1;
1085 static void vl_api_get_node_index_reply_t_handler_json
1086 (vl_api_get_node_index_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vat_json_init_object (&node);
1092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1093 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1095 vat_json_print (vam->ofp, &node);
1096 vat_json_free (&node);
1098 vam->retval = ntohl (mp->retval);
1099 vam->result_ready = 1;
1102 static void vl_api_get_next_index_reply_t_handler
1103 (vl_api_get_next_index_reply_t * mp)
1105 vat_main_t *vam = &vat_main;
1106 i32 retval = ntohl (mp->retval);
1107 if (vam->async_mode)
1109 vam->async_errors += (retval < 0);
1113 vam->retval = retval;
1115 errmsg ("next node index %d", ntohl (mp->next_index));
1116 vam->result_ready = 1;
1120 static void vl_api_get_next_index_reply_t_handler_json
1121 (vl_api_get_next_index_reply_t * mp)
1123 vat_main_t *vam = &vat_main;
1124 vat_json_node_t node;
1126 vat_json_init_object (&node);
1127 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1128 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1130 vat_json_print (vam->ofp, &node);
1131 vat_json_free (&node);
1133 vam->retval = ntohl (mp->retval);
1134 vam->result_ready = 1;
1137 static void vl_api_add_node_next_reply_t_handler
1138 (vl_api_add_node_next_reply_t * mp)
1140 vat_main_t *vam = &vat_main;
1141 i32 retval = ntohl (mp->retval);
1142 if (vam->async_mode)
1144 vam->async_errors += (retval < 0);
1148 vam->retval = retval;
1150 errmsg ("next index %d", ntohl (mp->next_index));
1151 vam->result_ready = 1;
1155 static void vl_api_add_node_next_reply_t_handler_json
1156 (vl_api_add_node_next_reply_t * mp)
1158 vat_main_t *vam = &vat_main;
1159 vat_json_node_t node;
1161 vat_json_init_object (&node);
1162 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1163 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1165 vat_json_print (vam->ofp, &node);
1166 vat_json_free (&node);
1168 vam->retval = ntohl (mp->retval);
1169 vam->result_ready = 1;
1172 static void vl_api_show_version_reply_t_handler
1173 (vl_api_show_version_reply_t * mp)
1175 vat_main_t *vam = &vat_main;
1176 i32 retval = ntohl (mp->retval);
1180 errmsg (" program: %s", mp->program);
1181 errmsg (" version: %s", mp->version);
1182 errmsg (" build date: %s", mp->build_date);
1183 errmsg ("build directory: %s", mp->build_directory);
1185 vam->retval = retval;
1186 vam->result_ready = 1;
1189 static void vl_api_show_version_reply_t_handler_json
1190 (vl_api_show_version_reply_t * mp)
1192 vat_main_t *vam = &vat_main;
1193 vat_json_node_t node;
1195 vat_json_init_object (&node);
1196 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1197 vat_json_object_add_string_copy (&node, "program", mp->program);
1198 vat_json_object_add_string_copy (&node, "version", mp->version);
1199 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1200 vat_json_object_add_string_copy (&node, "build_directory",
1201 mp->build_directory);
1203 vat_json_print (vam->ofp, &node);
1204 vat_json_free (&node);
1206 vam->retval = ntohl (mp->retval);
1207 vam->result_ready = 1;
1211 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1213 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1214 mp->mac_ip ? "mac/ip binding" : "address resolution",
1215 format_ip4_address, &mp->address,
1216 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1220 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1222 /* JSON output not supported */
1226 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1228 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1229 mp->mac_ip ? "mac/ip binding" : "address resolution",
1230 format_ip6_address, mp->address,
1231 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1235 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1237 /* JSON output not supported */
1241 * Special-case: build the bridge domain table, maintain
1242 * the next bd id vbl.
1244 static void vl_api_bridge_domain_details_t_handler
1245 (vl_api_bridge_domain_details_t * mp)
1247 vat_main_t *vam = &vat_main;
1248 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1250 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1251 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1253 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1254 ntohl (mp->bd_id), mp->learn, mp->forward,
1255 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1258 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1261 static void vl_api_bridge_domain_details_t_handler_json
1262 (vl_api_bridge_domain_details_t * mp)
1264 vat_main_t *vam = &vat_main;
1265 vat_json_node_t *node, *array = NULL;
1267 if (VAT_JSON_ARRAY != vam->json_tree.type)
1269 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1270 vat_json_init_array (&vam->json_tree);
1272 node = vat_json_array_add (&vam->json_tree);
1274 vat_json_init_object (node);
1275 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1276 vat_json_object_add_uint (node, "flood", mp->flood);
1277 vat_json_object_add_uint (node, "forward", mp->forward);
1278 vat_json_object_add_uint (node, "learn", mp->learn);
1279 vat_json_object_add_uint (node, "bvi_sw_if_index",
1280 ntohl (mp->bvi_sw_if_index));
1281 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1282 array = vat_json_object_add (node, "sw_if");
1283 vat_json_init_array (array);
1287 * Special-case: build the bridge domain sw if table.
1289 static void vl_api_bridge_domain_sw_if_details_t_handler
1290 (vl_api_bridge_domain_sw_if_details_t * mp)
1292 vat_main_t *vam = &vat_main;
1297 sw_if_index = ntohl (mp->sw_if_index);
1299 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1301 if ((u32) p->value[0] == sw_if_index)
1303 sw_if_name = (u8 *)(p->key);
1309 print (vam->ofp, "%7d %3d %s", sw_if_index,
1310 mp->shg, sw_if_name ? (char *) sw_if_name :
1311 "sw_if_index not found!");
1314 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1315 (vl_api_bridge_domain_sw_if_details_t * mp)
1317 vat_main_t *vam = &vat_main;
1318 vat_json_node_t *node = NULL;
1319 uword last_index = 0;
1321 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1322 ASSERT (vec_len (vam->json_tree.array) >= 1);
1323 last_index = vec_len (vam->json_tree.array) - 1;
1324 node = &vam->json_tree.array[last_index];
1325 node = vat_json_object_get_element (node, "sw_if");
1326 ASSERT (NULL != node);
1327 node = vat_json_array_add (node);
1329 vat_json_init_object (node);
1330 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1331 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1332 vat_json_object_add_uint (node, "shg", mp->shg);
1335 static void vl_api_control_ping_reply_t_handler
1336 (vl_api_control_ping_reply_t * mp)
1338 vat_main_t *vam = &vat_main;
1339 i32 retval = ntohl (mp->retval);
1340 if (vam->async_mode)
1342 vam->async_errors += (retval < 0);
1346 vam->retval = retval;
1347 vam->result_ready = 1;
1351 static void vl_api_control_ping_reply_t_handler_json
1352 (vl_api_control_ping_reply_t * mp)
1354 vat_main_t *vam = &vat_main;
1355 i32 retval = ntohl (mp->retval);
1357 if (VAT_JSON_NONE != vam->json_tree.type)
1359 vat_json_print (vam->ofp, &vam->json_tree);
1360 vat_json_free (&vam->json_tree);
1361 vam->json_tree.type = VAT_JSON_NONE;
1366 vat_json_init_array (&vam->json_tree);
1367 vat_json_print (vam->ofp, &vam->json_tree);
1368 vam->json_tree.type = VAT_JSON_NONE;
1371 vam->retval = retval;
1372 vam->result_ready = 1;
1376 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1378 vat_main_t *vam = &vat_main;
1379 i32 retval = ntohl (mp->retval);
1380 if (vam->async_mode)
1382 vam->async_errors += (retval < 0);
1386 vam->retval = retval;
1387 vam->result_ready = 1;
1391 static void vl_api_l2_flags_reply_t_handler_json
1392 (vl_api_l2_flags_reply_t * mp)
1394 vat_main_t *vam = &vat_main;
1395 vat_json_node_t node;
1397 vat_json_init_object (&node);
1398 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1399 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1400 ntohl (mp->resulting_feature_bitmap));
1402 vat_json_print (vam->ofp, &node);
1403 vat_json_free (&node);
1405 vam->retval = ntohl (mp->retval);
1406 vam->result_ready = 1;
1409 static void vl_api_bridge_flags_reply_t_handler
1410 (vl_api_bridge_flags_reply_t * mp)
1412 vat_main_t *vam = &vat_main;
1413 i32 retval = ntohl (mp->retval);
1414 if (vam->async_mode)
1416 vam->async_errors += (retval < 0);
1420 vam->retval = retval;
1421 vam->result_ready = 1;
1425 static void vl_api_bridge_flags_reply_t_handler_json
1426 (vl_api_bridge_flags_reply_t * mp)
1428 vat_main_t *vam = &vat_main;
1429 vat_json_node_t node;
1431 vat_json_init_object (&node);
1432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1433 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1434 ntohl (mp->resulting_feature_bitmap));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = ntohl (mp->retval);
1440 vam->result_ready = 1;
1443 static void vl_api_tap_connect_reply_t_handler
1444 (vl_api_tap_connect_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 i32 retval = ntohl (mp->retval);
1448 if (vam->async_mode)
1450 vam->async_errors += (retval < 0);
1454 vam->retval = retval;
1455 vam->sw_if_index = ntohl (mp->sw_if_index);
1456 vam->result_ready = 1;
1461 static void vl_api_tap_connect_reply_t_handler_json
1462 (vl_api_tap_connect_reply_t * mp)
1464 vat_main_t *vam = &vat_main;
1465 vat_json_node_t node;
1467 vat_json_init_object (&node);
1468 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1469 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1471 vat_json_print (vam->ofp, &node);
1472 vat_json_free (&node);
1474 vam->retval = ntohl (mp->retval);
1475 vam->result_ready = 1;
1480 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->sw_if_index = ntohl (mp->sw_if_index);
1492 vam->result_ready = 1;
1496 static void vl_api_tap_modify_reply_t_handler_json
1497 (vl_api_tap_modify_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 vat_json_node_t node;
1502 vat_json_init_object (&node);
1503 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1504 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1506 vat_json_print (vam->ofp, &node);
1507 vat_json_free (&node);
1509 vam->retval = ntohl (mp->retval);
1510 vam->result_ready = 1;
1514 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1516 vat_main_t *vam = &vat_main;
1517 i32 retval = ntohl (mp->retval);
1518 if (vam->async_mode)
1520 vam->async_errors += (retval < 0);
1524 vam->retval = retval;
1525 vam->result_ready = 1;
1529 static void vl_api_tap_delete_reply_t_handler_json
1530 (vl_api_tap_delete_reply_t * mp)
1532 vat_main_t *vam = &vat_main;
1533 vat_json_node_t node;
1535 vat_json_init_object (&node);
1536 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1538 vat_json_print (vam->ofp, &node);
1539 vat_json_free (&node);
1541 vam->retval = ntohl (mp->retval);
1542 vam->result_ready = 1;
1545 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1546 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 i32 retval = ntohl (mp->retval);
1550 if (vam->async_mode)
1552 vam->async_errors += (retval < 0);
1556 vam->retval = retval;
1557 vam->result_ready = 1;
1561 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1562 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1564 vat_main_t *vam = &vat_main;
1565 vat_json_node_t node;
1567 vat_json_init_object (&node);
1568 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1569 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1570 ntohl (mp->sw_if_index));
1572 vat_json_print (vam->ofp, &node);
1573 vat_json_free (&node);
1575 vam->retval = ntohl (mp->retval);
1576 vam->result_ready = 1;
1579 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1580 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1582 vat_main_t *vam = &vat_main;
1583 i32 retval = ntohl (mp->retval);
1584 if (vam->async_mode)
1586 vam->async_errors += (retval < 0);
1590 vam->retval = retval;
1591 vam->sw_if_index = ntohl (mp->sw_if_index);
1592 vam->result_ready = 1;
1596 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1597 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 vat_json_node_t node;
1602 vat_json_init_object (&node);
1603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1604 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1606 vat_json_print (vam->ofp, &node);
1607 vat_json_free (&node);
1609 vam->retval = ntohl (mp->retval);
1610 vam->result_ready = 1;
1614 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1615 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1617 vat_main_t *vam = &vat_main;
1618 i32 retval = ntohl (mp->retval);
1619 if (vam->async_mode)
1621 vam->async_errors += (retval < 0);
1625 vam->retval = retval;
1626 vam->result_ready = 1;
1630 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1631 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 vat_json_node_t node;
1636 vat_json_init_object (&node);
1637 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1640 vat_json_print (vam->ofp, &node);
1641 vat_json_free (&node);
1643 vam->retval = ntohl (mp->retval);
1644 vam->result_ready = 1;
1647 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1648 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 i32 retval = ntohl (mp->retval);
1652 if (vam->async_mode)
1654 vam->async_errors += (retval < 0);
1658 vam->retval = retval;
1659 vam->sw_if_index = ntohl (mp->sw_if_index);
1660 vam->result_ready = 1;
1664 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1665 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 vat_json_node_t node;
1670 vat_json_init_object (&node);
1671 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1672 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1674 vat_json_print (vam->ofp, &node);
1675 vat_json_free (&node);
1677 vam->retval = ntohl (mp->retval);
1678 vam->result_ready = 1;
1681 static void vl_api_gre_add_del_tunnel_reply_t_handler
1682 (vl_api_gre_add_del_tunnel_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 i32 retval = ntohl (mp->retval);
1686 if (vam->async_mode)
1688 vam->async_errors += (retval < 0);
1692 vam->retval = retval;
1693 vam->sw_if_index = ntohl (mp->sw_if_index);
1694 vam->result_ready = 1;
1698 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1699 (vl_api_gre_add_del_tunnel_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 vat_json_node_t node;
1704 vat_json_init_object (&node);
1705 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1706 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1708 vat_json_print (vam->ofp, &node);
1709 vat_json_free (&node);
1711 vam->retval = ntohl (mp->retval);
1712 vam->result_ready = 1;
1715 static void vl_api_create_vhost_user_if_reply_t_handler
1716 (vl_api_create_vhost_user_if_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 i32 retval = ntohl (mp->retval);
1720 if (vam->async_mode)
1722 vam->async_errors += (retval < 0);
1726 vam->retval = retval;
1727 vam->sw_if_index = ntohl (mp->sw_if_index);
1728 vam->result_ready = 1;
1732 static void vl_api_create_vhost_user_if_reply_t_handler_json
1733 (vl_api_create_vhost_user_if_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 vat_json_node_t node;
1738 vat_json_init_object (&node);
1739 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1740 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1742 vat_json_print (vam->ofp, &node);
1743 vat_json_free (&node);
1745 vam->retval = ntohl (mp->retval);
1746 vam->result_ready = 1;
1749 static void vl_api_ip_address_details_t_handler
1750 (vl_api_ip_address_details_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 static ip_address_details_t empty_ip_address_details = { {0} };
1754 ip_address_details_t *address = NULL;
1755 ip_details_t *current_ip_details = NULL;
1756 ip_details_t *details = NULL;
1758 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1760 if (!details || vam->current_sw_if_index >= vec_len (details)
1761 || !details[vam->current_sw_if_index].present)
1763 errmsg ("ip address details arrived but not stored");
1764 errmsg ("ip_dump should be called first");
1768 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1770 #define addresses (current_ip_details->addr)
1772 vec_validate_init_empty (addresses, vec_len (addresses),
1773 empty_ip_address_details);
1775 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1777 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1778 address->prefix_length = mp->prefix_length;
1782 static void vl_api_ip_address_details_t_handler_json
1783 (vl_api_ip_address_details_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t *node = NULL;
1787 struct in6_addr ip6;
1790 if (VAT_JSON_ARRAY != vam->json_tree.type)
1792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1793 vat_json_init_array (&vam->json_tree);
1795 node = vat_json_array_add (&vam->json_tree);
1797 vat_json_init_object (node);
1800 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1801 vat_json_object_add_ip6 (node, "ip", ip6);
1805 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1806 vat_json_object_add_ip4 (node, "ip", ip4);
1808 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1812 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1814 vat_main_t *vam = &vat_main;
1815 static ip_details_t empty_ip_details = { 0 };
1816 ip_details_t *ip = NULL;
1817 u32 sw_if_index = ~0;
1819 sw_if_index = ntohl (mp->sw_if_index);
1821 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1822 sw_if_index, empty_ip_details);
1824 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1831 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1833 vat_main_t *vam = &vat_main;
1835 if (VAT_JSON_ARRAY != vam->json_tree.type)
1837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1838 vat_json_init_array (&vam->json_tree);
1840 vat_json_array_add_uint (&vam->json_tree,
1841 clib_net_to_host_u32 (mp->sw_if_index));
1844 static void vl_api_map_domain_details_t_handler_json
1845 (vl_api_map_domain_details_t * mp)
1847 vat_json_node_t *node = NULL;
1848 vat_main_t *vam = &vat_main;
1849 struct in6_addr ip6;
1852 if (VAT_JSON_ARRAY != vam->json_tree.type)
1854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1855 vat_json_init_array (&vam->json_tree);
1858 node = vat_json_array_add (&vam->json_tree);
1859 vat_json_init_object (node);
1861 vat_json_object_add_uint (node, "domain_index",
1862 clib_net_to_host_u32 (mp->domain_index));
1863 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1864 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1865 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1866 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1867 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1868 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1869 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1870 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1871 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1872 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1873 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1874 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1875 vat_json_object_add_uint (node, "flags", mp->flags);
1876 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1877 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1880 static void vl_api_map_domain_details_t_handler
1881 (vl_api_map_domain_details_t * mp)
1883 vat_main_t *vam = &vat_main;
1885 if (mp->is_translation)
1888 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1889 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1890 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1891 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1892 clib_net_to_host_u32 (mp->domain_index));
1897 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1898 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1899 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1900 format_ip6_address, mp->ip6_src,
1901 clib_net_to_host_u32 (mp->domain_index));
1903 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1904 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1905 mp->is_translation ? "map-t" : "");
1908 static void vl_api_map_rule_details_t_handler_json
1909 (vl_api_map_rule_details_t * mp)
1911 struct in6_addr ip6;
1912 vat_json_node_t *node = NULL;
1913 vat_main_t *vam = &vat_main;
1915 if (VAT_JSON_ARRAY != vam->json_tree.type)
1917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1918 vat_json_init_array (&vam->json_tree);
1921 node = vat_json_array_add (&vam->json_tree);
1922 vat_json_init_object (node);
1924 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1925 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1926 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1930 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1932 vat_main_t *vam = &vat_main;
1933 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1934 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1938 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1940 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1941 "router_addr %U host_mac %U",
1942 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1943 format_ip4_address, &mp->host_address,
1944 format_ip4_address, &mp->router_address,
1945 format_ethernet_address, mp->host_mac);
1948 static void vl_api_dhcp_compl_event_t_handler_json
1949 (vl_api_dhcp_compl_event_t * mp)
1951 /* JSON output not supported */
1955 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1958 vat_main_t *vam = &vat_main;
1959 static u64 default_counter = 0;
1961 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1963 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1964 sw_if_index, default_counter);
1965 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1969 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1970 interface_counter_t counter)
1972 vat_main_t *vam = &vat_main;
1973 static interface_counter_t default_counter = { 0, };
1975 vec_validate_init_empty (vam->combined_interface_counters,
1976 vnet_counter_type, NULL);
1977 vec_validate_init_empty (vam->combined_interface_counters
1978 [vnet_counter_type], sw_if_index, default_counter);
1979 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1982 static void vl_api_vnet_interface_counters_t_handler
1983 (vl_api_vnet_interface_counters_t * mp)
1988 static void vl_api_vnet_interface_counters_t_handler_json
1989 (vl_api_vnet_interface_counters_t * mp)
1991 interface_counter_t counter;
1996 u32 first_sw_if_index;
1999 count = ntohl (mp->count);
2000 first_sw_if_index = ntohl (mp->first_sw_if_index);
2002 if (!mp->is_combined)
2004 v_packets = (u64 *) & mp->data;
2005 for (i = 0; i < count; i++)
2008 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2009 set_simple_interface_counter (mp->vnet_counter_type,
2010 first_sw_if_index + i, packets);
2016 v = (vlib_counter_t *) & mp->data;
2017 for (i = 0; i < count; i++)
2020 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2022 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2023 set_combined_interface_counter (mp->vnet_counter_type,
2024 first_sw_if_index + i, counter);
2031 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2033 vat_main_t *vam = &vat_main;
2036 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2038 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2047 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2049 vat_main_t *vam = &vat_main;
2052 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2054 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2062 static void vl_api_vnet_ip4_fib_counters_t_handler
2063 (vl_api_vnet_ip4_fib_counters_t * mp)
2068 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2069 (vl_api_vnet_ip4_fib_counters_t * mp)
2071 vat_main_t *vam = &vat_main;
2072 vl_api_ip4_fib_counter_t *v;
2073 ip4_fib_counter_t *counter;
2080 vrf_id = ntohl (mp->vrf_id);
2081 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2082 if (~0 == vrf_index)
2084 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2085 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2086 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2087 vec_validate (vam->ip4_fib_counters, vrf_index);
2088 vam->ip4_fib_counters[vrf_index] = NULL;
2091 vec_free (vam->ip4_fib_counters[vrf_index]);
2092 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2093 count = ntohl (mp->count);
2094 for (i = 0; i < count; i++)
2096 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2097 counter = &vam->ip4_fib_counters[vrf_index][i];
2098 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2099 counter->address = ip4;
2100 counter->address_length = v->address_length;
2101 counter->packets = clib_net_to_host_u64 (v->packets);
2102 counter->bytes = clib_net_to_host_u64 (v->bytes);
2107 static void vl_api_vnet_ip4_nbr_counters_t_handler
2108 (vl_api_vnet_ip4_nbr_counters_t * mp)
2113 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2114 (vl_api_vnet_ip4_nbr_counters_t * mp)
2116 vat_main_t *vam = &vat_main;
2117 vl_api_ip4_nbr_counter_t *v;
2118 ip4_nbr_counter_t *counter;
2123 sw_if_index = ntohl (mp->sw_if_index);
2124 count = ntohl (mp->count);
2125 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2128 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2130 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2131 for (i = 0; i < count; i++)
2133 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2134 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2135 counter->address.s_addr = v->address;
2136 counter->packets = clib_net_to_host_u64 (v->packets);
2137 counter->bytes = clib_net_to_host_u64 (v->bytes);
2138 counter->linkt = v->link_type;
2143 static void vl_api_vnet_ip6_fib_counters_t_handler
2144 (vl_api_vnet_ip6_fib_counters_t * mp)
2149 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2150 (vl_api_vnet_ip6_fib_counters_t * mp)
2152 vat_main_t *vam = &vat_main;
2153 vl_api_ip6_fib_counter_t *v;
2154 ip6_fib_counter_t *counter;
2155 struct in6_addr ip6;
2161 vrf_id = ntohl (mp->vrf_id);
2162 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2163 if (~0 == vrf_index)
2165 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2166 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2167 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2168 vec_validate (vam->ip6_fib_counters, vrf_index);
2169 vam->ip6_fib_counters[vrf_index] = NULL;
2172 vec_free (vam->ip6_fib_counters[vrf_index]);
2173 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2174 count = ntohl (mp->count);
2175 for (i = 0; i < count; i++)
2177 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2178 counter = &vam->ip6_fib_counters[vrf_index][i];
2179 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2180 counter->address = ip6;
2181 counter->address_length = v->address_length;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2188 static void vl_api_vnet_ip6_nbr_counters_t_handler
2189 (vl_api_vnet_ip6_nbr_counters_t * mp)
2194 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2195 (vl_api_vnet_ip6_nbr_counters_t * mp)
2197 vat_main_t *vam = &vat_main;
2198 vl_api_ip6_nbr_counter_t *v;
2199 ip6_nbr_counter_t *counter;
2200 struct in6_addr ip6;
2205 sw_if_index = ntohl (mp->sw_if_index);
2206 count = ntohl (mp->count);
2207 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2210 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2212 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2213 for (i = 0; i < count; i++)
2215 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2216 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2217 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2218 counter->address = ip6;
2219 counter->packets = clib_net_to_host_u64 (v->packets);
2220 counter->bytes = clib_net_to_host_u64 (v->bytes);
2225 static void vl_api_get_first_msg_id_reply_t_handler
2226 (vl_api_get_first_msg_id_reply_t * mp)
2228 vat_main_t *vam = &vat_main;
2229 i32 retval = ntohl (mp->retval);
2231 if (vam->async_mode)
2233 vam->async_errors += (retval < 0);
2237 vam->retval = retval;
2238 vam->result_ready = 1;
2242 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2246 static void vl_api_get_first_msg_id_reply_t_handler_json
2247 (vl_api_get_first_msg_id_reply_t * mp)
2249 vat_main_t *vam = &vat_main;
2250 vat_json_node_t node;
2252 vat_json_init_object (&node);
2253 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2254 vat_json_object_add_uint (&node, "first_msg_id",
2255 (uint) ntohs (mp->first_msg_id));
2257 vat_json_print (vam->ofp, &node);
2258 vat_json_free (&node);
2260 vam->retval = ntohl (mp->retval);
2261 vam->result_ready = 1;
2264 static void vl_api_get_node_graph_reply_t_handler
2265 (vl_api_get_node_graph_reply_t * mp)
2267 vat_main_t *vam = &vat_main;
2268 api_main_t *am = &api_main;
2269 i32 retval = ntohl (mp->retval);
2270 u8 *pvt_copy, *reply;
2275 if (vam->async_mode)
2277 vam->async_errors += (retval < 0);
2281 vam->retval = retval;
2282 vam->result_ready = 1;
2285 /* "Should never happen..." */
2289 reply = (u8 *) (mp->reply_in_shmem);
2290 pvt_copy = vec_dup (reply);
2292 /* Toss the shared-memory original... */
2293 pthread_mutex_lock (&am->vlib_rp->mutex);
2294 oldheap = svm_push_data_heap (am->vlib_rp);
2298 svm_pop_heap (oldheap);
2299 pthread_mutex_unlock (&am->vlib_rp->mutex);
2301 if (vam->graph_nodes)
2303 hash_free (vam->graph_node_index_by_name);
2305 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2307 node = vam->graph_nodes[i];
2308 vec_free (node->name);
2309 vec_free (node->next_nodes);
2312 vec_free (vam->graph_nodes);
2315 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2316 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2317 vec_free (pvt_copy);
2319 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2321 node = vam->graph_nodes[i];
2322 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2326 static void vl_api_get_node_graph_reply_t_handler_json
2327 (vl_api_get_node_graph_reply_t * mp)
2329 vat_main_t *vam = &vat_main;
2330 api_main_t *am = &api_main;
2332 vat_json_node_t node;
2335 /* $$$$ make this real? */
2336 vat_json_init_object (&node);
2337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2338 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2340 reply = (u8 *) (mp->reply_in_shmem);
2342 /* Toss the shared-memory original... */
2343 pthread_mutex_lock (&am->vlib_rp->mutex);
2344 oldheap = svm_push_data_heap (am->vlib_rp);
2348 svm_pop_heap (oldheap);
2349 pthread_mutex_unlock (&am->vlib_rp->mutex);
2351 vat_json_print (vam->ofp, &node);
2352 vat_json_free (&node);
2354 vam->retval = ntohl (mp->retval);
2355 vam->result_ready = 1;
2359 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2361 vat_main_t *vam = &vat_main;
2366 s = format (s, "%=16d%=16d%=16d",
2367 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2371 s = format (s, "%=16U%=16d%=16d",
2372 mp->is_ipv6 ? format_ip6_address :
2374 mp->ip_address, mp->priority, mp->weight);
2377 print (vam->ofp, "%v", s);
2382 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2385 vat_main_t *vam = &vat_main;
2386 vat_json_node_t *node = NULL;
2387 struct in6_addr ip6;
2390 if (VAT_JSON_ARRAY != vam->json_tree.type)
2392 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2393 vat_json_init_array (&vam->json_tree);
2395 node = vat_json_array_add (&vam->json_tree);
2396 vat_json_init_object (node);
2398 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2399 vat_json_object_add_uint (node, "priority", mp->priority);
2400 vat_json_object_add_uint (node, "weight", mp->weight);
2403 vat_json_object_add_uint (node, "sw_if_index",
2404 clib_net_to_host_u32 (mp->sw_if_index));
2409 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2410 vat_json_object_add_ip6 (node, "address", ip6);
2414 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2415 vat_json_object_add_ip4 (node, "address", ip4);
2421 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2424 vat_main_t *vam = &vat_main;
2427 ls_name = format (0, "%s", mp->ls_name);
2429 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2435 vl_api_lisp_locator_set_details_t_handler_json
2436 (vl_api_lisp_locator_set_details_t * mp)
2438 vat_main_t *vam = &vat_main;
2439 vat_json_node_t *node = 0;
2442 ls_name = format (0, "%s", mp->ls_name);
2443 vec_add1 (ls_name, 0);
2445 if (VAT_JSON_ARRAY != vam->json_tree.type)
2447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2448 vat_json_init_array (&vam->json_tree);
2450 node = vat_json_array_add (&vam->json_tree);
2452 vat_json_init_object (node);
2453 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2454 vat_json_object_add_uint (node, "ls_index",
2455 clib_net_to_host_u32 (mp->ls_index));
2460 format_lisp_flat_eid (u8 * s, va_list * args)
2462 u32 type = va_arg (*args, u32);
2463 u8 *eid = va_arg (*args, u8 *);
2464 u32 eid_len = va_arg (*args, u32);
2469 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2471 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2473 return format (s, "%U", format_ethernet_address, eid);
2479 format_lisp_eid_vat (u8 * s, va_list * args)
2481 u32 type = va_arg (*args, u32);
2482 u8 *eid = va_arg (*args, u8 *);
2483 u32 eid_len = va_arg (*args, u32);
2484 u8 *seid = va_arg (*args, u8 *);
2485 u32 seid_len = va_arg (*args, u32);
2486 u32 is_src_dst = va_arg (*args, u32);
2489 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2491 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2497 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2499 vat_main_t *vam = &vat_main;
2500 u8 *s = 0, *eid = 0;
2502 if (~0 == mp->locator_set_index)
2503 s = format (0, "action: %d", mp->action);
2505 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2507 eid = format (0, "%U", format_lisp_eid_vat,
2511 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2514 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2515 clib_net_to_host_u32 (mp->vni),
2517 mp->is_local ? "local" : "remote",
2518 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2519 clib_net_to_host_u16 (mp->key_id), mp->key);
2526 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2529 vat_main_t *vam = &vat_main;
2530 vat_json_node_t *node = 0;
2533 if (VAT_JSON_ARRAY != vam->json_tree.type)
2535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2536 vat_json_init_array (&vam->json_tree);
2538 node = vat_json_array_add (&vam->json_tree);
2540 vat_json_init_object (node);
2541 if (~0 == mp->locator_set_index)
2542 vat_json_object_add_uint (node, "action", mp->action);
2544 vat_json_object_add_uint (node, "locator_set_index",
2545 clib_net_to_host_u32 (mp->locator_set_index));
2547 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2548 eid = format (0, "%U", format_lisp_eid_vat,
2552 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2554 vat_json_object_add_string_copy (node, "eid", eid);
2555 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2556 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2557 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2561 vat_json_object_add_uint (node, "key_id",
2562 clib_net_to_host_u16 (mp->key_id));
2563 vat_json_object_add_string_copy (node, "key", mp->key);
2569 vl_api_lisp_eid_table_map_details_t_handler
2570 (vl_api_lisp_eid_table_map_details_t * mp)
2572 vat_main_t *vam = &vat_main;
2574 u8 *line = format (0, "%=10d%=10d",
2575 clib_net_to_host_u32 (mp->vni),
2576 clib_net_to_host_u32 (mp->dp_table));
2577 print (vam->ofp, "%v", line);
2582 vl_api_lisp_eid_table_map_details_t_handler_json
2583 (vl_api_lisp_eid_table_map_details_t * mp)
2585 vat_main_t *vam = &vat_main;
2586 vat_json_node_t *node = NULL;
2588 if (VAT_JSON_ARRAY != vam->json_tree.type)
2590 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2591 vat_json_init_array (&vam->json_tree);
2593 node = vat_json_array_add (&vam->json_tree);
2594 vat_json_init_object (node);
2595 vat_json_object_add_uint (node, "dp_table",
2596 clib_net_to_host_u32 (mp->dp_table));
2597 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vl_api_lisp_eid_table_vni_details_t_handler
2602 (vl_api_lisp_eid_table_vni_details_t * mp)
2604 vat_main_t *vam = &vat_main;
2606 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2607 print (vam->ofp, "%v", line);
2612 vl_api_lisp_eid_table_vni_details_t_handler_json
2613 (vl_api_lisp_eid_table_vni_details_t * mp)
2615 vat_main_t *vam = &vat_main;
2616 vat_json_node_t *node = NULL;
2618 if (VAT_JSON_ARRAY != vam->json_tree.type)
2620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2621 vat_json_init_array (&vam->json_tree);
2623 node = vat_json_array_add (&vam->json_tree);
2624 vat_json_init_object (node);
2625 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2629 vl_api_show_lisp_map_register_state_reply_t_handler
2630 (vl_api_show_lisp_map_register_state_reply_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 int retval = clib_net_to_host_u32 (mp->retval);
2635 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2637 vam->retval = retval;
2638 vam->result_ready = 1;
2642 vl_api_show_lisp_map_register_state_reply_t_handler_json
2643 (vl_api_show_lisp_map_register_state_reply_t * mp)
2645 vat_main_t *vam = &vat_main;
2646 vat_json_node_t _node, *node = &_node;
2647 int retval = clib_net_to_host_u32 (mp->retval);
2649 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2651 vat_json_init_object (node);
2652 vat_json_object_add_string_copy (node, "state", s);
2654 vat_json_print (vam->ofp, node);
2655 vat_json_free (node);
2657 vam->retval = retval;
2658 vam->result_ready = 1;
2663 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2664 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2666 vat_main_t *vam = &vat_main;
2667 int retval = clib_net_to_host_u32 (mp->retval);
2672 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2674 vam->retval = retval;
2675 vam->result_ready = 1;
2679 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2680 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2682 vat_main_t *vam = &vat_main;
2683 vat_json_node_t _node, *node = &_node;
2684 int retval = clib_net_to_host_u32 (mp->retval);
2686 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2687 vat_json_init_object (node);
2688 vat_json_object_add_string_copy (node, "state", s);
2690 vat_json_print (vam->ofp, node);
2691 vat_json_free (node);
2693 vam->retval = retval;
2694 vam->result_ready = 1;
2699 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2701 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2702 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2706 gpe_fwd_entries_get_reply_t_net_to_host
2707 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2711 mp->count = clib_net_to_host_u32 (mp->count);
2712 for (i = 0; i < mp->count; i++)
2714 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2719 vl_api_gpe_fwd_entry_path_details_t_handler
2720 (vl_api_gpe_fwd_entry_path_details_t * mp)
2722 vat_main_t *vam = &vat_main;
2723 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2725 if (mp->lcl_loc.is_ip4)
2726 format_ip_address_fcn = format_ip4_address;
2728 format_ip_address_fcn = format_ip6_address;
2730 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2731 format_ip_address_fcn, &mp->lcl_loc,
2732 format_ip_address_fcn, &mp->rmt_loc);
2736 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2738 struct in6_addr ip6;
2743 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2744 vat_json_object_add_ip4 (n, "address", ip4);
2748 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2749 vat_json_object_add_ip6 (n, "address", ip6);
2751 vat_json_object_add_uint (n, "weight", loc->weight);
2755 vl_api_gpe_fwd_entry_path_details_t_handler_json
2756 (vl_api_gpe_fwd_entry_path_details_t * mp)
2758 vat_main_t *vam = &vat_main;
2759 vat_json_node_t *node = NULL;
2760 vat_json_node_t *loc_node;
2762 if (VAT_JSON_ARRAY != vam->json_tree.type)
2764 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2765 vat_json_init_array (&vam->json_tree);
2767 node = vat_json_array_add (&vam->json_tree);
2768 vat_json_init_object (node);
2770 loc_node = vat_json_object_add (node, "local_locator");
2771 vat_json_init_object (loc_node);
2772 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2774 loc_node = vat_json_object_add (node, "remote_locator");
2775 vat_json_init_object (loc_node);
2776 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2780 vl_api_gpe_fwd_entries_get_reply_t_handler
2781 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2783 vat_main_t *vam = &vat_main;
2785 int retval = clib_net_to_host_u32 (mp->retval);
2786 vl_api_gpe_fwd_entry_t *e;
2791 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2793 for (i = 0; i < mp->count; i++)
2795 e = &mp->entries[i];
2796 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2797 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2798 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2802 vam->retval = retval;
2803 vam->result_ready = 1;
2807 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2808 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2811 vat_main_t *vam = &vat_main;
2812 vat_json_node_t *e = 0, root;
2814 int retval = clib_net_to_host_u32 (mp->retval);
2815 vl_api_gpe_fwd_entry_t *fwd;
2820 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2821 vat_json_init_array (&root);
2823 for (i = 0; i < mp->count; i++)
2825 e = vat_json_array_add (&root);
2826 fwd = &mp->entries[i];
2828 vat_json_init_object (e);
2829 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2830 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2832 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2833 fwd->leid_prefix_len);
2835 vat_json_object_add_string_copy (e, "leid", s);
2838 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2839 fwd->reid_prefix_len);
2841 vat_json_object_add_string_copy (e, "reid", s);
2845 vat_json_print (vam->ofp, &root);
2846 vat_json_free (&root);
2849 vam->retval = retval;
2850 vam->result_ready = 1;
2854 vl_api_lisp_adjacencies_get_reply_t_handler
2855 (vl_api_lisp_adjacencies_get_reply_t * mp)
2857 vat_main_t *vam = &vat_main;
2859 int retval = clib_net_to_host_u32 (mp->retval);
2860 vl_api_lisp_adjacency_t *a;
2865 n = clib_net_to_host_u32 (mp->count);
2867 for (i = 0; i < n; i++)
2869 a = &mp->adjacencies[i];
2870 print (vam->ofp, "%U %40U",
2871 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2872 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2876 vam->retval = retval;
2877 vam->result_ready = 1;
2881 vl_api_lisp_adjacencies_get_reply_t_handler_json
2882 (vl_api_lisp_adjacencies_get_reply_t * mp)
2885 vat_main_t *vam = &vat_main;
2886 vat_json_node_t *e = 0, root;
2888 int retval = clib_net_to_host_u32 (mp->retval);
2889 vl_api_lisp_adjacency_t *a;
2894 n = clib_net_to_host_u32 (mp->count);
2895 vat_json_init_array (&root);
2897 for (i = 0; i < n; i++)
2899 e = vat_json_array_add (&root);
2900 a = &mp->adjacencies[i];
2902 vat_json_init_object (e);
2903 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2904 a->leid_prefix_len);
2906 vat_json_object_add_string_copy (e, "leid", s);
2909 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2910 a->reid_prefix_len);
2912 vat_json_object_add_string_copy (e, "reid", s);
2916 vat_json_print (vam->ofp, &root);
2917 vat_json_free (&root);
2920 vam->retval = retval;
2921 vam->result_ready = 1;
2925 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2928 vat_main_t *vam = &vat_main;
2930 print (vam->ofp, "%=20U",
2931 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2936 vl_api_lisp_map_server_details_t_handler_json
2937 (vl_api_lisp_map_server_details_t * mp)
2939 vat_main_t *vam = &vat_main;
2940 vat_json_node_t *node = NULL;
2941 struct in6_addr ip6;
2944 if (VAT_JSON_ARRAY != vam->json_tree.type)
2946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2947 vat_json_init_array (&vam->json_tree);
2949 node = vat_json_array_add (&vam->json_tree);
2951 vat_json_init_object (node);
2954 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2955 vat_json_object_add_ip6 (node, "map-server", ip6);
2959 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2960 vat_json_object_add_ip4 (node, "map-server", ip4);
2965 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2968 vat_main_t *vam = &vat_main;
2970 print (vam->ofp, "%=20U",
2971 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2976 vl_api_lisp_map_resolver_details_t_handler_json
2977 (vl_api_lisp_map_resolver_details_t * mp)
2979 vat_main_t *vam = &vat_main;
2980 vat_json_node_t *node = NULL;
2981 struct in6_addr ip6;
2984 if (VAT_JSON_ARRAY != vam->json_tree.type)
2986 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2987 vat_json_init_array (&vam->json_tree);
2989 node = vat_json_array_add (&vam->json_tree);
2991 vat_json_init_object (node);
2994 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2995 vat_json_object_add_ip6 (node, "map resolver", ip6);
2999 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3000 vat_json_object_add_ip4 (node, "map resolver", ip4);
3005 vl_api_show_lisp_status_reply_t_handler
3006 (vl_api_show_lisp_status_reply_t * mp)
3008 vat_main_t *vam = &vat_main;
3009 i32 retval = ntohl (mp->retval);
3013 print (vam->ofp, "feature: %s\ngpe: %s",
3014 mp->feature_status ? "enabled" : "disabled",
3015 mp->gpe_status ? "enabled" : "disabled");
3018 vam->retval = retval;
3019 vam->result_ready = 1;
3023 vl_api_show_lisp_status_reply_t_handler_json
3024 (vl_api_show_lisp_status_reply_t * mp)
3026 vat_main_t *vam = &vat_main;
3027 vat_json_node_t node;
3028 u8 *gpe_status = NULL;
3029 u8 *feature_status = NULL;
3031 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3032 feature_status = format (0, "%s",
3033 mp->feature_status ? "enabled" : "disabled");
3034 vec_add1 (gpe_status, 0);
3035 vec_add1 (feature_status, 0);
3037 vat_json_init_object (&node);
3038 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3039 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3041 vec_free (gpe_status);
3042 vec_free (feature_status);
3044 vat_json_print (vam->ofp, &node);
3045 vat_json_free (&node);
3047 vam->retval = ntohl (mp->retval);
3048 vam->result_ready = 1;
3052 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
3053 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
3055 vat_main_t *vam = &vat_main;
3056 i32 retval = ntohl (mp->retval);
3060 print (vam->ofp, "%=20s", mp->locator_set_name);
3063 vam->retval = retval;
3064 vam->result_ready = 1;
3068 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
3069 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
3071 vat_main_t *vam = &vat_main;
3072 vat_json_node_t *node = NULL;
3074 if (VAT_JSON_ARRAY != vam->json_tree.type)
3076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3077 vat_json_init_array (&vam->json_tree);
3079 node = vat_json_array_add (&vam->json_tree);
3081 vat_json_init_object (node);
3082 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3084 vat_json_print (vam->ofp, node);
3085 vat_json_free (node);
3087 vam->retval = ntohl (mp->retval);
3088 vam->result_ready = 1;
3092 format_lisp_map_request_mode (u8 * s, va_list * args)
3094 u32 mode = va_arg (*args, u32);
3099 return format (0, "dst-only");
3101 return format (0, "src-dst");
3107 vl_api_show_lisp_map_request_mode_reply_t_handler
3108 (vl_api_show_lisp_map_request_mode_reply_t * mp)
3110 vat_main_t *vam = &vat_main;
3111 i32 retval = ntohl (mp->retval);
3115 u32 mode = mp->mode;
3116 print (vam->ofp, "map_request_mode: %U",
3117 format_lisp_map_request_mode, mode);
3120 vam->retval = retval;
3121 vam->result_ready = 1;
3125 vl_api_show_lisp_map_request_mode_reply_t_handler_json
3126 (vl_api_show_lisp_map_request_mode_reply_t * mp)
3128 vat_main_t *vam = &vat_main;
3129 vat_json_node_t node;
3134 s = format (0, "%U", format_lisp_map_request_mode, mode);
3137 vat_json_init_object (&node);
3138 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3139 vat_json_print (vam->ofp, &node);
3140 vat_json_free (&node);
3143 vam->retval = ntohl (mp->retval);
3144 vam->result_ready = 1;
3148 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
3150 vat_main_t *vam = &vat_main;
3151 i32 retval = ntohl (mp->retval);
3155 print (vam->ofp, "%-20s%-16s",
3156 mp->status ? "enabled" : "disabled",
3157 mp->status ? (char *) mp->locator_set_name : "");
3160 vam->retval = retval;
3161 vam->result_ready = 1;
3165 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
3168 vat_main_t *vam = &vat_main;
3169 vat_json_node_t node;
3172 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3173 vec_add1 (status, 0);
3175 vat_json_init_object (&node);
3176 vat_json_object_add_string_copy (&node, "status", status);
3179 vat_json_object_add_string_copy (&node, "locator_set",
3180 mp->locator_set_name);
3185 vat_json_print (vam->ofp, &node);
3186 vat_json_free (&node);
3188 vam->retval = ntohl (mp->retval);
3189 vam->result_ready = 1;
3193 format_policer_type (u8 * s, va_list * va)
3195 u32 i = va_arg (*va, u32);
3197 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3198 s = format (s, "1r2c");
3199 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3200 s = format (s, "1r3c");
3201 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3202 s = format (s, "2r3c-2698");
3203 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3204 s = format (s, "2r3c-4115");
3205 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3206 s = format (s, "2r3c-mef5cf1");
3208 s = format (s, "ILLEGAL");
3213 format_policer_rate_type (u8 * s, va_list * va)
3215 u32 i = va_arg (*va, u32);
3217 if (i == SSE2_QOS_RATE_KBPS)
3218 s = format (s, "kbps");
3219 else if (i == SSE2_QOS_RATE_PPS)
3220 s = format (s, "pps");
3222 s = format (s, "ILLEGAL");
3227 format_policer_round_type (u8 * s, va_list * va)
3229 u32 i = va_arg (*va, u32);
3231 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3232 s = format (s, "closest");
3233 else if (i == SSE2_QOS_ROUND_TO_UP)
3234 s = format (s, "up");
3235 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3236 s = format (s, "down");
3238 s = format (s, "ILLEGAL");
3243 format_policer_action_type (u8 * s, va_list * va)
3245 u32 i = va_arg (*va, u32);
3247 if (i == SSE2_QOS_ACTION_DROP)
3248 s = format (s, "drop");
3249 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3250 s = format (s, "transmit");
3251 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3252 s = format (s, "mark-and-transmit");
3254 s = format (s, "ILLEGAL");
3259 format_dscp (u8 * s, va_list * va)
3261 u32 i = va_arg (*va, u32);
3266 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3270 return format (s, "ILLEGAL");
3272 s = format (s, "%s", t);
3277 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3279 vat_main_t *vam = &vat_main;
3280 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3282 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3283 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3285 conform_dscp_str = format (0, "");
3287 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3288 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3290 exceed_dscp_str = format (0, "");
3292 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3293 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3295 violate_dscp_str = format (0, "");
3297 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3298 "rate type %U, round type %U, %s rate, %s color-aware, "
3299 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3300 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3301 "conform action %U%s, exceed action %U%s, violate action %U%s",
3303 format_policer_type, mp->type,
3306 clib_net_to_host_u64 (mp->cb),
3307 clib_net_to_host_u64 (mp->eb),
3308 format_policer_rate_type, mp->rate_type,
3309 format_policer_round_type, mp->round_type,
3310 mp->single_rate ? "single" : "dual",
3311 mp->color_aware ? "is" : "not",
3312 ntohl (mp->cir_tokens_per_period),
3313 ntohl (mp->pir_tokens_per_period),
3315 ntohl (mp->current_limit),
3316 ntohl (mp->current_bucket),
3317 ntohl (mp->extended_limit),
3318 ntohl (mp->extended_bucket),
3319 clib_net_to_host_u64 (mp->last_update_time),
3320 format_policer_action_type, mp->conform_action_type,
3322 format_policer_action_type, mp->exceed_action_type,
3324 format_policer_action_type, mp->violate_action_type,
3327 vec_free (conform_dscp_str);
3328 vec_free (exceed_dscp_str);
3329 vec_free (violate_dscp_str);
3332 static void vl_api_policer_details_t_handler_json
3333 (vl_api_policer_details_t * mp)
3335 vat_main_t *vam = &vat_main;
3336 vat_json_node_t *node;
3337 u8 *rate_type_str, *round_type_str, *type_str;
3338 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3340 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3342 format (0, "%U", format_policer_round_type, mp->round_type);
3343 type_str = format (0, "%U", format_policer_type, mp->type);
3344 conform_action_str = format (0, "%U", format_policer_action_type,
3345 mp->conform_action_type);
3346 exceed_action_str = format (0, "%U", format_policer_action_type,
3347 mp->exceed_action_type);
3348 violate_action_str = format (0, "%U", format_policer_action_type,
3349 mp->violate_action_type);
3351 if (VAT_JSON_ARRAY != vam->json_tree.type)
3353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3354 vat_json_init_array (&vam->json_tree);
3356 node = vat_json_array_add (&vam->json_tree);
3358 vat_json_init_object (node);
3359 vat_json_object_add_string_copy (node, "name", mp->name);
3360 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3361 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3362 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3363 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3364 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3365 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3366 vat_json_object_add_string_copy (node, "type", type_str);
3367 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3368 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3369 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3370 vat_json_object_add_uint (node, "cir_tokens_per_period",
3371 ntohl (mp->cir_tokens_per_period));
3372 vat_json_object_add_uint (node, "eir_tokens_per_period",
3373 ntohl (mp->pir_tokens_per_period));
3374 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3375 vat_json_object_add_uint (node, "current_bucket",
3376 ntohl (mp->current_bucket));
3377 vat_json_object_add_uint (node, "extended_limit",
3378 ntohl (mp->extended_limit));
3379 vat_json_object_add_uint (node, "extended_bucket",
3380 ntohl (mp->extended_bucket));
3381 vat_json_object_add_uint (node, "last_update_time",
3382 ntohl (mp->last_update_time));
3383 vat_json_object_add_string_copy (node, "conform_action",
3384 conform_action_str);
3385 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3387 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3388 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3389 vec_free (dscp_str);
3391 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3392 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3394 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3395 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3396 vec_free (dscp_str);
3398 vat_json_object_add_string_copy (node, "violate_action",
3399 violate_action_str);
3400 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3402 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3403 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3404 vec_free (dscp_str);
3407 vec_free (rate_type_str);
3408 vec_free (round_type_str);
3409 vec_free (type_str);
3410 vec_free (conform_action_str);
3411 vec_free (exceed_action_str);
3412 vec_free (violate_action_str);
3416 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3419 vat_main_t *vam = &vat_main;
3420 int i, count = ntohl (mp->count);
3423 print (vam->ofp, "classify table ids (%d) : ", count);
3424 for (i = 0; i < count; i++)
3426 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3427 print (vam->ofp, (i < count - 1) ? "," : "");
3429 vam->retval = ntohl (mp->retval);
3430 vam->result_ready = 1;
3434 vl_api_classify_table_ids_reply_t_handler_json
3435 (vl_api_classify_table_ids_reply_t * mp)
3437 vat_main_t *vam = &vat_main;
3438 int i, count = ntohl (mp->count);
3442 vat_json_node_t node;
3444 vat_json_init_object (&node);
3445 for (i = 0; i < count; i++)
3447 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3449 vat_json_print (vam->ofp, &node);
3450 vat_json_free (&node);
3452 vam->retval = ntohl (mp->retval);
3453 vam->result_ready = 1;
3457 vl_api_classify_table_by_interface_reply_t_handler
3458 (vl_api_classify_table_by_interface_reply_t * mp)
3460 vat_main_t *vam = &vat_main;
3463 table_id = ntohl (mp->l2_table_id);
3465 print (vam->ofp, "l2 table id : %d", table_id);
3467 print (vam->ofp, "l2 table id : No input ACL tables configured");
3468 table_id = ntohl (mp->ip4_table_id);
3470 print (vam->ofp, "ip4 table id : %d", table_id);
3472 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3473 table_id = ntohl (mp->ip6_table_id);
3475 print (vam->ofp, "ip6 table id : %d", table_id);
3477 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3478 vam->retval = ntohl (mp->retval);
3479 vam->result_ready = 1;
3483 vl_api_classify_table_by_interface_reply_t_handler_json
3484 (vl_api_classify_table_by_interface_reply_t * mp)
3486 vat_main_t *vam = &vat_main;
3487 vat_json_node_t node;
3489 vat_json_init_object (&node);
3491 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3492 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3493 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3495 vat_json_print (vam->ofp, &node);
3496 vat_json_free (&node);
3498 vam->retval = ntohl (mp->retval);
3499 vam->result_ready = 1;
3502 static void vl_api_policer_add_del_reply_t_handler
3503 (vl_api_policer_add_del_reply_t * mp)
3505 vat_main_t *vam = &vat_main;
3506 i32 retval = ntohl (mp->retval);
3507 if (vam->async_mode)
3509 vam->async_errors += (retval < 0);
3513 vam->retval = retval;
3514 vam->result_ready = 1;
3515 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3517 * Note: this is just barely thread-safe, depends on
3518 * the main thread spinning waiting for an answer...
3520 errmsg ("policer index %d", ntohl (mp->policer_index));
3524 static void vl_api_policer_add_del_reply_t_handler_json
3525 (vl_api_policer_add_del_reply_t * mp)
3527 vat_main_t *vam = &vat_main;
3528 vat_json_node_t node;
3530 vat_json_init_object (&node);
3531 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3532 vat_json_object_add_uint (&node, "policer_index",
3533 ntohl (mp->policer_index));
3535 vat_json_print (vam->ofp, &node);
3536 vat_json_free (&node);
3538 vam->retval = ntohl (mp->retval);
3539 vam->result_ready = 1;
3542 /* Format hex dump. */
3544 format_hex_bytes (u8 * s, va_list * va)
3546 u8 *bytes = va_arg (*va, u8 *);
3547 int n_bytes = va_arg (*va, int);
3550 /* Print short or long form depending on byte count. */
3551 uword short_form = n_bytes <= 32;
3552 uword indent = format_get_indent (s);
3557 for (i = 0; i < n_bytes; i++)
3559 if (!short_form && (i % 32) == 0)
3560 s = format (s, "%08x: ", i);
3561 s = format (s, "%02x", bytes[i]);
3562 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3563 s = format (s, "\n%U", format_white_space, indent);
3570 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3573 vat_main_t *vam = &vat_main;
3574 i32 retval = ntohl (mp->retval);
3577 print (vam->ofp, "classify table info :");
3578 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3579 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3580 ntohl (mp->miss_next_index));
3581 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3582 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3583 ntohl (mp->match_n_vectors));
3584 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3585 ntohl (mp->mask_length));
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3592 vl_api_classify_table_info_reply_t_handler_json
3593 (vl_api_classify_table_info_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3596 vat_json_node_t node;
3598 i32 retval = ntohl (mp->retval);
3601 vat_json_init_object (&node);
3603 vat_json_object_add_int (&node, "sessions",
3604 ntohl (mp->active_sessions));
3605 vat_json_object_add_int (&node, "nexttbl",
3606 ntohl (mp->next_table_index));
3607 vat_json_object_add_int (&node, "nextnode",
3608 ntohl (mp->miss_next_index));
3609 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3610 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3611 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3612 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3613 ntohl (mp->mask_length), 0);
3614 vat_json_object_add_string_copy (&node, "mask", s);
3616 vat_json_print (vam->ofp, &node);
3617 vat_json_free (&node);
3619 vam->retval = ntohl (mp->retval);
3620 vam->result_ready = 1;
3624 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3627 vat_main_t *vam = &vat_main;
3629 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3630 ntohl (mp->hit_next_index), ntohl (mp->advance),
3631 ntohl (mp->opaque_index));
3632 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3633 ntohl (mp->match_length));
3637 vl_api_classify_session_details_t_handler_json
3638 (vl_api_classify_session_details_t * mp)
3640 vat_main_t *vam = &vat_main;
3641 vat_json_node_t *node = NULL;
3643 if (VAT_JSON_ARRAY != vam->json_tree.type)
3645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3646 vat_json_init_array (&vam->json_tree);
3648 node = vat_json_array_add (&vam->json_tree);
3650 vat_json_init_object (node);
3651 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3652 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3653 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3655 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3657 vat_json_object_add_string_copy (node, "match", s);
3660 static void vl_api_pg_create_interface_reply_t_handler
3661 (vl_api_pg_create_interface_reply_t * mp)
3663 vat_main_t *vam = &vat_main;
3665 vam->retval = ntohl (mp->retval);
3666 vam->result_ready = 1;
3669 static void vl_api_pg_create_interface_reply_t_handler_json
3670 (vl_api_pg_create_interface_reply_t * mp)
3672 vat_main_t *vam = &vat_main;
3673 vat_json_node_t node;
3675 i32 retval = ntohl (mp->retval);
3678 vat_json_init_object (&node);
3680 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3682 vat_json_print (vam->ofp, &node);
3683 vat_json_free (&node);
3685 vam->retval = ntohl (mp->retval);
3686 vam->result_ready = 1;
3689 static void vl_api_policer_classify_details_t_handler
3690 (vl_api_policer_classify_details_t * mp)
3692 vat_main_t *vam = &vat_main;
3694 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3695 ntohl (mp->table_index));
3698 static void vl_api_policer_classify_details_t_handler_json
3699 (vl_api_policer_classify_details_t * mp)
3701 vat_main_t *vam = &vat_main;
3702 vat_json_node_t *node;
3704 if (VAT_JSON_ARRAY != vam->json_tree.type)
3706 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3707 vat_json_init_array (&vam->json_tree);
3709 node = vat_json_array_add (&vam->json_tree);
3711 vat_json_init_object (node);
3712 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3713 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3716 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3717 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3719 vat_main_t *vam = &vat_main;
3720 i32 retval = ntohl (mp->retval);
3721 if (vam->async_mode)
3723 vam->async_errors += (retval < 0);
3727 vam->retval = retval;
3728 vam->sw_if_index = ntohl (mp->sw_if_index);
3729 vam->result_ready = 1;
3733 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3734 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3736 vat_main_t *vam = &vat_main;
3737 vat_json_node_t node;
3739 vat_json_init_object (&node);
3740 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3741 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3743 vat_json_print (vam->ofp, &node);
3744 vat_json_free (&node);
3746 vam->retval = ntohl (mp->retval);
3747 vam->result_ready = 1;
3750 static void vl_api_flow_classify_details_t_handler
3751 (vl_api_flow_classify_details_t * mp)
3753 vat_main_t *vam = &vat_main;
3755 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3756 ntohl (mp->table_index));
3759 static void vl_api_flow_classify_details_t_handler_json
3760 (vl_api_flow_classify_details_t * mp)
3762 vat_main_t *vam = &vat_main;
3763 vat_json_node_t *node;
3765 if (VAT_JSON_ARRAY != vam->json_tree.type)
3767 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3768 vat_json_init_array (&vam->json_tree);
3770 node = vat_json_array_add (&vam->json_tree);
3772 vat_json_init_object (node);
3773 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3774 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3779 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3780 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3781 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3782 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3783 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3784 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3785 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3786 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3787 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3788 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3791 * Generate boilerplate reply handlers, which
3792 * dig the return value out of the xxx_reply_t API message,
3793 * stick it into vam->retval, and set vam->result_ready
3795 * Could also do this by pointing N message decode slots at
3796 * a single function, but that could break in subtle ways.
3799 #define foreach_standard_reply_retval_handler \
3800 _(sw_interface_set_flags_reply) \
3801 _(sw_interface_add_del_address_reply) \
3802 _(sw_interface_set_table_reply) \
3803 _(sw_interface_set_mpls_enable_reply) \
3804 _(sw_interface_set_vpath_reply) \
3805 _(sw_interface_set_vxlan_bypass_reply) \
3806 _(sw_interface_set_l2_bridge_reply) \
3807 _(bridge_domain_add_del_reply) \
3808 _(sw_interface_set_l2_xconnect_reply) \
3809 _(l2fib_add_del_reply) \
3810 _(ip_add_del_route_reply) \
3811 _(ip_mroute_add_del_reply) \
3812 _(mpls_route_add_del_reply) \
3813 _(mpls_ip_bind_unbind_reply) \
3814 _(proxy_arp_add_del_reply) \
3815 _(proxy_arp_intfc_enable_disable_reply) \
3816 _(sw_interface_set_unnumbered_reply) \
3817 _(ip_neighbor_add_del_reply) \
3818 _(reset_vrf_reply) \
3819 _(oam_add_del_reply) \
3820 _(reset_fib_reply) \
3821 _(dhcp_proxy_config_reply) \
3822 _(dhcp_proxy_set_vss_reply) \
3823 _(dhcp_client_config_reply) \
3824 _(set_ip_flow_hash_reply) \
3825 _(sw_interface_ip6_enable_disable_reply) \
3826 _(sw_interface_ip6_set_link_local_address_reply) \
3827 _(sw_interface_ip6nd_ra_prefix_reply) \
3828 _(sw_interface_ip6nd_ra_config_reply) \
3829 _(set_arp_neighbor_limit_reply) \
3830 _(l2_patch_add_del_reply) \
3831 _(sr_tunnel_add_del_reply) \
3832 _(sr_policy_add_del_reply) \
3833 _(sr_multicast_map_add_del_reply) \
3834 _(classify_add_del_session_reply) \
3835 _(classify_set_interface_ip_table_reply) \
3836 _(classify_set_interface_l2_tables_reply) \
3837 _(l2tpv3_set_tunnel_cookies_reply) \
3838 _(l2tpv3_interface_enable_disable_reply) \
3839 _(l2tpv3_set_lookup_key_reply) \
3840 _(l2_fib_clear_table_reply) \
3841 _(l2_interface_efp_filter_reply) \
3842 _(l2_interface_vlan_tag_rewrite_reply) \
3843 _(modify_vhost_user_if_reply) \
3844 _(delete_vhost_user_if_reply) \
3845 _(want_ip4_arp_events_reply) \
3846 _(want_ip6_nd_events_reply) \
3847 _(input_acl_set_interface_reply) \
3848 _(ipsec_spd_add_del_reply) \
3849 _(ipsec_interface_add_del_spd_reply) \
3850 _(ipsec_spd_add_del_entry_reply) \
3851 _(ipsec_sad_add_del_entry_reply) \
3852 _(ipsec_sa_set_key_reply) \
3853 _(ikev2_profile_add_del_reply) \
3854 _(ikev2_profile_set_auth_reply) \
3855 _(ikev2_profile_set_id_reply) \
3856 _(ikev2_profile_set_ts_reply) \
3857 _(ikev2_set_local_key_reply) \
3858 _(ikev2_set_responder_reply) \
3859 _(ikev2_set_ike_transforms_reply) \
3860 _(ikev2_set_esp_transforms_reply) \
3861 _(ikev2_set_sa_lifetime_reply) \
3862 _(ikev2_initiate_sa_init_reply) \
3863 _(ikev2_initiate_del_ike_sa_reply) \
3864 _(ikev2_initiate_del_child_sa_reply) \
3865 _(ikev2_initiate_rekey_child_sa_reply) \
3866 _(delete_loopback_reply) \
3867 _(bd_ip_mac_add_del_reply) \
3868 _(map_del_domain_reply) \
3869 _(map_add_del_rule_reply) \
3870 _(want_interface_events_reply) \
3871 _(want_stats_reply) \
3872 _(cop_interface_enable_disable_reply) \
3873 _(cop_whitelist_enable_disable_reply) \
3874 _(sw_interface_clear_stats_reply) \
3875 _(ioam_enable_reply) \
3876 _(ioam_disable_reply) \
3877 _(lisp_add_del_locator_reply) \
3878 _(lisp_add_del_local_eid_reply) \
3879 _(lisp_add_del_remote_mapping_reply) \
3880 _(lisp_add_del_adjacency_reply) \
3881 _(gpe_add_del_fwd_entry_reply) \
3882 _(lisp_add_del_map_resolver_reply) \
3883 _(lisp_add_del_map_server_reply) \
3884 _(gpe_enable_disable_reply) \
3885 _(gpe_add_del_iface_reply) \
3886 _(lisp_enable_disable_reply) \
3887 _(lisp_rloc_probe_enable_disable_reply) \
3888 _(lisp_map_register_enable_disable_reply) \
3889 _(lisp_pitr_set_locator_set_reply) \
3890 _(lisp_map_request_mode_reply) \
3891 _(lisp_add_del_map_request_itr_rlocs_reply) \
3892 _(lisp_eid_table_add_del_map_reply) \
3893 _(vxlan_gpe_add_del_tunnel_reply) \
3894 _(af_packet_delete_reply) \
3895 _(policer_classify_set_interface_reply) \
3896 _(netmap_create_reply) \
3897 _(netmap_delete_reply) \
3898 _(set_ipfix_exporter_reply) \
3899 _(set_ipfix_classify_stream_reply) \
3900 _(ipfix_classify_table_add_del_reply) \
3901 _(flow_classify_set_interface_reply) \
3902 _(sw_interface_span_enable_disable_reply) \
3903 _(pg_capture_reply) \
3904 _(pg_enable_disable_reply) \
3905 _(ip_source_and_port_range_check_add_del_reply) \
3906 _(ip_source_and_port_range_check_interface_add_del_reply)\
3907 _(delete_subif_reply) \
3908 _(l2_interface_pbb_tag_rewrite_reply) \
3910 _(feature_enable_disable_reply) \
3911 _(sw_interface_tag_add_del_reply) \
3912 _(sw_interface_set_mtu_reply)
3915 #define foreach_standard_dpdk_reply_retval_handler \
3916 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3917 _(sw_interface_set_dpdk_hqos_subport_reply) \
3918 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3922 static void vl_api_##n##_t_handler \
3923 (vl_api_##n##_t * mp) \
3925 vat_main_t * vam = &vat_main; \
3926 i32 retval = ntohl(mp->retval); \
3927 if (vam->async_mode) { \
3928 vam->async_errors += (retval < 0); \
3930 vam->retval = retval; \
3931 vam->result_ready = 1; \
3934 foreach_standard_reply_retval_handler;
3938 static void vl_api_##n##_t_handler_json \
3939 (vl_api_##n##_t * mp) \
3941 vat_main_t * vam = &vat_main; \
3942 vat_json_node_t node; \
3943 vat_json_init_object(&node); \
3944 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3945 vat_json_print(vam->ofp, &node); \
3946 vam->retval = ntohl(mp->retval); \
3947 vam->result_ready = 1; \
3949 foreach_standard_reply_retval_handler;
3954 static void vl_api_##n##_t_handler \
3955 (vl_api_##n##_t * mp) \
3957 vat_main_t * vam = &vat_main; \
3958 i32 retval = ntohl(mp->retval); \
3959 if (vam->async_mode) { \
3960 vam->async_errors += (retval < 0); \
3962 vam->retval = retval; \
3963 vam->result_ready = 1; \
3966 foreach_standard_dpdk_reply_retval_handler;
3970 static void vl_api_##n##_t_handler_json \
3971 (vl_api_##n##_t * mp) \
3973 vat_main_t * vam = &vat_main; \
3974 vat_json_node_t node; \
3975 vat_json_init_object(&node); \
3976 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3977 vat_json_print(vam->ofp, &node); \
3978 vam->retval = ntohl(mp->retval); \
3979 vam->result_ready = 1; \
3981 foreach_standard_dpdk_reply_retval_handler;
3986 * Table of message reply handlers, must include boilerplate handlers
3990 #define foreach_vpe_api_reply_msg \
3991 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3992 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3993 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3994 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3995 _(CONTROL_PING_REPLY, control_ping_reply) \
3996 _(CLI_REPLY, cli_reply) \
3997 _(CLI_INBAND_REPLY, cli_inband_reply) \
3998 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3999 sw_interface_add_del_address_reply) \
4000 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4001 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4002 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4003 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4004 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4005 sw_interface_set_l2_xconnect_reply) \
4006 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4007 sw_interface_set_l2_bridge_reply) \
4008 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4009 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4010 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4011 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4012 _(L2_FLAGS_REPLY, l2_flags_reply) \
4013 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4014 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4015 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4016 _(TAP_DELETE_REPLY, tap_delete_reply) \
4017 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4018 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4019 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4020 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4021 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4022 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4023 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4024 proxy_arp_intfc_enable_disable_reply) \
4025 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4026 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4027 sw_interface_set_unnumbered_reply) \
4028 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4029 _(RESET_VRF_REPLY, reset_vrf_reply) \
4030 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4031 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4032 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4033 _(RESET_FIB_REPLY, reset_fib_reply) \
4034 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4035 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4036 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4037 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4038 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4039 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4040 sw_interface_ip6_enable_disable_reply) \
4041 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4042 sw_interface_ip6_set_link_local_address_reply) \
4043 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4044 sw_interface_ip6nd_ra_prefix_reply) \
4045 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4046 sw_interface_ip6nd_ra_config_reply) \
4047 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4048 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4049 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4050 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4051 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4052 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4053 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4054 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4055 classify_set_interface_ip_table_reply) \
4056 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4057 classify_set_interface_l2_tables_reply) \
4058 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4059 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4060 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4061 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4062 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4063 l2tpv3_interface_enable_disable_reply) \
4064 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4065 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4066 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4067 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4068 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4069 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4070 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4071 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4072 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4073 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4074 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4075 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4076 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4077 _(SHOW_VERSION_REPLY, show_version_reply) \
4078 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4079 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4080 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4081 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4082 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4083 _(IP4_ARP_EVENT, ip4_arp_event) \
4084 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4085 _(IP6_ND_EVENT, ip6_nd_event) \
4086 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4087 _(IP_ADDRESS_DETAILS, ip_address_details) \
4088 _(IP_DETAILS, ip_details) \
4089 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4090 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4091 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4092 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4093 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4094 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4095 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4096 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4097 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4098 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4099 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4100 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4101 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4102 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4103 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4104 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4105 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4106 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4107 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4108 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4109 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4110 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4111 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4112 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4113 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4114 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4115 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4116 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4117 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4118 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4119 _(MAP_RULE_DETAILS, map_rule_details) \
4120 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4121 _(WANT_STATS_REPLY, want_stats_reply) \
4122 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4123 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4124 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4125 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4126 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4127 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4128 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4129 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
4130 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
4131 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
4132 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
4133 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
4134 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4135 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
4136 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
4137 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4138 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
4139 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4140 lisp_map_register_enable_disable_reply) \
4141 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4142 lisp_rloc_probe_enable_disable_reply) \
4143 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
4144 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
4145 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
4146 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4147 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
4148 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
4149 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
4150 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
4151 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
4152 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
4153 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
4154 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
4155 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4156 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4157 gpe_fwd_entry_path_details) \
4158 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
4159 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4160 lisp_add_del_map_request_itr_rlocs_reply) \
4161 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4162 lisp_get_map_request_itr_rlocs_reply) \
4163 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
4164 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
4165 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
4166 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
4167 show_lisp_map_register_state_reply) \
4168 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4169 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4170 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4171 _(POLICER_DETAILS, policer_details) \
4172 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4173 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4174 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4175 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4176 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4177 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4178 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4179 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4180 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4181 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4182 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4183 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4184 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4185 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4186 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4187 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4188 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4189 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4190 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4191 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4192 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4193 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4194 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4195 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4196 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4197 ip_source_and_port_range_check_add_del_reply) \
4198 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4199 ip_source_and_port_range_check_interface_add_del_reply) \
4200 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4201 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4202 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4203 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4204 _(PUNT_REPLY, punt_reply) \
4205 _(IP_FIB_DETAILS, ip_fib_details) \
4206 _(IP6_FIB_DETAILS, ip6_fib_details) \
4207 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4208 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4209 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4210 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4211 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4212 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4215 #define foreach_vpe_dpdk_api_reply_msg \
4216 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4217 sw_interface_set_dpdk_hqos_pipe_reply) \
4218 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4219 sw_interface_set_dpdk_hqos_subport_reply) \
4220 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4221 sw_interface_set_dpdk_hqos_tctbl_reply)
4231 #define STR_VTR_OP_CASE(op) \
4232 case L2_VTR_ ## op: \
4236 str_vtr_op (u32 vtr_op)
4240 STR_VTR_OP_CASE (DISABLED);
4241 STR_VTR_OP_CASE (PUSH_1);
4242 STR_VTR_OP_CASE (PUSH_2);
4243 STR_VTR_OP_CASE (POP_1);
4244 STR_VTR_OP_CASE (POP_2);
4245 STR_VTR_OP_CASE (TRANSLATE_1_1);
4246 STR_VTR_OP_CASE (TRANSLATE_1_2);
4247 STR_VTR_OP_CASE (TRANSLATE_2_1);
4248 STR_VTR_OP_CASE (TRANSLATE_2_2);
4255 dump_sub_interface_table (vat_main_t * vam)
4257 const sw_interface_subif_t *sub = NULL;
4259 if (vam->json_output)
4262 ("JSON output supported only for VPE API calls and dump_stats_table");
4267 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4268 "Interface", "sw_if_index",
4269 "sub id", "dot1ad", "tags", "outer id",
4270 "inner id", "exact", "default", "outer any", "inner any");
4272 vec_foreach (sub, vam->sw_if_subif_table)
4275 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4276 sub->interface_name,
4278 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4279 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4280 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4281 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4282 if (sub->vtr_op != L2_VTR_DISABLED)
4285 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4286 "tag1: %d tag2: %d ]",
4287 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4288 sub->vtr_tag1, sub->vtr_tag2);
4296 name_sort_cmp (void *a1, void *a2)
4298 name_sort_t *n1 = a1;
4299 name_sort_t *n2 = a2;
4301 return strcmp ((char *) n1->name, (char *) n2->name);
4305 dump_interface_table (vat_main_t * vam)
4308 name_sort_t *nses = 0, *ns;
4310 if (vam->json_output)
4313 ("JSON output supported only for VPE API calls and dump_stats_table");
4318 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4320 vec_add2 (nses, ns, 1);
4321 ns->name = (u8 *)(p->key);
4322 ns->value = (u32) p->value[0];
4326 vec_sort_with_function (nses, name_sort_cmp);
4328 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4329 vec_foreach (ns, nses)
4331 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4338 dump_ip_table (vat_main_t * vam, int is_ipv6)
4340 const ip_details_t *det = NULL;
4341 const ip_address_details_t *address = NULL;
4344 print (vam->ofp, "%-12s", "sw_if_index");
4346 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4353 print (vam->ofp, "%-12d", i);
4354 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4359 vec_foreach (address, det->addr)
4363 is_ipv6 ? format_ip6_address : format_ip4_address,
4364 address->ip, address->prefix_length);
4372 dump_ipv4_table (vat_main_t * vam)
4374 if (vam->json_output)
4377 ("JSON output supported only for VPE API calls and dump_stats_table");
4381 return dump_ip_table (vam, 0);
4385 dump_ipv6_table (vat_main_t * vam)
4387 if (vam->json_output)
4390 ("JSON output supported only for VPE API calls and dump_stats_table");
4394 return dump_ip_table (vam, 1);
4398 counter_type_to_str (u8 counter_type, u8 is_combined)
4402 switch (counter_type)
4404 case VNET_INTERFACE_COUNTER_DROP:
4406 case VNET_INTERFACE_COUNTER_PUNT:
4408 case VNET_INTERFACE_COUNTER_IP4:
4410 case VNET_INTERFACE_COUNTER_IP6:
4412 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4414 case VNET_INTERFACE_COUNTER_RX_MISS:
4416 case VNET_INTERFACE_COUNTER_RX_ERROR:
4418 case VNET_INTERFACE_COUNTER_TX_ERROR:
4421 return "INVALID-COUNTER-TYPE";
4426 switch (counter_type)
4428 case VNET_INTERFACE_COUNTER_RX:
4430 case VNET_INTERFACE_COUNTER_TX:
4433 return "INVALID-COUNTER-TYPE";
4439 dump_stats_table (vat_main_t * vam)
4441 vat_json_node_t node;
4442 vat_json_node_t *msg_array;
4443 vat_json_node_t *msg;
4444 vat_json_node_t *counter_array;
4445 vat_json_node_t *counter;
4446 interface_counter_t c;
4448 ip4_fib_counter_t *c4;
4449 ip6_fib_counter_t *c6;
4450 ip4_nbr_counter_t *n4;
4451 ip6_nbr_counter_t *n6;
4454 if (!vam->json_output)
4456 clib_warning ("dump_stats_table supported only in JSON format");
4460 vat_json_init_object (&node);
4462 /* interface counters */
4463 msg_array = vat_json_object_add (&node, "interface_counters");
4464 vat_json_init_array (msg_array);
4465 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4467 msg = vat_json_array_add (msg_array);
4468 vat_json_init_object (msg);
4469 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4470 (u8 *) counter_type_to_str (i, 0));
4471 vat_json_object_add_int (msg, "is_combined", 0);
4472 counter_array = vat_json_object_add (msg, "data");
4473 vat_json_init_array (counter_array);
4474 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4476 packets = vam->simple_interface_counters[i][j];
4477 vat_json_array_add_uint (counter_array, packets);
4480 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4482 msg = vat_json_array_add (msg_array);
4483 vat_json_init_object (msg);
4484 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4485 (u8 *) counter_type_to_str (i, 1));
4486 vat_json_object_add_int (msg, "is_combined", 1);
4487 counter_array = vat_json_object_add (msg, "data");
4488 vat_json_init_array (counter_array);
4489 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4491 c = vam->combined_interface_counters[i][j];
4492 counter = vat_json_array_add (counter_array);
4493 vat_json_init_object (counter);
4494 vat_json_object_add_uint (counter, "packets", c.packets);
4495 vat_json_object_add_uint (counter, "bytes", c.bytes);
4499 /* ip4 fib counters */
4500 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4501 vat_json_init_array (msg_array);
4502 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4504 msg = vat_json_array_add (msg_array);
4505 vat_json_init_object (msg);
4506 vat_json_object_add_uint (msg, "vrf_id",
4507 vam->ip4_fib_counters_vrf_id_by_index[i]);
4508 counter_array = vat_json_object_add (msg, "c");
4509 vat_json_init_array (counter_array);
4510 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4512 counter = vat_json_array_add (counter_array);
4513 vat_json_init_object (counter);
4514 c4 = &vam->ip4_fib_counters[i][j];
4515 vat_json_object_add_ip4 (counter, "address", c4->address);
4516 vat_json_object_add_uint (counter, "address_length",
4517 c4->address_length);
4518 vat_json_object_add_uint (counter, "packets", c4->packets);
4519 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4523 /* ip6 fib counters */
4524 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4525 vat_json_init_array (msg_array);
4526 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4528 msg = vat_json_array_add (msg_array);
4529 vat_json_init_object (msg);
4530 vat_json_object_add_uint (msg, "vrf_id",
4531 vam->ip6_fib_counters_vrf_id_by_index[i]);
4532 counter_array = vat_json_object_add (msg, "c");
4533 vat_json_init_array (counter_array);
4534 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4536 counter = vat_json_array_add (counter_array);
4537 vat_json_init_object (counter);
4538 c6 = &vam->ip6_fib_counters[i][j];
4539 vat_json_object_add_ip6 (counter, "address", c6->address);
4540 vat_json_object_add_uint (counter, "address_length",
4541 c6->address_length);
4542 vat_json_object_add_uint (counter, "packets", c6->packets);
4543 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4547 /* ip4 nbr counters */
4548 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4549 vat_json_init_array (msg_array);
4550 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4552 msg = vat_json_array_add (msg_array);
4553 vat_json_init_object (msg);
4554 vat_json_object_add_uint (msg, "sw_if_index", i);
4555 counter_array = vat_json_object_add (msg, "c");
4556 vat_json_init_array (counter_array);
4557 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4559 counter = vat_json_array_add (counter_array);
4560 vat_json_init_object (counter);
4561 n4 = &vam->ip4_nbr_counters[i][j];
4562 vat_json_object_add_ip4 (counter, "address", n4->address);
4563 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4564 vat_json_object_add_uint (counter, "packets", n4->packets);
4565 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4569 /* ip6 nbr counters */
4570 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4571 vat_json_init_array (msg_array);
4572 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4574 msg = vat_json_array_add (msg_array);
4575 vat_json_init_object (msg);
4576 vat_json_object_add_uint (msg, "sw_if_index", i);
4577 counter_array = vat_json_object_add (msg, "c");
4578 vat_json_init_array (counter_array);
4579 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4581 counter = vat_json_array_add (counter_array);
4582 vat_json_init_object (counter);
4583 n6 = &vam->ip6_nbr_counters[i][j];
4584 vat_json_object_add_ip6 (counter, "address", n6->address);
4585 vat_json_object_add_uint (counter, "packets", n6->packets);
4586 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4590 vat_json_print (vam->ofp, &node);
4591 vat_json_free (&node);
4597 exec (vat_main_t * vam)
4599 api_main_t *am = &api_main;
4600 vl_api_cli_request_t *mp;
4604 unformat_input_t *i = vam->input;
4606 if (vec_len (i->buffer) == 0)
4609 if (vam->exec_mode == 0 && unformat (i, "mode"))
4614 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4621 M (CLI_REQUEST, mp);
4624 * Copy cmd into shared memory.
4625 * In order for the CLI command to work, it
4626 * must be a vector ending in \n, not a C-string ending
4629 pthread_mutex_lock (&am->vlib_rp->mutex);
4630 oldheap = svm_push_data_heap (am->vlib_rp);
4632 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4633 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4635 svm_pop_heap (oldheap);
4636 pthread_mutex_unlock (&am->vlib_rp->mutex);
4638 mp->cmd_in_shmem = (u64) cmd;
4640 timeout = vat_time_now (vam) + 10.0;
4642 while (vat_time_now (vam) < timeout)
4644 if (vam->result_ready == 1)
4647 if (vam->shmem_result != NULL)
4648 print (vam->ofp, "%s", vam->shmem_result);
4649 pthread_mutex_lock (&am->vlib_rp->mutex);
4650 oldheap = svm_push_data_heap (am->vlib_rp);
4652 free_me = (u8 *) vam->shmem_result;
4655 svm_pop_heap (oldheap);
4656 pthread_mutex_unlock (&am->vlib_rp->mutex);
4664 * Future replacement of exec() that passes CLI buffers directly in
4665 * the API messages instead of an additional shared memory area.
4668 exec_inband (vat_main_t * vam)
4670 vl_api_cli_inband_t *mp;
4671 unformat_input_t *i = vam->input;
4674 if (vec_len (i->buffer) == 0)
4677 if (vam->exec_mode == 0 && unformat (i, "mode"))
4682 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4689 * In order for the CLI command to work, it
4690 * must be a vector ending in \n, not a C-string ending
4693 u32 len = vec_len (vam->input->buffer);
4694 M2 (CLI_INBAND, mp, len);
4695 clib_memcpy (mp->cmd, vam->input->buffer, len);
4696 mp->length = htonl (len);
4699 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4704 api_create_loopback (vat_main_t * vam)
4706 unformat_input_t *i = vam->input;
4707 vl_api_create_loopback_t *mp;
4712 memset (mac_address, 0, sizeof (mac_address));
4714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4716 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4722 /* Construct the API message */
4723 M (CREATE_LOOPBACK, mp);
4725 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4733 api_delete_loopback (vat_main_t * vam)
4735 unformat_input_t *i = vam->input;
4736 vl_api_delete_loopback_t *mp;
4737 u32 sw_if_index = ~0;
4740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4742 if (unformat (i, "sw_if_index %d", &sw_if_index))
4748 if (sw_if_index == ~0)
4750 errmsg ("missing sw_if_index");
4754 /* Construct the API message */
4755 M (DELETE_LOOPBACK, mp);
4756 mp->sw_if_index = ntohl (sw_if_index);
4764 api_want_stats (vat_main_t * vam)
4766 unformat_input_t *i = vam->input;
4767 vl_api_want_stats_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");
4788 mp->enable_disable = enable;
4796 api_want_interface_events (vat_main_t * vam)
4798 unformat_input_t *i = vam->input;
4799 vl_api_want_interface_events_t *mp;
4803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4805 if (unformat (i, "enable"))
4807 else if (unformat (i, "disable"))
4815 errmsg ("missing enable|disable");
4819 M (WANT_INTERFACE_EVENTS, mp);
4820 mp->enable_disable = enable;
4822 vam->interface_event_display = enable;
4830 /* Note: non-static, called once to set up the initial intfc table */
4832 api_sw_interface_dump (vat_main_t * vam)
4834 vl_api_sw_interface_dump_t *mp;
4835 vl_api_control_ping_t *mp_ping;
4837 name_sort_t *nses = 0, *ns;
4838 sw_interface_subif_t *sub = NULL;
4841 /* Toss the old name table */
4843 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4845 vec_add2 (nses, ns, 1);
4846 ns->name = (u8 *)(p->key);
4847 ns->value = (u32) p->value[0];
4851 hash_free (vam->sw_if_index_by_interface_name);
4853 vec_foreach (ns, nses) vec_free (ns->name);
4857 vec_foreach (sub, vam->sw_if_subif_table)
4859 vec_free (sub->interface_name);
4861 vec_free (vam->sw_if_subif_table);
4863 /* recreate the interface name hash table */
4864 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4866 /* Get list of ethernets */
4867 M (SW_INTERFACE_DUMP, mp);
4868 mp->name_filter_valid = 1;
4869 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4872 /* and local / loopback interfaces */
4873 M (SW_INTERFACE_DUMP, mp);
4874 mp->name_filter_valid = 1;
4875 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4878 /* and packet-generator interfaces */
4879 M (SW_INTERFACE_DUMP, mp);
4880 mp->name_filter_valid = 1;
4881 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4884 /* and vxlan-gpe tunnel interfaces */
4885 M (SW_INTERFACE_DUMP, mp);
4886 mp->name_filter_valid = 1;
4887 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4888 sizeof (mp->name_filter) - 1);
4891 /* and vxlan tunnel interfaces */
4892 M (SW_INTERFACE_DUMP, mp);
4893 mp->name_filter_valid = 1;
4894 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4897 /* and host (af_packet) interfaces */
4898 M (SW_INTERFACE_DUMP, mp);
4899 mp->name_filter_valid = 1;
4900 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4903 /* and l2tpv3 tunnel interfaces */
4904 M (SW_INTERFACE_DUMP, mp);
4905 mp->name_filter_valid = 1;
4906 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4907 sizeof (mp->name_filter) - 1);
4910 /* and GRE tunnel interfaces */
4911 M (SW_INTERFACE_DUMP, mp);
4912 mp->name_filter_valid = 1;
4913 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4916 /* and LISP-GPE interfaces */
4917 M (SW_INTERFACE_DUMP, mp);
4918 mp->name_filter_valid = 1;
4919 strncpy ((char *) mp->name_filter, "lisp_gpe",
4920 sizeof (mp->name_filter) - 1);
4923 /* and IPSEC tunnel interfaces */
4924 M (SW_INTERFACE_DUMP, mp);
4925 mp->name_filter_valid = 1;
4926 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4929 /* Use a control ping for synchronization */
4930 M (CONTROL_PING, mp_ping);
4938 api_sw_interface_set_flags (vat_main_t * vam)
4940 unformat_input_t *i = vam->input;
4941 vl_api_sw_interface_set_flags_t *mp;
4943 u8 sw_if_index_set = 0;
4944 u8 admin_up = 0, link_up = 0;
4947 /* Parse args required to build the message */
4948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4950 if (unformat (i, "admin-up"))
4952 else if (unformat (i, "admin-down"))
4954 else if (unformat (i, "link-up"))
4956 else if (unformat (i, "link-down"))
4959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4960 sw_if_index_set = 1;
4961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4962 sw_if_index_set = 1;
4967 if (sw_if_index_set == 0)
4969 errmsg ("missing interface name or sw_if_index");
4973 /* Construct the API message */
4974 M (SW_INTERFACE_SET_FLAGS, mp);
4975 mp->sw_if_index = ntohl (sw_if_index);
4976 mp->admin_up_down = admin_up;
4977 mp->link_up_down = link_up;
4982 /* Wait for a reply, return the good/bad news... */
4988 api_sw_interface_clear_stats (vat_main_t * vam)
4990 unformat_input_t *i = vam->input;
4991 vl_api_sw_interface_clear_stats_t *mp;
4993 u8 sw_if_index_set = 0;
4996 /* Parse args required to build the message */
4997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5000 sw_if_index_set = 1;
5001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5002 sw_if_index_set = 1;
5007 /* Construct the API message */
5008 M (SW_INTERFACE_CLEAR_STATS, mp);
5010 if (sw_if_index_set == 1)
5011 mp->sw_if_index = ntohl (sw_if_index);
5013 mp->sw_if_index = ~0;
5018 /* Wait for a reply, return the good/bad news... */
5025 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
5027 unformat_input_t *i = vam->input;
5028 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
5030 u8 sw_if_index_set = 0;
5039 /* Parse args required to build the message */
5040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5042 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5043 sw_if_index_set = 1;
5044 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5045 sw_if_index_set = 1;
5046 else if (unformat (i, "subport %u", &subport))
5049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5050 sw_if_index_set = 1;
5051 else if (unformat (i, "pipe %u", &pipe))
5053 else if (unformat (i, "profile %u", &profile))
5059 if (sw_if_index_set == 0)
5061 errmsg ("missing interface name or sw_if_index");
5065 if (subport_set == 0)
5067 errmsg ("missing subport ");
5073 errmsg ("missing pipe");
5077 if (profile_set == 0)
5079 errmsg ("missing profile");
5083 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
5085 mp->sw_if_index = ntohl (sw_if_index);
5086 mp->subport = ntohl (subport);
5087 mp->pipe = ntohl (pipe);
5088 mp->profile = ntohl (profile);
5097 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
5099 unformat_input_t *i = vam->input;
5100 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
5102 u8 sw_if_index_set = 0;
5105 u32 tb_rate = 1250000000; /* 10GbE */
5106 u32 tb_size = 1000000;
5107 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
5111 /* Parse args required to build the message */
5112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5114 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5115 sw_if_index_set = 1;
5116 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5117 sw_if_index_set = 1;
5118 else if (unformat (i, "subport %u", &subport))
5121 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5122 sw_if_index_set = 1;
5123 else if (unformat (i, "rate %u", &tb_rate))
5127 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
5129 tc_rate[tc_id] = tb_rate;
5131 else if (unformat (i, "bktsize %u", &tb_size))
5133 else if (unformat (i, "tc0 %u", &tc_rate[0]))
5135 else if (unformat (i, "tc1 %u", &tc_rate[1]))
5137 else if (unformat (i, "tc2 %u", &tc_rate[2]))
5139 else if (unformat (i, "tc3 %u", &tc_rate[3]))
5141 else if (unformat (i, "period %u", &tc_period))
5147 if (sw_if_index_set == 0)
5149 errmsg ("missing interface name or sw_if_index");
5153 if (subport_set == 0)
5155 errmsg ("missing subport ");
5159 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
5161 mp->sw_if_index = ntohl (sw_if_index);
5162 mp->subport = ntohl (subport);
5163 mp->tb_rate = ntohl (tb_rate);
5164 mp->tb_size = ntohl (tb_size);
5165 mp->tc_rate[0] = ntohl (tc_rate[0]);
5166 mp->tc_rate[1] = ntohl (tc_rate[1]);
5167 mp->tc_rate[2] = ntohl (tc_rate[2]);
5168 mp->tc_rate[3] = ntohl (tc_rate[3]);
5169 mp->tc_period = ntohl (tc_period);
5177 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
5179 unformat_input_t *i = vam->input;
5180 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
5182 u8 sw_if_index_set = 0;
5186 u32 entry, tc, queue;
5189 /* Parse args required to build the message */
5190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5192 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5193 sw_if_index_set = 1;
5194 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5195 sw_if_index_set = 1;
5196 else if (unformat (i, "entry %d", &entry))
5198 else if (unformat (i, "tc %d", &tc))
5200 else if (unformat (i, "queue %d", &queue))
5206 if (sw_if_index_set == 0)
5208 errmsg ("missing interface name or sw_if_index");
5214 errmsg ("missing entry ");
5220 errmsg ("missing traffic class ");
5226 errmsg ("missing queue ");
5230 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
5232 mp->sw_if_index = ntohl (sw_if_index);
5233 mp->entry = ntohl (entry);
5234 mp->tc = ntohl (tc);
5235 mp->queue = ntohl (queue);
5244 api_sw_interface_add_del_address (vat_main_t * vam)
5246 unformat_input_t *i = vam->input;
5247 vl_api_sw_interface_add_del_address_t *mp;
5249 u8 sw_if_index_set = 0;
5250 u8 is_add = 1, del_all = 0;
5251 u32 address_length = 0;
5252 u8 v4_address_set = 0;
5253 u8 v6_address_set = 0;
5254 ip4_address_t v4address;
5255 ip6_address_t v6address;
5258 /* Parse args required to build the message */
5259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5261 if (unformat (i, "del-all"))
5263 else if (unformat (i, "del"))
5266 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5267 sw_if_index_set = 1;
5268 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5269 sw_if_index_set = 1;
5270 else if (unformat (i, "%U/%d",
5271 unformat_ip4_address, &v4address, &address_length))
5273 else if (unformat (i, "%U/%d",
5274 unformat_ip6_address, &v6address, &address_length))
5280 if (sw_if_index_set == 0)
5282 errmsg ("missing interface name or sw_if_index");
5285 if (v4_address_set && v6_address_set)
5287 errmsg ("both v4 and v6 addresses set");
5290 if (!v4_address_set && !v6_address_set && !del_all)
5292 errmsg ("no addresses set");
5296 /* Construct the API message */
5297 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5299 mp->sw_if_index = ntohl (sw_if_index);
5300 mp->is_add = is_add;
5301 mp->del_all = del_all;
5305 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5309 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5311 mp->address_length = address_length;
5316 /* Wait for a reply, return good/bad news */
5322 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5324 unformat_input_t *i = vam->input;
5325 vl_api_sw_interface_set_mpls_enable_t *mp;
5327 u8 sw_if_index_set = 0;
5331 /* Parse args required to build the message */
5332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5334 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5335 sw_if_index_set = 1;
5336 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5337 sw_if_index_set = 1;
5338 else if (unformat (i, "disable"))
5340 else if (unformat (i, "dis"))
5346 if (sw_if_index_set == 0)
5348 errmsg ("missing interface name or sw_if_index");
5352 /* Construct the API message */
5353 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5355 mp->sw_if_index = ntohl (sw_if_index);
5356 mp->enable = enable;
5361 /* Wait for a reply... */
5367 api_sw_interface_set_table (vat_main_t * vam)
5369 unformat_input_t *i = vam->input;
5370 vl_api_sw_interface_set_table_t *mp;
5371 u32 sw_if_index, vrf_id = 0;
5372 u8 sw_if_index_set = 0;
5376 /* Parse args required to build the message */
5377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5379 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5380 sw_if_index_set = 1;
5381 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5382 sw_if_index_set = 1;
5383 else if (unformat (i, "vrf %d", &vrf_id))
5385 else if (unformat (i, "ipv6"))
5391 if (sw_if_index_set == 0)
5393 errmsg ("missing interface name or sw_if_index");
5397 /* Construct the API message */
5398 M (SW_INTERFACE_SET_TABLE, mp);
5400 mp->sw_if_index = ntohl (sw_if_index);
5401 mp->is_ipv6 = is_ipv6;
5402 mp->vrf_id = ntohl (vrf_id);
5407 /* Wait for a reply... */
5412 static void vl_api_sw_interface_get_table_reply_t_handler
5413 (vl_api_sw_interface_get_table_reply_t * mp)
5415 vat_main_t *vam = &vat_main;
5417 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5419 vam->retval = ntohl (mp->retval);
5420 vam->result_ready = 1;
5424 static void vl_api_sw_interface_get_table_reply_t_handler_json
5425 (vl_api_sw_interface_get_table_reply_t * mp)
5427 vat_main_t *vam = &vat_main;
5428 vat_json_node_t node;
5430 vat_json_init_object (&node);
5431 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5432 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5434 vat_json_print (vam->ofp, &node);
5435 vat_json_free (&node);
5437 vam->retval = ntohl (mp->retval);
5438 vam->result_ready = 1;
5442 api_sw_interface_get_table (vat_main_t * vam)
5444 unformat_input_t *i = vam->input;
5445 vl_api_sw_interface_get_table_t *mp;
5447 u8 sw_if_index_set = 0;
5451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5453 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5454 sw_if_index_set = 1;
5455 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5456 sw_if_index_set = 1;
5457 else if (unformat (i, "ipv6"))
5463 if (sw_if_index_set == 0)
5465 errmsg ("missing interface name or sw_if_index");
5469 M (SW_INTERFACE_GET_TABLE, mp);
5470 mp->sw_if_index = htonl (sw_if_index);
5471 mp->is_ipv6 = is_ipv6;
5479 api_sw_interface_set_vpath (vat_main_t * vam)
5481 unformat_input_t *i = vam->input;
5482 vl_api_sw_interface_set_vpath_t *mp;
5483 u32 sw_if_index = 0;
5484 u8 sw_if_index_set = 0;
5488 /* Parse args required to build the message */
5489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5491 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5492 sw_if_index_set = 1;
5493 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5494 sw_if_index_set = 1;
5495 else if (unformat (i, "enable"))
5497 else if (unformat (i, "disable"))
5503 if (sw_if_index_set == 0)
5505 errmsg ("missing interface name or sw_if_index");
5509 /* Construct the API message */
5510 M (SW_INTERFACE_SET_VPATH, mp);
5512 mp->sw_if_index = ntohl (sw_if_index);
5513 mp->enable = is_enable;
5518 /* Wait for a reply... */
5524 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5526 unformat_input_t *i = vam->input;
5527 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5528 u32 sw_if_index = 0;
5529 u8 sw_if_index_set = 0;
5534 /* Parse args required to build the message */
5535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5537 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5538 sw_if_index_set = 1;
5539 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5540 sw_if_index_set = 1;
5541 else if (unformat (i, "enable"))
5543 else if (unformat (i, "disable"))
5545 else if (unformat (i, "ip4"))
5547 else if (unformat (i, "ip6"))
5553 if (sw_if_index_set == 0)
5555 errmsg ("missing interface name or sw_if_index");
5559 /* Construct the API message */
5560 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5562 mp->sw_if_index = ntohl (sw_if_index);
5563 mp->enable = is_enable;
5564 mp->is_ipv6 = is_ipv6;
5569 /* Wait for a reply... */
5575 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5577 unformat_input_t *i = vam->input;
5578 vl_api_sw_interface_set_l2_xconnect_t *mp;
5580 u8 rx_sw_if_index_set = 0;
5582 u8 tx_sw_if_index_set = 0;
5586 /* Parse args required to build the message */
5587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5589 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5590 rx_sw_if_index_set = 1;
5591 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5592 tx_sw_if_index_set = 1;
5593 else if (unformat (i, "rx"))
5595 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5597 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5599 rx_sw_if_index_set = 1;
5604 else if (unformat (i, "tx"))
5606 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5608 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5610 tx_sw_if_index_set = 1;
5615 else if (unformat (i, "enable"))
5617 else if (unformat (i, "disable"))
5623 if (rx_sw_if_index_set == 0)
5625 errmsg ("missing rx interface name or rx_sw_if_index");
5629 if (enable && (tx_sw_if_index_set == 0))
5631 errmsg ("missing tx interface name or tx_sw_if_index");
5635 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5637 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5638 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5639 mp->enable = enable;
5647 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5649 unformat_input_t *i = vam->input;
5650 vl_api_sw_interface_set_l2_bridge_t *mp;
5652 u8 rx_sw_if_index_set = 0;
5660 /* Parse args required to build the message */
5661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5663 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5664 rx_sw_if_index_set = 1;
5665 else if (unformat (i, "bd_id %d", &bd_id))
5669 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5670 rx_sw_if_index_set = 1;
5671 else if (unformat (i, "shg %d", &shg))
5673 else if (unformat (i, "bvi"))
5675 else if (unformat (i, "enable"))
5677 else if (unformat (i, "disable"))
5683 if (rx_sw_if_index_set == 0)
5685 errmsg ("missing rx interface name or sw_if_index");
5689 if (enable && (bd_id_set == 0))
5691 errmsg ("missing bridge domain");
5695 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5697 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5698 mp->bd_id = ntohl (bd_id);
5701 mp->enable = enable;
5709 api_bridge_domain_dump (vat_main_t * vam)
5711 unformat_input_t *i = vam->input;
5712 vl_api_bridge_domain_dump_t *mp;
5713 vl_api_control_ping_t *mp_ping;
5717 /* Parse args required to build the message */
5718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5720 if (unformat (i, "bd_id %d", &bd_id))
5726 M (BRIDGE_DOMAIN_DUMP, mp);
5727 mp->bd_id = ntohl (bd_id);
5730 /* Use a control ping for synchronization */
5731 M (CONTROL_PING, mp_ping);
5739 api_bridge_domain_add_del (vat_main_t * vam)
5741 unformat_input_t *i = vam->input;
5742 vl_api_bridge_domain_add_del_t *mp;
5745 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5749 /* Parse args required to build the message */
5750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5752 if (unformat (i, "bd_id %d", &bd_id))
5754 else if (unformat (i, "flood %d", &flood))
5756 else if (unformat (i, "uu-flood %d", &uu_flood))
5758 else if (unformat (i, "forward %d", &forward))
5760 else if (unformat (i, "learn %d", &learn))
5762 else if (unformat (i, "arp-term %d", &arp_term))
5764 else if (unformat (i, "mac-age %d", &mac_age))
5766 else if (unformat (i, "del"))
5769 flood = uu_flood = forward = learn = 0;
5777 errmsg ("missing bridge domain");
5783 errmsg ("mac age must be less than 256 ");
5787 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5789 mp->bd_id = ntohl (bd_id);
5791 mp->uu_flood = uu_flood;
5792 mp->forward = forward;
5794 mp->arp_term = arp_term;
5795 mp->is_add = is_add;
5796 mp->mac_age = (u8) mac_age;
5804 api_l2fib_add_del (vat_main_t * vam)
5806 unformat_input_t *i = vam->input;
5807 vl_api_l2fib_add_del_t *mp;
5813 u32 sw_if_index = ~0;
5814 u8 sw_if_index_set = 0;
5823 /* Parse args required to build the message */
5824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5826 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5828 else if (unformat (i, "bd_id %d", &bd_id))
5830 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5831 sw_if_index_set = 1;
5832 else if (unformat (i, "sw_if"))
5834 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5837 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5838 sw_if_index_set = 1;
5843 else if (unformat (i, "static"))
5845 else if (unformat (i, "filter"))
5850 else if (unformat (i, "bvi"))
5855 else if (unformat (i, "del"))
5857 else if (unformat (i, "count %d", &count))
5865 errmsg ("missing mac address");
5871 errmsg ("missing bridge domain");
5875 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5877 errmsg ("missing interface name or sw_if_index");
5883 /* Turn on async mode */
5884 vam->async_mode = 1;
5885 vam->async_errors = 0;
5886 before = vat_time_now (vam);
5889 for (j = 0; j < count; j++)
5891 M (L2FIB_ADD_DEL, mp);
5894 mp->bd_id = ntohl (bd_id);
5895 mp->is_add = is_add;
5899 mp->sw_if_index = ntohl (sw_if_index);
5900 mp->static_mac = static_mac;
5901 mp->filter_mac = filter_mac;
5902 mp->bvi_mac = bvi_mac;
5904 increment_mac_address (&mac);
5911 vl_api_control_ping_t *mp_ping;
5914 /* Shut off async mode */
5915 vam->async_mode = 0;
5917 M (CONTROL_PING, mp_ping);
5920 timeout = vat_time_now (vam) + 1.0;
5921 while (vat_time_now (vam) < timeout)
5922 if (vam->result_ready == 1)
5927 if (vam->retval == -99)
5930 if (vam->async_errors > 0)
5932 errmsg ("%d asynchronous errors", vam->async_errors);
5935 vam->async_errors = 0;
5936 after = vat_time_now (vam);
5938 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5939 count, after - before, count / (after - before));
5945 /* Wait for a reply... */
5949 /* Return the good/bad news */
5950 return (vam->retval);
5954 api_l2_flags (vat_main_t * vam)
5956 unformat_input_t *i = vam->input;
5957 vl_api_l2_flags_t *mp;
5959 u32 feature_bitmap = 0;
5960 u8 sw_if_index_set = 0;
5963 /* Parse args required to build the message */
5964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5966 if (unformat (i, "sw_if_index %d", &sw_if_index))
5967 sw_if_index_set = 1;
5968 else if (unformat (i, "sw_if"))
5970 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5973 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5974 sw_if_index_set = 1;
5979 else if (unformat (i, "learn"))
5980 feature_bitmap |= L2INPUT_FEAT_LEARN;
5981 else if (unformat (i, "forward"))
5982 feature_bitmap |= L2INPUT_FEAT_FWD;
5983 else if (unformat (i, "flood"))
5984 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5985 else if (unformat (i, "uu-flood"))
5986 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5991 if (sw_if_index_set == 0)
5993 errmsg ("missing interface name or sw_if_index");
5999 mp->sw_if_index = ntohl (sw_if_index);
6000 mp->feature_bitmap = ntohl (feature_bitmap);
6008 api_bridge_flags (vat_main_t * vam)
6010 unformat_input_t *i = vam->input;
6011 vl_api_bridge_flags_t *mp;
6018 /* Parse args required to build the message */
6019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6021 if (unformat (i, "bd_id %d", &bd_id))
6023 else if (unformat (i, "learn"))
6025 else if (unformat (i, "forward"))
6027 else if (unformat (i, "flood"))
6029 else if (unformat (i, "uu-flood"))
6030 flags |= L2_UU_FLOOD;
6031 else if (unformat (i, "arp-term"))
6032 flags |= L2_ARP_TERM;
6033 else if (unformat (i, "off"))
6035 else if (unformat (i, "disable"))
6043 errmsg ("missing bridge domain");
6047 M (BRIDGE_FLAGS, mp);
6049 mp->bd_id = ntohl (bd_id);
6050 mp->feature_bitmap = ntohl (flags);
6051 mp->is_set = is_set;
6059 api_bd_ip_mac_add_del (vat_main_t * vam)
6061 unformat_input_t *i = vam->input;
6062 vl_api_bd_ip_mac_add_del_t *mp;
6069 ip4_address_t v4addr;
6070 ip6_address_t v6addr;
6075 /* Parse args required to build the message */
6076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6078 if (unformat (i, "bd_id %d", &bd_id))
6082 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6086 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6091 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6095 else if (unformat (i, "del"))
6103 errmsg ("missing bridge domain");
6106 else if (ip_set == 0)
6108 errmsg ("missing IP address");
6111 else if (mac_set == 0)
6113 errmsg ("missing MAC address");
6117 M (BD_IP_MAC_ADD_DEL, mp);
6119 mp->bd_id = ntohl (bd_id);
6120 mp->is_ipv6 = is_ipv6;
6121 mp->is_add = is_add;
6123 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6125 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6126 clib_memcpy (mp->mac_address, macaddr, 6);
6133 api_tap_connect (vat_main_t * vam)
6135 unformat_input_t *i = vam->input;
6136 vl_api_tap_connect_t *mp;
6142 ip4_address_t ip4_address;
6144 int ip4_address_set = 0;
6145 ip6_address_t ip6_address;
6147 int ip6_address_set = 0;
6150 memset (mac_address, 0, sizeof (mac_address));
6152 /* Parse args required to build the message */
6153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6155 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6159 else if (unformat (i, "random-mac"))
6161 else if (unformat (i, "tapname %s", &tap_name))
6163 else if (unformat (i, "tag %s", &tag))
6165 else if (unformat (i, "address %U/%d",
6166 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6167 ip4_address_set = 1;
6168 else if (unformat (i, "address %U/%d",
6169 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6170 ip6_address_set = 1;
6177 errmsg ("missing tap name");
6180 if (vec_len (tap_name) > 63)
6182 errmsg ("tap name too long");
6185 vec_add1 (tap_name, 0);
6187 if (vec_len (tag) > 63)
6189 errmsg ("tag too long");
6193 /* Construct the API message */
6194 M (TAP_CONNECT, mp);
6196 mp->use_random_mac = random_mac;
6197 clib_memcpy (mp->mac_address, mac_address, 6);
6198 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6200 clib_memcpy (mp->tag, tag, vec_len (tag));
6202 if (ip4_address_set)
6204 mp->ip4_address_set = 1;
6205 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6206 mp->ip4_mask_width = ip4_mask_width;
6208 if (ip6_address_set)
6210 mp->ip6_address_set = 1;
6211 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6212 mp->ip6_mask_width = ip6_mask_width;
6215 vec_free (tap_name);
6221 /* Wait for a reply... */
6227 api_tap_modify (vat_main_t * vam)
6229 unformat_input_t *i = vam->input;
6230 vl_api_tap_modify_t *mp;
6235 u32 sw_if_index = ~0;
6236 u8 sw_if_index_set = 0;
6239 memset (mac_address, 0, sizeof (mac_address));
6241 /* Parse args required to build the message */
6242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6244 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6245 sw_if_index_set = 1;
6246 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6247 sw_if_index_set = 1;
6248 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6252 else if (unformat (i, "random-mac"))
6254 else if (unformat (i, "tapname %s", &tap_name))
6260 if (sw_if_index_set == 0)
6262 errmsg ("missing vpp interface name");
6267 errmsg ("missing tap name");
6270 if (vec_len (tap_name) > 63)
6272 errmsg ("tap name too long");
6274 vec_add1 (tap_name, 0);
6276 /* Construct the API message */
6279 mp->use_random_mac = random_mac;
6280 mp->sw_if_index = ntohl (sw_if_index);
6281 clib_memcpy (mp->mac_address, mac_address, 6);
6282 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6283 vec_free (tap_name);
6288 /* Wait for a reply... */
6294 api_tap_delete (vat_main_t * vam)
6296 unformat_input_t *i = vam->input;
6297 vl_api_tap_delete_t *mp;
6298 u32 sw_if_index = ~0;
6299 u8 sw_if_index_set = 0;
6302 /* Parse args required to build the message */
6303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6305 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6306 sw_if_index_set = 1;
6307 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6308 sw_if_index_set = 1;
6313 if (sw_if_index_set == 0)
6315 errmsg ("missing vpp interface name");
6319 /* Construct the API message */
6322 mp->sw_if_index = ntohl (sw_if_index);
6327 /* Wait for a reply... */
6333 api_ip_add_del_route (vat_main_t * vam)
6335 unformat_input_t *i = vam->input;
6336 vl_api_ip_add_del_route_t *mp;
6337 u32 sw_if_index = ~0, vrf_id = 0;
6339 u8 is_local = 0, is_drop = 0;
6340 u8 is_unreach = 0, is_prohibit = 0;
6341 u8 create_vrf_if_needed = 0;
6343 u32 next_hop_weight = 1;
6345 u8 is_multipath = 0;
6347 u8 address_length_set = 0;
6348 u32 next_hop_table_id = 0;
6349 u32 resolve_attempts = 0;
6350 u32 dst_address_length = 0;
6351 u8 next_hop_set = 0;
6352 ip4_address_t v4_dst_address, v4_next_hop_address;
6353 ip6_address_t v6_dst_address, v6_next_hop_address;
6357 u32 random_add_del = 0;
6358 u32 *random_vector = 0;
6360 u32 random_seed = 0xdeaddabe;
6361 u32 classify_table_index = ~0;
6363 u8 resolve_host = 0, resolve_attached = 0;
6364 mpls_label_t *next_hop_out_label_stack = NULL;
6365 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6366 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6368 /* Parse args required to build the message */
6369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6375 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6380 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6385 else if (unformat (i, "/%d", &dst_address_length))
6387 address_length_set = 1;
6390 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6391 &v4_next_hop_address))
6395 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6396 &v6_next_hop_address))
6400 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6402 else if (unformat (i, "weight %d", &next_hop_weight))
6404 else if (unformat (i, "drop"))
6408 else if (unformat (i, "null-send-unreach"))
6412 else if (unformat (i, "null-send-prohibit"))
6416 else if (unformat (i, "local"))
6420 else if (unformat (i, "classify %d", &classify_table_index))
6424 else if (unformat (i, "del"))
6426 else if (unformat (i, "add"))
6428 else if (unformat (i, "not-last"))
6430 else if (unformat (i, "resolve-via-host"))
6432 else if (unformat (i, "resolve-via-attached"))
6433 resolve_attached = 1;
6434 else if (unformat (i, "multipath"))
6436 else if (unformat (i, "vrf %d", &vrf_id))
6438 else if (unformat (i, "create-vrf"))
6439 create_vrf_if_needed = 1;
6440 else if (unformat (i, "count %d", &count))
6442 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6444 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6446 else if (unformat (i, "out-label %d", &next_hop_out_label))
6447 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6448 else if (unformat (i, "via-label %d", &next_hop_via_label))
6450 else if (unformat (i, "random"))
6452 else if (unformat (i, "seed %d", &random_seed))
6456 clib_warning ("parse error '%U'", format_unformat_error, i);
6461 if (!next_hop_set && !is_drop && !is_local &&
6462 !is_classify && !is_unreach && !is_prohibit &&
6463 MPLS_LABEL_INVALID == next_hop_via_label)
6466 ("next hop / local / drop / unreach / prohibit / classify not set");
6470 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6472 errmsg ("next hop and next-hop via label set");
6475 if (address_set == 0)
6477 errmsg ("missing addresses");
6481 if (address_length_set == 0)
6483 errmsg ("missing address length");
6487 /* Generate a pile of unique, random routes */
6490 u32 this_random_address;
6491 random_hash = hash_create (count, sizeof (uword));
6493 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6494 for (j = 0; j <= count; j++)
6498 this_random_address = random_u32 (&random_seed);
6499 this_random_address =
6500 clib_host_to_net_u32 (this_random_address);
6502 while (hash_get (random_hash, this_random_address));
6503 vec_add1 (random_vector, this_random_address);
6504 hash_set (random_hash, this_random_address, 1);
6506 hash_free (random_hash);
6507 v4_dst_address.as_u32 = random_vector[0];
6512 /* Turn on async mode */
6513 vam->async_mode = 1;
6514 vam->async_errors = 0;
6515 before = vat_time_now (vam);
6518 for (j = 0; j < count; j++)
6520 /* Construct the API message */
6521 M2 (IP_ADD_DEL_ROUTE, mp,
6522 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6524 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6525 mp->table_id = ntohl (vrf_id);
6526 mp->create_vrf_if_needed = create_vrf_if_needed;
6528 mp->is_add = is_add;
6529 mp->is_drop = is_drop;
6530 mp->is_unreach = is_unreach;
6531 mp->is_prohibit = is_prohibit;
6532 mp->is_ipv6 = is_ipv6;
6533 mp->is_local = is_local;
6534 mp->is_classify = is_classify;
6535 mp->is_multipath = is_multipath;
6536 mp->is_resolve_host = resolve_host;
6537 mp->is_resolve_attached = resolve_attached;
6538 mp->not_last = not_last;
6539 mp->next_hop_weight = next_hop_weight;
6540 mp->dst_address_length = dst_address_length;
6541 mp->next_hop_table_id = ntohl (next_hop_table_id);
6542 mp->classify_table_index = ntohl (classify_table_index);
6543 mp->next_hop_via_label = ntohl (next_hop_via_label);
6544 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6545 if (0 != mp->next_hop_n_out_labels)
6547 memcpy (mp->next_hop_out_label_stack,
6548 next_hop_out_label_stack,
6549 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6550 vec_free (next_hop_out_label_stack);
6555 clib_memcpy (mp->dst_address, &v6_dst_address,
6556 sizeof (v6_dst_address));
6558 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6559 sizeof (v6_next_hop_address));
6560 increment_v6_address (&v6_dst_address);
6564 clib_memcpy (mp->dst_address, &v4_dst_address,
6565 sizeof (v4_dst_address));
6567 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6568 sizeof (v4_next_hop_address));
6570 v4_dst_address.as_u32 = random_vector[j + 1];
6572 increment_v4_address (&v4_dst_address);
6576 /* If we receive SIGTERM, stop now... */
6581 /* When testing multiple add/del ops, use a control-ping to sync */
6584 vl_api_control_ping_t *mp_ping;
6588 /* Shut off async mode */
6589 vam->async_mode = 0;
6591 M (CONTROL_PING, mp_ping);
6594 timeout = vat_time_now (vam) + 1.0;
6595 while (vat_time_now (vam) < timeout)
6596 if (vam->result_ready == 1)
6601 if (vam->retval == -99)
6604 if (vam->async_errors > 0)
6606 errmsg ("%d asynchronous errors", vam->async_errors);
6609 vam->async_errors = 0;
6610 after = vat_time_now (vam);
6612 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6616 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6617 count, after - before, count / (after - before));
6623 /* Wait for a reply... */
6628 /* Return the good/bad news */
6629 return (vam->retval);
6633 api_ip_mroute_add_del (vat_main_t * vam)
6635 unformat_input_t *i = vam->input;
6636 vl_api_ip_mroute_add_del_t *mp;
6637 u32 sw_if_index = ~0, vrf_id = 0;
6640 u8 create_vrf_if_needed = 0;
6643 u32 grp_address_length = 0;
6644 ip4_address_t v4_grp_address, v4_src_address;
6645 ip6_address_t v6_grp_address, v6_src_address;
6646 mfib_itf_flags_t iflags = 0;
6647 mfib_entry_flags_t eflags = 0;
6650 /* Parse args required to build the message */
6651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6653 if (unformat (i, "sw_if_index %d", &sw_if_index))
6655 else if (unformat (i, "%U %U",
6656 unformat_ip4_address, &v4_src_address,
6657 unformat_ip4_address, &v4_grp_address))
6659 grp_address_length = 64;
6663 else if (unformat (i, "%U %U",
6664 unformat_ip6_address, &v6_src_address,
6665 unformat_ip6_address, &v6_grp_address))
6667 grp_address_length = 256;
6671 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6673 memset (&v4_src_address, 0, sizeof (v4_src_address));
6674 grp_address_length = 32;
6678 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6680 memset (&v6_src_address, 0, sizeof (v6_src_address));
6681 grp_address_length = 128;
6685 else if (unformat (i, "/%d", &grp_address_length))
6687 else if (unformat (i, "local"))
6691 else if (unformat (i, "del"))
6693 else if (unformat (i, "add"))
6695 else if (unformat (i, "vrf %d", &vrf_id))
6697 else if (unformat (i, "create-vrf"))
6698 create_vrf_if_needed = 1;
6699 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6701 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6705 clib_warning ("parse error '%U'", format_unformat_error, i);
6710 if (address_set == 0)
6712 errmsg ("missing addresses\n");
6716 /* Construct the API message */
6717 M (IP_MROUTE_ADD_DEL, mp);
6719 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6720 mp->table_id = ntohl (vrf_id);
6721 mp->create_vrf_if_needed = create_vrf_if_needed;
6723 mp->is_add = is_add;
6724 mp->is_ipv6 = is_ipv6;
6725 mp->is_local = is_local;
6726 mp->itf_flags = ntohl (iflags);
6727 mp->entry_flags = ntohl (eflags);
6728 mp->grp_address_length = grp_address_length;
6729 mp->grp_address_length = ntohs (mp->grp_address_length);
6733 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6734 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6738 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6739 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6745 /* Wait for a reply... */
6751 api_mpls_route_add_del (vat_main_t * vam)
6753 unformat_input_t *i = vam->input;
6754 vl_api_mpls_route_add_del_t *mp;
6755 u32 sw_if_index = ~0, table_id = 0;
6756 u8 create_table_if_needed = 0;
6758 u32 next_hop_weight = 1;
6759 u8 is_multipath = 0;
6760 u32 next_hop_table_id = 0;
6761 u8 next_hop_set = 0;
6762 ip4_address_t v4_next_hop_address = {
6765 ip6_address_t v6_next_hop_address = { {0} };
6769 u32 classify_table_index = ~0;
6771 u8 resolve_host = 0, resolve_attached = 0;
6772 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6773 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6774 mpls_label_t *next_hop_out_label_stack = NULL;
6775 mpls_label_t local_label = MPLS_LABEL_INVALID;
6777 u8 next_hop_proto_is_ip4 = 1;
6779 /* Parse args required to build the message */
6780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6782 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6784 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6786 else if (unformat (i, "%d", &local_label))
6788 else if (unformat (i, "eos"))
6790 else if (unformat (i, "non-eos"))
6792 else if (unformat (i, "via %U", unformat_ip4_address,
6793 &v4_next_hop_address))
6796 next_hop_proto_is_ip4 = 1;
6798 else if (unformat (i, "via %U", unformat_ip6_address,
6799 &v6_next_hop_address))
6802 next_hop_proto_is_ip4 = 0;
6804 else if (unformat (i, "weight %d", &next_hop_weight))
6806 else if (unformat (i, "create-table"))
6807 create_table_if_needed = 1;
6808 else if (unformat (i, "classify %d", &classify_table_index))
6812 else if (unformat (i, "del"))
6814 else if (unformat (i, "add"))
6816 else if (unformat (i, "resolve-via-host"))
6818 else if (unformat (i, "resolve-via-attached"))
6819 resolve_attached = 1;
6820 else if (unformat (i, "multipath"))
6822 else if (unformat (i, "count %d", &count))
6824 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6827 next_hop_proto_is_ip4 = 1;
6829 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6832 next_hop_proto_is_ip4 = 0;
6834 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6836 else if (unformat (i, "via-label %d", &next_hop_via_label))
6838 else if (unformat (i, "out-label %d", &next_hop_out_label))
6839 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6842 clib_warning ("parse error '%U'", format_unformat_error, i);
6847 if (!next_hop_set && !is_classify)
6849 errmsg ("next hop / classify not set");
6853 if (MPLS_LABEL_INVALID == local_label)
6855 errmsg ("missing label");
6861 /* Turn on async mode */
6862 vam->async_mode = 1;
6863 vam->async_errors = 0;
6864 before = vat_time_now (vam);
6867 for (j = 0; j < count; j++)
6869 /* Construct the API message */
6870 M2 (MPLS_ROUTE_ADD_DEL, mp,
6871 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6873 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6874 mp->mr_table_id = ntohl (table_id);
6875 mp->mr_create_table_if_needed = create_table_if_needed;
6877 mp->mr_is_add = is_add;
6878 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6879 mp->mr_is_classify = is_classify;
6880 mp->mr_is_multipath = is_multipath;
6881 mp->mr_is_resolve_host = resolve_host;
6882 mp->mr_is_resolve_attached = resolve_attached;
6883 mp->mr_next_hop_weight = next_hop_weight;
6884 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6885 mp->mr_classify_table_index = ntohl (classify_table_index);
6886 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6887 mp->mr_label = ntohl (local_label);
6888 mp->mr_eos = is_eos;
6890 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6891 if (0 != mp->mr_next_hop_n_out_labels)
6893 memcpy (mp->mr_next_hop_out_label_stack,
6894 next_hop_out_label_stack,
6895 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6896 vec_free (next_hop_out_label_stack);
6901 if (next_hop_proto_is_ip4)
6903 clib_memcpy (mp->mr_next_hop,
6904 &v4_next_hop_address,
6905 sizeof (v4_next_hop_address));
6909 clib_memcpy (mp->mr_next_hop,
6910 &v6_next_hop_address,
6911 sizeof (v6_next_hop_address));
6918 /* If we receive SIGTERM, stop now... */
6923 /* When testing multiple add/del ops, use a control-ping to sync */
6926 vl_api_control_ping_t *mp_ping;
6930 /* Shut off async mode */
6931 vam->async_mode = 0;
6933 M (CONTROL_PING, mp_ping);
6936 timeout = vat_time_now (vam) + 1.0;
6937 while (vat_time_now (vam) < timeout)
6938 if (vam->result_ready == 1)
6943 if (vam->retval == -99)
6946 if (vam->async_errors > 0)
6948 errmsg ("%d asynchronous errors", vam->async_errors);
6951 vam->async_errors = 0;
6952 after = vat_time_now (vam);
6954 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6958 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6959 count, after - before, count / (after - before));
6965 /* Wait for a reply... */
6970 /* Return the good/bad news */
6971 return (vam->retval);
6975 api_mpls_ip_bind_unbind (vat_main_t * vam)
6977 unformat_input_t *i = vam->input;
6978 vl_api_mpls_ip_bind_unbind_t *mp;
6979 u32 ip_table_id = 0;
6980 u8 create_table_if_needed = 0;
6983 ip4_address_t v4_address;
6984 ip6_address_t v6_address;
6987 mpls_label_t local_label = MPLS_LABEL_INVALID;
6990 /* Parse args required to build the message */
6991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6993 if (unformat (i, "%U/%d", unformat_ip4_address,
6994 &v4_address, &address_length))
6999 else if (unformat (i, "%U/%d", unformat_ip6_address,
7000 &v6_address, &address_length))
7005 else if (unformat (i, "%d", &local_label))
7007 else if (unformat (i, "create-table"))
7008 create_table_if_needed = 1;
7009 else if (unformat (i, "table-id %d", &ip_table_id))
7011 else if (unformat (i, "unbind"))
7013 else if (unformat (i, "bind"))
7017 clib_warning ("parse error '%U'", format_unformat_error, i);
7024 errmsg ("IP addres not set");
7028 if (MPLS_LABEL_INVALID == local_label)
7030 errmsg ("missing label");
7034 /* Construct the API message */
7035 M (MPLS_IP_BIND_UNBIND, mp);
7037 mp->mb_create_table_if_needed = create_table_if_needed;
7038 mp->mb_is_bind = is_bind;
7039 mp->mb_is_ip4 = is_ip4;
7040 mp->mb_ip_table_id = ntohl (ip_table_id);
7041 mp->mb_mpls_table_id = 0;
7042 mp->mb_label = ntohl (local_label);
7043 mp->mb_address_length = address_length;
7046 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7048 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7053 /* Wait for a reply... */
7059 api_proxy_arp_add_del (vat_main_t * vam)
7061 unformat_input_t *i = vam->input;
7062 vl_api_proxy_arp_add_del_t *mp;
7065 ip4_address_t lo, hi;
7069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7071 if (unformat (i, "vrf %d", &vrf_id))
7073 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7074 unformat_ip4_address, &hi))
7076 else if (unformat (i, "del"))
7080 clib_warning ("parse error '%U'", format_unformat_error, i);
7087 errmsg ("address range not set");
7091 M (PROXY_ARP_ADD_DEL, mp);
7093 mp->vrf_id = ntohl (vrf_id);
7094 mp->is_add = is_add;
7095 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7096 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7104 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7106 unformat_input_t *i = vam->input;
7107 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7110 u8 sw_if_index_set = 0;
7113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7116 sw_if_index_set = 1;
7117 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7118 sw_if_index_set = 1;
7119 else if (unformat (i, "enable"))
7121 else if (unformat (i, "disable"))
7125 clib_warning ("parse error '%U'", format_unformat_error, i);
7130 if (sw_if_index_set == 0)
7132 errmsg ("missing interface name or sw_if_index");
7136 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7138 mp->sw_if_index = ntohl (sw_if_index);
7139 mp->enable_disable = enable;
7147 api_mpls_tunnel_add_del (vat_main_t * vam)
7149 unformat_input_t *i = vam->input;
7150 vl_api_mpls_tunnel_add_del_t *mp;
7154 u32 sw_if_index = ~0;
7155 u32 next_hop_sw_if_index = ~0;
7156 u32 next_hop_proto_is_ip4 = 1;
7158 u32 next_hop_table_id = 0;
7159 ip4_address_t v4_next_hop_address = {
7162 ip6_address_t v6_next_hop_address = { {0} };
7163 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7168 if (unformat (i, "add"))
7170 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7172 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7174 else if (unformat (i, "via %U",
7175 unformat_ip4_address, &v4_next_hop_address))
7177 next_hop_proto_is_ip4 = 1;
7179 else if (unformat (i, "via %U",
7180 unformat_ip6_address, &v6_next_hop_address))
7182 next_hop_proto_is_ip4 = 0;
7184 else if (unformat (i, "l2-only"))
7186 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7188 else if (unformat (i, "out-label %d", &next_hop_out_label))
7189 vec_add1 (labels, ntohl (next_hop_out_label));
7192 clib_warning ("parse error '%U'", format_unformat_error, i);
7197 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7199 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7200 mp->mt_sw_if_index = ntohl (sw_if_index);
7201 mp->mt_is_add = is_add;
7202 mp->mt_l2_only = l2_only;
7203 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7204 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7206 mp->mt_next_hop_n_out_labels = vec_len (labels);
7208 if (0 != mp->mt_next_hop_n_out_labels)
7210 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7211 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7215 if (next_hop_proto_is_ip4)
7217 clib_memcpy (mp->mt_next_hop,
7218 &v4_next_hop_address, sizeof (v4_next_hop_address));
7222 clib_memcpy (mp->mt_next_hop,
7223 &v6_next_hop_address, sizeof (v6_next_hop_address));
7232 api_sw_interface_set_unnumbered (vat_main_t * vam)
7234 unformat_input_t *i = vam->input;
7235 vl_api_sw_interface_set_unnumbered_t *mp;
7237 u32 unnum_sw_index = ~0;
7239 u8 sw_if_index_set = 0;
7242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7244 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7245 sw_if_index_set = 1;
7246 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7247 sw_if_index_set = 1;
7248 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7250 else if (unformat (i, "del"))
7254 clib_warning ("parse error '%U'", format_unformat_error, i);
7259 if (sw_if_index_set == 0)
7261 errmsg ("missing interface name or sw_if_index");
7265 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7267 mp->sw_if_index = ntohl (sw_if_index);
7268 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7269 mp->is_add = is_add;
7277 api_ip_neighbor_add_del (vat_main_t * vam)
7279 unformat_input_t *i = vam->input;
7280 vl_api_ip_neighbor_add_del_t *mp;
7282 u8 sw_if_index_set = 0;
7288 u8 v4_address_set = 0;
7289 u8 v6_address_set = 0;
7290 ip4_address_t v4address;
7291 ip6_address_t v6address;
7294 memset (mac_address, 0, sizeof (mac_address));
7296 /* Parse args required to build the message */
7297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7299 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7303 else if (unformat (i, "del"))
7306 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7307 sw_if_index_set = 1;
7308 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7309 sw_if_index_set = 1;
7310 else if (unformat (i, "is_static"))
7312 else if (unformat (i, "vrf %d", &vrf_id))
7314 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7316 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7320 clib_warning ("parse error '%U'", format_unformat_error, i);
7325 if (sw_if_index_set == 0)
7327 errmsg ("missing interface name or sw_if_index");
7330 if (v4_address_set && v6_address_set)
7332 errmsg ("both v4 and v6 addresses set");
7335 if (!v4_address_set && !v6_address_set)
7337 errmsg ("no address set");
7341 /* Construct the API message */
7342 M (IP_NEIGHBOR_ADD_DEL, mp);
7344 mp->sw_if_index = ntohl (sw_if_index);
7345 mp->is_add = is_add;
7346 mp->vrf_id = ntohl (vrf_id);
7347 mp->is_static = is_static;
7349 clib_memcpy (mp->mac_address, mac_address, 6);
7353 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7357 /* mp->is_ipv6 = 0; via memset in M macro above */
7358 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7364 /* Wait for a reply, return good/bad news */
7370 api_reset_vrf (vat_main_t * vam)
7372 unformat_input_t *i = vam->input;
7373 vl_api_reset_vrf_t *mp;
7379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7381 if (unformat (i, "vrf %d", &vrf_id))
7383 else if (unformat (i, "ipv6"))
7387 clib_warning ("parse error '%U'", format_unformat_error, i);
7392 if (vrf_id_set == 0)
7394 errmsg ("missing vrf id");
7400 mp->vrf_id = ntohl (vrf_id);
7401 mp->is_ipv6 = is_ipv6;
7409 api_create_vlan_subif (vat_main_t * vam)
7411 unformat_input_t *i = vam->input;
7412 vl_api_create_vlan_subif_t *mp;
7414 u8 sw_if_index_set = 0;
7419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7421 if (unformat (i, "sw_if_index %d", &sw_if_index))
7422 sw_if_index_set = 1;
7424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7425 sw_if_index_set = 1;
7426 else if (unformat (i, "vlan %d", &vlan_id))
7430 clib_warning ("parse error '%U'", format_unformat_error, i);
7435 if (sw_if_index_set == 0)
7437 errmsg ("missing interface name or sw_if_index");
7441 if (vlan_id_set == 0)
7443 errmsg ("missing vlan_id");
7446 M (CREATE_VLAN_SUBIF, mp);
7448 mp->sw_if_index = ntohl (sw_if_index);
7449 mp->vlan_id = ntohl (vlan_id);
7456 #define foreach_create_subif_bit \
7463 _(outer_vlan_id_any) \
7464 _(inner_vlan_id_any)
7467 api_create_subif (vat_main_t * vam)
7469 unformat_input_t *i = vam->input;
7470 vl_api_create_subif_t *mp;
7472 u8 sw_if_index_set = 0;
7479 u32 exact_match = 0;
7480 u32 default_sub = 0;
7481 u32 outer_vlan_id_any = 0;
7482 u32 inner_vlan_id_any = 0;
7484 u16 outer_vlan_id = 0;
7485 u16 inner_vlan_id = 0;
7488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7490 if (unformat (i, "sw_if_index %d", &sw_if_index))
7491 sw_if_index_set = 1;
7493 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7494 sw_if_index_set = 1;
7495 else if (unformat (i, "sub_id %d", &sub_id))
7497 else if (unformat (i, "outer_vlan_id %d", &tmp))
7498 outer_vlan_id = tmp;
7499 else if (unformat (i, "inner_vlan_id %d", &tmp))
7500 inner_vlan_id = tmp;
7502 #define _(a) else if (unformat (i, #a)) a = 1 ;
7503 foreach_create_subif_bit
7507 clib_warning ("parse error '%U'", format_unformat_error, i);
7512 if (sw_if_index_set == 0)
7514 errmsg ("missing interface name or sw_if_index");
7518 if (sub_id_set == 0)
7520 errmsg ("missing sub_id");
7523 M (CREATE_SUBIF, mp);
7525 mp->sw_if_index = ntohl (sw_if_index);
7526 mp->sub_id = ntohl (sub_id);
7528 #define _(a) mp->a = a;
7529 foreach_create_subif_bit;
7532 mp->outer_vlan_id = ntohs (outer_vlan_id);
7533 mp->inner_vlan_id = ntohs (inner_vlan_id);
7541 api_oam_add_del (vat_main_t * vam)
7543 unformat_input_t *i = vam->input;
7544 vl_api_oam_add_del_t *mp;
7547 ip4_address_t src, dst;
7552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 if (unformat (i, "vrf %d", &vrf_id))
7556 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7558 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7560 else if (unformat (i, "del"))
7564 clib_warning ("parse error '%U'", format_unformat_error, i);
7571 errmsg ("missing src addr");
7577 errmsg ("missing dst addr");
7581 M (OAM_ADD_DEL, mp);
7583 mp->vrf_id = ntohl (vrf_id);
7584 mp->is_add = is_add;
7585 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7586 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7594 api_reset_fib (vat_main_t * vam)
7596 unformat_input_t *i = vam->input;
7597 vl_api_reset_fib_t *mp;
7603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7605 if (unformat (i, "vrf %d", &vrf_id))
7607 else if (unformat (i, "ipv6"))
7611 clib_warning ("parse error '%U'", format_unformat_error, i);
7616 if (vrf_id_set == 0)
7618 errmsg ("missing vrf id");
7624 mp->vrf_id = ntohl (vrf_id);
7625 mp->is_ipv6 = is_ipv6;
7633 api_dhcp_proxy_config (vat_main_t * vam)
7635 unformat_input_t *i = vam->input;
7636 vl_api_dhcp_proxy_config_t *mp;
7638 u32 server_vrf_id = 0;
7640 u8 v4_address_set = 0;
7641 u8 v6_address_set = 0;
7642 ip4_address_t v4address;
7643 ip6_address_t v6address;
7644 u8 v4_src_address_set = 0;
7645 u8 v6_src_address_set = 0;
7646 ip4_address_t v4srcaddress;
7647 ip6_address_t v6srcaddress;
7650 /* Parse args required to build the message */
7651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7653 if (unformat (i, "del"))
7655 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7657 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7659 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7661 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7663 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7664 v4_src_address_set = 1;
7665 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7666 v6_src_address_set = 1;
7671 if (v4_address_set && v6_address_set)
7673 errmsg ("both v4 and v6 server addresses set");
7676 if (!v4_address_set && !v6_address_set)
7678 errmsg ("no server addresses set");
7682 if (v4_src_address_set && v6_src_address_set)
7684 errmsg ("both v4 and v6 src addresses set");
7687 if (!v4_src_address_set && !v6_src_address_set)
7689 errmsg ("no src addresses set");
7693 if (!(v4_src_address_set && v4_address_set) &&
7694 !(v6_src_address_set && v6_address_set))
7696 errmsg ("no matching server and src addresses set");
7700 /* Construct the API message */
7701 M (DHCP_PROXY_CONFIG, mp);
7703 mp->is_add = is_add;
7704 mp->rx_vrf_id = ntohl (rx_vrf_id);
7705 mp->server_vrf_id = ntohl (server_vrf_id);
7709 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7710 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7714 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7715 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7721 /* Wait for a reply, return good/bad news */
7726 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7727 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7730 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7732 vat_main_t *vam = &vat_main;
7736 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7737 ntohl (mp->rx_vrf_id),
7738 ntohl (mp->server_vrf_id),
7739 format_ip6_address, mp->dhcp_server,
7740 format_ip6_address, mp->dhcp_src_address,
7741 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7744 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7745 ntohl (mp->rx_vrf_id),
7746 ntohl (mp->server_vrf_id),
7747 format_ip4_address, mp->dhcp_server,
7748 format_ip4_address, mp->dhcp_src_address,
7749 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7752 static void vl_api_dhcp_proxy_details_t_handler_json
7753 (vl_api_dhcp_proxy_details_t * mp)
7755 vat_main_t *vam = &vat_main;
7756 vat_json_node_t *node = NULL;
7758 struct in6_addr ip6;
7760 if (VAT_JSON_ARRAY != vam->json_tree.type)
7762 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7763 vat_json_init_array (&vam->json_tree);
7765 node = vat_json_array_add (&vam->json_tree);
7767 vat_json_init_object (node);
7768 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7769 vat_json_object_add_uint (node, "server-table-id",
7770 ntohl (mp->server_vrf_id));
7773 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7774 vat_json_object_add_ip6 (node, "server_address", ip6);
7775 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7776 vat_json_object_add_ip6 (node, "src_address", ip6);
7780 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7781 vat_json_object_add_ip4 (node, "server_address", ip4);
7782 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7783 vat_json_object_add_ip4 (node, "src_address", ip4);
7785 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7786 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7790 api_dhcp_proxy_dump (vat_main_t * vam)
7792 unformat_input_t *i = vam->input;
7793 vl_api_control_ping_t *mp_ping;
7794 vl_api_dhcp_proxy_dump_t *mp;
7798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7800 if (unformat (i, "ipv6"))
7804 clib_warning ("parse error '%U'", format_unformat_error, i);
7809 M (DHCP_PROXY_DUMP, mp);
7811 mp->is_ip6 = is_ipv6;
7814 /* Use a control ping for synchronization */
7815 M (CONTROL_PING, mp_ping);
7823 api_dhcp_proxy_set_vss (vat_main_t * vam)
7825 unformat_input_t *i = vam->input;
7826 vl_api_dhcp_proxy_set_vss_t *mp;
7837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7839 if (unformat (i, "tbl_id %d", &tbl_id))
7841 if (unformat (i, "fib_id %d", &fib_id))
7843 if (unformat (i, "oui %d", &oui))
7845 else if (unformat (i, "ipv6"))
7847 else if (unformat (i, "del"))
7851 clib_warning ("parse error '%U'", format_unformat_error, i);
7856 if (tbl_id_set == 0)
7858 errmsg ("missing tbl id");
7862 if (fib_id_set == 0)
7864 errmsg ("missing fib id");
7869 errmsg ("missing oui");
7873 M (DHCP_PROXY_SET_VSS, mp);
7874 mp->tbl_id = ntohl (tbl_id);
7875 mp->fib_id = ntohl (fib_id);
7876 mp->oui = ntohl (oui);
7877 mp->is_ipv6 = is_ipv6;
7878 mp->is_add = is_add;
7886 api_dhcp_client_config (vat_main_t * vam)
7888 unformat_input_t *i = vam->input;
7889 vl_api_dhcp_client_config_t *mp;
7891 u8 sw_if_index_set = 0;
7894 u8 disable_event = 0;
7897 /* Parse args required to build the message */
7898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7900 if (unformat (i, "del"))
7903 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7904 sw_if_index_set = 1;
7905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7906 sw_if_index_set = 1;
7907 else if (unformat (i, "hostname %s", &hostname))
7909 else if (unformat (i, "disable_event"))
7915 if (sw_if_index_set == 0)
7917 errmsg ("missing interface name or sw_if_index");
7921 if (vec_len (hostname) > 63)
7923 errmsg ("hostname too long");
7925 vec_add1 (hostname, 0);
7927 /* Construct the API message */
7928 M (DHCP_CLIENT_CONFIG, mp);
7930 mp->sw_if_index = ntohl (sw_if_index);
7931 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7932 vec_free (hostname);
7933 mp->is_add = is_add;
7934 mp->want_dhcp_event = disable_event ? 0 : 1;
7935 mp->pid = getpid ();
7940 /* Wait for a reply, return good/bad news */
7946 api_set_ip_flow_hash (vat_main_t * vam)
7948 unformat_input_t *i = vam->input;
7949 vl_api_set_ip_flow_hash_t *mp;
7961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7963 if (unformat (i, "vrf %d", &vrf_id))
7965 else if (unformat (i, "ipv6"))
7967 else if (unformat (i, "src"))
7969 else if (unformat (i, "dst"))
7971 else if (unformat (i, "sport"))
7973 else if (unformat (i, "dport"))
7975 else if (unformat (i, "proto"))
7977 else if (unformat (i, "reverse"))
7982 clib_warning ("parse error '%U'", format_unformat_error, i);
7987 if (vrf_id_set == 0)
7989 errmsg ("missing vrf id");
7993 M (SET_IP_FLOW_HASH, mp);
7999 mp->reverse = reverse;
8000 mp->vrf_id = ntohl (vrf_id);
8001 mp->is_ipv6 = is_ipv6;
8009 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8011 unformat_input_t *i = vam->input;
8012 vl_api_sw_interface_ip6_enable_disable_t *mp;
8014 u8 sw_if_index_set = 0;
8018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8021 sw_if_index_set = 1;
8022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8023 sw_if_index_set = 1;
8024 else if (unformat (i, "enable"))
8026 else if (unformat (i, "disable"))
8030 clib_warning ("parse error '%U'", format_unformat_error, i);
8035 if (sw_if_index_set == 0)
8037 errmsg ("missing interface name or sw_if_index");
8041 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8043 mp->sw_if_index = ntohl (sw_if_index);
8044 mp->enable = enable;
8052 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8054 unformat_input_t *i = vam->input;
8055 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8057 u8 sw_if_index_set = 0;
8058 u8 v6_address_set = 0;
8059 ip6_address_t v6address;
8062 /* Parse args required to build the message */
8063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8065 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8066 sw_if_index_set = 1;
8067 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8068 sw_if_index_set = 1;
8069 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8075 if (sw_if_index_set == 0)
8077 errmsg ("missing interface name or sw_if_index");
8080 if (!v6_address_set)
8082 errmsg ("no address set");
8086 /* Construct the API message */
8087 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8089 mp->sw_if_index = ntohl (sw_if_index);
8090 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8095 /* Wait for a reply, return good/bad news */
8102 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8104 unformat_input_t *i = vam->input;
8105 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8107 u8 sw_if_index_set = 0;
8108 u32 address_length = 0;
8109 u8 v6_address_set = 0;
8110 ip6_address_t v6address;
8112 u8 no_advertise = 0;
8114 u8 no_autoconfig = 0;
8117 u32 val_lifetime = 0;
8118 u32 pref_lifetime = 0;
8121 /* Parse args required to build the message */
8122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8125 sw_if_index_set = 1;
8126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8127 sw_if_index_set = 1;
8128 else if (unformat (i, "%U/%d",
8129 unformat_ip6_address, &v6address, &address_length))
8131 else if (unformat (i, "val_life %d", &val_lifetime))
8133 else if (unformat (i, "pref_life %d", &pref_lifetime))
8135 else if (unformat (i, "def"))
8137 else if (unformat (i, "noadv"))
8139 else if (unformat (i, "offl"))
8141 else if (unformat (i, "noauto"))
8143 else if (unformat (i, "nolink"))
8145 else if (unformat (i, "isno"))
8149 clib_warning ("parse error '%U'", format_unformat_error, i);
8154 if (sw_if_index_set == 0)
8156 errmsg ("missing interface name or sw_if_index");
8159 if (!v6_address_set)
8161 errmsg ("no address set");
8165 /* Construct the API message */
8166 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8168 mp->sw_if_index = ntohl (sw_if_index);
8169 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8170 mp->address_length = address_length;
8171 mp->use_default = use_default;
8172 mp->no_advertise = no_advertise;
8173 mp->off_link = off_link;
8174 mp->no_autoconfig = no_autoconfig;
8175 mp->no_onlink = no_onlink;
8177 mp->val_lifetime = ntohl (val_lifetime);
8178 mp->pref_lifetime = ntohl (pref_lifetime);
8183 /* Wait for a reply, return good/bad news */
8189 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8191 unformat_input_t *i = vam->input;
8192 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8194 u8 sw_if_index_set = 0;
8199 u8 send_unicast = 0;
8202 u8 default_router = 0;
8203 u32 max_interval = 0;
8204 u32 min_interval = 0;
8206 u32 initial_count = 0;
8207 u32 initial_interval = 0;
8211 /* Parse args required to build the message */
8212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8215 sw_if_index_set = 1;
8216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8217 sw_if_index_set = 1;
8218 else if (unformat (i, "maxint %d", &max_interval))
8220 else if (unformat (i, "minint %d", &min_interval))
8222 else if (unformat (i, "life %d", &lifetime))
8224 else if (unformat (i, "count %d", &initial_count))
8226 else if (unformat (i, "interval %d", &initial_interval))
8228 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8230 else if (unformat (i, "managed"))
8232 else if (unformat (i, "other"))
8234 else if (unformat (i, "ll"))
8236 else if (unformat (i, "send"))
8238 else if (unformat (i, "cease"))
8240 else if (unformat (i, "isno"))
8242 else if (unformat (i, "def"))
8246 clib_warning ("parse error '%U'", format_unformat_error, i);
8251 if (sw_if_index_set == 0)
8253 errmsg ("missing interface name or sw_if_index");
8257 /* Construct the API message */
8258 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8260 mp->sw_if_index = ntohl (sw_if_index);
8261 mp->max_interval = ntohl (max_interval);
8262 mp->min_interval = ntohl (min_interval);
8263 mp->lifetime = ntohl (lifetime);
8264 mp->initial_count = ntohl (initial_count);
8265 mp->initial_interval = ntohl (initial_interval);
8266 mp->suppress = suppress;
8267 mp->managed = managed;
8269 mp->ll_option = ll_option;
8270 mp->send_unicast = send_unicast;
8273 mp->default_router = default_router;
8278 /* Wait for a reply, return good/bad news */
8284 api_set_arp_neighbor_limit (vat_main_t * vam)
8286 unformat_input_t *i = vam->input;
8287 vl_api_set_arp_neighbor_limit_t *mp;
8293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8295 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8297 else if (unformat (i, "ipv6"))
8301 clib_warning ("parse error '%U'", format_unformat_error, i);
8308 errmsg ("missing limit value");
8312 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8314 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8315 mp->is_ipv6 = is_ipv6;
8323 api_l2_patch_add_del (vat_main_t * vam)
8325 unformat_input_t *i = vam->input;
8326 vl_api_l2_patch_add_del_t *mp;
8328 u8 rx_sw_if_index_set = 0;
8330 u8 tx_sw_if_index_set = 0;
8334 /* Parse args required to build the message */
8335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8337 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8338 rx_sw_if_index_set = 1;
8339 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8340 tx_sw_if_index_set = 1;
8341 else if (unformat (i, "rx"))
8343 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8345 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8347 rx_sw_if_index_set = 1;
8352 else if (unformat (i, "tx"))
8354 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8356 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8358 tx_sw_if_index_set = 1;
8363 else if (unformat (i, "del"))
8369 if (rx_sw_if_index_set == 0)
8371 errmsg ("missing rx interface name or rx_sw_if_index");
8375 if (tx_sw_if_index_set == 0)
8377 errmsg ("missing tx interface name or tx_sw_if_index");
8381 M (L2_PATCH_ADD_DEL, mp);
8383 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8384 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8385 mp->is_add = is_add;
8393 api_ioam_enable (vat_main_t * vam)
8395 unformat_input_t *input = vam->input;
8396 vl_api_ioam_enable_t *mp;
8398 int has_trace_option = 0;
8399 int has_pot_option = 0;
8400 int has_seqno_option = 0;
8401 int has_analyse_option = 0;
8404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8406 if (unformat (input, "trace"))
8407 has_trace_option = 1;
8408 else if (unformat (input, "pot"))
8410 else if (unformat (input, "seqno"))
8411 has_seqno_option = 1;
8412 else if (unformat (input, "analyse"))
8413 has_analyse_option = 1;
8417 M (IOAM_ENABLE, mp);
8418 mp->id = htons (id);
8419 mp->seqno = has_seqno_option;
8420 mp->analyse = has_analyse_option;
8421 mp->pot_enable = has_pot_option;
8422 mp->trace_enable = has_trace_option;
8431 api_ioam_disable (vat_main_t * vam)
8433 vl_api_ioam_disable_t *mp;
8436 M (IOAM_DISABLE, mp);
8443 api_sr_tunnel_add_del (vat_main_t * vam)
8445 unformat_input_t *i = vam->input;
8446 vl_api_sr_tunnel_add_del_t *mp;
8449 ip6_address_t src_address;
8450 int src_address_set = 0;
8451 ip6_address_t dst_address;
8453 int dst_address_set = 0;
8455 u32 rx_table_id = 0;
8456 u32 tx_table_id = 0;
8457 ip6_address_t *segments = 0;
8458 ip6_address_t *this_seg;
8459 ip6_address_t *tags = 0;
8460 ip6_address_t *this_tag;
8461 ip6_address_t next_address, tag;
8463 u8 *policy_name = 0;
8466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8468 if (unformat (i, "del"))
8470 else if (unformat (i, "name %s", &name))
8472 else if (unformat (i, "policy %s", &policy_name))
8474 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8476 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8478 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8479 src_address_set = 1;
8480 else if (unformat (i, "dst %U/%d",
8481 unformat_ip6_address, &dst_address, &dst_mask_width))
8482 dst_address_set = 1;
8483 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8485 vec_add2 (segments, this_seg, 1);
8486 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8487 sizeof (*this_seg));
8489 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8491 vec_add2 (tags, this_tag, 1);
8492 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8494 else if (unformat (i, "clean"))
8495 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8496 else if (unformat (i, "protected"))
8497 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8498 else if (unformat (i, "InPE %d", &pl_index))
8500 if (pl_index <= 0 || pl_index > 4)
8502 pl_index_range_error:
8503 errmsg ("pl index %d out of range", pl_index);
8507 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8509 else if (unformat (i, "EgPE %d", &pl_index))
8511 if (pl_index <= 0 || pl_index > 4)
8512 goto pl_index_range_error;
8514 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8516 else if (unformat (i, "OrgSrc %d", &pl_index))
8518 if (pl_index <= 0 || pl_index > 4)
8519 goto pl_index_range_error;
8521 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8527 if (!src_address_set)
8529 errmsg ("src address required");
8533 if (!dst_address_set)
8535 errmsg ("dst address required");
8541 errmsg ("at least one sr segment required");
8545 M2 (SR_TUNNEL_ADD_DEL, mp,
8546 vec_len (segments) * sizeof (ip6_address_t)
8547 + vec_len (tags) * sizeof (ip6_address_t));
8549 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8550 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8551 mp->dst_mask_width = dst_mask_width;
8552 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8553 mp->n_segments = vec_len (segments);
8554 mp->n_tags = vec_len (tags);
8555 mp->is_add = is_del == 0;
8556 clib_memcpy (mp->segs_and_tags, segments,
8557 vec_len (segments) * sizeof (ip6_address_t));
8558 clib_memcpy (mp->segs_and_tags +
8559 vec_len (segments) * sizeof (ip6_address_t), tags,
8560 vec_len (tags) * sizeof (ip6_address_t));
8562 mp->outer_vrf_id = ntohl (rx_table_id);
8563 mp->inner_vrf_id = ntohl (tx_table_id);
8564 memcpy (mp->name, name, vec_len (name));
8565 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8567 vec_free (segments);
8576 api_sr_policy_add_del (vat_main_t * vam)
8578 unformat_input_t *input = vam->input;
8579 vl_api_sr_policy_add_del_t *mp;
8582 u8 *tunnel_name = 0;
8583 u8 **tunnel_names = 0;
8588 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8589 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8592 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8594 if (unformat (input, "del"))
8596 else if (unformat (input, "name %s", &name))
8598 else if (unformat (input, "tunnel %s", &tunnel_name))
8602 vec_add1 (tunnel_names, tunnel_name);
8604 - length = #bytes to store in serial vector
8605 - +1 = byte to store that length
8607 tunnel_names_length += (vec_len (tunnel_name) + 1);
8618 errmsg ("policy name required");
8622 if ((!tunnel_set) && (!is_del))
8624 errmsg ("tunnel name required");
8628 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8632 mp->is_add = !is_del;
8634 memcpy (mp->name, name, vec_len (name));
8635 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8636 u8 *serial_orig = 0;
8637 vec_validate (serial_orig, tunnel_names_length);
8638 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8639 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8641 for (j = 0; j < vec_len (tunnel_names); j++)
8643 tun_name_len = vec_len (tunnel_names[j]);
8644 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8645 serial_orig += 1; // Move along one byte to store the actual tunnel name
8646 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8647 serial_orig += tun_name_len; // Advance past the copy
8649 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8651 vec_free (tunnel_names);
8652 vec_free (tunnel_name);
8660 api_sr_multicast_map_add_del (vat_main_t * vam)
8662 unformat_input_t *input = vam->input;
8663 vl_api_sr_multicast_map_add_del_t *mp;
8665 ip6_address_t multicast_address;
8666 u8 *policy_name = 0;
8667 int multicast_address_set = 0;
8670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8672 if (unformat (input, "del"))
8676 (input, "address %U", unformat_ip6_address, &multicast_address))
8677 multicast_address_set = 1;
8678 else if (unformat (input, "sr-policy %s", &policy_name))
8684 if (!is_del && !policy_name)
8686 errmsg ("sr-policy name required");
8691 if (!multicast_address_set)
8693 errmsg ("address required");
8697 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8699 mp->is_add = !is_del;
8700 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8701 clib_memcpy (mp->multicast_address, &multicast_address,
8702 sizeof (mp->multicast_address));
8705 vec_free (policy_name);
8713 #define foreach_tcp_proto_field \
8717 #define foreach_udp_proto_field \
8721 #define foreach_ip4_proto_field \
8732 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8734 u8 **maskp = va_arg (*args, u8 **);
8736 u8 found_something = 0;
8739 #define _(a) u8 a=0;
8740 foreach_tcp_proto_field;
8743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8746 #define _(a) else if (unformat (input, #a)) a=1;
8747 foreach_tcp_proto_field
8753 #define _(a) found_something += a;
8754 foreach_tcp_proto_field;
8757 if (found_something == 0)
8760 vec_validate (mask, sizeof (*tcp) - 1);
8762 tcp = (tcp_header_t *) mask;
8764 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8765 foreach_tcp_proto_field;
8773 unformat_udp_mask (unformat_input_t * input, va_list * args)
8775 u8 **maskp = va_arg (*args, u8 **);
8777 u8 found_something = 0;
8780 #define _(a) u8 a=0;
8781 foreach_udp_proto_field;
8784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8787 #define _(a) else if (unformat (input, #a)) a=1;
8788 foreach_udp_proto_field
8794 #define _(a) found_something += a;
8795 foreach_udp_proto_field;
8798 if (found_something == 0)
8801 vec_validate (mask, sizeof (*udp) - 1);
8803 udp = (udp_header_t *) mask;
8805 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8806 foreach_udp_proto_field;
8815 u16 src_port, dst_port;
8819 unformat_l4_mask (unformat_input_t * input, va_list * args)
8821 u8 **maskp = va_arg (*args, u8 **);
8822 u16 src_port = 0, dst_port = 0;
8823 tcpudp_header_t *tcpudp;
8825 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8827 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8829 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8831 else if (unformat (input, "src_port"))
8833 else if (unformat (input, "dst_port"))
8839 if (!src_port && !dst_port)
8843 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8845 tcpudp = (tcpudp_header_t *) mask;
8846 tcpudp->src_port = src_port;
8847 tcpudp->dst_port = dst_port;
8855 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8857 u8 **maskp = va_arg (*args, u8 **);
8859 u8 found_something = 0;
8862 #define _(a) u8 a=0;
8863 foreach_ip4_proto_field;
8869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8871 if (unformat (input, "version"))
8873 else if (unformat (input, "hdr_length"))
8875 else if (unformat (input, "src"))
8877 else if (unformat (input, "dst"))
8879 else if (unformat (input, "proto"))
8882 #define _(a) else if (unformat (input, #a)) a=1;
8883 foreach_ip4_proto_field
8889 #define _(a) found_something += a;
8890 foreach_ip4_proto_field;
8893 if (found_something == 0)
8896 vec_validate (mask, sizeof (*ip) - 1);
8898 ip = (ip4_header_t *) mask;
8900 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8901 foreach_ip4_proto_field;
8904 ip->ip_version_and_header_length = 0;
8907 ip->ip_version_and_header_length |= 0xF0;
8910 ip->ip_version_and_header_length |= 0x0F;
8916 #define foreach_ip6_proto_field \
8924 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8926 u8 **maskp = va_arg (*args, u8 **);
8928 u8 found_something = 0;
8930 u32 ip_version_traffic_class_and_flow_label;
8932 #define _(a) u8 a=0;
8933 foreach_ip6_proto_field;
8936 u8 traffic_class = 0;
8939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8941 if (unformat (input, "version"))
8943 else if (unformat (input, "traffic-class"))
8945 else if (unformat (input, "flow-label"))
8947 else if (unformat (input, "src"))
8949 else if (unformat (input, "dst"))
8951 else if (unformat (input, "proto"))
8954 #define _(a) else if (unformat (input, #a)) a=1;
8955 foreach_ip6_proto_field
8961 #define _(a) found_something += a;
8962 foreach_ip6_proto_field;
8965 if (found_something == 0)
8968 vec_validate (mask, sizeof (*ip) - 1);
8970 ip = (ip6_header_t *) mask;
8972 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8973 foreach_ip6_proto_field;
8976 ip_version_traffic_class_and_flow_label = 0;
8979 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8982 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8985 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8987 ip->ip_version_traffic_class_and_flow_label =
8988 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8995 unformat_l3_mask (unformat_input_t * input, va_list * args)
8997 u8 **maskp = va_arg (*args, u8 **);
8999 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9001 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9003 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9012 unformat_l2_mask (unformat_input_t * input, va_list * args)
9014 u8 **maskp = va_arg (*args, u8 **);
9029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9031 if (unformat (input, "src"))
9033 else if (unformat (input, "dst"))
9035 else if (unformat (input, "proto"))
9037 else if (unformat (input, "tag1"))
9039 else if (unformat (input, "tag2"))
9041 else if (unformat (input, "ignore-tag1"))
9043 else if (unformat (input, "ignore-tag2"))
9045 else if (unformat (input, "cos1"))
9047 else if (unformat (input, "cos2"))
9049 else if (unformat (input, "dot1q"))
9051 else if (unformat (input, "dot1ad"))
9056 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9057 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9060 if (tag1 || ignore_tag1 || cos1 || dot1q)
9062 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9065 vec_validate (mask, len - 1);
9068 memset (mask, 0xff, 6);
9071 memset (mask + 6, 0xff, 6);
9075 /* inner vlan tag */
9084 mask[21] = mask[20] = 0xff;
9105 mask[16] = mask[17] = 0xff;
9115 mask[12] = mask[13] = 0xff;
9122 unformat_classify_mask (unformat_input_t * input, va_list * args)
9124 u8 **maskp = va_arg (*args, u8 **);
9125 u32 *skipp = va_arg (*args, u32 *);
9126 u32 *matchp = va_arg (*args, u32 *);
9134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9136 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9138 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9140 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9142 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9156 if (mask || l2 || l3 || l4)
9160 /* "With a free Ethernet header in every package" */
9162 vec_validate (l2, 13);
9166 vec_append (mask, l3);
9171 vec_append (mask, l4);
9176 /* Scan forward looking for the first significant mask octet */
9177 for (i = 0; i < vec_len (mask); i++)
9181 /* compute (skip, match) params */
9182 *skipp = i / sizeof (u32x4);
9183 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9185 /* Pad mask to an even multiple of the vector size */
9186 while (vec_len (mask) % sizeof (u32x4))
9189 match = vec_len (mask) / sizeof (u32x4);
9191 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9193 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9194 if (*tmp || *(tmp + 1))
9199 clib_warning ("BUG: match 0");
9201 _vec_len (mask) = match * sizeof (u32x4);
9212 #define foreach_l2_next \
9214 _(ethernet, ETHERNET_INPUT) \
9219 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9221 u32 *miss_next_indexp = va_arg (*args, u32 *);
9226 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9230 if (unformat (input, "%d", &tmp))
9239 *miss_next_indexp = next_index;
9243 #define foreach_ip_next \
9249 unformat_ip_next_index (unformat_input_t * input, va_list * args)
9251 u32 *miss_next_indexp = va_arg (*args, u32 *);
9256 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9260 if (unformat (input, "%d", &tmp))
9269 *miss_next_indexp = next_index;
9273 #define foreach_acl_next \
9277 unformat_acl_next_index (unformat_input_t * input, va_list * args)
9279 u32 *miss_next_indexp = va_arg (*args, u32 *);
9284 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9288 if (unformat (input, "permit"))
9293 else if (unformat (input, "%d", &tmp))
9302 *miss_next_indexp = next_index;
9307 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9309 u32 *r = va_arg (*args, u32 *);
9311 if (unformat (input, "conform-color"))
9312 *r = POLICE_CONFORM;
9313 else if (unformat (input, "exceed-color"))
9322 api_classify_add_del_table (vat_main_t * vam)
9324 unformat_input_t *i = vam->input;
9325 vl_api_classify_add_del_table_t *mp;
9332 u32 table_index = ~0;
9333 u32 next_table_index = ~0;
9334 u32 miss_next_index = ~0;
9335 u32 memory_size = 32 << 20;
9337 u32 current_data_flag = 0;
9338 int current_data_offset = 0;
9341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9343 if (unformat (i, "del"))
9345 else if (unformat (i, "del-chain"))
9350 else if (unformat (i, "buckets %d", &nbuckets))
9352 else if (unformat (i, "memory_size %d", &memory_size))
9354 else if (unformat (i, "skip %d", &skip))
9356 else if (unformat (i, "match %d", &match))
9358 else if (unformat (i, "table %d", &table_index))
9360 else if (unformat (i, "mask %U", unformat_classify_mask,
9361 &mask, &skip, &match))
9363 else if (unformat (i, "next-table %d", &next_table_index))
9365 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
9368 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9371 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9374 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9376 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9382 if (is_add && mask == 0)
9384 errmsg ("Mask required");
9388 if (is_add && skip == ~0)
9390 errmsg ("skip count required");
9394 if (is_add && match == ~0)
9396 errmsg ("match count required");
9400 if (!is_add && table_index == ~0)
9402 errmsg ("table index required for delete");
9406 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9408 mp->is_add = is_add;
9409 mp->del_chain = del_chain;
9410 mp->table_index = ntohl (table_index);
9411 mp->nbuckets = ntohl (nbuckets);
9412 mp->memory_size = ntohl (memory_size);
9413 mp->skip_n_vectors = ntohl (skip);
9414 mp->match_n_vectors = ntohl (match);
9415 mp->next_table_index = ntohl (next_table_index);
9416 mp->miss_next_index = ntohl (miss_next_index);
9417 mp->current_data_flag = ntohl (current_data_flag);
9418 mp->current_data_offset = ntohl (current_data_offset);
9419 clib_memcpy (mp->mask, mask, vec_len (mask));
9429 unformat_l4_match (unformat_input_t * input, va_list * args)
9431 u8 **matchp = va_arg (*args, u8 **);
9433 u8 *proto_header = 0;
9439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (input, "src_port %d", &src_port))
9443 else if (unformat (input, "dst_port %d", &dst_port))
9449 h.src_port = clib_host_to_net_u16 (src_port);
9450 h.dst_port = clib_host_to_net_u16 (dst_port);
9451 vec_validate (proto_header, sizeof (h) - 1);
9452 memcpy (proto_header, &h, sizeof (h));
9454 *matchp = proto_header;
9460 unformat_ip4_match (unformat_input_t * input, va_list * args)
9462 u8 **matchp = va_arg (*args, u8 **);
9469 int src = 0, dst = 0;
9470 ip4_address_t src_val, dst_val;
9477 int fragment_id = 0;
9478 u32 fragment_id_val;
9484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9486 if (unformat (input, "version %d", &version_val))
9488 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9490 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9492 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9494 else if (unformat (input, "proto %d", &proto_val))
9496 else if (unformat (input, "tos %d", &tos_val))
9498 else if (unformat (input, "length %d", &length_val))
9500 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9502 else if (unformat (input, "ttl %d", &ttl_val))
9504 else if (unformat (input, "checksum %d", &checksum_val))
9510 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9511 + ttl + checksum == 0)
9515 * Aligned because we use the real comparison functions
9517 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9519 ip = (ip4_header_t *) match;
9521 /* These are realistically matched in practice */
9523 ip->src_address.as_u32 = src_val.as_u32;
9526 ip->dst_address.as_u32 = dst_val.as_u32;
9529 ip->protocol = proto_val;
9532 /* These are not, but they're included for completeness */
9534 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9537 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9543 ip->length = clib_host_to_net_u16 (length_val);
9549 ip->checksum = clib_host_to_net_u16 (checksum_val);
9556 unformat_ip6_match (unformat_input_t * input, va_list * args)
9558 u8 **matchp = va_arg (*args, u8 **);
9563 u8 traffic_class = 0;
9564 u32 traffic_class_val = 0;
9567 int src = 0, dst = 0;
9568 ip6_address_t src_val, dst_val;
9571 int payload_length = 0;
9572 u32 payload_length_val;
9575 u32 ip_version_traffic_class_and_flow_label;
9577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9579 if (unformat (input, "version %d", &version_val))
9581 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9583 else if (unformat (input, "flow_label %d", &flow_label_val))
9585 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9587 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9589 else if (unformat (input, "proto %d", &proto_val))
9591 else if (unformat (input, "payload_length %d", &payload_length_val))
9593 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9599 if (version + traffic_class + flow_label + src + dst + proto +
9600 payload_length + hop_limit == 0)
9604 * Aligned because we use the real comparison functions
9606 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9608 ip = (ip6_header_t *) match;
9611 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9614 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9617 ip->protocol = proto_val;
9619 ip_version_traffic_class_and_flow_label = 0;
9622 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9625 ip_version_traffic_class_and_flow_label |=
9626 (traffic_class_val & 0xFF) << 20;
9629 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9631 ip->ip_version_traffic_class_and_flow_label =
9632 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9635 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9638 ip->hop_limit = hop_limit_val;
9645 unformat_l3_match (unformat_input_t * input, va_list * args)
9647 u8 **matchp = va_arg (*args, u8 **);
9649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9651 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9653 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9662 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9664 u8 *tagp = va_arg (*args, u8 *);
9667 if (unformat (input, "%d", &tag))
9669 tagp[0] = (tag >> 8) & 0x0F;
9670 tagp[1] = tag & 0xFF;
9678 unformat_l2_match (unformat_input_t * input, va_list * args)
9680 u8 **matchp = va_arg (*args, u8 **);
9700 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9702 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9705 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9707 else if (unformat (input, "proto %U",
9708 unformat_ethernet_type_host_byte_order, &proto_val))
9710 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9712 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9714 else if (unformat (input, "ignore-tag1"))
9716 else if (unformat (input, "ignore-tag2"))
9718 else if (unformat (input, "cos1 %d", &cos1_val))
9720 else if (unformat (input, "cos2 %d", &cos2_val))
9725 if ((src + dst + proto + tag1 + tag2 +
9726 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9729 if (tag1 || ignore_tag1 || cos1)
9731 if (tag2 || ignore_tag2 || cos2)
9734 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9737 clib_memcpy (match, dst_val, 6);
9740 clib_memcpy (match + 6, src_val, 6);
9744 /* inner vlan tag */
9745 match[19] = tag2_val[1];
9746 match[18] = tag2_val[0];
9748 match[18] |= (cos2_val & 0x7) << 5;
9751 match[21] = proto_val & 0xff;
9752 match[20] = proto_val >> 8;
9756 match[15] = tag1_val[1];
9757 match[14] = tag1_val[0];
9760 match[14] |= (cos1_val & 0x7) << 5;
9766 match[15] = tag1_val[1];
9767 match[14] = tag1_val[0];
9770 match[17] = proto_val & 0xff;
9771 match[16] = proto_val >> 8;
9774 match[14] |= (cos1_val & 0x7) << 5;
9780 match[18] |= (cos2_val & 0x7) << 5;
9782 match[14] |= (cos1_val & 0x7) << 5;
9785 match[13] = proto_val & 0xff;
9786 match[12] = proto_val >> 8;
9795 unformat_classify_match (unformat_input_t * input, va_list * args)
9797 u8 **matchp = va_arg (*args, u8 **);
9798 u32 skip_n_vectors = va_arg (*args, u32);
9799 u32 match_n_vectors = va_arg (*args, u32);
9806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9808 if (unformat (input, "hex %U", unformat_hex_string, &match))
9810 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9812 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9814 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9828 if (match || l2 || l3 || l4)
9832 /* "Win a free Ethernet header in every packet" */
9834 vec_validate_aligned (l2, 13, sizeof (u32x4));
9838 vec_append_aligned (match, l3, sizeof (u32x4));
9843 vec_append_aligned (match, l4, sizeof (u32x4));
9848 /* Make sure the vector is big enough even if key is all 0's */
9849 vec_validate_aligned
9850 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9853 /* Set size, include skipped vectors */
9854 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9865 api_classify_add_del_session (vat_main_t * vam)
9867 unformat_input_t *i = vam->input;
9868 vl_api_classify_add_del_session_t *mp;
9870 u32 table_index = ~0;
9871 u32 hit_next_index = ~0;
9872 u32 opaque_index = ~0;
9875 u32 skip_n_vectors = 0;
9876 u32 match_n_vectors = 0;
9882 * Warning: you have to supply skip_n and match_n
9883 * because the API client cant simply look at the classify
9887 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9889 if (unformat (i, "del"))
9891 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9894 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9897 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9900 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9902 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9904 else if (unformat (i, "opaque-index %d", &opaque_index))
9906 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9908 else if (unformat (i, "match_n %d", &match_n_vectors))
9910 else if (unformat (i, "match %U", unformat_classify_match,
9911 &match, skip_n_vectors, match_n_vectors))
9913 else if (unformat (i, "advance %d", &advance))
9915 else if (unformat (i, "table-index %d", &table_index))
9917 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9919 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9921 else if (unformat (i, "action %d", &action))
9923 else if (unformat (i, "metadata %d", &metadata))
9929 if (table_index == ~0)
9931 errmsg ("Table index required");
9935 if (is_add && match == 0)
9937 errmsg ("Match value required");
9941 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9943 mp->is_add = is_add;
9944 mp->table_index = ntohl (table_index);
9945 mp->hit_next_index = ntohl (hit_next_index);
9946 mp->opaque_index = ntohl (opaque_index);
9947 mp->advance = ntohl (advance);
9948 mp->action = action;
9949 mp->metadata = ntohl (metadata);
9950 clib_memcpy (mp->match, match, vec_len (match));
9959 api_classify_set_interface_ip_table (vat_main_t * vam)
9961 unformat_input_t *i = vam->input;
9962 vl_api_classify_set_interface_ip_table_t *mp;
9964 int sw_if_index_set;
9965 u32 table_index = ~0;
9969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9971 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9972 sw_if_index_set = 1;
9973 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9974 sw_if_index_set = 1;
9975 else if (unformat (i, "table %d", &table_index))
9979 clib_warning ("parse error '%U'", format_unformat_error, i);
9984 if (sw_if_index_set == 0)
9986 errmsg ("missing interface name or sw_if_index");
9991 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9993 mp->sw_if_index = ntohl (sw_if_index);
9994 mp->table_index = ntohl (table_index);
9995 mp->is_ipv6 = is_ipv6;
10003 api_classify_set_interface_l2_tables (vat_main_t * vam)
10005 unformat_input_t *i = vam->input;
10006 vl_api_classify_set_interface_l2_tables_t *mp;
10008 int sw_if_index_set;
10009 u32 ip4_table_index = ~0;
10010 u32 ip6_table_index = ~0;
10011 u32 other_table_index = ~0;
10015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10018 sw_if_index_set = 1;
10019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10020 sw_if_index_set = 1;
10021 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10023 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10025 else if (unformat (i, "other-table %d", &other_table_index))
10027 else if (unformat (i, "is-input %d", &is_input))
10031 clib_warning ("parse error '%U'", format_unformat_error, i);
10036 if (sw_if_index_set == 0)
10038 errmsg ("missing interface name or sw_if_index");
10043 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10045 mp->sw_if_index = ntohl (sw_if_index);
10046 mp->ip4_table_index = ntohl (ip4_table_index);
10047 mp->ip6_table_index = ntohl (ip6_table_index);
10048 mp->other_table_index = ntohl (other_table_index);
10049 mp->is_input = (u8) is_input;
10057 api_set_ipfix_exporter (vat_main_t * vam)
10059 unformat_input_t *i = vam->input;
10060 vl_api_set_ipfix_exporter_t *mp;
10061 ip4_address_t collector_address;
10062 u8 collector_address_set = 0;
10063 u32 collector_port = ~0;
10064 ip4_address_t src_address;
10065 u8 src_address_set = 0;
10068 u32 template_interval = ~0;
10069 u8 udp_checksum = 0;
10072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10074 if (unformat (i, "collector_address %U", unformat_ip4_address,
10075 &collector_address))
10076 collector_address_set = 1;
10077 else if (unformat (i, "collector_port %d", &collector_port))
10079 else if (unformat (i, "src_address %U", unformat_ip4_address,
10081 src_address_set = 1;
10082 else if (unformat (i, "vrf_id %d", &vrf_id))
10084 else if (unformat (i, "path_mtu %d", &path_mtu))
10086 else if (unformat (i, "template_interval %d", &template_interval))
10088 else if (unformat (i, "udp_checksum"))
10094 if (collector_address_set == 0)
10096 errmsg ("collector_address required");
10100 if (src_address_set == 0)
10102 errmsg ("src_address required");
10106 M (SET_IPFIX_EXPORTER, mp);
10108 memcpy (mp->collector_address, collector_address.data,
10109 sizeof (collector_address.data));
10110 mp->collector_port = htons ((u16) collector_port);
10111 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10112 mp->vrf_id = htonl (vrf_id);
10113 mp->path_mtu = htonl (path_mtu);
10114 mp->template_interval = htonl (template_interval);
10115 mp->udp_checksum = udp_checksum;
10123 api_set_ipfix_classify_stream (vat_main_t * vam)
10125 unformat_input_t *i = vam->input;
10126 vl_api_set_ipfix_classify_stream_t *mp;
10128 u32 src_port = UDP_DST_PORT_ipfix;
10131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10133 if (unformat (i, "domain %d", &domain_id))
10135 else if (unformat (i, "src_port %d", &src_port))
10139 errmsg ("unknown input `%U'", format_unformat_error, i);
10144 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10146 mp->domain_id = htonl (domain_id);
10147 mp->src_port = htons ((u16) src_port);
10155 api_ipfix_classify_table_add_del (vat_main_t * vam)
10157 unformat_input_t *i = vam->input;
10158 vl_api_ipfix_classify_table_add_del_t *mp;
10160 u32 classify_table_index = ~0;
10162 u8 transport_protocol = 255;
10165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10167 if (unformat (i, "add"))
10169 else if (unformat (i, "del"))
10171 else if (unformat (i, "table %d", &classify_table_index))
10173 else if (unformat (i, "ip4"))
10175 else if (unformat (i, "ip6"))
10177 else if (unformat (i, "tcp"))
10178 transport_protocol = 6;
10179 else if (unformat (i, "udp"))
10180 transport_protocol = 17;
10183 errmsg ("unknown input `%U'", format_unformat_error, i);
10190 errmsg ("expecting: add|del");
10193 if (classify_table_index == ~0)
10195 errmsg ("classifier table not specified");
10198 if (ip_version == 0)
10200 errmsg ("IP version not specified");
10204 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10206 mp->is_add = is_add;
10207 mp->table_id = htonl (classify_table_index);
10208 mp->ip_version = ip_version;
10209 mp->transport_protocol = transport_protocol;
10217 api_get_node_index (vat_main_t * vam)
10219 unformat_input_t *i = vam->input;
10220 vl_api_get_node_index_t *mp;
10224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10226 if (unformat (i, "node %s", &name))
10233 errmsg ("node name required");
10236 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10238 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10242 M (GET_NODE_INDEX, mp);
10243 clib_memcpy (mp->node_name, name, vec_len (name));
10252 api_get_next_index (vat_main_t * vam)
10254 unformat_input_t *i = vam->input;
10255 vl_api_get_next_index_t *mp;
10256 u8 *node_name = 0, *next_node_name = 0;
10259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10261 if (unformat (i, "node-name %s", &node_name))
10263 else if (unformat (i, "next-node-name %s", &next_node_name))
10267 if (node_name == 0)
10269 errmsg ("node name required");
10272 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10274 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10278 if (next_node_name == 0)
10280 errmsg ("next node name required");
10283 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10285 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10289 M (GET_NEXT_INDEX, mp);
10290 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10291 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10292 vec_free (node_name);
10293 vec_free (next_node_name);
10301 api_add_node_next (vat_main_t * vam)
10303 unformat_input_t *i = vam->input;
10304 vl_api_add_node_next_t *mp;
10309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10311 if (unformat (i, "node %s", &name))
10313 else if (unformat (i, "next %s", &next))
10320 errmsg ("node name required");
10323 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10325 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10330 errmsg ("next node required");
10333 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10335 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10339 M (ADD_NODE_NEXT, mp);
10340 clib_memcpy (mp->node_name, name, vec_len (name));
10341 clib_memcpy (mp->next_name, next, vec_len (next));
10351 api_l2tpv3_create_tunnel (vat_main_t * vam)
10353 unformat_input_t *i = vam->input;
10354 ip6_address_t client_address, our_address;
10355 int client_address_set = 0;
10356 int our_address_set = 0;
10357 u32 local_session_id = 0;
10358 u32 remote_session_id = 0;
10359 u64 local_cookie = 0;
10360 u64 remote_cookie = 0;
10361 u8 l2_sublayer_present = 0;
10362 vl_api_l2tpv3_create_tunnel_t *mp;
10365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10367 if (unformat (i, "client_address %U", unformat_ip6_address,
10369 client_address_set = 1;
10370 else if (unformat (i, "our_address %U", unformat_ip6_address,
10372 our_address_set = 1;
10373 else if (unformat (i, "local_session_id %d", &local_session_id))
10375 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10377 else if (unformat (i, "local_cookie %lld", &local_cookie))
10379 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10381 else if (unformat (i, "l2-sublayer-present"))
10382 l2_sublayer_present = 1;
10387 if (client_address_set == 0)
10389 errmsg ("client_address required");
10393 if (our_address_set == 0)
10395 errmsg ("our_address required");
10399 M (L2TPV3_CREATE_TUNNEL, mp);
10401 clib_memcpy (mp->client_address, client_address.as_u8,
10402 sizeof (mp->client_address));
10404 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10406 mp->local_session_id = ntohl (local_session_id);
10407 mp->remote_session_id = ntohl (remote_session_id);
10408 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10409 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10410 mp->l2_sublayer_present = l2_sublayer_present;
10419 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10421 unformat_input_t *i = vam->input;
10423 u8 sw_if_index_set = 0;
10424 u64 new_local_cookie = 0;
10425 u64 new_remote_cookie = 0;
10426 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10431 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10432 sw_if_index_set = 1;
10433 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10434 sw_if_index_set = 1;
10435 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10437 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10443 if (sw_if_index_set == 0)
10445 errmsg ("missing interface name or sw_if_index");
10449 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10451 mp->sw_if_index = ntohl (sw_if_index);
10452 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10453 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10461 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10463 unformat_input_t *i = vam->input;
10464 vl_api_l2tpv3_interface_enable_disable_t *mp;
10466 u8 sw_if_index_set = 0;
10467 u8 enable_disable = 1;
10470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10472 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10473 sw_if_index_set = 1;
10474 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10475 sw_if_index_set = 1;
10476 else if (unformat (i, "enable"))
10477 enable_disable = 1;
10478 else if (unformat (i, "disable"))
10479 enable_disable = 0;
10484 if (sw_if_index_set == 0)
10486 errmsg ("missing interface name or sw_if_index");
10490 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10492 mp->sw_if_index = ntohl (sw_if_index);
10493 mp->enable_disable = enable_disable;
10501 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10503 unformat_input_t *i = vam->input;
10504 vl_api_l2tpv3_set_lookup_key_t *mp;
10508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10510 if (unformat (i, "lookup_v6_src"))
10511 key = L2T_LOOKUP_SRC_ADDRESS;
10512 else if (unformat (i, "lookup_v6_dst"))
10513 key = L2T_LOOKUP_DST_ADDRESS;
10514 else if (unformat (i, "lookup_session_id"))
10515 key = L2T_LOOKUP_SESSION_ID;
10520 if (key == (u8) ~ 0)
10522 errmsg ("l2tp session lookup key unset");
10526 M (L2TPV3_SET_LOOKUP_KEY, mp);
10535 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10536 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10538 vat_main_t *vam = &vat_main;
10540 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10541 format_ip6_address, mp->our_address,
10542 format_ip6_address, mp->client_address,
10543 clib_net_to_host_u32 (mp->sw_if_index));
10546 " local cookies %016llx %016llx remote cookie %016llx",
10547 clib_net_to_host_u64 (mp->local_cookie[0]),
10548 clib_net_to_host_u64 (mp->local_cookie[1]),
10549 clib_net_to_host_u64 (mp->remote_cookie));
10551 print (vam->ofp, " local session-id %d remote session-id %d",
10552 clib_net_to_host_u32 (mp->local_session_id),
10553 clib_net_to_host_u32 (mp->remote_session_id));
10555 print (vam->ofp, " l2 specific sublayer %s\n",
10556 mp->l2_sublayer_present ? "preset" : "absent");
10560 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10561 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10563 vat_main_t *vam = &vat_main;
10564 vat_json_node_t *node = NULL;
10565 struct in6_addr addr;
10567 if (VAT_JSON_ARRAY != vam->json_tree.type)
10569 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10570 vat_json_init_array (&vam->json_tree);
10572 node = vat_json_array_add (&vam->json_tree);
10574 vat_json_init_object (node);
10576 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10577 vat_json_object_add_ip6 (node, "our_address", addr);
10578 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10579 vat_json_object_add_ip6 (node, "client_address", addr);
10581 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10582 vat_json_init_array (lc);
10583 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10584 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10585 vat_json_object_add_uint (node, "remote_cookie",
10586 clib_net_to_host_u64 (mp->remote_cookie));
10588 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10589 vat_json_object_add_uint (node, "local_session_id",
10590 clib_net_to_host_u32 (mp->local_session_id));
10591 vat_json_object_add_uint (node, "remote_session_id",
10592 clib_net_to_host_u32 (mp->remote_session_id));
10593 vat_json_object_add_string_copy (node, "l2_sublayer",
10594 mp->l2_sublayer_present ? (u8 *) "present"
10595 : (u8 *) "absent");
10599 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10601 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10602 vl_api_control_ping_t *mp_ping;
10605 /* Get list of l2tpv3-tunnel interfaces */
10606 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10609 /* Use a control ping for synchronization */
10610 M (CONTROL_PING, mp_ping);
10618 static void vl_api_sw_interface_tap_details_t_handler
10619 (vl_api_sw_interface_tap_details_t * mp)
10621 vat_main_t *vam = &vat_main;
10623 print (vam->ofp, "%-16s %d",
10624 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10627 static void vl_api_sw_interface_tap_details_t_handler_json
10628 (vl_api_sw_interface_tap_details_t * mp)
10630 vat_main_t *vam = &vat_main;
10631 vat_json_node_t *node = NULL;
10633 if (VAT_JSON_ARRAY != vam->json_tree.type)
10635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10636 vat_json_init_array (&vam->json_tree);
10638 node = vat_json_array_add (&vam->json_tree);
10640 vat_json_init_object (node);
10641 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10642 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10646 api_sw_interface_tap_dump (vat_main_t * vam)
10648 vl_api_sw_interface_tap_dump_t *mp;
10649 vl_api_control_ping_t *mp_ping;
10652 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10653 /* Get list of tap interfaces */
10654 M (SW_INTERFACE_TAP_DUMP, mp);
10657 /* Use a control ping for synchronization */
10658 M (CONTROL_PING, mp_ping);
10665 static uword unformat_vxlan_decap_next
10666 (unformat_input_t * input, va_list * args)
10668 u32 *result = va_arg (*args, u32 *);
10671 if (unformat (input, "l2"))
10672 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10673 else if (unformat (input, "%d", &tmp))
10681 api_vxlan_add_del_tunnel (vat_main_t * vam)
10683 unformat_input_t *line_input = vam->input;
10684 vl_api_vxlan_add_del_tunnel_t *mp;
10685 ip46_address_t src, dst;
10687 u8 ipv4_set = 0, ipv6_set = 0;
10691 u32 mcast_sw_if_index = ~0;
10692 u32 encap_vrf_id = 0;
10693 u32 decap_next_index = ~0;
10697 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10698 memset (&src, 0, sizeof src);
10699 memset (&dst, 0, sizeof dst);
10701 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10703 if (unformat (line_input, "del"))
10706 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10712 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10718 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10724 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10729 else if (unformat (line_input, "group %U %U",
10730 unformat_ip4_address, &dst.ip4,
10731 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10733 grp_set = dst_set = 1;
10736 else if (unformat (line_input, "group %U",
10737 unformat_ip4_address, &dst.ip4))
10739 grp_set = dst_set = 1;
10742 else if (unformat (line_input, "group %U %U",
10743 unformat_ip6_address, &dst.ip6,
10744 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10746 grp_set = dst_set = 1;
10749 else if (unformat (line_input, "group %U",
10750 unformat_ip6_address, &dst.ip6))
10752 grp_set = dst_set = 1;
10756 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10758 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10760 else if (unformat (line_input, "decap-next %U",
10761 unformat_vxlan_decap_next, &decap_next_index))
10763 else if (unformat (line_input, "vni %d", &vni))
10767 errmsg ("parse error '%U'", format_unformat_error, line_input);
10774 errmsg ("tunnel src address not specified");
10779 errmsg ("tunnel dst address not specified");
10783 if (grp_set && !ip46_address_is_multicast (&dst))
10785 errmsg ("tunnel group address not multicast");
10788 if (grp_set && mcast_sw_if_index == ~0)
10790 errmsg ("tunnel nonexistent multicast device");
10793 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10795 errmsg ("tunnel dst address must be unicast");
10800 if (ipv4_set && ipv6_set)
10802 errmsg ("both IPv4 and IPv6 addresses specified");
10806 if ((vni == 0) || (vni >> 24))
10808 errmsg ("vni not specified or out of range");
10812 M (VXLAN_ADD_DEL_TUNNEL, mp);
10816 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10817 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10821 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10822 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10824 mp->encap_vrf_id = ntohl (encap_vrf_id);
10825 mp->decap_next_index = ntohl (decap_next_index);
10826 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10827 mp->vni = ntohl (vni);
10828 mp->is_add = is_add;
10829 mp->is_ipv6 = ipv6_set;
10836 static void vl_api_vxlan_tunnel_details_t_handler
10837 (vl_api_vxlan_tunnel_details_t * mp)
10839 vat_main_t *vam = &vat_main;
10840 ip46_address_t src, dst;
10842 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10843 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10845 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10846 ntohl (mp->sw_if_index),
10847 format_ip46_address, &src, IP46_TYPE_ANY,
10848 format_ip46_address, &dst, IP46_TYPE_ANY,
10849 ntohl (mp->encap_vrf_id),
10850 ntohl (mp->decap_next_index), ntohl (mp->vni),
10851 ntohl (mp->mcast_sw_if_index));
10854 static void vl_api_vxlan_tunnel_details_t_handler_json
10855 (vl_api_vxlan_tunnel_details_t * mp)
10857 vat_main_t *vam = &vat_main;
10858 vat_json_node_t *node = NULL;
10860 if (VAT_JSON_ARRAY != vam->json_tree.type)
10862 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10863 vat_json_init_array (&vam->json_tree);
10865 node = vat_json_array_add (&vam->json_tree);
10867 vat_json_init_object (node);
10868 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10871 struct in6_addr ip6;
10873 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10874 vat_json_object_add_ip6 (node, "src_address", ip6);
10875 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10876 vat_json_object_add_ip6 (node, "dst_address", ip6);
10880 struct in_addr ip4;
10882 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10883 vat_json_object_add_ip4 (node, "src_address", ip4);
10884 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10885 vat_json_object_add_ip4 (node, "dst_address", ip4);
10887 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10888 vat_json_object_add_uint (node, "decap_next_index",
10889 ntohl (mp->decap_next_index));
10890 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10891 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10892 vat_json_object_add_uint (node, "mcast_sw_if_index",
10893 ntohl (mp->mcast_sw_if_index));
10897 api_vxlan_tunnel_dump (vat_main_t * vam)
10899 unformat_input_t *i = vam->input;
10900 vl_api_vxlan_tunnel_dump_t *mp;
10901 vl_api_control_ping_t *mp_ping;
10903 u8 sw_if_index_set = 0;
10906 /* Parse args required to build the message */
10907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10909 if (unformat (i, "sw_if_index %d", &sw_if_index))
10910 sw_if_index_set = 1;
10915 if (sw_if_index_set == 0)
10920 if (!vam->json_output)
10922 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10923 "sw_if_index", "src_address", "dst_address",
10924 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10927 /* Get list of vxlan-tunnel interfaces */
10928 M (VXLAN_TUNNEL_DUMP, mp);
10930 mp->sw_if_index = htonl (sw_if_index);
10934 /* Use a control ping for synchronization */
10935 M (CONTROL_PING, mp_ping);
10943 api_gre_add_del_tunnel (vat_main_t * vam)
10945 unformat_input_t *line_input = vam->input;
10946 vl_api_gre_add_del_tunnel_t *mp;
10947 ip4_address_t src4, dst4;
10952 u32 outer_fib_id = 0;
10955 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10957 if (unformat (line_input, "del"))
10959 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10961 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10963 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10965 else if (unformat (line_input, "teb"))
10969 errmsg ("parse error '%U'", format_unformat_error, line_input);
10976 errmsg ("tunnel src address not specified");
10981 errmsg ("tunnel dst address not specified");
10986 M (GRE_ADD_DEL_TUNNEL, mp);
10988 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10989 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10990 mp->outer_fib_id = ntohl (outer_fib_id);
10991 mp->is_add = is_add;
10999 static void vl_api_gre_tunnel_details_t_handler
11000 (vl_api_gre_tunnel_details_t * mp)
11002 vat_main_t *vam = &vat_main;
11004 print (vam->ofp, "%11d%15U%15U%6d%14d",
11005 ntohl (mp->sw_if_index),
11006 format_ip4_address, &mp->src_address,
11007 format_ip4_address, &mp->dst_address,
11008 mp->teb, ntohl (mp->outer_fib_id));
11011 static void vl_api_gre_tunnel_details_t_handler_json
11012 (vl_api_gre_tunnel_details_t * mp)
11014 vat_main_t *vam = &vat_main;
11015 vat_json_node_t *node = NULL;
11016 struct in_addr ip4;
11018 if (VAT_JSON_ARRAY != vam->json_tree.type)
11020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11021 vat_json_init_array (&vam->json_tree);
11023 node = vat_json_array_add (&vam->json_tree);
11025 vat_json_init_object (node);
11026 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11027 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11028 vat_json_object_add_ip4 (node, "src_address", ip4);
11029 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11030 vat_json_object_add_ip4 (node, "dst_address", ip4);
11031 vat_json_object_add_uint (node, "teb", mp->teb);
11032 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11036 api_gre_tunnel_dump (vat_main_t * vam)
11038 unformat_input_t *i = vam->input;
11039 vl_api_gre_tunnel_dump_t *mp;
11040 vl_api_control_ping_t *mp_ping;
11042 u8 sw_if_index_set = 0;
11045 /* Parse args required to build the message */
11046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11048 if (unformat (i, "sw_if_index %d", &sw_if_index))
11049 sw_if_index_set = 1;
11054 if (sw_if_index_set == 0)
11059 if (!vam->json_output)
11061 print (vam->ofp, "%11s%15s%15s%6s%14s",
11062 "sw_if_index", "src_address", "dst_address", "teb",
11066 /* Get list of gre-tunnel interfaces */
11067 M (GRE_TUNNEL_DUMP, mp);
11069 mp->sw_if_index = htonl (sw_if_index);
11073 /* Use a control ping for synchronization */
11074 M (CONTROL_PING, mp_ping);
11082 api_l2_fib_clear_table (vat_main_t * vam)
11084 // unformat_input_t * i = vam->input;
11085 vl_api_l2_fib_clear_table_t *mp;
11088 M (L2_FIB_CLEAR_TABLE, mp);
11096 api_l2_interface_efp_filter (vat_main_t * vam)
11098 unformat_input_t *i = vam->input;
11099 vl_api_l2_interface_efp_filter_t *mp;
11102 u8 sw_if_index_set = 0;
11105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11108 sw_if_index_set = 1;
11109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11110 sw_if_index_set = 1;
11111 else if (unformat (i, "enable"))
11113 else if (unformat (i, "disable"))
11117 clib_warning ("parse error '%U'", format_unformat_error, i);
11122 if (sw_if_index_set == 0)
11124 errmsg ("missing sw_if_index");
11128 M (L2_INTERFACE_EFP_FILTER, mp);
11130 mp->sw_if_index = ntohl (sw_if_index);
11131 mp->enable_disable = enable;
11138 #define foreach_vtr_op \
11139 _("disable", L2_VTR_DISABLED) \
11140 _("push-1", L2_VTR_PUSH_1) \
11141 _("push-2", L2_VTR_PUSH_2) \
11142 _("pop-1", L2_VTR_POP_1) \
11143 _("pop-2", L2_VTR_POP_2) \
11144 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11145 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11146 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11147 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11150 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11152 unformat_input_t *i = vam->input;
11153 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11155 u8 sw_if_index_set = 0;
11158 u32 push_dot1q = 1;
11163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11166 sw_if_index_set = 1;
11167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11168 sw_if_index_set = 1;
11169 else if (unformat (i, "vtr_op %d", &vtr_op))
11171 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11174 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11176 else if (unformat (i, "tag1 %d", &tag1))
11178 else if (unformat (i, "tag2 %d", &tag2))
11182 clib_warning ("parse error '%U'", format_unformat_error, i);
11187 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11189 errmsg ("missing vtr operation or sw_if_index");
11193 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11194 mp->sw_if_index = ntohl (sw_if_index);
11195 mp->vtr_op = ntohl (vtr_op);
11196 mp->push_dot1q = ntohl (push_dot1q);
11197 mp->tag1 = ntohl (tag1);
11198 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;
11212 u8 file_name_set = 0;
11213 u32 custom_dev_instance = ~0;
11215 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);
11275 api_modify_vhost_user_if (vat_main_t * vam)
11277 unformat_input_t *i = vam->input;
11278 vl_api_modify_vhost_user_if_t *mp;
11281 u8 file_name_set = 0;
11282 u32 custom_dev_instance = ~0;
11283 u8 sw_if_index_set = 0;
11284 u32 sw_if_index = (u32) ~ 0;
11287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11289 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11290 sw_if_index_set = 1;
11291 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11292 sw_if_index_set = 1;
11293 else if (unformat (i, "socket %s", &file_name))
11297 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11299 else if (unformat (i, "server"))
11305 if (sw_if_index_set == 0)
11307 errmsg ("missing sw_if_index or interface name");
11311 if (file_name_set == 0)
11313 errmsg ("missing socket file name");
11317 if (vec_len (file_name) > 255)
11319 errmsg ("socket file name too long");
11322 vec_add1 (file_name, 0);
11324 M (MODIFY_VHOST_USER_IF, mp);
11326 mp->sw_if_index = ntohl (sw_if_index);
11327 mp->is_server = is_server;
11328 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11329 vec_free (file_name);
11330 if (custom_dev_instance != ~0)
11333 mp->custom_dev_instance = ntohl (custom_dev_instance);
11342 api_delete_vhost_user_if (vat_main_t * vam)
11344 unformat_input_t *i = vam->input;
11345 vl_api_delete_vhost_user_if_t *mp;
11346 u32 sw_if_index = ~0;
11347 u8 sw_if_index_set = 0;
11350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11352 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11353 sw_if_index_set = 1;
11354 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11355 sw_if_index_set = 1;
11360 if (sw_if_index_set == 0)
11362 errmsg ("missing sw_if_index or interface name");
11367 M (DELETE_VHOST_USER_IF, mp);
11369 mp->sw_if_index = ntohl (sw_if_index);
11376 static void vl_api_sw_interface_vhost_user_details_t_handler
11377 (vl_api_sw_interface_vhost_user_details_t * mp)
11379 vat_main_t *vam = &vat_main;
11381 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11382 (char *) mp->interface_name,
11383 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11384 clib_net_to_host_u64 (mp->features), mp->is_server,
11385 ntohl (mp->num_regions), (char *) mp->sock_filename);
11386 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11389 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11390 (vl_api_sw_interface_vhost_user_details_t * mp)
11392 vat_main_t *vam = &vat_main;
11393 vat_json_node_t *node = NULL;
11395 if (VAT_JSON_ARRAY != vam->json_tree.type)
11397 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11398 vat_json_init_array (&vam->json_tree);
11400 node = vat_json_array_add (&vam->json_tree);
11402 vat_json_init_object (node);
11403 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11404 vat_json_object_add_string_copy (node, "interface_name",
11405 mp->interface_name);
11406 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11407 ntohl (mp->virtio_net_hdr_sz));
11408 vat_json_object_add_uint (node, "features",
11409 clib_net_to_host_u64 (mp->features));
11410 vat_json_object_add_uint (node, "is_server", mp->is_server);
11411 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11412 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11413 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11417 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11419 vl_api_sw_interface_vhost_user_dump_t *mp;
11420 vl_api_control_ping_t *mp_ping;
11423 "Interface name idx hdr_sz features server regions filename");
11425 /* Get list of vhost-user interfaces */
11426 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11429 /* Use a control ping for synchronization */
11430 M (CONTROL_PING, mp_ping);
11438 api_show_version (vat_main_t * vam)
11440 vl_api_show_version_t *mp;
11443 M (SHOW_VERSION, mp);
11452 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11454 unformat_input_t *line_input = vam->input;
11455 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11456 ip4_address_t local4, remote4;
11457 ip6_address_t local6, remote6;
11459 u8 ipv4_set = 0, ipv6_set = 0;
11462 u32 encap_vrf_id = 0;
11463 u32 decap_vrf_id = 0;
11469 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11471 if (unformat (line_input, "del"))
11473 else if (unformat (line_input, "local %U",
11474 unformat_ip4_address, &local4))
11479 else if (unformat (line_input, "remote %U",
11480 unformat_ip4_address, &remote4))
11485 else if (unformat (line_input, "local %U",
11486 unformat_ip6_address, &local6))
11491 else if (unformat (line_input, "remote %U",
11492 unformat_ip6_address, &remote6))
11497 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11499 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11501 else if (unformat (line_input, "vni %d", &vni))
11503 else if (unformat (line_input, "next-ip4"))
11505 else if (unformat (line_input, "next-ip6"))
11507 else if (unformat (line_input, "next-ethernet"))
11509 else if (unformat (line_input, "next-nsh"))
11513 errmsg ("parse error '%U'", format_unformat_error, line_input);
11518 if (local_set == 0)
11520 errmsg ("tunnel local address not specified");
11523 if (remote_set == 0)
11525 errmsg ("tunnel remote address not specified");
11528 if (ipv4_set && ipv6_set)
11530 errmsg ("both IPv4 and IPv6 addresses specified");
11536 errmsg ("vni not specified");
11540 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11545 clib_memcpy (&mp->local, &local6, sizeof (local6));
11546 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11550 clib_memcpy (&mp->local, &local4, sizeof (local4));
11551 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11554 mp->encap_vrf_id = ntohl (encap_vrf_id);
11555 mp->decap_vrf_id = ntohl (decap_vrf_id);
11556 mp->protocol = protocol;
11557 mp->vni = ntohl (vni);
11558 mp->is_add = is_add;
11559 mp->is_ipv6 = ipv6_set;
11566 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11567 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11569 vat_main_t *vam = &vat_main;
11571 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11572 ntohl (mp->sw_if_index),
11573 format_ip46_address, &(mp->local[0]),
11574 format_ip46_address, &(mp->remote[0]),
11576 ntohl (mp->protocol),
11577 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11580 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11581 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11583 vat_main_t *vam = &vat_main;
11584 vat_json_node_t *node = NULL;
11585 struct in_addr ip4;
11586 struct in6_addr ip6;
11588 if (VAT_JSON_ARRAY != vam->json_tree.type)
11590 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11591 vat_json_init_array (&vam->json_tree);
11593 node = vat_json_array_add (&vam->json_tree);
11595 vat_json_init_object (node);
11596 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11599 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11600 vat_json_object_add_ip6 (node, "local", ip6);
11601 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11602 vat_json_object_add_ip6 (node, "remote", ip6);
11606 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11607 vat_json_object_add_ip4 (node, "local", ip4);
11608 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11609 vat_json_object_add_ip4 (node, "remote", ip4);
11611 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11612 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11613 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11614 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11615 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11619 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11621 unformat_input_t *i = vam->input;
11622 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11623 vl_api_control_ping_t *mp_ping;
11625 u8 sw_if_index_set = 0;
11628 /* Parse args required to build the message */
11629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11631 if (unformat (i, "sw_if_index %d", &sw_if_index))
11632 sw_if_index_set = 1;
11637 if (sw_if_index_set == 0)
11642 if (!vam->json_output)
11644 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11645 "sw_if_index", "local", "remote", "vni",
11646 "protocol", "encap_vrf_id", "decap_vrf_id");
11649 /* Get list of vxlan-tunnel interfaces */
11650 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11652 mp->sw_if_index = htonl (sw_if_index);
11656 /* Use a control ping for synchronization */
11657 M (CONTROL_PING, mp_ping);
11665 format_l2_fib_mac_address (u8 * s, va_list * args)
11667 u8 *a = va_arg (*args, u8 *);
11669 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11670 a[2], a[3], a[4], a[5], a[6], a[7]);
11673 static void vl_api_l2_fib_table_entry_t_handler
11674 (vl_api_l2_fib_table_entry_t * mp)
11676 vat_main_t *vam = &vat_main;
11678 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11680 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11681 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11685 static void vl_api_l2_fib_table_entry_t_handler_json
11686 (vl_api_l2_fib_table_entry_t * mp)
11688 vat_main_t *vam = &vat_main;
11689 vat_json_node_t *node = NULL;
11691 if (VAT_JSON_ARRAY != vam->json_tree.type)
11693 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11694 vat_json_init_array (&vam->json_tree);
11696 node = vat_json_array_add (&vam->json_tree);
11698 vat_json_init_object (node);
11699 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11700 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11701 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11702 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11703 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11704 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11708 api_l2_fib_table_dump (vat_main_t * vam)
11710 unformat_input_t *i = vam->input;
11711 vl_api_l2_fib_table_dump_t *mp;
11712 vl_api_control_ping_t *mp_ping;
11717 /* Parse args required to build the message */
11718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11720 if (unformat (i, "bd_id %d", &bd_id))
11726 if (bd_id_set == 0)
11728 errmsg ("missing bridge domain");
11732 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11734 /* Get list of l2 fib entries */
11735 M (L2_FIB_TABLE_DUMP, mp);
11737 mp->bd_id = ntohl (bd_id);
11740 /* Use a control ping for synchronization */
11741 M (CONTROL_PING, mp_ping);
11750 api_interface_name_renumber (vat_main_t * vam)
11752 unformat_input_t *line_input = vam->input;
11753 vl_api_interface_name_renumber_t *mp;
11754 u32 sw_if_index = ~0;
11755 u32 new_show_dev_instance = ~0;
11758 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11760 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11763 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11765 else if (unformat (line_input, "new_show_dev_instance %d",
11766 &new_show_dev_instance))
11772 if (sw_if_index == ~0)
11774 errmsg ("missing interface name or sw_if_index");
11778 if (new_show_dev_instance == ~0)
11780 errmsg ("missing new_show_dev_instance");
11784 M (INTERFACE_NAME_RENUMBER, mp);
11786 mp->sw_if_index = ntohl (sw_if_index);
11787 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11795 api_want_ip4_arp_events (vat_main_t * vam)
11797 unformat_input_t *line_input = vam->input;
11798 vl_api_want_ip4_arp_events_t *mp;
11799 ip4_address_t address;
11800 int address_set = 0;
11801 u32 enable_disable = 1;
11804 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11806 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11808 else if (unformat (line_input, "del"))
11809 enable_disable = 0;
11814 if (address_set == 0)
11816 errmsg ("missing addresses");
11820 M (WANT_IP4_ARP_EVENTS, mp);
11821 mp->enable_disable = enable_disable;
11822 mp->pid = getpid ();
11823 mp->address = address.as_u32;
11831 api_want_ip6_nd_events (vat_main_t * vam)
11833 unformat_input_t *line_input = vam->input;
11834 vl_api_want_ip6_nd_events_t *mp;
11835 ip6_address_t address;
11836 int address_set = 0;
11837 u32 enable_disable = 1;
11840 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11842 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11844 else if (unformat (line_input, "del"))
11845 enable_disable = 0;
11850 if (address_set == 0)
11852 errmsg ("missing addresses");
11856 M (WANT_IP6_ND_EVENTS, mp);
11857 mp->enable_disable = enable_disable;
11858 mp->pid = getpid ();
11859 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11867 api_input_acl_set_interface (vat_main_t * vam)
11869 unformat_input_t *i = vam->input;
11870 vl_api_input_acl_set_interface_t *mp;
11872 int sw_if_index_set;
11873 u32 ip4_table_index = ~0;
11874 u32 ip6_table_index = ~0;
11875 u32 l2_table_index = ~0;
11879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11881 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11882 sw_if_index_set = 1;
11883 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11884 sw_if_index_set = 1;
11885 else if (unformat (i, "del"))
11887 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11889 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11891 else if (unformat (i, "l2-table %d", &l2_table_index))
11895 clib_warning ("parse error '%U'", format_unformat_error, i);
11900 if (sw_if_index_set == 0)
11902 errmsg ("missing interface name or sw_if_index");
11906 M (INPUT_ACL_SET_INTERFACE, mp);
11908 mp->sw_if_index = ntohl (sw_if_index);
11909 mp->ip4_table_index = ntohl (ip4_table_index);
11910 mp->ip6_table_index = ntohl (ip6_table_index);
11911 mp->l2_table_index = ntohl (l2_table_index);
11912 mp->is_add = is_add;
11920 api_ip_address_dump (vat_main_t * vam)
11922 unformat_input_t *i = vam->input;
11923 vl_api_ip_address_dump_t *mp;
11924 vl_api_control_ping_t *mp_ping;
11925 u32 sw_if_index = ~0;
11926 u8 sw_if_index_set = 0;
11931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11933 if (unformat (i, "sw_if_index %d", &sw_if_index))
11934 sw_if_index_set = 1;
11936 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11937 sw_if_index_set = 1;
11938 else if (unformat (i, "ipv4"))
11940 else if (unformat (i, "ipv6"))
11946 if (ipv4_set && ipv6_set)
11948 errmsg ("ipv4 and ipv6 flags cannot be both set");
11952 if ((!ipv4_set) && (!ipv6_set))
11954 errmsg ("no ipv4 nor ipv6 flag set");
11958 if (sw_if_index_set == 0)
11960 errmsg ("missing interface name or sw_if_index");
11964 vam->current_sw_if_index = sw_if_index;
11965 vam->is_ipv6 = ipv6_set;
11967 M (IP_ADDRESS_DUMP, mp);
11968 mp->sw_if_index = ntohl (sw_if_index);
11969 mp->is_ipv6 = ipv6_set;
11972 /* Use a control ping for synchronization */
11973 M (CONTROL_PING, mp_ping);
11981 api_ip_dump (vat_main_t * vam)
11983 vl_api_ip_dump_t *mp;
11984 vl_api_control_ping_t *mp_ping;
11985 unformat_input_t *in = vam->input;
11992 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11994 if (unformat (in, "ipv4"))
11996 else if (unformat (in, "ipv6"))
12002 if (ipv4_set && ipv6_set)
12004 errmsg ("ipv4 and ipv6 flags cannot be both set");
12008 if ((!ipv4_set) && (!ipv6_set))
12010 errmsg ("no ipv4 nor ipv6 flag set");
12014 is_ipv6 = ipv6_set;
12015 vam->is_ipv6 = is_ipv6;
12017 /* free old data */
12018 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12020 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12022 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12025 mp->is_ipv6 = ipv6_set;
12028 /* Use a control ping for synchronization */
12029 M (CONTROL_PING, mp_ping);
12037 api_ipsec_spd_add_del (vat_main_t * vam)
12039 unformat_input_t *i = vam->input;
12040 vl_api_ipsec_spd_add_del_t *mp;
12045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12047 if (unformat (i, "spd_id %d", &spd_id))
12049 else if (unformat (i, "del"))
12053 clib_warning ("parse error '%U'", format_unformat_error, i);
12059 errmsg ("spd_id must be set");
12063 M (IPSEC_SPD_ADD_DEL, mp);
12065 mp->spd_id = ntohl (spd_id);
12066 mp->is_add = is_add;
12074 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12076 unformat_input_t *i = vam->input;
12077 vl_api_ipsec_interface_add_del_spd_t *mp;
12079 u8 sw_if_index_set = 0;
12080 u32 spd_id = (u32) ~ 0;
12084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12086 if (unformat (i, "del"))
12088 else if (unformat (i, "spd_id %d", &spd_id))
12091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12092 sw_if_index_set = 1;
12093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12094 sw_if_index_set = 1;
12097 clib_warning ("parse error '%U'", format_unformat_error, i);
12103 if (spd_id == (u32) ~ 0)
12105 errmsg ("spd_id must be set");
12109 if (sw_if_index_set == 0)
12111 errmsg ("missing interface name or sw_if_index");
12115 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12117 mp->spd_id = ntohl (spd_id);
12118 mp->sw_if_index = ntohl (sw_if_index);
12119 mp->is_add = is_add;
12127 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12129 unformat_input_t *i = vam->input;
12130 vl_api_ipsec_spd_add_del_entry_t *mp;
12131 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12132 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12134 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12135 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12136 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12137 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12140 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12141 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12142 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12143 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12144 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12145 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12149 if (unformat (i, "del"))
12151 if (unformat (i, "outbound"))
12153 if (unformat (i, "inbound"))
12155 else if (unformat (i, "spd_id %d", &spd_id))
12157 else if (unformat (i, "sa_id %d", &sa_id))
12159 else if (unformat (i, "priority %d", &priority))
12161 else if (unformat (i, "protocol %d", &protocol))
12163 else if (unformat (i, "lport_start %d", &lport_start))
12165 else if (unformat (i, "lport_stop %d", &lport_stop))
12167 else if (unformat (i, "rport_start %d", &rport_start))
12169 else if (unformat (i, "rport_stop %d", &rport_stop))
12173 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12179 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12186 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12192 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12199 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12205 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12212 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12218 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12224 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12226 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12228 clib_warning ("unsupported action: 'resolve'");
12234 clib_warning ("parse error '%U'", format_unformat_error, i);
12240 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12242 mp->spd_id = ntohl (spd_id);
12243 mp->priority = ntohl (priority);
12244 mp->is_outbound = is_outbound;
12246 mp->is_ipv6 = is_ipv6;
12247 if (is_ipv6 || is_ip_any)
12249 clib_memcpy (mp->remote_address_start, &raddr6_start,
12250 sizeof (ip6_address_t));
12251 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12252 sizeof (ip6_address_t));
12253 clib_memcpy (mp->local_address_start, &laddr6_start,
12254 sizeof (ip6_address_t));
12255 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12256 sizeof (ip6_address_t));
12260 clib_memcpy (mp->remote_address_start, &raddr4_start,
12261 sizeof (ip4_address_t));
12262 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12263 sizeof (ip4_address_t));
12264 clib_memcpy (mp->local_address_start, &laddr4_start,
12265 sizeof (ip4_address_t));
12266 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12267 sizeof (ip4_address_t));
12269 mp->protocol = (u8) protocol;
12270 mp->local_port_start = ntohs ((u16) lport_start);
12271 mp->local_port_stop = ntohs ((u16) lport_stop);
12272 mp->remote_port_start = ntohs ((u16) rport_start);
12273 mp->remote_port_stop = ntohs ((u16) rport_stop);
12274 mp->policy = (u8) policy;
12275 mp->sa_id = ntohl (sa_id);
12276 mp->is_add = is_add;
12277 mp->is_ip_any = is_ip_any;
12284 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12286 unformat_input_t *i = vam->input;
12287 vl_api_ipsec_sad_add_del_entry_t *mp;
12288 u32 sad_id = 0, spi = 0;
12289 u8 *ck = 0, *ik = 0;
12292 u8 protocol = IPSEC_PROTOCOL_AH;
12293 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12294 u32 crypto_alg = 0, integ_alg = 0;
12295 ip4_address_t tun_src4;
12296 ip4_address_t tun_dst4;
12297 ip6_address_t tun_src6;
12298 ip6_address_t tun_dst6;
12301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12303 if (unformat (i, "del"))
12305 else if (unformat (i, "sad_id %d", &sad_id))
12307 else if (unformat (i, "spi %d", &spi))
12309 else if (unformat (i, "esp"))
12310 protocol = IPSEC_PROTOCOL_ESP;
12311 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12314 is_tunnel_ipv6 = 0;
12316 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12319 is_tunnel_ipv6 = 0;
12321 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12324 is_tunnel_ipv6 = 1;
12326 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12329 is_tunnel_ipv6 = 1;
12333 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12335 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12336 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12338 clib_warning ("unsupported crypto-alg: '%U'",
12339 format_ipsec_crypto_alg, crypto_alg);
12343 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12347 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12349 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12350 integ_alg >= IPSEC_INTEG_N_ALG)
12352 clib_warning ("unsupported integ-alg: '%U'",
12353 format_ipsec_integ_alg, integ_alg);
12357 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12361 clib_warning ("parse error '%U'", format_unformat_error, i);
12367 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12369 mp->sad_id = ntohl (sad_id);
12370 mp->is_add = is_add;
12371 mp->protocol = protocol;
12372 mp->spi = ntohl (spi);
12373 mp->is_tunnel = is_tunnel;
12374 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12375 mp->crypto_algorithm = crypto_alg;
12376 mp->integrity_algorithm = integ_alg;
12377 mp->crypto_key_length = vec_len (ck);
12378 mp->integrity_key_length = vec_len (ik);
12380 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12381 mp->crypto_key_length = sizeof (mp->crypto_key);
12383 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12384 mp->integrity_key_length = sizeof (mp->integrity_key);
12387 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12389 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12393 if (is_tunnel_ipv6)
12395 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12396 sizeof (ip6_address_t));
12397 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12398 sizeof (ip6_address_t));
12402 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12403 sizeof (ip4_address_t));
12404 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12405 sizeof (ip4_address_t));
12415 api_ipsec_sa_set_key (vat_main_t * vam)
12417 unformat_input_t *i = vam->input;
12418 vl_api_ipsec_sa_set_key_t *mp;
12420 u8 *ck = 0, *ik = 0;
12423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12425 if (unformat (i, "sa_id %d", &sa_id))
12427 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12429 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12433 clib_warning ("parse error '%U'", format_unformat_error, i);
12438 M (IPSEC_SA_SET_KEY, mp);
12440 mp->sa_id = ntohl (sa_id);
12441 mp->crypto_key_length = vec_len (ck);
12442 mp->integrity_key_length = vec_len (ik);
12444 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12445 mp->crypto_key_length = sizeof (mp->crypto_key);
12447 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12448 mp->integrity_key_length = sizeof (mp->integrity_key);
12451 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12453 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12461 api_ikev2_profile_add_del (vat_main_t * vam)
12463 unformat_input_t *i = vam->input;
12464 vl_api_ikev2_profile_add_del_t *mp;
12469 const char *valid_chars = "a-zA-Z0-9_";
12471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12473 if (unformat (i, "del"))
12475 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12476 vec_add1 (name, 0);
12479 errmsg ("parse error '%U'", format_unformat_error, i);
12484 if (!vec_len (name))
12486 errmsg ("profile name must be specified");
12490 if (vec_len (name) > 64)
12492 errmsg ("profile name too long");
12496 M (IKEV2_PROFILE_ADD_DEL, mp);
12498 clib_memcpy (mp->name, name, vec_len (name));
12499 mp->is_add = is_add;
12508 api_ikev2_profile_set_auth (vat_main_t * vam)
12510 unformat_input_t *i = vam->input;
12511 vl_api_ikev2_profile_set_auth_t *mp;
12514 u32 auth_method = 0;
12518 const char *valid_chars = "a-zA-Z0-9_";
12520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12522 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12523 vec_add1 (name, 0);
12524 else if (unformat (i, "auth_method %U",
12525 unformat_ikev2_auth_method, &auth_method))
12527 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12529 else if (unformat (i, "auth_data %v", &data))
12533 errmsg ("parse error '%U'", format_unformat_error, i);
12538 if (!vec_len (name))
12540 errmsg ("profile name must be specified");
12544 if (vec_len (name) > 64)
12546 errmsg ("profile name too long");
12550 if (!vec_len (data))
12552 errmsg ("auth_data must be specified");
12558 errmsg ("auth_method must be specified");
12562 M (IKEV2_PROFILE_SET_AUTH, mp);
12564 mp->is_hex = is_hex;
12565 mp->auth_method = (u8) auth_method;
12566 mp->data_len = vec_len (data);
12567 clib_memcpy (mp->name, name, vec_len (name));
12568 clib_memcpy (mp->data, data, vec_len (data));
12578 api_ikev2_profile_set_id (vat_main_t * vam)
12580 unformat_input_t *i = vam->input;
12581 vl_api_ikev2_profile_set_id_t *mp;
12589 const char *valid_chars = "a-zA-Z0-9_";
12591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12593 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12594 vec_add1 (name, 0);
12595 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12597 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12599 data = vec_new (u8, 4);
12600 clib_memcpy (data, ip4.as_u8, 4);
12602 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12604 else if (unformat (i, "id_data %v", &data))
12606 else if (unformat (i, "local"))
12608 else if (unformat (i, "remote"))
12612 errmsg ("parse error '%U'", format_unformat_error, i);
12617 if (!vec_len (name))
12619 errmsg ("profile name must be specified");
12623 if (vec_len (name) > 64)
12625 errmsg ("profile name too long");
12629 if (!vec_len (data))
12631 errmsg ("id_data must be specified");
12637 errmsg ("id_type must be specified");
12641 M (IKEV2_PROFILE_SET_ID, mp);
12643 mp->is_local = is_local;
12644 mp->id_type = (u8) id_type;
12645 mp->data_len = vec_len (data);
12646 clib_memcpy (mp->name, name, vec_len (name));
12647 clib_memcpy (mp->data, data, vec_len (data));
12657 api_ikev2_profile_set_ts (vat_main_t * vam)
12659 unformat_input_t *i = vam->input;
12660 vl_api_ikev2_profile_set_ts_t *mp;
12663 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12664 ip4_address_t start_addr, end_addr;
12666 const char *valid_chars = "a-zA-Z0-9_";
12669 start_addr.as_u32 = 0;
12670 end_addr.as_u32 = (u32) ~ 0;
12672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12674 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12675 vec_add1 (name, 0);
12676 else if (unformat (i, "protocol %d", &proto))
12678 else if (unformat (i, "start_port %d", &start_port))
12680 else if (unformat (i, "end_port %d", &end_port))
12683 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12685 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12687 else if (unformat (i, "local"))
12689 else if (unformat (i, "remote"))
12693 errmsg ("parse error '%U'", format_unformat_error, i);
12698 if (!vec_len (name))
12700 errmsg ("profile name must be specified");
12704 if (vec_len (name) > 64)
12706 errmsg ("profile name too long");
12710 M (IKEV2_PROFILE_SET_TS, mp);
12712 mp->is_local = is_local;
12713 mp->proto = (u8) proto;
12714 mp->start_port = (u16) start_port;
12715 mp->end_port = (u16) end_port;
12716 mp->start_addr = start_addr.as_u32;
12717 mp->end_addr = end_addr.as_u32;
12718 clib_memcpy (mp->name, name, vec_len (name));
12727 api_ikev2_set_local_key (vat_main_t * vam)
12729 unformat_input_t *i = vam->input;
12730 vl_api_ikev2_set_local_key_t *mp;
12734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12736 if (unformat (i, "file %v", &file))
12737 vec_add1 (file, 0);
12740 errmsg ("parse error '%U'", format_unformat_error, i);
12745 if (!vec_len (file))
12747 errmsg ("RSA key file must be specified");
12751 if (vec_len (file) > 256)
12753 errmsg ("file name too long");
12757 M (IKEV2_SET_LOCAL_KEY, mp);
12759 clib_memcpy (mp->key_file, file, vec_len (file));
12768 api_ikev2_set_responder (vat_main_t * vam)
12770 unformat_input_t *i = vam->input;
12771 vl_api_ikev2_set_responder_t *mp;
12774 u32 sw_if_index = ~0;
12775 ip4_address_t address;
12777 const char *valid_chars = "a-zA-Z0-9_";
12779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12782 (i, "%U interface %d address %U", unformat_token, valid_chars,
12783 &name, &sw_if_index, unformat_ip4_address, &address))
12784 vec_add1 (name, 0);
12787 errmsg ("parse error '%U'", format_unformat_error, i);
12792 if (!vec_len (name))
12794 errmsg ("profile name must be specified");
12798 if (vec_len (name) > 64)
12800 errmsg ("profile name too long");
12804 M (IKEV2_SET_RESPONDER, mp);
12806 clib_memcpy (mp->name, name, vec_len (name));
12809 mp->sw_if_index = sw_if_index;
12810 clib_memcpy (mp->address, &address, sizeof (address));
12818 api_ikev2_set_ike_transforms (vat_main_t * vam)
12820 unformat_input_t *i = vam->input;
12821 vl_api_ikev2_set_ike_transforms_t *mp;
12824 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12826 const char *valid_chars = "a-zA-Z0-9_";
12828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12830 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12831 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12832 vec_add1 (name, 0);
12835 errmsg ("parse error '%U'", format_unformat_error, i);
12840 if (!vec_len (name))
12842 errmsg ("profile name must be specified");
12846 if (vec_len (name) > 64)
12848 errmsg ("profile name too long");
12852 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12854 clib_memcpy (mp->name, name, vec_len (name));
12856 mp->crypto_alg = crypto_alg;
12857 mp->crypto_key_size = crypto_key_size;
12858 mp->integ_alg = integ_alg;
12859 mp->dh_group = dh_group;
12868 api_ikev2_set_esp_transforms (vat_main_t * vam)
12870 unformat_input_t *i = vam->input;
12871 vl_api_ikev2_set_esp_transforms_t *mp;
12874 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12876 const char *valid_chars = "a-zA-Z0-9_";
12878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12880 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12881 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12882 vec_add1 (name, 0);
12885 errmsg ("parse error '%U'", format_unformat_error, i);
12890 if (!vec_len (name))
12892 errmsg ("profile name must be specified");
12896 if (vec_len (name) > 64)
12898 errmsg ("profile name too long");
12902 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12904 clib_memcpy (mp->name, name, vec_len (name));
12906 mp->crypto_alg = crypto_alg;
12907 mp->crypto_key_size = crypto_key_size;
12908 mp->integ_alg = integ_alg;
12909 mp->dh_group = dh_group;
12917 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12919 unformat_input_t *i = vam->input;
12920 vl_api_ikev2_set_sa_lifetime_t *mp;
12923 u64 lifetime, lifetime_maxdata;
12924 u32 lifetime_jitter, handover;
12926 const char *valid_chars = "a-zA-Z0-9_";
12928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12930 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12931 &lifetime, &lifetime_jitter, &handover,
12932 &lifetime_maxdata))
12933 vec_add1 (name, 0);
12936 errmsg ("parse error '%U'", format_unformat_error, i);
12941 if (!vec_len (name))
12943 errmsg ("profile name must be specified");
12947 if (vec_len (name) > 64)
12949 errmsg ("profile name too long");
12953 M (IKEV2_SET_SA_LIFETIME, mp);
12955 clib_memcpy (mp->name, name, vec_len (name));
12957 mp->lifetime = lifetime;
12958 mp->lifetime_jitter = lifetime_jitter;
12959 mp->handover = handover;
12960 mp->lifetime_maxdata = lifetime_maxdata;
12968 api_ikev2_initiate_sa_init (vat_main_t * vam)
12970 unformat_input_t *i = vam->input;
12971 vl_api_ikev2_initiate_sa_init_t *mp;
12975 const char *valid_chars = "a-zA-Z0-9_";
12977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12979 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12980 vec_add1 (name, 0);
12983 errmsg ("parse error '%U'", format_unformat_error, i);
12988 if (!vec_len (name))
12990 errmsg ("profile name must be specified");
12994 if (vec_len (name) > 64)
12996 errmsg ("profile name too long");
13000 M (IKEV2_INITIATE_SA_INIT, mp);
13002 clib_memcpy (mp->name, name, vec_len (name));
13011 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13013 unformat_input_t *i = vam->input;
13014 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13021 if (unformat (i, "%lx", &ispi))
13025 errmsg ("parse error '%U'", format_unformat_error, i);
13030 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13040 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13042 unformat_input_t *i = vam->input;
13043 vl_api_ikev2_initiate_del_child_sa_t *mp;
13048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13050 if (unformat (i, "%x", &ispi))
13054 errmsg ("parse error '%U'", format_unformat_error, i);
13059 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13069 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13071 unformat_input_t *i = vam->input;
13072 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13079 if (unformat (i, "%x", &ispi))
13083 errmsg ("parse error '%U'", format_unformat_error, i);
13088 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13101 api_map_add_domain (vat_main_t * vam)
13103 unformat_input_t *i = vam->input;
13104 vl_api_map_add_domain_t *mp;
13106 ip4_address_t ip4_prefix;
13107 ip6_address_t ip6_prefix;
13108 ip6_address_t ip6_src;
13109 u32 num_m_args = 0;
13110 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13111 0, psid_length = 0;
13112 u8 is_translation = 0;
13114 u32 ip6_src_len = 128;
13117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13119 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13120 &ip4_prefix, &ip4_prefix_len))
13122 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13123 &ip6_prefix, &ip6_prefix_len))
13127 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13130 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13132 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13134 else if (unformat (i, "psid-offset %d", &psid_offset))
13136 else if (unformat (i, "psid-len %d", &psid_length))
13138 else if (unformat (i, "mtu %d", &mtu))
13140 else if (unformat (i, "map-t"))
13141 is_translation = 1;
13144 clib_warning ("parse error '%U'", format_unformat_error, i);
13149 if (num_m_args < 3)
13151 errmsg ("mandatory argument(s) missing");
13155 /* Construct the API message */
13156 M (MAP_ADD_DOMAIN, mp);
13158 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13159 mp->ip4_prefix_len = ip4_prefix_len;
13161 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13162 mp->ip6_prefix_len = ip6_prefix_len;
13164 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13165 mp->ip6_src_prefix_len = ip6_src_len;
13167 mp->ea_bits_len = ea_bits_len;
13168 mp->psid_offset = psid_offset;
13169 mp->psid_length = psid_length;
13170 mp->is_translation = is_translation;
13171 mp->mtu = htons (mtu);
13176 /* Wait for a reply, return good/bad news */
13182 api_map_del_domain (vat_main_t * vam)
13184 unformat_input_t *i = vam->input;
13185 vl_api_map_del_domain_t *mp;
13187 u32 num_m_args = 0;
13191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13193 if (unformat (i, "index %d", &index))
13197 clib_warning ("parse error '%U'", format_unformat_error, i);
13202 if (num_m_args != 1)
13204 errmsg ("mandatory argument(s) missing");
13208 /* Construct the API message */
13209 M (MAP_DEL_DOMAIN, mp);
13211 mp->index = ntohl (index);
13216 /* Wait for a reply, return good/bad news */
13222 api_map_add_del_rule (vat_main_t * vam)
13224 unformat_input_t *i = vam->input;
13225 vl_api_map_add_del_rule_t *mp;
13227 ip6_address_t ip6_dst;
13228 u32 num_m_args = 0, index, psid = 0;
13231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13233 if (unformat (i, "index %d", &index))
13235 else if (unformat (i, "psid %d", &psid))
13237 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13239 else if (unformat (i, "del"))
13245 clib_warning ("parse error '%U'", format_unformat_error, i);
13250 /* Construct the API message */
13251 M (MAP_ADD_DEL_RULE, mp);
13253 mp->index = ntohl (index);
13254 mp->is_add = is_add;
13255 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13256 mp->psid = ntohs (psid);
13261 /* Wait for a reply, return good/bad news */
13267 api_map_domain_dump (vat_main_t * vam)
13269 vl_api_map_domain_dump_t *mp;
13270 vl_api_control_ping_t *mp_ping;
13273 /* Construct the API message */
13274 M (MAP_DOMAIN_DUMP, mp);
13279 /* Use a control ping for synchronization */
13280 M (CONTROL_PING, mp_ping);
13288 api_map_rule_dump (vat_main_t * vam)
13290 unformat_input_t *i = vam->input;
13291 vl_api_map_rule_dump_t *mp;
13292 vl_api_control_ping_t *mp_ping;
13293 u32 domain_index = ~0;
13296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13298 if (unformat (i, "index %u", &domain_index))
13304 if (domain_index == ~0)
13306 clib_warning ("parse error: domain index expected");
13310 /* Construct the API message */
13311 M (MAP_RULE_DUMP, mp);
13313 mp->domain_index = htonl (domain_index);
13318 /* Use a control ping for synchronization */
13319 M (CONTROL_PING, mp_ping);
13326 static void vl_api_map_add_domain_reply_t_handler
13327 (vl_api_map_add_domain_reply_t * mp)
13329 vat_main_t *vam = &vat_main;
13330 i32 retval = ntohl (mp->retval);
13332 if (vam->async_mode)
13334 vam->async_errors += (retval < 0);
13338 vam->retval = retval;
13339 vam->result_ready = 1;
13343 static void vl_api_map_add_domain_reply_t_handler_json
13344 (vl_api_map_add_domain_reply_t * mp)
13346 vat_main_t *vam = &vat_main;
13347 vat_json_node_t node;
13349 vat_json_init_object (&node);
13350 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13351 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13353 vat_json_print (vam->ofp, &node);
13354 vat_json_free (&node);
13356 vam->retval = ntohl (mp->retval);
13357 vam->result_ready = 1;
13361 api_get_first_msg_id (vat_main_t * vam)
13363 vl_api_get_first_msg_id_t *mp;
13364 unformat_input_t *i = vam->input;
13369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13371 if (unformat (i, "client %s", &name))
13379 errmsg ("missing client name");
13382 vec_add1 (name, 0);
13384 if (vec_len (name) > 63)
13386 errmsg ("client name too long");
13390 M (GET_FIRST_MSG_ID, mp);
13391 clib_memcpy (mp->name, name, vec_len (name));
13398 api_cop_interface_enable_disable (vat_main_t * vam)
13400 unformat_input_t *line_input = vam->input;
13401 vl_api_cop_interface_enable_disable_t *mp;
13402 u32 sw_if_index = ~0;
13403 u8 enable_disable = 1;
13406 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13408 if (unformat (line_input, "disable"))
13409 enable_disable = 0;
13410 if (unformat (line_input, "enable"))
13411 enable_disable = 1;
13412 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13413 vam, &sw_if_index))
13415 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13421 if (sw_if_index == ~0)
13423 errmsg ("missing interface name or sw_if_index");
13427 /* Construct the API message */
13428 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13429 mp->sw_if_index = ntohl (sw_if_index);
13430 mp->enable_disable = enable_disable;
13434 /* Wait for the reply */
13440 api_cop_whitelist_enable_disable (vat_main_t * vam)
13442 unformat_input_t *line_input = vam->input;
13443 vl_api_cop_whitelist_enable_disable_t *mp;
13444 u32 sw_if_index = ~0;
13445 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13449 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13451 if (unformat (line_input, "ip4"))
13453 else if (unformat (line_input, "ip6"))
13455 else if (unformat (line_input, "default"))
13457 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13458 vam, &sw_if_index))
13460 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13462 else if (unformat (line_input, "fib-id %d", &fib_id))
13468 if (sw_if_index == ~0)
13470 errmsg ("missing interface name or sw_if_index");
13474 /* Construct the API message */
13475 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13476 mp->sw_if_index = ntohl (sw_if_index);
13477 mp->fib_id = ntohl (fib_id);
13480 mp->default_cop = default_cop;
13484 /* Wait for the reply */
13490 api_get_node_graph (vat_main_t * vam)
13492 vl_api_get_node_graph_t *mp;
13495 M (GET_NODE_GRAPH, mp);
13499 /* Wait for the reply */
13505 /** Used for parsing LISP eids */
13506 typedef CLIB_PACKED(struct{
13507 u8 addr[16]; /**< eid address */
13508 u32 len; /**< prefix length if IP */
13509 u8 type; /**< type of eid */
13514 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13516 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13518 memset (a, 0, sizeof (a[0]));
13520 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13522 a->type = 0; /* ipv4 type */
13524 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13526 a->type = 1; /* ipv6 type */
13528 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13530 a->type = 2; /* mac type */
13537 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13546 lisp_eid_size_vat (u8 type)
13561 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13563 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13567 api_lisp_add_del_locator_set (vat_main_t * vam)
13569 unformat_input_t *input = vam->input;
13570 vl_api_lisp_add_del_locator_set_t *mp;
13572 u8 *locator_set_name = NULL;
13573 u8 locator_set_name_set = 0;
13574 vl_api_local_locator_t locator, *locators = 0;
13575 u32 sw_if_index, priority, weight;
13579 /* Parse args required to build the message */
13580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13582 if (unformat (input, "del"))
13586 else if (unformat (input, "locator-set %s", &locator_set_name))
13588 locator_set_name_set = 1;
13590 else if (unformat (input, "sw_if_index %u p %u w %u",
13591 &sw_if_index, &priority, &weight))
13593 locator.sw_if_index = htonl (sw_if_index);
13594 locator.priority = priority;
13595 locator.weight = weight;
13596 vec_add1 (locators, locator);
13600 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13601 &sw_if_index, &priority, &weight))
13603 locator.sw_if_index = htonl (sw_if_index);
13604 locator.priority = priority;
13605 locator.weight = weight;
13606 vec_add1 (locators, locator);
13612 if (locator_set_name_set == 0)
13614 errmsg ("missing locator-set name");
13615 vec_free (locators);
13619 if (vec_len (locator_set_name) > 64)
13621 errmsg ("locator-set name too long");
13622 vec_free (locator_set_name);
13623 vec_free (locators);
13626 vec_add1 (locator_set_name, 0);
13628 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13630 /* Construct the API message */
13631 M2 (LISP_ADD_DEL_LOCATOR_SET, mp, data_len);
13633 mp->is_add = is_add;
13634 clib_memcpy (mp->locator_set_name, locator_set_name,
13635 vec_len (locator_set_name));
13636 vec_free (locator_set_name);
13638 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13640 clib_memcpy (mp->locators, locators, data_len);
13641 vec_free (locators);
13646 /* Wait for a reply... */
13652 api_lisp_add_del_locator (vat_main_t * vam)
13654 unformat_input_t *input = vam->input;
13655 vl_api_lisp_add_del_locator_t *mp;
13656 u32 tmp_if_index = ~0;
13657 u32 sw_if_index = ~0;
13658 u8 sw_if_index_set = 0;
13659 u8 sw_if_index_if_name_set = 0;
13661 u8 priority_set = 0;
13665 u8 *locator_set_name = NULL;
13666 u8 locator_set_name_set = 0;
13669 /* Parse args required to build the message */
13670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13672 if (unformat (input, "del"))
13676 else if (unformat (input, "locator-set %s", &locator_set_name))
13678 locator_set_name_set = 1;
13680 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13683 sw_if_index_if_name_set = 1;
13684 sw_if_index = tmp_if_index;
13686 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13688 sw_if_index_set = 1;
13689 sw_if_index = tmp_if_index;
13691 else if (unformat (input, "p %d", &priority))
13695 else if (unformat (input, "w %d", &weight))
13703 if (locator_set_name_set == 0)
13705 errmsg ("missing locator-set name");
13709 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13711 errmsg ("missing sw_if_index");
13712 vec_free (locator_set_name);
13716 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13718 errmsg ("cannot use both params interface name and sw_if_index");
13719 vec_free (locator_set_name);
13723 if (priority_set == 0)
13725 errmsg ("missing locator-set priority");
13726 vec_free (locator_set_name);
13730 if (weight_set == 0)
13732 errmsg ("missing locator-set weight");
13733 vec_free (locator_set_name);
13737 if (vec_len (locator_set_name) > 64)
13739 errmsg ("locator-set name too long");
13740 vec_free (locator_set_name);
13743 vec_add1 (locator_set_name, 0);
13745 /* Construct the API message */
13746 M (LISP_ADD_DEL_LOCATOR, mp);
13748 mp->is_add = is_add;
13749 mp->sw_if_index = ntohl (sw_if_index);
13750 mp->priority = priority;
13751 mp->weight = weight;
13752 clib_memcpy (mp->locator_set_name, locator_set_name,
13753 vec_len (locator_set_name));
13754 vec_free (locator_set_name);
13759 /* Wait for a reply... */
13765 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13767 u32 *key_id = va_arg (*args, u32 *);
13770 if (unformat (input, "%s", &s))
13772 if (!strcmp ((char *) s, "sha1"))
13773 key_id[0] = HMAC_SHA_1_96;
13774 else if (!strcmp ((char *) s, "sha256"))
13775 key_id[0] = HMAC_SHA_256_128;
13778 clib_warning ("invalid key_id: '%s'", s);
13779 key_id[0] = HMAC_NO_KEY;
13790 api_lisp_add_del_local_eid (vat_main_t * vam)
13792 unformat_input_t *input = vam->input;
13793 vl_api_lisp_add_del_local_eid_t *mp;
13796 lisp_eid_vat_t _eid, *eid = &_eid;
13797 u8 *locator_set_name = 0;
13798 u8 locator_set_name_set = 0;
13804 /* Parse args required to build the message */
13805 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13807 if (unformat (input, "del"))
13811 else if (unformat (input, "vni %d", &vni))
13815 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13819 else if (unformat (input, "locator-set %s", &locator_set_name))
13821 locator_set_name_set = 1;
13823 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13825 else if (unformat (input, "secret-key %_%v%_", &key))
13831 if (locator_set_name_set == 0)
13833 errmsg ("missing locator-set name");
13839 errmsg ("EID address not set!");
13840 vec_free (locator_set_name);
13844 if (key && (0 == key_id))
13846 errmsg ("invalid key_id!");
13850 if (vec_len (key) > 64)
13852 errmsg ("key too long");
13857 if (vec_len (locator_set_name) > 64)
13859 errmsg ("locator-set name too long");
13860 vec_free (locator_set_name);
13863 vec_add1 (locator_set_name, 0);
13865 /* Construct the API message */
13866 M (LISP_ADD_DEL_LOCAL_EID, mp);
13868 mp->is_add = is_add;
13869 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13870 mp->eid_type = eid->type;
13871 mp->prefix_len = eid->len;
13872 mp->vni = clib_host_to_net_u32 (vni);
13873 mp->key_id = clib_host_to_net_u16 (key_id);
13874 clib_memcpy (mp->locator_set_name, locator_set_name,
13875 vec_len (locator_set_name));
13876 clib_memcpy (mp->key, key, vec_len (key));
13878 vec_free (locator_set_name);
13884 /* Wait for a reply... */
13890 /** Used for transferring locators via VPP API */
13891 typedef CLIB_PACKED(struct
13893 u8 is_ip4; /**< is locator an IPv4 address? */
13894 u8 priority; /**< locator priority */
13895 u8 weight; /**< locator weight */
13896 u8 addr[16]; /**< IPv4/IPv6 address */
13901 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13903 u32 dp_table = 0, vni = 0;;
13904 unformat_input_t *input = vam->input;
13905 vl_api_gpe_add_del_fwd_entry_t *mp;
13907 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13908 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13909 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13910 u32 action = ~0, w;
13911 ip4_address_t rmt_rloc4, lcl_rloc4;
13912 ip6_address_t rmt_rloc6, lcl_rloc6;
13913 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13916 memset (&rloc, 0, sizeof (rloc));
13918 /* Parse args required to build the message */
13919 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13921 if (unformat (input, "del"))
13923 else if (unformat (input, "add"))
13925 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13929 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13933 else if (unformat (input, "vrf %d", &dp_table))
13935 else if (unformat (input, "bd %d", &dp_table))
13937 else if (unformat (input, "vni %d", &vni))
13939 else if (unformat (input, "w %d", &w))
13943 errmsg ("No RLOC configured for setting priority/weight!");
13946 curr_rloc->weight = w;
13948 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13949 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13953 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13955 vec_add1 (lcl_locs, rloc);
13957 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13958 vec_add1 (rmt_locs, rloc);
13959 /* weight saved in rmt loc */
13960 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13962 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13963 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13966 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13968 vec_add1 (lcl_locs, rloc);
13970 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13971 vec_add1 (rmt_locs, rloc);
13972 /* weight saved in rmt loc */
13973 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13975 else if (unformat (input, "action %d", &action))
13981 clib_warning ("parse error '%U'", format_unformat_error, input);
13988 errmsg ("remote eid addresses not set");
13992 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13994 errmsg ("eid types don't match");
13998 if (0 == rmt_locs && (u32) ~ 0 == action)
14000 errmsg ("action not set for negative mapping");
14004 /* Construct the API message */
14005 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14006 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14008 mp->is_add = is_add;
14009 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14010 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14011 mp->eid_type = rmt_eid->type;
14012 mp->dp_table = clib_host_to_net_u32 (dp_table);
14013 mp->vni = clib_host_to_net_u32 (vni);
14014 mp->rmt_len = rmt_eid->len;
14015 mp->lcl_len = lcl_eid->len;
14016 mp->action = action;
14018 if (0 != rmt_locs && 0 != lcl_locs)
14020 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14021 clib_memcpy (mp->locs, lcl_locs,
14022 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14024 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14025 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14026 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14028 vec_free (lcl_locs);
14029 vec_free (rmt_locs);
14034 /* Wait for a reply... */
14040 api_lisp_add_del_map_server (vat_main_t * vam)
14042 unformat_input_t *input = vam->input;
14043 vl_api_lisp_add_del_map_server_t *mp;
14047 ip4_address_t ipv4;
14048 ip6_address_t ipv6;
14051 /* Parse args required to build the message */
14052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14054 if (unformat (input, "del"))
14058 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14062 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14070 if (ipv4_set && ipv6_set)
14072 errmsg ("both eid v4 and v6 addresses set");
14076 if (!ipv4_set && !ipv6_set)
14078 errmsg ("eid addresses not set");
14082 /* Construct the API message */
14083 M (LISP_ADD_DEL_MAP_SERVER, mp);
14085 mp->is_add = is_add;
14089 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14094 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14100 /* Wait for a reply... */
14106 api_lisp_add_del_map_resolver (vat_main_t * vam)
14108 unformat_input_t *input = vam->input;
14109 vl_api_lisp_add_del_map_resolver_t *mp;
14113 ip4_address_t ipv4;
14114 ip6_address_t ipv6;
14117 /* Parse args required to build the message */
14118 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14120 if (unformat (input, "del"))
14124 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14128 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14136 if (ipv4_set && ipv6_set)
14138 errmsg ("both eid v4 and v6 addresses set");
14142 if (!ipv4_set && !ipv6_set)
14144 errmsg ("eid addresses not set");
14148 /* Construct the API message */
14149 M (LISP_ADD_DEL_MAP_RESOLVER, mp);
14151 mp->is_add = is_add;
14155 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14160 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14166 /* Wait for a reply... */
14172 api_lisp_gpe_enable_disable (vat_main_t * vam)
14174 unformat_input_t *input = vam->input;
14175 vl_api_gpe_enable_disable_t *mp;
14180 /* Parse args required to build the message */
14181 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14183 if (unformat (input, "enable"))
14188 else if (unformat (input, "disable"))
14199 errmsg ("Value not set");
14203 /* Construct the API message */
14204 M (GPE_ENABLE_DISABLE, mp);
14211 /* Wait for a reply... */
14217 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
14219 unformat_input_t *input = vam->input;
14220 vl_api_lisp_rloc_probe_enable_disable_t *mp;
14225 /* Parse args required to build the message */
14226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14228 if (unformat (input, "enable"))
14233 else if (unformat (input, "disable"))
14241 errmsg ("Value not set");
14245 /* Construct the API message */
14246 M (LISP_RLOC_PROBE_ENABLE_DISABLE, mp);
14248 mp->is_enabled = is_en;
14253 /* Wait for a reply... */
14259 api_lisp_map_register_enable_disable (vat_main_t * vam)
14261 unformat_input_t *input = vam->input;
14262 vl_api_lisp_map_register_enable_disable_t *mp;
14267 /* Parse args required to build the message */
14268 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14270 if (unformat (input, "enable"))
14275 else if (unformat (input, "disable"))
14283 errmsg ("Value not set");
14287 /* Construct the API message */
14288 M (LISP_MAP_REGISTER_ENABLE_DISABLE, mp);
14290 mp->is_enabled = is_en;
14295 /* Wait for a reply... */
14301 api_lisp_enable_disable (vat_main_t * vam)
14303 unformat_input_t *input = vam->input;
14304 vl_api_lisp_enable_disable_t *mp;
14309 /* Parse args required to build the message */
14310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14312 if (unformat (input, "enable"))
14317 else if (unformat (input, "disable"))
14327 errmsg ("Value not set");
14331 /* Construct the API message */
14332 M (LISP_ENABLE_DISABLE, mp);
14339 /* Wait for a reply... */
14345 api_show_lisp_map_register_state (vat_main_t * vam)
14347 vl_api_show_lisp_map_register_state_t *mp;
14350 M (SHOW_LISP_MAP_REGISTER_STATE, mp);
14355 /* wait for reply */
14361 api_show_lisp_rloc_probe_state (vat_main_t * vam)
14363 vl_api_show_lisp_rloc_probe_state_t *mp;
14366 M (SHOW_LISP_RLOC_PROBE_STATE, mp);
14371 /* wait for reply */
14377 api_show_lisp_map_request_mode (vat_main_t * vam)
14379 vl_api_show_lisp_map_request_mode_t *mp;
14382 M (SHOW_LISP_MAP_REQUEST_MODE, mp);
14387 /* wait for reply */
14393 api_lisp_map_request_mode (vat_main_t * vam)
14395 unformat_input_t *input = vam->input;
14396 vl_api_lisp_map_request_mode_t *mp;
14400 /* Parse args required to build the message */
14401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14403 if (unformat (input, "dst-only"))
14405 else if (unformat (input, "src-dst"))
14409 errmsg ("parse error '%U'", format_unformat_error, input);
14414 M (LISP_MAP_REQUEST_MODE, mp);
14421 /* wait for reply */
14427 * Enable/disable LISP proxy ITR.
14429 * @param vam vpp API test context
14430 * @return return code
14433 api_lisp_pitr_set_locator_set (vat_main_t * vam)
14435 u8 ls_name_set = 0;
14436 unformat_input_t *input = vam->input;
14437 vl_api_lisp_pitr_set_locator_set_t *mp;
14442 /* Parse args required to build the message */
14443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14445 if (unformat (input, "del"))
14447 else if (unformat (input, "locator-set %s", &ls_name))
14451 errmsg ("parse error '%U'", format_unformat_error, input);
14458 errmsg ("locator-set name not set!");
14462 M (LISP_PITR_SET_LOCATOR_SET, mp);
14464 mp->is_add = is_add;
14465 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14466 vec_free (ls_name);
14471 /* wait for reply */
14477 api_show_lisp_pitr (vat_main_t * vam)
14479 vl_api_show_lisp_pitr_t *mp;
14482 if (!vam->json_output)
14484 print (vam->ofp, "%=20s", "lisp status:");
14487 M (SHOW_LISP_PITR, mp);
14491 /* Wait for a reply... */
14497 * Add/delete mapping between vni and vrf
14500 api_lisp_eid_table_add_del_map (vat_main_t * vam)
14502 unformat_input_t *input = vam->input;
14503 vl_api_lisp_eid_table_add_del_map_t *mp;
14504 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14505 u32 vni, vrf, bd_index;
14508 /* Parse args required to build the message */
14509 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14511 if (unformat (input, "del"))
14513 else if (unformat (input, "vrf %d", &vrf))
14515 else if (unformat (input, "bd_index %d", &bd_index))
14517 else if (unformat (input, "vni %d", &vni))
14523 if (!vni_set || (!vrf_set && !bd_index_set))
14525 errmsg ("missing arguments!");
14529 if (vrf_set && bd_index_set)
14531 errmsg ("error: both vrf and bd entered!");
14535 M (LISP_EID_TABLE_ADD_DEL_MAP, mp);
14537 mp->is_add = is_add;
14538 mp->vni = htonl (vni);
14539 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14540 mp->is_l2 = bd_index_set;
14545 /* wait for reply */
14551 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14553 u32 *action = va_arg (*args, u32 *);
14556 if (unformat (input, "%s", &s))
14558 if (!strcmp ((char *) s, "no-action"))
14560 else if (!strcmp ((char *) s, "natively-forward"))
14562 else if (!strcmp ((char *) s, "send-map-request"))
14564 else if (!strcmp ((char *) s, "drop"))
14568 clib_warning ("invalid action: '%s'", s);
14580 * Add/del remote mapping to/from LISP control plane
14582 * @param vam vpp API test context
14583 * @return return code
14586 api_lisp_add_del_remote_mapping (vat_main_t * vam)
14588 unformat_input_t *input = vam->input;
14589 vl_api_lisp_add_del_remote_mapping_t *mp;
14591 lisp_eid_vat_t _eid, *eid = &_eid;
14592 lisp_eid_vat_t _seid, *seid = &_seid;
14593 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14594 u32 action = ~0, p, w, data_len;
14595 ip4_address_t rloc4;
14596 ip6_address_t rloc6;
14597 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14600 memset (&rloc, 0, sizeof (rloc));
14602 /* Parse args required to build the message */
14603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14605 if (unformat (input, "del-all"))
14609 else if (unformat (input, "del"))
14613 else if (unformat (input, "add"))
14617 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14621 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14625 else if (unformat (input, "vni %d", &vni))
14629 else if (unformat (input, "p %d w %d", &p, &w))
14633 errmsg ("No RLOC configured for setting priority/weight!");
14636 curr_rloc->priority = p;
14637 curr_rloc->weight = w;
14639 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14642 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14643 vec_add1 (rlocs, rloc);
14644 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14646 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14649 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14650 vec_add1 (rlocs, rloc);
14651 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14653 else if (unformat (input, "action %U",
14654 unformat_negative_mapping_action, &action))
14660 clib_warning ("parse error '%U'", format_unformat_error, input);
14667 errmsg ("missing params!");
14671 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14673 errmsg ("no action set for negative map-reply!");
14677 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14679 M2 (LISP_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14680 mp->is_add = is_add;
14681 mp->vni = htonl (vni);
14682 mp->action = (u8) action;
14683 mp->is_src_dst = seid_set;
14684 mp->eid_len = eid->len;
14685 mp->seid_len = seid->len;
14686 mp->del_all = del_all;
14687 mp->eid_type = eid->type;
14688 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14689 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14691 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14692 clib_memcpy (mp->rlocs, rlocs, data_len);
14698 /* Wait for a reply... */
14704 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14705 * forwarding entries in data-plane accordingly.
14707 * @param vam vpp API test context
14708 * @return return code
14711 api_lisp_add_del_adjacency (vat_main_t * vam)
14713 unformat_input_t *input = vam->input;
14714 vl_api_lisp_add_del_adjacency_t *mp;
14716 ip4_address_t leid4, reid4;
14717 ip6_address_t leid6, reid6;
14718 u8 reid_mac[6] = { 0 };
14719 u8 leid_mac[6] = { 0 };
14720 u8 reid_type, leid_type;
14721 u32 leid_len = 0, reid_len = 0, len;
14725 leid_type = reid_type = (u8) ~ 0;
14727 /* Parse args required to build the message */
14728 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14730 if (unformat (input, "del"))
14734 else if (unformat (input, "add"))
14738 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14741 reid_type = 0; /* ipv4 */
14744 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14747 reid_type = 1; /* ipv6 */
14750 else if (unformat (input, "reid %U", unformat_ethernet_address,
14753 reid_type = 2; /* mac */
14755 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14758 leid_type = 0; /* ipv4 */
14761 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14764 leid_type = 1; /* ipv6 */
14767 else if (unformat (input, "leid %U", unformat_ethernet_address,
14770 leid_type = 2; /* mac */
14772 else if (unformat (input, "vni %d", &vni))
14778 errmsg ("parse error '%U'", format_unformat_error, input);
14783 if ((u8) ~ 0 == reid_type)
14785 errmsg ("missing params!");
14789 if (leid_type != reid_type)
14791 errmsg ("remote and local EIDs are of different types!");
14795 M (LISP_ADD_DEL_ADJACENCY, mp);
14796 mp->is_add = is_add;
14797 mp->vni = htonl (vni);
14798 mp->leid_len = leid_len;
14799 mp->reid_len = reid_len;
14800 mp->eid_type = reid_type;
14802 switch (mp->eid_type)
14805 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14806 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14809 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14810 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14813 clib_memcpy (mp->leid, leid_mac, 6);
14814 clib_memcpy (mp->reid, reid_mac, 6);
14817 errmsg ("unknown EID type %d!", mp->eid_type);
14824 /* Wait for a reply... */
14830 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14832 unformat_input_t *input = vam->input;
14833 vl_api_gpe_add_del_iface_t *mp;
14834 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14835 u32 dp_table = 0, vni = 0;
14838 /* Parse args required to build the message */
14839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14841 if (unformat (input, "up"))
14846 else if (unformat (input, "down"))
14851 else if (unformat (input, "table_id %d", &dp_table))
14855 else if (unformat (input, "bd_id %d", &dp_table))
14860 else if (unformat (input, "vni %d", &vni))
14868 if (action_set == 0)
14870 errmsg ("Action not set");
14873 if (dp_table_set == 0 || vni_set == 0)
14875 errmsg ("vni and dp_table must be set");
14879 /* Construct the API message */
14880 M (GPE_ADD_DEL_IFACE, mp);
14882 mp->is_add = is_add;
14883 mp->dp_table = dp_table;
14890 /* Wait for a reply... */
14896 * Add/del map request itr rlocs from LISP control plane and updates
14898 * @param vam vpp API test context
14899 * @return return code
14902 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14904 unformat_input_t *input = vam->input;
14905 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14906 u8 *locator_set_name = 0;
14907 u8 locator_set_name_set = 0;
14911 /* Parse args required to build the message */
14912 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14914 if (unformat (input, "del"))
14918 else if (unformat (input, "%_%v%_", &locator_set_name))
14920 locator_set_name_set = 1;
14924 clib_warning ("parse error '%U'", format_unformat_error, input);
14929 if (is_add && !locator_set_name_set)
14931 errmsg ("itr-rloc is not set!");
14935 if (is_add && vec_len (locator_set_name) > 64)
14937 errmsg ("itr-rloc locator-set name too long");
14938 vec_free (locator_set_name);
14942 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14943 mp->is_add = is_add;
14946 clib_memcpy (mp->locator_set_name, locator_set_name,
14947 vec_len (locator_set_name));
14951 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14953 vec_free (locator_set_name);
14958 /* Wait for a reply... */
14964 api_lisp_locator_dump (vat_main_t * vam)
14966 unformat_input_t *input = vam->input;
14967 vl_api_lisp_locator_dump_t *mp;
14968 vl_api_control_ping_t *mp_ping;
14969 u8 is_index_set = 0, is_name_set = 0;
14974 /* Parse args required to build the message */
14975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14977 if (unformat (input, "ls_name %_%v%_", &ls_name))
14981 else if (unformat (input, "ls_index %d", &ls_index))
14987 errmsg ("parse error '%U'", format_unformat_error, input);
14992 if (!is_index_set && !is_name_set)
14994 errmsg ("error: expected one of index or name!");
14998 if (is_index_set && is_name_set)
15000 errmsg ("error: only one param expected!");
15004 if (vec_len (ls_name) > 62)
15006 errmsg ("error: locator set name too long!");
15010 if (!vam->json_output)
15012 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15015 M (LISP_LOCATOR_DUMP, mp);
15016 mp->is_index_set = is_index_set;
15019 mp->ls_index = clib_host_to_net_u32 (ls_index);
15022 vec_add1 (ls_name, 0);
15023 strncpy ((char *) mp->ls_name, (char *) ls_name,
15024 sizeof (mp->ls_name) - 1);
15030 /* Use a control ping for synchronization */
15031 M (CONTROL_PING, mp_ping);
15034 /* Wait for a reply... */
15040 api_lisp_locator_set_dump (vat_main_t * vam)
15042 vl_api_lisp_locator_set_dump_t *mp;
15043 vl_api_control_ping_t *mp_ping;
15044 unformat_input_t *input = vam->input;
15048 /* Parse args required to build the message */
15049 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15051 if (unformat (input, "local"))
15055 else if (unformat (input, "remote"))
15061 errmsg ("parse error '%U'", format_unformat_error, input);
15066 if (!vam->json_output)
15068 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15071 M (LISP_LOCATOR_SET_DUMP, mp);
15073 mp->filter = filter;
15078 /* Use a control ping for synchronization */
15079 M (CONTROL_PING, mp_ping);
15082 /* Wait for a reply... */
15088 api_lisp_eid_table_map_dump (vat_main_t * vam)
15092 unformat_input_t *input = vam->input;
15093 vl_api_lisp_eid_table_map_dump_t *mp;
15094 vl_api_control_ping_t *mp_ping;
15097 /* Parse args required to build the message */
15098 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15100 if (unformat (input, "l2"))
15105 else if (unformat (input, "l3"))
15112 errmsg ("parse error '%U'", format_unformat_error, input);
15119 errmsg ("expected one of 'l2' or 'l3' parameter!");
15123 if (!vam->json_output)
15125 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15128 M (LISP_EID_TABLE_MAP_DUMP, mp);
15134 /* Use a control ping for synchronization */
15135 M (CONTROL_PING, mp_ping);
15138 /* Wait for a reply... */
15144 api_lisp_eid_table_vni_dump (vat_main_t * vam)
15146 vl_api_lisp_eid_table_vni_dump_t *mp;
15147 vl_api_control_ping_t *mp_ping;
15150 if (!vam->json_output)
15152 print (vam->ofp, "VNI");
15155 M (LISP_EID_TABLE_VNI_DUMP, mp);
15160 /* Use a control ping for synchronization */
15161 M (CONTROL_PING, mp_ping);
15164 /* Wait for a reply... */
15170 api_lisp_eid_table_dump (vat_main_t * vam)
15172 unformat_input_t *i = vam->input;
15173 vl_api_lisp_eid_table_dump_t *mp;
15174 vl_api_control_ping_t *mp_ping;
15175 struct in_addr ip4;
15176 struct in6_addr ip6;
15178 u8 eid_type = ~0, eid_set = 0;
15179 u32 prefix_length = ~0, t, vni = 0;
15183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15185 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15191 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15197 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15202 else if (unformat (i, "vni %d", &t))
15206 else if (unformat (i, "local"))
15210 else if (unformat (i, "remote"))
15216 errmsg ("parse error '%U'", format_unformat_error, i);
15221 if (!vam->json_output)
15223 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15224 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15227 M (LISP_EID_TABLE_DUMP, mp);
15229 mp->filter = filter;
15233 mp->vni = htonl (vni);
15234 mp->eid_type = eid_type;
15238 mp->prefix_length = prefix_length;
15239 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15242 mp->prefix_length = prefix_length;
15243 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15246 clib_memcpy (mp->eid, mac, sizeof (mac));
15249 errmsg ("unknown EID type %d!", eid_type);
15257 /* Use a control ping for synchronization */
15258 M (CONTROL_PING, mp_ping);
15261 /* Wait for a reply... */
15267 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15269 unformat_input_t *i = vam->input;
15270 vl_api_gpe_fwd_entries_get_t *mp;
15275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15277 if (unformat (i, "vni %d", &vni))
15283 errmsg ("parse error '%U'", format_unformat_error, i);
15290 errmsg ("vni not set!");
15294 if (!vam->json_output)
15296 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15300 M (GPE_FWD_ENTRIES_GET, mp);
15301 mp->vni = clib_host_to_net_u32 (vni);
15306 /* Wait for a reply... */
15311 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15312 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15313 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15314 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15317 api_lisp_adjacencies_get (vat_main_t * vam)
15319 unformat_input_t *i = vam->input;
15320 vl_api_lisp_adjacencies_get_t *mp;
15325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15327 if (unformat (i, "vni %d", &vni))
15333 errmsg ("parse error '%U'", format_unformat_error, i);
15340 errmsg ("vni not set!");
15344 if (!vam->json_output)
15346 print (vam->ofp, "%s %40s", "leid", "reid");
15349 M (LISP_ADJACENCIES_GET, mp);
15350 mp->vni = clib_host_to_net_u32 (vni);
15355 /* Wait for a reply... */
15361 api_lisp_map_server_dump (vat_main_t * vam)
15363 vl_api_lisp_map_server_dump_t *mp;
15364 vl_api_control_ping_t *mp_ping;
15367 if (!vam->json_output)
15369 print (vam->ofp, "%=20s", "Map server");
15372 M (LISP_MAP_SERVER_DUMP, mp);
15376 /* Use a control ping for synchronization */
15377 M (CONTROL_PING, mp_ping);
15380 /* Wait for a reply... */
15386 api_lisp_map_resolver_dump (vat_main_t * vam)
15388 vl_api_lisp_map_resolver_dump_t *mp;
15389 vl_api_control_ping_t *mp_ping;
15392 if (!vam->json_output)
15394 print (vam->ofp, "%=20s", "Map resolver");
15397 M (LISP_MAP_RESOLVER_DUMP, mp);
15401 /* Use a control ping for synchronization */
15402 M (CONTROL_PING, mp_ping);
15405 /* Wait for a reply... */
15411 api_show_lisp_status (vat_main_t * vam)
15413 vl_api_show_lisp_status_t *mp;
15416 if (!vam->json_output)
15418 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
15421 M (SHOW_LISP_STATUS, mp);
15424 /* Wait for a reply... */
15430 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15432 vl_api_gpe_fwd_entry_path_dump_t *mp;
15433 vl_api_control_ping_t *mp_ping;
15434 unformat_input_t *i = vam->input;
15435 u32 fwd_entry_index = ~0;
15438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15440 if (unformat (i, "index %d", &fwd_entry_index))
15446 if (~0 == fwd_entry_index)
15448 errmsg ("no index specified!");
15452 if (!vam->json_output)
15454 print (vam->ofp, "first line");
15457 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15461 /* Use a control ping for synchronization */
15462 M (CONTROL_PING, mp_ping);
15465 /* Wait for a reply... */
15471 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
15473 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
15476 if (!vam->json_output)
15478 print (vam->ofp, "%=20s", "itr-rlocs:");
15481 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, mp);
15484 /* Wait for a reply... */
15490 api_af_packet_create (vat_main_t * vam)
15492 unformat_input_t *i = vam->input;
15493 vl_api_af_packet_create_t *mp;
15494 u8 *host_if_name = 0;
15496 u8 random_hw_addr = 1;
15499 memset (hw_addr, 0, sizeof (hw_addr));
15501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15503 if (unformat (i, "name %s", &host_if_name))
15504 vec_add1 (host_if_name, 0);
15505 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15506 random_hw_addr = 0;
15511 if (!vec_len (host_if_name))
15513 errmsg ("host-interface name must be specified");
15517 if (vec_len (host_if_name) > 64)
15519 errmsg ("host-interface name too long");
15523 M (AF_PACKET_CREATE, mp);
15525 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15526 clib_memcpy (mp->hw_addr, hw_addr, 6);
15527 mp->use_random_hw_addr = random_hw_addr;
15528 vec_free (host_if_name);
15531 W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15536 api_af_packet_delete (vat_main_t * vam)
15538 unformat_input_t *i = vam->input;
15539 vl_api_af_packet_delete_t *mp;
15540 u8 *host_if_name = 0;
15543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15545 if (unformat (i, "name %s", &host_if_name))
15546 vec_add1 (host_if_name, 0);
15551 if (!vec_len (host_if_name))
15553 errmsg ("host-interface name must be specified");
15557 if (vec_len (host_if_name) > 64)
15559 errmsg ("host-interface name too long");
15563 M (AF_PACKET_DELETE, mp);
15565 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15566 vec_free (host_if_name);
15574 api_policer_add_del (vat_main_t * vam)
15576 unformat_input_t *i = vam->input;
15577 vl_api_policer_add_del_t *mp;
15587 u8 color_aware = 0;
15588 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15591 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15592 conform_action.dscp = 0;
15593 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15594 exceed_action.dscp = 0;
15595 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15596 violate_action.dscp = 0;
15598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15600 if (unformat (i, "del"))
15602 else if (unformat (i, "name %s", &name))
15603 vec_add1 (name, 0);
15604 else if (unformat (i, "cir %u", &cir))
15606 else if (unformat (i, "eir %u", &eir))
15608 else if (unformat (i, "cb %u", &cb))
15610 else if (unformat (i, "eb %u", &eb))
15612 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15615 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15618 else if (unformat (i, "type %U", unformat_policer_type, &type))
15620 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15623 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15626 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15629 else if (unformat (i, "color-aware"))
15635 if (!vec_len (name))
15637 errmsg ("policer name must be specified");
15641 if (vec_len (name) > 64)
15643 errmsg ("policer name too long");
15647 M (POLICER_ADD_DEL, mp);
15649 clib_memcpy (mp->name, name, vec_len (name));
15651 mp->is_add = is_add;
15656 mp->rate_type = rate_type;
15657 mp->round_type = round_type;
15659 mp->conform_action_type = conform_action.action_type;
15660 mp->conform_dscp = conform_action.dscp;
15661 mp->exceed_action_type = exceed_action.action_type;
15662 mp->exceed_dscp = exceed_action.dscp;
15663 mp->violate_action_type = violate_action.action_type;
15664 mp->violate_dscp = violate_action.dscp;
15665 mp->color_aware = color_aware;
15673 api_policer_dump (vat_main_t * vam)
15675 unformat_input_t *i = vam->input;
15676 vl_api_policer_dump_t *mp;
15677 vl_api_control_ping_t *mp_ping;
15678 u8 *match_name = 0;
15679 u8 match_name_valid = 0;
15682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15684 if (unformat (i, "name %s", &match_name))
15686 vec_add1 (match_name, 0);
15687 match_name_valid = 1;
15693 M (POLICER_DUMP, mp);
15694 mp->match_name_valid = match_name_valid;
15695 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15696 vec_free (match_name);
15700 /* Use a control ping for synchronization */
15701 M (CONTROL_PING, mp_ping);
15704 /* Wait for a reply... */
15710 api_policer_classify_set_interface (vat_main_t * vam)
15712 unformat_input_t *i = vam->input;
15713 vl_api_policer_classify_set_interface_t *mp;
15715 int sw_if_index_set;
15716 u32 ip4_table_index = ~0;
15717 u32 ip6_table_index = ~0;
15718 u32 l2_table_index = ~0;
15722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15724 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15725 sw_if_index_set = 1;
15726 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15727 sw_if_index_set = 1;
15728 else if (unformat (i, "del"))
15730 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15732 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15734 else if (unformat (i, "l2-table %d", &l2_table_index))
15738 clib_warning ("parse error '%U'", format_unformat_error, i);
15743 if (sw_if_index_set == 0)
15745 errmsg ("missing interface name or sw_if_index");
15749 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15751 mp->sw_if_index = ntohl (sw_if_index);
15752 mp->ip4_table_index = ntohl (ip4_table_index);
15753 mp->ip6_table_index = ntohl (ip6_table_index);
15754 mp->l2_table_index = ntohl (l2_table_index);
15755 mp->is_add = is_add;
15763 api_policer_classify_dump (vat_main_t * vam)
15765 unformat_input_t *i = vam->input;
15766 vl_api_policer_classify_dump_t *mp;
15767 vl_api_control_ping_t *mp_ping;
15768 u8 type = POLICER_CLASSIFY_N_TABLES;
15771 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15775 errmsg ("classify table type must be specified");
15779 if (!vam->json_output)
15781 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15784 M (POLICER_CLASSIFY_DUMP, mp);
15789 /* Use a control ping for synchronization */
15790 M (CONTROL_PING, mp_ping);
15793 /* Wait for a reply... */
15799 api_netmap_create (vat_main_t * vam)
15801 unformat_input_t *i = vam->input;
15802 vl_api_netmap_create_t *mp;
15805 u8 random_hw_addr = 1;
15810 memset (hw_addr, 0, sizeof (hw_addr));
15812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15814 if (unformat (i, "name %s", &if_name))
15815 vec_add1 (if_name, 0);
15816 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15817 random_hw_addr = 0;
15818 else if (unformat (i, "pipe"))
15820 else if (unformat (i, "master"))
15822 else if (unformat (i, "slave"))
15828 if (!vec_len (if_name))
15830 errmsg ("interface name must be specified");
15834 if (vec_len (if_name) > 64)
15836 errmsg ("interface name too long");
15840 M (NETMAP_CREATE, mp);
15842 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15843 clib_memcpy (mp->hw_addr, hw_addr, 6);
15844 mp->use_random_hw_addr = random_hw_addr;
15845 mp->is_pipe = is_pipe;
15846 mp->is_master = is_master;
15847 vec_free (if_name);
15855 api_netmap_delete (vat_main_t * vam)
15857 unformat_input_t *i = vam->input;
15858 vl_api_netmap_delete_t *mp;
15862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15864 if (unformat (i, "name %s", &if_name))
15865 vec_add1 (if_name, 0);
15870 if (!vec_len (if_name))
15872 errmsg ("interface name must be specified");
15876 if (vec_len (if_name) > 64)
15878 errmsg ("interface name too long");
15882 M (NETMAP_DELETE, mp);
15884 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15885 vec_free (if_name);
15892 static void vl_api_mpls_tunnel_details_t_handler
15893 (vl_api_mpls_tunnel_details_t * mp)
15895 vat_main_t *vam = &vat_main;
15896 i32 len = mp->mt_next_hop_n_labels;
15899 print (vam->ofp, "[%d]: via %U %d labels ",
15901 format_ip4_address, mp->mt_next_hop,
15902 ntohl (mp->mt_next_hop_sw_if_index));
15903 for (i = 0; i < len; i++)
15905 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15907 print (vam->ofp, "");
15910 static void vl_api_mpls_tunnel_details_t_handler_json
15911 (vl_api_mpls_tunnel_details_t * mp)
15913 vat_main_t *vam = &vat_main;
15914 vat_json_node_t *node = NULL;
15915 struct in_addr ip4;
15917 i32 len = mp->mt_next_hop_n_labels;
15919 if (VAT_JSON_ARRAY != vam->json_tree.type)
15921 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15922 vat_json_init_array (&vam->json_tree);
15924 node = vat_json_array_add (&vam->json_tree);
15926 vat_json_init_object (node);
15927 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15928 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15929 vat_json_object_add_ip4 (node, "next_hop", ip4);
15930 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15931 ntohl (mp->mt_next_hop_sw_if_index));
15932 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15933 vat_json_object_add_uint (node, "label_count", len);
15934 for (i = 0; i < len; i++)
15936 vat_json_object_add_uint (node, "label",
15937 ntohl (mp->mt_next_hop_out_labels[i]));
15942 api_mpls_tunnel_dump (vat_main_t * vam)
15944 vl_api_mpls_tunnel_dump_t *mp;
15945 vl_api_control_ping_t *mp_ping;
15949 /* Parse args required to build the message */
15950 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15952 if (!unformat (vam->input, "tunnel_index %d", &index))
15959 print (vam->ofp, " tunnel_index %d", index);
15961 M (MPLS_TUNNEL_DUMP, mp);
15962 mp->tunnel_index = htonl (index);
15965 /* Use a control ping for synchronization */
15966 M (CONTROL_PING, mp_ping);
15973 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15974 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15977 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15979 vat_main_t *vam = &vat_main;
15980 int count = ntohl (mp->count);
15981 vl_api_fib_path2_t *fp;
15985 "table-id %d, label %u, ess_bit %u",
15986 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15988 for (i = 0; i < count; i++)
15990 if (fp->afi == IP46_TYPE_IP6)
15992 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15993 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15994 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15995 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15996 format_ip6_address, fp->next_hop);
15997 else if (fp->afi == IP46_TYPE_IP4)
15999 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16000 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16001 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16002 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16003 format_ip4_address, fp->next_hop);
16008 static void vl_api_mpls_fib_details_t_handler_json
16009 (vl_api_mpls_fib_details_t * mp)
16011 vat_main_t *vam = &vat_main;
16012 int count = ntohl (mp->count);
16013 vat_json_node_t *node = NULL;
16014 struct in_addr ip4;
16015 struct in6_addr ip6;
16016 vl_api_fib_path2_t *fp;
16019 if (VAT_JSON_ARRAY != vam->json_tree.type)
16021 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16022 vat_json_init_array (&vam->json_tree);
16024 node = vat_json_array_add (&vam->json_tree);
16026 vat_json_init_object (node);
16027 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16028 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16029 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16030 vat_json_object_add_uint (node, "path_count", count);
16032 for (i = 0; i < count; i++)
16034 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16035 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16036 vat_json_object_add_uint (node, "is_local", fp->is_local);
16037 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16038 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16039 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16040 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16041 if (fp->afi == IP46_TYPE_IP4)
16043 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16044 vat_json_object_add_ip4 (node, "next_hop", ip4);
16046 else if (fp->afi == IP46_TYPE_IP6)
16048 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16049 vat_json_object_add_ip6 (node, "next_hop", ip6);
16055 api_mpls_fib_dump (vat_main_t * vam)
16057 vl_api_mpls_fib_dump_t *mp;
16058 vl_api_control_ping_t *mp_ping;
16061 M (MPLS_FIB_DUMP, mp);
16064 /* Use a control ping for synchronization */
16065 M (CONTROL_PING, mp_ping);
16072 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16073 #define vl_api_ip_fib_details_t_print vl_noop_handler
16076 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16078 vat_main_t *vam = &vat_main;
16079 int count = ntohl (mp->count);
16080 vl_api_fib_path_t *fp;
16084 "table-id %d, prefix %U/%d",
16085 ntohl (mp->table_id), format_ip4_address, mp->address,
16086 mp->address_length);
16088 for (i = 0; i < count; i++)
16090 if (fp->afi == IP46_TYPE_IP6)
16092 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16093 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16094 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16095 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16096 format_ip6_address, fp->next_hop);
16097 else if (fp->afi == IP46_TYPE_IP4)
16099 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16100 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16101 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16102 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16103 format_ip4_address, fp->next_hop);
16108 static void vl_api_ip_fib_details_t_handler_json
16109 (vl_api_ip_fib_details_t * mp)
16111 vat_main_t *vam = &vat_main;
16112 int count = ntohl (mp->count);
16113 vat_json_node_t *node = NULL;
16114 struct in_addr ip4;
16115 struct in6_addr ip6;
16116 vl_api_fib_path_t *fp;
16119 if (VAT_JSON_ARRAY != vam->json_tree.type)
16121 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16122 vat_json_init_array (&vam->json_tree);
16124 node = vat_json_array_add (&vam->json_tree);
16126 vat_json_init_object (node);
16127 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16128 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16129 vat_json_object_add_ip4 (node, "prefix", ip4);
16130 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16131 vat_json_object_add_uint (node, "path_count", count);
16133 for (i = 0; i < count; i++)
16135 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16136 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16137 vat_json_object_add_uint (node, "is_local", fp->is_local);
16138 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16139 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16140 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16141 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16142 if (fp->afi == IP46_TYPE_IP4)
16144 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16145 vat_json_object_add_ip4 (node, "next_hop", ip4);
16147 else if (fp->afi == IP46_TYPE_IP6)
16149 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16150 vat_json_object_add_ip6 (node, "next_hop", ip6);
16156 api_ip_fib_dump (vat_main_t * vam)
16158 vl_api_ip_fib_dump_t *mp;
16159 vl_api_control_ping_t *mp_ping;
16162 M (IP_FIB_DUMP, mp);
16165 /* Use a control ping for synchronization */
16166 M (CONTROL_PING, mp_ping);
16174 api_ip_mfib_dump (vat_main_t * vam)
16176 vl_api_ip_mfib_dump_t *mp;
16177 vl_api_control_ping_t *mp_ping;
16180 M (IP_MFIB_DUMP, mp);
16183 /* Use a control ping for synchronization */
16184 M (CONTROL_PING, mp_ping);
16191 static void vl_api_ip_neighbor_details_t_handler
16192 (vl_api_ip_neighbor_details_t * mp)
16194 vat_main_t *vam = &vat_main;
16196 print (vam->ofp, "%c %U %U",
16197 (mp->is_static) ? 'S' : 'D',
16198 format_ethernet_address, &mp->mac_address,
16199 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16203 static void vl_api_ip_neighbor_details_t_handler_json
16204 (vl_api_ip_neighbor_details_t * mp)
16207 vat_main_t *vam = &vat_main;
16208 vat_json_node_t *node;
16209 struct in_addr ip4;
16210 struct in6_addr ip6;
16212 if (VAT_JSON_ARRAY != vam->json_tree.type)
16214 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16215 vat_json_init_array (&vam->json_tree);
16217 node = vat_json_array_add (&vam->json_tree);
16219 vat_json_init_object (node);
16220 vat_json_object_add_string_copy (node, "flag",
16221 (mp->is_static) ? (u8 *) "static" : (u8 *)
16224 vat_json_object_add_string_copy (node, "link_layer",
16225 format (0, "%U", format_ethernet_address,
16226 &mp->mac_address));
16230 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16231 vat_json_object_add_ip6 (node, "ip_address", ip6);
16235 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16236 vat_json_object_add_ip4 (node, "ip_address", ip4);
16241 api_ip_neighbor_dump (vat_main_t * vam)
16243 unformat_input_t *i = vam->input;
16244 vl_api_ip_neighbor_dump_t *mp;
16245 vl_api_control_ping_t *mp_ping;
16247 u32 sw_if_index = ~0;
16250 /* Parse args required to build the message */
16251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16253 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16255 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16257 else if (unformat (i, "ip6"))
16263 if (sw_if_index == ~0)
16265 errmsg ("missing interface name or sw_if_index");
16269 M (IP_NEIGHBOR_DUMP, mp);
16270 mp->is_ipv6 = (u8) is_ipv6;
16271 mp->sw_if_index = ntohl (sw_if_index);
16274 /* Use a control ping for synchronization */
16275 M (CONTROL_PING, mp_ping);
16282 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16283 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16286 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16288 vat_main_t *vam = &vat_main;
16289 int count = ntohl (mp->count);
16290 vl_api_fib_path_t *fp;
16294 "table-id %d, prefix %U/%d",
16295 ntohl (mp->table_id), format_ip6_address, mp->address,
16296 mp->address_length);
16298 for (i = 0; i < count; i++)
16300 if (fp->afi == IP46_TYPE_IP6)
16302 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16303 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16304 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16305 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16306 format_ip6_address, fp->next_hop);
16307 else if (fp->afi == IP46_TYPE_IP4)
16309 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16310 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16311 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16312 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16313 format_ip4_address, fp->next_hop);
16318 static void vl_api_ip6_fib_details_t_handler_json
16319 (vl_api_ip6_fib_details_t * mp)
16321 vat_main_t *vam = &vat_main;
16322 int count = ntohl (mp->count);
16323 vat_json_node_t *node = NULL;
16324 struct in_addr ip4;
16325 struct in6_addr ip6;
16326 vl_api_fib_path_t *fp;
16329 if (VAT_JSON_ARRAY != vam->json_tree.type)
16331 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16332 vat_json_init_array (&vam->json_tree);
16334 node = vat_json_array_add (&vam->json_tree);
16336 vat_json_init_object (node);
16337 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16338 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16339 vat_json_object_add_ip6 (node, "prefix", ip6);
16340 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16341 vat_json_object_add_uint (node, "path_count", count);
16343 for (i = 0; i < count; i++)
16345 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16346 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16347 vat_json_object_add_uint (node, "is_local", fp->is_local);
16348 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16349 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16350 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16351 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16352 if (fp->afi == IP46_TYPE_IP4)
16354 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16355 vat_json_object_add_ip4 (node, "next_hop", ip4);
16357 else if (fp->afi == IP46_TYPE_IP6)
16359 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16360 vat_json_object_add_ip6 (node, "next_hop", ip6);
16366 api_ip6_fib_dump (vat_main_t * vam)
16368 vl_api_ip6_fib_dump_t *mp;
16369 vl_api_control_ping_t *mp_ping;
16372 M (IP6_FIB_DUMP, mp);
16375 /* Use a control ping for synchronization */
16376 M (CONTROL_PING, mp_ping);
16384 api_ip6_mfib_dump (vat_main_t * vam)
16386 vl_api_ip6_mfib_dump_t *mp;
16387 vl_api_control_ping_t *mp_ping;
16390 M (IP6_MFIB_DUMP, mp);
16393 /* Use a control ping for synchronization */
16394 M (CONTROL_PING, mp_ping);
16402 api_classify_table_ids (vat_main_t * vam)
16404 vl_api_classify_table_ids_t *mp;
16407 /* Construct the API message */
16408 M (CLASSIFY_TABLE_IDS, mp);
16417 api_classify_table_by_interface (vat_main_t * vam)
16419 unformat_input_t *input = vam->input;
16420 vl_api_classify_table_by_interface_t *mp;
16422 u32 sw_if_index = ~0;
16424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16426 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16428 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16433 if (sw_if_index == ~0)
16435 errmsg ("missing interface name or sw_if_index");
16439 /* Construct the API message */
16440 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16442 mp->sw_if_index = ntohl (sw_if_index);
16450 api_classify_table_info (vat_main_t * vam)
16452 unformat_input_t *input = vam->input;
16453 vl_api_classify_table_info_t *mp;
16457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16459 if (unformat (input, "table_id %d", &table_id))
16464 if (table_id == ~0)
16466 errmsg ("missing table id");
16470 /* Construct the API message */
16471 M (CLASSIFY_TABLE_INFO, mp);
16473 mp->table_id = ntohl (table_id);
16481 api_classify_session_dump (vat_main_t * vam)
16483 unformat_input_t *input = vam->input;
16484 vl_api_classify_session_dump_t *mp;
16485 vl_api_control_ping_t *mp_ping;
16489 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16491 if (unformat (input, "table_id %d", &table_id))
16496 if (table_id == ~0)
16498 errmsg ("missing table id");
16502 /* Construct the API message */
16503 M (CLASSIFY_SESSION_DUMP, mp);
16505 mp->table_id = ntohl (table_id);
16508 /* Use a control ping for synchronization */
16509 M (CONTROL_PING, mp_ping);
16517 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16519 vat_main_t *vam = &vat_main;
16521 print (vam->ofp, "collector_address %U, collector_port %d, "
16522 "src_address %U, vrf_id %d, path_mtu %u, "
16523 "template_interval %u, udp_checksum %d",
16524 format_ip4_address, mp->collector_address,
16525 ntohs (mp->collector_port),
16526 format_ip4_address, mp->src_address,
16527 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16528 ntohl (mp->template_interval), mp->udp_checksum);
16531 vam->result_ready = 1;
16535 vl_api_ipfix_exporter_details_t_handler_json
16536 (vl_api_ipfix_exporter_details_t * mp)
16538 vat_main_t *vam = &vat_main;
16539 vat_json_node_t node;
16540 struct in_addr collector_address;
16541 struct in_addr src_address;
16543 vat_json_init_object (&node);
16544 clib_memcpy (&collector_address, &mp->collector_address,
16545 sizeof (collector_address));
16546 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16547 vat_json_object_add_uint (&node, "collector_port",
16548 ntohs (mp->collector_port));
16549 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16550 vat_json_object_add_ip4 (&node, "src_address", src_address);
16551 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16552 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16553 vat_json_object_add_uint (&node, "template_interval",
16554 ntohl (mp->template_interval));
16555 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16557 vat_json_print (vam->ofp, &node);
16558 vat_json_free (&node);
16560 vam->result_ready = 1;
16564 api_ipfix_exporter_dump (vat_main_t * vam)
16566 vl_api_ipfix_exporter_dump_t *mp;
16569 /* Construct the API message */
16570 M (IPFIX_EXPORTER_DUMP, mp);
16579 api_ipfix_classify_stream_dump (vat_main_t * vam)
16581 vl_api_ipfix_classify_stream_dump_t *mp;
16584 /* Construct the API message */
16585 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16596 vl_api_ipfix_classify_stream_details_t_handler
16597 (vl_api_ipfix_classify_stream_details_t * mp)
16599 vat_main_t *vam = &vat_main;
16600 print (vam->ofp, "domain_id %d, src_port %d",
16601 ntohl (mp->domain_id), ntohs (mp->src_port));
16603 vam->result_ready = 1;
16607 vl_api_ipfix_classify_stream_details_t_handler_json
16608 (vl_api_ipfix_classify_stream_details_t * mp)
16610 vat_main_t *vam = &vat_main;
16611 vat_json_node_t node;
16613 vat_json_init_object (&node);
16614 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16615 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16617 vat_json_print (vam->ofp, &node);
16618 vat_json_free (&node);
16620 vam->result_ready = 1;
16624 api_ipfix_classify_table_dump (vat_main_t * vam)
16626 vl_api_ipfix_classify_table_dump_t *mp;
16627 vl_api_control_ping_t *mp_ping;
16630 if (!vam->json_output)
16632 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16633 "transport_protocol");
16636 /* Construct the API message */
16637 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16642 /* Use a control ping for synchronization */
16643 M (CONTROL_PING, mp_ping);
16651 vl_api_ipfix_classify_table_details_t_handler
16652 (vl_api_ipfix_classify_table_details_t * mp)
16654 vat_main_t *vam = &vat_main;
16655 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16656 mp->transport_protocol);
16660 vl_api_ipfix_classify_table_details_t_handler_json
16661 (vl_api_ipfix_classify_table_details_t * mp)
16663 vat_json_node_t *node = NULL;
16664 vat_main_t *vam = &vat_main;
16666 if (VAT_JSON_ARRAY != vam->json_tree.type)
16668 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16669 vat_json_init_array (&vam->json_tree);
16672 node = vat_json_array_add (&vam->json_tree);
16673 vat_json_init_object (node);
16675 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16676 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16677 vat_json_object_add_uint (node, "transport_protocol",
16678 mp->transport_protocol);
16682 api_sw_interface_span_enable_disable (vat_main_t * vam)
16684 unformat_input_t *i = vam->input;
16685 vl_api_sw_interface_span_enable_disable_t *mp;
16686 u32 src_sw_if_index = ~0;
16687 u32 dst_sw_if_index = ~0;
16691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16694 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16696 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16700 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16702 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16704 else if (unformat (i, "disable"))
16706 else if (unformat (i, "rx"))
16708 else if (unformat (i, "tx"))
16710 else if (unformat (i, "both"))
16716 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16718 mp->sw_if_index_from = htonl (src_sw_if_index);
16719 mp->sw_if_index_to = htonl (dst_sw_if_index);
16728 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16731 vat_main_t *vam = &vat_main;
16732 u8 *sw_if_from_name = 0;
16733 u8 *sw_if_to_name = 0;
16734 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16735 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16736 char *states[] = { "none", "rx", "tx", "both" };
16740 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16742 if ((u32) p->value[0] == sw_if_index_from)
16744 sw_if_from_name = (u8 *)(p->key);
16748 if ((u32) p->value[0] == sw_if_index_to)
16750 sw_if_to_name = (u8 *)(p->key);
16751 if (sw_if_from_name)
16756 print (vam->ofp, "%20s => %20s (%s)",
16757 sw_if_from_name, sw_if_to_name, states[mp->state]);
16761 vl_api_sw_interface_span_details_t_handler_json
16762 (vl_api_sw_interface_span_details_t * mp)
16764 vat_main_t *vam = &vat_main;
16765 vat_json_node_t *node = NULL;
16766 u8 *sw_if_from_name = 0;
16767 u8 *sw_if_to_name = 0;
16768 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16769 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16773 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16775 if ((u32) p->value[0] == sw_if_index_from)
16777 sw_if_from_name = (u8 *)(p->key);
16781 if ((u32) p->value[0] == sw_if_index_to)
16783 sw_if_to_name = (u8 *)(p->key);
16784 if (sw_if_from_name)
16790 if (VAT_JSON_ARRAY != vam->json_tree.type)
16792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16793 vat_json_init_array (&vam->json_tree);
16795 node = vat_json_array_add (&vam->json_tree);
16797 vat_json_init_object (node);
16798 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16799 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16800 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16801 if (0 != sw_if_to_name)
16803 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16805 vat_json_object_add_uint (node, "state", mp->state);
16809 api_sw_interface_span_dump (vat_main_t * vam)
16811 vl_api_sw_interface_span_dump_t *mp;
16812 vl_api_control_ping_t *mp_ping;
16815 M (SW_INTERFACE_SPAN_DUMP, mp);
16818 /* Use a control ping for synchronization */
16819 M (CONTROL_PING, mp_ping);
16827 api_pg_create_interface (vat_main_t * vam)
16829 unformat_input_t *input = vam->input;
16830 vl_api_pg_create_interface_t *mp;
16834 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16836 if (unformat (input, "if_id %d", &if_id))
16843 errmsg ("missing pg interface index");
16847 /* Construct the API message */
16848 M (PG_CREATE_INTERFACE, mp);
16850 mp->interface_id = ntohl (if_id);
16858 api_pg_capture (vat_main_t * vam)
16860 unformat_input_t *input = vam->input;
16861 vl_api_pg_capture_t *mp;
16866 u8 pcap_file_set = 0;
16869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16871 if (unformat (input, "if_id %d", &if_id))
16873 else if (unformat (input, "pcap %s", &pcap_file))
16875 else if (unformat (input, "count %d", &count))
16877 else if (unformat (input, "disable"))
16884 errmsg ("missing pg interface index");
16887 if (pcap_file_set > 0)
16889 if (vec_len (pcap_file) > 255)
16891 errmsg ("pcap file name is too long");
16896 u32 name_len = vec_len (pcap_file);
16897 /* Construct the API message */
16898 M (PG_CAPTURE, mp);
16900 mp->interface_id = ntohl (if_id);
16901 mp->is_enabled = enable;
16902 mp->count = ntohl (count);
16903 mp->pcap_name_length = ntohl (name_len);
16904 if (pcap_file_set != 0)
16906 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16908 vec_free (pcap_file);
16916 api_pg_enable_disable (vat_main_t * vam)
16918 unformat_input_t *input = vam->input;
16919 vl_api_pg_enable_disable_t *mp;
16922 u8 stream_name_set = 0;
16923 u8 *stream_name = 0;
16925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16927 if (unformat (input, "stream %s", &stream_name))
16928 stream_name_set = 1;
16929 else if (unformat (input, "disable"))
16935 if (stream_name_set > 0)
16937 if (vec_len (stream_name) > 255)
16939 errmsg ("stream name too long");
16944 u32 name_len = vec_len (stream_name);
16945 /* Construct the API message */
16946 M (PG_ENABLE_DISABLE, mp);
16948 mp->is_enabled = enable;
16949 if (stream_name_set != 0)
16951 mp->stream_name_length = ntohl (name_len);
16952 clib_memcpy (mp->stream_name, stream_name, name_len);
16954 vec_free (stream_name);
16962 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16964 unformat_input_t *input = vam->input;
16965 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16967 u16 *low_ports = 0;
16968 u16 *high_ports = 0;
16971 ip4_address_t ip4_addr;
16972 ip6_address_t ip6_addr;
16981 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16983 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16989 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16994 else if (unformat (input, "vrf %d", &vrf_id))
16996 else if (unformat (input, "del"))
16998 else if (unformat (input, "port %d", &tmp))
17000 if (tmp == 0 || tmp > 65535)
17002 errmsg ("port %d out of range", tmp);
17006 this_hi = this_low + 1;
17007 vec_add1 (low_ports, this_low);
17008 vec_add1 (high_ports, this_hi);
17010 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17012 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17014 errmsg ("incorrect range parameters");
17018 /* Note: in debug CLI +1 is added to high before
17019 passing to real fn that does "the work"
17020 (ip_source_and_port_range_check_add_del).
17021 This fn is a wrapper around the binary API fn a
17022 control plane will call, which expects this increment
17023 to have occurred. Hence letting the binary API control
17024 plane fn do the increment for consistency between VAT
17025 and other control planes.
17028 vec_add1 (low_ports, this_low);
17029 vec_add1 (high_ports, this_hi);
17035 if (prefix_set == 0)
17037 errmsg ("<address>/<mask> not specified");
17043 errmsg ("VRF ID required, not specified");
17050 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17054 if (vec_len (low_ports) == 0)
17056 errmsg ("At least one port or port range required");
17060 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17062 mp->is_add = is_add;
17067 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17072 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17075 mp->mask_length = length;
17076 mp->number_of_ranges = vec_len (low_ports);
17078 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17079 vec_free (low_ports);
17081 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17082 vec_free (high_ports);
17084 mp->vrf_id = ntohl (vrf_id);
17092 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17094 unformat_input_t *input = vam->input;
17095 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17096 u32 sw_if_index = ~0;
17098 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17099 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17103 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17105 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17107 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17109 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17111 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17113 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17115 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17117 else if (unformat (input, "del"))
17123 if (sw_if_index == ~0)
17125 errmsg ("Interface required but not specified");
17131 errmsg ("VRF ID required but not specified");
17135 if (tcp_out_vrf_id == 0
17136 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17139 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17143 /* Construct the API message */
17144 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17146 mp->sw_if_index = ntohl (sw_if_index);
17147 mp->is_add = is_add;
17148 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17149 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17150 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17151 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17156 /* Wait for a reply... */
17162 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17164 unformat_input_t *i = vam->input;
17165 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17166 u32 local_sa_id = 0;
17167 u32 remote_sa_id = 0;
17168 ip4_address_t src_address;
17169 ip4_address_t dst_address;
17173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17175 if (unformat (i, "local_sa %d", &local_sa_id))
17177 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17179 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17181 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17183 else if (unformat (i, "del"))
17187 clib_warning ("parse error '%U'", format_unformat_error, i);
17192 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17194 mp->local_sa_id = ntohl (local_sa_id);
17195 mp->remote_sa_id = ntohl (remote_sa_id);
17196 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17197 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17198 mp->is_add = is_add;
17206 api_punt (vat_main_t * vam)
17208 unformat_input_t *i = vam->input;
17216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17218 if (unformat (i, "ip %d", &ipv))
17220 else if (unformat (i, "protocol %d", &protocol))
17222 else if (unformat (i, "port %d", &port))
17224 else if (unformat (i, "del"))
17228 clib_warning ("parse error '%U'", format_unformat_error, i);
17235 mp->is_add = (u8) is_add;
17236 mp->ipv = (u8) ipv;
17237 mp->l4_protocol = (u8) protocol;
17238 mp->l4_port = htons ((u16) port);
17245 static void vl_api_ipsec_gre_tunnel_details_t_handler
17246 (vl_api_ipsec_gre_tunnel_details_t * mp)
17248 vat_main_t *vam = &vat_main;
17250 print (vam->ofp, "%11d%15U%15U%14d%14d",
17251 ntohl (mp->sw_if_index),
17252 format_ip4_address, &mp->src_address,
17253 format_ip4_address, &mp->dst_address,
17254 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17257 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17258 (vl_api_ipsec_gre_tunnel_details_t * mp)
17260 vat_main_t *vam = &vat_main;
17261 vat_json_node_t *node = NULL;
17262 struct in_addr ip4;
17264 if (VAT_JSON_ARRAY != vam->json_tree.type)
17266 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17267 vat_json_init_array (&vam->json_tree);
17269 node = vat_json_array_add (&vam->json_tree);
17271 vat_json_init_object (node);
17272 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17273 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17274 vat_json_object_add_ip4 (node, "src_address", ip4);
17275 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17276 vat_json_object_add_ip4 (node, "dst_address", ip4);
17277 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17278 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17282 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17284 unformat_input_t *i = vam->input;
17285 vl_api_ipsec_gre_tunnel_dump_t *mp;
17286 vl_api_control_ping_t *mp_ping;
17288 u8 sw_if_index_set = 0;
17291 /* Parse args required to build the message */
17292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17294 if (unformat (i, "sw_if_index %d", &sw_if_index))
17295 sw_if_index_set = 1;
17300 if (sw_if_index_set == 0)
17305 if (!vam->json_output)
17307 print (vam->ofp, "%11s%15s%15s%14s%14s",
17308 "sw_if_index", "src_address", "dst_address",
17309 "local_sa_id", "remote_sa_id");
17312 /* Get list of gre-tunnel interfaces */
17313 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17315 mp->sw_if_index = htonl (sw_if_index);
17319 /* Use a control ping for synchronization */
17320 M (CONTROL_PING, mp_ping);
17328 api_delete_subif (vat_main_t * vam)
17330 unformat_input_t *i = vam->input;
17331 vl_api_delete_subif_t *mp;
17332 u32 sw_if_index = ~0;
17335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17339 if (unformat (i, "sw_if_index %d", &sw_if_index))
17345 if (sw_if_index == ~0)
17347 errmsg ("missing sw_if_index");
17351 /* Construct the API message */
17352 M (DELETE_SUBIF, mp);
17353 mp->sw_if_index = ntohl (sw_if_index);
17360 #define foreach_pbb_vtr_op \
17361 _("disable", L2_VTR_DISABLED) \
17362 _("pop", L2_VTR_POP_2) \
17363 _("push", L2_VTR_PUSH_2)
17366 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17368 unformat_input_t *i = vam->input;
17369 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17370 u32 sw_if_index = ~0, vtr_op = ~0;
17371 u16 outer_tag = ~0;
17372 u8 dmac[6], smac[6];
17373 u8 dmac_set = 0, smac_set = 0;
17379 /* Shut up coverity */
17380 memset (dmac, 0, sizeof (dmac));
17381 memset (smac, 0, sizeof (smac));
17383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17385 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17387 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17389 else if (unformat (i, "vtr_op %d", &vtr_op))
17391 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17394 else if (unformat (i, "translate_pbb_stag"))
17396 if (unformat (i, "%d", &tmp))
17398 vtr_op = L2_VTR_TRANSLATE_2_1;
17404 ("translate_pbb_stag operation requires outer tag definition");
17408 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17410 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17412 else if (unformat (i, "sid %d", &sid))
17414 else if (unformat (i, "vlanid %d", &tmp))
17418 clib_warning ("parse error '%U'", format_unformat_error, i);
17423 if ((sw_if_index == ~0) || (vtr_op == ~0))
17425 errmsg ("missing sw_if_index or vtr operation");
17428 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17429 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17432 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17436 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17437 mp->sw_if_index = ntohl (sw_if_index);
17438 mp->vtr_op = ntohl (vtr_op);
17439 mp->outer_tag = ntohs (outer_tag);
17440 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17441 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17442 mp->b_vlanid = ntohs (vlanid);
17443 mp->i_sid = ntohl (sid);
17451 api_flow_classify_set_interface (vat_main_t * vam)
17453 unformat_input_t *i = vam->input;
17454 vl_api_flow_classify_set_interface_t *mp;
17456 int sw_if_index_set;
17457 u32 ip4_table_index = ~0;
17458 u32 ip6_table_index = ~0;
17462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17465 sw_if_index_set = 1;
17466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17467 sw_if_index_set = 1;
17468 else if (unformat (i, "del"))
17470 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17472 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17476 clib_warning ("parse error '%U'", format_unformat_error, i);
17481 if (sw_if_index_set == 0)
17483 errmsg ("missing interface name or sw_if_index");
17487 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17489 mp->sw_if_index = ntohl (sw_if_index);
17490 mp->ip4_table_index = ntohl (ip4_table_index);
17491 mp->ip6_table_index = ntohl (ip6_table_index);
17492 mp->is_add = is_add;
17500 api_flow_classify_dump (vat_main_t * vam)
17502 unformat_input_t *i = vam->input;
17503 vl_api_flow_classify_dump_t *mp;
17504 vl_api_control_ping_t *mp_ping;
17505 u8 type = FLOW_CLASSIFY_N_TABLES;
17508 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17512 errmsg ("classify table type must be specified");
17516 if (!vam->json_output)
17518 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17521 M (FLOW_CLASSIFY_DUMP, mp);
17526 /* Use a control ping for synchronization */
17527 M (CONTROL_PING, mp_ping);
17530 /* Wait for a reply... */
17536 api_feature_enable_disable (vat_main_t * vam)
17538 unformat_input_t *i = vam->input;
17539 vl_api_feature_enable_disable_t *mp;
17541 u8 *feature_name = 0;
17542 u32 sw_if_index = ~0;
17546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17548 if (unformat (i, "arc_name %s", &arc_name))
17550 else if (unformat (i, "feature_name %s", &feature_name))
17553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17555 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17557 else if (unformat (i, "disable"))
17565 errmsg ("missing arc name");
17568 if (vec_len (arc_name) > 63)
17570 errmsg ("arc name too long");
17573 if (feature_name == 0)
17575 errmsg ("missing feature name");
17578 if (vec_len (feature_name) > 63)
17580 errmsg ("feature name too long");
17583 if (sw_if_index == ~0)
17585 errmsg ("missing interface name or sw_if_index");
17589 /* Construct the API message */
17590 M (FEATURE_ENABLE_DISABLE, mp);
17591 mp->sw_if_index = ntohl (sw_if_index);
17592 mp->enable = enable;
17593 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17594 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17595 vec_free (arc_name);
17596 vec_free (feature_name);
17604 api_sw_interface_tag_add_del (vat_main_t * vam)
17606 unformat_input_t *i = vam->input;
17607 vl_api_sw_interface_tag_add_del_t *mp;
17608 u32 sw_if_index = ~0;
17613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17615 if (unformat (i, "tag %s", &tag))
17617 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17619 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17621 else if (unformat (i, "del"))
17627 if (sw_if_index == ~0)
17629 errmsg ("missing interface name or sw_if_index");
17633 if (enable && (tag == 0))
17635 errmsg ("no tag specified");
17639 /* Construct the API message */
17640 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17641 mp->sw_if_index = ntohl (sw_if_index);
17642 mp->is_add = enable;
17644 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17652 static void vl_api_l2_xconnect_details_t_handler
17653 (vl_api_l2_xconnect_details_t * mp)
17655 vat_main_t *vam = &vat_main;
17657 print (vam->ofp, "%15d%15d",
17658 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17661 static void vl_api_l2_xconnect_details_t_handler_json
17662 (vl_api_l2_xconnect_details_t * mp)
17664 vat_main_t *vam = &vat_main;
17665 vat_json_node_t *node = NULL;
17667 if (VAT_JSON_ARRAY != vam->json_tree.type)
17669 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17670 vat_json_init_array (&vam->json_tree);
17672 node = vat_json_array_add (&vam->json_tree);
17674 vat_json_init_object (node);
17675 vat_json_object_add_uint (node, "rx_sw_if_index",
17676 ntohl (mp->rx_sw_if_index));
17677 vat_json_object_add_uint (node, "tx_sw_if_index",
17678 ntohl (mp->tx_sw_if_index));
17682 api_l2_xconnect_dump (vat_main_t * vam)
17684 vl_api_l2_xconnect_dump_t *mp;
17685 vl_api_control_ping_t *mp_ping;
17688 if (!vam->json_output)
17690 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17693 M (L2_XCONNECT_DUMP, mp);
17697 /* Use a control ping for synchronization */
17698 M (CONTROL_PING, mp_ping);
17706 api_sw_interface_set_mtu (vat_main_t * vam)
17708 unformat_input_t *i = vam->input;
17709 vl_api_sw_interface_set_mtu_t *mp;
17710 u32 sw_if_index = ~0;
17714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17716 if (unformat (i, "mtu %d", &mtu))
17718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17726 if (sw_if_index == ~0)
17728 errmsg ("missing interface name or sw_if_index");
17734 errmsg ("no mtu specified");
17738 /* Construct the API message */
17739 M (SW_INTERFACE_SET_MTU, mp);
17740 mp->sw_if_index = ntohl (sw_if_index);
17741 mp->mtu = ntohs ((u16) mtu);
17750 q_or_quit (vat_main_t * vam)
17752 longjmp (vam->jump_buf, 1);
17753 return 0; /* not so much */
17757 q (vat_main_t * vam)
17759 return q_or_quit (vam);
17763 quit (vat_main_t * vam)
17765 return q_or_quit (vam);
17769 comment (vat_main_t * vam)
17775 cmd_cmp (void *a1, void *a2)
17780 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17784 help (vat_main_t * vam)
17789 unformat_input_t *i = vam->input;
17792 if (unformat (i, "%s", &name))
17796 vec_add1 (name, 0);
17798 hs = hash_get_mem (vam->help_by_name, name);
17800 print (vam->ofp, "usage: %s %s", name, hs[0]);
17802 print (vam->ofp, "No such msg / command '%s'", name);
17807 print (vam->ofp, "Help is available for the following:");
17810 hash_foreach_pair (p, vam->function_by_name,
17812 vec_add1 (cmds, (u8 *)(p->key));
17816 vec_sort_with_function (cmds, cmd_cmp);
17818 for (j = 0; j < vec_len (cmds); j++)
17819 print (vam->ofp, "%s", cmds[j]);
17826 set (vat_main_t * vam)
17828 u8 *name = 0, *value = 0;
17829 unformat_input_t *i = vam->input;
17831 if (unformat (i, "%s", &name))
17833 /* The input buffer is a vector, not a string. */
17834 value = vec_dup (i->buffer);
17835 vec_delete (value, i->index, 0);
17836 /* Almost certainly has a trailing newline */
17837 if (value[vec_len (value) - 1] == '\n')
17838 value[vec_len (value) - 1] = 0;
17839 /* Make sure it's a proper string, one way or the other */
17840 vec_add1 (value, 0);
17841 (void) clib_macro_set_value (&vam->macro_main,
17842 (char *) name, (char *) value);
17845 errmsg ("usage: set <name> <value>");
17853 unset (vat_main_t * vam)
17857 if (unformat (vam->input, "%s", &name))
17858 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17859 errmsg ("unset: %s wasn't set", name);
17872 macro_sort_cmp (void *a1, void *a2)
17874 macro_sort_t *s1 = a1;
17875 macro_sort_t *s2 = a2;
17877 return strcmp ((char *) (s1->name), (char *) (s2->name));
17881 dump_macro_table (vat_main_t * vam)
17883 macro_sort_t *sort_me = 0, *sm;
17888 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17890 vec_add2 (sort_me, sm, 1);
17891 sm->name = (u8 *)(p->key);
17892 sm->value = (u8 *) (p->value[0]);
17896 vec_sort_with_function (sort_me, macro_sort_cmp);
17898 if (vec_len (sort_me))
17899 print (vam->ofp, "%-15s%s", "Name", "Value");
17901 print (vam->ofp, "The macro table is empty...");
17903 for (i = 0; i < vec_len (sort_me); i++)
17904 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17909 dump_node_table (vat_main_t * vam)
17912 vlib_node_t *node, *next_node;
17914 if (vec_len (vam->graph_nodes) == 0)
17916 print (vam->ofp, "Node table empty, issue get_node_graph...");
17920 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17922 node = vam->graph_nodes[i];
17923 print (vam->ofp, "[%d] %s", i, node->name);
17924 for (j = 0; j < vec_len (node->next_nodes); j++)
17926 if (node->next_nodes[j] != ~0)
17928 next_node = vam->graph_nodes[node->next_nodes[j]];
17929 print (vam->ofp, " [%d] %s", j, next_node->name);
17937 value_sort_cmp (void *a1, void *a2)
17939 name_sort_t *n1 = a1;
17940 name_sort_t *n2 = a2;
17942 if (n1->value < n2->value)
17944 if (n1->value > n2->value)
17951 dump_msg_api_table (vat_main_t * vam)
17953 api_main_t *am = &api_main;
17954 name_sort_t *nses = 0, *ns;
17959 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17961 vec_add2 (nses, ns, 1);
17962 ns->name = (u8 *)(hp->key);
17963 ns->value = (u32) hp->value[0];
17967 vec_sort_with_function (nses, value_sort_cmp);
17969 for (i = 0; i < vec_len (nses); i++)
17970 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17976 get_msg_id (vat_main_t * vam)
17981 if (unformat (vam->input, "%s", &name_and_crc))
17983 message_index = vl_api_get_msg_index (name_and_crc);
17984 if (message_index == ~0)
17986 print (vam->ofp, " '%s' not found", name_and_crc);
17989 print (vam->ofp, " '%s' has message index %d",
17990 name_and_crc, message_index);
17993 errmsg ("name_and_crc required...");
17998 search_node_table (vat_main_t * vam)
18000 unformat_input_t *line_input = vam->input;
18003 vlib_node_t *node, *next_node;
18006 if (vam->graph_node_index_by_name == 0)
18008 print (vam->ofp, "Node table empty, issue get_node_graph...");
18012 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18014 if (unformat (line_input, "%s", &node_to_find))
18016 vec_add1 (node_to_find, 0);
18017 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18020 print (vam->ofp, "%s not found...", node_to_find);
18023 node = vam->graph_nodes[p[0]];
18024 print (vam->ofp, "[%d] %s", p[0], node->name);
18025 for (j = 0; j < vec_len (node->next_nodes); j++)
18027 if (node->next_nodes[j] != ~0)
18029 next_node = vam->graph_nodes[node->next_nodes[j]];
18030 print (vam->ofp, " [%d] %s", j, next_node->name);
18037 clib_warning ("parse error '%U'", format_unformat_error,
18043 vec_free (node_to_find);
18052 script (vat_main_t * vam)
18054 #if (VPP_API_TEST_BUILTIN==0)
18056 char *save_current_file;
18057 unformat_input_t save_input;
18058 jmp_buf save_jump_buf;
18059 u32 save_line_number;
18061 FILE *new_fp, *save_ifp;
18063 if (unformat (vam->input, "%s", &s))
18065 new_fp = fopen ((char *) s, "r");
18068 errmsg ("Couldn't open script file %s", s);
18075 errmsg ("Missing script name");
18079 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18080 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18081 save_ifp = vam->ifp;
18082 save_line_number = vam->input_line_number;
18083 save_current_file = (char *) vam->current_file;
18085 vam->input_line_number = 0;
18087 vam->current_file = s;
18090 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18091 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18092 vam->ifp = save_ifp;
18093 vam->input_line_number = save_line_number;
18094 vam->current_file = (u8 *) save_current_file;
18099 clib_warning ("use the exec command...");
18105 echo (vat_main_t * vam)
18107 print (vam->ofp, "%v", vam->input->buffer);
18111 /* List of API message constructors, CLI names map to api_xxx */
18112 #define foreach_vpe_api_msg \
18113 _(create_loopback,"[mac <mac-addr>]") \
18114 _(sw_interface_dump,"") \
18115 _(sw_interface_set_flags, \
18116 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18117 _(sw_interface_add_del_address, \
18118 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18119 _(sw_interface_set_table, \
18120 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18121 _(sw_interface_set_mpls_enable, \
18122 "<intfc> | sw_if_index [disable | dis]") \
18123 _(sw_interface_set_vpath, \
18124 "<intfc> | sw_if_index <id> enable | disable") \
18125 _(sw_interface_set_vxlan_bypass, \
18126 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18127 _(sw_interface_set_l2_xconnect, \
18128 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18129 "enable | disable") \
18130 _(sw_interface_set_l2_bridge, \
18131 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18132 "[shg <split-horizon-group>] [bvi]\n" \
18133 "enable | disable") \
18134 _(bridge_domain_add_del, \
18135 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18136 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18138 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18140 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18142 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18144 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18146 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18148 "<vpp-if-name> | sw_if_index <id>") \
18149 _(sw_interface_tap_dump, "") \
18150 _(ip_add_del_route, \
18151 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18152 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18153 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18154 "[multipath] [count <n>]") \
18155 _(ip_mroute_add_del, \
18156 "<src> <grp>/<mask> [table-id <n>]\n" \
18157 "[<intfc> | sw_if_index <id>] [local] [del]") \
18158 _(mpls_route_add_del, \
18159 "<label> <eos> via <addr> [table-id <n>]\n" \
18160 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18161 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18162 "[multipath] [count <n>]") \
18163 _(mpls_ip_bind_unbind, \
18164 "<label> <addr/len>") \
18165 _(mpls_tunnel_add_del, \
18166 " via <addr> [table-id <n>]\n" \
18167 "sw_if_index <id>] [l2] [del]") \
18168 _(proxy_arp_add_del, \
18169 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18170 _(proxy_arp_intfc_enable_disable, \
18171 "<intfc> | sw_if_index <id> enable | disable") \
18172 _(sw_interface_set_unnumbered, \
18173 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18174 _(ip_neighbor_add_del, \
18175 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18176 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18177 _(reset_vrf, "vrf <id> [ipv6]") \
18178 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18179 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18180 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18181 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18182 "[outer_vlan_id_any][inner_vlan_id_any]") \
18183 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18184 _(reset_fib, "vrf <n> [ipv6]") \
18185 _(dhcp_proxy_config, \
18186 "svr <v46-address> src <v46-address>\n" \
18187 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18188 _(dhcp_proxy_set_vss, \
18189 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18190 _(dhcp_proxy_dump, "ip6") \
18191 _(dhcp_client_config, \
18192 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18193 _(set_ip_flow_hash, \
18194 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18195 _(sw_interface_ip6_enable_disable, \
18196 "<intfc> | sw_if_index <id> enable | disable") \
18197 _(sw_interface_ip6_set_link_local_address, \
18198 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18199 _(sw_interface_ip6nd_ra_prefix, \
18200 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18201 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18202 "[nolink] [isno]") \
18203 _(sw_interface_ip6nd_ra_config, \
18204 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18205 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18206 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18207 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18208 _(l2_patch_add_del, \
18209 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18210 "enable | disable") \
18211 _(sr_tunnel_add_del, \
18212 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
18213 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
18214 "[policy <policy_name>]") \
18215 _(sr_policy_add_del, \
18216 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
18217 _(sr_multicast_map_add_del, \
18218 "address [ip6 multicast address] sr-policy [policy name] [del]") \
18219 _(classify_add_del_table, \
18220 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18221 " [del] [del-chain] mask <mask-value>\n" \
18222 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18223 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18224 _(classify_add_del_session, \
18225 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18226 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18227 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18228 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18229 _(classify_set_interface_ip_table, \
18230 "<intfc> | sw_if_index <nn> table <nn>") \
18231 _(classify_set_interface_l2_tables, \
18232 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18233 " [other-table <nn>]") \
18234 _(get_node_index, "node <node-name") \
18235 _(add_node_next, "node <node-name> next <next-node-name>") \
18236 _(l2tpv3_create_tunnel, \
18237 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18238 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18239 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18240 _(l2tpv3_set_tunnel_cookies, \
18241 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18242 "[new_remote_cookie <nn>]\n") \
18243 _(l2tpv3_interface_enable_disable, \
18244 "<intfc> | sw_if_index <nn> enable | disable") \
18245 _(l2tpv3_set_lookup_key, \
18246 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18247 _(sw_if_l2tpv3_tunnel_dump, "") \
18248 _(vxlan_add_del_tunnel, \
18249 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18250 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18251 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18252 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18253 _(gre_add_del_tunnel, \
18254 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18255 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18256 _(l2_fib_clear_table, "") \
18257 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18258 _(l2_interface_vlan_tag_rewrite, \
18259 "<intfc> | sw_if_index <nn> \n" \
18260 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18261 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18262 _(create_vhost_user_if, \
18263 "socket <filename> [server] [renumber <dev_instance>] " \
18264 "[mac <mac_address>]") \
18265 _(modify_vhost_user_if, \
18266 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18267 "[server] [renumber <dev_instance>]") \
18268 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18269 _(sw_interface_vhost_user_dump, "") \
18270 _(show_version, "") \
18271 _(vxlan_gpe_add_del_tunnel, \
18272 "local <addr> remote <addr> vni <nn>\n" \
18273 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18274 "[next-ethernet] [next-nsh]\n") \
18275 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18276 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18277 _(interface_name_renumber, \
18278 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18279 _(input_acl_set_interface, \
18280 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18281 " [l2-table <nn>] [del]") \
18282 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18283 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18284 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18285 _(ip_dump, "ipv4 | ipv6") \
18286 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18287 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18289 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18290 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18291 " integ_alg <alg> integ_key <hex>") \
18292 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18293 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18294 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18295 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18296 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18297 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18298 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18299 "(auth_data 0x<data> | auth_data <data>)") \
18300 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18301 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18302 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18303 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18304 "(local|remote)") \
18305 _(ikev2_set_local_key, "file <absolute_file_path>") \
18306 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18307 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18308 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18309 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18310 _(ikev2_initiate_sa_init, "<profile_name>") \
18311 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18312 _(ikev2_initiate_del_child_sa, "<ispi>") \
18313 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18314 _(delete_loopback,"sw_if_index <nn>") \
18315 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18316 _(map_add_domain, \
18317 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18318 "ip6-src <ip6addr> " \
18319 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18320 _(map_del_domain, "index <n>") \
18321 _(map_add_del_rule, \
18322 "index <n> psid <n> dst <ip6addr> [del]") \
18323 _(map_domain_dump, "") \
18324 _(map_rule_dump, "index <map-domain>") \
18325 _(want_interface_events, "enable|disable") \
18326 _(want_stats,"enable|disable") \
18327 _(get_first_msg_id, "client <name>") \
18328 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18329 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18330 "fib-id <nn> [ip4][ip6][default]") \
18331 _(get_node_graph, " ") \
18332 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18333 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18334 _(ioam_disable, "") \
18335 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18336 " sw_if_index <sw_if_index> p <priority> " \
18337 "w <weight>] [del]") \
18338 _(lisp_add_del_locator, "locator-set <locator_name> " \
18339 "iface <intf> | sw_if_index <sw_if_index> " \
18340 "p <priority> w <weight> [del]") \
18341 _(lisp_add_del_local_eid,"vni <vni> eid " \
18342 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18343 "locator-set <locator_name> [del]" \
18344 "[key-id sha1|sha256 secret-key <secret-key>]") \
18345 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18346 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18347 _(lisp_enable_disable, "enable|disable") \
18348 _(lisp_map_register_enable_disable, "enable|disable") \
18349 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18350 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18352 "rloc <locator> p <prio> " \
18353 "w <weight> [rloc <loc> ... ] " \
18354 "action <action> [del-all]") \
18355 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18357 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18358 _(lisp_map_request_mode, "src-dst|dst-only") \
18359 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18360 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18361 _(lisp_locator_set_dump, "[local | remote]") \
18362 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18363 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18364 "[local] | [remote]") \
18365 _(lisp_eid_table_vni_dump, "") \
18366 _(lisp_eid_table_map_dump, "l2|l3") \
18367 _(lisp_map_resolver_dump, "") \
18368 _(lisp_map_server_dump, "") \
18369 _(lisp_adjacencies_get, "vni <vni>") \
18370 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18371 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18372 _(lisp_gpe_add_del_iface, "up|down") \
18373 _(lisp_gpe_enable_disable, "enable|disable") \
18374 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18375 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18376 _(show_lisp_rloc_probe_state, "") \
18377 _(show_lisp_map_register_state, "") \
18378 _(show_lisp_status, "") \
18379 _(lisp_get_map_request_itr_rlocs, "") \
18380 _(show_lisp_pitr, "") \
18381 _(show_lisp_map_request_mode, "") \
18382 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18383 _(af_packet_delete, "name <host interface name>") \
18384 _(policer_add_del, "name <policer name> <params> [del]") \
18385 _(policer_dump, "[name <policer name>]") \
18386 _(policer_classify_set_interface, \
18387 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18388 " [l2-table <nn>] [del]") \
18389 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18390 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18391 "[master|slave]") \
18392 _(netmap_delete, "name <interface name>") \
18393 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18394 _(mpls_fib_dump, "") \
18395 _(classify_table_ids, "") \
18396 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18397 _(classify_table_info, "table_id <nn>") \
18398 _(classify_session_dump, "table_id <nn>") \
18399 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18400 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18401 "[template_interval <nn>] [udp_checksum]") \
18402 _(ipfix_exporter_dump, "") \
18403 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18404 _(ipfix_classify_stream_dump, "") \
18405 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18406 _(ipfix_classify_table_dump, "") \
18407 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18408 _(sw_interface_span_dump, "") \
18409 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18410 _(pg_create_interface, "if_id <nn>") \
18411 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18412 _(pg_enable_disable, "[stream <id>] disable") \
18413 _(ip_source_and_port_range_check_add_del, \
18414 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18415 _(ip_source_and_port_range_check_interface_add_del, \
18416 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18417 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18418 _(ipsec_gre_add_del_tunnel, \
18419 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18420 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18421 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18422 _(l2_interface_pbb_tag_rewrite, \
18423 "<intfc> | sw_if_index <nn> \n" \
18424 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18425 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18426 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18427 _(flow_classify_set_interface, \
18428 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18429 _(flow_classify_dump, "type [ip4|ip6]") \
18430 _(ip_fib_dump, "") \
18431 _(ip_mfib_dump, "") \
18432 _(ip6_fib_dump, "") \
18433 _(ip6_mfib_dump, "") \
18434 _(feature_enable_disable, "arc_name <arc_name> " \
18435 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18436 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18438 _(l2_xconnect_dump, "") \
18439 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18440 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18441 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18444 #define foreach_vpe_dpdk_api_msg \
18445 _(sw_interface_set_dpdk_hqos_pipe, \
18446 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
18447 "profile <profile-id>\n") \
18448 _(sw_interface_set_dpdk_hqos_subport, \
18449 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
18450 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
18451 _(sw_interface_set_dpdk_hqos_tctbl, \
18452 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
18455 /* List of command functions, CLI names map directly to functions */
18456 #define foreach_cli_function \
18457 _(comment, "usage: comment <ignore-rest-of-line>") \
18458 _(dump_interface_table, "usage: dump_interface_table") \
18459 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18460 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18461 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18462 _(dump_stats_table, "usage: dump_stats_table") \
18463 _(dump_macro_table, "usage: dump_macro_table ") \
18464 _(dump_node_table, "usage: dump_node_table") \
18465 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18466 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18467 _(echo, "usage: echo <message>") \
18468 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18469 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18470 _(help, "usage: help") \
18471 _(q, "usage: quit") \
18472 _(quit, "usage: quit") \
18473 _(search_node_table, "usage: search_node_table <name>...") \
18474 _(set, "usage: set <variable-name> <value>") \
18475 _(script, "usage: script <file-name>") \
18476 _(unset, "usage: unset <variable-name>")
18479 static void vl_api_##n##_t_handler_uni \
18480 (vl_api_##n##_t * mp) \
18482 vat_main_t * vam = &vat_main; \
18483 if (vam->json_output) { \
18484 vl_api_##n##_t_handler_json(mp); \
18486 vl_api_##n##_t_handler(mp); \
18489 foreach_vpe_api_reply_msg;
18494 static void vl_api_##n##_t_handler_uni \
18495 (vl_api_##n##_t * mp) \
18497 vat_main_t * vam = &vat_main; \
18498 if (vam->json_output) { \
18499 vl_api_##n##_t_handler_json(mp); \
18501 vl_api_##n##_t_handler(mp); \
18504 foreach_vpe_dpdk_api_reply_msg;
18509 vat_api_hookup (vat_main_t * vam)
18512 vl_msg_api_set_handlers(VL_API_##N, #n, \
18513 vl_api_##n##_t_handler_uni, \
18515 vl_api_##n##_t_endian, \
18516 vl_api_##n##_t_print, \
18517 sizeof(vl_api_##n##_t), 1);
18518 foreach_vpe_api_reply_msg;
18523 vl_msg_api_set_handlers(VL_API_##N, #n, \
18524 vl_api_##n##_t_handler_uni, \
18526 vl_api_##n##_t_endian, \
18527 vl_api_##n##_t_print, \
18528 sizeof(vl_api_##n##_t), 1);
18529 foreach_vpe_dpdk_api_reply_msg;
18533 #if (VPP_API_TEST_BUILTIN==0)
18534 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18537 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18539 vam->function_by_name = hash_create_string (0, sizeof (uword));
18541 vam->help_by_name = hash_create_string (0, sizeof (uword));
18543 /* API messages we can send */
18544 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18545 foreach_vpe_api_msg;
18548 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18549 foreach_vpe_dpdk_api_msg;
18554 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18555 foreach_vpe_api_msg;
18558 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18559 foreach_vpe_dpdk_api_msg;
18563 /* CLI functions */
18564 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18565 foreach_cli_function;
18569 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18570 foreach_cli_function;
18575 * fd.io coding-style-patch-verification: ON
18578 * eval: (c-set-style "gnu")