2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
53 #include "vat/json_format.h"
58 #define vl_typedefs /* define message structures */
59 #include <vpp/api/vpe_all_api_h.h>
62 /* declare message handlers for each api */
64 #define vl_endianfun /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* instantiate all the print functions we know about */
69 #define vl_print(handle, ...)
71 #include <vpp/api/vpe_all_api_h.h>
74 #define __plugin_msg_base 0
75 #include <vlibapi/vat_helper_macros.h>
78 vat_time_now (vat_main_t * vam)
80 #if VPP_API_TEST_BUILTIN
81 return vlib_time_now (vam->vlib_main);
83 return clib_time_now (&vam->clib_time);
88 errmsg (char *fmt, ...)
90 vat_main_t *vam = &vat_main;
95 s = va_format (0, fmt, &va);
100 #if VPP_API_TEST_BUILTIN
101 vlib_cli_output (vam->vlib_main, (char *) s);
104 if (vam->ifp != stdin)
105 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
106 vam->input_line_number);
107 fformat (vam->ofp, (char *) s);
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 #if VPP_API_TEST_BUILTIN == 0
134 /* Parse an IP4 address %d.%d.%d.%d. */
136 unformat_ip4_address (unformat_input_t * input, va_list * args)
138 u8 *result = va_arg (*args, u8 *);
141 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
144 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
156 unformat_ethernet_address (unformat_input_t * input, va_list * args)
158 u8 *result = va_arg (*args, u8 *);
161 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
162 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
166 for (i = 0; i < 6; i++)
167 if (a[i] >= (1 << 8))
170 for (i = 0; i < 6; i++)
176 /* Returns ethernet type as an int in host byte order. */
178 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
181 u16 *result = va_arg (*args, u16 *);
185 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
187 if (type >= (1 << 16))
195 /* Parse an IP6 address. */
197 unformat_ip6_address (unformat_input_t * input, va_list * args)
199 ip6_address_t *result = va_arg (*args, ip6_address_t *);
201 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
202 uword c, n_colon, double_colon_index;
204 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
205 double_colon_index = ARRAY_LEN (hex_quads);
206 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
209 if (c >= '0' && c <= '9')
211 else if (c >= 'a' && c <= 'f')
212 hex_digit = c + 10 - 'a';
213 else if (c >= 'A' && c <= 'F')
214 hex_digit = c + 10 - 'A';
215 else if (c == ':' && n_colon < 2)
219 unformat_put_input (input);
223 /* Too many hex quads. */
224 if (n_hex_quads >= ARRAY_LEN (hex_quads))
229 hex_quad = (hex_quad << 4) | hex_digit;
231 /* Hex quad must fit in 16 bits. */
232 if (n_hex_digits >= 4)
239 /* Save position of :: */
242 /* More than one :: ? */
243 if (double_colon_index < ARRAY_LEN (hex_quads))
245 double_colon_index = n_hex_quads;
248 if (n_colon > 0 && n_hex_digits > 0)
250 hex_quads[n_hex_quads++] = hex_quad;
256 if (n_hex_digits > 0)
257 hex_quads[n_hex_quads++] = hex_quad;
262 /* Expand :: to appropriate number of zero hex quads. */
263 if (double_colon_index < ARRAY_LEN (hex_quads))
265 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
267 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
268 hex_quads[n_zero + i] = hex_quads[i];
270 for (i = 0; i < n_zero; i++)
271 hex_quads[double_colon_index + i] = 0;
273 n_hex_quads = ARRAY_LEN (hex_quads);
276 /* Too few hex quads given. */
277 if (n_hex_quads < ARRAY_LEN (hex_quads))
280 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
281 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
288 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
290 u32 *r = va_arg (*args, u32 *);
293 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
294 foreach_ipsec_policy_action
302 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
304 u32 *r = va_arg (*args, u32 *);
307 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
308 foreach_ipsec_crypto_alg
316 format_ipsec_crypto_alg (u8 * s, va_list * args)
318 u32 i = va_arg (*args, u32);
323 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
324 foreach_ipsec_crypto_alg
327 return format (s, "unknown");
329 return format (s, "%s", t);
333 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
339 foreach_ipsec_integ_alg
347 format_ipsec_integ_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_integ_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
370 foreach_ikev2_auth_method
378 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
380 u32 *r = va_arg (*args, u32 *);
383 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
384 foreach_ikev2_id_type
390 #endif /* VPP_API_TEST_BUILTIN */
393 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
395 u8 *r = va_arg (*args, u8 *);
397 if (unformat (input, "kbps"))
398 *r = SSE2_QOS_RATE_KBPS;
399 else if (unformat (input, "pps"))
400 *r = SSE2_QOS_RATE_PPS;
407 unformat_policer_round_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "closest"))
412 *r = SSE2_QOS_ROUND_TO_CLOSEST;
413 else if (unformat (input, "up"))
414 *r = SSE2_QOS_ROUND_TO_UP;
415 else if (unformat (input, "down"))
416 *r = SSE2_QOS_ROUND_TO_DOWN;
423 unformat_policer_type (unformat_input_t * input, va_list * args)
425 u8 *r = va_arg (*args, u8 *);
427 if (unformat (input, "1r2c"))
428 *r = SSE2_QOS_POLICER_TYPE_1R2C;
429 else if (unformat (input, "1r3c"))
430 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
431 else if (unformat (input, "2r3c-2698"))
432 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
433 else if (unformat (input, "2r3c-4115"))
434 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
435 else if (unformat (input, "2r3c-mef5cf1"))
436 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
443 unformat_dscp (unformat_input_t * input, va_list * va)
445 u8 *r = va_arg (*va, u8 *);
448 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
457 unformat_policer_action_type (unformat_input_t * input, va_list * va)
459 sse2_qos_pol_action_params_st *a
460 = va_arg (*va, sse2_qos_pol_action_params_st *);
462 if (unformat (input, "drop"))
463 a->action_type = SSE2_QOS_ACTION_DROP;
464 else if (unformat (input, "transmit"))
465 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
466 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
467 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
474 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
476 u32 *r = va_arg (*va, u32 *);
479 if (unformat (input, "ip4"))
480 tid = POLICER_CLASSIFY_TABLE_IP4;
481 else if (unformat (input, "ip6"))
482 tid = POLICER_CLASSIFY_TABLE_IP6;
483 else if (unformat (input, "l2"))
484 tid = POLICER_CLASSIFY_TABLE_L2;
493 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
495 u32 *r = va_arg (*va, u32 *);
498 if (unformat (input, "ip4"))
499 tid = FLOW_CLASSIFY_TABLE_IP4;
500 else if (unformat (input, "ip6"))
501 tid = FLOW_CLASSIFY_TABLE_IP6;
509 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
510 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
511 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
512 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
515 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
517 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
518 mfib_itf_attribute_t attr;
521 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
523 if (unformat (input, mfib_itf_flag_long_names[attr]))
524 *iflags |= (1 << attr);
526 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
528 if (unformat (input, mfib_itf_flag_names[attr]))
529 *iflags |= (1 << attr);
532 return (old == *iflags ? 0 : 1);
536 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
538 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
539 mfib_entry_attribute_t attr;
542 FOR_EACH_MFIB_ATTRIBUTE (attr)
544 if (unformat (input, mfib_flag_long_names[attr]))
545 *eflags |= (1 << attr);
547 FOR_EACH_MFIB_ATTRIBUTE (attr)
549 if (unformat (input, mfib_flag_names[attr]))
550 *eflags |= (1 << attr);
553 return (old == *eflags ? 0 : 1);
556 #if (VPP_API_TEST_BUILTIN==0)
558 format_ip4_address (u8 * s, va_list * args)
560 u8 *a = va_arg (*args, u8 *);
561 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
565 format_ip6_address (u8 * s, va_list * args)
567 ip6_address_t *a = va_arg (*args, ip6_address_t *);
568 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
570 i_max_n_zero = ARRAY_LEN (a->as_u16);
572 i_first_zero = i_max_n_zero;
574 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
576 u32 is_zero = a->as_u16[i] == 0;
577 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
583 if ((!is_zero && n_zeros > max_n_zeros)
584 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
586 i_max_n_zero = i_first_zero;
587 max_n_zeros = n_zeros;
588 i_first_zero = ARRAY_LEN (a->as_u16);
593 last_double_colon = 0;
594 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
596 if (i == i_max_n_zero && max_n_zeros > 1)
598 s = format (s, "::");
599 i += max_n_zeros - 1;
600 last_double_colon = 1;
604 s = format (s, "%s%x",
605 (last_double_colon || i == 0) ? "" : ":",
606 clib_net_to_host_u16 (a->as_u16[i]));
607 last_double_colon = 0;
614 /* Format an IP46 address. */
616 format_ip46_address (u8 * s, va_list * args)
618 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
619 ip46_type_t type = va_arg (*args, ip46_type_t);
625 is_ip4 = ip46_address_is_ip4 (ip46);
636 format (s, "%U", format_ip4_address, &ip46->ip4) :
637 format (s, "%U", format_ip6_address, &ip46->ip6);
641 format_ethernet_address (u8 * s, va_list * args)
643 u8 *a = va_arg (*args, u8 *);
645 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
646 a[0], a[1], a[2], a[3], a[4], a[5]);
651 increment_v4_address (ip4_address_t * a)
655 v = ntohl (a->as_u32) + 1;
656 a->as_u32 = ntohl (v);
660 increment_v6_address (ip6_address_t * a)
664 v0 = clib_net_to_host_u64 (a->as_u64[0]);
665 v1 = clib_net_to_host_u64 (a->as_u64[1]);
670 a->as_u64[0] = clib_net_to_host_u64 (v0);
671 a->as_u64[1] = clib_net_to_host_u64 (v1);
675 increment_mac_address (u64 * mac)
679 tmp = clib_net_to_host_u64 (tmp);
680 tmp += 1 << 16; /* skip unused (least significant) octets */
681 tmp = clib_host_to_net_u64 (tmp);
685 static void vl_api_create_loopback_reply_t_handler
686 (vl_api_create_loopback_reply_t * mp)
688 vat_main_t *vam = &vat_main;
689 i32 retval = ntohl (mp->retval);
691 vam->retval = retval;
692 vam->regenerate_interface_table = 1;
693 vam->sw_if_index = ntohl (mp->sw_if_index);
694 vam->result_ready = 1;
697 static void vl_api_create_loopback_reply_t_handler_json
698 (vl_api_create_loopback_reply_t * mp)
700 vat_main_t *vam = &vat_main;
701 vat_json_node_t node;
703 vat_json_init_object (&node);
704 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
705 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
707 vat_json_print (vam->ofp, &node);
708 vat_json_free (&node);
709 vam->retval = ntohl (mp->retval);
710 vam->result_ready = 1;
713 static void vl_api_af_packet_create_reply_t_handler
714 (vl_api_af_packet_create_reply_t * mp)
716 vat_main_t *vam = &vat_main;
717 i32 retval = ntohl (mp->retval);
719 vam->retval = retval;
720 vam->regenerate_interface_table = 1;
721 vam->sw_if_index = ntohl (mp->sw_if_index);
722 vam->result_ready = 1;
725 static void vl_api_af_packet_create_reply_t_handler_json
726 (vl_api_af_packet_create_reply_t * mp)
728 vat_main_t *vam = &vat_main;
729 vat_json_node_t node;
731 vat_json_init_object (&node);
732 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
733 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
735 vat_json_print (vam->ofp, &node);
736 vat_json_free (&node);
738 vam->retval = ntohl (mp->retval);
739 vam->result_ready = 1;
742 static void vl_api_create_vlan_subif_reply_t_handler
743 (vl_api_create_vlan_subif_reply_t * mp)
745 vat_main_t *vam = &vat_main;
746 i32 retval = ntohl (mp->retval);
748 vam->retval = retval;
749 vam->regenerate_interface_table = 1;
750 vam->sw_if_index = ntohl (mp->sw_if_index);
751 vam->result_ready = 1;
754 static void vl_api_create_vlan_subif_reply_t_handler_json
755 (vl_api_create_vlan_subif_reply_t * mp)
757 vat_main_t *vam = &vat_main;
758 vat_json_node_t node;
760 vat_json_init_object (&node);
761 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
762 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
764 vat_json_print (vam->ofp, &node);
765 vat_json_free (&node);
767 vam->retval = ntohl (mp->retval);
768 vam->result_ready = 1;
771 static void vl_api_create_subif_reply_t_handler
772 (vl_api_create_subif_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 i32 retval = ntohl (mp->retval);
777 vam->retval = retval;
778 vam->regenerate_interface_table = 1;
779 vam->sw_if_index = ntohl (mp->sw_if_index);
780 vam->result_ready = 1;
783 static void vl_api_create_subif_reply_t_handler_json
784 (vl_api_create_subif_reply_t * mp)
786 vat_main_t *vam = &vat_main;
787 vat_json_node_t node;
789 vat_json_init_object (&node);
790 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
791 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
793 vat_json_print (vam->ofp, &node);
794 vat_json_free (&node);
796 vam->retval = ntohl (mp->retval);
797 vam->result_ready = 1;
800 static void vl_api_interface_name_renumber_reply_t_handler
801 (vl_api_interface_name_renumber_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 i32 retval = ntohl (mp->retval);
806 vam->retval = retval;
807 vam->regenerate_interface_table = 1;
808 vam->result_ready = 1;
811 static void vl_api_interface_name_renumber_reply_t_handler_json
812 (vl_api_interface_name_renumber_reply_t * mp)
814 vat_main_t *vam = &vat_main;
815 vat_json_node_t node;
817 vat_json_init_object (&node);
818 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
820 vat_json_print (vam->ofp, &node);
821 vat_json_free (&node);
823 vam->retval = ntohl (mp->retval);
824 vam->result_ready = 1;
828 * Special-case: build the interface table, maintain
829 * the next loopback sw_if_index vbl.
831 static void vl_api_sw_interface_details_t_handler
832 (vl_api_sw_interface_details_t * mp)
834 vat_main_t *vam = &vat_main;
835 u8 *s = format (0, "%s%c", mp->interface_name, 0);
837 hash_set_mem (vam->sw_if_index_by_interface_name, s,
838 ntohl (mp->sw_if_index));
840 /* In sub interface case, fill the sub interface table entry */
841 if (mp->sw_if_index != mp->sup_sw_if_index)
843 sw_interface_subif_t *sub = NULL;
845 vec_add2 (vam->sw_if_subif_table, sub, 1);
847 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
848 strncpy ((char *) sub->interface_name, (char *) s,
849 vec_len (sub->interface_name));
850 sub->sw_if_index = ntohl (mp->sw_if_index);
851 sub->sub_id = ntohl (mp->sub_id);
853 sub->sub_dot1ad = mp->sub_dot1ad;
854 sub->sub_number_of_tags = mp->sub_number_of_tags;
855 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
856 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
857 sub->sub_exact_match = mp->sub_exact_match;
858 sub->sub_default = mp->sub_default;
859 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
860 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
862 /* vlan tag rewrite */
863 sub->vtr_op = ntohl (mp->vtr_op);
864 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
865 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
866 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
870 static void vl_api_sw_interface_details_t_handler_json
871 (vl_api_sw_interface_details_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t *node = NULL;
876 if (VAT_JSON_ARRAY != vam->json_tree.type)
878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
879 vat_json_init_array (&vam->json_tree);
881 node = vat_json_array_add (&vam->json_tree);
883 vat_json_init_object (node);
884 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
885 vat_json_object_add_uint (node, "sup_sw_if_index",
886 ntohl (mp->sup_sw_if_index));
887 vat_json_object_add_uint (node, "l2_address_length",
888 ntohl (mp->l2_address_length));
889 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
890 sizeof (mp->l2_address));
891 vat_json_object_add_string_copy (node, "interface_name",
893 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
894 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
895 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
896 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
897 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
898 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
899 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
900 vat_json_object_add_uint (node, "sub_number_of_tags",
901 mp->sub_number_of_tags);
902 vat_json_object_add_uint (node, "sub_outer_vlan_id",
903 ntohs (mp->sub_outer_vlan_id));
904 vat_json_object_add_uint (node, "sub_inner_vlan_id",
905 ntohs (mp->sub_inner_vlan_id));
906 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
907 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
908 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
909 mp->sub_outer_vlan_id_any);
910 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
911 mp->sub_inner_vlan_id_any);
912 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
913 vat_json_object_add_uint (node, "vtr_push_dot1q",
914 ntohl (mp->vtr_push_dot1q));
915 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
916 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
919 static void vl_api_sw_interface_set_flags_t_handler
920 (vl_api_sw_interface_set_flags_t * mp)
922 vat_main_t *vam = &vat_main;
923 if (vam->interface_event_display)
924 errmsg ("interface flags: sw_if_index %d %s %s",
925 ntohl (mp->sw_if_index),
926 mp->admin_up_down ? "admin-up" : "admin-down",
927 mp->link_up_down ? "link-up" : "link-down");
930 static void vl_api_sw_interface_set_flags_t_handler_json
931 (vl_api_sw_interface_set_flags_t * mp)
933 /* JSON output not supported */
937 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
939 vat_main_t *vam = &vat_main;
940 i32 retval = ntohl (mp->retval);
942 vam->retval = retval;
943 vam->shmem_result = (u8 *) mp->reply_in_shmem;
944 vam->result_ready = 1;
948 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
950 vat_main_t *vam = &vat_main;
951 vat_json_node_t node;
952 api_main_t *am = &api_main;
956 vat_json_init_object (&node);
957 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
958 vat_json_object_add_uint (&node, "reply_in_shmem",
959 ntohl (mp->reply_in_shmem));
960 /* Toss the shared-memory original... */
961 pthread_mutex_lock (&am->vlib_rp->mutex);
962 oldheap = svm_push_data_heap (am->vlib_rp);
964 reply = (u8 *) (mp->reply_in_shmem);
967 svm_pop_heap (oldheap);
968 pthread_mutex_unlock (&am->vlib_rp->mutex);
970 vat_json_print (vam->ofp, &node);
971 vat_json_free (&node);
973 vam->retval = ntohl (mp->retval);
974 vam->result_ready = 1;
978 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
980 vat_main_t *vam = &vat_main;
981 i32 retval = ntohl (mp->retval);
983 vam->retval = retval;
984 vam->cmd_reply = mp->reply;
985 vam->result_ready = 1;
989 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
991 vat_main_t *vam = &vat_main;
992 vat_json_node_t node;
994 vat_json_init_object (&node);
995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
996 vat_json_object_add_string_copy (&node, "reply", mp->reply);
998 vat_json_print (vam->ofp, &node);
999 vat_json_free (&node);
1001 vam->retval = ntohl (mp->retval);
1002 vam->result_ready = 1;
1005 static void vl_api_classify_add_del_table_reply_t_handler
1006 (vl_api_classify_add_del_table_reply_t * mp)
1008 vat_main_t *vam = &vat_main;
1009 i32 retval = ntohl (mp->retval);
1010 if (vam->async_mode)
1012 vam->async_errors += (retval < 0);
1016 vam->retval = retval;
1018 ((mp->new_table_index != 0xFFFFFFFF) ||
1019 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1020 (mp->match_n_vectors != 0xFFFFFFFF)))
1022 * Note: this is just barely thread-safe, depends on
1023 * the main thread spinning waiting for an answer...
1025 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1026 ntohl (mp->new_table_index),
1027 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1028 vam->result_ready = 1;
1032 static void vl_api_classify_add_del_table_reply_t_handler_json
1033 (vl_api_classify_add_del_table_reply_t * mp)
1035 vat_main_t *vam = &vat_main;
1036 vat_json_node_t node;
1038 vat_json_init_object (&node);
1039 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1040 vat_json_object_add_uint (&node, "new_table_index",
1041 ntohl (mp->new_table_index));
1042 vat_json_object_add_uint (&node, "skip_n_vectors",
1043 ntohl (mp->skip_n_vectors));
1044 vat_json_object_add_uint (&node, "match_n_vectors",
1045 ntohl (mp->match_n_vectors));
1047 vat_json_print (vam->ofp, &node);
1048 vat_json_free (&node);
1050 vam->retval = ntohl (mp->retval);
1051 vam->result_ready = 1;
1054 static void vl_api_get_node_index_reply_t_handler
1055 (vl_api_get_node_index_reply_t * mp)
1057 vat_main_t *vam = &vat_main;
1058 i32 retval = ntohl (mp->retval);
1059 if (vam->async_mode)
1061 vam->async_errors += (retval < 0);
1065 vam->retval = retval;
1067 errmsg ("node index %d", ntohl (mp->node_index));
1068 vam->result_ready = 1;
1072 static void vl_api_get_node_index_reply_t_handler_json
1073 (vl_api_get_node_index_reply_t * mp)
1075 vat_main_t *vam = &vat_main;
1076 vat_json_node_t node;
1078 vat_json_init_object (&node);
1079 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1080 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1082 vat_json_print (vam->ofp, &node);
1083 vat_json_free (&node);
1085 vam->retval = ntohl (mp->retval);
1086 vam->result_ready = 1;
1089 static void vl_api_get_next_index_reply_t_handler
1090 (vl_api_get_next_index_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 i32 retval = ntohl (mp->retval);
1094 if (vam->async_mode)
1096 vam->async_errors += (retval < 0);
1100 vam->retval = retval;
1102 errmsg ("next node index %d", ntohl (mp->next_index));
1103 vam->result_ready = 1;
1107 static void vl_api_get_next_index_reply_t_handler_json
1108 (vl_api_get_next_index_reply_t * mp)
1110 vat_main_t *vam = &vat_main;
1111 vat_json_node_t node;
1113 vat_json_init_object (&node);
1114 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1115 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1117 vat_json_print (vam->ofp, &node);
1118 vat_json_free (&node);
1120 vam->retval = ntohl (mp->retval);
1121 vam->result_ready = 1;
1124 static void vl_api_add_node_next_reply_t_handler
1125 (vl_api_add_node_next_reply_t * mp)
1127 vat_main_t *vam = &vat_main;
1128 i32 retval = ntohl (mp->retval);
1129 if (vam->async_mode)
1131 vam->async_errors += (retval < 0);
1135 vam->retval = retval;
1137 errmsg ("next index %d", ntohl (mp->next_index));
1138 vam->result_ready = 1;
1142 static void vl_api_add_node_next_reply_t_handler_json
1143 (vl_api_add_node_next_reply_t * mp)
1145 vat_main_t *vam = &vat_main;
1146 vat_json_node_t node;
1148 vat_json_init_object (&node);
1149 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1150 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1152 vat_json_print (vam->ofp, &node);
1153 vat_json_free (&node);
1155 vam->retval = ntohl (mp->retval);
1156 vam->result_ready = 1;
1159 static void vl_api_show_version_reply_t_handler
1160 (vl_api_show_version_reply_t * mp)
1162 vat_main_t *vam = &vat_main;
1163 i32 retval = ntohl (mp->retval);
1167 errmsg (" program: %s", mp->program);
1168 errmsg (" version: %s", mp->version);
1169 errmsg (" build date: %s", mp->build_date);
1170 errmsg ("build directory: %s", mp->build_directory);
1172 vam->retval = retval;
1173 vam->result_ready = 1;
1176 static void vl_api_show_version_reply_t_handler_json
1177 (vl_api_show_version_reply_t * mp)
1179 vat_main_t *vam = &vat_main;
1180 vat_json_node_t node;
1182 vat_json_init_object (&node);
1183 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1184 vat_json_object_add_string_copy (&node, "program", mp->program);
1185 vat_json_object_add_string_copy (&node, "version", mp->version);
1186 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1187 vat_json_object_add_string_copy (&node, "build_directory",
1188 mp->build_directory);
1190 vat_json_print (vam->ofp, &node);
1191 vat_json_free (&node);
1193 vam->retval = ntohl (mp->retval);
1194 vam->result_ready = 1;
1198 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1200 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1201 mp->mac_ip ? "mac/ip binding" : "address resolution",
1202 format_ip4_address, &mp->address,
1203 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1207 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1209 /* JSON output not supported */
1213 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1215 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1216 mp->mac_ip ? "mac/ip binding" : "address resolution",
1217 format_ip6_address, mp->address,
1218 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1222 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1224 /* JSON output not supported */
1228 * Special-case: build the bridge domain table, maintain
1229 * the next bd id vbl.
1231 static void vl_api_bridge_domain_details_t_handler
1232 (vl_api_bridge_domain_details_t * mp)
1234 vat_main_t *vam = &vat_main;
1235 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1237 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1238 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1240 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1241 ntohl (mp->bd_id), mp->learn, mp->forward,
1242 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1245 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1248 static void vl_api_bridge_domain_details_t_handler_json
1249 (vl_api_bridge_domain_details_t * mp)
1251 vat_main_t *vam = &vat_main;
1252 vat_json_node_t *node, *array = NULL;
1254 if (VAT_JSON_ARRAY != vam->json_tree.type)
1256 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1257 vat_json_init_array (&vam->json_tree);
1259 node = vat_json_array_add (&vam->json_tree);
1261 vat_json_init_object (node);
1262 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1263 vat_json_object_add_uint (node, "flood", mp->flood);
1264 vat_json_object_add_uint (node, "forward", mp->forward);
1265 vat_json_object_add_uint (node, "learn", mp->learn);
1266 vat_json_object_add_uint (node, "bvi_sw_if_index",
1267 ntohl (mp->bvi_sw_if_index));
1268 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1269 array = vat_json_object_add (node, "sw_if");
1270 vat_json_init_array (array);
1274 * Special-case: build the bridge domain sw if table.
1276 static void vl_api_bridge_domain_sw_if_details_t_handler
1277 (vl_api_bridge_domain_sw_if_details_t * mp)
1279 vat_main_t *vam = &vat_main;
1284 sw_if_index = ntohl (mp->sw_if_index);
1286 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1288 if ((u32) p->value[0] == sw_if_index)
1290 sw_if_name = (u8 *)(p->key);
1296 print (vam->ofp, "%7d %3d %s", sw_if_index,
1297 mp->shg, sw_if_name ? (char *) sw_if_name :
1298 "sw_if_index not found!");
1301 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1302 (vl_api_bridge_domain_sw_if_details_t * mp)
1304 vat_main_t *vam = &vat_main;
1305 vat_json_node_t *node = NULL;
1306 uword last_index = 0;
1308 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1309 ASSERT (vec_len (vam->json_tree.array) >= 1);
1310 last_index = vec_len (vam->json_tree.array) - 1;
1311 node = &vam->json_tree.array[last_index];
1312 node = vat_json_object_get_element (node, "sw_if");
1313 ASSERT (NULL != node);
1314 node = vat_json_array_add (node);
1316 vat_json_init_object (node);
1317 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1318 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1319 vat_json_object_add_uint (node, "shg", mp->shg);
1322 static void vl_api_control_ping_reply_t_handler
1323 (vl_api_control_ping_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 i32 retval = ntohl (mp->retval);
1327 if (vam->async_mode)
1329 vam->async_errors += (retval < 0);
1333 vam->retval = retval;
1334 vam->result_ready = 1;
1338 static void vl_api_control_ping_reply_t_handler_json
1339 (vl_api_control_ping_reply_t * mp)
1341 vat_main_t *vam = &vat_main;
1342 i32 retval = ntohl (mp->retval);
1344 if (VAT_JSON_NONE != vam->json_tree.type)
1346 vat_json_print (vam->ofp, &vam->json_tree);
1347 vat_json_free (&vam->json_tree);
1348 vam->json_tree.type = VAT_JSON_NONE;
1353 vat_json_init_array (&vam->json_tree);
1354 vat_json_print (vam->ofp, &vam->json_tree);
1355 vam->json_tree.type = VAT_JSON_NONE;
1358 vam->retval = retval;
1359 vam->result_ready = 1;
1363 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1365 vat_main_t *vam = &vat_main;
1366 i32 retval = ntohl (mp->retval);
1367 if (vam->async_mode)
1369 vam->async_errors += (retval < 0);
1373 vam->retval = retval;
1374 vam->result_ready = 1;
1378 static void vl_api_l2_flags_reply_t_handler_json
1379 (vl_api_l2_flags_reply_t * mp)
1381 vat_main_t *vam = &vat_main;
1382 vat_json_node_t node;
1384 vat_json_init_object (&node);
1385 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1386 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1387 ntohl (mp->resulting_feature_bitmap));
1389 vat_json_print (vam->ofp, &node);
1390 vat_json_free (&node);
1392 vam->retval = ntohl (mp->retval);
1393 vam->result_ready = 1;
1396 static void vl_api_bridge_flags_reply_t_handler
1397 (vl_api_bridge_flags_reply_t * mp)
1399 vat_main_t *vam = &vat_main;
1400 i32 retval = ntohl (mp->retval);
1401 if (vam->async_mode)
1403 vam->async_errors += (retval < 0);
1407 vam->retval = retval;
1408 vam->result_ready = 1;
1412 static void vl_api_bridge_flags_reply_t_handler_json
1413 (vl_api_bridge_flags_reply_t * mp)
1415 vat_main_t *vam = &vat_main;
1416 vat_json_node_t node;
1418 vat_json_init_object (&node);
1419 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1420 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1421 ntohl (mp->resulting_feature_bitmap));
1423 vat_json_print (vam->ofp, &node);
1424 vat_json_free (&node);
1426 vam->retval = ntohl (mp->retval);
1427 vam->result_ready = 1;
1430 static void vl_api_tap_connect_reply_t_handler
1431 (vl_api_tap_connect_reply_t * mp)
1433 vat_main_t *vam = &vat_main;
1434 i32 retval = ntohl (mp->retval);
1435 if (vam->async_mode)
1437 vam->async_errors += (retval < 0);
1441 vam->retval = retval;
1442 vam->sw_if_index = ntohl (mp->sw_if_index);
1443 vam->result_ready = 1;
1448 static void vl_api_tap_connect_reply_t_handler_json
1449 (vl_api_tap_connect_reply_t * mp)
1451 vat_main_t *vam = &vat_main;
1452 vat_json_node_t node;
1454 vat_json_init_object (&node);
1455 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1456 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1458 vat_json_print (vam->ofp, &node);
1459 vat_json_free (&node);
1461 vam->retval = ntohl (mp->retval);
1462 vam->result_ready = 1;
1467 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1469 vat_main_t *vam = &vat_main;
1470 i32 retval = ntohl (mp->retval);
1471 if (vam->async_mode)
1473 vam->async_errors += (retval < 0);
1477 vam->retval = retval;
1478 vam->sw_if_index = ntohl (mp->sw_if_index);
1479 vam->result_ready = 1;
1483 static void vl_api_tap_modify_reply_t_handler_json
1484 (vl_api_tap_modify_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 vat_json_node_t node;
1489 vat_json_init_object (&node);
1490 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1491 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1493 vat_json_print (vam->ofp, &node);
1494 vat_json_free (&node);
1496 vam->retval = ntohl (mp->retval);
1497 vam->result_ready = 1;
1501 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1503 vat_main_t *vam = &vat_main;
1504 i32 retval = ntohl (mp->retval);
1505 if (vam->async_mode)
1507 vam->async_errors += (retval < 0);
1511 vam->retval = retval;
1512 vam->result_ready = 1;
1516 static void vl_api_tap_delete_reply_t_handler_json
1517 (vl_api_tap_delete_reply_t * mp)
1519 vat_main_t *vam = &vat_main;
1520 vat_json_node_t node;
1522 vat_json_init_object (&node);
1523 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1525 vat_json_print (vam->ofp, &node);
1526 vat_json_free (&node);
1528 vam->retval = ntohl (mp->retval);
1529 vam->result_ready = 1;
1532 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1533 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1535 vat_main_t *vam = &vat_main;
1536 i32 retval = ntohl (mp->retval);
1537 if (vam->async_mode)
1539 vam->async_errors += (retval < 0);
1543 vam->retval = retval;
1544 vam->result_ready = 1;
1548 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1549 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1551 vat_main_t *vam = &vat_main;
1552 vat_json_node_t node;
1554 vat_json_init_object (&node);
1555 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1556 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1557 ntohl (mp->sw_if_index));
1559 vat_json_print (vam->ofp, &node);
1560 vat_json_free (&node);
1562 vam->retval = ntohl (mp->retval);
1563 vam->result_ready = 1;
1566 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1567 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1569 vat_main_t *vam = &vat_main;
1570 i32 retval = ntohl (mp->retval);
1571 if (vam->async_mode)
1573 vam->async_errors += (retval < 0);
1577 vam->retval = retval;
1578 vam->sw_if_index = ntohl (mp->sw_if_index);
1579 vam->result_ready = 1;
1583 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1584 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1586 vat_main_t *vam = &vat_main;
1587 vat_json_node_t node;
1589 vat_json_init_object (&node);
1590 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1591 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1593 vat_json_print (vam->ofp, &node);
1594 vat_json_free (&node);
1596 vam->retval = ntohl (mp->retval);
1597 vam->result_ready = 1;
1601 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1602 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1604 vat_main_t *vam = &vat_main;
1605 i32 retval = ntohl (mp->retval);
1606 if (vam->async_mode)
1608 vam->async_errors += (retval < 0);
1612 vam->retval = retval;
1613 vam->result_ready = 1;
1617 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1618 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1620 vat_main_t *vam = &vat_main;
1621 vat_json_node_t node;
1623 vat_json_init_object (&node);
1624 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1625 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1627 vat_json_print (vam->ofp, &node);
1628 vat_json_free (&node);
1630 vam->retval = ntohl (mp->retval);
1631 vam->result_ready = 1;
1634 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1635 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1637 vat_main_t *vam = &vat_main;
1638 i32 retval = ntohl (mp->retval);
1639 if (vam->async_mode)
1641 vam->async_errors += (retval < 0);
1645 vam->retval = retval;
1646 vam->sw_if_index = ntohl (mp->sw_if_index);
1647 vam->result_ready = 1;
1651 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1652 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1654 vat_main_t *vam = &vat_main;
1655 vat_json_node_t node;
1657 vat_json_init_object (&node);
1658 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1659 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1661 vat_json_print (vam->ofp, &node);
1662 vat_json_free (&node);
1664 vam->retval = ntohl (mp->retval);
1665 vam->result_ready = 1;
1668 static void vl_api_gre_add_del_tunnel_reply_t_handler
1669 (vl_api_gre_add_del_tunnel_reply_t * mp)
1671 vat_main_t *vam = &vat_main;
1672 i32 retval = ntohl (mp->retval);
1673 if (vam->async_mode)
1675 vam->async_errors += (retval < 0);
1679 vam->retval = retval;
1680 vam->sw_if_index = ntohl (mp->sw_if_index);
1681 vam->result_ready = 1;
1685 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1686 (vl_api_gre_add_del_tunnel_reply_t * mp)
1688 vat_main_t *vam = &vat_main;
1689 vat_json_node_t node;
1691 vat_json_init_object (&node);
1692 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1693 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1695 vat_json_print (vam->ofp, &node);
1696 vat_json_free (&node);
1698 vam->retval = ntohl (mp->retval);
1699 vam->result_ready = 1;
1702 static void vl_api_create_vhost_user_if_reply_t_handler
1703 (vl_api_create_vhost_user_if_reply_t * mp)
1705 vat_main_t *vam = &vat_main;
1706 i32 retval = ntohl (mp->retval);
1707 if (vam->async_mode)
1709 vam->async_errors += (retval < 0);
1713 vam->retval = retval;
1714 vam->sw_if_index = ntohl (mp->sw_if_index);
1715 vam->result_ready = 1;
1719 static void vl_api_create_vhost_user_if_reply_t_handler_json
1720 (vl_api_create_vhost_user_if_reply_t * mp)
1722 vat_main_t *vam = &vat_main;
1723 vat_json_node_t node;
1725 vat_json_init_object (&node);
1726 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1727 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1729 vat_json_print (vam->ofp, &node);
1730 vat_json_free (&node);
1732 vam->retval = ntohl (mp->retval);
1733 vam->result_ready = 1;
1736 static void vl_api_ip_address_details_t_handler
1737 (vl_api_ip_address_details_t * mp)
1739 vat_main_t *vam = &vat_main;
1740 static ip_address_details_t empty_ip_address_details = { {0} };
1741 ip_address_details_t *address = NULL;
1742 ip_details_t *current_ip_details = NULL;
1743 ip_details_t *details = NULL;
1745 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1747 if (!details || vam->current_sw_if_index >= vec_len (details)
1748 || !details[vam->current_sw_if_index].present)
1750 errmsg ("ip address details arrived but not stored");
1751 errmsg ("ip_dump should be called first");
1755 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1757 #define addresses (current_ip_details->addr)
1759 vec_validate_init_empty (addresses, vec_len (addresses),
1760 empty_ip_address_details);
1762 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1764 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1765 address->prefix_length = mp->prefix_length;
1769 static void vl_api_ip_address_details_t_handler_json
1770 (vl_api_ip_address_details_t * mp)
1772 vat_main_t *vam = &vat_main;
1773 vat_json_node_t *node = NULL;
1774 struct in6_addr ip6;
1777 if (VAT_JSON_ARRAY != vam->json_tree.type)
1779 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1780 vat_json_init_array (&vam->json_tree);
1782 node = vat_json_array_add (&vam->json_tree);
1784 vat_json_init_object (node);
1787 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1788 vat_json_object_add_ip6 (node, "ip", ip6);
1792 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1793 vat_json_object_add_ip4 (node, "ip", ip4);
1795 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1799 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 static ip_details_t empty_ip_details = { 0 };
1803 ip_details_t *ip = NULL;
1804 u32 sw_if_index = ~0;
1806 sw_if_index = ntohl (mp->sw_if_index);
1808 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1809 sw_if_index, empty_ip_details);
1811 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1818 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1820 vat_main_t *vam = &vat_main;
1822 if (VAT_JSON_ARRAY != vam->json_tree.type)
1824 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1825 vat_json_init_array (&vam->json_tree);
1827 vat_json_array_add_uint (&vam->json_tree,
1828 clib_net_to_host_u32 (mp->sw_if_index));
1831 static void vl_api_map_domain_details_t_handler_json
1832 (vl_api_map_domain_details_t * mp)
1834 vat_json_node_t *node = NULL;
1835 vat_main_t *vam = &vat_main;
1836 struct in6_addr ip6;
1839 if (VAT_JSON_ARRAY != vam->json_tree.type)
1841 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1842 vat_json_init_array (&vam->json_tree);
1845 node = vat_json_array_add (&vam->json_tree);
1846 vat_json_init_object (node);
1848 vat_json_object_add_uint (node, "domain_index",
1849 clib_net_to_host_u32 (mp->domain_index));
1850 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1851 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1852 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1853 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1854 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1855 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1856 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1857 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1858 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1859 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1860 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1861 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1862 vat_json_object_add_uint (node, "flags", mp->flags);
1863 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1864 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1867 static void vl_api_map_domain_details_t_handler
1868 (vl_api_map_domain_details_t * mp)
1870 vat_main_t *vam = &vat_main;
1872 if (mp->is_translation)
1875 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1876 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1877 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1878 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1879 clib_net_to_host_u32 (mp->domain_index));
1884 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1885 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1886 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1887 format_ip6_address, mp->ip6_src,
1888 clib_net_to_host_u32 (mp->domain_index));
1890 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1891 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1892 mp->is_translation ? "map-t" : "");
1895 static void vl_api_map_rule_details_t_handler_json
1896 (vl_api_map_rule_details_t * mp)
1898 struct in6_addr ip6;
1899 vat_json_node_t *node = NULL;
1900 vat_main_t *vam = &vat_main;
1902 if (VAT_JSON_ARRAY != vam->json_tree.type)
1904 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1905 vat_json_init_array (&vam->json_tree);
1908 node = vat_json_array_add (&vam->json_tree);
1909 vat_json_init_object (node);
1911 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1912 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1913 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1917 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1921 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1925 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1927 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1928 "router_addr %U host_mac %U",
1929 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1930 format_ip4_address, &mp->host_address,
1931 format_ip4_address, &mp->router_address,
1932 format_ethernet_address, mp->host_mac);
1935 static void vl_api_dhcp_compl_event_t_handler_json
1936 (vl_api_dhcp_compl_event_t * mp)
1938 /* JSON output not supported */
1942 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1945 vat_main_t *vam = &vat_main;
1946 static u64 default_counter = 0;
1948 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1950 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1951 sw_if_index, default_counter);
1952 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1956 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1957 interface_counter_t counter)
1959 vat_main_t *vam = &vat_main;
1960 static interface_counter_t default_counter = { 0, };
1962 vec_validate_init_empty (vam->combined_interface_counters,
1963 vnet_counter_type, NULL);
1964 vec_validate_init_empty (vam->combined_interface_counters
1965 [vnet_counter_type], sw_if_index, default_counter);
1966 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1969 static void vl_api_vnet_interface_counters_t_handler
1970 (vl_api_vnet_interface_counters_t * mp)
1975 static void vl_api_vnet_interface_counters_t_handler_json
1976 (vl_api_vnet_interface_counters_t * mp)
1978 interface_counter_t counter;
1983 u32 first_sw_if_index;
1986 count = ntohl (mp->count);
1987 first_sw_if_index = ntohl (mp->first_sw_if_index);
1989 if (!mp->is_combined)
1991 v_packets = (u64 *) & mp->data;
1992 for (i = 0; i < count; i++)
1995 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1996 set_simple_interface_counter (mp->vnet_counter_type,
1997 first_sw_if_index + i, packets);
2003 v = (vlib_counter_t *) & mp->data;
2004 for (i = 0; i < count; i++)
2007 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2009 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2010 set_combined_interface_counter (mp->vnet_counter_type,
2011 first_sw_if_index + i, counter);
2018 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2020 vat_main_t *vam = &vat_main;
2023 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2025 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2034 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2036 vat_main_t *vam = &vat_main;
2039 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2041 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2049 static void vl_api_vnet_ip4_fib_counters_t_handler
2050 (vl_api_vnet_ip4_fib_counters_t * mp)
2055 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2056 (vl_api_vnet_ip4_fib_counters_t * mp)
2058 vat_main_t *vam = &vat_main;
2059 vl_api_ip4_fib_counter_t *v;
2060 ip4_fib_counter_t *counter;
2067 vrf_id = ntohl (mp->vrf_id);
2068 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2069 if (~0 == vrf_index)
2071 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2072 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2073 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2074 vec_validate (vam->ip4_fib_counters, vrf_index);
2075 vam->ip4_fib_counters[vrf_index] = NULL;
2078 vec_free (vam->ip4_fib_counters[vrf_index]);
2079 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2080 count = ntohl (mp->count);
2081 for (i = 0; i < count; i++)
2083 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2084 counter = &vam->ip4_fib_counters[vrf_index][i];
2085 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2086 counter->address = ip4;
2087 counter->address_length = v->address_length;
2088 counter->packets = clib_net_to_host_u64 (v->packets);
2089 counter->bytes = clib_net_to_host_u64 (v->bytes);
2094 static void vl_api_vnet_ip4_nbr_counters_t_handler
2095 (vl_api_vnet_ip4_nbr_counters_t * mp)
2100 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2101 (vl_api_vnet_ip4_nbr_counters_t * mp)
2103 vat_main_t *vam = &vat_main;
2104 vl_api_ip4_nbr_counter_t *v;
2105 ip4_nbr_counter_t *counter;
2110 sw_if_index = ntohl (mp->sw_if_index);
2111 count = ntohl (mp->count);
2112 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2115 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2117 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2118 for (i = 0; i < count; i++)
2120 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2121 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2122 counter->address.s_addr = v->address;
2123 counter->packets = clib_net_to_host_u64 (v->packets);
2124 counter->bytes = clib_net_to_host_u64 (v->bytes);
2125 counter->linkt = v->link_type;
2130 static void vl_api_vnet_ip6_fib_counters_t_handler
2131 (vl_api_vnet_ip6_fib_counters_t * mp)
2136 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2137 (vl_api_vnet_ip6_fib_counters_t * mp)
2139 vat_main_t *vam = &vat_main;
2140 vl_api_ip6_fib_counter_t *v;
2141 ip6_fib_counter_t *counter;
2142 struct in6_addr ip6;
2148 vrf_id = ntohl (mp->vrf_id);
2149 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2150 if (~0 == vrf_index)
2152 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2153 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2154 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2155 vec_validate (vam->ip6_fib_counters, vrf_index);
2156 vam->ip6_fib_counters[vrf_index] = NULL;
2159 vec_free (vam->ip6_fib_counters[vrf_index]);
2160 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2161 count = ntohl (mp->count);
2162 for (i = 0; i < count; i++)
2164 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2165 counter = &vam->ip6_fib_counters[vrf_index][i];
2166 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2167 counter->address = ip6;
2168 counter->address_length = v->address_length;
2169 counter->packets = clib_net_to_host_u64 (v->packets);
2170 counter->bytes = clib_net_to_host_u64 (v->bytes);
2175 static void vl_api_vnet_ip6_nbr_counters_t_handler
2176 (vl_api_vnet_ip6_nbr_counters_t * mp)
2181 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2182 (vl_api_vnet_ip6_nbr_counters_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 vl_api_ip6_nbr_counter_t *v;
2186 ip6_nbr_counter_t *counter;
2187 struct in6_addr ip6;
2192 sw_if_index = ntohl (mp->sw_if_index);
2193 count = ntohl (mp->count);
2194 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2197 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2199 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2200 for (i = 0; i < count; i++)
2202 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2203 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2204 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2205 counter->address = ip6;
2206 counter->packets = clib_net_to_host_u64 (v->packets);
2207 counter->bytes = clib_net_to_host_u64 (v->bytes);
2212 static void vl_api_get_first_msg_id_reply_t_handler
2213 (vl_api_get_first_msg_id_reply_t * mp)
2215 vat_main_t *vam = &vat_main;
2216 i32 retval = ntohl (mp->retval);
2218 if (vam->async_mode)
2220 vam->async_errors += (retval < 0);
2224 vam->retval = retval;
2225 vam->result_ready = 1;
2229 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2233 static void vl_api_get_first_msg_id_reply_t_handler_json
2234 (vl_api_get_first_msg_id_reply_t * mp)
2236 vat_main_t *vam = &vat_main;
2237 vat_json_node_t node;
2239 vat_json_init_object (&node);
2240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2241 vat_json_object_add_uint (&node, "first_msg_id",
2242 (uint) ntohs (mp->first_msg_id));
2244 vat_json_print (vam->ofp, &node);
2245 vat_json_free (&node);
2247 vam->retval = ntohl (mp->retval);
2248 vam->result_ready = 1;
2251 static void vl_api_get_node_graph_reply_t_handler
2252 (vl_api_get_node_graph_reply_t * mp)
2254 vat_main_t *vam = &vat_main;
2255 api_main_t *am = &api_main;
2256 i32 retval = ntohl (mp->retval);
2257 u8 *pvt_copy, *reply;
2262 if (vam->async_mode)
2264 vam->async_errors += (retval < 0);
2268 vam->retval = retval;
2269 vam->result_ready = 1;
2272 /* "Should never happen..." */
2276 reply = (u8 *) (mp->reply_in_shmem);
2277 pvt_copy = vec_dup (reply);
2279 /* Toss the shared-memory original... */
2280 pthread_mutex_lock (&am->vlib_rp->mutex);
2281 oldheap = svm_push_data_heap (am->vlib_rp);
2285 svm_pop_heap (oldheap);
2286 pthread_mutex_unlock (&am->vlib_rp->mutex);
2288 if (vam->graph_nodes)
2290 hash_free (vam->graph_node_index_by_name);
2292 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2294 node = vam->graph_nodes[i];
2295 vec_free (node->name);
2296 vec_free (node->next_nodes);
2299 vec_free (vam->graph_nodes);
2302 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2303 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2304 vec_free (pvt_copy);
2306 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2308 node = vam->graph_nodes[i];
2309 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2313 static void vl_api_get_node_graph_reply_t_handler_json
2314 (vl_api_get_node_graph_reply_t * mp)
2316 vat_main_t *vam = &vat_main;
2317 api_main_t *am = &api_main;
2319 vat_json_node_t node;
2322 /* $$$$ make this real? */
2323 vat_json_init_object (&node);
2324 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2325 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2327 reply = (u8 *) (mp->reply_in_shmem);
2329 /* Toss the shared-memory original... */
2330 pthread_mutex_lock (&am->vlib_rp->mutex);
2331 oldheap = svm_push_data_heap (am->vlib_rp);
2335 svm_pop_heap (oldheap);
2336 pthread_mutex_unlock (&am->vlib_rp->mutex);
2338 vat_json_print (vam->ofp, &node);
2339 vat_json_free (&node);
2341 vam->retval = ntohl (mp->retval);
2342 vam->result_ready = 1;
2346 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2348 vat_main_t *vam = &vat_main;
2353 s = format (s, "%=16d%=16d%=16d",
2354 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2358 s = format (s, "%=16U%=16d%=16d",
2359 mp->is_ipv6 ? format_ip6_address :
2361 mp->ip_address, mp->priority, mp->weight);
2364 print (vam->ofp, "%v", s);
2369 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2372 vat_main_t *vam = &vat_main;
2373 vat_json_node_t *node = NULL;
2374 struct in6_addr ip6;
2377 if (VAT_JSON_ARRAY != vam->json_tree.type)
2379 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2380 vat_json_init_array (&vam->json_tree);
2382 node = vat_json_array_add (&vam->json_tree);
2383 vat_json_init_object (node);
2385 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2386 vat_json_object_add_uint (node, "priority", mp->priority);
2387 vat_json_object_add_uint (node, "weight", mp->weight);
2390 vat_json_object_add_uint (node, "sw_if_index",
2391 clib_net_to_host_u32 (mp->sw_if_index));
2396 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2397 vat_json_object_add_ip6 (node, "address", ip6);
2401 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2402 vat_json_object_add_ip4 (node, "address", ip4);
2408 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2411 vat_main_t *vam = &vat_main;
2414 ls_name = format (0, "%s", mp->ls_name);
2416 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2422 vl_api_lisp_locator_set_details_t_handler_json
2423 (vl_api_lisp_locator_set_details_t * mp)
2425 vat_main_t *vam = &vat_main;
2426 vat_json_node_t *node = 0;
2429 ls_name = format (0, "%s", mp->ls_name);
2430 vec_add1 (ls_name, 0);
2432 if (VAT_JSON_ARRAY != vam->json_tree.type)
2434 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2435 vat_json_init_array (&vam->json_tree);
2437 node = vat_json_array_add (&vam->json_tree);
2439 vat_json_init_object (node);
2440 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2441 vat_json_object_add_uint (node, "ls_index",
2442 clib_net_to_host_u32 (mp->ls_index));
2447 format_lisp_flat_eid (u8 * s, va_list * args)
2449 u32 type = va_arg (*args, u32);
2450 u8 *eid = va_arg (*args, u8 *);
2451 u32 eid_len = va_arg (*args, u32);
2456 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2458 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2460 return format (s, "%U", format_ethernet_address, eid);
2466 format_lisp_eid_vat (u8 * s, va_list * args)
2468 u32 type = va_arg (*args, u32);
2469 u8 *eid = va_arg (*args, u8 *);
2470 u32 eid_len = va_arg (*args, u32);
2471 u8 *seid = va_arg (*args, u8 *);
2472 u32 seid_len = va_arg (*args, u32);
2473 u32 is_src_dst = va_arg (*args, u32);
2476 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2478 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2484 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2486 vat_main_t *vam = &vat_main;
2487 u8 *s = 0, *eid = 0;
2489 if (~0 == mp->locator_set_index)
2490 s = format (0, "action: %d", mp->action);
2492 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2494 eid = format (0, "%U", format_lisp_eid_vat,
2498 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2501 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2502 clib_net_to_host_u32 (mp->vni),
2504 mp->is_local ? "local" : "remote",
2505 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2506 clib_net_to_host_u16 (mp->key_id), mp->key);
2513 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2516 vat_main_t *vam = &vat_main;
2517 vat_json_node_t *node = 0;
2520 if (VAT_JSON_ARRAY != vam->json_tree.type)
2522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2523 vat_json_init_array (&vam->json_tree);
2525 node = vat_json_array_add (&vam->json_tree);
2527 vat_json_init_object (node);
2528 if (~0 == mp->locator_set_index)
2529 vat_json_object_add_uint (node, "action", mp->action);
2531 vat_json_object_add_uint (node, "locator_set_index",
2532 clib_net_to_host_u32 (mp->locator_set_index));
2534 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2535 eid = format (0, "%U", format_lisp_eid_vat,
2539 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2541 vat_json_object_add_string_copy (node, "eid", eid);
2542 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2543 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2544 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2548 vat_json_object_add_uint (node, "key_id",
2549 clib_net_to_host_u16 (mp->key_id));
2550 vat_json_object_add_string_copy (node, "key", mp->key);
2556 vl_api_lisp_eid_table_map_details_t_handler
2557 (vl_api_lisp_eid_table_map_details_t * mp)
2559 vat_main_t *vam = &vat_main;
2561 u8 *line = format (0, "%=10d%=10d",
2562 clib_net_to_host_u32 (mp->vni),
2563 clib_net_to_host_u32 (mp->dp_table));
2564 print (vam->ofp, "%v", line);
2569 vl_api_lisp_eid_table_map_details_t_handler_json
2570 (vl_api_lisp_eid_table_map_details_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 vat_json_node_t *node = NULL;
2575 if (VAT_JSON_ARRAY != vam->json_tree.type)
2577 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2578 vat_json_init_array (&vam->json_tree);
2580 node = vat_json_array_add (&vam->json_tree);
2581 vat_json_init_object (node);
2582 vat_json_object_add_uint (node, "dp_table",
2583 clib_net_to_host_u32 (mp->dp_table));
2584 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2588 vl_api_lisp_eid_table_vni_details_t_handler
2589 (vl_api_lisp_eid_table_vni_details_t * mp)
2591 vat_main_t *vam = &vat_main;
2593 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2594 print (vam->ofp, "%v", line);
2599 vl_api_lisp_eid_table_vni_details_t_handler_json
2600 (vl_api_lisp_eid_table_vni_details_t * mp)
2602 vat_main_t *vam = &vat_main;
2603 vat_json_node_t *node = NULL;
2605 if (VAT_JSON_ARRAY != vam->json_tree.type)
2607 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2608 vat_json_init_array (&vam->json_tree);
2610 node = vat_json_array_add (&vam->json_tree);
2611 vat_json_init_object (node);
2612 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2616 vl_api_show_lisp_map_register_state_reply_t_handler
2617 (vl_api_show_lisp_map_register_state_reply_t * mp)
2619 vat_main_t *vam = &vat_main;
2620 int retval = clib_net_to_host_u32 (mp->retval);
2622 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2624 vam->retval = retval;
2625 vam->result_ready = 1;
2629 vl_api_show_lisp_map_register_state_reply_t_handler_json
2630 (vl_api_show_lisp_map_register_state_reply_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 vat_json_node_t _node, *node = &_node;
2634 int retval = clib_net_to_host_u32 (mp->retval);
2636 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2638 vat_json_init_object (node);
2639 vat_json_object_add_string_copy (node, "state", s);
2641 vat_json_print (vam->ofp, node);
2642 vat_json_free (node);
2644 vam->retval = retval;
2645 vam->result_ready = 1;
2650 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2651 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2653 vat_main_t *vam = &vat_main;
2654 int retval = clib_net_to_host_u32 (mp->retval);
2659 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2661 vam->retval = retval;
2662 vam->result_ready = 1;
2666 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2667 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2669 vat_main_t *vam = &vat_main;
2670 vat_json_node_t _node, *node = &_node;
2671 int retval = clib_net_to_host_u32 (mp->retval);
2673 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2674 vat_json_init_object (node);
2675 vat_json_object_add_string_copy (node, "state", s);
2677 vat_json_print (vam->ofp, node);
2678 vat_json_free (node);
2680 vam->retval = retval;
2681 vam->result_ready = 1;
2686 vl_api_lisp_adjacencies_get_reply_t_handler
2687 (vl_api_lisp_adjacencies_get_reply_t * mp)
2689 vat_main_t *vam = &vat_main;
2691 int retval = clib_net_to_host_u32 (mp->retval);
2692 vl_api_lisp_adjacency_t *a;
2697 n = clib_net_to_host_u32 (mp->count);
2699 for (i = 0; i < n; i++)
2701 a = &mp->adjacencies[i];
2702 print (vam->ofp, "%U %40U",
2703 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2704 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2708 vam->retval = retval;
2709 vam->result_ready = 1;
2713 vl_api_lisp_adjacencies_get_reply_t_handler_json
2714 (vl_api_lisp_adjacencies_get_reply_t * mp)
2717 vat_main_t *vam = &vat_main;
2718 vat_json_node_t *e = 0, root;
2720 int retval = clib_net_to_host_u32 (mp->retval);
2721 vl_api_lisp_adjacency_t *a;
2726 n = clib_net_to_host_u32 (mp->count);
2727 vat_json_init_array (&root);
2729 for (i = 0; i < n; i++)
2731 e = vat_json_array_add (&root);
2732 a = &mp->adjacencies[i];
2734 vat_json_init_object (e);
2735 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2736 a->leid_prefix_len);
2738 vat_json_object_add_string_copy (e, "leid", s);
2741 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2742 a->reid_prefix_len);
2744 vat_json_object_add_string_copy (e, "reid", s);
2748 vat_json_print (vam->ofp, &root);
2749 vat_json_free (&root);
2752 vam->retval = retval;
2753 vam->result_ready = 1;
2757 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2760 vat_main_t *vam = &vat_main;
2762 print (vam->ofp, "%=20U",
2763 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2768 vl_api_lisp_map_server_details_t_handler_json
2769 (vl_api_lisp_map_server_details_t * mp)
2771 vat_main_t *vam = &vat_main;
2772 vat_json_node_t *node = NULL;
2773 struct in6_addr ip6;
2776 if (VAT_JSON_ARRAY != vam->json_tree.type)
2778 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2779 vat_json_init_array (&vam->json_tree);
2781 node = vat_json_array_add (&vam->json_tree);
2783 vat_json_init_object (node);
2786 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2787 vat_json_object_add_ip6 (node, "map-server", ip6);
2791 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2792 vat_json_object_add_ip4 (node, "map-server", ip4);
2797 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2800 vat_main_t *vam = &vat_main;
2802 print (vam->ofp, "%=20U",
2803 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2808 vl_api_lisp_map_resolver_details_t_handler_json
2809 (vl_api_lisp_map_resolver_details_t * mp)
2811 vat_main_t *vam = &vat_main;
2812 vat_json_node_t *node = NULL;
2813 struct in6_addr ip6;
2816 if (VAT_JSON_ARRAY != vam->json_tree.type)
2818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2819 vat_json_init_array (&vam->json_tree);
2821 node = vat_json_array_add (&vam->json_tree);
2823 vat_json_init_object (node);
2826 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2827 vat_json_object_add_ip6 (node, "map resolver", ip6);
2831 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2832 vat_json_object_add_ip4 (node, "map resolver", ip4);
2837 vl_api_show_lisp_status_reply_t_handler
2838 (vl_api_show_lisp_status_reply_t * mp)
2840 vat_main_t *vam = &vat_main;
2841 i32 retval = ntohl (mp->retval);
2845 print (vam->ofp, "feature: %s\ngpe: %s",
2846 mp->feature_status ? "enabled" : "disabled",
2847 mp->gpe_status ? "enabled" : "disabled");
2850 vam->retval = retval;
2851 vam->result_ready = 1;
2855 vl_api_show_lisp_status_reply_t_handler_json
2856 (vl_api_show_lisp_status_reply_t * mp)
2858 vat_main_t *vam = &vat_main;
2859 vat_json_node_t node;
2860 u8 *gpe_status = NULL;
2861 u8 *feature_status = NULL;
2863 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2864 feature_status = format (0, "%s",
2865 mp->feature_status ? "enabled" : "disabled");
2866 vec_add1 (gpe_status, 0);
2867 vec_add1 (feature_status, 0);
2869 vat_json_init_object (&node);
2870 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2871 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2873 vec_free (gpe_status);
2874 vec_free (feature_status);
2876 vat_json_print (vam->ofp, &node);
2877 vat_json_free (&node);
2879 vam->retval = ntohl (mp->retval);
2880 vam->result_ready = 1;
2884 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2885 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2887 vat_main_t *vam = &vat_main;
2888 i32 retval = ntohl (mp->retval);
2892 print (vam->ofp, "%=20s", mp->locator_set_name);
2895 vam->retval = retval;
2896 vam->result_ready = 1;
2900 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2901 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2903 vat_main_t *vam = &vat_main;
2904 vat_json_node_t *node = NULL;
2906 if (VAT_JSON_ARRAY != vam->json_tree.type)
2908 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2909 vat_json_init_array (&vam->json_tree);
2911 node = vat_json_array_add (&vam->json_tree);
2913 vat_json_init_object (node);
2914 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2916 vat_json_print (vam->ofp, node);
2917 vat_json_free (node);
2919 vam->retval = ntohl (mp->retval);
2920 vam->result_ready = 1;
2924 format_lisp_map_request_mode (u8 * s, va_list * args)
2926 u32 mode = va_arg (*args, u32);
2931 return format (0, "dst-only");
2933 return format (0, "src-dst");
2939 vl_api_show_lisp_map_request_mode_reply_t_handler
2940 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2942 vat_main_t *vam = &vat_main;
2943 i32 retval = ntohl (mp->retval);
2947 u32 mode = mp->mode;
2948 print (vam->ofp, "map_request_mode: %U",
2949 format_lisp_map_request_mode, mode);
2952 vam->retval = retval;
2953 vam->result_ready = 1;
2957 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2958 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2960 vat_main_t *vam = &vat_main;
2961 vat_json_node_t node;
2966 s = format (0, "%U", format_lisp_map_request_mode, mode);
2969 vat_json_init_object (&node);
2970 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2971 vat_json_print (vam->ofp, &node);
2972 vat_json_free (&node);
2975 vam->retval = ntohl (mp->retval);
2976 vam->result_ready = 1;
2980 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2982 vat_main_t *vam = &vat_main;
2983 i32 retval = ntohl (mp->retval);
2987 print (vam->ofp, "%-20s%-16s",
2988 mp->status ? "enabled" : "disabled",
2989 mp->status ? (char *) mp->locator_set_name : "");
2992 vam->retval = retval;
2993 vam->result_ready = 1;
2997 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
3000 vat_main_t *vam = &vat_main;
3001 vat_json_node_t node;
3004 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3005 vec_add1 (status, 0);
3007 vat_json_init_object (&node);
3008 vat_json_object_add_string_copy (&node, "status", status);
3011 vat_json_object_add_string_copy (&node, "locator_set",
3012 mp->locator_set_name);
3017 vat_json_print (vam->ofp, &node);
3018 vat_json_free (&node);
3020 vam->retval = ntohl (mp->retval);
3021 vam->result_ready = 1;
3025 format_policer_type (u8 * s, va_list * va)
3027 u32 i = va_arg (*va, u32);
3029 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3030 s = format (s, "1r2c");
3031 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3032 s = format (s, "1r3c");
3033 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3034 s = format (s, "2r3c-2698");
3035 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3036 s = format (s, "2r3c-4115");
3037 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3038 s = format (s, "2r3c-mef5cf1");
3040 s = format (s, "ILLEGAL");
3045 format_policer_rate_type (u8 * s, va_list * va)
3047 u32 i = va_arg (*va, u32);
3049 if (i == SSE2_QOS_RATE_KBPS)
3050 s = format (s, "kbps");
3051 else if (i == SSE2_QOS_RATE_PPS)
3052 s = format (s, "pps");
3054 s = format (s, "ILLEGAL");
3059 format_policer_round_type (u8 * s, va_list * va)
3061 u32 i = va_arg (*va, u32);
3063 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3064 s = format (s, "closest");
3065 else if (i == SSE2_QOS_ROUND_TO_UP)
3066 s = format (s, "up");
3067 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3068 s = format (s, "down");
3070 s = format (s, "ILLEGAL");
3075 format_policer_action_type (u8 * s, va_list * va)
3077 u32 i = va_arg (*va, u32);
3079 if (i == SSE2_QOS_ACTION_DROP)
3080 s = format (s, "drop");
3081 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3082 s = format (s, "transmit");
3083 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3084 s = format (s, "mark-and-transmit");
3086 s = format (s, "ILLEGAL");
3091 format_dscp (u8 * s, va_list * va)
3093 u32 i = va_arg (*va, u32);
3098 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3102 return format (s, "ILLEGAL");
3104 s = format (s, "%s", t);
3109 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3114 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3115 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3117 conform_dscp_str = format (0, "");
3119 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3120 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3122 exceed_dscp_str = format (0, "");
3124 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3125 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3127 violate_dscp_str = format (0, "");
3129 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3130 "rate type %U, round type %U, %s rate, %s color-aware, "
3131 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3132 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3133 "conform action %U%s, exceed action %U%s, violate action %U%s",
3135 format_policer_type, mp->type,
3138 clib_net_to_host_u64 (mp->cb),
3139 clib_net_to_host_u64 (mp->eb),
3140 format_policer_rate_type, mp->rate_type,
3141 format_policer_round_type, mp->round_type,
3142 mp->single_rate ? "single" : "dual",
3143 mp->color_aware ? "is" : "not",
3144 ntohl (mp->cir_tokens_per_period),
3145 ntohl (mp->pir_tokens_per_period),
3147 ntohl (mp->current_limit),
3148 ntohl (mp->current_bucket),
3149 ntohl (mp->extended_limit),
3150 ntohl (mp->extended_bucket),
3151 clib_net_to_host_u64 (mp->last_update_time),
3152 format_policer_action_type, mp->conform_action_type,
3154 format_policer_action_type, mp->exceed_action_type,
3156 format_policer_action_type, mp->violate_action_type,
3159 vec_free (conform_dscp_str);
3160 vec_free (exceed_dscp_str);
3161 vec_free (violate_dscp_str);
3164 static void vl_api_policer_details_t_handler_json
3165 (vl_api_policer_details_t * mp)
3167 vat_main_t *vam = &vat_main;
3168 vat_json_node_t *node;
3169 u8 *rate_type_str, *round_type_str, *type_str;
3170 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3172 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3174 format (0, "%U", format_policer_round_type, mp->round_type);
3175 type_str = format (0, "%U", format_policer_type, mp->type);
3176 conform_action_str = format (0, "%U", format_policer_action_type,
3177 mp->conform_action_type);
3178 exceed_action_str = format (0, "%U", format_policer_action_type,
3179 mp->exceed_action_type);
3180 violate_action_str = format (0, "%U", format_policer_action_type,
3181 mp->violate_action_type);
3183 if (VAT_JSON_ARRAY != vam->json_tree.type)
3185 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3186 vat_json_init_array (&vam->json_tree);
3188 node = vat_json_array_add (&vam->json_tree);
3190 vat_json_init_object (node);
3191 vat_json_object_add_string_copy (node, "name", mp->name);
3192 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3193 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3194 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3195 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3196 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3197 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3198 vat_json_object_add_string_copy (node, "type", type_str);
3199 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3200 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3201 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3202 vat_json_object_add_uint (node, "cir_tokens_per_period",
3203 ntohl (mp->cir_tokens_per_period));
3204 vat_json_object_add_uint (node, "eir_tokens_per_period",
3205 ntohl (mp->pir_tokens_per_period));
3206 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3207 vat_json_object_add_uint (node, "current_bucket",
3208 ntohl (mp->current_bucket));
3209 vat_json_object_add_uint (node, "extended_limit",
3210 ntohl (mp->extended_limit));
3211 vat_json_object_add_uint (node, "extended_bucket",
3212 ntohl (mp->extended_bucket));
3213 vat_json_object_add_uint (node, "last_update_time",
3214 ntohl (mp->last_update_time));
3215 vat_json_object_add_string_copy (node, "conform_action",
3216 conform_action_str);
3217 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3219 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3220 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3221 vec_free (dscp_str);
3223 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3224 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3226 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3227 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3228 vec_free (dscp_str);
3230 vat_json_object_add_string_copy (node, "violate_action",
3231 violate_action_str);
3232 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3234 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3235 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3236 vec_free (dscp_str);
3239 vec_free (rate_type_str);
3240 vec_free (round_type_str);
3241 vec_free (type_str);
3242 vec_free (conform_action_str);
3243 vec_free (exceed_action_str);
3244 vec_free (violate_action_str);
3248 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3251 vat_main_t *vam = &vat_main;
3252 int i, count = ntohl (mp->count);
3255 print (vam->ofp, "classify table ids (%d) : ", count);
3256 for (i = 0; i < count; i++)
3258 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3259 print (vam->ofp, (i < count - 1) ? "," : "");
3261 vam->retval = ntohl (mp->retval);
3262 vam->result_ready = 1;
3266 vl_api_classify_table_ids_reply_t_handler_json
3267 (vl_api_classify_table_ids_reply_t * mp)
3269 vat_main_t *vam = &vat_main;
3270 int i, count = ntohl (mp->count);
3274 vat_json_node_t node;
3276 vat_json_init_object (&node);
3277 for (i = 0; i < count; i++)
3279 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3281 vat_json_print (vam->ofp, &node);
3282 vat_json_free (&node);
3284 vam->retval = ntohl (mp->retval);
3285 vam->result_ready = 1;
3289 vl_api_classify_table_by_interface_reply_t_handler
3290 (vl_api_classify_table_by_interface_reply_t * mp)
3292 vat_main_t *vam = &vat_main;
3295 table_id = ntohl (mp->l2_table_id);
3297 print (vam->ofp, "l2 table id : %d", table_id);
3299 print (vam->ofp, "l2 table id : No input ACL tables configured");
3300 table_id = ntohl (mp->ip4_table_id);
3302 print (vam->ofp, "ip4 table id : %d", table_id);
3304 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3305 table_id = ntohl (mp->ip6_table_id);
3307 print (vam->ofp, "ip6 table id : %d", table_id);
3309 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3310 vam->retval = ntohl (mp->retval);
3311 vam->result_ready = 1;
3315 vl_api_classify_table_by_interface_reply_t_handler_json
3316 (vl_api_classify_table_by_interface_reply_t * mp)
3318 vat_main_t *vam = &vat_main;
3319 vat_json_node_t node;
3321 vat_json_init_object (&node);
3323 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3324 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3325 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3327 vat_json_print (vam->ofp, &node);
3328 vat_json_free (&node);
3330 vam->retval = ntohl (mp->retval);
3331 vam->result_ready = 1;
3334 static void vl_api_policer_add_del_reply_t_handler
3335 (vl_api_policer_add_del_reply_t * mp)
3337 vat_main_t *vam = &vat_main;
3338 i32 retval = ntohl (mp->retval);
3339 if (vam->async_mode)
3341 vam->async_errors += (retval < 0);
3345 vam->retval = retval;
3346 vam->result_ready = 1;
3347 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3349 * Note: this is just barely thread-safe, depends on
3350 * the main thread spinning waiting for an answer...
3352 errmsg ("policer index %d", ntohl (mp->policer_index));
3356 static void vl_api_policer_add_del_reply_t_handler_json
3357 (vl_api_policer_add_del_reply_t * mp)
3359 vat_main_t *vam = &vat_main;
3360 vat_json_node_t node;
3362 vat_json_init_object (&node);
3363 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3364 vat_json_object_add_uint (&node, "policer_index",
3365 ntohl (mp->policer_index));
3367 vat_json_print (vam->ofp, &node);
3368 vat_json_free (&node);
3370 vam->retval = ntohl (mp->retval);
3371 vam->result_ready = 1;
3374 /* Format hex dump. */
3376 format_hex_bytes (u8 * s, va_list * va)
3378 u8 *bytes = va_arg (*va, u8 *);
3379 int n_bytes = va_arg (*va, int);
3382 /* Print short or long form depending on byte count. */
3383 uword short_form = n_bytes <= 32;
3384 uword indent = format_get_indent (s);
3389 for (i = 0; i < n_bytes; i++)
3391 if (!short_form && (i % 32) == 0)
3392 s = format (s, "%08x: ", i);
3393 s = format (s, "%02x", bytes[i]);
3394 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3395 s = format (s, "\n%U", format_white_space, indent);
3402 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3405 vat_main_t *vam = &vat_main;
3406 i32 retval = ntohl (mp->retval);
3409 print (vam->ofp, "classify table info :");
3410 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3411 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3412 ntohl (mp->miss_next_index));
3413 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3414 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3415 ntohl (mp->match_n_vectors));
3416 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3417 ntohl (mp->mask_length));
3419 vam->retval = retval;
3420 vam->result_ready = 1;
3424 vl_api_classify_table_info_reply_t_handler_json
3425 (vl_api_classify_table_info_reply_t * mp)
3427 vat_main_t *vam = &vat_main;
3428 vat_json_node_t node;
3430 i32 retval = ntohl (mp->retval);
3433 vat_json_init_object (&node);
3435 vat_json_object_add_int (&node, "sessions",
3436 ntohl (mp->active_sessions));
3437 vat_json_object_add_int (&node, "nexttbl",
3438 ntohl (mp->next_table_index));
3439 vat_json_object_add_int (&node, "nextnode",
3440 ntohl (mp->miss_next_index));
3441 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3442 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3443 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3444 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3445 ntohl (mp->mask_length), 0);
3446 vat_json_object_add_string_copy (&node, "mask", s);
3448 vat_json_print (vam->ofp, &node);
3449 vat_json_free (&node);
3451 vam->retval = ntohl (mp->retval);
3452 vam->result_ready = 1;
3456 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3459 vat_main_t *vam = &vat_main;
3461 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3462 ntohl (mp->hit_next_index), ntohl (mp->advance),
3463 ntohl (mp->opaque_index));
3464 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3465 ntohl (mp->match_length));
3469 vl_api_classify_session_details_t_handler_json
3470 (vl_api_classify_session_details_t * mp)
3472 vat_main_t *vam = &vat_main;
3473 vat_json_node_t *node = NULL;
3475 if (VAT_JSON_ARRAY != vam->json_tree.type)
3477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3478 vat_json_init_array (&vam->json_tree);
3480 node = vat_json_array_add (&vam->json_tree);
3482 vat_json_init_object (node);
3483 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3484 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3485 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3487 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3489 vat_json_object_add_string_copy (node, "match", s);
3492 static void vl_api_pg_create_interface_reply_t_handler
3493 (vl_api_pg_create_interface_reply_t * mp)
3495 vat_main_t *vam = &vat_main;
3497 vam->retval = ntohl (mp->retval);
3498 vam->result_ready = 1;
3501 static void vl_api_pg_create_interface_reply_t_handler_json
3502 (vl_api_pg_create_interface_reply_t * mp)
3504 vat_main_t *vam = &vat_main;
3505 vat_json_node_t node;
3507 i32 retval = ntohl (mp->retval);
3510 vat_json_init_object (&node);
3512 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3514 vat_json_print (vam->ofp, &node);
3515 vat_json_free (&node);
3517 vam->retval = ntohl (mp->retval);
3518 vam->result_ready = 1;
3521 static void vl_api_policer_classify_details_t_handler
3522 (vl_api_policer_classify_details_t * mp)
3524 vat_main_t *vam = &vat_main;
3526 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3527 ntohl (mp->table_index));
3530 static void vl_api_policer_classify_details_t_handler_json
3531 (vl_api_policer_classify_details_t * mp)
3533 vat_main_t *vam = &vat_main;
3534 vat_json_node_t *node;
3536 if (VAT_JSON_ARRAY != vam->json_tree.type)
3538 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3539 vat_json_init_array (&vam->json_tree);
3541 node = vat_json_array_add (&vam->json_tree);
3543 vat_json_init_object (node);
3544 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3545 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3548 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3549 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3551 vat_main_t *vam = &vat_main;
3552 i32 retval = ntohl (mp->retval);
3553 if (vam->async_mode)
3555 vam->async_errors += (retval < 0);
3559 vam->retval = retval;
3560 vam->sw_if_index = ntohl (mp->sw_if_index);
3561 vam->result_ready = 1;
3565 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3566 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3568 vat_main_t *vam = &vat_main;
3569 vat_json_node_t node;
3571 vat_json_init_object (&node);
3572 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3573 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3575 vat_json_print (vam->ofp, &node);
3576 vat_json_free (&node);
3578 vam->retval = ntohl (mp->retval);
3579 vam->result_ready = 1;
3582 static void vl_api_flow_classify_details_t_handler
3583 (vl_api_flow_classify_details_t * mp)
3585 vat_main_t *vam = &vat_main;
3587 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3588 ntohl (mp->table_index));
3591 static void vl_api_flow_classify_details_t_handler_json
3592 (vl_api_flow_classify_details_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 vat_json_node_t *node;
3597 if (VAT_JSON_ARRAY != vam->json_tree.type)
3599 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3600 vat_json_init_array (&vam->json_tree);
3602 node = vat_json_array_add (&vam->json_tree);
3604 vat_json_init_object (node);
3605 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3606 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3611 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3612 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3613 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3614 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3615 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3616 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3617 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3618 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3619 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3620 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3623 * Generate boilerplate reply handlers, which
3624 * dig the return value out of the xxx_reply_t API message,
3625 * stick it into vam->retval, and set vam->result_ready
3627 * Could also do this by pointing N message decode slots at
3628 * a single function, but that could break in subtle ways.
3631 #define foreach_standard_reply_retval_handler \
3632 _(sw_interface_set_flags_reply) \
3633 _(sw_interface_add_del_address_reply) \
3634 _(sw_interface_set_table_reply) \
3635 _(sw_interface_set_mpls_enable_reply) \
3636 _(sw_interface_set_vpath_reply) \
3637 _(sw_interface_set_vxlan_bypass_reply) \
3638 _(sw_interface_set_l2_bridge_reply) \
3639 _(bridge_domain_add_del_reply) \
3640 _(sw_interface_set_l2_xconnect_reply) \
3641 _(l2fib_add_del_reply) \
3642 _(ip_add_del_route_reply) \
3643 _(ip_mroute_add_del_reply) \
3644 _(mpls_route_add_del_reply) \
3645 _(mpls_ip_bind_unbind_reply) \
3646 _(proxy_arp_add_del_reply) \
3647 _(proxy_arp_intfc_enable_disable_reply) \
3648 _(sw_interface_set_unnumbered_reply) \
3649 _(ip_neighbor_add_del_reply) \
3650 _(reset_vrf_reply) \
3651 _(oam_add_del_reply) \
3652 _(reset_fib_reply) \
3653 _(dhcp_proxy_config_reply) \
3654 _(dhcp_proxy_config_2_reply) \
3655 _(dhcp_proxy_set_vss_reply) \
3656 _(dhcp_client_config_reply) \
3657 _(set_ip_flow_hash_reply) \
3658 _(sw_interface_ip6_enable_disable_reply) \
3659 _(sw_interface_ip6_set_link_local_address_reply) \
3660 _(sw_interface_ip6nd_ra_prefix_reply) \
3661 _(sw_interface_ip6nd_ra_config_reply) \
3662 _(set_arp_neighbor_limit_reply) \
3663 _(l2_patch_add_del_reply) \
3664 _(sr_tunnel_add_del_reply) \
3665 _(sr_policy_add_del_reply) \
3666 _(sr_multicast_map_add_del_reply) \
3667 _(classify_add_del_session_reply) \
3668 _(classify_set_interface_ip_table_reply) \
3669 _(classify_set_interface_l2_tables_reply) \
3670 _(l2tpv3_set_tunnel_cookies_reply) \
3671 _(l2tpv3_interface_enable_disable_reply) \
3672 _(l2tpv3_set_lookup_key_reply) \
3673 _(l2_fib_clear_table_reply) \
3674 _(l2_interface_efp_filter_reply) \
3675 _(l2_interface_vlan_tag_rewrite_reply) \
3676 _(modify_vhost_user_if_reply) \
3677 _(delete_vhost_user_if_reply) \
3678 _(want_ip4_arp_events_reply) \
3679 _(want_ip6_nd_events_reply) \
3680 _(input_acl_set_interface_reply) \
3681 _(ipsec_spd_add_del_reply) \
3682 _(ipsec_interface_add_del_spd_reply) \
3683 _(ipsec_spd_add_del_entry_reply) \
3684 _(ipsec_sad_add_del_entry_reply) \
3685 _(ipsec_sa_set_key_reply) \
3686 _(ikev2_profile_add_del_reply) \
3687 _(ikev2_profile_set_auth_reply) \
3688 _(ikev2_profile_set_id_reply) \
3689 _(ikev2_profile_set_ts_reply) \
3690 _(ikev2_set_local_key_reply) \
3691 _(delete_loopback_reply) \
3692 _(bd_ip_mac_add_del_reply) \
3693 _(map_del_domain_reply) \
3694 _(map_add_del_rule_reply) \
3695 _(want_interface_events_reply) \
3696 _(want_stats_reply) \
3697 _(cop_interface_enable_disable_reply) \
3698 _(cop_whitelist_enable_disable_reply) \
3699 _(sw_interface_clear_stats_reply) \
3700 _(ioam_enable_reply) \
3701 _(ioam_disable_reply) \
3702 _(lisp_add_del_locator_reply) \
3703 _(lisp_add_del_local_eid_reply) \
3704 _(lisp_add_del_remote_mapping_reply) \
3705 _(lisp_add_del_adjacency_reply) \
3706 _(lisp_gpe_add_del_fwd_entry_reply) \
3707 _(lisp_add_del_map_resolver_reply) \
3708 _(lisp_add_del_map_server_reply) \
3709 _(lisp_gpe_enable_disable_reply) \
3710 _(lisp_gpe_add_del_iface_reply) \
3711 _(lisp_enable_disable_reply) \
3712 _(lisp_rloc_probe_enable_disable_reply) \
3713 _(lisp_map_register_enable_disable_reply) \
3714 _(lisp_pitr_set_locator_set_reply) \
3715 _(lisp_map_request_mode_reply) \
3716 _(lisp_add_del_map_request_itr_rlocs_reply) \
3717 _(lisp_eid_table_add_del_map_reply) \
3718 _(vxlan_gpe_add_del_tunnel_reply) \
3719 _(af_packet_delete_reply) \
3720 _(policer_classify_set_interface_reply) \
3721 _(netmap_create_reply) \
3722 _(netmap_delete_reply) \
3723 _(set_ipfix_exporter_reply) \
3724 _(set_ipfix_classify_stream_reply) \
3725 _(ipfix_classify_table_add_del_reply) \
3726 _(flow_classify_set_interface_reply) \
3727 _(sw_interface_span_enable_disable_reply) \
3728 _(pg_capture_reply) \
3729 _(pg_enable_disable_reply) \
3730 _(ip_source_and_port_range_check_add_del_reply) \
3731 _(ip_source_and_port_range_check_interface_add_del_reply)\
3732 _(delete_subif_reply) \
3733 _(l2_interface_pbb_tag_rewrite_reply) \
3735 _(feature_enable_disable_reply) \
3736 _(sw_interface_tag_add_del_reply) \
3737 _(sw_interface_set_mtu_reply)
3740 #define foreach_standard_dpdk_reply_retval_handler \
3741 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3742 _(sw_interface_set_dpdk_hqos_subport_reply) \
3743 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3747 static void vl_api_##n##_t_handler \
3748 (vl_api_##n##_t * mp) \
3750 vat_main_t * vam = &vat_main; \
3751 i32 retval = ntohl(mp->retval); \
3752 if (vam->async_mode) { \
3753 vam->async_errors += (retval < 0); \
3755 vam->retval = retval; \
3756 vam->result_ready = 1; \
3759 foreach_standard_reply_retval_handler;
3763 static void vl_api_##n##_t_handler_json \
3764 (vl_api_##n##_t * mp) \
3766 vat_main_t * vam = &vat_main; \
3767 vat_json_node_t node; \
3768 vat_json_init_object(&node); \
3769 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3770 vat_json_print(vam->ofp, &node); \
3771 vam->retval = ntohl(mp->retval); \
3772 vam->result_ready = 1; \
3774 foreach_standard_reply_retval_handler;
3779 static void vl_api_##n##_t_handler \
3780 (vl_api_##n##_t * mp) \
3782 vat_main_t * vam = &vat_main; \
3783 i32 retval = ntohl(mp->retval); \
3784 if (vam->async_mode) { \
3785 vam->async_errors += (retval < 0); \
3787 vam->retval = retval; \
3788 vam->result_ready = 1; \
3791 foreach_standard_dpdk_reply_retval_handler;
3795 static void vl_api_##n##_t_handler_json \
3796 (vl_api_##n##_t * mp) \
3798 vat_main_t * vam = &vat_main; \
3799 vat_json_node_t node; \
3800 vat_json_init_object(&node); \
3801 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3802 vat_json_print(vam->ofp, &node); \
3803 vam->retval = ntohl(mp->retval); \
3804 vam->result_ready = 1; \
3806 foreach_standard_dpdk_reply_retval_handler;
3811 * Table of message reply handlers, must include boilerplate handlers
3815 #define foreach_vpe_api_reply_msg \
3816 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3817 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3818 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3819 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3820 _(CONTROL_PING_REPLY, control_ping_reply) \
3821 _(CLI_REPLY, cli_reply) \
3822 _(CLI_INBAND_REPLY, cli_inband_reply) \
3823 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3824 sw_interface_add_del_address_reply) \
3825 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3826 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3827 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3828 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3829 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3830 sw_interface_set_l2_xconnect_reply) \
3831 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3832 sw_interface_set_l2_bridge_reply) \
3833 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3834 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3835 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3836 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3837 _(L2_FLAGS_REPLY, l2_flags_reply) \
3838 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3839 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3840 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3841 _(TAP_DELETE_REPLY, tap_delete_reply) \
3842 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3843 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3844 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
3845 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3846 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3847 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3848 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3849 proxy_arp_intfc_enable_disable_reply) \
3850 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3851 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3852 sw_interface_set_unnumbered_reply) \
3853 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3854 _(RESET_VRF_REPLY, reset_vrf_reply) \
3855 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3856 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3857 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3858 _(RESET_FIB_REPLY, reset_fib_reply) \
3859 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3860 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3861 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3862 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3863 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3864 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3865 sw_interface_ip6_enable_disable_reply) \
3866 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3867 sw_interface_ip6_set_link_local_address_reply) \
3868 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3869 sw_interface_ip6nd_ra_prefix_reply) \
3870 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3871 sw_interface_ip6nd_ra_config_reply) \
3872 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3873 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3874 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3875 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3876 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3877 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3878 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3879 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3880 classify_set_interface_ip_table_reply) \
3881 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3882 classify_set_interface_l2_tables_reply) \
3883 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3884 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3885 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3886 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3887 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3888 l2tpv3_interface_enable_disable_reply) \
3889 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3890 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3891 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3892 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3893 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3894 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3895 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3896 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3897 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3898 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3899 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3900 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3901 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3902 _(SHOW_VERSION_REPLY, show_version_reply) \
3903 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3904 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3905 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3906 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3907 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3908 _(IP4_ARP_EVENT, ip4_arp_event) \
3909 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3910 _(IP6_ND_EVENT, ip6_nd_event) \
3911 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3912 _(IP_ADDRESS_DETAILS, ip_address_details) \
3913 _(IP_DETAILS, ip_details) \
3914 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3915 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3916 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3917 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3918 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3919 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3920 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3921 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3922 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3923 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3924 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3925 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3926 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3927 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3928 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3929 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3930 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
3931 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
3932 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3933 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3934 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3935 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3936 _(MAP_RULE_DETAILS, map_rule_details) \
3937 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3938 _(WANT_STATS_REPLY, want_stats_reply) \
3939 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3940 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3941 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3942 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3943 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3944 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3945 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3946 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3947 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3948 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3949 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3950 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3951 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3952 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3953 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3954 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3955 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3956 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3957 lisp_map_register_enable_disable_reply) \
3958 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3959 lisp_rloc_probe_enable_disable_reply) \
3960 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3961 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3962 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3963 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3964 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3965 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3966 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3967 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3968 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3969 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3970 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3971 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3972 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3973 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3974 lisp_add_del_map_request_itr_rlocs_reply) \
3975 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3976 lisp_get_map_request_itr_rlocs_reply) \
3977 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3978 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3979 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3980 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3981 show_lisp_map_register_state_reply) \
3982 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3983 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3984 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3985 _(POLICER_DETAILS, policer_details) \
3986 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3987 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3988 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3989 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3990 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3991 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3992 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3993 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3994 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3995 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3996 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3997 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3998 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3999 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4000 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4001 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4002 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4003 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4004 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4005 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4006 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4007 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4008 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4009 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4010 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4011 ip_source_and_port_range_check_add_del_reply) \
4012 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4013 ip_source_and_port_range_check_interface_add_del_reply) \
4014 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4015 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4016 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4017 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4018 _(PUNT_REPLY, punt_reply) \
4019 _(IP_FIB_DETAILS, ip_fib_details) \
4020 _(IP6_FIB_DETAILS, ip6_fib_details) \
4021 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4022 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4023 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4024 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4025 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4026 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4029 #define foreach_vpe_dpdk_api_reply_msg \
4030 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4031 sw_interface_set_dpdk_hqos_pipe_reply) \
4032 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4033 sw_interface_set_dpdk_hqos_subport_reply) \
4034 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4035 sw_interface_set_dpdk_hqos_tctbl_reply)
4045 #define STR_VTR_OP_CASE(op) \
4046 case L2_VTR_ ## op: \
4050 str_vtr_op (u32 vtr_op)
4054 STR_VTR_OP_CASE (DISABLED);
4055 STR_VTR_OP_CASE (PUSH_1);
4056 STR_VTR_OP_CASE (PUSH_2);
4057 STR_VTR_OP_CASE (POP_1);
4058 STR_VTR_OP_CASE (POP_2);
4059 STR_VTR_OP_CASE (TRANSLATE_1_1);
4060 STR_VTR_OP_CASE (TRANSLATE_1_2);
4061 STR_VTR_OP_CASE (TRANSLATE_2_1);
4062 STR_VTR_OP_CASE (TRANSLATE_2_2);
4069 dump_sub_interface_table (vat_main_t * vam)
4071 const sw_interface_subif_t *sub = NULL;
4073 if (vam->json_output)
4076 ("JSON output supported only for VPE API calls and dump_stats_table");
4081 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4082 "Interface", "sw_if_index",
4083 "sub id", "dot1ad", "tags", "outer id",
4084 "inner id", "exact", "default", "outer any", "inner any");
4086 vec_foreach (sub, vam->sw_if_subif_table)
4089 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4090 sub->interface_name,
4092 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4093 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4094 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4095 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4096 if (sub->vtr_op != L2_VTR_DISABLED)
4099 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4100 "tag1: %d tag2: %d ]",
4101 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4102 sub->vtr_tag1, sub->vtr_tag2);
4110 name_sort_cmp (void *a1, void *a2)
4112 name_sort_t *n1 = a1;
4113 name_sort_t *n2 = a2;
4115 return strcmp ((char *) n1->name, (char *) n2->name);
4119 dump_interface_table (vat_main_t * vam)
4122 name_sort_t *nses = 0, *ns;
4124 if (vam->json_output)
4127 ("JSON output supported only for VPE API calls and dump_stats_table");
4132 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4134 vec_add2 (nses, ns, 1);
4135 ns->name = (u8 *)(p->key);
4136 ns->value = (u32) p->value[0];
4140 vec_sort_with_function (nses, name_sort_cmp);
4142 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4143 vec_foreach (ns, nses)
4145 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4152 dump_ip_table (vat_main_t * vam, int is_ipv6)
4154 const ip_details_t *det = NULL;
4155 const ip_address_details_t *address = NULL;
4158 print (vam->ofp, "%-12s", "sw_if_index");
4160 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4167 print (vam->ofp, "%-12d", i);
4168 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4173 vec_foreach (address, det->addr)
4177 is_ipv6 ? format_ip6_address : format_ip4_address,
4178 address->ip, address->prefix_length);
4186 dump_ipv4_table (vat_main_t * vam)
4188 if (vam->json_output)
4191 ("JSON output supported only for VPE API calls and dump_stats_table");
4195 return dump_ip_table (vam, 0);
4199 dump_ipv6_table (vat_main_t * vam)
4201 if (vam->json_output)
4204 ("JSON output supported only for VPE API calls and dump_stats_table");
4208 return dump_ip_table (vam, 1);
4212 counter_type_to_str (u8 counter_type, u8 is_combined)
4216 switch (counter_type)
4218 case VNET_INTERFACE_COUNTER_DROP:
4220 case VNET_INTERFACE_COUNTER_PUNT:
4222 case VNET_INTERFACE_COUNTER_IP4:
4224 case VNET_INTERFACE_COUNTER_IP6:
4226 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4228 case VNET_INTERFACE_COUNTER_RX_MISS:
4230 case VNET_INTERFACE_COUNTER_RX_ERROR:
4232 case VNET_INTERFACE_COUNTER_TX_ERROR:
4235 return "INVALID-COUNTER-TYPE";
4240 switch (counter_type)
4242 case VNET_INTERFACE_COUNTER_RX:
4244 case VNET_INTERFACE_COUNTER_TX:
4247 return "INVALID-COUNTER-TYPE";
4253 dump_stats_table (vat_main_t * vam)
4255 vat_json_node_t node;
4256 vat_json_node_t *msg_array;
4257 vat_json_node_t *msg;
4258 vat_json_node_t *counter_array;
4259 vat_json_node_t *counter;
4260 interface_counter_t c;
4262 ip4_fib_counter_t *c4;
4263 ip6_fib_counter_t *c6;
4264 ip4_nbr_counter_t *n4;
4265 ip6_nbr_counter_t *n6;
4268 if (!vam->json_output)
4270 clib_warning ("dump_stats_table supported only in JSON format");
4274 vat_json_init_object (&node);
4276 /* interface counters */
4277 msg_array = vat_json_object_add (&node, "interface_counters");
4278 vat_json_init_array (msg_array);
4279 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4281 msg = vat_json_array_add (msg_array);
4282 vat_json_init_object (msg);
4283 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4284 (u8 *) counter_type_to_str (i, 0));
4285 vat_json_object_add_int (msg, "is_combined", 0);
4286 counter_array = vat_json_object_add (msg, "data");
4287 vat_json_init_array (counter_array);
4288 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4290 packets = vam->simple_interface_counters[i][j];
4291 vat_json_array_add_uint (counter_array, packets);
4294 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4296 msg = vat_json_array_add (msg_array);
4297 vat_json_init_object (msg);
4298 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4299 (u8 *) counter_type_to_str (i, 1));
4300 vat_json_object_add_int (msg, "is_combined", 1);
4301 counter_array = vat_json_object_add (msg, "data");
4302 vat_json_init_array (counter_array);
4303 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4305 c = vam->combined_interface_counters[i][j];
4306 counter = vat_json_array_add (counter_array);
4307 vat_json_init_object (counter);
4308 vat_json_object_add_uint (counter, "packets", c.packets);
4309 vat_json_object_add_uint (counter, "bytes", c.bytes);
4313 /* ip4 fib counters */
4314 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4315 vat_json_init_array (msg_array);
4316 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4318 msg = vat_json_array_add (msg_array);
4319 vat_json_init_object (msg);
4320 vat_json_object_add_uint (msg, "vrf_id",
4321 vam->ip4_fib_counters_vrf_id_by_index[i]);
4322 counter_array = vat_json_object_add (msg, "c");
4323 vat_json_init_array (counter_array);
4324 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4326 counter = vat_json_array_add (counter_array);
4327 vat_json_init_object (counter);
4328 c4 = &vam->ip4_fib_counters[i][j];
4329 vat_json_object_add_ip4 (counter, "address", c4->address);
4330 vat_json_object_add_uint (counter, "address_length",
4331 c4->address_length);
4332 vat_json_object_add_uint (counter, "packets", c4->packets);
4333 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4337 /* ip6 fib counters */
4338 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4339 vat_json_init_array (msg_array);
4340 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4342 msg = vat_json_array_add (msg_array);
4343 vat_json_init_object (msg);
4344 vat_json_object_add_uint (msg, "vrf_id",
4345 vam->ip6_fib_counters_vrf_id_by_index[i]);
4346 counter_array = vat_json_object_add (msg, "c");
4347 vat_json_init_array (counter_array);
4348 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4350 counter = vat_json_array_add (counter_array);
4351 vat_json_init_object (counter);
4352 c6 = &vam->ip6_fib_counters[i][j];
4353 vat_json_object_add_ip6 (counter, "address", c6->address);
4354 vat_json_object_add_uint (counter, "address_length",
4355 c6->address_length);
4356 vat_json_object_add_uint (counter, "packets", c6->packets);
4357 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4361 /* ip4 nbr counters */
4362 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4363 vat_json_init_array (msg_array);
4364 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4366 msg = vat_json_array_add (msg_array);
4367 vat_json_init_object (msg);
4368 vat_json_object_add_uint (msg, "sw_if_index", i);
4369 counter_array = vat_json_object_add (msg, "c");
4370 vat_json_init_array (counter_array);
4371 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4373 counter = vat_json_array_add (counter_array);
4374 vat_json_init_object (counter);
4375 n4 = &vam->ip4_nbr_counters[i][j];
4376 vat_json_object_add_ip4 (counter, "address", n4->address);
4377 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4378 vat_json_object_add_uint (counter, "packets", n4->packets);
4379 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4383 /* ip6 nbr counters */
4384 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4385 vat_json_init_array (msg_array);
4386 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4388 msg = vat_json_array_add (msg_array);
4389 vat_json_init_object (msg);
4390 vat_json_object_add_uint (msg, "sw_if_index", i);
4391 counter_array = vat_json_object_add (msg, "c");
4392 vat_json_init_array (counter_array);
4393 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4395 counter = vat_json_array_add (counter_array);
4396 vat_json_init_object (counter);
4397 n6 = &vam->ip6_nbr_counters[i][j];
4398 vat_json_object_add_ip6 (counter, "address", n6->address);
4399 vat_json_object_add_uint (counter, "packets", n6->packets);
4400 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4404 vat_json_print (vam->ofp, &node);
4405 vat_json_free (&node);
4411 exec (vat_main_t * vam)
4413 api_main_t *am = &api_main;
4414 vl_api_cli_request_t *mp;
4418 unformat_input_t *i = vam->input;
4420 if (vec_len (i->buffer) == 0)
4423 if (vam->exec_mode == 0 && unformat (i, "mode"))
4428 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4435 M (CLI_REQUEST, cli_request);
4438 * Copy cmd into shared memory.
4439 * In order for the CLI command to work, it
4440 * must be a vector ending in \n, not a C-string ending
4443 pthread_mutex_lock (&am->vlib_rp->mutex);
4444 oldheap = svm_push_data_heap (am->vlib_rp);
4446 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4447 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4449 svm_pop_heap (oldheap);
4450 pthread_mutex_unlock (&am->vlib_rp->mutex);
4452 mp->cmd_in_shmem = (u64) cmd;
4454 timeout = vat_time_now (vam) + 10.0;
4456 while (vat_time_now (vam) < timeout)
4458 if (vam->result_ready == 1)
4461 if (vam->shmem_result != NULL)
4462 print (vam->ofp, "%s", vam->shmem_result);
4463 pthread_mutex_lock (&am->vlib_rp->mutex);
4464 oldheap = svm_push_data_heap (am->vlib_rp);
4466 free_me = (u8 *) vam->shmem_result;
4469 svm_pop_heap (oldheap);
4470 pthread_mutex_unlock (&am->vlib_rp->mutex);
4478 * Future replacement of exec() that passes CLI buffers directly in
4479 * the API messages instead of an additional shared memory area.
4482 exec_inband (vat_main_t * vam)
4484 vl_api_cli_inband_t *mp;
4486 unformat_input_t *i = vam->input;
4488 if (vec_len (i->buffer) == 0)
4491 if (vam->exec_mode == 0 && unformat (i, "mode"))
4496 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4503 * In order for the CLI command to work, it
4504 * must be a vector ending in \n, not a C-string ending
4507 u32 len = vec_len (vam->input->buffer);
4508 M2 (CLI_INBAND, cli_inband, len);
4509 clib_memcpy (mp->cmd, vam->input->buffer, len);
4510 mp->length = htonl (len);
4513 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4517 api_create_loopback (vat_main_t * vam)
4519 unformat_input_t *i = vam->input;
4520 vl_api_create_loopback_t *mp;
4525 memset (mac_address, 0, sizeof (mac_address));
4527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4529 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4535 /* Construct the API message */
4536 M (CREATE_LOOPBACK, create_loopback);
4538 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4545 api_delete_loopback (vat_main_t * vam)
4547 unformat_input_t *i = vam->input;
4548 vl_api_delete_loopback_t *mp;
4550 u32 sw_if_index = ~0;
4552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4554 if (unformat (i, "sw_if_index %d", &sw_if_index))
4560 if (sw_if_index == ~0)
4562 errmsg ("missing sw_if_index");
4566 /* Construct the API message */
4567 M (DELETE_LOOPBACK, delete_loopback);
4568 mp->sw_if_index = ntohl (sw_if_index);
4575 api_want_stats (vat_main_t * vam)
4577 unformat_input_t *i = vam->input;
4578 vl_api_want_stats_t *mp;
4582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4584 if (unformat (i, "enable"))
4586 else if (unformat (i, "disable"))
4594 errmsg ("missing enable|disable");
4598 M (WANT_STATS, want_stats);
4599 mp->enable_disable = enable;
4606 api_want_interface_events (vat_main_t * vam)
4608 unformat_input_t *i = vam->input;
4609 vl_api_want_interface_events_t *mp;
4613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4615 if (unformat (i, "enable"))
4617 else if (unformat (i, "disable"))
4625 errmsg ("missing enable|disable");
4629 M (WANT_INTERFACE_EVENTS, want_interface_events);
4630 mp->enable_disable = enable;
4632 vam->interface_event_display = enable;
4639 /* Note: non-static, called once to set up the initial intfc table */
4641 api_sw_interface_dump (vat_main_t * vam)
4643 vl_api_sw_interface_dump_t *mp;
4646 name_sort_t *nses = 0, *ns;
4647 sw_interface_subif_t *sub = NULL;
4649 /* Toss the old name table */
4651 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4653 vec_add2 (nses, ns, 1);
4654 ns->name = (u8 *)(p->key);
4655 ns->value = (u32) p->value[0];
4659 hash_free (vam->sw_if_index_by_interface_name);
4661 vec_foreach (ns, nses) vec_free (ns->name);
4665 vec_foreach (sub, vam->sw_if_subif_table)
4667 vec_free (sub->interface_name);
4669 vec_free (vam->sw_if_subif_table);
4671 /* recreate the interface name hash table */
4672 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4674 /* Get list of ethernets */
4675 M (SW_INTERFACE_DUMP, sw_interface_dump);
4676 mp->name_filter_valid = 1;
4677 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4680 /* and local / loopback interfaces */
4681 M (SW_INTERFACE_DUMP, sw_interface_dump);
4682 mp->name_filter_valid = 1;
4683 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4686 /* and packet-generator interfaces */
4687 M (SW_INTERFACE_DUMP, sw_interface_dump);
4688 mp->name_filter_valid = 1;
4689 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4692 /* and vxlan-gpe tunnel interfaces */
4693 M (SW_INTERFACE_DUMP, sw_interface_dump);
4694 mp->name_filter_valid = 1;
4695 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4696 sizeof (mp->name_filter) - 1);
4699 /* and vxlan tunnel interfaces */
4700 M (SW_INTERFACE_DUMP, sw_interface_dump);
4701 mp->name_filter_valid = 1;
4702 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4705 /* and host (af_packet) interfaces */
4706 M (SW_INTERFACE_DUMP, sw_interface_dump);
4707 mp->name_filter_valid = 1;
4708 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4711 /* and l2tpv3 tunnel interfaces */
4712 M (SW_INTERFACE_DUMP, sw_interface_dump);
4713 mp->name_filter_valid = 1;
4714 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4715 sizeof (mp->name_filter) - 1);
4718 /* and GRE tunnel interfaces */
4719 M (SW_INTERFACE_DUMP, sw_interface_dump);
4720 mp->name_filter_valid = 1;
4721 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4724 /* and LISP-GPE interfaces */
4725 M (SW_INTERFACE_DUMP, sw_interface_dump);
4726 mp->name_filter_valid = 1;
4727 strncpy ((char *) mp->name_filter, "lisp_gpe",
4728 sizeof (mp->name_filter) - 1);
4731 /* and IPSEC tunnel interfaces */
4732 M (SW_INTERFACE_DUMP, sw_interface_dump);
4733 mp->name_filter_valid = 1;
4734 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4737 /* Use a control ping for synchronization */
4739 vl_api_control_ping_t *mp;
4740 M (CONTROL_PING, control_ping);
4747 api_sw_interface_set_flags (vat_main_t * vam)
4749 unformat_input_t *i = vam->input;
4750 vl_api_sw_interface_set_flags_t *mp;
4753 u8 sw_if_index_set = 0;
4754 u8 admin_up = 0, link_up = 0;
4756 /* Parse args required to build the message */
4757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4759 if (unformat (i, "admin-up"))
4761 else if (unformat (i, "admin-down"))
4763 else if (unformat (i, "link-up"))
4765 else if (unformat (i, "link-down"))
4768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4769 sw_if_index_set = 1;
4770 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4771 sw_if_index_set = 1;
4776 if (sw_if_index_set == 0)
4778 errmsg ("missing interface name or sw_if_index");
4782 /* Construct the API message */
4783 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4784 mp->sw_if_index = ntohl (sw_if_index);
4785 mp->admin_up_down = admin_up;
4786 mp->link_up_down = link_up;
4791 /* Wait for a reply, return the good/bad news... */
4796 api_sw_interface_clear_stats (vat_main_t * vam)
4798 unformat_input_t *i = vam->input;
4799 vl_api_sw_interface_clear_stats_t *mp;
4802 u8 sw_if_index_set = 0;
4804 /* Parse args required to build the message */
4805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4807 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4808 sw_if_index_set = 1;
4809 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4810 sw_if_index_set = 1;
4815 /* Construct the API message */
4816 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4818 if (sw_if_index_set == 1)
4819 mp->sw_if_index = ntohl (sw_if_index);
4821 mp->sw_if_index = ~0;
4826 /* Wait for a reply, return the good/bad news... */
4832 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4834 unformat_input_t *i = vam->input;
4835 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4838 u8 sw_if_index_set = 0;
4846 /* Parse args required to build the message */
4847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4849 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4850 sw_if_index_set = 1;
4851 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4852 sw_if_index_set = 1;
4853 else if (unformat (i, "subport %u", &subport))
4856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4857 sw_if_index_set = 1;
4858 else if (unformat (i, "pipe %u", &pipe))
4860 else if (unformat (i, "profile %u", &profile))
4866 if (sw_if_index_set == 0)
4868 errmsg ("missing interface name or sw_if_index");
4872 if (subport_set == 0)
4874 errmsg ("missing subport ");
4880 errmsg ("missing pipe");
4884 if (profile_set == 0)
4886 errmsg ("missing profile");
4890 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4892 mp->sw_if_index = ntohl (sw_if_index);
4893 mp->subport = ntohl (subport);
4894 mp->pipe = ntohl (pipe);
4895 mp->profile = ntohl (profile);
4905 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4907 unformat_input_t *i = vam->input;
4908 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4911 u8 sw_if_index_set = 0;
4914 u32 tb_rate = 1250000000; /* 10GbE */
4915 u32 tb_size = 1000000;
4916 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4919 /* Parse args required to build the message */
4920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4922 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4923 sw_if_index_set = 1;
4924 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4925 sw_if_index_set = 1;
4926 else if (unformat (i, "subport %u", &subport))
4929 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4930 sw_if_index_set = 1;
4931 else if (unformat (i, "rate %u", &tb_rate))
4935 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4937 tc_rate[tc_id] = tb_rate;
4939 else if (unformat (i, "bktsize %u", &tb_size))
4941 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4943 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4945 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4947 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4949 else if (unformat (i, "period %u", &tc_period))
4955 if (sw_if_index_set == 0)
4957 errmsg ("missing interface name or sw_if_index");
4961 if (subport_set == 0)
4963 errmsg ("missing subport ");
4967 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4969 mp->sw_if_index = ntohl (sw_if_index);
4970 mp->subport = ntohl (subport);
4971 mp->tb_rate = ntohl (tb_rate);
4972 mp->tb_size = ntohl (tb_size);
4973 mp->tc_rate[0] = ntohl (tc_rate[0]);
4974 mp->tc_rate[1] = ntohl (tc_rate[1]);
4975 mp->tc_rate[2] = ntohl (tc_rate[2]);
4976 mp->tc_rate[3] = ntohl (tc_rate[3]);
4977 mp->tc_period = ntohl (tc_period);
4986 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4988 unformat_input_t *i = vam->input;
4989 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4992 u8 sw_if_index_set = 0;
4996 u32 entry, tc, queue;
4998 /* Parse args required to build the message */
4999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5001 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5002 sw_if_index_set = 1;
5003 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5004 sw_if_index_set = 1;
5005 else if (unformat (i, "entry %d", &entry))
5007 else if (unformat (i, "tc %d", &tc))
5009 else if (unformat (i, "queue %d", &queue))
5015 if (sw_if_index_set == 0)
5017 errmsg ("missing interface name or sw_if_index");
5023 errmsg ("missing entry ");
5029 errmsg ("missing traffic class ");
5035 errmsg ("missing queue ");
5039 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
5041 mp->sw_if_index = ntohl (sw_if_index);
5042 mp->entry = ntohl (entry);
5043 mp->tc = ntohl (tc);
5044 mp->queue = ntohl (queue);
5054 api_sw_interface_add_del_address (vat_main_t * vam)
5056 unformat_input_t *i = vam->input;
5057 vl_api_sw_interface_add_del_address_t *mp;
5060 u8 sw_if_index_set = 0;
5061 u8 is_add = 1, del_all = 0;
5062 u32 address_length = 0;
5063 u8 v4_address_set = 0;
5064 u8 v6_address_set = 0;
5065 ip4_address_t v4address;
5066 ip6_address_t v6address;
5068 /* Parse args required to build the message */
5069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5071 if (unformat (i, "del-all"))
5073 else if (unformat (i, "del"))
5076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5077 sw_if_index_set = 1;
5078 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5079 sw_if_index_set = 1;
5080 else if (unformat (i, "%U/%d",
5081 unformat_ip4_address, &v4address, &address_length))
5083 else if (unformat (i, "%U/%d",
5084 unformat_ip6_address, &v6address, &address_length))
5090 if (sw_if_index_set == 0)
5092 errmsg ("missing interface name or sw_if_index");
5095 if (v4_address_set && v6_address_set)
5097 errmsg ("both v4 and v6 addresses set");
5100 if (!v4_address_set && !v6_address_set && !del_all)
5102 errmsg ("no addresses set");
5106 /* Construct the API message */
5107 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
5109 mp->sw_if_index = ntohl (sw_if_index);
5110 mp->is_add = is_add;
5111 mp->del_all = del_all;
5115 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5119 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5121 mp->address_length = address_length;
5126 /* Wait for a reply, return good/bad news */
5131 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5133 unformat_input_t *i = vam->input;
5134 vl_api_sw_interface_set_mpls_enable_t *mp;
5137 u8 sw_if_index_set = 0;
5140 /* Parse args required to build the message */
5141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5143 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5144 sw_if_index_set = 1;
5145 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5146 sw_if_index_set = 1;
5147 else if (unformat (i, "disable"))
5149 else if (unformat (i, "dis"))
5155 if (sw_if_index_set == 0)
5157 errmsg ("missing interface name or sw_if_index");
5161 /* Construct the API message */
5162 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5164 mp->sw_if_index = ntohl (sw_if_index);
5165 mp->enable = enable;
5170 /* Wait for a reply... */
5175 api_sw_interface_set_table (vat_main_t * vam)
5177 unformat_input_t *i = vam->input;
5178 vl_api_sw_interface_set_table_t *mp;
5180 u32 sw_if_index, vrf_id = 0;
5181 u8 sw_if_index_set = 0;
5184 /* Parse args required to build the message */
5185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5187 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5188 sw_if_index_set = 1;
5189 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5190 sw_if_index_set = 1;
5191 else if (unformat (i, "vrf %d", &vrf_id))
5193 else if (unformat (i, "ipv6"))
5199 if (sw_if_index_set == 0)
5201 errmsg ("missing interface name or sw_if_index");
5205 /* Construct the API message */
5206 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5208 mp->sw_if_index = ntohl (sw_if_index);
5209 mp->is_ipv6 = is_ipv6;
5210 mp->vrf_id = ntohl (vrf_id);
5215 /* Wait for a reply... */
5219 static void vl_api_sw_interface_get_table_reply_t_handler
5220 (vl_api_sw_interface_get_table_reply_t * mp)
5222 vat_main_t *vam = &vat_main;
5224 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5226 vam->retval = ntohl (mp->retval);
5227 vam->result_ready = 1;
5231 static void vl_api_sw_interface_get_table_reply_t_handler_json
5232 (vl_api_sw_interface_get_table_reply_t * mp)
5234 vat_main_t *vam = &vat_main;
5235 vat_json_node_t node;
5237 vat_json_init_object (&node);
5238 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5239 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5241 vat_json_print (vam->ofp, &node);
5242 vat_json_free (&node);
5244 vam->retval = ntohl (mp->retval);
5245 vam->result_ready = 1;
5249 api_sw_interface_get_table (vat_main_t * vam)
5251 unformat_input_t *i = vam->input;
5252 vl_api_sw_interface_get_table_t *mp;
5254 u8 sw_if_index_set = 0;
5258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5260 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5261 sw_if_index_set = 1;
5262 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5263 sw_if_index_set = 1;
5264 else if (unformat (i, "ipv6"))
5270 if (sw_if_index_set == 0)
5272 errmsg ("missing interface name or sw_if_index");
5276 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5277 mp->sw_if_index = htonl (sw_if_index);
5278 mp->is_ipv6 = is_ipv6;
5285 api_sw_interface_set_vpath (vat_main_t * vam)
5287 unformat_input_t *i = vam->input;
5288 vl_api_sw_interface_set_vpath_t *mp;
5290 u32 sw_if_index = 0;
5291 u8 sw_if_index_set = 0;
5294 /* Parse args required to build the message */
5295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5297 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5298 sw_if_index_set = 1;
5299 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5300 sw_if_index_set = 1;
5301 else if (unformat (i, "enable"))
5303 else if (unformat (i, "disable"))
5309 if (sw_if_index_set == 0)
5311 errmsg ("missing interface name or sw_if_index");
5315 /* Construct the API message */
5316 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5318 mp->sw_if_index = ntohl (sw_if_index);
5319 mp->enable = is_enable;
5324 /* Wait for a reply... */
5329 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5331 unformat_input_t *i = vam->input;
5332 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5334 u32 sw_if_index = 0;
5335 u8 sw_if_index_set = 0;
5339 /* Parse args required to build the message */
5340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5342 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5343 sw_if_index_set = 1;
5344 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5345 sw_if_index_set = 1;
5346 else if (unformat (i, "enable"))
5348 else if (unformat (i, "disable"))
5350 else if (unformat (i, "ip4"))
5352 else if (unformat (i, "ip6"))
5358 if (sw_if_index_set == 0)
5360 errmsg ("missing interface name or sw_if_index");
5364 /* Construct the API message */
5365 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5367 mp->sw_if_index = ntohl (sw_if_index);
5368 mp->enable = is_enable;
5369 mp->is_ipv6 = is_ipv6;
5374 /* Wait for a reply... */
5379 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5381 unformat_input_t *i = vam->input;
5382 vl_api_sw_interface_set_l2_xconnect_t *mp;
5385 u8 rx_sw_if_index_set = 0;
5387 u8 tx_sw_if_index_set = 0;
5390 /* Parse args required to build the message */
5391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5393 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5394 rx_sw_if_index_set = 1;
5395 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5396 tx_sw_if_index_set = 1;
5397 else if (unformat (i, "rx"))
5399 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5401 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5403 rx_sw_if_index_set = 1;
5408 else if (unformat (i, "tx"))
5410 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5412 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5414 tx_sw_if_index_set = 1;
5419 else if (unformat (i, "enable"))
5421 else if (unformat (i, "disable"))
5427 if (rx_sw_if_index_set == 0)
5429 errmsg ("missing rx interface name or rx_sw_if_index");
5433 if (enable && (tx_sw_if_index_set == 0))
5435 errmsg ("missing tx interface name or tx_sw_if_index");
5439 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5441 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5442 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5443 mp->enable = enable;
5452 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5454 unformat_input_t *i = vam->input;
5455 vl_api_sw_interface_set_l2_bridge_t *mp;
5458 u8 rx_sw_if_index_set = 0;
5465 /* Parse args required to build the message */
5466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5468 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5469 rx_sw_if_index_set = 1;
5470 else if (unformat (i, "bd_id %d", &bd_id))
5474 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5475 rx_sw_if_index_set = 1;
5476 else if (unformat (i, "shg %d", &shg))
5478 else if (unformat (i, "bvi"))
5480 else if (unformat (i, "enable"))
5482 else if (unformat (i, "disable"))
5488 if (rx_sw_if_index_set == 0)
5490 errmsg ("missing rx interface name or sw_if_index");
5494 if (enable && (bd_id_set == 0))
5496 errmsg ("missing bridge domain");
5500 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5502 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5503 mp->bd_id = ntohl (bd_id);
5506 mp->enable = enable;
5515 api_bridge_domain_dump (vat_main_t * vam)
5517 unformat_input_t *i = vam->input;
5518 vl_api_bridge_domain_dump_t *mp;
5522 /* Parse args required to build the message */
5523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5525 if (unformat (i, "bd_id %d", &bd_id))
5531 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5532 mp->bd_id = ntohl (bd_id);
5535 /* Use a control ping for synchronization */
5537 vl_api_control_ping_t *mp;
5538 M (CONTROL_PING, control_ping);
5548 api_bridge_domain_add_del (vat_main_t * vam)
5550 unformat_input_t *i = vam->input;
5551 vl_api_bridge_domain_add_del_t *mp;
5555 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5558 /* Parse args required to build the message */
5559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5561 if (unformat (i, "bd_id %d", &bd_id))
5563 else if (unformat (i, "flood %d", &flood))
5565 else if (unformat (i, "uu-flood %d", &uu_flood))
5567 else if (unformat (i, "forward %d", &forward))
5569 else if (unformat (i, "learn %d", &learn))
5571 else if (unformat (i, "arp-term %d", &arp_term))
5573 else if (unformat (i, "mac-age %d", &mac_age))
5575 else if (unformat (i, "del"))
5578 flood = uu_flood = forward = learn = 0;
5586 errmsg ("missing bridge domain");
5592 errmsg ("mac age must be less than 256 ");
5596 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5598 mp->bd_id = ntohl (bd_id);
5600 mp->uu_flood = uu_flood;
5601 mp->forward = forward;
5603 mp->arp_term = arp_term;
5604 mp->is_add = is_add;
5605 mp->mac_age = (u8) mac_age;
5614 api_l2fib_add_del (vat_main_t * vam)
5616 unformat_input_t *i = vam->input;
5617 vl_api_l2fib_add_del_t *mp;
5623 u32 sw_if_index = ~0;
5624 u8 sw_if_index_set = 0;
5633 /* Parse args required to build the message */
5634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5636 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5638 else if (unformat (i, "bd_id %d", &bd_id))
5640 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5641 sw_if_index_set = 1;
5642 else if (unformat (i, "sw_if"))
5644 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5647 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5648 sw_if_index_set = 1;
5653 else if (unformat (i, "static"))
5655 else if (unformat (i, "filter"))
5660 else if (unformat (i, "bvi"))
5665 else if (unformat (i, "del"))
5667 else if (unformat (i, "count %d", &count))
5675 errmsg ("missing mac address");
5681 errmsg ("missing bridge domain");
5685 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5687 errmsg ("missing interface name or sw_if_index");
5693 /* Turn on async mode */
5694 vam->async_mode = 1;
5695 vam->async_errors = 0;
5696 before = vat_time_now (vam);
5699 for (j = 0; j < count; j++)
5701 M (L2FIB_ADD_DEL, l2fib_add_del);
5704 mp->bd_id = ntohl (bd_id);
5705 mp->is_add = is_add;
5709 mp->sw_if_index = ntohl (sw_if_index);
5710 mp->static_mac = static_mac;
5711 mp->filter_mac = filter_mac;
5712 mp->bvi_mac = bvi_mac;
5714 increment_mac_address (&mac);
5721 vl_api_control_ping_t *mp;
5724 /* Shut off async mode */
5725 vam->async_mode = 0;
5727 M (CONTROL_PING, control_ping);
5730 timeout = vat_time_now (vam) + 1.0;
5731 while (vat_time_now (vam) < timeout)
5732 if (vam->result_ready == 1)
5737 if (vam->retval == -99)
5740 if (vam->async_errors > 0)
5742 errmsg ("%d asynchronous errors", vam->async_errors);
5745 vam->async_errors = 0;
5746 after = vat_time_now (vam);
5748 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5749 count, after - before, count / (after - before));
5753 /* Wait for a reply... */
5756 /* Return the good/bad news */
5757 return (vam->retval);
5761 api_l2_flags (vat_main_t * vam)
5763 unformat_input_t *i = vam->input;
5764 vl_api_l2_flags_t *mp;
5767 u32 feature_bitmap = 0;
5768 u8 sw_if_index_set = 0;
5770 /* Parse args required to build the message */
5771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5773 if (unformat (i, "sw_if_index %d", &sw_if_index))
5774 sw_if_index_set = 1;
5775 else if (unformat (i, "sw_if"))
5777 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5780 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5781 sw_if_index_set = 1;
5786 else if (unformat (i, "learn"))
5787 feature_bitmap |= L2INPUT_FEAT_LEARN;
5788 else if (unformat (i, "forward"))
5789 feature_bitmap |= L2INPUT_FEAT_FWD;
5790 else if (unformat (i, "flood"))
5791 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5792 else if (unformat (i, "uu-flood"))
5793 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5798 if (sw_if_index_set == 0)
5800 errmsg ("missing interface name or sw_if_index");
5804 M (L2_FLAGS, l2_flags);
5806 mp->sw_if_index = ntohl (sw_if_index);
5807 mp->feature_bitmap = ntohl (feature_bitmap);
5816 api_bridge_flags (vat_main_t * vam)
5818 unformat_input_t *i = vam->input;
5819 vl_api_bridge_flags_t *mp;
5826 /* Parse args required to build the message */
5827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5829 if (unformat (i, "bd_id %d", &bd_id))
5831 else if (unformat (i, "learn"))
5833 else if (unformat (i, "forward"))
5835 else if (unformat (i, "flood"))
5837 else if (unformat (i, "uu-flood"))
5838 flags |= L2_UU_FLOOD;
5839 else if (unformat (i, "arp-term"))
5840 flags |= L2_ARP_TERM;
5841 else if (unformat (i, "off"))
5843 else if (unformat (i, "disable"))
5851 errmsg ("missing bridge domain");
5855 M (BRIDGE_FLAGS, bridge_flags);
5857 mp->bd_id = ntohl (bd_id);
5858 mp->feature_bitmap = ntohl (flags);
5859 mp->is_set = is_set;
5868 api_bd_ip_mac_add_del (vat_main_t * vam)
5870 unformat_input_t *i = vam->input;
5871 vl_api_bd_ip_mac_add_del_t *mp;
5879 ip4_address_t v4addr;
5880 ip6_address_t v6addr;
5884 /* Parse args required to build the message */
5885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5887 if (unformat (i, "bd_id %d", &bd_id))
5891 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5895 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5900 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5904 else if (unformat (i, "del"))
5912 errmsg ("missing bridge domain");
5915 else if (ip_set == 0)
5917 errmsg ("missing IP address");
5920 else if (mac_set == 0)
5922 errmsg ("missing MAC address");
5926 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5928 mp->bd_id = ntohl (bd_id);
5929 mp->is_ipv6 = is_ipv6;
5930 mp->is_add = is_add;
5932 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5934 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5935 clib_memcpy (mp->mac_address, macaddr, 6);
5943 api_tap_connect (vat_main_t * vam)
5945 unformat_input_t *i = vam->input;
5946 vl_api_tap_connect_t *mp;
5953 ip4_address_t ip4_address;
5955 int ip4_address_set = 0;
5956 ip6_address_t ip6_address;
5958 int ip6_address_set = 0;
5960 memset (mac_address, 0, sizeof (mac_address));
5962 /* Parse args required to build the message */
5963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5965 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5969 else if (unformat (i, "random-mac"))
5971 else if (unformat (i, "tapname %s", &tap_name))
5973 else if (unformat (i, "tag %s", &tag))
5975 else if (unformat (i, "address %U/%d",
5976 unformat_ip4_address, &ip4_address, &ip4_mask_width))
5977 ip4_address_set = 1;
5978 else if (unformat (i, "address %U/%d",
5979 unformat_ip6_address, &ip6_address, &ip6_mask_width))
5980 ip6_address_set = 1;
5987 errmsg ("missing tap name");
5990 if (vec_len (tap_name) > 63)
5992 errmsg ("tap name too long");
5995 vec_add1 (tap_name, 0);
5997 if (vec_len (tag) > 63)
5999 errmsg ("tag too long");
6003 /* Construct the API message */
6004 M (TAP_CONNECT, tap_connect);
6006 mp->use_random_mac = random_mac;
6007 clib_memcpy (mp->mac_address, mac_address, 6);
6008 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6010 clib_memcpy (mp->tag, tag, vec_len (tag));
6012 if (ip4_address_set)
6014 mp->ip4_address_set = 1;
6015 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6016 mp->ip4_mask_width = ip4_mask_width;
6018 if (ip6_address_set)
6020 mp->ip6_address_set = 1;
6021 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6022 mp->ip6_mask_width = ip6_mask_width;
6025 vec_free (tap_name);
6031 /* Wait for a reply... */
6036 api_tap_modify (vat_main_t * vam)
6038 unformat_input_t *i = vam->input;
6039 vl_api_tap_modify_t *mp;
6045 u32 sw_if_index = ~0;
6046 u8 sw_if_index_set = 0;
6048 memset (mac_address, 0, sizeof (mac_address));
6050 /* Parse args required to build the message */
6051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6053 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6054 sw_if_index_set = 1;
6055 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6056 sw_if_index_set = 1;
6057 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6061 else if (unformat (i, "random-mac"))
6063 else if (unformat (i, "tapname %s", &tap_name))
6069 if (sw_if_index_set == 0)
6071 errmsg ("missing vpp interface name");
6076 errmsg ("missing tap name");
6079 if (vec_len (tap_name) > 63)
6081 errmsg ("tap name too long");
6083 vec_add1 (tap_name, 0);
6085 /* Construct the API message */
6086 M (TAP_MODIFY, tap_modify);
6088 mp->use_random_mac = random_mac;
6089 mp->sw_if_index = ntohl (sw_if_index);
6090 clib_memcpy (mp->mac_address, mac_address, 6);
6091 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6092 vec_free (tap_name);
6097 /* Wait for a reply... */
6102 api_tap_delete (vat_main_t * vam)
6104 unformat_input_t *i = vam->input;
6105 vl_api_tap_delete_t *mp;
6107 u32 sw_if_index = ~0;
6108 u8 sw_if_index_set = 0;
6110 /* Parse args required to build the message */
6111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6114 sw_if_index_set = 1;
6115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6116 sw_if_index_set = 1;
6121 if (sw_if_index_set == 0)
6123 errmsg ("missing vpp interface name");
6127 /* Construct the API message */
6128 M (TAP_DELETE, tap_delete);
6130 mp->sw_if_index = ntohl (sw_if_index);
6135 /* Wait for a reply... */
6140 api_ip_add_del_route (vat_main_t * vam)
6142 unformat_input_t *i = vam->input;
6143 vl_api_ip_add_del_route_t *mp;
6145 u32 sw_if_index = ~0, vrf_id = 0;
6147 u8 is_local = 0, is_drop = 0;
6148 u8 is_unreach = 0, is_prohibit = 0;
6149 u8 create_vrf_if_needed = 0;
6151 u32 next_hop_weight = 1;
6153 u8 is_multipath = 0;
6155 u8 address_length_set = 0;
6156 u32 next_hop_table_id = 0;
6157 u32 resolve_attempts = 0;
6158 u32 dst_address_length = 0;
6159 u8 next_hop_set = 0;
6160 ip4_address_t v4_dst_address, v4_next_hop_address;
6161 ip6_address_t v6_dst_address, v6_next_hop_address;
6165 u32 random_add_del = 0;
6166 u32 *random_vector = 0;
6168 u32 random_seed = 0xdeaddabe;
6169 u32 classify_table_index = ~0;
6171 u8 resolve_host = 0, resolve_attached = 0;
6172 mpls_label_t *next_hop_out_label_stack = NULL;
6173 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6174 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6176 /* Parse args required to build the message */
6177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6183 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6188 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6193 else if (unformat (i, "/%d", &dst_address_length))
6195 address_length_set = 1;
6198 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6199 &v4_next_hop_address))
6203 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6204 &v6_next_hop_address))
6208 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6210 else if (unformat (i, "weight %d", &next_hop_weight))
6212 else if (unformat (i, "drop"))
6216 else if (unformat (i, "null-send-unreach"))
6220 else if (unformat (i, "null-send-prohibit"))
6224 else if (unformat (i, "local"))
6228 else if (unformat (i, "classify %d", &classify_table_index))
6232 else if (unformat (i, "del"))
6234 else if (unformat (i, "add"))
6236 else if (unformat (i, "not-last"))
6238 else if (unformat (i, "resolve-via-host"))
6240 else if (unformat (i, "resolve-via-attached"))
6241 resolve_attached = 1;
6242 else if (unformat (i, "multipath"))
6244 else if (unformat (i, "vrf %d", &vrf_id))
6246 else if (unformat (i, "create-vrf"))
6247 create_vrf_if_needed = 1;
6248 else if (unformat (i, "count %d", &count))
6250 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6252 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6254 else if (unformat (i, "out-label %d", &next_hop_out_label))
6255 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6256 else if (unformat (i, "via-label %d", &next_hop_via_label))
6258 else if (unformat (i, "random"))
6260 else if (unformat (i, "seed %d", &random_seed))
6264 clib_warning ("parse error '%U'", format_unformat_error, i);
6269 if (!next_hop_set && !is_drop && !is_local &&
6270 !is_classify && !is_unreach && !is_prohibit &&
6271 MPLS_LABEL_INVALID == next_hop_via_label)
6274 ("next hop / local / drop / unreach / prohibit / classify not set");
6278 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6280 errmsg ("next hop and next-hop via label set");
6283 if (address_set == 0)
6285 errmsg ("missing addresses");
6289 if (address_length_set == 0)
6291 errmsg ("missing address length");
6295 /* Generate a pile of unique, random routes */
6298 u32 this_random_address;
6299 random_hash = hash_create (count, sizeof (uword));
6301 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6302 for (j = 0; j <= count; j++)
6306 this_random_address = random_u32 (&random_seed);
6307 this_random_address =
6308 clib_host_to_net_u32 (this_random_address);
6310 while (hash_get (random_hash, this_random_address));
6311 vec_add1 (random_vector, this_random_address);
6312 hash_set (random_hash, this_random_address, 1);
6314 hash_free (random_hash);
6315 v4_dst_address.as_u32 = random_vector[0];
6320 /* Turn on async mode */
6321 vam->async_mode = 1;
6322 vam->async_errors = 0;
6323 before = vat_time_now (vam);
6326 for (j = 0; j < count; j++)
6328 /* Construct the API message */
6329 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6330 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6332 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6333 mp->table_id = ntohl (vrf_id);
6334 mp->create_vrf_if_needed = create_vrf_if_needed;
6336 mp->is_add = is_add;
6337 mp->is_drop = is_drop;
6338 mp->is_unreach = is_unreach;
6339 mp->is_prohibit = is_prohibit;
6340 mp->is_ipv6 = is_ipv6;
6341 mp->is_local = is_local;
6342 mp->is_classify = is_classify;
6343 mp->is_multipath = is_multipath;
6344 mp->is_resolve_host = resolve_host;
6345 mp->is_resolve_attached = resolve_attached;
6346 mp->not_last = not_last;
6347 mp->next_hop_weight = next_hop_weight;
6348 mp->dst_address_length = dst_address_length;
6349 mp->next_hop_table_id = ntohl (next_hop_table_id);
6350 mp->classify_table_index = ntohl (classify_table_index);
6351 mp->next_hop_via_label = ntohl (next_hop_via_label);
6352 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6353 if (0 != mp->next_hop_n_out_labels)
6355 memcpy (mp->next_hop_out_label_stack,
6356 next_hop_out_label_stack,
6357 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6358 vec_free (next_hop_out_label_stack);
6363 clib_memcpy (mp->dst_address, &v6_dst_address,
6364 sizeof (v6_dst_address));
6366 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6367 sizeof (v6_next_hop_address));
6368 increment_v6_address (&v6_dst_address);
6372 clib_memcpy (mp->dst_address, &v4_dst_address,
6373 sizeof (v4_dst_address));
6375 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6376 sizeof (v4_next_hop_address));
6378 v4_dst_address.as_u32 = random_vector[j + 1];
6380 increment_v4_address (&v4_dst_address);
6384 /* If we receive SIGTERM, stop now... */
6389 /* When testing multiple add/del ops, use a control-ping to sync */
6392 vl_api_control_ping_t *mp;
6395 /* Shut off async mode */
6396 vam->async_mode = 0;
6398 M (CONTROL_PING, control_ping);
6401 timeout = vat_time_now (vam) + 1.0;
6402 while (vat_time_now (vam) < timeout)
6403 if (vam->result_ready == 1)
6408 if (vam->retval == -99)
6411 if (vam->async_errors > 0)
6413 errmsg ("%d asynchronous errors", vam->async_errors);
6416 vam->async_errors = 0;
6417 after = vat_time_now (vam);
6419 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6423 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6424 count, after - before, count / (after - before));
6428 /* Wait for a reply... */
6432 /* Return the good/bad news */
6433 return (vam->retval);
6437 api_ip_mroute_add_del (vat_main_t * vam)
6439 unformat_input_t *i = vam->input;
6440 vl_api_ip_mroute_add_del_t *mp;
6442 u32 sw_if_index = ~0, vrf_id = 0;
6445 u8 create_vrf_if_needed = 0;
6448 u32 grp_address_length = 0;
6449 ip4_address_t v4_grp_address, v4_src_address;
6450 ip6_address_t v6_grp_address, v6_src_address;
6451 mfib_itf_flags_t iflags = 0;
6452 mfib_entry_flags_t eflags = 0;
6454 /* Parse args required to build the message */
6455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6457 if (unformat (i, "sw_if_index %d", &sw_if_index))
6459 else if (unformat (i, "%U %U",
6460 unformat_ip4_address, &v4_src_address,
6461 unformat_ip4_address, &v4_grp_address))
6463 grp_address_length = 64;
6467 else if (unformat (i, "%U %U",
6468 unformat_ip6_address, &v6_src_address,
6469 unformat_ip6_address, &v6_grp_address))
6471 grp_address_length = 256;
6475 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6477 memset (&v4_src_address, 0, sizeof (v4_src_address));
6478 grp_address_length = 32;
6482 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6484 memset (&v6_src_address, 0, sizeof (v6_src_address));
6485 grp_address_length = 128;
6489 else if (unformat (i, "/%d", &grp_address_length))
6491 else if (unformat (i, "local"))
6495 else if (unformat (i, "del"))
6497 else if (unformat (i, "add"))
6499 else if (unformat (i, "vrf %d", &vrf_id))
6501 else if (unformat (i, "create-vrf"))
6502 create_vrf_if_needed = 1;
6503 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6505 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6509 clib_warning ("parse error '%U'", format_unformat_error, i);
6514 if (address_set == 0)
6516 errmsg ("missing addresses\n");
6520 /* Construct the API message */
6521 M (IP_MROUTE_ADD_DEL, ip_mroute_add_del);
6523 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6524 mp->table_id = ntohl (vrf_id);
6525 mp->create_vrf_if_needed = create_vrf_if_needed;
6527 mp->is_add = is_add;
6528 mp->is_ipv6 = is_ipv6;
6529 mp->is_local = is_local;
6530 mp->itf_flags = ntohl (iflags);
6531 mp->entry_flags = ntohl (eflags);
6532 mp->grp_address_length = grp_address_length;
6533 mp->grp_address_length = ntohs (mp->grp_address_length);
6537 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6538 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6542 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6543 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6549 /* Wait for a reply... */
6552 /* Return the good/bad news */
6553 return (vam->retval);
6557 api_mpls_route_add_del (vat_main_t * vam)
6559 unformat_input_t *i = vam->input;
6560 vl_api_mpls_route_add_del_t *mp;
6562 u32 sw_if_index = ~0, table_id = 0;
6563 u8 create_table_if_needed = 0;
6565 u32 next_hop_weight = 1;
6566 u8 is_multipath = 0;
6567 u32 next_hop_table_id = 0;
6568 u8 next_hop_set = 0;
6569 ip4_address_t v4_next_hop_address = {
6572 ip6_address_t v6_next_hop_address = { {0} };
6576 u32 classify_table_index = ~0;
6578 u8 resolve_host = 0, resolve_attached = 0;
6579 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6580 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6581 mpls_label_t *next_hop_out_label_stack = NULL;
6582 mpls_label_t local_label = MPLS_LABEL_INVALID;
6584 u8 next_hop_proto_is_ip4 = 1;
6586 /* Parse args required to build the message */
6587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6589 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6591 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6593 else if (unformat (i, "%d", &local_label))
6595 else if (unformat (i, "eos"))
6597 else if (unformat (i, "non-eos"))
6599 else if (unformat (i, "via %U", unformat_ip4_address,
6600 &v4_next_hop_address))
6603 next_hop_proto_is_ip4 = 1;
6605 else if (unformat (i, "via %U", unformat_ip6_address,
6606 &v6_next_hop_address))
6609 next_hop_proto_is_ip4 = 0;
6611 else if (unformat (i, "weight %d", &next_hop_weight))
6613 else if (unformat (i, "create-table"))
6614 create_table_if_needed = 1;
6615 else if (unformat (i, "classify %d", &classify_table_index))
6619 else if (unformat (i, "del"))
6621 else if (unformat (i, "add"))
6623 else if (unformat (i, "resolve-via-host"))
6625 else if (unformat (i, "resolve-via-attached"))
6626 resolve_attached = 1;
6627 else if (unformat (i, "multipath"))
6629 else if (unformat (i, "count %d", &count))
6631 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6634 next_hop_proto_is_ip4 = 1;
6636 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6639 next_hop_proto_is_ip4 = 0;
6641 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6643 else if (unformat (i, "via-label %d", &next_hop_via_label))
6645 else if (unformat (i, "out-label %d", &next_hop_out_label))
6646 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6649 clib_warning ("parse error '%U'", format_unformat_error, i);
6654 if (!next_hop_set && !is_classify)
6656 errmsg ("next hop / classify not set");
6660 if (MPLS_LABEL_INVALID == local_label)
6662 errmsg ("missing label");
6668 /* Turn on async mode */
6669 vam->async_mode = 1;
6670 vam->async_errors = 0;
6671 before = vat_time_now (vam);
6674 for (j = 0; j < count; j++)
6676 /* Construct the API message */
6677 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6678 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6680 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6681 mp->mr_table_id = ntohl (table_id);
6682 mp->mr_create_table_if_needed = create_table_if_needed;
6684 mp->mr_is_add = is_add;
6685 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6686 mp->mr_is_classify = is_classify;
6687 mp->mr_is_multipath = is_multipath;
6688 mp->mr_is_resolve_host = resolve_host;
6689 mp->mr_is_resolve_attached = resolve_attached;
6690 mp->mr_next_hop_weight = next_hop_weight;
6691 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6692 mp->mr_classify_table_index = ntohl (classify_table_index);
6693 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6694 mp->mr_label = ntohl (local_label);
6695 mp->mr_eos = is_eos;
6697 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6698 if (0 != mp->mr_next_hop_n_out_labels)
6700 memcpy (mp->mr_next_hop_out_label_stack,
6701 next_hop_out_label_stack,
6702 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6703 vec_free (next_hop_out_label_stack);
6708 if (next_hop_proto_is_ip4)
6710 clib_memcpy (mp->mr_next_hop,
6711 &v4_next_hop_address,
6712 sizeof (v4_next_hop_address));
6716 clib_memcpy (mp->mr_next_hop,
6717 &v6_next_hop_address,
6718 sizeof (v6_next_hop_address));
6725 /* If we receive SIGTERM, stop now... */
6730 /* When testing multiple add/del ops, use a control-ping to sync */
6733 vl_api_control_ping_t *mp;
6736 /* Shut off async mode */
6737 vam->async_mode = 0;
6739 M (CONTROL_PING, control_ping);
6742 timeout = vat_time_now (vam) + 1.0;
6743 while (vat_time_now (vam) < timeout)
6744 if (vam->result_ready == 1)
6749 if (vam->retval == -99)
6752 if (vam->async_errors > 0)
6754 errmsg ("%d asynchronous errors", vam->async_errors);
6757 vam->async_errors = 0;
6758 after = vat_time_now (vam);
6760 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6764 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6765 count, after - before, count / (after - before));
6769 /* Wait for a reply... */
6773 /* Return the good/bad news */
6774 return (vam->retval);
6778 api_mpls_ip_bind_unbind (vat_main_t * vam)
6780 unformat_input_t *i = vam->input;
6781 vl_api_mpls_ip_bind_unbind_t *mp;
6783 u32 ip_table_id = 0;
6784 u8 create_table_if_needed = 0;
6787 ip4_address_t v4_address;
6788 ip6_address_t v6_address;
6791 mpls_label_t local_label = MPLS_LABEL_INVALID;
6793 /* Parse args required to build the message */
6794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6796 if (unformat (i, "%U/%d", unformat_ip4_address,
6797 &v4_address, &address_length))
6802 else if (unformat (i, "%U/%d", unformat_ip6_address,
6803 &v6_address, &address_length))
6808 else if (unformat (i, "%d", &local_label))
6810 else if (unformat (i, "create-table"))
6811 create_table_if_needed = 1;
6812 else if (unformat (i, "table-id %d", &ip_table_id))
6814 else if (unformat (i, "unbind"))
6816 else if (unformat (i, "bind"))
6820 clib_warning ("parse error '%U'", format_unformat_error, i);
6827 errmsg ("IP addres not set");
6831 if (MPLS_LABEL_INVALID == local_label)
6833 errmsg ("missing label");
6837 /* Construct the API message */
6838 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6840 mp->mb_create_table_if_needed = create_table_if_needed;
6841 mp->mb_is_bind = is_bind;
6842 mp->mb_is_ip4 = is_ip4;
6843 mp->mb_ip_table_id = ntohl (ip_table_id);
6844 mp->mb_mpls_table_id = 0;
6845 mp->mb_label = ntohl (local_label);
6846 mp->mb_address_length = address_length;
6849 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6851 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6856 /* Wait for a reply... */
6861 api_proxy_arp_add_del (vat_main_t * vam)
6863 unformat_input_t *i = vam->input;
6864 vl_api_proxy_arp_add_del_t *mp;
6868 ip4_address_t lo, hi;
6871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6873 if (unformat (i, "vrf %d", &vrf_id))
6875 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6876 unformat_ip4_address, &hi))
6878 else if (unformat (i, "del"))
6882 clib_warning ("parse error '%U'", format_unformat_error, i);
6889 errmsg ("address range not set");
6893 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6895 mp->vrf_id = ntohl (vrf_id);
6896 mp->is_add = is_add;
6897 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6898 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6907 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6909 unformat_input_t *i = vam->input;
6910 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6914 u8 sw_if_index_set = 0;
6916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6918 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6919 sw_if_index_set = 1;
6920 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6921 sw_if_index_set = 1;
6922 else if (unformat (i, "enable"))
6924 else if (unformat (i, "disable"))
6928 clib_warning ("parse error '%U'", format_unformat_error, i);
6933 if (sw_if_index_set == 0)
6935 errmsg ("missing interface name or sw_if_index");
6939 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6941 mp->sw_if_index = ntohl (sw_if_index);
6942 mp->enable_disable = enable;
6951 api_mpls_tunnel_add_del (vat_main_t * vam)
6953 unformat_input_t *i = vam->input;
6954 vl_api_mpls_tunnel_add_del_t *mp;
6959 u32 sw_if_index = ~0;
6960 u32 next_hop_sw_if_index = ~0;
6961 u32 next_hop_proto_is_ip4 = 1;
6963 u32 next_hop_table_id = 0;
6964 ip4_address_t v4_next_hop_address = {
6967 ip6_address_t v6_next_hop_address = { {0} };
6968 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6972 if (unformat (i, "add"))
6974 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6976 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6978 else if (unformat (i, "via %U",
6979 unformat_ip4_address, &v4_next_hop_address))
6981 next_hop_proto_is_ip4 = 1;
6983 else if (unformat (i, "via %U",
6984 unformat_ip6_address, &v6_next_hop_address))
6986 next_hop_proto_is_ip4 = 0;
6988 else if (unformat (i, "l2-only"))
6990 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6992 else if (unformat (i, "out-label %d", &next_hop_out_label))
6993 vec_add1 (labels, ntohl (next_hop_out_label));
6996 clib_warning ("parse error '%U'", format_unformat_error, i);
7001 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
7002 sizeof (mpls_label_t) * vec_len (labels));
7004 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7005 mp->mt_sw_if_index = ntohl (sw_if_index);
7006 mp->mt_is_add = is_add;
7007 mp->mt_l2_only = l2_only;
7008 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7009 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7011 mp->mt_next_hop_n_out_labels = vec_len (labels);
7013 if (0 != mp->mt_next_hop_n_out_labels)
7015 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7016 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7020 if (next_hop_proto_is_ip4)
7022 clib_memcpy (mp->mt_next_hop,
7023 &v4_next_hop_address, sizeof (v4_next_hop_address));
7027 clib_memcpy (mp->mt_next_hop,
7028 &v6_next_hop_address, sizeof (v6_next_hop_address));
7038 api_sw_interface_set_unnumbered (vat_main_t * vam)
7040 unformat_input_t *i = vam->input;
7041 vl_api_sw_interface_set_unnumbered_t *mp;
7044 u32 unnum_sw_index = ~0;
7046 u8 sw_if_index_set = 0;
7048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7051 sw_if_index_set = 1;
7052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7053 sw_if_index_set = 1;
7054 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7056 else if (unformat (i, "del"))
7060 clib_warning ("parse error '%U'", format_unformat_error, i);
7065 if (sw_if_index_set == 0)
7067 errmsg ("missing interface name or sw_if_index");
7071 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
7073 mp->sw_if_index = ntohl (sw_if_index);
7074 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7075 mp->is_add = is_add;
7084 api_ip_neighbor_add_del (vat_main_t * vam)
7086 unformat_input_t *i = vam->input;
7087 vl_api_ip_neighbor_add_del_t *mp;
7090 u8 sw_if_index_set = 0;
7096 u8 v4_address_set = 0;
7097 u8 v6_address_set = 0;
7098 ip4_address_t v4address;
7099 ip6_address_t v6address;
7101 memset (mac_address, 0, sizeof (mac_address));
7103 /* Parse args required to build the message */
7104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7106 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7110 else if (unformat (i, "del"))
7113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7114 sw_if_index_set = 1;
7115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7116 sw_if_index_set = 1;
7117 else if (unformat (i, "is_static"))
7119 else if (unformat (i, "vrf %d", &vrf_id))
7121 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7123 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7127 clib_warning ("parse error '%U'", format_unformat_error, i);
7132 if (sw_if_index_set == 0)
7134 errmsg ("missing interface name or sw_if_index");
7137 if (v4_address_set && v6_address_set)
7139 errmsg ("both v4 and v6 addresses set");
7142 if (!v4_address_set && !v6_address_set)
7144 errmsg ("no address set");
7148 /* Construct the API message */
7149 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
7151 mp->sw_if_index = ntohl (sw_if_index);
7152 mp->is_add = is_add;
7153 mp->vrf_id = ntohl (vrf_id);
7154 mp->is_static = is_static;
7156 clib_memcpy (mp->mac_address, mac_address, 6);
7160 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7164 /* mp->is_ipv6 = 0; via memset in M macro above */
7165 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7171 /* Wait for a reply, return good/bad news */
7179 api_reset_vrf (vat_main_t * vam)
7181 unformat_input_t *i = vam->input;
7182 vl_api_reset_vrf_t *mp;
7188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7190 if (unformat (i, "vrf %d", &vrf_id))
7192 else if (unformat (i, "ipv6"))
7196 clib_warning ("parse error '%U'", format_unformat_error, i);
7201 if (vrf_id_set == 0)
7203 errmsg ("missing vrf id");
7207 M (RESET_VRF, reset_vrf);
7209 mp->vrf_id = ntohl (vrf_id);
7210 mp->is_ipv6 = is_ipv6;
7219 api_create_vlan_subif (vat_main_t * vam)
7221 unformat_input_t *i = vam->input;
7222 vl_api_create_vlan_subif_t *mp;
7225 u8 sw_if_index_set = 0;
7229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7231 if (unformat (i, "sw_if_index %d", &sw_if_index))
7232 sw_if_index_set = 1;
7234 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7235 sw_if_index_set = 1;
7236 else if (unformat (i, "vlan %d", &vlan_id))
7240 clib_warning ("parse error '%U'", format_unformat_error, i);
7245 if (sw_if_index_set == 0)
7247 errmsg ("missing interface name or sw_if_index");
7251 if (vlan_id_set == 0)
7253 errmsg ("missing vlan_id");
7256 M (CREATE_VLAN_SUBIF, create_vlan_subif);
7258 mp->sw_if_index = ntohl (sw_if_index);
7259 mp->vlan_id = ntohl (vlan_id);
7267 #define foreach_create_subif_bit \
7274 _(outer_vlan_id_any) \
7275 _(inner_vlan_id_any)
7278 api_create_subif (vat_main_t * vam)
7280 unformat_input_t *i = vam->input;
7281 vl_api_create_subif_t *mp;
7284 u8 sw_if_index_set = 0;
7291 u32 exact_match = 0;
7292 u32 default_sub = 0;
7293 u32 outer_vlan_id_any = 0;
7294 u32 inner_vlan_id_any = 0;
7296 u16 outer_vlan_id = 0;
7297 u16 inner_vlan_id = 0;
7299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7301 if (unformat (i, "sw_if_index %d", &sw_if_index))
7302 sw_if_index_set = 1;
7304 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7305 sw_if_index_set = 1;
7306 else if (unformat (i, "sub_id %d", &sub_id))
7308 else if (unformat (i, "outer_vlan_id %d", &tmp))
7309 outer_vlan_id = tmp;
7310 else if (unformat (i, "inner_vlan_id %d", &tmp))
7311 inner_vlan_id = tmp;
7313 #define _(a) else if (unformat (i, #a)) a = 1 ;
7314 foreach_create_subif_bit
7318 clib_warning ("parse error '%U'", format_unformat_error, i);
7323 if (sw_if_index_set == 0)
7325 errmsg ("missing interface name or sw_if_index");
7329 if (sub_id_set == 0)
7331 errmsg ("missing sub_id");
7334 M (CREATE_SUBIF, create_subif);
7336 mp->sw_if_index = ntohl (sw_if_index);
7337 mp->sub_id = ntohl (sub_id);
7339 #define _(a) mp->a = a;
7340 foreach_create_subif_bit;
7343 mp->outer_vlan_id = ntohs (outer_vlan_id);
7344 mp->inner_vlan_id = ntohs (inner_vlan_id);
7353 api_oam_add_del (vat_main_t * vam)
7355 unformat_input_t *i = vam->input;
7356 vl_api_oam_add_del_t *mp;
7360 ip4_address_t src, dst;
7364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7366 if (unformat (i, "vrf %d", &vrf_id))
7368 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7370 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7372 else if (unformat (i, "del"))
7376 clib_warning ("parse error '%U'", format_unformat_error, i);
7383 errmsg ("missing src addr");
7389 errmsg ("missing dst addr");
7393 M (OAM_ADD_DEL, oam_add_del);
7395 mp->vrf_id = ntohl (vrf_id);
7396 mp->is_add = is_add;
7397 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7398 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7407 api_reset_fib (vat_main_t * vam)
7409 unformat_input_t *i = vam->input;
7410 vl_api_reset_fib_t *mp;
7416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7418 if (unformat (i, "vrf %d", &vrf_id))
7420 else if (unformat (i, "ipv6"))
7424 clib_warning ("parse error '%U'", format_unformat_error, i);
7429 if (vrf_id_set == 0)
7431 errmsg ("missing vrf id");
7435 M (RESET_FIB, reset_fib);
7437 mp->vrf_id = ntohl (vrf_id);
7438 mp->is_ipv6 = is_ipv6;
7447 api_dhcp_proxy_config (vat_main_t * vam)
7449 unformat_input_t *i = vam->input;
7450 vl_api_dhcp_proxy_config_t *mp;
7455 u8 v4_address_set = 0;
7456 u8 v6_address_set = 0;
7457 ip4_address_t v4address;
7458 ip6_address_t v6address;
7459 u8 v4_src_address_set = 0;
7460 u8 v6_src_address_set = 0;
7461 ip4_address_t v4srcaddress;
7462 ip6_address_t v6srcaddress;
7464 /* Parse args required to build the message */
7465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7467 if (unformat (i, "del"))
7469 else if (unformat (i, "vrf %d", &vrf_id))
7471 else if (unformat (i, "insert-cid %d", &insert_cid))
7473 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7475 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7477 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7478 v4_src_address_set = 1;
7479 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7480 v6_src_address_set = 1;
7485 if (v4_address_set && v6_address_set)
7487 errmsg ("both v4 and v6 server addresses set");
7490 if (!v4_address_set && !v6_address_set)
7492 errmsg ("no server addresses set");
7496 if (v4_src_address_set && v6_src_address_set)
7498 errmsg ("both v4 and v6 src addresses set");
7501 if (!v4_src_address_set && !v6_src_address_set)
7503 errmsg ("no src addresses set");
7507 if (!(v4_src_address_set && v4_address_set) &&
7508 !(v6_src_address_set && v6_address_set))
7510 errmsg ("no matching server and src addresses set");
7514 /* Construct the API message */
7515 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7517 mp->insert_circuit_id = insert_cid;
7518 mp->is_add = is_add;
7519 mp->vrf_id = ntohl (vrf_id);
7523 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7524 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7528 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7529 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7535 /* Wait for a reply, return good/bad news */
7542 api_dhcp_proxy_config_2 (vat_main_t * vam)
7544 unformat_input_t *i = vam->input;
7545 vl_api_dhcp_proxy_config_2_t *mp;
7548 u32 server_vrf_id = 0;
7551 u8 v4_address_set = 0;
7552 u8 v6_address_set = 0;
7553 ip4_address_t v4address;
7554 ip6_address_t v6address;
7555 u8 v4_src_address_set = 0;
7556 u8 v6_src_address_set = 0;
7557 ip4_address_t v4srcaddress;
7558 ip6_address_t v6srcaddress;
7560 /* Parse args required to build the message */
7561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7563 if (unformat (i, "del"))
7565 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7567 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7569 else if (unformat (i, "insert-cid %d", &insert_cid))
7571 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7573 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7575 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7576 v4_src_address_set = 1;
7577 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7578 v6_src_address_set = 1;
7583 if (v4_address_set && v6_address_set)
7585 errmsg ("both v4 and v6 server addresses set");
7588 if (!v4_address_set && !v6_address_set)
7590 errmsg ("no server addresses set");
7594 if (v4_src_address_set && v6_src_address_set)
7596 errmsg ("both v4 and v6 src addresses set");
7599 if (!v4_src_address_set && !v6_src_address_set)
7601 errmsg ("no src addresses set");
7605 if (!(v4_src_address_set && v4_address_set) &&
7606 !(v6_src_address_set && v6_address_set))
7608 errmsg ("no matching server and src addresses set");
7612 /* Construct the API message */
7613 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7615 mp->insert_circuit_id = insert_cid;
7616 mp->is_add = is_add;
7617 mp->rx_vrf_id = ntohl (rx_vrf_id);
7618 mp->server_vrf_id = ntohl (server_vrf_id);
7622 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7623 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7627 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7628 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7634 /* Wait for a reply, return good/bad news */
7641 api_dhcp_proxy_set_vss (vat_main_t * vam)
7643 unformat_input_t *i = vam->input;
7644 vl_api_dhcp_proxy_set_vss_t *mp;
7655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7657 if (unformat (i, "tbl_id %d", &tbl_id))
7659 if (unformat (i, "fib_id %d", &fib_id))
7661 if (unformat (i, "oui %d", &oui))
7663 else if (unformat (i, "ipv6"))
7665 else if (unformat (i, "del"))
7669 clib_warning ("parse error '%U'", format_unformat_error, i);
7674 if (tbl_id_set == 0)
7676 errmsg ("missing tbl id");
7680 if (fib_id_set == 0)
7682 errmsg ("missing fib id");
7687 errmsg ("missing oui");
7691 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7692 mp->tbl_id = ntohl (tbl_id);
7693 mp->fib_id = ntohl (fib_id);
7694 mp->oui = ntohl (oui);
7695 mp->is_ipv6 = is_ipv6;
7696 mp->is_add = is_add;
7705 api_dhcp_client_config (vat_main_t * vam)
7707 unformat_input_t *i = vam->input;
7708 vl_api_dhcp_client_config_t *mp;
7711 u8 sw_if_index_set = 0;
7714 u8 disable_event = 0;
7716 /* Parse args required to build the message */
7717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7719 if (unformat (i, "del"))
7722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7723 sw_if_index_set = 1;
7724 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7725 sw_if_index_set = 1;
7726 else if (unformat (i, "hostname %s", &hostname))
7728 else if (unformat (i, "disable_event"))
7734 if (sw_if_index_set == 0)
7736 errmsg ("missing interface name or sw_if_index");
7740 if (vec_len (hostname) > 63)
7742 errmsg ("hostname too long");
7744 vec_add1 (hostname, 0);
7746 /* Construct the API message */
7747 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7749 mp->sw_if_index = ntohl (sw_if_index);
7750 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7751 vec_free (hostname);
7752 mp->is_add = is_add;
7753 mp->want_dhcp_event = disable_event ? 0 : 1;
7754 mp->pid = getpid ();
7759 /* Wait for a reply, return good/bad news */
7766 api_set_ip_flow_hash (vat_main_t * vam)
7768 unformat_input_t *i = vam->input;
7769 vl_api_set_ip_flow_hash_t *mp;
7781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7783 if (unformat (i, "vrf %d", &vrf_id))
7785 else if (unformat (i, "ipv6"))
7787 else if (unformat (i, "src"))
7789 else if (unformat (i, "dst"))
7791 else if (unformat (i, "sport"))
7793 else if (unformat (i, "dport"))
7795 else if (unformat (i, "proto"))
7797 else if (unformat (i, "reverse"))
7802 clib_warning ("parse error '%U'", format_unformat_error, i);
7807 if (vrf_id_set == 0)
7809 errmsg ("missing vrf id");
7813 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7819 mp->reverse = reverse;
7820 mp->vrf_id = ntohl (vrf_id);
7821 mp->is_ipv6 = is_ipv6;
7830 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7832 unformat_input_t *i = vam->input;
7833 vl_api_sw_interface_ip6_enable_disable_t *mp;
7836 u8 sw_if_index_set = 0;
7839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7841 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7842 sw_if_index_set = 1;
7843 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7844 sw_if_index_set = 1;
7845 else if (unformat (i, "enable"))
7847 else if (unformat (i, "disable"))
7851 clib_warning ("parse error '%U'", format_unformat_error, i);
7856 if (sw_if_index_set == 0)
7858 errmsg ("missing interface name or sw_if_index");
7862 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7864 mp->sw_if_index = ntohl (sw_if_index);
7865 mp->enable = enable;
7874 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7876 unformat_input_t *i = vam->input;
7877 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7880 u8 sw_if_index_set = 0;
7881 u8 v6_address_set = 0;
7882 ip6_address_t v6address;
7884 /* Parse args required to build the message */
7885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7888 sw_if_index_set = 1;
7889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7890 sw_if_index_set = 1;
7891 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7897 if (sw_if_index_set == 0)
7899 errmsg ("missing interface name or sw_if_index");
7902 if (!v6_address_set)
7904 errmsg ("no address set");
7908 /* Construct the API message */
7909 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7910 sw_interface_ip6_set_link_local_address);
7912 mp->sw_if_index = ntohl (sw_if_index);
7913 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7918 /* Wait for a reply, return good/bad news */
7927 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7929 unformat_input_t *i = vam->input;
7930 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7933 u8 sw_if_index_set = 0;
7934 u32 address_length = 0;
7935 u8 v6_address_set = 0;
7936 ip6_address_t v6address;
7938 u8 no_advertise = 0;
7940 u8 no_autoconfig = 0;
7943 u32 val_lifetime = 0;
7944 u32 pref_lifetime = 0;
7946 /* Parse args required to build the message */
7947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7950 sw_if_index_set = 1;
7951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7952 sw_if_index_set = 1;
7953 else if (unformat (i, "%U/%d",
7954 unformat_ip6_address, &v6address, &address_length))
7956 else if (unformat (i, "val_life %d", &val_lifetime))
7958 else if (unformat (i, "pref_life %d", &pref_lifetime))
7960 else if (unformat (i, "def"))
7962 else if (unformat (i, "noadv"))
7964 else if (unformat (i, "offl"))
7966 else if (unformat (i, "noauto"))
7968 else if (unformat (i, "nolink"))
7970 else if (unformat (i, "isno"))
7974 clib_warning ("parse error '%U'", format_unformat_error, i);
7979 if (sw_if_index_set == 0)
7981 errmsg ("missing interface name or sw_if_index");
7984 if (!v6_address_set)
7986 errmsg ("no address set");
7990 /* Construct the API message */
7991 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7993 mp->sw_if_index = ntohl (sw_if_index);
7994 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7995 mp->address_length = address_length;
7996 mp->use_default = use_default;
7997 mp->no_advertise = no_advertise;
7998 mp->off_link = off_link;
7999 mp->no_autoconfig = no_autoconfig;
8000 mp->no_onlink = no_onlink;
8002 mp->val_lifetime = ntohl (val_lifetime);
8003 mp->pref_lifetime = ntohl (pref_lifetime);
8008 /* Wait for a reply, return good/bad news */
8016 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8018 unformat_input_t *i = vam->input;
8019 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8022 u8 sw_if_index_set = 0;
8027 u8 send_unicast = 0;
8030 u8 default_router = 0;
8031 u32 max_interval = 0;
8032 u32 min_interval = 0;
8034 u32 initial_count = 0;
8035 u32 initial_interval = 0;
8038 /* Parse args required to build the message */
8039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8042 sw_if_index_set = 1;
8043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8044 sw_if_index_set = 1;
8045 else if (unformat (i, "maxint %d", &max_interval))
8047 else if (unformat (i, "minint %d", &min_interval))
8049 else if (unformat (i, "life %d", &lifetime))
8051 else if (unformat (i, "count %d", &initial_count))
8053 else if (unformat (i, "interval %d", &initial_interval))
8055 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8057 else if (unformat (i, "managed"))
8059 else if (unformat (i, "other"))
8061 else if (unformat (i, "ll"))
8063 else if (unformat (i, "send"))
8065 else if (unformat (i, "cease"))
8067 else if (unformat (i, "isno"))
8069 else if (unformat (i, "def"))
8073 clib_warning ("parse error '%U'", format_unformat_error, i);
8078 if (sw_if_index_set == 0)
8080 errmsg ("missing interface name or sw_if_index");
8084 /* Construct the API message */
8085 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
8087 mp->sw_if_index = ntohl (sw_if_index);
8088 mp->max_interval = ntohl (max_interval);
8089 mp->min_interval = ntohl (min_interval);
8090 mp->lifetime = ntohl (lifetime);
8091 mp->initial_count = ntohl (initial_count);
8092 mp->initial_interval = ntohl (initial_interval);
8093 mp->suppress = suppress;
8094 mp->managed = managed;
8096 mp->ll_option = ll_option;
8097 mp->send_unicast = send_unicast;
8100 mp->default_router = default_router;
8105 /* Wait for a reply, return good/bad news */
8113 api_set_arp_neighbor_limit (vat_main_t * vam)
8115 unformat_input_t *i = vam->input;
8116 vl_api_set_arp_neighbor_limit_t *mp;
8122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8124 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8126 else if (unformat (i, "ipv6"))
8130 clib_warning ("parse error '%U'", format_unformat_error, i);
8137 errmsg ("missing limit value");
8141 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
8143 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8144 mp->is_ipv6 = is_ipv6;
8153 api_l2_patch_add_del (vat_main_t * vam)
8155 unformat_input_t *i = vam->input;
8156 vl_api_l2_patch_add_del_t *mp;
8159 u8 rx_sw_if_index_set = 0;
8161 u8 tx_sw_if_index_set = 0;
8164 /* Parse args required to build the message */
8165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8167 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8168 rx_sw_if_index_set = 1;
8169 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8170 tx_sw_if_index_set = 1;
8171 else if (unformat (i, "rx"))
8173 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8175 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8177 rx_sw_if_index_set = 1;
8182 else if (unformat (i, "tx"))
8184 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8186 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8188 tx_sw_if_index_set = 1;
8193 else if (unformat (i, "del"))
8199 if (rx_sw_if_index_set == 0)
8201 errmsg ("missing rx interface name or rx_sw_if_index");
8205 if (tx_sw_if_index_set == 0)
8207 errmsg ("missing tx interface name or tx_sw_if_index");
8211 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
8213 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8214 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8215 mp->is_add = is_add;
8224 api_ioam_enable (vat_main_t * vam)
8226 unformat_input_t *input = vam->input;
8227 vl_api_ioam_enable_t *mp;
8230 int has_trace_option = 0;
8231 int has_pot_option = 0;
8232 int has_seqno_option = 0;
8233 int has_analyse_option = 0;
8235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8237 if (unformat (input, "trace"))
8238 has_trace_option = 1;
8239 else if (unformat (input, "pot"))
8241 else if (unformat (input, "seqno"))
8242 has_seqno_option = 1;
8243 else if (unformat (input, "analyse"))
8244 has_analyse_option = 1;
8248 M (IOAM_ENABLE, ioam_enable);
8249 mp->id = htons (id);
8250 mp->seqno = has_seqno_option;
8251 mp->analyse = has_analyse_option;
8252 mp->pot_enable = has_pot_option;
8253 mp->trace_enable = has_trace_option;
8264 api_ioam_disable (vat_main_t * vam)
8266 vl_api_ioam_disable_t *mp;
8269 M (IOAM_DISABLE, ioam_disable);
8276 api_sr_tunnel_add_del (vat_main_t * vam)
8278 unformat_input_t *i = vam->input;
8279 vl_api_sr_tunnel_add_del_t *mp;
8283 ip6_address_t src_address;
8284 int src_address_set = 0;
8285 ip6_address_t dst_address;
8287 int dst_address_set = 0;
8289 u32 rx_table_id = 0;
8290 u32 tx_table_id = 0;
8291 ip6_address_t *segments = 0;
8292 ip6_address_t *this_seg;
8293 ip6_address_t *tags = 0;
8294 ip6_address_t *this_tag;
8295 ip6_address_t next_address, tag;
8297 u8 *policy_name = 0;
8299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8301 if (unformat (i, "del"))
8303 else if (unformat (i, "name %s", &name))
8305 else if (unformat (i, "policy %s", &policy_name))
8307 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8309 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8311 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8312 src_address_set = 1;
8313 else if (unformat (i, "dst %U/%d",
8314 unformat_ip6_address, &dst_address, &dst_mask_width))
8315 dst_address_set = 1;
8316 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8318 vec_add2 (segments, this_seg, 1);
8319 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8320 sizeof (*this_seg));
8322 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8324 vec_add2 (tags, this_tag, 1);
8325 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8327 else if (unformat (i, "clean"))
8328 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8329 else if (unformat (i, "protected"))
8330 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8331 else if (unformat (i, "InPE %d", &pl_index))
8333 if (pl_index <= 0 || pl_index > 4)
8335 pl_index_range_error:
8336 errmsg ("pl index %d out of range", pl_index);
8340 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8342 else if (unformat (i, "EgPE %d", &pl_index))
8344 if (pl_index <= 0 || pl_index > 4)
8345 goto pl_index_range_error;
8347 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8349 else if (unformat (i, "OrgSrc %d", &pl_index))
8351 if (pl_index <= 0 || pl_index > 4)
8352 goto pl_index_range_error;
8354 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8360 if (!src_address_set)
8362 errmsg ("src address required");
8366 if (!dst_address_set)
8368 errmsg ("dst address required");
8374 errmsg ("at least one sr segment required");
8378 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8379 vec_len (segments) * sizeof (ip6_address_t)
8380 + vec_len (tags) * sizeof (ip6_address_t));
8382 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8383 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8384 mp->dst_mask_width = dst_mask_width;
8385 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8386 mp->n_segments = vec_len (segments);
8387 mp->n_tags = vec_len (tags);
8388 mp->is_add = is_del == 0;
8389 clib_memcpy (mp->segs_and_tags, segments,
8390 vec_len (segments) * sizeof (ip6_address_t));
8391 clib_memcpy (mp->segs_and_tags +
8392 vec_len (segments) * sizeof (ip6_address_t), tags,
8393 vec_len (tags) * sizeof (ip6_address_t));
8395 mp->outer_vrf_id = ntohl (rx_table_id);
8396 mp->inner_vrf_id = ntohl (tx_table_id);
8397 memcpy (mp->name, name, vec_len (name));
8398 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8400 vec_free (segments);
8409 api_sr_policy_add_del (vat_main_t * vam)
8411 unformat_input_t *input = vam->input;
8412 vl_api_sr_policy_add_del_t *mp;
8416 u8 *tunnel_name = 0;
8417 u8 **tunnel_names = 0;
8422 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8423 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8425 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8427 if (unformat (input, "del"))
8429 else if (unformat (input, "name %s", &name))
8431 else if (unformat (input, "tunnel %s", &tunnel_name))
8435 vec_add1 (tunnel_names, tunnel_name);
8437 - length = #bytes to store in serial vector
8438 - +1 = byte to store that length
8440 tunnel_names_length += (vec_len (tunnel_name) + 1);
8451 errmsg ("policy name required");
8455 if ((!tunnel_set) && (!is_del))
8457 errmsg ("tunnel name required");
8461 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8465 mp->is_add = !is_del;
8467 memcpy (mp->name, name, vec_len (name));
8468 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8469 u8 *serial_orig = 0;
8470 vec_validate (serial_orig, tunnel_names_length);
8471 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8472 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8474 for (j = 0; j < vec_len (tunnel_names); j++)
8476 tun_name_len = vec_len (tunnel_names[j]);
8477 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8478 serial_orig += 1; // Move along one byte to store the actual tunnel name
8479 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8480 serial_orig += tun_name_len; // Advance past the copy
8482 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8484 vec_free (tunnel_names);
8485 vec_free (tunnel_name);
8493 api_sr_multicast_map_add_del (vat_main_t * vam)
8495 unformat_input_t *input = vam->input;
8496 vl_api_sr_multicast_map_add_del_t *mp;
8499 ip6_address_t multicast_address;
8500 u8 *policy_name = 0;
8501 int multicast_address_set = 0;
8503 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8505 if (unformat (input, "del"))
8509 (input, "address %U", unformat_ip6_address, &multicast_address))
8510 multicast_address_set = 1;
8511 else if (unformat (input, "sr-policy %s", &policy_name))
8517 if (!is_del && !policy_name)
8519 errmsg ("sr-policy name required");
8524 if (!multicast_address_set)
8526 errmsg ("address required");
8530 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8532 mp->is_add = !is_del;
8533 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8534 clib_memcpy (mp->multicast_address, &multicast_address,
8535 sizeof (mp->multicast_address));
8538 vec_free (policy_name);
8546 #define foreach_tcp_proto_field \
8550 #define foreach_udp_proto_field \
8554 #define foreach_ip4_proto_field \
8565 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8567 u8 **maskp = va_arg (*args, u8 **);
8569 u8 found_something = 0;
8572 #define _(a) u8 a=0;
8573 foreach_tcp_proto_field;
8576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8579 #define _(a) else if (unformat (input, #a)) a=1;
8580 foreach_tcp_proto_field
8586 #define _(a) found_something += a;
8587 foreach_tcp_proto_field;
8590 if (found_something == 0)
8593 vec_validate (mask, sizeof (*tcp) - 1);
8595 tcp = (tcp_header_t *) mask;
8597 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8598 foreach_tcp_proto_field;
8606 unformat_udp_mask (unformat_input_t * input, va_list * args)
8608 u8 **maskp = va_arg (*args, u8 **);
8610 u8 found_something = 0;
8613 #define _(a) u8 a=0;
8614 foreach_udp_proto_field;
8617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8620 #define _(a) else if (unformat (input, #a)) a=1;
8621 foreach_udp_proto_field
8627 #define _(a) found_something += a;
8628 foreach_udp_proto_field;
8631 if (found_something == 0)
8634 vec_validate (mask, sizeof (*udp) - 1);
8636 udp = (udp_header_t *) mask;
8638 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8639 foreach_udp_proto_field;
8648 u16 src_port, dst_port;
8652 unformat_l4_mask (unformat_input_t * input, va_list * args)
8654 u8 **maskp = va_arg (*args, u8 **);
8655 u16 src_port = 0, dst_port = 0;
8656 tcpudp_header_t *tcpudp;
8658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8662 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8664 else if (unformat (input, "src_port"))
8666 else if (unformat (input, "dst_port"))
8672 if (!src_port && !dst_port)
8676 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8678 tcpudp = (tcpudp_header_t *) mask;
8679 tcpudp->src_port = src_port;
8680 tcpudp->dst_port = dst_port;
8688 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8690 u8 **maskp = va_arg (*args, u8 **);
8692 u8 found_something = 0;
8695 #define _(a) u8 a=0;
8696 foreach_ip4_proto_field;
8702 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8704 if (unformat (input, "version"))
8706 else if (unformat (input, "hdr_length"))
8708 else if (unformat (input, "src"))
8710 else if (unformat (input, "dst"))
8712 else if (unformat (input, "proto"))
8715 #define _(a) else if (unformat (input, #a)) a=1;
8716 foreach_ip4_proto_field
8722 #define _(a) found_something += a;
8723 foreach_ip4_proto_field;
8726 if (found_something == 0)
8729 vec_validate (mask, sizeof (*ip) - 1);
8731 ip = (ip4_header_t *) mask;
8733 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8734 foreach_ip4_proto_field;
8737 ip->ip_version_and_header_length = 0;
8740 ip->ip_version_and_header_length |= 0xF0;
8743 ip->ip_version_and_header_length |= 0x0F;
8749 #define foreach_ip6_proto_field \
8757 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8759 u8 **maskp = va_arg (*args, u8 **);
8761 u8 found_something = 0;
8763 u32 ip_version_traffic_class_and_flow_label;
8765 #define _(a) u8 a=0;
8766 foreach_ip6_proto_field;
8769 u8 traffic_class = 0;
8772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8774 if (unformat (input, "version"))
8776 else if (unformat (input, "traffic-class"))
8778 else if (unformat (input, "flow-label"))
8780 else if (unformat (input, "src"))
8782 else if (unformat (input, "dst"))
8784 else if (unformat (input, "proto"))
8787 #define _(a) else if (unformat (input, #a)) a=1;
8788 foreach_ip6_proto_field
8794 #define _(a) found_something += a;
8795 foreach_ip6_proto_field;
8798 if (found_something == 0)
8801 vec_validate (mask, sizeof (*ip) - 1);
8803 ip = (ip6_header_t *) mask;
8805 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8806 foreach_ip6_proto_field;
8809 ip_version_traffic_class_and_flow_label = 0;
8812 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8815 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8818 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8820 ip->ip_version_traffic_class_and_flow_label =
8821 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8828 unformat_l3_mask (unformat_input_t * input, va_list * args)
8830 u8 **maskp = va_arg (*args, u8 **);
8832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8834 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8836 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8845 unformat_l2_mask (unformat_input_t * input, va_list * args)
8847 u8 **maskp = va_arg (*args, u8 **);
8862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8864 if (unformat (input, "src"))
8866 else if (unformat (input, "dst"))
8868 else if (unformat (input, "proto"))
8870 else if (unformat (input, "tag1"))
8872 else if (unformat (input, "tag2"))
8874 else if (unformat (input, "ignore-tag1"))
8876 else if (unformat (input, "ignore-tag2"))
8878 else if (unformat (input, "cos1"))
8880 else if (unformat (input, "cos2"))
8882 else if (unformat (input, "dot1q"))
8884 else if (unformat (input, "dot1ad"))
8889 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8890 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8893 if (tag1 || ignore_tag1 || cos1 || dot1q)
8895 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8898 vec_validate (mask, len - 1);
8901 memset (mask, 0xff, 6);
8904 memset (mask + 6, 0xff, 6);
8908 /* inner vlan tag */
8917 mask[21] = mask[20] = 0xff;
8938 mask[16] = mask[17] = 0xff;
8948 mask[12] = mask[13] = 0xff;
8955 unformat_classify_mask (unformat_input_t * input, va_list * args)
8957 u8 **maskp = va_arg (*args, u8 **);
8958 u32 *skipp = va_arg (*args, u32 *);
8959 u32 *matchp = va_arg (*args, u32 *);
8967 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8969 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8971 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8973 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8975 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8989 if (mask || l2 || l3 || l4)
8993 /* "With a free Ethernet header in every package" */
8995 vec_validate (l2, 13);
8999 vec_append (mask, l3);
9004 vec_append (mask, l4);
9009 /* Scan forward looking for the first significant mask octet */
9010 for (i = 0; i < vec_len (mask); i++)
9014 /* compute (skip, match) params */
9015 *skipp = i / sizeof (u32x4);
9016 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9018 /* Pad mask to an even multiple of the vector size */
9019 while (vec_len (mask) % sizeof (u32x4))
9022 match = vec_len (mask) / sizeof (u32x4);
9024 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9026 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9027 if (*tmp || *(tmp + 1))
9032 clib_warning ("BUG: match 0");
9034 _vec_len (mask) = match * sizeof (u32x4);
9045 #define foreach_l2_next \
9047 _(ethernet, ETHERNET_INPUT) \
9052 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9054 u32 *miss_next_indexp = va_arg (*args, u32 *);
9059 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9063 if (unformat (input, "%d", &tmp))
9072 *miss_next_indexp = next_index;
9076 #define foreach_ip_next \
9082 unformat_ip_next_index (unformat_input_t * input, va_list * args)
9084 u32 *miss_next_indexp = va_arg (*args, u32 *);
9089 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9093 if (unformat (input, "%d", &tmp))
9102 *miss_next_indexp = next_index;
9106 #define foreach_acl_next \
9110 unformat_acl_next_index (unformat_input_t * input, va_list * args)
9112 u32 *miss_next_indexp = va_arg (*args, u32 *);
9117 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9121 if (unformat (input, "permit"))
9126 else if (unformat (input, "%d", &tmp))
9135 *miss_next_indexp = next_index;
9140 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9142 u32 *r = va_arg (*args, u32 *);
9144 if (unformat (input, "conform-color"))
9145 *r = POLICE_CONFORM;
9146 else if (unformat (input, "exceed-color"))
9155 api_classify_add_del_table (vat_main_t * vam)
9157 unformat_input_t *i = vam->input;
9158 vl_api_classify_add_del_table_t *mp;
9165 u32 table_index = ~0;
9166 u32 next_table_index = ~0;
9167 u32 miss_next_index = ~0;
9168 u32 memory_size = 32 << 20;
9171 u32 current_data_flag = 0;
9172 int current_data_offset = 0;
9174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9176 if (unformat (i, "del"))
9178 else if (unformat (i, "del-chain"))
9183 else if (unformat (i, "buckets %d", &nbuckets))
9185 else if (unformat (i, "memory_size %d", &memory_size))
9187 else if (unformat (i, "skip %d", &skip))
9189 else if (unformat (i, "match %d", &match))
9191 else if (unformat (i, "table %d", &table_index))
9193 else if (unformat (i, "mask %U", unformat_classify_mask,
9194 &mask, &skip, &match))
9196 else if (unformat (i, "next-table %d", &next_table_index))
9198 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
9201 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9204 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9207 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9209 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9215 if (is_add && mask == 0)
9217 errmsg ("Mask required");
9221 if (is_add && skip == ~0)
9223 errmsg ("skip count required");
9227 if (is_add && match == ~0)
9229 errmsg ("match count required");
9233 if (!is_add && table_index == ~0)
9235 errmsg ("table index required for delete");
9239 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
9241 mp->is_add = is_add;
9242 mp->del_chain = del_chain;
9243 mp->table_index = ntohl (table_index);
9244 mp->nbuckets = ntohl (nbuckets);
9245 mp->memory_size = ntohl (memory_size);
9246 mp->skip_n_vectors = ntohl (skip);
9247 mp->match_n_vectors = ntohl (match);
9248 mp->next_table_index = ntohl (next_table_index);
9249 mp->miss_next_index = ntohl (miss_next_index);
9250 mp->current_data_flag = ntohl (current_data_flag);
9251 mp->current_data_offset = ntohl (current_data_offset);
9252 clib_memcpy (mp->mask, mask, vec_len (mask));
9262 unformat_l4_match (unformat_input_t * input, va_list * args)
9264 u8 **matchp = va_arg (*args, u8 **);
9266 u8 *proto_header = 0;
9272 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9274 if (unformat (input, "src_port %d", &src_port))
9276 else if (unformat (input, "dst_port %d", &dst_port))
9282 h.src_port = clib_host_to_net_u16 (src_port);
9283 h.dst_port = clib_host_to_net_u16 (dst_port);
9284 vec_validate (proto_header, sizeof (h) - 1);
9285 memcpy (proto_header, &h, sizeof (h));
9287 *matchp = proto_header;
9293 unformat_ip4_match (unformat_input_t * input, va_list * args)
9295 u8 **matchp = va_arg (*args, u8 **);
9302 int src = 0, dst = 0;
9303 ip4_address_t src_val, dst_val;
9310 int fragment_id = 0;
9311 u32 fragment_id_val;
9317 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9319 if (unformat (input, "version %d", &version_val))
9321 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9323 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9325 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9327 else if (unformat (input, "proto %d", &proto_val))
9329 else if (unformat (input, "tos %d", &tos_val))
9331 else if (unformat (input, "length %d", &length_val))
9333 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9335 else if (unformat (input, "ttl %d", &ttl_val))
9337 else if (unformat (input, "checksum %d", &checksum_val))
9343 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9344 + ttl + checksum == 0)
9348 * Aligned because we use the real comparison functions
9350 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9352 ip = (ip4_header_t *) match;
9354 /* These are realistically matched in practice */
9356 ip->src_address.as_u32 = src_val.as_u32;
9359 ip->dst_address.as_u32 = dst_val.as_u32;
9362 ip->protocol = proto_val;
9365 /* These are not, but they're included for completeness */
9367 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9370 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9376 ip->length = clib_host_to_net_u16 (length_val);
9382 ip->checksum = clib_host_to_net_u16 (checksum_val);
9389 unformat_ip6_match (unformat_input_t * input, va_list * args)
9391 u8 **matchp = va_arg (*args, u8 **);
9396 u8 traffic_class = 0;
9397 u32 traffic_class_val = 0;
9400 int src = 0, dst = 0;
9401 ip6_address_t src_val, dst_val;
9404 int payload_length = 0;
9405 u32 payload_length_val;
9408 u32 ip_version_traffic_class_and_flow_label;
9410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9412 if (unformat (input, "version %d", &version_val))
9414 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9416 else if (unformat (input, "flow_label %d", &flow_label_val))
9418 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9420 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9422 else if (unformat (input, "proto %d", &proto_val))
9424 else if (unformat (input, "payload_length %d", &payload_length_val))
9426 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9432 if (version + traffic_class + flow_label + src + dst + proto +
9433 payload_length + hop_limit == 0)
9437 * Aligned because we use the real comparison functions
9439 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9441 ip = (ip6_header_t *) match;
9444 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9447 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9450 ip->protocol = proto_val;
9452 ip_version_traffic_class_and_flow_label = 0;
9455 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9458 ip_version_traffic_class_and_flow_label |=
9459 (traffic_class_val & 0xFF) << 20;
9462 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9464 ip->ip_version_traffic_class_and_flow_label =
9465 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9468 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9471 ip->hop_limit = hop_limit_val;
9478 unformat_l3_match (unformat_input_t * input, va_list * args)
9480 u8 **matchp = va_arg (*args, u8 **);
9482 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9484 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9486 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9495 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9497 u8 *tagp = va_arg (*args, u8 *);
9500 if (unformat (input, "%d", &tag))
9502 tagp[0] = (tag >> 8) & 0x0F;
9503 tagp[1] = tag & 0xFF;
9511 unformat_l2_match (unformat_input_t * input, va_list * args)
9513 u8 **matchp = va_arg (*args, u8 **);
9533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9535 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9538 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9540 else if (unformat (input, "proto %U",
9541 unformat_ethernet_type_host_byte_order, &proto_val))
9543 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9545 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9547 else if (unformat (input, "ignore-tag1"))
9549 else if (unformat (input, "ignore-tag2"))
9551 else if (unformat (input, "cos1 %d", &cos1_val))
9553 else if (unformat (input, "cos2 %d", &cos2_val))
9558 if ((src + dst + proto + tag1 + tag2 +
9559 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9562 if (tag1 || ignore_tag1 || cos1)
9564 if (tag2 || ignore_tag2 || cos2)
9567 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9570 clib_memcpy (match, dst_val, 6);
9573 clib_memcpy (match + 6, src_val, 6);
9577 /* inner vlan tag */
9578 match[19] = tag2_val[1];
9579 match[18] = tag2_val[0];
9581 match[18] |= (cos2_val & 0x7) << 5;
9584 match[21] = proto_val & 0xff;
9585 match[20] = proto_val >> 8;
9589 match[15] = tag1_val[1];
9590 match[14] = tag1_val[0];
9593 match[14] |= (cos1_val & 0x7) << 5;
9599 match[15] = tag1_val[1];
9600 match[14] = tag1_val[0];
9603 match[17] = proto_val & 0xff;
9604 match[16] = proto_val >> 8;
9607 match[14] |= (cos1_val & 0x7) << 5;
9613 match[18] |= (cos2_val & 0x7) << 5;
9615 match[14] |= (cos1_val & 0x7) << 5;
9618 match[13] = proto_val & 0xff;
9619 match[12] = proto_val >> 8;
9628 unformat_classify_match (unformat_input_t * input, va_list * args)
9630 u8 **matchp = va_arg (*args, u8 **);
9631 u32 skip_n_vectors = va_arg (*args, u32);
9632 u32 match_n_vectors = va_arg (*args, u32);
9639 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9641 if (unformat (input, "hex %U", unformat_hex_string, &match))
9643 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9645 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9647 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9661 if (match || l2 || l3 || l4)
9665 /* "Win a free Ethernet header in every packet" */
9667 vec_validate_aligned (l2, 13, sizeof (u32x4));
9671 vec_append_aligned (match, l3, sizeof (u32x4));
9676 vec_append_aligned (match, l4, sizeof (u32x4));
9681 /* Make sure the vector is big enough even if key is all 0's */
9682 vec_validate_aligned
9683 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9686 /* Set size, include skipped vectors */
9687 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9698 api_classify_add_del_session (vat_main_t * vam)
9700 unformat_input_t *i = vam->input;
9701 vl_api_classify_add_del_session_t *mp;
9703 u32 table_index = ~0;
9704 u32 hit_next_index = ~0;
9705 u32 opaque_index = ~0;
9709 u32 skip_n_vectors = 0;
9710 u32 match_n_vectors = 0;
9715 * Warning: you have to supply skip_n and match_n
9716 * because the API client cant simply look at the classify
9720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9722 if (unformat (i, "del"))
9724 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9727 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9730 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9733 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9735 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9737 else if (unformat (i, "opaque-index %d", &opaque_index))
9739 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9741 else if (unformat (i, "match_n %d", &match_n_vectors))
9743 else if (unformat (i, "match %U", unformat_classify_match,
9744 &match, skip_n_vectors, match_n_vectors))
9746 else if (unformat (i, "advance %d", &advance))
9748 else if (unformat (i, "table-index %d", &table_index))
9750 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9752 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9754 else if (unformat (i, "action %d", &action))
9756 else if (unformat (i, "metadata %d", &metadata))
9762 if (table_index == ~0)
9764 errmsg ("Table index required");
9768 if (is_add && match == 0)
9770 errmsg ("Match value required");
9774 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9776 mp->is_add = is_add;
9777 mp->table_index = ntohl (table_index);
9778 mp->hit_next_index = ntohl (hit_next_index);
9779 mp->opaque_index = ntohl (opaque_index);
9780 mp->advance = ntohl (advance);
9781 mp->action = action;
9782 mp->metadata = ntohl (metadata);
9783 clib_memcpy (mp->match, match, vec_len (match));
9792 api_classify_set_interface_ip_table (vat_main_t * vam)
9794 unformat_input_t *i = vam->input;
9795 vl_api_classify_set_interface_ip_table_t *mp;
9798 int sw_if_index_set;
9799 u32 table_index = ~0;
9802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9805 sw_if_index_set = 1;
9806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9807 sw_if_index_set = 1;
9808 else if (unformat (i, "table %d", &table_index))
9812 clib_warning ("parse error '%U'", format_unformat_error, i);
9817 if (sw_if_index_set == 0)
9819 errmsg ("missing interface name or sw_if_index");
9824 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9826 mp->sw_if_index = ntohl (sw_if_index);
9827 mp->table_index = ntohl (table_index);
9828 mp->is_ipv6 = is_ipv6;
9837 api_classify_set_interface_l2_tables (vat_main_t * vam)
9839 unformat_input_t *i = vam->input;
9840 vl_api_classify_set_interface_l2_tables_t *mp;
9843 int sw_if_index_set;
9844 u32 ip4_table_index = ~0;
9845 u32 ip6_table_index = ~0;
9846 u32 other_table_index = ~0;
9849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9851 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9852 sw_if_index_set = 1;
9853 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9854 sw_if_index_set = 1;
9855 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9857 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9859 else if (unformat (i, "other-table %d", &other_table_index))
9861 else if (unformat (i, "is-input %d", &is_input))
9865 clib_warning ("parse error '%U'", format_unformat_error, i);
9870 if (sw_if_index_set == 0)
9872 errmsg ("missing interface name or sw_if_index");
9877 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9879 mp->sw_if_index = ntohl (sw_if_index);
9880 mp->ip4_table_index = ntohl (ip4_table_index);
9881 mp->ip6_table_index = ntohl (ip6_table_index);
9882 mp->other_table_index = ntohl (other_table_index);
9883 mp->is_input = (u8) is_input;
9892 api_set_ipfix_exporter (vat_main_t * vam)
9894 unformat_input_t *i = vam->input;
9895 vl_api_set_ipfix_exporter_t *mp;
9896 ip4_address_t collector_address;
9897 u8 collector_address_set = 0;
9898 u32 collector_port = ~0;
9899 ip4_address_t src_address;
9900 u8 src_address_set = 0;
9903 u32 template_interval = ~0;
9904 u8 udp_checksum = 0;
9907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9909 if (unformat (i, "collector_address %U", unformat_ip4_address,
9910 &collector_address))
9911 collector_address_set = 1;
9912 else if (unformat (i, "collector_port %d", &collector_port))
9914 else if (unformat (i, "src_address %U", unformat_ip4_address,
9916 src_address_set = 1;
9917 else if (unformat (i, "vrf_id %d", &vrf_id))
9919 else if (unformat (i, "path_mtu %d", &path_mtu))
9921 else if (unformat (i, "template_interval %d", &template_interval))
9923 else if (unformat (i, "udp_checksum"))
9929 if (collector_address_set == 0)
9931 errmsg ("collector_address required");
9935 if (src_address_set == 0)
9937 errmsg ("src_address required");
9941 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9943 memcpy (mp->collector_address, collector_address.data,
9944 sizeof (collector_address.data));
9945 mp->collector_port = htons ((u16) collector_port);
9946 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9947 mp->vrf_id = htonl (vrf_id);
9948 mp->path_mtu = htonl (path_mtu);
9949 mp->template_interval = htonl (template_interval);
9950 mp->udp_checksum = udp_checksum;
9958 api_set_ipfix_classify_stream (vat_main_t * vam)
9960 unformat_input_t *i = vam->input;
9961 vl_api_set_ipfix_classify_stream_t *mp;
9963 u32 src_port = UDP_DST_PORT_ipfix;
9966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9968 if (unformat (i, "domain %d", &domain_id))
9970 else if (unformat (i, "src_port %d", &src_port))
9974 errmsg ("unknown input `%U'", format_unformat_error, i);
9979 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9981 mp->domain_id = htonl (domain_id);
9982 mp->src_port = htons ((u16) src_port);
9990 api_ipfix_classify_table_add_del (vat_main_t * vam)
9992 unformat_input_t *i = vam->input;
9993 vl_api_ipfix_classify_table_add_del_t *mp;
9995 u32 classify_table_index = ~0;
9997 u8 transport_protocol = 255;
10000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10002 if (unformat (i, "add"))
10004 else if (unformat (i, "del"))
10006 else if (unformat (i, "table %d", &classify_table_index))
10008 else if (unformat (i, "ip4"))
10010 else if (unformat (i, "ip6"))
10012 else if (unformat (i, "tcp"))
10013 transport_protocol = 6;
10014 else if (unformat (i, "udp"))
10015 transport_protocol = 17;
10018 errmsg ("unknown input `%U'", format_unformat_error, i);
10025 errmsg ("expecting: add|del");
10028 if (classify_table_index == ~0)
10030 errmsg ("classifier table not specified");
10033 if (ip_version == 0)
10035 errmsg ("IP version not specified");
10039 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
10041 mp->is_add = is_add;
10042 mp->table_id = htonl (classify_table_index);
10043 mp->ip_version = ip_version;
10044 mp->transport_protocol = transport_protocol;
10052 api_get_node_index (vat_main_t * vam)
10054 unformat_input_t *i = vam->input;
10055 vl_api_get_node_index_t *mp;
10059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10061 if (unformat (i, "node %s", &name))
10068 errmsg ("node name required");
10071 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10073 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10077 M (GET_NODE_INDEX, get_node_index);
10078 clib_memcpy (mp->node_name, name, vec_len (name));
10088 api_get_next_index (vat_main_t * vam)
10090 unformat_input_t *i = vam->input;
10091 vl_api_get_next_index_t *mp;
10093 u8 *node_name = 0, *next_node_name = 0;
10095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10097 if (unformat (i, "node-name %s", &node_name))
10099 else if (unformat (i, "next-node-name %s", &next_node_name))
10103 if (node_name == 0)
10105 errmsg ("node name required");
10108 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10110 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10114 if (next_node_name == 0)
10116 errmsg ("next node name required");
10119 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10121 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10125 M (GET_NEXT_INDEX, get_next_index);
10126 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10127 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10128 vec_free (node_name);
10129 vec_free (next_node_name);
10138 api_add_node_next (vat_main_t * vam)
10140 unformat_input_t *i = vam->input;
10141 vl_api_add_node_next_t *mp;
10146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10148 if (unformat (i, "node %s", &name))
10150 else if (unformat (i, "next %s", &next))
10157 errmsg ("node name required");
10160 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10162 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10167 errmsg ("next node required");
10170 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10172 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10176 M (ADD_NODE_NEXT, add_node_next);
10177 clib_memcpy (mp->node_name, name, vec_len (name));
10178 clib_memcpy (mp->next_name, next, vec_len (next));
10189 api_l2tpv3_create_tunnel (vat_main_t * vam)
10191 unformat_input_t *i = vam->input;
10192 ip6_address_t client_address, our_address;
10193 int client_address_set = 0;
10194 int our_address_set = 0;
10195 u32 local_session_id = 0;
10196 u32 remote_session_id = 0;
10197 u64 local_cookie = 0;
10198 u64 remote_cookie = 0;
10199 u8 l2_sublayer_present = 0;
10200 vl_api_l2tpv3_create_tunnel_t *mp;
10203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10205 if (unformat (i, "client_address %U", unformat_ip6_address,
10207 client_address_set = 1;
10208 else if (unformat (i, "our_address %U", unformat_ip6_address,
10210 our_address_set = 1;
10211 else if (unformat (i, "local_session_id %d", &local_session_id))
10213 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10215 else if (unformat (i, "local_cookie %lld", &local_cookie))
10217 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10219 else if (unformat (i, "l2-sublayer-present"))
10220 l2_sublayer_present = 1;
10225 if (client_address_set == 0)
10227 errmsg ("client_address required");
10231 if (our_address_set == 0)
10233 errmsg ("our_address required");
10237 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
10239 clib_memcpy (mp->client_address, client_address.as_u8,
10240 sizeof (mp->client_address));
10242 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10244 mp->local_session_id = ntohl (local_session_id);
10245 mp->remote_session_id = ntohl (remote_session_id);
10246 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10247 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10248 mp->l2_sublayer_present = l2_sublayer_present;
10258 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10260 unformat_input_t *i = vam->input;
10262 u8 sw_if_index_set = 0;
10263 u64 new_local_cookie = 0;
10264 u64 new_remote_cookie = 0;
10265 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10270 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10271 sw_if_index_set = 1;
10272 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10273 sw_if_index_set = 1;
10274 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10276 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10282 if (sw_if_index_set == 0)
10284 errmsg ("missing interface name or sw_if_index");
10288 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
10290 mp->sw_if_index = ntohl (sw_if_index);
10291 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10292 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10301 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10303 unformat_input_t *i = vam->input;
10304 vl_api_l2tpv3_interface_enable_disable_t *mp;
10307 u8 sw_if_index_set = 0;
10308 u8 enable_disable = 1;
10310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10312 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10313 sw_if_index_set = 1;
10314 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10315 sw_if_index_set = 1;
10316 else if (unformat (i, "enable"))
10317 enable_disable = 1;
10318 else if (unformat (i, "disable"))
10319 enable_disable = 0;
10324 if (sw_if_index_set == 0)
10326 errmsg ("missing interface name or sw_if_index");
10330 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10332 mp->sw_if_index = ntohl (sw_if_index);
10333 mp->enable_disable = enable_disable;
10342 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10344 unformat_input_t *i = vam->input;
10345 vl_api_l2tpv3_set_lookup_key_t *mp;
10349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10351 if (unformat (i, "lookup_v6_src"))
10352 key = L2T_LOOKUP_SRC_ADDRESS;
10353 else if (unformat (i, "lookup_v6_dst"))
10354 key = L2T_LOOKUP_DST_ADDRESS;
10355 else if (unformat (i, "lookup_session_id"))
10356 key = L2T_LOOKUP_SESSION_ID;
10361 if (key == (u8) ~ 0)
10363 errmsg ("l2tp session lookup key unset");
10367 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10377 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10378 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10380 vat_main_t *vam = &vat_main;
10382 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10383 format_ip6_address, mp->our_address,
10384 format_ip6_address, mp->client_address,
10385 clib_net_to_host_u32 (mp->sw_if_index));
10388 " local cookies %016llx %016llx remote cookie %016llx",
10389 clib_net_to_host_u64 (mp->local_cookie[0]),
10390 clib_net_to_host_u64 (mp->local_cookie[1]),
10391 clib_net_to_host_u64 (mp->remote_cookie));
10393 print (vam->ofp, " local session-id %d remote session-id %d",
10394 clib_net_to_host_u32 (mp->local_session_id),
10395 clib_net_to_host_u32 (mp->remote_session_id));
10397 print (vam->ofp, " l2 specific sublayer %s\n",
10398 mp->l2_sublayer_present ? "preset" : "absent");
10402 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10403 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10405 vat_main_t *vam = &vat_main;
10406 vat_json_node_t *node = NULL;
10407 struct in6_addr addr;
10409 if (VAT_JSON_ARRAY != vam->json_tree.type)
10411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10412 vat_json_init_array (&vam->json_tree);
10414 node = vat_json_array_add (&vam->json_tree);
10416 vat_json_init_object (node);
10418 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10419 vat_json_object_add_ip6 (node, "our_address", addr);
10420 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10421 vat_json_object_add_ip6 (node, "client_address", addr);
10423 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10424 vat_json_init_array (lc);
10425 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10426 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10427 vat_json_object_add_uint (node, "remote_cookie",
10428 clib_net_to_host_u64 (mp->remote_cookie));
10430 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10431 vat_json_object_add_uint (node, "local_session_id",
10432 clib_net_to_host_u32 (mp->local_session_id));
10433 vat_json_object_add_uint (node, "remote_session_id",
10434 clib_net_to_host_u32 (mp->remote_session_id));
10435 vat_json_object_add_string_copy (node, "l2_sublayer",
10436 mp->l2_sublayer_present ? (u8 *) "present"
10437 : (u8 *) "absent");
10441 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10443 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10446 /* Get list of l2tpv3-tunnel interfaces */
10447 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10450 /* Use a control ping for synchronization */
10452 vl_api_control_ping_t *mp;
10453 M (CONTROL_PING, control_ping);
10460 static void vl_api_sw_interface_tap_details_t_handler
10461 (vl_api_sw_interface_tap_details_t * mp)
10463 vat_main_t *vam = &vat_main;
10465 print (vam->ofp, "%-16s %d",
10466 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10469 static void vl_api_sw_interface_tap_details_t_handler_json
10470 (vl_api_sw_interface_tap_details_t * mp)
10472 vat_main_t *vam = &vat_main;
10473 vat_json_node_t *node = NULL;
10475 if (VAT_JSON_ARRAY != vam->json_tree.type)
10477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10478 vat_json_init_array (&vam->json_tree);
10480 node = vat_json_array_add (&vam->json_tree);
10482 vat_json_init_object (node);
10483 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10484 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10488 api_sw_interface_tap_dump (vat_main_t * vam)
10490 vl_api_sw_interface_tap_dump_t *mp;
10493 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10494 /* Get list of tap interfaces */
10495 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10498 /* Use a control ping for synchronization */
10500 vl_api_control_ping_t *mp;
10501 M (CONTROL_PING, control_ping);
10507 static uword unformat_vxlan_decap_next
10508 (unformat_input_t * input, va_list * args)
10510 u32 *result = va_arg (*args, u32 *);
10513 if (unformat (input, "l2"))
10514 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10515 else if (unformat (input, "%d", &tmp))
10523 api_vxlan_add_del_tunnel (vat_main_t * vam)
10525 unformat_input_t *line_input = vam->input;
10526 vl_api_vxlan_add_del_tunnel_t *mp;
10528 ip46_address_t src, dst;
10530 u8 ipv4_set = 0, ipv6_set = 0;
10534 u32 mcast_sw_if_index = ~0;
10535 u32 encap_vrf_id = 0;
10536 u32 decap_next_index = ~0;
10539 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10540 memset (&src, 0, sizeof src);
10541 memset (&dst, 0, sizeof dst);
10543 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10545 if (unformat (line_input, "del"))
10548 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10554 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10560 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10566 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10571 else if (unformat (line_input, "group %U %U",
10572 unformat_ip4_address, &dst.ip4,
10573 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10575 grp_set = dst_set = 1;
10578 else if (unformat (line_input, "group %U",
10579 unformat_ip4_address, &dst.ip4))
10581 grp_set = dst_set = 1;
10584 else if (unformat (line_input, "group %U %U",
10585 unformat_ip6_address, &dst.ip6,
10586 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10588 grp_set = dst_set = 1;
10591 else if (unformat (line_input, "group %U",
10592 unformat_ip6_address, &dst.ip6))
10594 grp_set = dst_set = 1;
10598 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10600 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10602 else if (unformat (line_input, "decap-next %U",
10603 unformat_vxlan_decap_next, &decap_next_index))
10605 else if (unformat (line_input, "vni %d", &vni))
10609 errmsg ("parse error '%U'", format_unformat_error, line_input);
10616 errmsg ("tunnel src address not specified");
10621 errmsg ("tunnel dst address not specified");
10625 if (grp_set && !ip46_address_is_multicast (&dst))
10627 errmsg ("tunnel group address not multicast");
10630 if (grp_set && mcast_sw_if_index == ~0)
10632 errmsg ("tunnel nonexistent multicast device");
10635 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10637 errmsg ("tunnel dst address must be unicast");
10642 if (ipv4_set && ipv6_set)
10644 errmsg ("both IPv4 and IPv6 addresses specified");
10648 if ((vni == 0) || (vni >> 24))
10650 errmsg ("vni not specified or out of range");
10654 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10658 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10659 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10663 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10664 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10666 mp->encap_vrf_id = ntohl (encap_vrf_id);
10667 mp->decap_next_index = ntohl (decap_next_index);
10668 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10669 mp->vni = ntohl (vni);
10670 mp->is_add = is_add;
10671 mp->is_ipv6 = ipv6_set;
10679 static void vl_api_vxlan_tunnel_details_t_handler
10680 (vl_api_vxlan_tunnel_details_t * mp)
10682 vat_main_t *vam = &vat_main;
10683 ip46_address_t src, dst;
10685 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10686 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10688 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10689 ntohl (mp->sw_if_index),
10690 format_ip46_address, &src, IP46_TYPE_ANY,
10691 format_ip46_address, &dst, IP46_TYPE_ANY,
10692 ntohl (mp->encap_vrf_id),
10693 ntohl (mp->decap_next_index), ntohl (mp->vni),
10694 ntohl (mp->mcast_sw_if_index));
10697 static void vl_api_vxlan_tunnel_details_t_handler_json
10698 (vl_api_vxlan_tunnel_details_t * mp)
10700 vat_main_t *vam = &vat_main;
10701 vat_json_node_t *node = NULL;
10703 if (VAT_JSON_ARRAY != vam->json_tree.type)
10705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10706 vat_json_init_array (&vam->json_tree);
10708 node = vat_json_array_add (&vam->json_tree);
10710 vat_json_init_object (node);
10711 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10714 struct in6_addr ip6;
10716 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10717 vat_json_object_add_ip6 (node, "src_address", ip6);
10718 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10719 vat_json_object_add_ip6 (node, "dst_address", ip6);
10723 struct in_addr ip4;
10725 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10726 vat_json_object_add_ip4 (node, "src_address", ip4);
10727 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10728 vat_json_object_add_ip4 (node, "dst_address", ip4);
10730 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10731 vat_json_object_add_uint (node, "decap_next_index",
10732 ntohl (mp->decap_next_index));
10733 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10734 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10735 vat_json_object_add_uint (node, "mcast_sw_if_index",
10736 ntohl (mp->mcast_sw_if_index));
10740 api_vxlan_tunnel_dump (vat_main_t * vam)
10742 unformat_input_t *i = vam->input;
10743 vl_api_vxlan_tunnel_dump_t *mp;
10746 u8 sw_if_index_set = 0;
10748 /* Parse args required to build the message */
10749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10751 if (unformat (i, "sw_if_index %d", &sw_if_index))
10752 sw_if_index_set = 1;
10757 if (sw_if_index_set == 0)
10762 if (!vam->json_output)
10764 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10765 "sw_if_index", "src_address", "dst_address",
10766 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10769 /* Get list of vxlan-tunnel interfaces */
10770 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10772 mp->sw_if_index = htonl (sw_if_index);
10776 /* Use a control ping for synchronization */
10778 vl_api_control_ping_t *mp;
10779 M (CONTROL_PING, control_ping);
10786 api_gre_add_del_tunnel (vat_main_t * vam)
10788 unformat_input_t *line_input = vam->input;
10789 vl_api_gre_add_del_tunnel_t *mp;
10791 ip4_address_t src4, dst4;
10796 u32 outer_fib_id = 0;
10798 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10800 if (unformat (line_input, "del"))
10802 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10804 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10806 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10808 else if (unformat (line_input, "teb"))
10812 errmsg ("parse error '%U'", format_unformat_error, line_input);
10819 errmsg ("tunnel src address not specified");
10824 errmsg ("tunnel dst address not specified");
10829 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10831 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10832 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10833 mp->outer_fib_id = ntohl (outer_fib_id);
10834 mp->is_add = is_add;
10843 static void vl_api_gre_tunnel_details_t_handler
10844 (vl_api_gre_tunnel_details_t * mp)
10846 vat_main_t *vam = &vat_main;
10848 print (vam->ofp, "%11d%15U%15U%6d%14d",
10849 ntohl (mp->sw_if_index),
10850 format_ip4_address, &mp->src_address,
10851 format_ip4_address, &mp->dst_address,
10852 mp->teb, ntohl (mp->outer_fib_id));
10855 static void vl_api_gre_tunnel_details_t_handler_json
10856 (vl_api_gre_tunnel_details_t * mp)
10858 vat_main_t *vam = &vat_main;
10859 vat_json_node_t *node = NULL;
10860 struct in_addr ip4;
10862 if (VAT_JSON_ARRAY != vam->json_tree.type)
10864 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10865 vat_json_init_array (&vam->json_tree);
10867 node = vat_json_array_add (&vam->json_tree);
10869 vat_json_init_object (node);
10870 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10871 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10872 vat_json_object_add_ip4 (node, "src_address", ip4);
10873 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10874 vat_json_object_add_ip4 (node, "dst_address", ip4);
10875 vat_json_object_add_uint (node, "teb", mp->teb);
10876 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10880 api_gre_tunnel_dump (vat_main_t * vam)
10882 unformat_input_t *i = vam->input;
10883 vl_api_gre_tunnel_dump_t *mp;
10886 u8 sw_if_index_set = 0;
10888 /* Parse args required to build the message */
10889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10891 if (unformat (i, "sw_if_index %d", &sw_if_index))
10892 sw_if_index_set = 1;
10897 if (sw_if_index_set == 0)
10902 if (!vam->json_output)
10904 print (vam->ofp, "%11s%15s%15s%6s%14s",
10905 "sw_if_index", "src_address", "dst_address", "teb",
10909 /* Get list of gre-tunnel interfaces */
10910 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10912 mp->sw_if_index = htonl (sw_if_index);
10916 /* Use a control ping for synchronization */
10918 vl_api_control_ping_t *mp;
10919 M (CONTROL_PING, control_ping);
10926 api_l2_fib_clear_table (vat_main_t * vam)
10928 // unformat_input_t * i = vam->input;
10929 vl_api_l2_fib_clear_table_t *mp;
10932 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10941 api_l2_interface_efp_filter (vat_main_t * vam)
10943 unformat_input_t *i = vam->input;
10944 vl_api_l2_interface_efp_filter_t *mp;
10948 u8 sw_if_index_set = 0;
10950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10952 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10953 sw_if_index_set = 1;
10954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10955 sw_if_index_set = 1;
10956 else if (unformat (i, "enable"))
10958 else if (unformat (i, "disable"))
10962 clib_warning ("parse error '%U'", format_unformat_error, i);
10967 if (sw_if_index_set == 0)
10969 errmsg ("missing sw_if_index");
10973 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10975 mp->sw_if_index = ntohl (sw_if_index);
10976 mp->enable_disable = enable;
10984 #define foreach_vtr_op \
10985 _("disable", L2_VTR_DISABLED) \
10986 _("push-1", L2_VTR_PUSH_1) \
10987 _("push-2", L2_VTR_PUSH_2) \
10988 _("pop-1", L2_VTR_POP_1) \
10989 _("pop-2", L2_VTR_POP_2) \
10990 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10991 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10992 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10993 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10996 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10998 unformat_input_t *i = vam->input;
10999 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11002 u8 sw_if_index_set = 0;
11005 u32 push_dot1q = 1;
11009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11012 sw_if_index_set = 1;
11013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11014 sw_if_index_set = 1;
11015 else if (unformat (i, "vtr_op %d", &vtr_op))
11017 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11020 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11022 else if (unformat (i, "tag1 %d", &tag1))
11024 else if (unformat (i, "tag2 %d", &tag2))
11028 clib_warning ("parse error '%U'", format_unformat_error, i);
11033 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11035 errmsg ("missing vtr operation or sw_if_index");
11039 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
11040 mp->sw_if_index = ntohl (sw_if_index);
11041 mp->vtr_op = ntohl (vtr_op);
11042 mp->push_dot1q = ntohl (push_dot1q);
11043 mp->tag1 = ntohl (tag1);
11044 mp->tag2 = ntohl (tag2);
11053 api_create_vhost_user_if (vat_main_t * vam)
11055 unformat_input_t *i = vam->input;
11056 vl_api_create_vhost_user_if_t *mp;
11060 u8 file_name_set = 0;
11061 u32 custom_dev_instance = ~0;
11063 u8 use_custom_mac = 0;
11066 /* Shut up coverity */
11067 memset (hwaddr, 0, sizeof (hwaddr));
11069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11071 if (unformat (i, "socket %s", &file_name))
11075 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11077 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11078 use_custom_mac = 1;
11079 else if (unformat (i, "server"))
11081 else if (unformat (i, "tag %s", &tag))
11087 if (file_name_set == 0)
11089 errmsg ("missing socket file name");
11093 if (vec_len (file_name) > 255)
11095 errmsg ("socket file name too long");
11098 vec_add1 (file_name, 0);
11100 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
11102 mp->is_server = is_server;
11103 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11104 vec_free (file_name);
11105 if (custom_dev_instance != ~0)
11108 mp->custom_dev_instance = ntohl (custom_dev_instance);
11110 mp->use_custom_mac = use_custom_mac;
11111 clib_memcpy (mp->mac_address, hwaddr, 6);
11113 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11123 api_modify_vhost_user_if (vat_main_t * vam)
11125 unformat_input_t *i = vam->input;
11126 vl_api_modify_vhost_user_if_t *mp;
11130 u8 file_name_set = 0;
11131 u32 custom_dev_instance = ~0;
11132 u8 sw_if_index_set = 0;
11133 u32 sw_if_index = (u32) ~ 0;
11135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11138 sw_if_index_set = 1;
11139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11140 sw_if_index_set = 1;
11141 else if (unformat (i, "socket %s", &file_name))
11145 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11147 else if (unformat (i, "server"))
11153 if (sw_if_index_set == 0)
11155 errmsg ("missing sw_if_index or interface name");
11159 if (file_name_set == 0)
11161 errmsg ("missing socket file name");
11165 if (vec_len (file_name) > 255)
11167 errmsg ("socket file name too long");
11170 vec_add1 (file_name, 0);
11172 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
11174 mp->sw_if_index = ntohl (sw_if_index);
11175 mp->is_server = is_server;
11176 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11177 vec_free (file_name);
11178 if (custom_dev_instance != ~0)
11181 mp->custom_dev_instance = ntohl (custom_dev_instance);
11191 api_delete_vhost_user_if (vat_main_t * vam)
11193 unformat_input_t *i = vam->input;
11194 vl_api_delete_vhost_user_if_t *mp;
11196 u32 sw_if_index = ~0;
11197 u8 sw_if_index_set = 0;
11199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11201 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11202 sw_if_index_set = 1;
11203 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11204 sw_if_index_set = 1;
11209 if (sw_if_index_set == 0)
11211 errmsg ("missing sw_if_index or interface name");
11216 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
11218 mp->sw_if_index = ntohl (sw_if_index);
11226 static void vl_api_sw_interface_vhost_user_details_t_handler
11227 (vl_api_sw_interface_vhost_user_details_t * mp)
11229 vat_main_t *vam = &vat_main;
11231 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11232 (char *) mp->interface_name,
11233 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11234 clib_net_to_host_u64 (mp->features), mp->is_server,
11235 ntohl (mp->num_regions), (char *) mp->sock_filename);
11236 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11239 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11240 (vl_api_sw_interface_vhost_user_details_t * mp)
11242 vat_main_t *vam = &vat_main;
11243 vat_json_node_t *node = NULL;
11245 if (VAT_JSON_ARRAY != vam->json_tree.type)
11247 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11248 vat_json_init_array (&vam->json_tree);
11250 node = vat_json_array_add (&vam->json_tree);
11252 vat_json_init_object (node);
11253 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11254 vat_json_object_add_string_copy (node, "interface_name",
11255 mp->interface_name);
11256 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11257 ntohl (mp->virtio_net_hdr_sz));
11258 vat_json_object_add_uint (node, "features",
11259 clib_net_to_host_u64 (mp->features));
11260 vat_json_object_add_uint (node, "is_server", mp->is_server);
11261 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11262 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11263 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11267 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11269 vl_api_sw_interface_vhost_user_dump_t *mp;
11272 "Interface name idx hdr_sz features server regions filename");
11274 /* Get list of vhost-user interfaces */
11275 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
11278 /* Use a control ping for synchronization */
11280 vl_api_control_ping_t *mp;
11281 M (CONTROL_PING, control_ping);
11288 api_show_version (vat_main_t * vam)
11290 vl_api_show_version_t *mp;
11293 M (SHOW_VERSION, show_version);
11303 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11305 unformat_input_t *line_input = vam->input;
11306 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11308 ip4_address_t local4, remote4;
11309 ip6_address_t local6, remote6;
11311 u8 ipv4_set = 0, ipv6_set = 0;
11314 u32 encap_vrf_id = 0;
11315 u32 decap_vrf_id = 0;
11320 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11322 if (unformat (line_input, "del"))
11324 else if (unformat (line_input, "local %U",
11325 unformat_ip4_address, &local4))
11330 else if (unformat (line_input, "remote %U",
11331 unformat_ip4_address, &remote4))
11336 else if (unformat (line_input, "local %U",
11337 unformat_ip6_address, &local6))
11342 else if (unformat (line_input, "remote %U",
11343 unformat_ip6_address, &remote6))
11348 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11350 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11352 else if (unformat (line_input, "vni %d", &vni))
11354 else if (unformat (line_input, "next-ip4"))
11356 else if (unformat (line_input, "next-ip6"))
11358 else if (unformat (line_input, "next-ethernet"))
11360 else if (unformat (line_input, "next-nsh"))
11364 errmsg ("parse error '%U'", format_unformat_error, line_input);
11369 if (local_set == 0)
11371 errmsg ("tunnel local address not specified");
11374 if (remote_set == 0)
11376 errmsg ("tunnel remote address not specified");
11379 if (ipv4_set && ipv6_set)
11381 errmsg ("both IPv4 and IPv6 addresses specified");
11387 errmsg ("vni not specified");
11391 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11396 clib_memcpy (&mp->local, &local6, sizeof (local6));
11397 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11401 clib_memcpy (&mp->local, &local4, sizeof (local4));
11402 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11405 mp->encap_vrf_id = ntohl (encap_vrf_id);
11406 mp->decap_vrf_id = ntohl (decap_vrf_id);
11407 mp->protocol = protocol;
11408 mp->vni = ntohl (vni);
11409 mp->is_add = is_add;
11410 mp->is_ipv6 = ipv6_set;
11418 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11419 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11421 vat_main_t *vam = &vat_main;
11423 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11424 ntohl (mp->sw_if_index),
11425 format_ip46_address, &(mp->local[0]),
11426 format_ip46_address, &(mp->remote[0]),
11428 ntohl (mp->protocol),
11429 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11432 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11433 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11435 vat_main_t *vam = &vat_main;
11436 vat_json_node_t *node = NULL;
11437 struct in_addr ip4;
11438 struct in6_addr ip6;
11440 if (VAT_JSON_ARRAY != vam->json_tree.type)
11442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11443 vat_json_init_array (&vam->json_tree);
11445 node = vat_json_array_add (&vam->json_tree);
11447 vat_json_init_object (node);
11448 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11451 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11452 vat_json_object_add_ip6 (node, "local", ip6);
11453 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11454 vat_json_object_add_ip6 (node, "remote", ip6);
11458 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11459 vat_json_object_add_ip4 (node, "local", ip4);
11460 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11461 vat_json_object_add_ip4 (node, "remote", ip4);
11463 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11464 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11465 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11466 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11467 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11471 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11473 unformat_input_t *i = vam->input;
11474 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11477 u8 sw_if_index_set = 0;
11479 /* Parse args required to build the message */
11480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11482 if (unformat (i, "sw_if_index %d", &sw_if_index))
11483 sw_if_index_set = 1;
11488 if (sw_if_index_set == 0)
11493 if (!vam->json_output)
11495 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11496 "sw_if_index", "local", "remote", "vni",
11497 "protocol", "encap_vrf_id", "decap_vrf_id");
11500 /* Get list of vxlan-tunnel interfaces */
11501 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11503 mp->sw_if_index = htonl (sw_if_index);
11507 /* Use a control ping for synchronization */
11509 vl_api_control_ping_t *mp;
11510 M (CONTROL_PING, control_ping);
11517 format_l2_fib_mac_address (u8 * s, va_list * args)
11519 u8 *a = va_arg (*args, u8 *);
11521 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11522 a[2], a[3], a[4], a[5], a[6], a[7]);
11525 static void vl_api_l2_fib_table_entry_t_handler
11526 (vl_api_l2_fib_table_entry_t * mp)
11528 vat_main_t *vam = &vat_main;
11530 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11532 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11533 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11537 static void vl_api_l2_fib_table_entry_t_handler_json
11538 (vl_api_l2_fib_table_entry_t * mp)
11540 vat_main_t *vam = &vat_main;
11541 vat_json_node_t *node = NULL;
11543 if (VAT_JSON_ARRAY != vam->json_tree.type)
11545 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11546 vat_json_init_array (&vam->json_tree);
11548 node = vat_json_array_add (&vam->json_tree);
11550 vat_json_init_object (node);
11551 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11552 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11553 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11554 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11555 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11556 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11560 api_l2_fib_table_dump (vat_main_t * vam)
11562 unformat_input_t *i = vam->input;
11563 vl_api_l2_fib_table_dump_t *mp;
11568 /* Parse args required to build the message */
11569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11571 if (unformat (i, "bd_id %d", &bd_id))
11577 if (bd_id_set == 0)
11579 errmsg ("missing bridge domain");
11583 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11585 /* Get list of l2 fib entries */
11586 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11588 mp->bd_id = ntohl (bd_id);
11591 /* Use a control ping for synchronization */
11593 vl_api_control_ping_t *mp;
11594 M (CONTROL_PING, control_ping);
11602 api_interface_name_renumber (vat_main_t * vam)
11604 unformat_input_t *line_input = vam->input;
11605 vl_api_interface_name_renumber_t *mp;
11606 u32 sw_if_index = ~0;
11608 u32 new_show_dev_instance = ~0;
11610 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11612 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11615 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11617 else if (unformat (line_input, "new_show_dev_instance %d",
11618 &new_show_dev_instance))
11624 if (sw_if_index == ~0)
11626 errmsg ("missing interface name or sw_if_index");
11630 if (new_show_dev_instance == ~0)
11632 errmsg ("missing new_show_dev_instance");
11636 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11638 mp->sw_if_index = ntohl (sw_if_index);
11639 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11646 api_want_ip4_arp_events (vat_main_t * vam)
11648 unformat_input_t *line_input = vam->input;
11649 vl_api_want_ip4_arp_events_t *mp;
11651 ip4_address_t address;
11652 int address_set = 0;
11653 u32 enable_disable = 1;
11655 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11657 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11659 else if (unformat (line_input, "del"))
11660 enable_disable = 0;
11665 if (address_set == 0)
11667 errmsg ("missing addresses");
11671 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11672 mp->enable_disable = enable_disable;
11673 mp->pid = getpid ();
11674 mp->address = address.as_u32;
11681 api_want_ip6_nd_events (vat_main_t * vam)
11683 unformat_input_t *line_input = vam->input;
11684 vl_api_want_ip6_nd_events_t *mp;
11686 ip6_address_t address;
11687 int address_set = 0;
11688 u32 enable_disable = 1;
11690 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11692 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11694 else if (unformat (line_input, "del"))
11695 enable_disable = 0;
11700 if (address_set == 0)
11702 errmsg ("missing addresses");
11706 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11707 mp->enable_disable = enable_disable;
11708 mp->pid = getpid ();
11709 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11716 api_input_acl_set_interface (vat_main_t * vam)
11718 unformat_input_t *i = vam->input;
11719 vl_api_input_acl_set_interface_t *mp;
11722 int sw_if_index_set;
11723 u32 ip4_table_index = ~0;
11724 u32 ip6_table_index = ~0;
11725 u32 l2_table_index = ~0;
11728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11730 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11731 sw_if_index_set = 1;
11732 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11733 sw_if_index_set = 1;
11734 else if (unformat (i, "del"))
11736 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11738 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11740 else if (unformat (i, "l2-table %d", &l2_table_index))
11744 clib_warning ("parse error '%U'", format_unformat_error, i);
11749 if (sw_if_index_set == 0)
11751 errmsg ("missing interface name or sw_if_index");
11755 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11757 mp->sw_if_index = ntohl (sw_if_index);
11758 mp->ip4_table_index = ntohl (ip4_table_index);
11759 mp->ip6_table_index = ntohl (ip6_table_index);
11760 mp->l2_table_index = ntohl (l2_table_index);
11761 mp->is_add = is_add;
11770 api_ip_address_dump (vat_main_t * vam)
11772 unformat_input_t *i = vam->input;
11773 vl_api_ip_address_dump_t *mp;
11774 u32 sw_if_index = ~0;
11775 u8 sw_if_index_set = 0;
11780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11782 if (unformat (i, "sw_if_index %d", &sw_if_index))
11783 sw_if_index_set = 1;
11785 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11786 sw_if_index_set = 1;
11787 else if (unformat (i, "ipv4"))
11789 else if (unformat (i, "ipv6"))
11795 if (ipv4_set && ipv6_set)
11797 errmsg ("ipv4 and ipv6 flags cannot be both set");
11801 if ((!ipv4_set) && (!ipv6_set))
11803 errmsg ("no ipv4 nor ipv6 flag set");
11807 if (sw_if_index_set == 0)
11809 errmsg ("missing interface name or sw_if_index");
11813 vam->current_sw_if_index = sw_if_index;
11814 vam->is_ipv6 = ipv6_set;
11816 M (IP_ADDRESS_DUMP, ip_address_dump);
11817 mp->sw_if_index = ntohl (sw_if_index);
11818 mp->is_ipv6 = ipv6_set;
11821 /* Use a control ping for synchronization */
11823 vl_api_control_ping_t *mp;
11824 M (CONTROL_PING, control_ping);
11831 api_ip_dump (vat_main_t * vam)
11833 vl_api_ip_dump_t *mp;
11834 unformat_input_t *in = vam->input;
11841 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11843 if (unformat (in, "ipv4"))
11845 else if (unformat (in, "ipv6"))
11851 if (ipv4_set && ipv6_set)
11853 errmsg ("ipv4 and ipv6 flags cannot be both set");
11857 if ((!ipv4_set) && (!ipv6_set))
11859 errmsg ("no ipv4 nor ipv6 flag set");
11863 is_ipv6 = ipv6_set;
11864 vam->is_ipv6 = is_ipv6;
11866 /* free old data */
11867 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11869 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11871 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11873 M (IP_DUMP, ip_dump);
11874 mp->is_ipv6 = ipv6_set;
11877 /* Use a control ping for synchronization */
11879 vl_api_control_ping_t *mp;
11880 M (CONTROL_PING, control_ping);
11887 api_ipsec_spd_add_del (vat_main_t * vam)
11889 unformat_input_t *i = vam->input;
11890 vl_api_ipsec_spd_add_del_t *mp;
11895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11897 if (unformat (i, "spd_id %d", &spd_id))
11899 else if (unformat (i, "del"))
11903 clib_warning ("parse error '%U'", format_unformat_error, i);
11909 errmsg ("spd_id must be set");
11913 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11915 mp->spd_id = ntohl (spd_id);
11916 mp->is_add = is_add;
11925 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11927 unformat_input_t *i = vam->input;
11928 vl_api_ipsec_interface_add_del_spd_t *mp;
11931 u8 sw_if_index_set = 0;
11932 u32 spd_id = (u32) ~ 0;
11935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11937 if (unformat (i, "del"))
11939 else if (unformat (i, "spd_id %d", &spd_id))
11942 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11943 sw_if_index_set = 1;
11944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11945 sw_if_index_set = 1;
11948 clib_warning ("parse error '%U'", format_unformat_error, i);
11954 if (spd_id == (u32) ~ 0)
11956 errmsg ("spd_id must be set");
11960 if (sw_if_index_set == 0)
11962 errmsg ("missing interface name or sw_if_index");
11966 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11968 mp->spd_id = ntohl (spd_id);
11969 mp->sw_if_index = ntohl (sw_if_index);
11970 mp->is_add = is_add;
11979 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11981 unformat_input_t *i = vam->input;
11982 vl_api_ipsec_spd_add_del_entry_t *mp;
11984 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11985 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11987 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11988 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11989 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11990 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11992 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11993 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11994 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11995 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11996 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11997 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12001 if (unformat (i, "del"))
12003 if (unformat (i, "outbound"))
12005 if (unformat (i, "inbound"))
12007 else if (unformat (i, "spd_id %d", &spd_id))
12009 else if (unformat (i, "sa_id %d", &sa_id))
12011 else if (unformat (i, "priority %d", &priority))
12013 else if (unformat (i, "protocol %d", &protocol))
12015 else if (unformat (i, "lport_start %d", &lport_start))
12017 else if (unformat (i, "lport_stop %d", &lport_stop))
12019 else if (unformat (i, "rport_start %d", &rport_start))
12021 else if (unformat (i, "rport_stop %d", &rport_stop))
12025 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12031 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12038 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12044 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12051 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12057 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12064 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12070 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12076 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12078 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12080 clib_warning ("unsupported action: 'resolve'");
12086 clib_warning ("parse error '%U'", format_unformat_error, i);
12092 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
12094 mp->spd_id = ntohl (spd_id);
12095 mp->priority = ntohl (priority);
12096 mp->is_outbound = is_outbound;
12098 mp->is_ipv6 = is_ipv6;
12099 if (is_ipv6 || is_ip_any)
12101 clib_memcpy (mp->remote_address_start, &raddr6_start,
12102 sizeof (ip6_address_t));
12103 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12104 sizeof (ip6_address_t));
12105 clib_memcpy (mp->local_address_start, &laddr6_start,
12106 sizeof (ip6_address_t));
12107 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12108 sizeof (ip6_address_t));
12112 clib_memcpy (mp->remote_address_start, &raddr4_start,
12113 sizeof (ip4_address_t));
12114 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12115 sizeof (ip4_address_t));
12116 clib_memcpy (mp->local_address_start, &laddr4_start,
12117 sizeof (ip4_address_t));
12118 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12119 sizeof (ip4_address_t));
12121 mp->protocol = (u8) protocol;
12122 mp->local_port_start = ntohs ((u16) lport_start);
12123 mp->local_port_stop = ntohs ((u16) lport_stop);
12124 mp->remote_port_start = ntohs ((u16) rport_start);
12125 mp->remote_port_stop = ntohs ((u16) rport_stop);
12126 mp->policy = (u8) policy;
12127 mp->sa_id = ntohl (sa_id);
12128 mp->is_add = is_add;
12129 mp->is_ip_any = is_ip_any;
12137 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12139 unformat_input_t *i = vam->input;
12140 vl_api_ipsec_sad_add_del_entry_t *mp;
12142 u32 sad_id = 0, spi = 0;
12143 u8 *ck = 0, *ik = 0;
12146 u8 protocol = IPSEC_PROTOCOL_AH;
12147 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12148 u32 crypto_alg = 0, integ_alg = 0;
12149 ip4_address_t tun_src4;
12150 ip4_address_t tun_dst4;
12151 ip6_address_t tun_src6;
12152 ip6_address_t tun_dst6;
12154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12156 if (unformat (i, "del"))
12158 else if (unformat (i, "sad_id %d", &sad_id))
12160 else if (unformat (i, "spi %d", &spi))
12162 else if (unformat (i, "esp"))
12163 protocol = IPSEC_PROTOCOL_ESP;
12164 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12167 is_tunnel_ipv6 = 0;
12169 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12172 is_tunnel_ipv6 = 0;
12174 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12177 is_tunnel_ipv6 = 1;
12179 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12182 is_tunnel_ipv6 = 1;
12186 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12188 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12189 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12191 clib_warning ("unsupported crypto-alg: '%U'",
12192 format_ipsec_crypto_alg, crypto_alg);
12196 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12200 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12203 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
12205 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12207 integ_alg >= IPSEC_INTEG_N_ALG)
12209 clib_warning ("unsupported integ-alg: '%U'",
12210 format_ipsec_integ_alg, integ_alg);
12214 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12218 clib_warning ("parse error '%U'", format_unformat_error, i);
12225 /*Special cases, aes-gcm-128 encryption */
12226 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
12228 if (integ_alg != IPSEC_INTEG_ALG_NONE
12229 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
12232 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
12235 else /*set integ-alg internally to aes-gcm-128 */
12236 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
12238 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
12240 clib_warning ("unsupported integ-alg: aes-gcm-128");
12243 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
12245 clib_warning ("unsupported integ-alg: none");
12251 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
12253 mp->sad_id = ntohl (sad_id);
12254 mp->is_add = is_add;
12255 mp->protocol = protocol;
12256 mp->spi = ntohl (spi);
12257 mp->is_tunnel = is_tunnel;
12258 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12259 mp->crypto_algorithm = crypto_alg;
12260 mp->integrity_algorithm = integ_alg;
12261 mp->crypto_key_length = vec_len (ck);
12262 mp->integrity_key_length = vec_len (ik);
12264 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12265 mp->crypto_key_length = sizeof (mp->crypto_key);
12267 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12268 mp->integrity_key_length = sizeof (mp->integrity_key);
12271 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12273 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12277 if (is_tunnel_ipv6)
12279 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12280 sizeof (ip6_address_t));
12281 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12282 sizeof (ip6_address_t));
12286 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12287 sizeof (ip4_address_t));
12288 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12289 sizeof (ip4_address_t));
12300 api_ipsec_sa_set_key (vat_main_t * vam)
12302 unformat_input_t *i = vam->input;
12303 vl_api_ipsec_sa_set_key_t *mp;
12306 u8 *ck = 0, *ik = 0;
12308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12310 if (unformat (i, "sa_id %d", &sa_id))
12312 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12314 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12318 clib_warning ("parse error '%U'", format_unformat_error, i);
12323 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12325 mp->sa_id = ntohl (sa_id);
12326 mp->crypto_key_length = vec_len (ck);
12327 mp->integrity_key_length = vec_len (ik);
12329 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12330 mp->crypto_key_length = sizeof (mp->crypto_key);
12332 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12333 mp->integrity_key_length = sizeof (mp->integrity_key);
12336 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12338 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12347 api_ikev2_profile_add_del (vat_main_t * vam)
12349 unformat_input_t *i = vam->input;
12350 vl_api_ikev2_profile_add_del_t *mp;
12355 const char *valid_chars = "a-zA-Z0-9_";
12357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12359 if (unformat (i, "del"))
12361 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12362 vec_add1 (name, 0);
12365 errmsg ("parse error '%U'", format_unformat_error, i);
12370 if (!vec_len (name))
12372 errmsg ("profile name must be specified");
12376 if (vec_len (name) > 64)
12378 errmsg ("profile name too long");
12382 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12384 clib_memcpy (mp->name, name, vec_len (name));
12385 mp->is_add = is_add;
12395 api_ikev2_profile_set_auth (vat_main_t * vam)
12397 unformat_input_t *i = vam->input;
12398 vl_api_ikev2_profile_set_auth_t *mp;
12402 u32 auth_method = 0;
12405 const char *valid_chars = "a-zA-Z0-9_";
12407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12409 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12410 vec_add1 (name, 0);
12411 else if (unformat (i, "auth_method %U",
12412 unformat_ikev2_auth_method, &auth_method))
12414 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12416 else if (unformat (i, "auth_data %v", &data))
12420 errmsg ("parse error '%U'", format_unformat_error, i);
12425 if (!vec_len (name))
12427 errmsg ("profile name must be specified");
12431 if (vec_len (name) > 64)
12433 errmsg ("profile name too long");
12437 if (!vec_len (data))
12439 errmsg ("auth_data must be specified");
12445 errmsg ("auth_method must be specified");
12449 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12451 mp->is_hex = is_hex;
12452 mp->auth_method = (u8) auth_method;
12453 mp->data_len = vec_len (data);
12454 clib_memcpy (mp->name, name, vec_len (name));
12455 clib_memcpy (mp->data, data, vec_len (data));
12466 api_ikev2_profile_set_id (vat_main_t * vam)
12468 unformat_input_t *i = vam->input;
12469 vl_api_ikev2_profile_set_id_t *mp;
12477 const char *valid_chars = "a-zA-Z0-9_";
12479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12481 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12482 vec_add1 (name, 0);
12483 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12485 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12487 data = vec_new (u8, 4);
12488 clib_memcpy (data, ip4.as_u8, 4);
12490 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12492 else if (unformat (i, "id_data %v", &data))
12494 else if (unformat (i, "local"))
12496 else if (unformat (i, "remote"))
12500 errmsg ("parse error '%U'", format_unformat_error, i);
12505 if (!vec_len (name))
12507 errmsg ("profile name must be specified");
12511 if (vec_len (name) > 64)
12513 errmsg ("profile name too long");
12517 if (!vec_len (data))
12519 errmsg ("id_data must be specified");
12525 errmsg ("id_type must be specified");
12529 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12531 mp->is_local = is_local;
12532 mp->id_type = (u8) id_type;
12533 mp->data_len = vec_len (data);
12534 clib_memcpy (mp->name, name, vec_len (name));
12535 clib_memcpy (mp->data, data, vec_len (data));
12546 api_ikev2_profile_set_ts (vat_main_t * vam)
12548 unformat_input_t *i = vam->input;
12549 vl_api_ikev2_profile_set_ts_t *mp;
12553 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12554 ip4_address_t start_addr, end_addr;
12556 const char *valid_chars = "a-zA-Z0-9_";
12558 start_addr.as_u32 = 0;
12559 end_addr.as_u32 = (u32) ~ 0;
12561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12563 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12564 vec_add1 (name, 0);
12565 else if (unformat (i, "protocol %d", &proto))
12567 else if (unformat (i, "start_port %d", &start_port))
12569 else if (unformat (i, "end_port %d", &end_port))
12572 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12574 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12576 else if (unformat (i, "local"))
12578 else if (unformat (i, "remote"))
12582 errmsg ("parse error '%U'", format_unformat_error, i);
12587 if (!vec_len (name))
12589 errmsg ("profile name must be specified");
12593 if (vec_len (name) > 64)
12595 errmsg ("profile name too long");
12599 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12601 mp->is_local = is_local;
12602 mp->proto = (u8) proto;
12603 mp->start_port = (u16) start_port;
12604 mp->end_port = (u16) end_port;
12605 mp->start_addr = start_addr.as_u32;
12606 mp->end_addr = end_addr.as_u32;
12607 clib_memcpy (mp->name, name, vec_len (name));
12617 api_ikev2_set_local_key (vat_main_t * vam)
12619 unformat_input_t *i = vam->input;
12620 vl_api_ikev2_set_local_key_t *mp;
12624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12626 if (unformat (i, "file %v", &file))
12627 vec_add1 (file, 0);
12630 errmsg ("parse error '%U'", format_unformat_error, i);
12635 if (!vec_len (file))
12637 errmsg ("RSA key file must be specified");
12641 if (vec_len (file) > 256)
12643 errmsg ("file name too long");
12647 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12649 clib_memcpy (mp->key_file, file, vec_len (file));
12662 api_map_add_domain (vat_main_t * vam)
12664 unformat_input_t *i = vam->input;
12665 vl_api_map_add_domain_t *mp;
12668 ip4_address_t ip4_prefix;
12669 ip6_address_t ip6_prefix;
12670 ip6_address_t ip6_src;
12671 u32 num_m_args = 0;
12672 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12673 0, psid_length = 0;
12674 u8 is_translation = 0;
12676 u32 ip6_src_len = 128;
12678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12680 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12681 &ip4_prefix, &ip4_prefix_len))
12683 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12684 &ip6_prefix, &ip6_prefix_len))
12688 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12691 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12693 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12695 else if (unformat (i, "psid-offset %d", &psid_offset))
12697 else if (unformat (i, "psid-len %d", &psid_length))
12699 else if (unformat (i, "mtu %d", &mtu))
12701 else if (unformat (i, "map-t"))
12702 is_translation = 1;
12705 clib_warning ("parse error '%U'", format_unformat_error, i);
12710 if (num_m_args < 3)
12712 errmsg ("mandatory argument(s) missing");
12716 /* Construct the API message */
12717 M (MAP_ADD_DOMAIN, map_add_domain);
12719 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12720 mp->ip4_prefix_len = ip4_prefix_len;
12722 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12723 mp->ip6_prefix_len = ip6_prefix_len;
12725 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12726 mp->ip6_src_prefix_len = ip6_src_len;
12728 mp->ea_bits_len = ea_bits_len;
12729 mp->psid_offset = psid_offset;
12730 mp->psid_length = psid_length;
12731 mp->is_translation = is_translation;
12732 mp->mtu = htons (mtu);
12737 /* Wait for a reply, return good/bad news */
12742 api_map_del_domain (vat_main_t * vam)
12744 unformat_input_t *i = vam->input;
12745 vl_api_map_del_domain_t *mp;
12748 u32 num_m_args = 0;
12751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12753 if (unformat (i, "index %d", &index))
12757 clib_warning ("parse error '%U'", format_unformat_error, i);
12762 if (num_m_args != 1)
12764 errmsg ("mandatory argument(s) missing");
12768 /* Construct the API message */
12769 M (MAP_DEL_DOMAIN, map_del_domain);
12771 mp->index = ntohl (index);
12776 /* Wait for a reply, return good/bad news */
12781 api_map_add_del_rule (vat_main_t * vam)
12783 unformat_input_t *i = vam->input;
12784 vl_api_map_add_del_rule_t *mp;
12787 ip6_address_t ip6_dst;
12788 u32 num_m_args = 0, index, psid = 0;
12790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12792 if (unformat (i, "index %d", &index))
12794 else if (unformat (i, "psid %d", &psid))
12796 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12798 else if (unformat (i, "del"))
12804 clib_warning ("parse error '%U'", format_unformat_error, i);
12809 /* Construct the API message */
12810 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12812 mp->index = ntohl (index);
12813 mp->is_add = is_add;
12814 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12815 mp->psid = ntohs (psid);
12820 /* Wait for a reply, return good/bad news */
12825 api_map_domain_dump (vat_main_t * vam)
12827 vl_api_map_domain_dump_t *mp;
12830 /* Construct the API message */
12831 M (MAP_DOMAIN_DUMP, map_domain_dump);
12836 /* Use a control ping for synchronization */
12838 vl_api_control_ping_t *mp;
12839 M (CONTROL_PING, control_ping);
12846 api_map_rule_dump (vat_main_t * vam)
12848 unformat_input_t *i = vam->input;
12849 vl_api_map_rule_dump_t *mp;
12851 u32 domain_index = ~0;
12853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12855 if (unformat (i, "index %u", &domain_index))
12861 if (domain_index == ~0)
12863 clib_warning ("parse error: domain index expected");
12867 /* Construct the API message */
12868 M (MAP_RULE_DUMP, map_rule_dump);
12870 mp->domain_index = htonl (domain_index);
12875 /* Use a control ping for synchronization */
12877 vl_api_control_ping_t *mp;
12878 M (CONTROL_PING, control_ping);
12884 static void vl_api_map_add_domain_reply_t_handler
12885 (vl_api_map_add_domain_reply_t * mp)
12887 vat_main_t *vam = &vat_main;
12888 i32 retval = ntohl (mp->retval);
12890 if (vam->async_mode)
12892 vam->async_errors += (retval < 0);
12896 vam->retval = retval;
12897 vam->result_ready = 1;
12901 static void vl_api_map_add_domain_reply_t_handler_json
12902 (vl_api_map_add_domain_reply_t * mp)
12904 vat_main_t *vam = &vat_main;
12905 vat_json_node_t node;
12907 vat_json_init_object (&node);
12908 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12909 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12911 vat_json_print (vam->ofp, &node);
12912 vat_json_free (&node);
12914 vam->retval = ntohl (mp->retval);
12915 vam->result_ready = 1;
12919 api_get_first_msg_id (vat_main_t * vam)
12921 vl_api_get_first_msg_id_t *mp;
12923 unformat_input_t *i = vam->input;
12927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12929 if (unformat (i, "client %s", &name))
12937 errmsg ("missing client name");
12940 vec_add1 (name, 0);
12942 if (vec_len (name) > 63)
12944 errmsg ("client name too long");
12948 M (GET_FIRST_MSG_ID, get_first_msg_id);
12949 clib_memcpy (mp->name, name, vec_len (name));
12957 api_cop_interface_enable_disable (vat_main_t * vam)
12959 unformat_input_t *line_input = vam->input;
12960 vl_api_cop_interface_enable_disable_t *mp;
12962 u32 sw_if_index = ~0;
12963 u8 enable_disable = 1;
12965 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12967 if (unformat (line_input, "disable"))
12968 enable_disable = 0;
12969 if (unformat (line_input, "enable"))
12970 enable_disable = 1;
12971 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12972 vam, &sw_if_index))
12974 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12980 if (sw_if_index == ~0)
12982 errmsg ("missing interface name or sw_if_index");
12986 /* Construct the API message */
12987 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12988 mp->sw_if_index = ntohl (sw_if_index);
12989 mp->enable_disable = enable_disable;
12993 /* Wait for the reply */
12998 api_cop_whitelist_enable_disable (vat_main_t * vam)
13000 unformat_input_t *line_input = vam->input;
13001 vl_api_cop_whitelist_enable_disable_t *mp;
13003 u32 sw_if_index = ~0;
13004 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13007 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13009 if (unformat (line_input, "ip4"))
13011 else if (unformat (line_input, "ip6"))
13013 else if (unformat (line_input, "default"))
13015 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13016 vam, &sw_if_index))
13018 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13020 else if (unformat (line_input, "fib-id %d", &fib_id))
13026 if (sw_if_index == ~0)
13028 errmsg ("missing interface name or sw_if_index");
13032 /* Construct the API message */
13033 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
13034 mp->sw_if_index = ntohl (sw_if_index);
13035 mp->fib_id = ntohl (fib_id);
13038 mp->default_cop = default_cop;
13042 /* Wait for the reply */
13047 api_get_node_graph (vat_main_t * vam)
13049 vl_api_get_node_graph_t *mp;
13052 M (GET_NODE_GRAPH, get_node_graph);
13056 /* Wait for the reply */
13061 /** Used for parsing LISP eids */
13062 typedef CLIB_PACKED(struct{
13063 u8 addr[16]; /**< eid address */
13064 u32 len; /**< prefix length if IP */
13065 u8 type; /**< type of eid */
13070 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13072 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13074 memset (a, 0, sizeof (a[0]));
13076 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13078 a->type = 0; /* ipv4 type */
13080 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13082 a->type = 1; /* ipv6 type */
13084 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13086 a->type = 2; /* mac type */
13093 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13102 lisp_eid_size_vat (u8 type)
13117 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13119 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13123 /** Used for transferring locators via VPP API */
13124 typedef CLIB_PACKED(struct
13126 u32 sw_if_index; /**< locator sw_if_index */
13127 u8 priority; /**< locator priority */
13128 u8 weight; /**< locator weight */
13133 api_lisp_add_del_locator_set (vat_main_t * vam)
13135 unformat_input_t *input = vam->input;
13136 vl_api_lisp_add_del_locator_set_t *mp;
13139 u8 *locator_set_name = NULL;
13140 u8 locator_set_name_set = 0;
13141 ls_locator_t locator, *locators = 0;
13142 u32 sw_if_index, priority, weight;
13145 /* Parse args required to build the message */
13146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13148 if (unformat (input, "del"))
13152 else if (unformat (input, "locator-set %s", &locator_set_name))
13154 locator_set_name_set = 1;
13156 else if (unformat (input, "sw_if_index %u p %u w %u",
13157 &sw_if_index, &priority, &weight))
13159 locator.sw_if_index = htonl (sw_if_index);
13160 locator.priority = priority;
13161 locator.weight = weight;
13162 vec_add1 (locators, locator);
13166 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13167 &sw_if_index, &priority, &weight))
13169 locator.sw_if_index = htonl (sw_if_index);
13170 locator.priority = priority;
13171 locator.weight = weight;
13172 vec_add1 (locators, locator);
13178 if (locator_set_name_set == 0)
13180 errmsg ("missing locator-set name");
13181 vec_free (locators);
13185 if (vec_len (locator_set_name) > 64)
13187 errmsg ("locator-set name too long");
13188 vec_free (locator_set_name);
13189 vec_free (locators);
13192 vec_add1 (locator_set_name, 0);
13194 data_len = sizeof (ls_locator_t) * vec_len (locators);
13196 /* Construct the API message */
13197 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
13199 mp->is_add = is_add;
13200 clib_memcpy (mp->locator_set_name, locator_set_name,
13201 vec_len (locator_set_name));
13202 vec_free (locator_set_name);
13204 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13206 clib_memcpy (mp->locators, locators, data_len);
13207 vec_free (locators);
13212 /* Wait for a reply... */
13220 api_lisp_add_del_locator (vat_main_t * vam)
13222 unformat_input_t *input = vam->input;
13223 vl_api_lisp_add_del_locator_t *mp;
13225 u32 tmp_if_index = ~0;
13226 u32 sw_if_index = ~0;
13227 u8 sw_if_index_set = 0;
13228 u8 sw_if_index_if_name_set = 0;
13230 u8 priority_set = 0;
13234 u8 *locator_set_name = NULL;
13235 u8 locator_set_name_set = 0;
13237 /* Parse args required to build the message */
13238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13240 if (unformat (input, "del"))
13244 else if (unformat (input, "locator-set %s", &locator_set_name))
13246 locator_set_name_set = 1;
13248 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13251 sw_if_index_if_name_set = 1;
13252 sw_if_index = tmp_if_index;
13254 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13256 sw_if_index_set = 1;
13257 sw_if_index = tmp_if_index;
13259 else if (unformat (input, "p %d", &priority))
13263 else if (unformat (input, "w %d", &weight))
13271 if (locator_set_name_set == 0)
13273 errmsg ("missing locator-set name");
13277 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13279 errmsg ("missing sw_if_index");
13280 vec_free (locator_set_name);
13284 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13286 errmsg ("cannot use both params interface name and sw_if_index");
13287 vec_free (locator_set_name);
13291 if (priority_set == 0)
13293 errmsg ("missing locator-set priority");
13294 vec_free (locator_set_name);
13298 if (weight_set == 0)
13300 errmsg ("missing locator-set weight");
13301 vec_free (locator_set_name);
13305 if (vec_len (locator_set_name) > 64)
13307 errmsg ("locator-set name too long");
13308 vec_free (locator_set_name);
13311 vec_add1 (locator_set_name, 0);
13313 /* Construct the API message */
13314 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13316 mp->is_add = is_add;
13317 mp->sw_if_index = ntohl (sw_if_index);
13318 mp->priority = priority;
13319 mp->weight = weight;
13320 clib_memcpy (mp->locator_set_name, locator_set_name,
13321 vec_len (locator_set_name));
13322 vec_free (locator_set_name);
13327 /* Wait for a reply... */
13335 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13337 u32 *key_id = va_arg (*args, u32 *);
13340 if (unformat (input, "%s", &s))
13342 if (!strcmp ((char *) s, "sha1"))
13343 key_id[0] = HMAC_SHA_1_96;
13344 else if (!strcmp ((char *) s, "sha256"))
13345 key_id[0] = HMAC_SHA_256_128;
13348 clib_warning ("invalid key_id: '%s'", s);
13349 key_id[0] = HMAC_NO_KEY;
13360 api_lisp_add_del_local_eid (vat_main_t * vam)
13362 unformat_input_t *input = vam->input;
13363 vl_api_lisp_add_del_local_eid_t *mp;
13367 lisp_eid_vat_t _eid, *eid = &_eid;
13368 u8 *locator_set_name = 0;
13369 u8 locator_set_name_set = 0;
13374 /* Parse args required to build the message */
13375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13377 if (unformat (input, "del"))
13381 else if (unformat (input, "vni %d", &vni))
13385 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13389 else if (unformat (input, "locator-set %s", &locator_set_name))
13391 locator_set_name_set = 1;
13393 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13395 else if (unformat (input, "secret-key %_%v%_", &key))
13401 if (locator_set_name_set == 0)
13403 errmsg ("missing locator-set name");
13409 errmsg ("EID address not set!");
13410 vec_free (locator_set_name);
13414 if (key && (0 == key_id))
13416 errmsg ("invalid key_id!");
13420 if (vec_len (key) > 64)
13422 errmsg ("key too long");
13427 if (vec_len (locator_set_name) > 64)
13429 errmsg ("locator-set name too long");
13430 vec_free (locator_set_name);
13433 vec_add1 (locator_set_name, 0);
13435 /* Construct the API message */
13436 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13438 mp->is_add = is_add;
13439 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13440 mp->eid_type = eid->type;
13441 mp->prefix_len = eid->len;
13442 mp->vni = clib_host_to_net_u32 (vni);
13443 mp->key_id = clib_host_to_net_u16 (key_id);
13444 clib_memcpy (mp->locator_set_name, locator_set_name,
13445 vec_len (locator_set_name));
13446 clib_memcpy (mp->key, key, vec_len (key));
13448 vec_free (locator_set_name);
13454 /* Wait for a reply... */
13462 /** Used for transferring locators via VPP API */
13463 typedef CLIB_PACKED(struct
13465 u8 is_ip4; /**< is locator an IPv4 address? */
13466 u8 priority; /**< locator priority */
13467 u8 weight; /**< locator weight */
13468 u8 addr[16]; /**< IPv4/IPv6 address */
13473 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13475 u32 dp_table = 0, vni = 0;;
13476 unformat_input_t *input = vam->input;
13477 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13480 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13481 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13482 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13483 u32 action = ~0, w;
13484 ip4_address_t rmt_rloc4, lcl_rloc4;
13485 ip6_address_t rmt_rloc6, lcl_rloc6;
13486 vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc =
13489 memset (&rloc, 0, sizeof (rloc));
13491 /* Parse args required to build the message */
13492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13494 if (unformat (input, "del"))
13496 else if (unformat (input, "add"))
13498 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13502 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13506 else if (unformat (input, "vrf %d", &dp_table))
13508 else if (unformat (input, "bd %d", &dp_table))
13510 else if (unformat (input, "vni %d", &vni))
13512 else if (unformat (input, "w %d", &w))
13516 errmsg ("No RLOC configured for setting priority/weight!");
13519 curr_rloc->weight = w;
13521 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13522 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13526 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13528 vec_add1 (lcl_locs, rloc);
13530 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13531 vec_add1 (rmt_locs, rloc);
13532 /* weight saved in rmt loc */
13533 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13535 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13536 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13539 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13541 vec_add1 (lcl_locs, rloc);
13543 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13544 vec_add1 (rmt_locs, rloc);
13545 /* weight saved in rmt loc */
13546 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13548 else if (unformat (input, "action %d", &action))
13554 clib_warning ("parse error '%U'", format_unformat_error, input);
13561 errmsg ("remote eid addresses not set");
13565 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13567 errmsg ("eid types don't match");
13571 if (0 == rmt_locs && (u32) ~ 0 == action)
13573 errmsg ("action not set for negative mapping");
13577 /* Construct the API message */
13578 M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry,
13579 sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2);
13581 mp->is_add = is_add;
13582 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13583 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13584 mp->eid_type = rmt_eid->type;
13585 mp->dp_table = clib_host_to_net_u32 (dp_table);
13586 mp->vni = clib_host_to_net_u32 (vni);
13587 mp->rmt_len = rmt_eid->len;
13588 mp->lcl_len = lcl_eid->len;
13589 mp->action = action;
13591 if (0 != rmt_locs && 0 != lcl_locs)
13593 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13594 clib_memcpy (mp->locs, lcl_locs,
13595 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs)));
13597 u32 offset = sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs);
13598 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13599 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs)));
13601 vec_free (lcl_locs);
13602 vec_free (rmt_locs);
13607 /* Wait for a reply... */
13615 api_lisp_add_del_map_server (vat_main_t * vam)
13617 unformat_input_t *input = vam->input;
13618 vl_api_lisp_add_del_map_server_t *mp;
13623 ip4_address_t ipv4;
13624 ip6_address_t ipv6;
13626 /* Parse args required to build the message */
13627 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13629 if (unformat (input, "del"))
13633 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13637 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13645 if (ipv4_set && ipv6_set)
13647 errmsg ("both eid v4 and v6 addresses set");
13651 if (!ipv4_set && !ipv6_set)
13653 errmsg ("eid addresses not set");
13657 /* Construct the API message */
13658 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13660 mp->is_add = is_add;
13664 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13669 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13675 /* Wait for a reply... */
13683 api_lisp_add_del_map_resolver (vat_main_t * vam)
13685 unformat_input_t *input = vam->input;
13686 vl_api_lisp_add_del_map_resolver_t *mp;
13691 ip4_address_t ipv4;
13692 ip6_address_t ipv6;
13694 /* Parse args required to build the message */
13695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13697 if (unformat (input, "del"))
13701 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13705 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13713 if (ipv4_set && ipv6_set)
13715 errmsg ("both eid v4 and v6 addresses set");
13719 if (!ipv4_set && !ipv6_set)
13721 errmsg ("eid addresses not set");
13725 /* Construct the API message */
13726 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13728 mp->is_add = is_add;
13732 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13737 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13743 /* Wait for a reply... */
13751 api_lisp_gpe_enable_disable (vat_main_t * vam)
13753 unformat_input_t *input = vam->input;
13754 vl_api_lisp_gpe_enable_disable_t *mp;
13759 /* Parse args required to build the message */
13760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13762 if (unformat (input, "enable"))
13767 else if (unformat (input, "disable"))
13778 errmsg ("Value not set");
13782 /* Construct the API message */
13783 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13790 /* Wait for a reply... */
13798 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13800 unformat_input_t *input = vam->input;
13801 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13806 /* Parse args required to build the message */
13807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13809 if (unformat (input, "enable"))
13814 else if (unformat (input, "disable"))
13822 errmsg ("Value not set");
13826 /* Construct the API message */
13827 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13829 mp->is_enabled = is_en;
13834 /* Wait for a reply... */
13842 api_lisp_map_register_enable_disable (vat_main_t * vam)
13844 unformat_input_t *input = vam->input;
13845 vl_api_lisp_map_register_enable_disable_t *mp;
13850 /* Parse args required to build the message */
13851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13853 if (unformat (input, "enable"))
13858 else if (unformat (input, "disable"))
13866 errmsg ("Value not set");
13870 /* Construct the API message */
13871 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13873 mp->is_enabled = is_en;
13878 /* Wait for a reply... */
13886 api_lisp_enable_disable (vat_main_t * vam)
13888 unformat_input_t *input = vam->input;
13889 vl_api_lisp_enable_disable_t *mp;
13894 /* Parse args required to build the message */
13895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13897 if (unformat (input, "enable"))
13902 else if (unformat (input, "disable"))
13912 errmsg ("Value not set");
13916 /* Construct the API message */
13917 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13924 /* Wait for a reply... */
13932 api_show_lisp_map_register_state (vat_main_t * vam)
13935 vl_api_show_lisp_map_register_state_t *mp;
13937 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13942 /* wait for reply */
13949 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13952 vl_api_show_lisp_rloc_probe_state_t *mp;
13954 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13959 /* wait for reply */
13966 api_show_lisp_map_request_mode (vat_main_t * vam)
13969 vl_api_show_lisp_map_request_mode_t *mp;
13971 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13976 /* wait for reply */
13983 api_lisp_map_request_mode (vat_main_t * vam)
13986 unformat_input_t *input = vam->input;
13987 vl_api_lisp_map_request_mode_t *mp;
13990 /* Parse args required to build the message */
13991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13993 if (unformat (input, "dst-only"))
13995 else if (unformat (input, "src-dst"))
13999 errmsg ("parse error '%U'", format_unformat_error, input);
14004 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
14011 /* wait for reply */
14019 * Enable/disable LISP proxy ITR.
14021 * @param vam vpp API test context
14022 * @return return code
14025 api_lisp_pitr_set_locator_set (vat_main_t * vam)
14028 u8 ls_name_set = 0;
14029 unformat_input_t *input = vam->input;
14030 vl_api_lisp_pitr_set_locator_set_t *mp;
14034 /* Parse args required to build the message */
14035 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14037 if (unformat (input, "del"))
14039 else if (unformat (input, "locator-set %s", &ls_name))
14043 errmsg ("parse error '%U'", format_unformat_error, input);
14050 errmsg ("locator-set name not set!");
14054 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
14056 mp->is_add = is_add;
14057 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14058 vec_free (ls_name);
14063 /* wait for reply */
14071 api_show_lisp_pitr (vat_main_t * vam)
14073 vl_api_show_lisp_pitr_t *mp;
14076 if (!vam->json_output)
14078 print (vam->ofp, "%=20s", "lisp status:");
14081 M (SHOW_LISP_PITR, show_lisp_pitr);
14085 /* Wait for a reply... */
14093 * Add/delete mapping between vni and vrf
14096 api_lisp_eid_table_add_del_map (vat_main_t * vam)
14099 unformat_input_t *input = vam->input;
14100 vl_api_lisp_eid_table_add_del_map_t *mp;
14101 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14102 u32 vni, vrf, bd_index;
14104 /* Parse args required to build the message */
14105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14107 if (unformat (input, "del"))
14109 else if (unformat (input, "vrf %d", &vrf))
14111 else if (unformat (input, "bd_index %d", &bd_index))
14113 else if (unformat (input, "vni %d", &vni))
14119 if (!vni_set || (!vrf_set && !bd_index_set))
14121 errmsg ("missing arguments!");
14125 if (vrf_set && bd_index_set)
14127 errmsg ("error: both vrf and bd entered!");
14131 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
14133 mp->is_add = is_add;
14134 mp->vni = htonl (vni);
14135 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14136 mp->is_l2 = bd_index_set;
14141 /* wait for reply */
14149 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14151 u32 *action = va_arg (*args, u32 *);
14154 if (unformat (input, "%s", &s))
14156 if (!strcmp ((char *) s, "no-action"))
14158 else if (!strcmp ((char *) s, "natively-forward"))
14160 else if (!strcmp ((char *) s, "send-map-request"))
14162 else if (!strcmp ((char *) s, "drop"))
14166 clib_warning ("invalid action: '%s'", s);
14178 * Add/del remote mapping to/from LISP control plane
14180 * @param vam vpp API test context
14181 * @return return code
14184 api_lisp_add_del_remote_mapping (vat_main_t * vam)
14186 unformat_input_t *input = vam->input;
14187 vl_api_lisp_add_del_remote_mapping_t *mp;
14190 lisp_eid_vat_t _eid, *eid = &_eid;
14191 lisp_eid_vat_t _seid, *seid = &_seid;
14192 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14193 u32 action = ~0, p, w, data_len;
14194 ip4_address_t rloc4;
14195 ip6_address_t rloc6;
14196 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
14198 memset (&rloc, 0, sizeof (rloc));
14200 /* Parse args required to build the message */
14201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14203 if (unformat (input, "del-all"))
14207 else if (unformat (input, "del"))
14211 else if (unformat (input, "add"))
14215 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14219 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14223 else if (unformat (input, "vni %d", &vni))
14227 else if (unformat (input, "p %d w %d", &p, &w))
14231 errmsg ("No RLOC configured for setting priority/weight!");
14234 curr_rloc->priority = p;
14235 curr_rloc->weight = w;
14237 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14240 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14241 vec_add1 (rlocs, rloc);
14242 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14244 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14247 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14248 vec_add1 (rlocs, rloc);
14249 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14251 else if (unformat (input, "action %U",
14252 unformat_negative_mapping_action, &action))
14258 clib_warning ("parse error '%U'", format_unformat_error, input);
14265 errmsg ("missing params!");
14269 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14271 errmsg ("no action set for negative map-reply!");
14275 data_len = vec_len (rlocs) * sizeof (rloc_t);
14277 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14278 mp->is_add = is_add;
14279 mp->vni = htonl (vni);
14280 mp->action = (u8) action;
14281 mp->is_src_dst = seid_set;
14282 mp->eid_len = eid->len;
14283 mp->seid_len = seid->len;
14284 mp->del_all = del_all;
14285 mp->eid_type = eid->type;
14286 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14287 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14289 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14290 clib_memcpy (mp->rlocs, rlocs, data_len);
14296 /* Wait for a reply... */
14304 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14305 * forwarding entries in data-plane accordingly.
14307 * @param vam vpp API test context
14308 * @return return code
14311 api_lisp_add_del_adjacency (vat_main_t * vam)
14313 unformat_input_t *input = vam->input;
14314 vl_api_lisp_add_del_adjacency_t *mp;
14317 ip4_address_t leid4, reid4;
14318 ip6_address_t leid6, reid6;
14319 u8 reid_mac[6] = { 0 };
14320 u8 leid_mac[6] = { 0 };
14321 u8 reid_type, leid_type;
14322 u32 leid_len = 0, reid_len = 0, len;
14325 leid_type = reid_type = (u8) ~ 0;
14327 /* Parse args required to build the message */
14328 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14330 if (unformat (input, "del"))
14334 else if (unformat (input, "add"))
14338 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14341 reid_type = 0; /* ipv4 */
14344 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14347 reid_type = 1; /* ipv6 */
14350 else if (unformat (input, "reid %U", unformat_ethernet_address,
14353 reid_type = 2; /* mac */
14355 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14358 leid_type = 0; /* ipv4 */
14361 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14364 leid_type = 1; /* ipv6 */
14367 else if (unformat (input, "leid %U", unformat_ethernet_address,
14370 leid_type = 2; /* mac */
14372 else if (unformat (input, "vni %d", &vni))
14378 errmsg ("parse error '%U'", format_unformat_error, input);
14383 if ((u8) ~ 0 == reid_type)
14385 errmsg ("missing params!");
14389 if (leid_type != reid_type)
14391 errmsg ("remote and local EIDs are of different types!");
14395 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14396 mp->is_add = is_add;
14397 mp->vni = htonl (vni);
14398 mp->leid_len = leid_len;
14399 mp->reid_len = reid_len;
14400 mp->eid_type = reid_type;
14402 switch (mp->eid_type)
14405 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14406 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14409 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14410 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14413 clib_memcpy (mp->leid, leid_mac, 6);
14414 clib_memcpy (mp->reid, reid_mac, 6);
14417 errmsg ("unknown EID type %d!", mp->eid_type);
14424 /* Wait for a reply... */
14432 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14434 unformat_input_t *input = vam->input;
14435 vl_api_lisp_gpe_add_del_iface_t *mp;
14437 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14438 u32 dp_table = 0, vni = 0;
14440 /* Parse args required to build the message */
14441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14443 if (unformat (input, "up"))
14448 else if (unformat (input, "down"))
14453 else if (unformat (input, "table_id %d", &dp_table))
14457 else if (unformat (input, "bd_id %d", &dp_table))
14462 else if (unformat (input, "vni %d", &vni))
14470 if (action_set == 0)
14472 errmsg ("Action not set");
14475 if (dp_table_set == 0 || vni_set == 0)
14477 errmsg ("vni and dp_table must be set");
14481 /* Construct the API message */
14482 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14484 mp->is_add = is_add;
14485 mp->dp_table = dp_table;
14492 /* Wait for a reply... */
14500 * Add/del map request itr rlocs from LISP control plane and updates
14502 * @param vam vpp API test context
14503 * @return return code
14506 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14508 unformat_input_t *input = vam->input;
14509 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14511 u8 *locator_set_name = 0;
14512 u8 locator_set_name_set = 0;
14515 /* Parse args required to build the message */
14516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14518 if (unformat (input, "del"))
14522 else if (unformat (input, "%_%v%_", &locator_set_name))
14524 locator_set_name_set = 1;
14528 clib_warning ("parse error '%U'", format_unformat_error, input);
14533 if (is_add && !locator_set_name_set)
14535 errmsg ("itr-rloc is not set!");
14539 if (is_add && vec_len (locator_set_name) > 64)
14541 errmsg ("itr-rloc locator-set name too long");
14542 vec_free (locator_set_name);
14546 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14547 mp->is_add = is_add;
14550 clib_memcpy (mp->locator_set_name, locator_set_name,
14551 vec_len (locator_set_name));
14555 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14557 vec_free (locator_set_name);
14562 /* Wait for a reply... */
14570 api_lisp_locator_dump (vat_main_t * vam)
14572 unformat_input_t *input = vam->input;
14573 vl_api_lisp_locator_dump_t *mp;
14575 u8 is_index_set = 0, is_name_set = 0;
14579 /* Parse args required to build the message */
14580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14582 if (unformat (input, "ls_name %_%v%_", &ls_name))
14586 else if (unformat (input, "ls_index %d", &ls_index))
14592 errmsg ("parse error '%U'", format_unformat_error, input);
14597 if (!is_index_set && !is_name_set)
14599 errmsg ("error: expected one of index or name!");
14603 if (is_index_set && is_name_set)
14605 errmsg ("error: only one param expected!");
14609 if (vec_len (ls_name) > 62)
14611 errmsg ("error: locator set name too long!");
14615 if (!vam->json_output)
14617 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14620 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14621 mp->is_index_set = is_index_set;
14624 mp->ls_index = clib_host_to_net_u32 (ls_index);
14627 vec_add1 (ls_name, 0);
14628 strncpy ((char *) mp->ls_name, (char *) ls_name,
14629 sizeof (mp->ls_name) - 1);
14635 /* Use a control ping for synchronization */
14637 vl_api_control_ping_t *mp;
14638 M (CONTROL_PING, control_ping);
14641 /* Wait for a reply... */
14649 api_lisp_locator_set_dump (vat_main_t * vam)
14651 vl_api_lisp_locator_set_dump_t *mp;
14652 unformat_input_t *input = vam->input;
14656 /* Parse args required to build the message */
14657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14659 if (unformat (input, "local"))
14663 else if (unformat (input, "remote"))
14669 errmsg ("parse error '%U'", format_unformat_error, input);
14674 if (!vam->json_output)
14676 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14679 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14681 mp->filter = filter;
14686 /* Use a control ping for synchronization */
14688 vl_api_control_ping_t *mp;
14689 M (CONTROL_PING, control_ping);
14692 /* Wait for a reply... */
14700 api_lisp_eid_table_map_dump (vat_main_t * vam)
14704 unformat_input_t *input = vam->input;
14705 vl_api_lisp_eid_table_map_dump_t *mp;
14708 /* Parse args required to build the message */
14709 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14711 if (unformat (input, "l2"))
14716 else if (unformat (input, "l3"))
14723 errmsg ("parse error '%U'", format_unformat_error, input);
14730 errmsg ("expected one of 'l2' or 'l3' parameter!");
14734 if (!vam->json_output)
14736 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14739 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14745 /* Use a control ping for synchronization */
14747 vl_api_control_ping_t *mp;
14748 M (CONTROL_PING, control_ping);
14751 /* Wait for a reply... */
14759 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14761 vl_api_lisp_eid_table_vni_dump_t *mp;
14764 if (!vam->json_output)
14766 print (vam->ofp, "VNI");
14769 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14774 /* Use a control ping for synchronization */
14776 vl_api_control_ping_t *mp;
14777 M (CONTROL_PING, control_ping);
14780 /* Wait for a reply... */
14788 api_lisp_eid_table_dump (vat_main_t * vam)
14790 unformat_input_t *i = vam->input;
14791 vl_api_lisp_eid_table_dump_t *mp;
14793 struct in_addr ip4;
14794 struct in6_addr ip6;
14796 u8 eid_type = ~0, eid_set = 0;
14797 u32 prefix_length = ~0, t, vni = 0;
14800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14802 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14808 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14814 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14819 else if (unformat (i, "vni %d", &t))
14823 else if (unformat (i, "local"))
14827 else if (unformat (i, "remote"))
14833 errmsg ("parse error '%U'", format_unformat_error, i);
14838 if (!vam->json_output)
14840 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14841 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14844 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14846 mp->filter = filter;
14850 mp->vni = htonl (vni);
14851 mp->eid_type = eid_type;
14855 mp->prefix_length = prefix_length;
14856 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14859 mp->prefix_length = prefix_length;
14860 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14863 clib_memcpy (mp->eid, mac, sizeof (mac));
14866 errmsg ("unknown EID type %d!", eid_type);
14874 /* Use a control ping for synchronization */
14876 vl_api_control_ping_t *mp;
14877 M (CONTROL_PING, control_ping);
14881 /* Wait for a reply... */
14889 api_lisp_adjacencies_get (vat_main_t * vam)
14891 unformat_input_t *i = vam->input;
14892 vl_api_lisp_adjacencies_get_t *mp;
14897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14899 if (unformat (i, "vni %d", &vni))
14905 errmsg ("parse error '%U'", format_unformat_error, i);
14912 errmsg ("vni not set!");
14916 if (!vam->json_output)
14918 print (vam->ofp, "%s %40s", "leid", "reid");
14921 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14922 mp->vni = clib_host_to_net_u32 (vni);
14927 /* Wait for a reply... */
14935 api_lisp_map_server_dump (vat_main_t * vam)
14937 vl_api_lisp_map_server_dump_t *mp;
14940 if (!vam->json_output)
14942 print (vam->ofp, "%=20s", "Map server");
14945 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14949 /* Use a control ping for synchronization */
14951 vl_api_control_ping_t *mp;
14952 M (CONTROL_PING, control_ping);
14955 /* Wait for a reply... */
14963 api_lisp_map_resolver_dump (vat_main_t * vam)
14965 vl_api_lisp_map_resolver_dump_t *mp;
14968 if (!vam->json_output)
14970 print (vam->ofp, "%=20s", "Map resolver");
14973 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14977 /* Use a control ping for synchronization */
14979 vl_api_control_ping_t *mp;
14980 M (CONTROL_PING, control_ping);
14983 /* Wait for a reply... */
14991 api_show_lisp_status (vat_main_t * vam)
14993 vl_api_show_lisp_status_t *mp;
14996 if (!vam->json_output)
14998 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
15001 M (SHOW_LISP_STATUS, show_lisp_status);
15004 /* Wait for a reply... */
15012 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
15014 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
15017 if (!vam->json_output)
15019 print (vam->ofp, "%=20s", "itr-rlocs:");
15022 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
15025 /* Wait for a reply... */
15033 api_af_packet_create (vat_main_t * vam)
15035 unformat_input_t *i = vam->input;
15036 vl_api_af_packet_create_t *mp;
15038 u8 *host_if_name = 0;
15040 u8 random_hw_addr = 1;
15042 memset (hw_addr, 0, sizeof (hw_addr));
15044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15046 if (unformat (i, "name %s", &host_if_name))
15047 vec_add1 (host_if_name, 0);
15048 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15049 random_hw_addr = 0;
15054 if (!vec_len (host_if_name))
15056 errmsg ("host-interface name must be specified");
15060 if (vec_len (host_if_name) > 64)
15062 errmsg ("host-interface name too long");
15066 M (AF_PACKET_CREATE, af_packet_create);
15068 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15069 clib_memcpy (mp->hw_addr, hw_addr, 6);
15070 mp->use_random_hw_addr = random_hw_addr;
15071 vec_free (host_if_name);
15074 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15080 api_af_packet_delete (vat_main_t * vam)
15082 unformat_input_t *i = vam->input;
15083 vl_api_af_packet_delete_t *mp;
15085 u8 *host_if_name = 0;
15087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15089 if (unformat (i, "name %s", &host_if_name))
15090 vec_add1 (host_if_name, 0);
15095 if (!vec_len (host_if_name))
15097 errmsg ("host-interface name must be specified");
15101 if (vec_len (host_if_name) > 64)
15103 errmsg ("host-interface name too long");
15107 M (AF_PACKET_DELETE, af_packet_delete);
15109 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15110 vec_free (host_if_name);
15119 api_policer_add_del (vat_main_t * vam)
15121 unformat_input_t *i = vam->input;
15122 vl_api_policer_add_del_t *mp;
15133 u8 color_aware = 0;
15134 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15136 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15137 conform_action.dscp = 0;
15138 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15139 exceed_action.dscp = 0;
15140 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15141 violate_action.dscp = 0;
15143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15145 if (unformat (i, "del"))
15147 else if (unformat (i, "name %s", &name))
15148 vec_add1 (name, 0);
15149 else if (unformat (i, "cir %u", &cir))
15151 else if (unformat (i, "eir %u", &eir))
15153 else if (unformat (i, "cb %u", &cb))
15155 else if (unformat (i, "eb %u", &eb))
15157 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15160 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15163 else if (unformat (i, "type %U", unformat_policer_type, &type))
15165 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15168 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15171 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15174 else if (unformat (i, "color-aware"))
15180 if (!vec_len (name))
15182 errmsg ("policer name must be specified");
15186 if (vec_len (name) > 64)
15188 errmsg ("policer name too long");
15192 M (POLICER_ADD_DEL, policer_add_del);
15194 clib_memcpy (mp->name, name, vec_len (name));
15196 mp->is_add = is_add;
15201 mp->rate_type = rate_type;
15202 mp->round_type = round_type;
15204 mp->conform_action_type = conform_action.action_type;
15205 mp->conform_dscp = conform_action.dscp;
15206 mp->exceed_action_type = exceed_action.action_type;
15207 mp->exceed_dscp = exceed_action.dscp;
15208 mp->violate_action_type = violate_action.action_type;
15209 mp->violate_dscp = violate_action.dscp;
15210 mp->color_aware = color_aware;
15219 api_policer_dump (vat_main_t * vam)
15221 unformat_input_t *i = vam->input;
15222 vl_api_policer_dump_t *mp;
15224 u8 *match_name = 0;
15225 u8 match_name_valid = 0;
15227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15229 if (unformat (i, "name %s", &match_name))
15231 vec_add1 (match_name, 0);
15232 match_name_valid = 1;
15238 M (POLICER_DUMP, policer_dump);
15239 mp->match_name_valid = match_name_valid;
15240 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15241 vec_free (match_name);
15245 /* Use a control ping for synchronization */
15247 vl_api_control_ping_t *mp;
15248 M (CONTROL_PING, control_ping);
15251 /* Wait for a reply... */
15259 api_policer_classify_set_interface (vat_main_t * vam)
15261 unformat_input_t *i = vam->input;
15262 vl_api_policer_classify_set_interface_t *mp;
15265 int sw_if_index_set;
15266 u32 ip4_table_index = ~0;
15267 u32 ip6_table_index = ~0;
15268 u32 l2_table_index = ~0;
15271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15274 sw_if_index_set = 1;
15275 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15276 sw_if_index_set = 1;
15277 else if (unformat (i, "del"))
15279 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15281 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15283 else if (unformat (i, "l2-table %d", &l2_table_index))
15287 clib_warning ("parse error '%U'", format_unformat_error, i);
15292 if (sw_if_index_set == 0)
15294 errmsg ("missing interface name or sw_if_index");
15298 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15300 mp->sw_if_index = ntohl (sw_if_index);
15301 mp->ip4_table_index = ntohl (ip4_table_index);
15302 mp->ip6_table_index = ntohl (ip6_table_index);
15303 mp->l2_table_index = ntohl (l2_table_index);
15304 mp->is_add = is_add;
15313 api_policer_classify_dump (vat_main_t * vam)
15315 unformat_input_t *i = vam->input;
15316 vl_api_policer_classify_dump_t *mp;
15318 u8 type = POLICER_CLASSIFY_N_TABLES;
15320 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15324 errmsg ("classify table type must be specified");
15328 if (!vam->json_output)
15330 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15333 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15338 /* Use a control ping for synchronization */
15340 vl_api_control_ping_t *mp;
15341 M (CONTROL_PING, control_ping);
15344 /* Wait for a reply... */
15352 api_netmap_create (vat_main_t * vam)
15354 unformat_input_t *i = vam->input;
15355 vl_api_netmap_create_t *mp;
15359 u8 random_hw_addr = 1;
15363 memset (hw_addr, 0, sizeof (hw_addr));
15365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15367 if (unformat (i, "name %s", &if_name))
15368 vec_add1 (if_name, 0);
15369 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15370 random_hw_addr = 0;
15371 else if (unformat (i, "pipe"))
15373 else if (unformat (i, "master"))
15375 else if (unformat (i, "slave"))
15381 if (!vec_len (if_name))
15383 errmsg ("interface name must be specified");
15387 if (vec_len (if_name) > 64)
15389 errmsg ("interface name too long");
15393 M (NETMAP_CREATE, netmap_create);
15395 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15396 clib_memcpy (mp->hw_addr, hw_addr, 6);
15397 mp->use_random_hw_addr = random_hw_addr;
15398 mp->is_pipe = is_pipe;
15399 mp->is_master = is_master;
15400 vec_free (if_name);
15409 api_netmap_delete (vat_main_t * vam)
15411 unformat_input_t *i = vam->input;
15412 vl_api_netmap_delete_t *mp;
15416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15418 if (unformat (i, "name %s", &if_name))
15419 vec_add1 (if_name, 0);
15424 if (!vec_len (if_name))
15426 errmsg ("interface name must be specified");
15430 if (vec_len (if_name) > 64)
15432 errmsg ("interface name too long");
15436 M (NETMAP_DELETE, netmap_delete);
15438 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15439 vec_free (if_name);
15447 static void vl_api_mpls_tunnel_details_t_handler
15448 (vl_api_mpls_tunnel_details_t * mp)
15450 vat_main_t *vam = &vat_main;
15451 i32 len = mp->mt_next_hop_n_labels;
15454 print (vam->ofp, "[%d]: via %U %d labels ",
15456 format_ip4_address, mp->mt_next_hop,
15457 ntohl (mp->mt_next_hop_sw_if_index));
15458 for (i = 0; i < len; i++)
15460 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15462 print (vam->ofp, "");
15465 static void vl_api_mpls_tunnel_details_t_handler_json
15466 (vl_api_mpls_tunnel_details_t * mp)
15468 vat_main_t *vam = &vat_main;
15469 vat_json_node_t *node = NULL;
15470 struct in_addr ip4;
15472 i32 len = mp->mt_next_hop_n_labels;
15474 if (VAT_JSON_ARRAY != vam->json_tree.type)
15476 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15477 vat_json_init_array (&vam->json_tree);
15479 node = vat_json_array_add (&vam->json_tree);
15481 vat_json_init_object (node);
15482 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15483 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15484 vat_json_object_add_ip4 (node, "next_hop", ip4);
15485 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15486 ntohl (mp->mt_next_hop_sw_if_index));
15487 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15488 vat_json_object_add_uint (node, "label_count", len);
15489 for (i = 0; i < len; i++)
15491 vat_json_object_add_uint (node, "label",
15492 ntohl (mp->mt_next_hop_out_labels[i]));
15497 api_mpls_tunnel_dump (vat_main_t * vam)
15499 vl_api_mpls_tunnel_dump_t *mp;
15503 /* Parse args required to build the message */
15504 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15506 if (!unformat (vam->input, "tunnel_index %d", &index))
15513 print (vam->ofp, " tunnel_index %d", index);
15515 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15516 mp->tunnel_index = htonl (index);
15519 /* Use a control ping for synchronization */
15521 vl_api_control_ping_t *mp;
15522 M (CONTROL_PING, control_ping);
15528 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15529 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15532 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15534 vat_main_t *vam = &vat_main;
15535 int count = ntohl (mp->count);
15536 vl_api_fib_path2_t *fp;
15540 "table-id %d, label %u, ess_bit %u",
15541 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15543 for (i = 0; i < count; i++)
15545 if (fp->afi == IP46_TYPE_IP6)
15547 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15548 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15549 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15550 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15551 format_ip6_address, fp->next_hop);
15552 else if (fp->afi == IP46_TYPE_IP4)
15554 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15555 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15556 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15557 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15558 format_ip4_address, fp->next_hop);
15563 static void vl_api_mpls_fib_details_t_handler_json
15564 (vl_api_mpls_fib_details_t * mp)
15566 vat_main_t *vam = &vat_main;
15567 int count = ntohl (mp->count);
15568 vat_json_node_t *node = NULL;
15569 struct in_addr ip4;
15570 struct in6_addr ip6;
15571 vl_api_fib_path2_t *fp;
15574 if (VAT_JSON_ARRAY != vam->json_tree.type)
15576 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15577 vat_json_init_array (&vam->json_tree);
15579 node = vat_json_array_add (&vam->json_tree);
15581 vat_json_init_object (node);
15582 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15583 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15584 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15585 vat_json_object_add_uint (node, "path_count", count);
15587 for (i = 0; i < count; i++)
15589 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15590 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15591 vat_json_object_add_uint (node, "is_local", fp->is_local);
15592 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15593 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15594 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15595 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15596 if (fp->afi == IP46_TYPE_IP4)
15598 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15599 vat_json_object_add_ip4 (node, "next_hop", ip4);
15601 else if (fp->afi == IP46_TYPE_IP6)
15603 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15604 vat_json_object_add_ip6 (node, "next_hop", ip6);
15610 api_mpls_fib_dump (vat_main_t * vam)
15612 vl_api_mpls_fib_dump_t *mp;
15615 M (MPLS_FIB_DUMP, mpls_fib_dump);
15618 /* Use a control ping for synchronization */
15620 vl_api_control_ping_t *mp;
15621 M (CONTROL_PING, control_ping);
15627 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15628 #define vl_api_ip_fib_details_t_print vl_noop_handler
15631 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15633 vat_main_t *vam = &vat_main;
15634 int count = ntohl (mp->count);
15635 vl_api_fib_path_t *fp;
15639 "table-id %d, prefix %U/%d",
15640 ntohl (mp->table_id), format_ip4_address, mp->address,
15641 mp->address_length);
15643 for (i = 0; i < count; i++)
15645 if (fp->afi == IP46_TYPE_IP6)
15647 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15648 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15649 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15650 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15651 format_ip6_address, fp->next_hop);
15652 else if (fp->afi == IP46_TYPE_IP4)
15654 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15655 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15656 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15657 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15658 format_ip4_address, fp->next_hop);
15663 static void vl_api_ip_fib_details_t_handler_json
15664 (vl_api_ip_fib_details_t * mp)
15666 vat_main_t *vam = &vat_main;
15667 int count = ntohl (mp->count);
15668 vat_json_node_t *node = NULL;
15669 struct in_addr ip4;
15670 struct in6_addr ip6;
15671 vl_api_fib_path_t *fp;
15674 if (VAT_JSON_ARRAY != vam->json_tree.type)
15676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15677 vat_json_init_array (&vam->json_tree);
15679 node = vat_json_array_add (&vam->json_tree);
15681 vat_json_init_object (node);
15682 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15683 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15684 vat_json_object_add_ip4 (node, "prefix", ip4);
15685 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15686 vat_json_object_add_uint (node, "path_count", count);
15688 for (i = 0; i < count; i++)
15690 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15691 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15692 vat_json_object_add_uint (node, "is_local", fp->is_local);
15693 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15694 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15695 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15696 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15697 if (fp->afi == IP46_TYPE_IP4)
15699 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15700 vat_json_object_add_ip4 (node, "next_hop", ip4);
15702 else if (fp->afi == IP46_TYPE_IP6)
15704 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15705 vat_json_object_add_ip6 (node, "next_hop", ip6);
15711 api_ip_fib_dump (vat_main_t * vam)
15713 vl_api_ip_fib_dump_t *mp;
15716 M (IP_FIB_DUMP, ip_fib_dump);
15719 /* Use a control ping for synchronization */
15721 vl_api_control_ping_t *mp;
15722 M (CONTROL_PING, control_ping);
15728 static void vl_api_ip_neighbor_details_t_handler
15729 (vl_api_ip_neighbor_details_t * mp)
15731 vat_main_t *vam = &vat_main;
15733 print (vam->ofp, "%c %U %U",
15734 (mp->is_static) ? 'S' : 'D',
15735 format_ethernet_address, &mp->mac_address,
15736 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15740 static void vl_api_ip_neighbor_details_t_handler_json
15741 (vl_api_ip_neighbor_details_t * mp)
15744 vat_main_t *vam = &vat_main;
15745 vat_json_node_t *node;
15746 struct in_addr ip4;
15747 struct in6_addr ip6;
15749 if (VAT_JSON_ARRAY != vam->json_tree.type)
15751 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15752 vat_json_init_array (&vam->json_tree);
15754 node = vat_json_array_add (&vam->json_tree);
15756 vat_json_init_object (node);
15757 vat_json_object_add_string_copy (node, "flag",
15758 (mp->is_static) ? (u8 *) "static" : (u8 *)
15761 vat_json_object_add_string_copy (node, "link_layer",
15762 format (0, "%U", format_ethernet_address,
15763 &mp->mac_address));
15767 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15768 vat_json_object_add_ip6 (node, "ip_address", ip6);
15772 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15773 vat_json_object_add_ip4 (node, "ip_address", ip4);
15778 api_ip_neighbor_dump (vat_main_t * vam)
15780 unformat_input_t *i = vam->input;
15781 vl_api_ip_neighbor_dump_t *mp;
15784 u32 sw_if_index = ~0;
15786 /* Parse args required to build the message */
15787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15789 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15791 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15793 else if (unformat (i, "ip6"))
15799 if (sw_if_index == ~0)
15801 errmsg ("missing interface name or sw_if_index");
15805 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15806 mp->is_ipv6 = (u8) is_ipv6;
15807 mp->sw_if_index = ntohl (sw_if_index);
15810 /* Use a control ping for synchronization */
15812 vl_api_control_ping_t *mp;
15813 M (CONTROL_PING, control_ping);
15819 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15820 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15823 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15825 vat_main_t *vam = &vat_main;
15826 int count = ntohl (mp->count);
15827 vl_api_fib_path_t *fp;
15831 "table-id %d, prefix %U/%d",
15832 ntohl (mp->table_id), format_ip6_address, mp->address,
15833 mp->address_length);
15835 for (i = 0; i < count; i++)
15837 if (fp->afi == IP46_TYPE_IP6)
15839 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15840 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15841 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15842 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15843 format_ip6_address, fp->next_hop);
15844 else if (fp->afi == IP46_TYPE_IP4)
15846 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15847 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15848 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15849 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15850 format_ip4_address, fp->next_hop);
15855 static void vl_api_ip6_fib_details_t_handler_json
15856 (vl_api_ip6_fib_details_t * mp)
15858 vat_main_t *vam = &vat_main;
15859 int count = ntohl (mp->count);
15860 vat_json_node_t *node = NULL;
15861 struct in_addr ip4;
15862 struct in6_addr ip6;
15863 vl_api_fib_path_t *fp;
15866 if (VAT_JSON_ARRAY != vam->json_tree.type)
15868 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15869 vat_json_init_array (&vam->json_tree);
15871 node = vat_json_array_add (&vam->json_tree);
15873 vat_json_init_object (node);
15874 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15875 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15876 vat_json_object_add_ip6 (node, "prefix", ip6);
15877 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15878 vat_json_object_add_uint (node, "path_count", count);
15880 for (i = 0; i < count; i++)
15882 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15883 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15884 vat_json_object_add_uint (node, "is_local", fp->is_local);
15885 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15886 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15887 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15888 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15889 if (fp->afi == IP46_TYPE_IP4)
15891 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15892 vat_json_object_add_ip4 (node, "next_hop", ip4);
15894 else if (fp->afi == IP46_TYPE_IP6)
15896 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15897 vat_json_object_add_ip6 (node, "next_hop", ip6);
15903 api_ip6_fib_dump (vat_main_t * vam)
15905 vl_api_ip6_fib_dump_t *mp;
15908 M (IP6_FIB_DUMP, ip6_fib_dump);
15911 /* Use a control ping for synchronization */
15913 vl_api_control_ping_t *mp;
15914 M (CONTROL_PING, control_ping);
15921 api_classify_table_ids (vat_main_t * vam)
15923 vl_api_classify_table_ids_t *mp;
15926 /* Construct the API message */
15927 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15937 api_classify_table_by_interface (vat_main_t * vam)
15939 unformat_input_t *input = vam->input;
15940 vl_api_classify_table_by_interface_t *mp;
15943 u32 sw_if_index = ~0;
15944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15946 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15948 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15953 if (sw_if_index == ~0)
15955 errmsg ("missing interface name or sw_if_index");
15959 /* Construct the API message */
15960 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15962 mp->sw_if_index = ntohl (sw_if_index);
15971 api_classify_table_info (vat_main_t * vam)
15973 unformat_input_t *input = vam->input;
15974 vl_api_classify_table_info_t *mp;
15978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15980 if (unformat (input, "table_id %d", &table_id))
15985 if (table_id == ~0)
15987 errmsg ("missing table id");
15991 /* Construct the API message */
15992 M (CLASSIFY_TABLE_INFO, classify_table_info);
15994 mp->table_id = ntohl (table_id);
16003 api_classify_session_dump (vat_main_t * vam)
16005 unformat_input_t *input = vam->input;
16006 vl_api_classify_session_dump_t *mp;
16010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16012 if (unformat (input, "table_id %d", &table_id))
16017 if (table_id == ~0)
16019 errmsg ("missing table id");
16023 /* Construct the API message */
16024 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
16026 mp->table_id = ntohl (table_id);
16029 /* Use a control ping for synchronization */
16031 vl_api_control_ping_t *mp;
16032 M (CONTROL_PING, control_ping);
16041 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16043 vat_main_t *vam = &vat_main;
16045 print (vam->ofp, "collector_address %U, collector_port %d, "
16046 "src_address %U, vrf_id %d, path_mtu %u, "
16047 "template_interval %u, udp_checksum %d",
16048 format_ip4_address, mp->collector_address,
16049 ntohs (mp->collector_port),
16050 format_ip4_address, mp->src_address,
16051 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16052 ntohl (mp->template_interval), mp->udp_checksum);
16055 vam->result_ready = 1;
16059 vl_api_ipfix_exporter_details_t_handler_json
16060 (vl_api_ipfix_exporter_details_t * mp)
16062 vat_main_t *vam = &vat_main;
16063 vat_json_node_t node;
16064 struct in_addr collector_address;
16065 struct in_addr src_address;
16067 vat_json_init_object (&node);
16068 clib_memcpy (&collector_address, &mp->collector_address,
16069 sizeof (collector_address));
16070 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16071 vat_json_object_add_uint (&node, "collector_port",
16072 ntohs (mp->collector_port));
16073 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16074 vat_json_object_add_ip4 (&node, "src_address", src_address);
16075 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16076 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16077 vat_json_object_add_uint (&node, "template_interval",
16078 ntohl (mp->template_interval));
16079 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16081 vat_json_print (vam->ofp, &node);
16082 vat_json_free (&node);
16084 vam->result_ready = 1;
16088 api_ipfix_exporter_dump (vat_main_t * vam)
16090 vl_api_ipfix_exporter_dump_t *mp;
16093 /* Construct the API message */
16094 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
16104 api_ipfix_classify_stream_dump (vat_main_t * vam)
16106 vl_api_ipfix_classify_stream_dump_t *mp;
16109 /* Construct the API message */
16110 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
16120 vl_api_ipfix_classify_stream_details_t_handler
16121 (vl_api_ipfix_classify_stream_details_t * mp)
16123 vat_main_t *vam = &vat_main;
16124 print (vam->ofp, "domain_id %d, src_port %d",
16125 ntohl (mp->domain_id), ntohs (mp->src_port));
16127 vam->result_ready = 1;
16131 vl_api_ipfix_classify_stream_details_t_handler_json
16132 (vl_api_ipfix_classify_stream_details_t * mp)
16134 vat_main_t *vam = &vat_main;
16135 vat_json_node_t node;
16137 vat_json_init_object (&node);
16138 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16139 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16141 vat_json_print (vam->ofp, &node);
16142 vat_json_free (&node);
16144 vam->result_ready = 1;
16148 api_ipfix_classify_table_dump (vat_main_t * vam)
16150 vl_api_ipfix_classify_table_dump_t *mp;
16153 if (!vam->json_output)
16155 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16156 "transport_protocol");
16159 /* Construct the API message */
16160 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
16165 /* Use a control ping for synchronization */
16167 vl_api_control_ping_t *mp;
16168 M (CONTROL_PING, control_ping);
16175 vl_api_ipfix_classify_table_details_t_handler
16176 (vl_api_ipfix_classify_table_details_t * mp)
16178 vat_main_t *vam = &vat_main;
16179 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16180 mp->transport_protocol);
16184 vl_api_ipfix_classify_table_details_t_handler_json
16185 (vl_api_ipfix_classify_table_details_t * mp)
16187 vat_json_node_t *node = NULL;
16188 vat_main_t *vam = &vat_main;
16190 if (VAT_JSON_ARRAY != vam->json_tree.type)
16192 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16193 vat_json_init_array (&vam->json_tree);
16196 node = vat_json_array_add (&vam->json_tree);
16197 vat_json_init_object (node);
16199 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16200 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16201 vat_json_object_add_uint (node, "transport_protocol",
16202 mp->transport_protocol);
16206 api_sw_interface_span_enable_disable (vat_main_t * vam)
16208 unformat_input_t *i = vam->input;
16209 vl_api_sw_interface_span_enable_disable_t *mp;
16211 u32 src_sw_if_index = ~0;
16212 u32 dst_sw_if_index = ~0;
16215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16218 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16220 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16224 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16226 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16228 else if (unformat (i, "disable"))
16230 else if (unformat (i, "rx"))
16232 else if (unformat (i, "tx"))
16234 else if (unformat (i, "both"))
16240 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16242 mp->sw_if_index_from = htonl (src_sw_if_index);
16243 mp->sw_if_index_to = htonl (dst_sw_if_index);
16253 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16256 vat_main_t *vam = &vat_main;
16257 u8 *sw_if_from_name = 0;
16258 u8 *sw_if_to_name = 0;
16259 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16260 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16261 char *states[] = { "none", "rx", "tx", "both" };
16265 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16267 if ((u32) p->value[0] == sw_if_index_from)
16269 sw_if_from_name = (u8 *)(p->key);
16273 if ((u32) p->value[0] == sw_if_index_to)
16275 sw_if_to_name = (u8 *)(p->key);
16276 if (sw_if_from_name)
16281 print (vam->ofp, "%20s => %20s (%s)",
16282 sw_if_from_name, sw_if_to_name, states[mp->state]);
16286 vl_api_sw_interface_span_details_t_handler_json
16287 (vl_api_sw_interface_span_details_t * mp)
16289 vat_main_t *vam = &vat_main;
16290 vat_json_node_t *node = NULL;
16291 u8 *sw_if_from_name = 0;
16292 u8 *sw_if_to_name = 0;
16293 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16294 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16298 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16300 if ((u32) p->value[0] == sw_if_index_from)
16302 sw_if_from_name = (u8 *)(p->key);
16306 if ((u32) p->value[0] == sw_if_index_to)
16308 sw_if_to_name = (u8 *)(p->key);
16309 if (sw_if_from_name)
16315 if (VAT_JSON_ARRAY != vam->json_tree.type)
16317 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16318 vat_json_init_array (&vam->json_tree);
16320 node = vat_json_array_add (&vam->json_tree);
16322 vat_json_init_object (node);
16323 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16324 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16325 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16326 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16327 vat_json_object_add_uint (node, "state", mp->state);
16331 api_sw_interface_span_dump (vat_main_t * vam)
16333 vl_api_sw_interface_span_dump_t *mp;
16336 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16339 /* Use a control ping for synchronization */
16341 vl_api_control_ping_t *mp;
16342 M (CONTROL_PING, control_ping);
16349 api_pg_create_interface (vat_main_t * vam)
16351 unformat_input_t *input = vam->input;
16352 vl_api_pg_create_interface_t *mp;
16356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16358 if (unformat (input, "if_id %d", &if_id))
16365 errmsg ("missing pg interface index");
16369 /* Construct the API message */
16370 M (PG_CREATE_INTERFACE, pg_create_interface);
16372 mp->interface_id = ntohl (if_id);
16381 api_pg_capture (vat_main_t * vam)
16383 unformat_input_t *input = vam->input;
16384 vl_api_pg_capture_t *mp;
16390 u8 pcap_file_set = 0;
16392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16394 if (unformat (input, "if_id %d", &if_id))
16396 else if (unformat (input, "pcap %s", &pcap_file))
16398 else if (unformat (input, "count %d", &count))
16400 else if (unformat (input, "disable"))
16407 errmsg ("missing pg interface index");
16410 if (pcap_file_set > 0)
16412 if (vec_len (pcap_file) > 255)
16414 errmsg ("pcap file name is too long");
16419 u32 name_len = vec_len (pcap_file);
16420 /* Construct the API message */
16421 M (PG_CAPTURE, pg_capture);
16423 mp->interface_id = ntohl (if_id);
16424 mp->is_enabled = enable;
16425 mp->count = ntohl (count);
16426 mp->pcap_name_length = ntohl (name_len);
16427 if (pcap_file_set != 0)
16429 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16431 vec_free (pcap_file);
16440 api_pg_enable_disable (vat_main_t * vam)
16442 unformat_input_t *input = vam->input;
16443 vl_api_pg_enable_disable_t *mp;
16447 u8 stream_name_set = 0;
16448 u8 *stream_name = 0;
16449 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16451 if (unformat (input, "stream %s", &stream_name))
16452 stream_name_set = 1;
16453 else if (unformat (input, "disable"))
16459 if (stream_name_set > 0)
16461 if (vec_len (stream_name) > 255)
16463 errmsg ("stream name too long");
16468 u32 name_len = vec_len (stream_name);
16469 /* Construct the API message */
16470 M (PG_ENABLE_DISABLE, pg_enable_disable);
16472 mp->is_enabled = enable;
16473 if (stream_name_set != 0)
16475 mp->stream_name_length = ntohl (name_len);
16476 clib_memcpy (mp->stream_name, stream_name, name_len);
16478 vec_free (stream_name);
16487 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16489 unformat_input_t *input = vam->input;
16490 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16493 u16 *low_ports = 0;
16494 u16 *high_ports = 0;
16497 ip4_address_t ip4_addr;
16498 ip6_address_t ip6_addr;
16506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16508 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16514 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16519 else if (unformat (input, "vrf %d", &vrf_id))
16521 else if (unformat (input, "del"))
16523 else if (unformat (input, "port %d", &tmp))
16525 if (tmp == 0 || tmp > 65535)
16527 errmsg ("port %d out of range", tmp);
16531 this_hi = this_low + 1;
16532 vec_add1 (low_ports, this_low);
16533 vec_add1 (high_ports, this_hi);
16535 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16537 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16539 errmsg ("incorrect range parameters");
16543 /* Note: in debug CLI +1 is added to high before
16544 passing to real fn that does "the work"
16545 (ip_source_and_port_range_check_add_del).
16546 This fn is a wrapper around the binary API fn a
16547 control plane will call, which expects this increment
16548 to have occurred. Hence letting the binary API control
16549 plane fn do the increment for consistency between VAT
16550 and other control planes.
16553 vec_add1 (low_ports, this_low);
16554 vec_add1 (high_ports, this_hi);
16560 if (prefix_set == 0)
16562 errmsg ("<address>/<mask> not specified");
16568 errmsg ("VRF ID required, not specified");
16575 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16579 if (vec_len (low_ports) == 0)
16581 errmsg ("At least one port or port range required");
16585 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16586 ip_source_and_port_range_check_add_del);
16588 mp->is_add = is_add;
16593 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16598 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16601 mp->mask_length = length;
16602 mp->number_of_ranges = vec_len (low_ports);
16604 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16605 vec_free (low_ports);
16607 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16608 vec_free (high_ports);
16610 mp->vrf_id = ntohl (vrf_id);
16619 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16621 unformat_input_t *input = vam->input;
16622 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16624 u32 sw_if_index = ~0;
16626 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16627 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16632 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16634 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16636 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16638 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16640 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16642 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16644 else if (unformat (input, "del"))
16650 if (sw_if_index == ~0)
16652 errmsg ("Interface required but not specified");
16658 errmsg ("VRF ID required but not specified");
16662 if (tcp_out_vrf_id == 0
16663 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16666 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16670 /* Construct the API message */
16671 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16672 ip_source_and_port_range_check_interface_add_del);
16674 mp->sw_if_index = ntohl (sw_if_index);
16675 mp->is_add = is_add;
16676 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16677 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16678 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16679 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16684 /* Wait for a reply... */
16689 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16691 unformat_input_t *i = vam->input;
16692 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16694 u32 local_sa_id = 0;
16695 u32 remote_sa_id = 0;
16696 ip4_address_t src_address;
16697 ip4_address_t dst_address;
16700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16702 if (unformat (i, "local_sa %d", &local_sa_id))
16704 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16706 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16708 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16710 else if (unformat (i, "del"))
16714 clib_warning ("parse error '%U'", format_unformat_error, i);
16719 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16721 mp->local_sa_id = ntohl (local_sa_id);
16722 mp->remote_sa_id = ntohl (remote_sa_id);
16723 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16724 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16725 mp->is_add = is_add;
16734 api_punt (vat_main_t * vam)
16736 unformat_input_t *i = vam->input;
16744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16746 if (unformat (i, "ip %d", &ipv))
16748 else if (unformat (i, "protocol %d", &protocol))
16750 else if (unformat (i, "port %d", &port))
16752 else if (unformat (i, "del"))
16756 clib_warning ("parse error '%U'", format_unformat_error, i);
16763 mp->is_add = (u8) is_add;
16764 mp->ipv = (u8) ipv;
16765 mp->l4_protocol = (u8) protocol;
16766 mp->l4_port = htons ((u16) port);
16774 static void vl_api_ipsec_gre_tunnel_details_t_handler
16775 (vl_api_ipsec_gre_tunnel_details_t * mp)
16777 vat_main_t *vam = &vat_main;
16779 print (vam->ofp, "%11d%15U%15U%14d%14d",
16780 ntohl (mp->sw_if_index),
16781 format_ip4_address, &mp->src_address,
16782 format_ip4_address, &mp->dst_address,
16783 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16786 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16787 (vl_api_ipsec_gre_tunnel_details_t * mp)
16789 vat_main_t *vam = &vat_main;
16790 vat_json_node_t *node = NULL;
16791 struct in_addr ip4;
16793 if (VAT_JSON_ARRAY != vam->json_tree.type)
16795 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16796 vat_json_init_array (&vam->json_tree);
16798 node = vat_json_array_add (&vam->json_tree);
16800 vat_json_init_object (node);
16801 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16802 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16803 vat_json_object_add_ip4 (node, "src_address", ip4);
16804 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16805 vat_json_object_add_ip4 (node, "dst_address", ip4);
16806 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16807 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16811 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16813 unformat_input_t *i = vam->input;
16814 vl_api_ipsec_gre_tunnel_dump_t *mp;
16817 u8 sw_if_index_set = 0;
16819 /* Parse args required to build the message */
16820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16822 if (unformat (i, "sw_if_index %d", &sw_if_index))
16823 sw_if_index_set = 1;
16828 if (sw_if_index_set == 0)
16833 if (!vam->json_output)
16835 print (vam->ofp, "%11s%15s%15s%14s%14s",
16836 "sw_if_index", "src_address", "dst_address",
16837 "local_sa_id", "remote_sa_id");
16840 /* Get list of gre-tunnel interfaces */
16841 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16843 mp->sw_if_index = htonl (sw_if_index);
16847 /* Use a control ping for synchronization */
16849 vl_api_control_ping_t *mp;
16850 M (CONTROL_PING, control_ping);
16857 api_delete_subif (vat_main_t * vam)
16859 unformat_input_t *i = vam->input;
16860 vl_api_delete_subif_t *mp;
16862 u32 sw_if_index = ~0;
16864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16866 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16868 if (unformat (i, "sw_if_index %d", &sw_if_index))
16874 if (sw_if_index == ~0)
16876 errmsg ("missing sw_if_index");
16880 /* Construct the API message */
16881 M (DELETE_SUBIF, delete_subif);
16882 mp->sw_if_index = ntohl (sw_if_index);
16888 #define foreach_pbb_vtr_op \
16889 _("disable", L2_VTR_DISABLED) \
16890 _("pop", L2_VTR_POP_2) \
16891 _("push", L2_VTR_PUSH_2)
16894 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16896 unformat_input_t *i = vam->input;
16897 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16899 u32 sw_if_index = ~0, vtr_op = ~0;
16900 u16 outer_tag = ~0;
16901 u8 dmac[6], smac[6];
16902 u8 dmac_set = 0, smac_set = 0;
16907 /* Shut up coverity */
16908 memset (dmac, 0, sizeof (dmac));
16909 memset (smac, 0, sizeof (smac));
16911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16913 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16915 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16917 else if (unformat (i, "vtr_op %d", &vtr_op))
16919 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16922 else if (unformat (i, "translate_pbb_stag"))
16924 if (unformat (i, "%d", &tmp))
16926 vtr_op = L2_VTR_TRANSLATE_2_1;
16932 ("translate_pbb_stag operation requires outer tag definition");
16936 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16938 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16940 else if (unformat (i, "sid %d", &sid))
16942 else if (unformat (i, "vlanid %d", &tmp))
16946 clib_warning ("parse error '%U'", format_unformat_error, i);
16951 if ((sw_if_index == ~0) || (vtr_op == ~0))
16953 errmsg ("missing sw_if_index or vtr operation");
16956 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16957 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16960 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16964 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16965 mp->sw_if_index = ntohl (sw_if_index);
16966 mp->vtr_op = ntohl (vtr_op);
16967 mp->outer_tag = ntohs (outer_tag);
16968 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16969 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16970 mp->b_vlanid = ntohs (vlanid);
16971 mp->i_sid = ntohl (sid);
16980 api_flow_classify_set_interface (vat_main_t * vam)
16982 unformat_input_t *i = vam->input;
16983 vl_api_flow_classify_set_interface_t *mp;
16986 int sw_if_index_set;
16987 u32 ip4_table_index = ~0;
16988 u32 ip6_table_index = ~0;
16991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16993 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16994 sw_if_index_set = 1;
16995 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16996 sw_if_index_set = 1;
16997 else if (unformat (i, "del"))
16999 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17001 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17005 clib_warning ("parse error '%U'", format_unformat_error, i);
17010 if (sw_if_index_set == 0)
17012 errmsg ("missing interface name or sw_if_index");
17016 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
17018 mp->sw_if_index = ntohl (sw_if_index);
17019 mp->ip4_table_index = ntohl (ip4_table_index);
17020 mp->ip6_table_index = ntohl (ip6_table_index);
17021 mp->is_add = is_add;
17030 api_flow_classify_dump (vat_main_t * vam)
17032 unformat_input_t *i = vam->input;
17033 vl_api_flow_classify_dump_t *mp;
17035 u8 type = FLOW_CLASSIFY_N_TABLES;
17037 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17041 errmsg ("classify table type must be specified");
17045 if (!vam->json_output)
17047 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17050 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
17055 /* Use a control ping for synchronization */
17057 vl_api_control_ping_t *mp;
17058 M (CONTROL_PING, control_ping);
17061 /* Wait for a reply... */
17069 api_feature_enable_disable (vat_main_t * vam)
17071 unformat_input_t *i = vam->input;
17072 vl_api_feature_enable_disable_t *mp;
17075 u8 *feature_name = 0;
17076 u32 sw_if_index = ~0;
17079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17081 if (unformat (i, "arc_name %s", &arc_name))
17083 else if (unformat (i, "feature_name %s", &feature_name))
17086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17090 else if (unformat (i, "disable"))
17098 errmsg ("missing arc name");
17101 if (vec_len (arc_name) > 63)
17103 errmsg ("arc name too long");
17106 if (feature_name == 0)
17108 errmsg ("missing feature name");
17111 if (vec_len (feature_name) > 63)
17113 errmsg ("feature name too long");
17116 if (sw_if_index == ~0)
17118 errmsg ("missing interface name or sw_if_index");
17122 /* Construct the API message */
17123 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
17124 mp->sw_if_index = ntohl (sw_if_index);
17125 mp->enable = enable;
17126 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17127 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17128 vec_free (arc_name);
17129 vec_free (feature_name);
17136 api_sw_interface_tag_add_del (vat_main_t * vam)
17138 unformat_input_t *i = vam->input;
17139 vl_api_sw_interface_tag_add_del_t *mp;
17141 u32 sw_if_index = ~0;
17145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17147 if (unformat (i, "tag %s", &tag))
17149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17151 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17153 else if (unformat (i, "del"))
17159 if (sw_if_index == ~0)
17161 errmsg ("missing interface name or sw_if_index");
17165 if (enable && (tag == 0))
17167 errmsg ("no tag specified");
17171 /* Construct the API message */
17172 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
17173 mp->sw_if_index = ntohl (sw_if_index);
17174 mp->is_add = enable;
17176 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17183 static void vl_api_l2_xconnect_details_t_handler
17184 (vl_api_l2_xconnect_details_t * mp)
17186 vat_main_t *vam = &vat_main;
17188 print (vam->ofp, "%15d%15d",
17189 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17192 static void vl_api_l2_xconnect_details_t_handler_json
17193 (vl_api_l2_xconnect_details_t * mp)
17195 vat_main_t *vam = &vat_main;
17196 vat_json_node_t *node = NULL;
17198 if (VAT_JSON_ARRAY != vam->json_tree.type)
17200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17201 vat_json_init_array (&vam->json_tree);
17203 node = vat_json_array_add (&vam->json_tree);
17205 vat_json_init_object (node);
17206 vat_json_object_add_uint (node, "rx_sw_if_index",
17207 ntohl (mp->rx_sw_if_index));
17208 vat_json_object_add_uint (node, "tx_sw_if_index",
17209 ntohl (mp->tx_sw_if_index));
17213 api_l2_xconnect_dump (vat_main_t * vam)
17215 vl_api_l2_xconnect_dump_t *mp;
17218 if (!vam->json_output)
17220 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17223 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
17227 /* Use a control ping for synchronization */
17229 vl_api_control_ping_t *mp;
17230 M (CONTROL_PING, control_ping);
17237 api_sw_interface_set_mtu (vat_main_t * vam)
17239 unformat_input_t *i = vam->input;
17240 vl_api_sw_interface_set_mtu_t *mp;
17242 u32 sw_if_index = ~0;
17245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17247 if (unformat (i, "mtu %d", &mtu))
17249 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17251 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17257 if (sw_if_index == ~0)
17259 errmsg ("missing interface name or sw_if_index");
17265 errmsg ("no mtu specified");
17269 /* Construct the API message */
17270 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17271 mp->sw_if_index = ntohl (sw_if_index);
17272 mp->mtu = ntohs ((u16) mtu);
17280 q_or_quit (vat_main_t * vam)
17282 longjmp (vam->jump_buf, 1);
17283 return 0; /* not so much */
17287 q (vat_main_t * vam)
17289 return q_or_quit (vam);
17293 quit (vat_main_t * vam)
17295 return q_or_quit (vam);
17299 comment (vat_main_t * vam)
17305 cmd_cmp (void *a1, void *a2)
17310 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17314 help (vat_main_t * vam)
17319 unformat_input_t *i = vam->input;
17322 if (unformat (i, "%s", &name))
17326 vec_add1 (name, 0);
17328 hs = hash_get_mem (vam->help_by_name, name);
17330 print (vam->ofp, "usage: %s %s", name, hs[0]);
17332 print (vam->ofp, "No such msg / command '%s'", name);
17337 print (vam->ofp, "Help is available for the following:");
17340 hash_foreach_pair (p, vam->function_by_name,
17342 vec_add1 (cmds, (u8 *)(p->key));
17346 vec_sort_with_function (cmds, cmd_cmp);
17348 for (j = 0; j < vec_len (cmds); j++)
17349 print (vam->ofp, "%s", cmds[j]);
17356 set (vat_main_t * vam)
17358 u8 *name = 0, *value = 0;
17359 unformat_input_t *i = vam->input;
17361 if (unformat (i, "%s", &name))
17363 /* The input buffer is a vector, not a string. */
17364 value = vec_dup (i->buffer);
17365 vec_delete (value, i->index, 0);
17366 /* Almost certainly has a trailing newline */
17367 if (value[vec_len (value) - 1] == '\n')
17368 value[vec_len (value) - 1] = 0;
17369 /* Make sure it's a proper string, one way or the other */
17370 vec_add1 (value, 0);
17371 (void) clib_macro_set_value (&vam->macro_main,
17372 (char *) name, (char *) value);
17375 errmsg ("usage: set <name> <value>");
17383 unset (vat_main_t * vam)
17387 if (unformat (vam->input, "%s", &name))
17388 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17389 errmsg ("unset: %s wasn't set", name);
17402 macro_sort_cmp (void *a1, void *a2)
17404 macro_sort_t *s1 = a1;
17405 macro_sort_t *s2 = a2;
17407 return strcmp ((char *) (s1->name), (char *) (s2->name));
17411 dump_macro_table (vat_main_t * vam)
17413 macro_sort_t *sort_me = 0, *sm;
17418 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17420 vec_add2 (sort_me, sm, 1);
17421 sm->name = (u8 *)(p->key);
17422 sm->value = (u8 *) (p->value[0]);
17426 vec_sort_with_function (sort_me, macro_sort_cmp);
17428 if (vec_len (sort_me))
17429 print (vam->ofp, "%-15s%s", "Name", "Value");
17431 print (vam->ofp, "The macro table is empty...");
17433 for (i = 0; i < vec_len (sort_me); i++)
17434 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17439 dump_node_table (vat_main_t * vam)
17442 vlib_node_t *node, *next_node;
17444 if (vec_len (vam->graph_nodes) == 0)
17446 print (vam->ofp, "Node table empty, issue get_node_graph...");
17450 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17452 node = vam->graph_nodes[i];
17453 print (vam->ofp, "[%d] %s", i, node->name);
17454 for (j = 0; j < vec_len (node->next_nodes); j++)
17456 if (node->next_nodes[j] != ~0)
17458 next_node = vam->graph_nodes[node->next_nodes[j]];
17459 print (vam->ofp, " [%d] %s", j, next_node->name);
17467 value_sort_cmp (void *a1, void *a2)
17469 name_sort_t *n1 = a1;
17470 name_sort_t *n2 = a2;
17472 if (n1->value < n2->value)
17474 if (n1->value > n2->value)
17481 dump_msg_api_table (vat_main_t * vam)
17483 api_main_t *am = &api_main;
17484 name_sort_t *nses = 0, *ns;
17489 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17491 vec_add2 (nses, ns, 1);
17492 ns->name = (u8 *)(hp->key);
17493 ns->value = (u32) hp->value[0];
17497 vec_sort_with_function (nses, value_sort_cmp);
17499 for (i = 0; i < vec_len (nses); i++)
17500 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17506 get_msg_id (vat_main_t * vam)
17511 if (unformat (vam->input, "%s", &name_and_crc))
17513 message_index = vl_api_get_msg_index (name_and_crc);
17514 if (message_index == ~0)
17516 print (vam->ofp, " '%s' not found", name_and_crc);
17519 print (vam->ofp, " '%s' has message index %d",
17520 name_and_crc, message_index);
17523 errmsg ("name_and_crc required...");
17528 search_node_table (vat_main_t * vam)
17530 unformat_input_t *line_input = vam->input;
17533 vlib_node_t *node, *next_node;
17536 if (vam->graph_node_index_by_name == 0)
17538 print (vam->ofp, "Node table empty, issue get_node_graph...");
17542 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17544 if (unformat (line_input, "%s", &node_to_find))
17546 vec_add1 (node_to_find, 0);
17547 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17550 print (vam->ofp, "%s not found...", node_to_find);
17553 node = vam->graph_nodes[p[0]];
17554 print (vam->ofp, "[%d] %s", p[0], node->name);
17555 for (j = 0; j < vec_len (node->next_nodes); j++)
17557 if (node->next_nodes[j] != ~0)
17559 next_node = vam->graph_nodes[node->next_nodes[j]];
17560 print (vam->ofp, " [%d] %s", j, next_node->name);
17567 clib_warning ("parse error '%U'", format_unformat_error,
17573 vec_free (node_to_find);
17582 script (vat_main_t * vam)
17584 #if (VPP_API_TEST_BUILTIN==0)
17586 char *save_current_file;
17587 unformat_input_t save_input;
17588 jmp_buf save_jump_buf;
17589 u32 save_line_number;
17591 FILE *new_fp, *save_ifp;
17593 if (unformat (vam->input, "%s", &s))
17595 new_fp = fopen ((char *) s, "r");
17598 errmsg ("Couldn't open script file %s", s);
17605 errmsg ("Missing script name");
17609 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17610 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17611 save_ifp = vam->ifp;
17612 save_line_number = vam->input_line_number;
17613 save_current_file = (char *) vam->current_file;
17615 vam->input_line_number = 0;
17617 vam->current_file = s;
17620 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17621 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17622 vam->ifp = save_ifp;
17623 vam->input_line_number = save_line_number;
17624 vam->current_file = (u8 *) save_current_file;
17629 clib_warning ("use the exec command...");
17635 echo (vat_main_t * vam)
17637 print (vam->ofp, "%v", vam->input->buffer);
17641 /* List of API message constructors, CLI names map to api_xxx */
17642 #define foreach_vpe_api_msg \
17643 _(create_loopback,"[mac <mac-addr>]") \
17644 _(sw_interface_dump,"") \
17645 _(sw_interface_set_flags, \
17646 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17647 _(sw_interface_add_del_address, \
17648 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17649 _(sw_interface_set_table, \
17650 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17651 _(sw_interface_set_mpls_enable, \
17652 "<intfc> | sw_if_index [disable | dis]") \
17653 _(sw_interface_set_vpath, \
17654 "<intfc> | sw_if_index <id> enable | disable") \
17655 _(sw_interface_set_vxlan_bypass, \
17656 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17657 _(sw_interface_set_l2_xconnect, \
17658 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17659 "enable | disable") \
17660 _(sw_interface_set_l2_bridge, \
17661 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17662 "[shg <split-horizon-group>] [bvi]\n" \
17663 "enable | disable") \
17664 _(bridge_domain_add_del, \
17665 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17666 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17668 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17670 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17672 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17674 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17676 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17678 "<vpp-if-name> | sw_if_index <id>") \
17679 _(sw_interface_tap_dump, "") \
17680 _(ip_add_del_route, \
17681 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17682 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17683 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17684 "[multipath] [count <n>]") \
17685 _(ip_mroute_add_del, \
17686 "<src> <grp>/<mask> [table-id <n>]\n" \
17687 "[<intfc> | sw_if_index <id>] [local] [del]") \
17688 _(mpls_route_add_del, \
17689 "<label> <eos> via <addr> [table-id <n>]\n" \
17690 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17691 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17692 "[multipath] [count <n>]") \
17693 _(mpls_ip_bind_unbind, \
17694 "<label> <addr/len>") \
17695 _(mpls_tunnel_add_del, \
17696 " via <addr> [table-id <n>]\n" \
17697 "sw_if_index <id>] [l2] [del]") \
17698 _(proxy_arp_add_del, \
17699 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17700 _(proxy_arp_intfc_enable_disable, \
17701 "<intfc> | sw_if_index <id> enable | disable") \
17702 _(sw_interface_set_unnumbered, \
17703 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17704 _(ip_neighbor_add_del, \
17705 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17706 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17707 _(reset_vrf, "vrf <id> [ipv6]") \
17708 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17709 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17710 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17711 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17712 "[outer_vlan_id_any][inner_vlan_id_any]") \
17713 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17714 _(reset_fib, "vrf <n> [ipv6]") \
17715 _(dhcp_proxy_config, \
17716 "svr <v46-address> src <v46-address>\n" \
17717 "insert-cid <n> [del]") \
17718 _(dhcp_proxy_config_2, \
17719 "svr <v46-address> src <v46-address>\n" \
17720 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17721 _(dhcp_proxy_set_vss, \
17722 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17723 _(dhcp_client_config, \
17724 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17725 _(set_ip_flow_hash, \
17726 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17727 _(sw_interface_ip6_enable_disable, \
17728 "<intfc> | sw_if_index <id> enable | disable") \
17729 _(sw_interface_ip6_set_link_local_address, \
17730 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17731 _(sw_interface_ip6nd_ra_prefix, \
17732 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17733 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17734 "[nolink] [isno]") \
17735 _(sw_interface_ip6nd_ra_config, \
17736 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17737 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17738 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17739 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17740 _(l2_patch_add_del, \
17741 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17742 "enable | disable") \
17743 _(sr_tunnel_add_del, \
17744 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17745 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17746 "[policy <policy_name>]") \
17747 _(sr_policy_add_del, \
17748 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17749 _(sr_multicast_map_add_del, \
17750 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17751 _(classify_add_del_table, \
17752 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17753 " [del] [del-chain] mask <mask-value>\n" \
17754 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17755 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17756 _(classify_add_del_session, \
17757 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17758 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17759 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17760 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17761 _(classify_set_interface_ip_table, \
17762 "<intfc> | sw_if_index <nn> table <nn>") \
17763 _(classify_set_interface_l2_tables, \
17764 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17765 " [other-table <nn>]") \
17766 _(get_node_index, "node <node-name") \
17767 _(add_node_next, "node <node-name> next <next-node-name>") \
17768 _(l2tpv3_create_tunnel, \
17769 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17770 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17771 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17772 _(l2tpv3_set_tunnel_cookies, \
17773 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17774 "[new_remote_cookie <nn>]\n") \
17775 _(l2tpv3_interface_enable_disable, \
17776 "<intfc> | sw_if_index <nn> enable | disable") \
17777 _(l2tpv3_set_lookup_key, \
17778 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17779 _(sw_if_l2tpv3_tunnel_dump, "") \
17780 _(vxlan_add_del_tunnel, \
17781 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17782 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17783 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17784 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17785 _(gre_add_del_tunnel, \
17786 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17787 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17788 _(l2_fib_clear_table, "") \
17789 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17790 _(l2_interface_vlan_tag_rewrite, \
17791 "<intfc> | sw_if_index <nn> \n" \
17792 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17793 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17794 _(create_vhost_user_if, \
17795 "socket <filename> [server] [renumber <dev_instance>] " \
17796 "[mac <mac_address>]") \
17797 _(modify_vhost_user_if, \
17798 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17799 "[server] [renumber <dev_instance>]") \
17800 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17801 _(sw_interface_vhost_user_dump, "") \
17802 _(show_version, "") \
17803 _(vxlan_gpe_add_del_tunnel, \
17804 "local <addr> remote <addr> vni <nn>\n" \
17805 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17806 "[next-ethernet] [next-nsh]\n") \
17807 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17808 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17809 _(interface_name_renumber, \
17810 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17811 _(input_acl_set_interface, \
17812 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17813 " [l2-table <nn>] [del]") \
17814 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17815 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17816 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17817 _(ip_dump, "ipv4 | ipv6") \
17818 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17819 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17821 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17822 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17823 " integ_alg <alg> integ_key <hex>") \
17824 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17825 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17826 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17827 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17828 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17829 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17830 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17831 "(auth_data 0x<data> | auth_data <data>)") \
17832 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17833 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17834 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17835 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17836 "(local|remote)") \
17837 _(ikev2_set_local_key, "file <absolute_file_path>") \
17838 _(delete_loopback,"sw_if_index <nn>") \
17839 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17840 _(map_add_domain, \
17841 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17842 "ip6-src <ip6addr> " \
17843 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17844 _(map_del_domain, "index <n>") \
17845 _(map_add_del_rule, \
17846 "index <n> psid <n> dst <ip6addr> [del]") \
17847 _(map_domain_dump, "") \
17848 _(map_rule_dump, "index <map-domain>") \
17849 _(want_interface_events, "enable|disable") \
17850 _(want_stats,"enable|disable") \
17851 _(get_first_msg_id, "client <name>") \
17852 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17853 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17854 "fib-id <nn> [ip4][ip6][default]") \
17855 _(get_node_graph, " ") \
17856 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17857 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17858 _(ioam_disable, "") \
17859 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17860 " sw_if_index <sw_if_index> p <priority> " \
17861 "w <weight>] [del]") \
17862 _(lisp_add_del_locator, "locator-set <locator_name> " \
17863 "iface <intf> | sw_if_index <sw_if_index> " \
17864 "p <priority> w <weight> [del]") \
17865 _(lisp_add_del_local_eid,"vni <vni> eid " \
17866 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17867 "locator-set <locator_name> [del]" \
17868 "[key-id sha1|sha256 secret-key <secret-key>]") \
17869 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
17870 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
17871 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17872 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17873 _(lisp_gpe_enable_disable, "enable|disable") \
17874 _(lisp_enable_disable, "enable|disable") \
17875 _(lisp_map_register_enable_disable, "enable|disable") \
17876 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17877 _(lisp_gpe_add_del_iface, "up|down") \
17878 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17880 "rloc <locator> p <prio> " \
17881 "w <weight> [rloc <loc> ... ] " \
17882 "action <action> [del-all]") \
17883 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17885 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17886 _(lisp_map_request_mode, "src-dst|dst-only") \
17887 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17888 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17889 _(lisp_locator_set_dump, "[local | remote]") \
17890 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17891 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17892 "[local] | [remote]") \
17893 _(lisp_eid_table_vni_dump, "") \
17894 _(lisp_eid_table_map_dump, "l2|l3") \
17895 _(lisp_map_resolver_dump, "") \
17896 _(lisp_map_server_dump, "") \
17897 _(lisp_adjacencies_get, "vni <vni>") \
17898 _(show_lisp_rloc_probe_state, "") \
17899 _(show_lisp_map_register_state, "") \
17900 _(show_lisp_status, "") \
17901 _(lisp_get_map_request_itr_rlocs, "") \
17902 _(show_lisp_pitr, "") \
17903 _(show_lisp_map_request_mode, "") \
17904 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17905 _(af_packet_delete, "name <host interface name>") \
17906 _(policer_add_del, "name <policer name> <params> [del]") \
17907 _(policer_dump, "[name <policer name>]") \
17908 _(policer_classify_set_interface, \
17909 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17910 " [l2-table <nn>] [del]") \
17911 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17912 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17913 "[master|slave]") \
17914 _(netmap_delete, "name <interface name>") \
17915 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17916 _(mpls_fib_dump, "") \
17917 _(classify_table_ids, "") \
17918 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17919 _(classify_table_info, "table_id <nn>") \
17920 _(classify_session_dump, "table_id <nn>") \
17921 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17922 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17923 "[template_interval <nn>] [udp_checksum]") \
17924 _(ipfix_exporter_dump, "") \
17925 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17926 _(ipfix_classify_stream_dump, "") \
17927 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17928 _(ipfix_classify_table_dump, "") \
17929 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17930 _(sw_interface_span_dump, "") \
17931 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17932 _(pg_create_interface, "if_id <nn>") \
17933 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17934 _(pg_enable_disable, "[stream <id>] disable") \
17935 _(ip_source_and_port_range_check_add_del, \
17936 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17937 _(ip_source_and_port_range_check_interface_add_del, \
17938 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17939 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17940 _(ipsec_gre_add_del_tunnel, \
17941 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17942 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17943 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17944 _(l2_interface_pbb_tag_rewrite, \
17945 "<intfc> | sw_if_index <nn> \n" \
17946 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17947 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17948 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17949 _(flow_classify_set_interface, \
17950 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17951 _(flow_classify_dump, "type [ip4|ip6]") \
17952 _(ip_fib_dump, "") \
17953 _(ip6_fib_dump, "") \
17954 _(feature_enable_disable, "arc_name <arc_name> " \
17955 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17956 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17958 _(l2_xconnect_dump, "") \
17959 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17960 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17961 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17964 #define foreach_vpe_dpdk_api_msg \
17965 _(sw_interface_set_dpdk_hqos_pipe, \
17966 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17967 "profile <profile-id>\n") \
17968 _(sw_interface_set_dpdk_hqos_subport, \
17969 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17970 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17971 _(sw_interface_set_dpdk_hqos_tctbl, \
17972 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
17975 /* List of command functions, CLI names map directly to functions */
17976 #define foreach_cli_function \
17977 _(comment, "usage: comment <ignore-rest-of-line>") \
17978 _(dump_interface_table, "usage: dump_interface_table") \
17979 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17980 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17981 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17982 _(dump_stats_table, "usage: dump_stats_table") \
17983 _(dump_macro_table, "usage: dump_macro_table ") \
17984 _(dump_node_table, "usage: dump_node_table") \
17985 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17986 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17987 _(echo, "usage: echo <message>") \
17988 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17989 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17990 _(help, "usage: help") \
17991 _(q, "usage: quit") \
17992 _(quit, "usage: quit") \
17993 _(search_node_table, "usage: search_node_table <name>...") \
17994 _(set, "usage: set <variable-name> <value>") \
17995 _(script, "usage: script <file-name>") \
17996 _(unset, "usage: unset <variable-name>")
17999 static void vl_api_##n##_t_handler_uni \
18000 (vl_api_##n##_t * mp) \
18002 vat_main_t * vam = &vat_main; \
18003 if (vam->json_output) { \
18004 vl_api_##n##_t_handler_json(mp); \
18006 vl_api_##n##_t_handler(mp); \
18009 foreach_vpe_api_reply_msg;
18014 static void vl_api_##n##_t_handler_uni \
18015 (vl_api_##n##_t * mp) \
18017 vat_main_t * vam = &vat_main; \
18018 if (vam->json_output) { \
18019 vl_api_##n##_t_handler_json(mp); \
18021 vl_api_##n##_t_handler(mp); \
18024 foreach_vpe_dpdk_api_reply_msg;
18029 vat_api_hookup (vat_main_t * vam)
18032 vl_msg_api_set_handlers(VL_API_##N, #n, \
18033 vl_api_##n##_t_handler_uni, \
18035 vl_api_##n##_t_endian, \
18036 vl_api_##n##_t_print, \
18037 sizeof(vl_api_##n##_t), 1);
18038 foreach_vpe_api_reply_msg;
18043 vl_msg_api_set_handlers(VL_API_##N, #n, \
18044 vl_api_##n##_t_handler_uni, \
18046 vl_api_##n##_t_endian, \
18047 vl_api_##n##_t_print, \
18048 sizeof(vl_api_##n##_t), 1);
18049 foreach_vpe_dpdk_api_reply_msg;
18053 #if (VPP_API_TEST_BUILTIN==0)
18054 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18057 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18059 vam->function_by_name = hash_create_string (0, sizeof (uword));
18061 vam->help_by_name = hash_create_string (0, sizeof (uword));
18063 /* API messages we can send */
18064 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18065 foreach_vpe_api_msg;
18068 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18069 foreach_vpe_dpdk_api_msg;
18074 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18075 foreach_vpe_api_msg;
18078 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18079 foreach_vpe_dpdk_api_msg;
18083 /* CLI functions */
18084 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18085 foreach_cli_function;
18089 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18090 foreach_cli_function;
18095 * fd.io coding-style-patch-verification: ON
18098 * eval: (c-set-style "gnu")