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))
12202 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12203 integ_alg >= IPSEC_INTEG_N_ALG)
12205 clib_warning ("unsupported integ-alg: '%U'",
12206 format_ipsec_integ_alg, integ_alg);
12210 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12214 clib_warning ("parse error '%U'", format_unformat_error, i);
12220 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
12222 mp->sad_id = ntohl (sad_id);
12223 mp->is_add = is_add;
12224 mp->protocol = protocol;
12225 mp->spi = ntohl (spi);
12226 mp->is_tunnel = is_tunnel;
12227 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12228 mp->crypto_algorithm = crypto_alg;
12229 mp->integrity_algorithm = integ_alg;
12230 mp->crypto_key_length = vec_len (ck);
12231 mp->integrity_key_length = vec_len (ik);
12233 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12234 mp->crypto_key_length = sizeof (mp->crypto_key);
12236 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12237 mp->integrity_key_length = sizeof (mp->integrity_key);
12240 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12242 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12246 if (is_tunnel_ipv6)
12248 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12249 sizeof (ip6_address_t));
12250 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12251 sizeof (ip6_address_t));
12255 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12256 sizeof (ip4_address_t));
12257 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12258 sizeof (ip4_address_t));
12269 api_ipsec_sa_set_key (vat_main_t * vam)
12271 unformat_input_t *i = vam->input;
12272 vl_api_ipsec_sa_set_key_t *mp;
12275 u8 *ck = 0, *ik = 0;
12277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12279 if (unformat (i, "sa_id %d", &sa_id))
12281 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12283 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12287 clib_warning ("parse error '%U'", format_unformat_error, i);
12292 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12294 mp->sa_id = ntohl (sa_id);
12295 mp->crypto_key_length = vec_len (ck);
12296 mp->integrity_key_length = vec_len (ik);
12298 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12299 mp->crypto_key_length = sizeof (mp->crypto_key);
12301 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12302 mp->integrity_key_length = sizeof (mp->integrity_key);
12305 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12307 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12316 api_ikev2_profile_add_del (vat_main_t * vam)
12318 unformat_input_t *i = vam->input;
12319 vl_api_ikev2_profile_add_del_t *mp;
12324 const char *valid_chars = "a-zA-Z0-9_";
12326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12328 if (unformat (i, "del"))
12330 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12331 vec_add1 (name, 0);
12334 errmsg ("parse error '%U'", format_unformat_error, i);
12339 if (!vec_len (name))
12341 errmsg ("profile name must be specified");
12345 if (vec_len (name) > 64)
12347 errmsg ("profile name too long");
12351 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12353 clib_memcpy (mp->name, name, vec_len (name));
12354 mp->is_add = is_add;
12364 api_ikev2_profile_set_auth (vat_main_t * vam)
12366 unformat_input_t *i = vam->input;
12367 vl_api_ikev2_profile_set_auth_t *mp;
12371 u32 auth_method = 0;
12374 const char *valid_chars = "a-zA-Z0-9_";
12376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12378 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12379 vec_add1 (name, 0);
12380 else if (unformat (i, "auth_method %U",
12381 unformat_ikev2_auth_method, &auth_method))
12383 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12385 else if (unformat (i, "auth_data %v", &data))
12389 errmsg ("parse error '%U'", format_unformat_error, i);
12394 if (!vec_len (name))
12396 errmsg ("profile name must be specified");
12400 if (vec_len (name) > 64)
12402 errmsg ("profile name too long");
12406 if (!vec_len (data))
12408 errmsg ("auth_data must be specified");
12414 errmsg ("auth_method must be specified");
12418 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12420 mp->is_hex = is_hex;
12421 mp->auth_method = (u8) auth_method;
12422 mp->data_len = vec_len (data);
12423 clib_memcpy (mp->name, name, vec_len (name));
12424 clib_memcpy (mp->data, data, vec_len (data));
12435 api_ikev2_profile_set_id (vat_main_t * vam)
12437 unformat_input_t *i = vam->input;
12438 vl_api_ikev2_profile_set_id_t *mp;
12446 const char *valid_chars = "a-zA-Z0-9_";
12448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12450 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12451 vec_add1 (name, 0);
12452 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12454 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12456 data = vec_new (u8, 4);
12457 clib_memcpy (data, ip4.as_u8, 4);
12459 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12461 else if (unformat (i, "id_data %v", &data))
12463 else if (unformat (i, "local"))
12465 else if (unformat (i, "remote"))
12469 errmsg ("parse error '%U'", format_unformat_error, i);
12474 if (!vec_len (name))
12476 errmsg ("profile name must be specified");
12480 if (vec_len (name) > 64)
12482 errmsg ("profile name too long");
12486 if (!vec_len (data))
12488 errmsg ("id_data must be specified");
12494 errmsg ("id_type must be specified");
12498 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12500 mp->is_local = is_local;
12501 mp->id_type = (u8) id_type;
12502 mp->data_len = vec_len (data);
12503 clib_memcpy (mp->name, name, vec_len (name));
12504 clib_memcpy (mp->data, data, vec_len (data));
12515 api_ikev2_profile_set_ts (vat_main_t * vam)
12517 unformat_input_t *i = vam->input;
12518 vl_api_ikev2_profile_set_ts_t *mp;
12522 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12523 ip4_address_t start_addr, end_addr;
12525 const char *valid_chars = "a-zA-Z0-9_";
12527 start_addr.as_u32 = 0;
12528 end_addr.as_u32 = (u32) ~ 0;
12530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12532 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12533 vec_add1 (name, 0);
12534 else if (unformat (i, "protocol %d", &proto))
12536 else if (unformat (i, "start_port %d", &start_port))
12538 else if (unformat (i, "end_port %d", &end_port))
12541 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12543 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12545 else if (unformat (i, "local"))
12547 else if (unformat (i, "remote"))
12551 errmsg ("parse error '%U'", format_unformat_error, i);
12556 if (!vec_len (name))
12558 errmsg ("profile name must be specified");
12562 if (vec_len (name) > 64)
12564 errmsg ("profile name too long");
12568 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12570 mp->is_local = is_local;
12571 mp->proto = (u8) proto;
12572 mp->start_port = (u16) start_port;
12573 mp->end_port = (u16) end_port;
12574 mp->start_addr = start_addr.as_u32;
12575 mp->end_addr = end_addr.as_u32;
12576 clib_memcpy (mp->name, name, vec_len (name));
12586 api_ikev2_set_local_key (vat_main_t * vam)
12588 unformat_input_t *i = vam->input;
12589 vl_api_ikev2_set_local_key_t *mp;
12593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12595 if (unformat (i, "file %v", &file))
12596 vec_add1 (file, 0);
12599 errmsg ("parse error '%U'", format_unformat_error, i);
12604 if (!vec_len (file))
12606 errmsg ("RSA key file must be specified");
12610 if (vec_len (file) > 256)
12612 errmsg ("file name too long");
12616 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12618 clib_memcpy (mp->key_file, file, vec_len (file));
12631 api_map_add_domain (vat_main_t * vam)
12633 unformat_input_t *i = vam->input;
12634 vl_api_map_add_domain_t *mp;
12637 ip4_address_t ip4_prefix;
12638 ip6_address_t ip6_prefix;
12639 ip6_address_t ip6_src;
12640 u32 num_m_args = 0;
12641 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12642 0, psid_length = 0;
12643 u8 is_translation = 0;
12645 u32 ip6_src_len = 128;
12647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12649 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12650 &ip4_prefix, &ip4_prefix_len))
12652 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12653 &ip6_prefix, &ip6_prefix_len))
12657 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12660 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12662 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12664 else if (unformat (i, "psid-offset %d", &psid_offset))
12666 else if (unformat (i, "psid-len %d", &psid_length))
12668 else if (unformat (i, "mtu %d", &mtu))
12670 else if (unformat (i, "map-t"))
12671 is_translation = 1;
12674 clib_warning ("parse error '%U'", format_unformat_error, i);
12679 if (num_m_args < 3)
12681 errmsg ("mandatory argument(s) missing");
12685 /* Construct the API message */
12686 M (MAP_ADD_DOMAIN, map_add_domain);
12688 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12689 mp->ip4_prefix_len = ip4_prefix_len;
12691 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12692 mp->ip6_prefix_len = ip6_prefix_len;
12694 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12695 mp->ip6_src_prefix_len = ip6_src_len;
12697 mp->ea_bits_len = ea_bits_len;
12698 mp->psid_offset = psid_offset;
12699 mp->psid_length = psid_length;
12700 mp->is_translation = is_translation;
12701 mp->mtu = htons (mtu);
12706 /* Wait for a reply, return good/bad news */
12711 api_map_del_domain (vat_main_t * vam)
12713 unformat_input_t *i = vam->input;
12714 vl_api_map_del_domain_t *mp;
12717 u32 num_m_args = 0;
12720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12722 if (unformat (i, "index %d", &index))
12726 clib_warning ("parse error '%U'", format_unformat_error, i);
12731 if (num_m_args != 1)
12733 errmsg ("mandatory argument(s) missing");
12737 /* Construct the API message */
12738 M (MAP_DEL_DOMAIN, map_del_domain);
12740 mp->index = ntohl (index);
12745 /* Wait for a reply, return good/bad news */
12750 api_map_add_del_rule (vat_main_t * vam)
12752 unformat_input_t *i = vam->input;
12753 vl_api_map_add_del_rule_t *mp;
12756 ip6_address_t ip6_dst;
12757 u32 num_m_args = 0, index, psid = 0;
12759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12761 if (unformat (i, "index %d", &index))
12763 else if (unformat (i, "psid %d", &psid))
12765 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12767 else if (unformat (i, "del"))
12773 clib_warning ("parse error '%U'", format_unformat_error, i);
12778 /* Construct the API message */
12779 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12781 mp->index = ntohl (index);
12782 mp->is_add = is_add;
12783 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12784 mp->psid = ntohs (psid);
12789 /* Wait for a reply, return good/bad news */
12794 api_map_domain_dump (vat_main_t * vam)
12796 vl_api_map_domain_dump_t *mp;
12799 /* Construct the API message */
12800 M (MAP_DOMAIN_DUMP, map_domain_dump);
12805 /* Use a control ping for synchronization */
12807 vl_api_control_ping_t *mp;
12808 M (CONTROL_PING, control_ping);
12815 api_map_rule_dump (vat_main_t * vam)
12817 unformat_input_t *i = vam->input;
12818 vl_api_map_rule_dump_t *mp;
12820 u32 domain_index = ~0;
12822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12824 if (unformat (i, "index %u", &domain_index))
12830 if (domain_index == ~0)
12832 clib_warning ("parse error: domain index expected");
12836 /* Construct the API message */
12837 M (MAP_RULE_DUMP, map_rule_dump);
12839 mp->domain_index = htonl (domain_index);
12844 /* Use a control ping for synchronization */
12846 vl_api_control_ping_t *mp;
12847 M (CONTROL_PING, control_ping);
12853 static void vl_api_map_add_domain_reply_t_handler
12854 (vl_api_map_add_domain_reply_t * mp)
12856 vat_main_t *vam = &vat_main;
12857 i32 retval = ntohl (mp->retval);
12859 if (vam->async_mode)
12861 vam->async_errors += (retval < 0);
12865 vam->retval = retval;
12866 vam->result_ready = 1;
12870 static void vl_api_map_add_domain_reply_t_handler_json
12871 (vl_api_map_add_domain_reply_t * mp)
12873 vat_main_t *vam = &vat_main;
12874 vat_json_node_t node;
12876 vat_json_init_object (&node);
12877 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12878 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12880 vat_json_print (vam->ofp, &node);
12881 vat_json_free (&node);
12883 vam->retval = ntohl (mp->retval);
12884 vam->result_ready = 1;
12888 api_get_first_msg_id (vat_main_t * vam)
12890 vl_api_get_first_msg_id_t *mp;
12892 unformat_input_t *i = vam->input;
12896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12898 if (unformat (i, "client %s", &name))
12906 errmsg ("missing client name");
12909 vec_add1 (name, 0);
12911 if (vec_len (name) > 63)
12913 errmsg ("client name too long");
12917 M (GET_FIRST_MSG_ID, get_first_msg_id);
12918 clib_memcpy (mp->name, name, vec_len (name));
12926 api_cop_interface_enable_disable (vat_main_t * vam)
12928 unformat_input_t *line_input = vam->input;
12929 vl_api_cop_interface_enable_disable_t *mp;
12931 u32 sw_if_index = ~0;
12932 u8 enable_disable = 1;
12934 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12936 if (unformat (line_input, "disable"))
12937 enable_disable = 0;
12938 if (unformat (line_input, "enable"))
12939 enable_disable = 1;
12940 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12941 vam, &sw_if_index))
12943 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12949 if (sw_if_index == ~0)
12951 errmsg ("missing interface name or sw_if_index");
12955 /* Construct the API message */
12956 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12957 mp->sw_if_index = ntohl (sw_if_index);
12958 mp->enable_disable = enable_disable;
12962 /* Wait for the reply */
12967 api_cop_whitelist_enable_disable (vat_main_t * vam)
12969 unformat_input_t *line_input = vam->input;
12970 vl_api_cop_whitelist_enable_disable_t *mp;
12972 u32 sw_if_index = ~0;
12973 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12976 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12978 if (unformat (line_input, "ip4"))
12980 else if (unformat (line_input, "ip6"))
12982 else if (unformat (line_input, "default"))
12984 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12985 vam, &sw_if_index))
12987 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12989 else if (unformat (line_input, "fib-id %d", &fib_id))
12995 if (sw_if_index == ~0)
12997 errmsg ("missing interface name or sw_if_index");
13001 /* Construct the API message */
13002 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
13003 mp->sw_if_index = ntohl (sw_if_index);
13004 mp->fib_id = ntohl (fib_id);
13007 mp->default_cop = default_cop;
13011 /* Wait for the reply */
13016 api_get_node_graph (vat_main_t * vam)
13018 vl_api_get_node_graph_t *mp;
13021 M (GET_NODE_GRAPH, get_node_graph);
13025 /* Wait for the reply */
13030 /** Used for parsing LISP eids */
13031 typedef CLIB_PACKED(struct{
13032 u8 addr[16]; /**< eid address */
13033 u32 len; /**< prefix length if IP */
13034 u8 type; /**< type of eid */
13039 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13041 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13043 memset (a, 0, sizeof (a[0]));
13045 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13047 a->type = 0; /* ipv4 type */
13049 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13051 a->type = 1; /* ipv6 type */
13053 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13055 a->type = 2; /* mac type */
13062 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13071 lisp_eid_size_vat (u8 type)
13086 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13088 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13092 /** Used for transferring locators via VPP API */
13093 typedef CLIB_PACKED(struct
13095 u32 sw_if_index; /**< locator sw_if_index */
13096 u8 priority; /**< locator priority */
13097 u8 weight; /**< locator weight */
13102 api_lisp_add_del_locator_set (vat_main_t * vam)
13104 unformat_input_t *input = vam->input;
13105 vl_api_lisp_add_del_locator_set_t *mp;
13108 u8 *locator_set_name = NULL;
13109 u8 locator_set_name_set = 0;
13110 ls_locator_t locator, *locators = 0;
13111 u32 sw_if_index, priority, weight;
13114 /* Parse args required to build the message */
13115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13117 if (unformat (input, "del"))
13121 else if (unformat (input, "locator-set %s", &locator_set_name))
13123 locator_set_name_set = 1;
13125 else if (unformat (input, "sw_if_index %u p %u w %u",
13126 &sw_if_index, &priority, &weight))
13128 locator.sw_if_index = htonl (sw_if_index);
13129 locator.priority = priority;
13130 locator.weight = weight;
13131 vec_add1 (locators, locator);
13135 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13136 &sw_if_index, &priority, &weight))
13138 locator.sw_if_index = htonl (sw_if_index);
13139 locator.priority = priority;
13140 locator.weight = weight;
13141 vec_add1 (locators, locator);
13147 if (locator_set_name_set == 0)
13149 errmsg ("missing locator-set name");
13150 vec_free (locators);
13154 if (vec_len (locator_set_name) > 64)
13156 errmsg ("locator-set name too long");
13157 vec_free (locator_set_name);
13158 vec_free (locators);
13161 vec_add1 (locator_set_name, 0);
13163 data_len = sizeof (ls_locator_t) * vec_len (locators);
13165 /* Construct the API message */
13166 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
13168 mp->is_add = is_add;
13169 clib_memcpy (mp->locator_set_name, locator_set_name,
13170 vec_len (locator_set_name));
13171 vec_free (locator_set_name);
13173 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13175 clib_memcpy (mp->locators, locators, data_len);
13176 vec_free (locators);
13181 /* Wait for a reply... */
13189 api_lisp_add_del_locator (vat_main_t * vam)
13191 unformat_input_t *input = vam->input;
13192 vl_api_lisp_add_del_locator_t *mp;
13194 u32 tmp_if_index = ~0;
13195 u32 sw_if_index = ~0;
13196 u8 sw_if_index_set = 0;
13197 u8 sw_if_index_if_name_set = 0;
13199 u8 priority_set = 0;
13203 u8 *locator_set_name = NULL;
13204 u8 locator_set_name_set = 0;
13206 /* Parse args required to build the message */
13207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13209 if (unformat (input, "del"))
13213 else if (unformat (input, "locator-set %s", &locator_set_name))
13215 locator_set_name_set = 1;
13217 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13220 sw_if_index_if_name_set = 1;
13221 sw_if_index = tmp_if_index;
13223 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13225 sw_if_index_set = 1;
13226 sw_if_index = tmp_if_index;
13228 else if (unformat (input, "p %d", &priority))
13232 else if (unformat (input, "w %d", &weight))
13240 if (locator_set_name_set == 0)
13242 errmsg ("missing locator-set name");
13246 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13248 errmsg ("missing sw_if_index");
13249 vec_free (locator_set_name);
13253 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13255 errmsg ("cannot use both params interface name and sw_if_index");
13256 vec_free (locator_set_name);
13260 if (priority_set == 0)
13262 errmsg ("missing locator-set priority");
13263 vec_free (locator_set_name);
13267 if (weight_set == 0)
13269 errmsg ("missing locator-set weight");
13270 vec_free (locator_set_name);
13274 if (vec_len (locator_set_name) > 64)
13276 errmsg ("locator-set name too long");
13277 vec_free (locator_set_name);
13280 vec_add1 (locator_set_name, 0);
13282 /* Construct the API message */
13283 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13285 mp->is_add = is_add;
13286 mp->sw_if_index = ntohl (sw_if_index);
13287 mp->priority = priority;
13288 mp->weight = weight;
13289 clib_memcpy (mp->locator_set_name, locator_set_name,
13290 vec_len (locator_set_name));
13291 vec_free (locator_set_name);
13296 /* Wait for a reply... */
13304 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13306 u32 *key_id = va_arg (*args, u32 *);
13309 if (unformat (input, "%s", &s))
13311 if (!strcmp ((char *) s, "sha1"))
13312 key_id[0] = HMAC_SHA_1_96;
13313 else if (!strcmp ((char *) s, "sha256"))
13314 key_id[0] = HMAC_SHA_256_128;
13317 clib_warning ("invalid key_id: '%s'", s);
13318 key_id[0] = HMAC_NO_KEY;
13329 api_lisp_add_del_local_eid (vat_main_t * vam)
13331 unformat_input_t *input = vam->input;
13332 vl_api_lisp_add_del_local_eid_t *mp;
13336 lisp_eid_vat_t _eid, *eid = &_eid;
13337 u8 *locator_set_name = 0;
13338 u8 locator_set_name_set = 0;
13343 /* Parse args required to build the message */
13344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13346 if (unformat (input, "del"))
13350 else if (unformat (input, "vni %d", &vni))
13354 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13358 else if (unformat (input, "locator-set %s", &locator_set_name))
13360 locator_set_name_set = 1;
13362 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13364 else if (unformat (input, "secret-key %_%v%_", &key))
13370 if (locator_set_name_set == 0)
13372 errmsg ("missing locator-set name");
13378 errmsg ("EID address not set!");
13379 vec_free (locator_set_name);
13383 if (key && (0 == key_id))
13385 errmsg ("invalid key_id!");
13389 if (vec_len (key) > 64)
13391 errmsg ("key too long");
13396 if (vec_len (locator_set_name) > 64)
13398 errmsg ("locator-set name too long");
13399 vec_free (locator_set_name);
13402 vec_add1 (locator_set_name, 0);
13404 /* Construct the API message */
13405 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13407 mp->is_add = is_add;
13408 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13409 mp->eid_type = eid->type;
13410 mp->prefix_len = eid->len;
13411 mp->vni = clib_host_to_net_u32 (vni);
13412 mp->key_id = clib_host_to_net_u16 (key_id);
13413 clib_memcpy (mp->locator_set_name, locator_set_name,
13414 vec_len (locator_set_name));
13415 clib_memcpy (mp->key, key, vec_len (key));
13417 vec_free (locator_set_name);
13423 /* Wait for a reply... */
13431 /** Used for transferring locators via VPP API */
13432 typedef CLIB_PACKED(struct
13434 u8 is_ip4; /**< is locator an IPv4 address? */
13435 u8 priority; /**< locator priority */
13436 u8 weight; /**< locator weight */
13437 u8 addr[16]; /**< IPv4/IPv6 address */
13442 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13444 u32 dp_table = 0, vni = 0;;
13445 unformat_input_t *input = vam->input;
13446 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13449 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13450 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13451 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13452 u32 action = ~0, w;
13453 ip4_address_t rmt_rloc4, lcl_rloc4;
13454 ip6_address_t rmt_rloc6, lcl_rloc6;
13455 vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc =
13458 memset (&rloc, 0, sizeof (rloc));
13460 /* Parse args required to build the message */
13461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13463 if (unformat (input, "del"))
13465 else if (unformat (input, "add"))
13467 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13471 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13475 else if (unformat (input, "vrf %d", &dp_table))
13477 else if (unformat (input, "bd %d", &dp_table))
13479 else if (unformat (input, "vni %d", &vni))
13481 else if (unformat (input, "w %d", &w))
13485 errmsg ("No RLOC configured for setting priority/weight!");
13488 curr_rloc->weight = w;
13490 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13491 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13495 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13497 vec_add1 (lcl_locs, rloc);
13499 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13500 vec_add1 (rmt_locs, rloc);
13501 /* weight saved in rmt loc */
13502 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13504 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13505 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13508 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13510 vec_add1 (lcl_locs, rloc);
13512 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13513 vec_add1 (rmt_locs, rloc);
13514 /* weight saved in rmt loc */
13515 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13517 else if (unformat (input, "action %d", &action))
13523 clib_warning ("parse error '%U'", format_unformat_error, input);
13530 errmsg ("remote eid addresses not set");
13534 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13536 errmsg ("eid types don't match");
13540 if (0 == rmt_locs && (u32) ~ 0 == action)
13542 errmsg ("action not set for negative mapping");
13546 /* Construct the API message */
13547 M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry,
13548 sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2);
13550 mp->is_add = is_add;
13551 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13552 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13553 mp->eid_type = rmt_eid->type;
13554 mp->dp_table = clib_host_to_net_u32 (dp_table);
13555 mp->vni = clib_host_to_net_u32 (vni);
13556 mp->rmt_len = rmt_eid->len;
13557 mp->lcl_len = lcl_eid->len;
13558 mp->action = action;
13560 if (0 != rmt_locs && 0 != lcl_locs)
13562 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13563 clib_memcpy (mp->locs, lcl_locs,
13564 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs)));
13566 u32 offset = sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs);
13567 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13568 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs)));
13570 vec_free (lcl_locs);
13571 vec_free (rmt_locs);
13576 /* Wait for a reply... */
13584 api_lisp_add_del_map_server (vat_main_t * vam)
13586 unformat_input_t *input = vam->input;
13587 vl_api_lisp_add_del_map_server_t *mp;
13592 ip4_address_t ipv4;
13593 ip6_address_t ipv6;
13595 /* Parse args required to build the message */
13596 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13598 if (unformat (input, "del"))
13602 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13606 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13614 if (ipv4_set && ipv6_set)
13616 errmsg ("both eid v4 and v6 addresses set");
13620 if (!ipv4_set && !ipv6_set)
13622 errmsg ("eid addresses not set");
13626 /* Construct the API message */
13627 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13629 mp->is_add = is_add;
13633 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13638 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13644 /* Wait for a reply... */
13652 api_lisp_add_del_map_resolver (vat_main_t * vam)
13654 unformat_input_t *input = vam->input;
13655 vl_api_lisp_add_del_map_resolver_t *mp;
13660 ip4_address_t ipv4;
13661 ip6_address_t ipv6;
13663 /* Parse args required to build the message */
13664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13666 if (unformat (input, "del"))
13670 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13674 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13682 if (ipv4_set && ipv6_set)
13684 errmsg ("both eid v4 and v6 addresses set");
13688 if (!ipv4_set && !ipv6_set)
13690 errmsg ("eid addresses not set");
13694 /* Construct the API message */
13695 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13697 mp->is_add = is_add;
13701 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13706 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13712 /* Wait for a reply... */
13720 api_lisp_gpe_enable_disable (vat_main_t * vam)
13722 unformat_input_t *input = vam->input;
13723 vl_api_lisp_gpe_enable_disable_t *mp;
13728 /* Parse args required to build the message */
13729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13731 if (unformat (input, "enable"))
13736 else if (unformat (input, "disable"))
13747 errmsg ("Value not set");
13751 /* Construct the API message */
13752 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13759 /* Wait for a reply... */
13767 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13769 unformat_input_t *input = vam->input;
13770 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13775 /* Parse args required to build the message */
13776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13778 if (unformat (input, "enable"))
13783 else if (unformat (input, "disable"))
13791 errmsg ("Value not set");
13795 /* Construct the API message */
13796 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13798 mp->is_enabled = is_en;
13803 /* Wait for a reply... */
13811 api_lisp_map_register_enable_disable (vat_main_t * vam)
13813 unformat_input_t *input = vam->input;
13814 vl_api_lisp_map_register_enable_disable_t *mp;
13819 /* Parse args required to build the message */
13820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13822 if (unformat (input, "enable"))
13827 else if (unformat (input, "disable"))
13835 errmsg ("Value not set");
13839 /* Construct the API message */
13840 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13842 mp->is_enabled = is_en;
13847 /* Wait for a reply... */
13855 api_lisp_enable_disable (vat_main_t * vam)
13857 unformat_input_t *input = vam->input;
13858 vl_api_lisp_enable_disable_t *mp;
13863 /* Parse args required to build the message */
13864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13866 if (unformat (input, "enable"))
13871 else if (unformat (input, "disable"))
13881 errmsg ("Value not set");
13885 /* Construct the API message */
13886 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13893 /* Wait for a reply... */
13901 api_show_lisp_map_register_state (vat_main_t * vam)
13904 vl_api_show_lisp_map_register_state_t *mp;
13906 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13911 /* wait for reply */
13918 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13921 vl_api_show_lisp_rloc_probe_state_t *mp;
13923 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13928 /* wait for reply */
13935 api_show_lisp_map_request_mode (vat_main_t * vam)
13938 vl_api_show_lisp_map_request_mode_t *mp;
13940 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13945 /* wait for reply */
13952 api_lisp_map_request_mode (vat_main_t * vam)
13955 unformat_input_t *input = vam->input;
13956 vl_api_lisp_map_request_mode_t *mp;
13959 /* Parse args required to build the message */
13960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13962 if (unformat (input, "dst-only"))
13964 else if (unformat (input, "src-dst"))
13968 errmsg ("parse error '%U'", format_unformat_error, input);
13973 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13980 /* wait for reply */
13988 * Enable/disable LISP proxy ITR.
13990 * @param vam vpp API test context
13991 * @return return code
13994 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13997 u8 ls_name_set = 0;
13998 unformat_input_t *input = vam->input;
13999 vl_api_lisp_pitr_set_locator_set_t *mp;
14003 /* Parse args required to build the message */
14004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14006 if (unformat (input, "del"))
14008 else if (unformat (input, "locator-set %s", &ls_name))
14012 errmsg ("parse error '%U'", format_unformat_error, input);
14019 errmsg ("locator-set name not set!");
14023 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
14025 mp->is_add = is_add;
14026 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14027 vec_free (ls_name);
14032 /* wait for reply */
14040 api_show_lisp_pitr (vat_main_t * vam)
14042 vl_api_show_lisp_pitr_t *mp;
14045 if (!vam->json_output)
14047 print (vam->ofp, "%=20s", "lisp status:");
14050 M (SHOW_LISP_PITR, show_lisp_pitr);
14054 /* Wait for a reply... */
14062 * Add/delete mapping between vni and vrf
14065 api_lisp_eid_table_add_del_map (vat_main_t * vam)
14068 unformat_input_t *input = vam->input;
14069 vl_api_lisp_eid_table_add_del_map_t *mp;
14070 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14071 u32 vni, vrf, bd_index;
14073 /* Parse args required to build the message */
14074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14076 if (unformat (input, "del"))
14078 else if (unformat (input, "vrf %d", &vrf))
14080 else if (unformat (input, "bd_index %d", &bd_index))
14082 else if (unformat (input, "vni %d", &vni))
14088 if (!vni_set || (!vrf_set && !bd_index_set))
14090 errmsg ("missing arguments!");
14094 if (vrf_set && bd_index_set)
14096 errmsg ("error: both vrf and bd entered!");
14100 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
14102 mp->is_add = is_add;
14103 mp->vni = htonl (vni);
14104 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14105 mp->is_l2 = bd_index_set;
14110 /* wait for reply */
14118 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14120 u32 *action = va_arg (*args, u32 *);
14123 if (unformat (input, "%s", &s))
14125 if (!strcmp ((char *) s, "no-action"))
14127 else if (!strcmp ((char *) s, "natively-forward"))
14129 else if (!strcmp ((char *) s, "send-map-request"))
14131 else if (!strcmp ((char *) s, "drop"))
14135 clib_warning ("invalid action: '%s'", s);
14147 * Add/del remote mapping to/from LISP control plane
14149 * @param vam vpp API test context
14150 * @return return code
14153 api_lisp_add_del_remote_mapping (vat_main_t * vam)
14155 unformat_input_t *input = vam->input;
14156 vl_api_lisp_add_del_remote_mapping_t *mp;
14159 lisp_eid_vat_t _eid, *eid = &_eid;
14160 lisp_eid_vat_t _seid, *seid = &_seid;
14161 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14162 u32 action = ~0, p, w, data_len;
14163 ip4_address_t rloc4;
14164 ip6_address_t rloc6;
14165 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
14167 memset (&rloc, 0, sizeof (rloc));
14169 /* Parse args required to build the message */
14170 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14172 if (unformat (input, "del-all"))
14176 else if (unformat (input, "del"))
14180 else if (unformat (input, "add"))
14184 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14188 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14192 else if (unformat (input, "vni %d", &vni))
14196 else if (unformat (input, "p %d w %d", &p, &w))
14200 errmsg ("No RLOC configured for setting priority/weight!");
14203 curr_rloc->priority = p;
14204 curr_rloc->weight = w;
14206 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14209 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14210 vec_add1 (rlocs, rloc);
14211 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14213 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14216 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14217 vec_add1 (rlocs, rloc);
14218 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14220 else if (unformat (input, "action %U",
14221 unformat_negative_mapping_action, &action))
14227 clib_warning ("parse error '%U'", format_unformat_error, input);
14234 errmsg ("missing params!");
14238 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14240 errmsg ("no action set for negative map-reply!");
14244 data_len = vec_len (rlocs) * sizeof (rloc_t);
14246 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14247 mp->is_add = is_add;
14248 mp->vni = htonl (vni);
14249 mp->action = (u8) action;
14250 mp->is_src_dst = seid_set;
14251 mp->eid_len = eid->len;
14252 mp->seid_len = seid->len;
14253 mp->del_all = del_all;
14254 mp->eid_type = eid->type;
14255 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14256 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14258 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14259 clib_memcpy (mp->rlocs, rlocs, data_len);
14265 /* Wait for a reply... */
14273 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14274 * forwarding entries in data-plane accordingly.
14276 * @param vam vpp API test context
14277 * @return return code
14280 api_lisp_add_del_adjacency (vat_main_t * vam)
14282 unformat_input_t *input = vam->input;
14283 vl_api_lisp_add_del_adjacency_t *mp;
14286 ip4_address_t leid4, reid4;
14287 ip6_address_t leid6, reid6;
14288 u8 reid_mac[6] = { 0 };
14289 u8 leid_mac[6] = { 0 };
14290 u8 reid_type, leid_type;
14291 u32 leid_len = 0, reid_len = 0, len;
14294 leid_type = reid_type = (u8) ~ 0;
14296 /* Parse args required to build the message */
14297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14299 if (unformat (input, "del"))
14303 else if (unformat (input, "add"))
14307 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14310 reid_type = 0; /* ipv4 */
14313 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14316 reid_type = 1; /* ipv6 */
14319 else if (unformat (input, "reid %U", unformat_ethernet_address,
14322 reid_type = 2; /* mac */
14324 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14327 leid_type = 0; /* ipv4 */
14330 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14333 leid_type = 1; /* ipv6 */
14336 else if (unformat (input, "leid %U", unformat_ethernet_address,
14339 leid_type = 2; /* mac */
14341 else if (unformat (input, "vni %d", &vni))
14347 errmsg ("parse error '%U'", format_unformat_error, input);
14352 if ((u8) ~ 0 == reid_type)
14354 errmsg ("missing params!");
14358 if (leid_type != reid_type)
14360 errmsg ("remote and local EIDs are of different types!");
14364 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14365 mp->is_add = is_add;
14366 mp->vni = htonl (vni);
14367 mp->leid_len = leid_len;
14368 mp->reid_len = reid_len;
14369 mp->eid_type = reid_type;
14371 switch (mp->eid_type)
14374 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14375 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14378 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14379 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14382 clib_memcpy (mp->leid, leid_mac, 6);
14383 clib_memcpy (mp->reid, reid_mac, 6);
14386 errmsg ("unknown EID type %d!", mp->eid_type);
14393 /* Wait for a reply... */
14401 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14403 unformat_input_t *input = vam->input;
14404 vl_api_lisp_gpe_add_del_iface_t *mp;
14406 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14407 u32 dp_table = 0, vni = 0;
14409 /* Parse args required to build the message */
14410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14412 if (unformat (input, "up"))
14417 else if (unformat (input, "down"))
14422 else if (unformat (input, "table_id %d", &dp_table))
14426 else if (unformat (input, "bd_id %d", &dp_table))
14431 else if (unformat (input, "vni %d", &vni))
14439 if (action_set == 0)
14441 errmsg ("Action not set");
14444 if (dp_table_set == 0 || vni_set == 0)
14446 errmsg ("vni and dp_table must be set");
14450 /* Construct the API message */
14451 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14453 mp->is_add = is_add;
14454 mp->dp_table = dp_table;
14461 /* Wait for a reply... */
14469 * Add/del map request itr rlocs from LISP control plane and updates
14471 * @param vam vpp API test context
14472 * @return return code
14475 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14477 unformat_input_t *input = vam->input;
14478 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14480 u8 *locator_set_name = 0;
14481 u8 locator_set_name_set = 0;
14484 /* Parse args required to build the message */
14485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14487 if (unformat (input, "del"))
14491 else if (unformat (input, "%_%v%_", &locator_set_name))
14493 locator_set_name_set = 1;
14497 clib_warning ("parse error '%U'", format_unformat_error, input);
14502 if (is_add && !locator_set_name_set)
14504 errmsg ("itr-rloc is not set!");
14508 if (is_add && vec_len (locator_set_name) > 64)
14510 errmsg ("itr-rloc locator-set name too long");
14511 vec_free (locator_set_name);
14515 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14516 mp->is_add = is_add;
14519 clib_memcpy (mp->locator_set_name, locator_set_name,
14520 vec_len (locator_set_name));
14524 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14526 vec_free (locator_set_name);
14531 /* Wait for a reply... */
14539 api_lisp_locator_dump (vat_main_t * vam)
14541 unformat_input_t *input = vam->input;
14542 vl_api_lisp_locator_dump_t *mp;
14544 u8 is_index_set = 0, is_name_set = 0;
14548 /* Parse args required to build the message */
14549 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14551 if (unformat (input, "ls_name %_%v%_", &ls_name))
14555 else if (unformat (input, "ls_index %d", &ls_index))
14561 errmsg ("parse error '%U'", format_unformat_error, input);
14566 if (!is_index_set && !is_name_set)
14568 errmsg ("error: expected one of index or name!");
14572 if (is_index_set && is_name_set)
14574 errmsg ("error: only one param expected!");
14578 if (vec_len (ls_name) > 62)
14580 errmsg ("error: locator set name too long!");
14584 if (!vam->json_output)
14586 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14589 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14590 mp->is_index_set = is_index_set;
14593 mp->ls_index = clib_host_to_net_u32 (ls_index);
14596 vec_add1 (ls_name, 0);
14597 strncpy ((char *) mp->ls_name, (char *) ls_name,
14598 sizeof (mp->ls_name) - 1);
14604 /* Use a control ping for synchronization */
14606 vl_api_control_ping_t *mp;
14607 M (CONTROL_PING, control_ping);
14610 /* Wait for a reply... */
14618 api_lisp_locator_set_dump (vat_main_t * vam)
14620 vl_api_lisp_locator_set_dump_t *mp;
14621 unformat_input_t *input = vam->input;
14625 /* Parse args required to build the message */
14626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14628 if (unformat (input, "local"))
14632 else if (unformat (input, "remote"))
14638 errmsg ("parse error '%U'", format_unformat_error, input);
14643 if (!vam->json_output)
14645 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14648 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14650 mp->filter = filter;
14655 /* Use a control ping for synchronization */
14657 vl_api_control_ping_t *mp;
14658 M (CONTROL_PING, control_ping);
14661 /* Wait for a reply... */
14669 api_lisp_eid_table_map_dump (vat_main_t * vam)
14673 unformat_input_t *input = vam->input;
14674 vl_api_lisp_eid_table_map_dump_t *mp;
14677 /* Parse args required to build the message */
14678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (input, "l2"))
14685 else if (unformat (input, "l3"))
14692 errmsg ("parse error '%U'", format_unformat_error, input);
14699 errmsg ("expected one of 'l2' or 'l3' parameter!");
14703 if (!vam->json_output)
14705 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14708 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14714 /* Use a control ping for synchronization */
14716 vl_api_control_ping_t *mp;
14717 M (CONTROL_PING, control_ping);
14720 /* Wait for a reply... */
14728 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14730 vl_api_lisp_eid_table_vni_dump_t *mp;
14733 if (!vam->json_output)
14735 print (vam->ofp, "VNI");
14738 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14743 /* Use a control ping for synchronization */
14745 vl_api_control_ping_t *mp;
14746 M (CONTROL_PING, control_ping);
14749 /* Wait for a reply... */
14757 api_lisp_eid_table_dump (vat_main_t * vam)
14759 unformat_input_t *i = vam->input;
14760 vl_api_lisp_eid_table_dump_t *mp;
14762 struct in_addr ip4;
14763 struct in6_addr ip6;
14765 u8 eid_type = ~0, eid_set = 0;
14766 u32 prefix_length = ~0, t, vni = 0;
14769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14771 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14777 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14783 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14788 else if (unformat (i, "vni %d", &t))
14792 else if (unformat (i, "local"))
14796 else if (unformat (i, "remote"))
14802 errmsg ("parse error '%U'", format_unformat_error, i);
14807 if (!vam->json_output)
14809 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14810 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14813 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14815 mp->filter = filter;
14819 mp->vni = htonl (vni);
14820 mp->eid_type = eid_type;
14824 mp->prefix_length = prefix_length;
14825 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14828 mp->prefix_length = prefix_length;
14829 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14832 clib_memcpy (mp->eid, mac, sizeof (mac));
14835 errmsg ("unknown EID type %d!", eid_type);
14843 /* Use a control ping for synchronization */
14845 vl_api_control_ping_t *mp;
14846 M (CONTROL_PING, control_ping);
14850 /* Wait for a reply... */
14858 api_lisp_adjacencies_get (vat_main_t * vam)
14860 unformat_input_t *i = vam->input;
14861 vl_api_lisp_adjacencies_get_t *mp;
14866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14868 if (unformat (i, "vni %d", &vni))
14874 errmsg ("parse error '%U'", format_unformat_error, i);
14881 errmsg ("vni not set!");
14885 if (!vam->json_output)
14887 print (vam->ofp, "%s %40s", "leid", "reid");
14890 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14891 mp->vni = clib_host_to_net_u32 (vni);
14896 /* Wait for a reply... */
14904 api_lisp_map_server_dump (vat_main_t * vam)
14906 vl_api_lisp_map_server_dump_t *mp;
14909 if (!vam->json_output)
14911 print (vam->ofp, "%=20s", "Map server");
14914 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14918 /* Use a control ping for synchronization */
14920 vl_api_control_ping_t *mp;
14921 M (CONTROL_PING, control_ping);
14924 /* Wait for a reply... */
14932 api_lisp_map_resolver_dump (vat_main_t * vam)
14934 vl_api_lisp_map_resolver_dump_t *mp;
14937 if (!vam->json_output)
14939 print (vam->ofp, "%=20s", "Map resolver");
14942 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14946 /* Use a control ping for synchronization */
14948 vl_api_control_ping_t *mp;
14949 M (CONTROL_PING, control_ping);
14952 /* Wait for a reply... */
14960 api_show_lisp_status (vat_main_t * vam)
14962 vl_api_show_lisp_status_t *mp;
14965 if (!vam->json_output)
14967 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14970 M (SHOW_LISP_STATUS, show_lisp_status);
14973 /* Wait for a reply... */
14981 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14983 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14986 if (!vam->json_output)
14988 print (vam->ofp, "%=20s", "itr-rlocs:");
14991 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14994 /* Wait for a reply... */
15002 api_af_packet_create (vat_main_t * vam)
15004 unformat_input_t *i = vam->input;
15005 vl_api_af_packet_create_t *mp;
15007 u8 *host_if_name = 0;
15009 u8 random_hw_addr = 1;
15011 memset (hw_addr, 0, sizeof (hw_addr));
15013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15015 if (unformat (i, "name %s", &host_if_name))
15016 vec_add1 (host_if_name, 0);
15017 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15018 random_hw_addr = 0;
15023 if (!vec_len (host_if_name))
15025 errmsg ("host-interface name must be specified");
15029 if (vec_len (host_if_name) > 64)
15031 errmsg ("host-interface name too long");
15035 M (AF_PACKET_CREATE, af_packet_create);
15037 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15038 clib_memcpy (mp->hw_addr, hw_addr, 6);
15039 mp->use_random_hw_addr = random_hw_addr;
15040 vec_free (host_if_name);
15043 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15049 api_af_packet_delete (vat_main_t * vam)
15051 unformat_input_t *i = vam->input;
15052 vl_api_af_packet_delete_t *mp;
15054 u8 *host_if_name = 0;
15056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15058 if (unformat (i, "name %s", &host_if_name))
15059 vec_add1 (host_if_name, 0);
15064 if (!vec_len (host_if_name))
15066 errmsg ("host-interface name must be specified");
15070 if (vec_len (host_if_name) > 64)
15072 errmsg ("host-interface name too long");
15076 M (AF_PACKET_DELETE, af_packet_delete);
15078 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15079 vec_free (host_if_name);
15088 api_policer_add_del (vat_main_t * vam)
15090 unformat_input_t *i = vam->input;
15091 vl_api_policer_add_del_t *mp;
15102 u8 color_aware = 0;
15103 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15105 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15106 conform_action.dscp = 0;
15107 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15108 exceed_action.dscp = 0;
15109 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15110 violate_action.dscp = 0;
15112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15114 if (unformat (i, "del"))
15116 else if (unformat (i, "name %s", &name))
15117 vec_add1 (name, 0);
15118 else if (unformat (i, "cir %u", &cir))
15120 else if (unformat (i, "eir %u", &eir))
15122 else if (unformat (i, "cb %u", &cb))
15124 else if (unformat (i, "eb %u", &eb))
15126 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15129 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15132 else if (unformat (i, "type %U", unformat_policer_type, &type))
15134 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15137 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15140 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15143 else if (unformat (i, "color-aware"))
15149 if (!vec_len (name))
15151 errmsg ("policer name must be specified");
15155 if (vec_len (name) > 64)
15157 errmsg ("policer name too long");
15161 M (POLICER_ADD_DEL, policer_add_del);
15163 clib_memcpy (mp->name, name, vec_len (name));
15165 mp->is_add = is_add;
15170 mp->rate_type = rate_type;
15171 mp->round_type = round_type;
15173 mp->conform_action_type = conform_action.action_type;
15174 mp->conform_dscp = conform_action.dscp;
15175 mp->exceed_action_type = exceed_action.action_type;
15176 mp->exceed_dscp = exceed_action.dscp;
15177 mp->violate_action_type = violate_action.action_type;
15178 mp->violate_dscp = violate_action.dscp;
15179 mp->color_aware = color_aware;
15188 api_policer_dump (vat_main_t * vam)
15190 unformat_input_t *i = vam->input;
15191 vl_api_policer_dump_t *mp;
15193 u8 *match_name = 0;
15194 u8 match_name_valid = 0;
15196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15198 if (unformat (i, "name %s", &match_name))
15200 vec_add1 (match_name, 0);
15201 match_name_valid = 1;
15207 M (POLICER_DUMP, policer_dump);
15208 mp->match_name_valid = match_name_valid;
15209 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15210 vec_free (match_name);
15214 /* Use a control ping for synchronization */
15216 vl_api_control_ping_t *mp;
15217 M (CONTROL_PING, control_ping);
15220 /* Wait for a reply... */
15228 api_policer_classify_set_interface (vat_main_t * vam)
15230 unformat_input_t *i = vam->input;
15231 vl_api_policer_classify_set_interface_t *mp;
15234 int sw_if_index_set;
15235 u32 ip4_table_index = ~0;
15236 u32 ip6_table_index = ~0;
15237 u32 l2_table_index = ~0;
15240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15242 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15243 sw_if_index_set = 1;
15244 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15245 sw_if_index_set = 1;
15246 else if (unformat (i, "del"))
15248 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15250 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15252 else if (unformat (i, "l2-table %d", &l2_table_index))
15256 clib_warning ("parse error '%U'", format_unformat_error, i);
15261 if (sw_if_index_set == 0)
15263 errmsg ("missing interface name or sw_if_index");
15267 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15269 mp->sw_if_index = ntohl (sw_if_index);
15270 mp->ip4_table_index = ntohl (ip4_table_index);
15271 mp->ip6_table_index = ntohl (ip6_table_index);
15272 mp->l2_table_index = ntohl (l2_table_index);
15273 mp->is_add = is_add;
15282 api_policer_classify_dump (vat_main_t * vam)
15284 unformat_input_t *i = vam->input;
15285 vl_api_policer_classify_dump_t *mp;
15287 u8 type = POLICER_CLASSIFY_N_TABLES;
15289 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15293 errmsg ("classify table type must be specified");
15297 if (!vam->json_output)
15299 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15302 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15307 /* Use a control ping for synchronization */
15309 vl_api_control_ping_t *mp;
15310 M (CONTROL_PING, control_ping);
15313 /* Wait for a reply... */
15321 api_netmap_create (vat_main_t * vam)
15323 unformat_input_t *i = vam->input;
15324 vl_api_netmap_create_t *mp;
15328 u8 random_hw_addr = 1;
15332 memset (hw_addr, 0, sizeof (hw_addr));
15334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15336 if (unformat (i, "name %s", &if_name))
15337 vec_add1 (if_name, 0);
15338 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15339 random_hw_addr = 0;
15340 else if (unformat (i, "pipe"))
15342 else if (unformat (i, "master"))
15344 else if (unformat (i, "slave"))
15350 if (!vec_len (if_name))
15352 errmsg ("interface name must be specified");
15356 if (vec_len (if_name) > 64)
15358 errmsg ("interface name too long");
15362 M (NETMAP_CREATE, netmap_create);
15364 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15365 clib_memcpy (mp->hw_addr, hw_addr, 6);
15366 mp->use_random_hw_addr = random_hw_addr;
15367 mp->is_pipe = is_pipe;
15368 mp->is_master = is_master;
15369 vec_free (if_name);
15378 api_netmap_delete (vat_main_t * vam)
15380 unformat_input_t *i = vam->input;
15381 vl_api_netmap_delete_t *mp;
15385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15387 if (unformat (i, "name %s", &if_name))
15388 vec_add1 (if_name, 0);
15393 if (!vec_len (if_name))
15395 errmsg ("interface name must be specified");
15399 if (vec_len (if_name) > 64)
15401 errmsg ("interface name too long");
15405 M (NETMAP_DELETE, netmap_delete);
15407 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15408 vec_free (if_name);
15416 static void vl_api_mpls_tunnel_details_t_handler
15417 (vl_api_mpls_tunnel_details_t * mp)
15419 vat_main_t *vam = &vat_main;
15420 i32 len = mp->mt_next_hop_n_labels;
15423 print (vam->ofp, "[%d]: via %U %d labels ",
15425 format_ip4_address, mp->mt_next_hop,
15426 ntohl (mp->mt_next_hop_sw_if_index));
15427 for (i = 0; i < len; i++)
15429 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15431 print (vam->ofp, "");
15434 static void vl_api_mpls_tunnel_details_t_handler_json
15435 (vl_api_mpls_tunnel_details_t * mp)
15437 vat_main_t *vam = &vat_main;
15438 vat_json_node_t *node = NULL;
15439 struct in_addr ip4;
15441 i32 len = mp->mt_next_hop_n_labels;
15443 if (VAT_JSON_ARRAY != vam->json_tree.type)
15445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15446 vat_json_init_array (&vam->json_tree);
15448 node = vat_json_array_add (&vam->json_tree);
15450 vat_json_init_object (node);
15451 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15452 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15453 vat_json_object_add_ip4 (node, "next_hop", ip4);
15454 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15455 ntohl (mp->mt_next_hop_sw_if_index));
15456 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15457 vat_json_object_add_uint (node, "label_count", len);
15458 for (i = 0; i < len; i++)
15460 vat_json_object_add_uint (node, "label",
15461 ntohl (mp->mt_next_hop_out_labels[i]));
15466 api_mpls_tunnel_dump (vat_main_t * vam)
15468 vl_api_mpls_tunnel_dump_t *mp;
15472 /* Parse args required to build the message */
15473 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15475 if (!unformat (vam->input, "tunnel_index %d", &index))
15482 print (vam->ofp, " tunnel_index %d", index);
15484 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15485 mp->tunnel_index = htonl (index);
15488 /* Use a control ping for synchronization */
15490 vl_api_control_ping_t *mp;
15491 M (CONTROL_PING, control_ping);
15497 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15498 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15501 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15503 vat_main_t *vam = &vat_main;
15504 int count = ntohl (mp->count);
15505 vl_api_fib_path2_t *fp;
15509 "table-id %d, label %u, ess_bit %u",
15510 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15512 for (i = 0; i < count; i++)
15514 if (fp->afi == IP46_TYPE_IP6)
15516 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15517 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15518 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15519 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15520 format_ip6_address, fp->next_hop);
15521 else if (fp->afi == IP46_TYPE_IP4)
15523 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15524 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15525 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15526 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15527 format_ip4_address, fp->next_hop);
15532 static void vl_api_mpls_fib_details_t_handler_json
15533 (vl_api_mpls_fib_details_t * mp)
15535 vat_main_t *vam = &vat_main;
15536 int count = ntohl (mp->count);
15537 vat_json_node_t *node = NULL;
15538 struct in_addr ip4;
15539 struct in6_addr ip6;
15540 vl_api_fib_path2_t *fp;
15543 if (VAT_JSON_ARRAY != vam->json_tree.type)
15545 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15546 vat_json_init_array (&vam->json_tree);
15548 node = vat_json_array_add (&vam->json_tree);
15550 vat_json_init_object (node);
15551 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15552 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15553 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15554 vat_json_object_add_uint (node, "path_count", count);
15556 for (i = 0; i < count; i++)
15558 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15559 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15560 vat_json_object_add_uint (node, "is_local", fp->is_local);
15561 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15562 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15563 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15564 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15565 if (fp->afi == IP46_TYPE_IP4)
15567 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15568 vat_json_object_add_ip4 (node, "next_hop", ip4);
15570 else if (fp->afi == IP46_TYPE_IP6)
15572 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15573 vat_json_object_add_ip6 (node, "next_hop", ip6);
15579 api_mpls_fib_dump (vat_main_t * vam)
15581 vl_api_mpls_fib_dump_t *mp;
15584 M (MPLS_FIB_DUMP, mpls_fib_dump);
15587 /* Use a control ping for synchronization */
15589 vl_api_control_ping_t *mp;
15590 M (CONTROL_PING, control_ping);
15596 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15597 #define vl_api_ip_fib_details_t_print vl_noop_handler
15600 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15602 vat_main_t *vam = &vat_main;
15603 int count = ntohl (mp->count);
15604 vl_api_fib_path_t *fp;
15608 "table-id %d, prefix %U/%d",
15609 ntohl (mp->table_id), format_ip4_address, mp->address,
15610 mp->address_length);
15612 for (i = 0; i < count; i++)
15614 if (fp->afi == IP46_TYPE_IP6)
15616 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15617 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15618 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15619 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15620 format_ip6_address, fp->next_hop);
15621 else if (fp->afi == IP46_TYPE_IP4)
15623 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15624 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15625 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15626 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15627 format_ip4_address, fp->next_hop);
15632 static void vl_api_ip_fib_details_t_handler_json
15633 (vl_api_ip_fib_details_t * mp)
15635 vat_main_t *vam = &vat_main;
15636 int count = ntohl (mp->count);
15637 vat_json_node_t *node = NULL;
15638 struct in_addr ip4;
15639 struct in6_addr ip6;
15640 vl_api_fib_path_t *fp;
15643 if (VAT_JSON_ARRAY != vam->json_tree.type)
15645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15646 vat_json_init_array (&vam->json_tree);
15648 node = vat_json_array_add (&vam->json_tree);
15650 vat_json_init_object (node);
15651 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15652 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15653 vat_json_object_add_ip4 (node, "prefix", ip4);
15654 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15655 vat_json_object_add_uint (node, "path_count", count);
15657 for (i = 0; i < count; i++)
15659 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15660 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15661 vat_json_object_add_uint (node, "is_local", fp->is_local);
15662 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15663 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15664 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15665 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15666 if (fp->afi == IP46_TYPE_IP4)
15668 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15669 vat_json_object_add_ip4 (node, "next_hop", ip4);
15671 else if (fp->afi == IP46_TYPE_IP6)
15673 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15674 vat_json_object_add_ip6 (node, "next_hop", ip6);
15680 api_ip_fib_dump (vat_main_t * vam)
15682 vl_api_ip_fib_dump_t *mp;
15685 M (IP_FIB_DUMP, ip_fib_dump);
15688 /* Use a control ping for synchronization */
15690 vl_api_control_ping_t *mp;
15691 M (CONTROL_PING, control_ping);
15697 static void vl_api_ip_neighbor_details_t_handler
15698 (vl_api_ip_neighbor_details_t * mp)
15700 vat_main_t *vam = &vat_main;
15702 print (vam->ofp, "%c %U %U",
15703 (mp->is_static) ? 'S' : 'D',
15704 format_ethernet_address, &mp->mac_address,
15705 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15709 static void vl_api_ip_neighbor_details_t_handler_json
15710 (vl_api_ip_neighbor_details_t * mp)
15713 vat_main_t *vam = &vat_main;
15714 vat_json_node_t *node;
15715 struct in_addr ip4;
15716 struct in6_addr ip6;
15718 if (VAT_JSON_ARRAY != vam->json_tree.type)
15720 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15721 vat_json_init_array (&vam->json_tree);
15723 node = vat_json_array_add (&vam->json_tree);
15725 vat_json_init_object (node);
15726 vat_json_object_add_string_copy (node, "flag",
15727 (mp->is_static) ? (u8 *) "static" : (u8 *)
15730 vat_json_object_add_string_copy (node, "link_layer",
15731 format (0, "%U", format_ethernet_address,
15732 &mp->mac_address));
15736 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15737 vat_json_object_add_ip6 (node, "ip_address", ip6);
15741 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15742 vat_json_object_add_ip4 (node, "ip_address", ip4);
15747 api_ip_neighbor_dump (vat_main_t * vam)
15749 unformat_input_t *i = vam->input;
15750 vl_api_ip_neighbor_dump_t *mp;
15753 u32 sw_if_index = ~0;
15755 /* Parse args required to build the message */
15756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15762 else if (unformat (i, "ip6"))
15768 if (sw_if_index == ~0)
15770 errmsg ("missing interface name or sw_if_index");
15774 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15775 mp->is_ipv6 = (u8) is_ipv6;
15776 mp->sw_if_index = ntohl (sw_if_index);
15779 /* Use a control ping for synchronization */
15781 vl_api_control_ping_t *mp;
15782 M (CONTROL_PING, control_ping);
15788 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15789 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15792 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15794 vat_main_t *vam = &vat_main;
15795 int count = ntohl (mp->count);
15796 vl_api_fib_path_t *fp;
15800 "table-id %d, prefix %U/%d",
15801 ntohl (mp->table_id), format_ip6_address, mp->address,
15802 mp->address_length);
15804 for (i = 0; i < count; i++)
15806 if (fp->afi == IP46_TYPE_IP6)
15808 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15809 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15810 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15811 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15812 format_ip6_address, fp->next_hop);
15813 else if (fp->afi == IP46_TYPE_IP4)
15815 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15816 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15817 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15818 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15819 format_ip4_address, fp->next_hop);
15824 static void vl_api_ip6_fib_details_t_handler_json
15825 (vl_api_ip6_fib_details_t * mp)
15827 vat_main_t *vam = &vat_main;
15828 int count = ntohl (mp->count);
15829 vat_json_node_t *node = NULL;
15830 struct in_addr ip4;
15831 struct in6_addr ip6;
15832 vl_api_fib_path_t *fp;
15835 if (VAT_JSON_ARRAY != vam->json_tree.type)
15837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15838 vat_json_init_array (&vam->json_tree);
15840 node = vat_json_array_add (&vam->json_tree);
15842 vat_json_init_object (node);
15843 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15844 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15845 vat_json_object_add_ip6 (node, "prefix", ip6);
15846 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15847 vat_json_object_add_uint (node, "path_count", count);
15849 for (i = 0; i < count; i++)
15851 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15852 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15853 vat_json_object_add_uint (node, "is_local", fp->is_local);
15854 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15855 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15856 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15857 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15858 if (fp->afi == IP46_TYPE_IP4)
15860 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15861 vat_json_object_add_ip4 (node, "next_hop", ip4);
15863 else if (fp->afi == IP46_TYPE_IP6)
15865 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15866 vat_json_object_add_ip6 (node, "next_hop", ip6);
15872 api_ip6_fib_dump (vat_main_t * vam)
15874 vl_api_ip6_fib_dump_t *mp;
15877 M (IP6_FIB_DUMP, ip6_fib_dump);
15880 /* Use a control ping for synchronization */
15882 vl_api_control_ping_t *mp;
15883 M (CONTROL_PING, control_ping);
15890 api_classify_table_ids (vat_main_t * vam)
15892 vl_api_classify_table_ids_t *mp;
15895 /* Construct the API message */
15896 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15906 api_classify_table_by_interface (vat_main_t * vam)
15908 unformat_input_t *input = vam->input;
15909 vl_api_classify_table_by_interface_t *mp;
15912 u32 sw_if_index = ~0;
15913 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15915 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15917 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15922 if (sw_if_index == ~0)
15924 errmsg ("missing interface name or sw_if_index");
15928 /* Construct the API message */
15929 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15931 mp->sw_if_index = ntohl (sw_if_index);
15940 api_classify_table_info (vat_main_t * vam)
15942 unformat_input_t *input = vam->input;
15943 vl_api_classify_table_info_t *mp;
15947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15949 if (unformat (input, "table_id %d", &table_id))
15954 if (table_id == ~0)
15956 errmsg ("missing table id");
15960 /* Construct the API message */
15961 M (CLASSIFY_TABLE_INFO, classify_table_info);
15963 mp->table_id = ntohl (table_id);
15972 api_classify_session_dump (vat_main_t * vam)
15974 unformat_input_t *input = vam->input;
15975 vl_api_classify_session_dump_t *mp;
15979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15981 if (unformat (input, "table_id %d", &table_id))
15986 if (table_id == ~0)
15988 errmsg ("missing table id");
15992 /* Construct the API message */
15993 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15995 mp->table_id = ntohl (table_id);
15998 /* Use a control ping for synchronization */
16000 vl_api_control_ping_t *mp;
16001 M (CONTROL_PING, control_ping);
16010 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16012 vat_main_t *vam = &vat_main;
16014 print (vam->ofp, "collector_address %U, collector_port %d, "
16015 "src_address %U, vrf_id %d, path_mtu %u, "
16016 "template_interval %u, udp_checksum %d",
16017 format_ip4_address, mp->collector_address,
16018 ntohs (mp->collector_port),
16019 format_ip4_address, mp->src_address,
16020 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16021 ntohl (mp->template_interval), mp->udp_checksum);
16024 vam->result_ready = 1;
16028 vl_api_ipfix_exporter_details_t_handler_json
16029 (vl_api_ipfix_exporter_details_t * mp)
16031 vat_main_t *vam = &vat_main;
16032 vat_json_node_t node;
16033 struct in_addr collector_address;
16034 struct in_addr src_address;
16036 vat_json_init_object (&node);
16037 clib_memcpy (&collector_address, &mp->collector_address,
16038 sizeof (collector_address));
16039 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16040 vat_json_object_add_uint (&node, "collector_port",
16041 ntohs (mp->collector_port));
16042 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16043 vat_json_object_add_ip4 (&node, "src_address", src_address);
16044 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16045 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16046 vat_json_object_add_uint (&node, "template_interval",
16047 ntohl (mp->template_interval));
16048 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16050 vat_json_print (vam->ofp, &node);
16051 vat_json_free (&node);
16053 vam->result_ready = 1;
16057 api_ipfix_exporter_dump (vat_main_t * vam)
16059 vl_api_ipfix_exporter_dump_t *mp;
16062 /* Construct the API message */
16063 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
16073 api_ipfix_classify_stream_dump (vat_main_t * vam)
16075 vl_api_ipfix_classify_stream_dump_t *mp;
16078 /* Construct the API message */
16079 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
16089 vl_api_ipfix_classify_stream_details_t_handler
16090 (vl_api_ipfix_classify_stream_details_t * mp)
16092 vat_main_t *vam = &vat_main;
16093 print (vam->ofp, "domain_id %d, src_port %d",
16094 ntohl (mp->domain_id), ntohs (mp->src_port));
16096 vam->result_ready = 1;
16100 vl_api_ipfix_classify_stream_details_t_handler_json
16101 (vl_api_ipfix_classify_stream_details_t * mp)
16103 vat_main_t *vam = &vat_main;
16104 vat_json_node_t node;
16106 vat_json_init_object (&node);
16107 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16108 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16110 vat_json_print (vam->ofp, &node);
16111 vat_json_free (&node);
16113 vam->result_ready = 1;
16117 api_ipfix_classify_table_dump (vat_main_t * vam)
16119 vl_api_ipfix_classify_table_dump_t *mp;
16122 if (!vam->json_output)
16124 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16125 "transport_protocol");
16128 /* Construct the API message */
16129 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
16134 /* Use a control ping for synchronization */
16136 vl_api_control_ping_t *mp;
16137 M (CONTROL_PING, control_ping);
16144 vl_api_ipfix_classify_table_details_t_handler
16145 (vl_api_ipfix_classify_table_details_t * mp)
16147 vat_main_t *vam = &vat_main;
16148 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16149 mp->transport_protocol);
16153 vl_api_ipfix_classify_table_details_t_handler_json
16154 (vl_api_ipfix_classify_table_details_t * mp)
16156 vat_json_node_t *node = NULL;
16157 vat_main_t *vam = &vat_main;
16159 if (VAT_JSON_ARRAY != vam->json_tree.type)
16161 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16162 vat_json_init_array (&vam->json_tree);
16165 node = vat_json_array_add (&vam->json_tree);
16166 vat_json_init_object (node);
16168 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16169 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16170 vat_json_object_add_uint (node, "transport_protocol",
16171 mp->transport_protocol);
16175 api_sw_interface_span_enable_disable (vat_main_t * vam)
16177 unformat_input_t *i = vam->input;
16178 vl_api_sw_interface_span_enable_disable_t *mp;
16180 u32 src_sw_if_index = ~0;
16181 u32 dst_sw_if_index = ~0;
16184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16187 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16189 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16193 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16195 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16197 else if (unformat (i, "disable"))
16199 else if (unformat (i, "rx"))
16201 else if (unformat (i, "tx"))
16203 else if (unformat (i, "both"))
16209 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16211 mp->sw_if_index_from = htonl (src_sw_if_index);
16212 mp->sw_if_index_to = htonl (dst_sw_if_index);
16222 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16225 vat_main_t *vam = &vat_main;
16226 u8 *sw_if_from_name = 0;
16227 u8 *sw_if_to_name = 0;
16228 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16229 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16230 char *states[] = { "none", "rx", "tx", "both" };
16234 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16236 if ((u32) p->value[0] == sw_if_index_from)
16238 sw_if_from_name = (u8 *)(p->key);
16242 if ((u32) p->value[0] == sw_if_index_to)
16244 sw_if_to_name = (u8 *)(p->key);
16245 if (sw_if_from_name)
16250 print (vam->ofp, "%20s => %20s (%s)",
16251 sw_if_from_name, sw_if_to_name, states[mp->state]);
16255 vl_api_sw_interface_span_details_t_handler_json
16256 (vl_api_sw_interface_span_details_t * mp)
16258 vat_main_t *vam = &vat_main;
16259 vat_json_node_t *node = NULL;
16260 u8 *sw_if_from_name = 0;
16261 u8 *sw_if_to_name = 0;
16262 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16263 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16267 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16269 if ((u32) p->value[0] == sw_if_index_from)
16271 sw_if_from_name = (u8 *)(p->key);
16275 if ((u32) p->value[0] == sw_if_index_to)
16277 sw_if_to_name = (u8 *)(p->key);
16278 if (sw_if_from_name)
16284 if (VAT_JSON_ARRAY != vam->json_tree.type)
16286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16287 vat_json_init_array (&vam->json_tree);
16289 node = vat_json_array_add (&vam->json_tree);
16291 vat_json_init_object (node);
16292 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16293 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16294 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16295 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16296 vat_json_object_add_uint (node, "state", mp->state);
16300 api_sw_interface_span_dump (vat_main_t * vam)
16302 vl_api_sw_interface_span_dump_t *mp;
16305 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16308 /* Use a control ping for synchronization */
16310 vl_api_control_ping_t *mp;
16311 M (CONTROL_PING, control_ping);
16318 api_pg_create_interface (vat_main_t * vam)
16320 unformat_input_t *input = vam->input;
16321 vl_api_pg_create_interface_t *mp;
16325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16327 if (unformat (input, "if_id %d", &if_id))
16334 errmsg ("missing pg interface index");
16338 /* Construct the API message */
16339 M (PG_CREATE_INTERFACE, pg_create_interface);
16341 mp->interface_id = ntohl (if_id);
16350 api_pg_capture (vat_main_t * vam)
16352 unformat_input_t *input = vam->input;
16353 vl_api_pg_capture_t *mp;
16359 u8 pcap_file_set = 0;
16361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16363 if (unformat (input, "if_id %d", &if_id))
16365 else if (unformat (input, "pcap %s", &pcap_file))
16367 else if (unformat (input, "count %d", &count))
16369 else if (unformat (input, "disable"))
16376 errmsg ("missing pg interface index");
16379 if (pcap_file_set > 0)
16381 if (vec_len (pcap_file) > 255)
16383 errmsg ("pcap file name is too long");
16388 u32 name_len = vec_len (pcap_file);
16389 /* Construct the API message */
16390 M (PG_CAPTURE, pg_capture);
16392 mp->interface_id = ntohl (if_id);
16393 mp->is_enabled = enable;
16394 mp->count = ntohl (count);
16395 mp->pcap_name_length = ntohl (name_len);
16396 if (pcap_file_set != 0)
16398 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16400 vec_free (pcap_file);
16409 api_pg_enable_disable (vat_main_t * vam)
16411 unformat_input_t *input = vam->input;
16412 vl_api_pg_enable_disable_t *mp;
16416 u8 stream_name_set = 0;
16417 u8 *stream_name = 0;
16418 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16420 if (unformat (input, "stream %s", &stream_name))
16421 stream_name_set = 1;
16422 else if (unformat (input, "disable"))
16428 if (stream_name_set > 0)
16430 if (vec_len (stream_name) > 255)
16432 errmsg ("stream name too long");
16437 u32 name_len = vec_len (stream_name);
16438 /* Construct the API message */
16439 M (PG_ENABLE_DISABLE, pg_enable_disable);
16441 mp->is_enabled = enable;
16442 if (stream_name_set != 0)
16444 mp->stream_name_length = ntohl (name_len);
16445 clib_memcpy (mp->stream_name, stream_name, name_len);
16447 vec_free (stream_name);
16456 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16458 unformat_input_t *input = vam->input;
16459 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16462 u16 *low_ports = 0;
16463 u16 *high_ports = 0;
16466 ip4_address_t ip4_addr;
16467 ip6_address_t ip6_addr;
16475 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16477 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16483 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16488 else if (unformat (input, "vrf %d", &vrf_id))
16490 else if (unformat (input, "del"))
16492 else if (unformat (input, "port %d", &tmp))
16494 if (tmp == 0 || tmp > 65535)
16496 errmsg ("port %d out of range", tmp);
16500 this_hi = this_low + 1;
16501 vec_add1 (low_ports, this_low);
16502 vec_add1 (high_ports, this_hi);
16504 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16506 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16508 errmsg ("incorrect range parameters");
16512 /* Note: in debug CLI +1 is added to high before
16513 passing to real fn that does "the work"
16514 (ip_source_and_port_range_check_add_del).
16515 This fn is a wrapper around the binary API fn a
16516 control plane will call, which expects this increment
16517 to have occurred. Hence letting the binary API control
16518 plane fn do the increment for consistency between VAT
16519 and other control planes.
16522 vec_add1 (low_ports, this_low);
16523 vec_add1 (high_ports, this_hi);
16529 if (prefix_set == 0)
16531 errmsg ("<address>/<mask> not specified");
16537 errmsg ("VRF ID required, not specified");
16544 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16548 if (vec_len (low_ports) == 0)
16550 errmsg ("At least one port or port range required");
16554 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16555 ip_source_and_port_range_check_add_del);
16557 mp->is_add = is_add;
16562 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16567 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16570 mp->mask_length = length;
16571 mp->number_of_ranges = vec_len (low_ports);
16573 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16574 vec_free (low_ports);
16576 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16577 vec_free (high_ports);
16579 mp->vrf_id = ntohl (vrf_id);
16588 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16590 unformat_input_t *input = vam->input;
16591 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16593 u32 sw_if_index = ~0;
16595 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16596 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16599 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16601 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16603 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16605 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16607 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16609 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16611 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16613 else if (unformat (input, "del"))
16619 if (sw_if_index == ~0)
16621 errmsg ("Interface required but not specified");
16627 errmsg ("VRF ID required but not specified");
16631 if (tcp_out_vrf_id == 0
16632 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16635 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16639 /* Construct the API message */
16640 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16641 ip_source_and_port_range_check_interface_add_del);
16643 mp->sw_if_index = ntohl (sw_if_index);
16644 mp->is_add = is_add;
16645 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16646 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16647 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16648 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16653 /* Wait for a reply... */
16658 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16660 unformat_input_t *i = vam->input;
16661 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16663 u32 local_sa_id = 0;
16664 u32 remote_sa_id = 0;
16665 ip4_address_t src_address;
16666 ip4_address_t dst_address;
16669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16671 if (unformat (i, "local_sa %d", &local_sa_id))
16673 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16675 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16677 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16679 else if (unformat (i, "del"))
16683 clib_warning ("parse error '%U'", format_unformat_error, i);
16688 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16690 mp->local_sa_id = ntohl (local_sa_id);
16691 mp->remote_sa_id = ntohl (remote_sa_id);
16692 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16693 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16694 mp->is_add = is_add;
16703 api_punt (vat_main_t * vam)
16705 unformat_input_t *i = vam->input;
16713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16715 if (unformat (i, "ip %d", &ipv))
16717 else if (unformat (i, "protocol %d", &protocol))
16719 else if (unformat (i, "port %d", &port))
16721 else if (unformat (i, "del"))
16725 clib_warning ("parse error '%U'", format_unformat_error, i);
16732 mp->is_add = (u8) is_add;
16733 mp->ipv = (u8) ipv;
16734 mp->l4_protocol = (u8) protocol;
16735 mp->l4_port = htons ((u16) port);
16743 static void vl_api_ipsec_gre_tunnel_details_t_handler
16744 (vl_api_ipsec_gre_tunnel_details_t * mp)
16746 vat_main_t *vam = &vat_main;
16748 print (vam->ofp, "%11d%15U%15U%14d%14d",
16749 ntohl (mp->sw_if_index),
16750 format_ip4_address, &mp->src_address,
16751 format_ip4_address, &mp->dst_address,
16752 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16755 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16756 (vl_api_ipsec_gre_tunnel_details_t * mp)
16758 vat_main_t *vam = &vat_main;
16759 vat_json_node_t *node = NULL;
16760 struct in_addr ip4;
16762 if (VAT_JSON_ARRAY != vam->json_tree.type)
16764 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16765 vat_json_init_array (&vam->json_tree);
16767 node = vat_json_array_add (&vam->json_tree);
16769 vat_json_init_object (node);
16770 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16771 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16772 vat_json_object_add_ip4 (node, "src_address", ip4);
16773 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16774 vat_json_object_add_ip4 (node, "dst_address", ip4);
16775 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16776 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16780 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16782 unformat_input_t *i = vam->input;
16783 vl_api_ipsec_gre_tunnel_dump_t *mp;
16786 u8 sw_if_index_set = 0;
16788 /* Parse args required to build the message */
16789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16791 if (unformat (i, "sw_if_index %d", &sw_if_index))
16792 sw_if_index_set = 1;
16797 if (sw_if_index_set == 0)
16802 if (!vam->json_output)
16804 print (vam->ofp, "%11s%15s%15s%14s%14s",
16805 "sw_if_index", "src_address", "dst_address",
16806 "local_sa_id", "remote_sa_id");
16809 /* Get list of gre-tunnel interfaces */
16810 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16812 mp->sw_if_index = htonl (sw_if_index);
16816 /* Use a control ping for synchronization */
16818 vl_api_control_ping_t *mp;
16819 M (CONTROL_PING, control_ping);
16826 api_delete_subif (vat_main_t * vam)
16828 unformat_input_t *i = vam->input;
16829 vl_api_delete_subif_t *mp;
16831 u32 sw_if_index = ~0;
16833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16837 if (unformat (i, "sw_if_index %d", &sw_if_index))
16843 if (sw_if_index == ~0)
16845 errmsg ("missing sw_if_index");
16849 /* Construct the API message */
16850 M (DELETE_SUBIF, delete_subif);
16851 mp->sw_if_index = ntohl (sw_if_index);
16857 #define foreach_pbb_vtr_op \
16858 _("disable", L2_VTR_DISABLED) \
16859 _("pop", L2_VTR_POP_2) \
16860 _("push", L2_VTR_PUSH_2)
16863 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16865 unformat_input_t *i = vam->input;
16866 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16868 u32 sw_if_index = ~0, vtr_op = ~0;
16869 u16 outer_tag = ~0;
16870 u8 dmac[6], smac[6];
16871 u8 dmac_set = 0, smac_set = 0;
16876 /* Shut up coverity */
16877 memset (dmac, 0, sizeof (dmac));
16878 memset (smac, 0, sizeof (smac));
16880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16882 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16884 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16886 else if (unformat (i, "vtr_op %d", &vtr_op))
16888 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16891 else if (unformat (i, "translate_pbb_stag"))
16893 if (unformat (i, "%d", &tmp))
16895 vtr_op = L2_VTR_TRANSLATE_2_1;
16901 ("translate_pbb_stag operation requires outer tag definition");
16905 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16907 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16909 else if (unformat (i, "sid %d", &sid))
16911 else if (unformat (i, "vlanid %d", &tmp))
16915 clib_warning ("parse error '%U'", format_unformat_error, i);
16920 if ((sw_if_index == ~0) || (vtr_op == ~0))
16922 errmsg ("missing sw_if_index or vtr operation");
16925 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16926 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16929 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16933 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16934 mp->sw_if_index = ntohl (sw_if_index);
16935 mp->vtr_op = ntohl (vtr_op);
16936 mp->outer_tag = ntohs (outer_tag);
16937 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16938 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16939 mp->b_vlanid = ntohs (vlanid);
16940 mp->i_sid = ntohl (sid);
16949 api_flow_classify_set_interface (vat_main_t * vam)
16951 unformat_input_t *i = vam->input;
16952 vl_api_flow_classify_set_interface_t *mp;
16955 int sw_if_index_set;
16956 u32 ip4_table_index = ~0;
16957 u32 ip6_table_index = ~0;
16960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16962 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16963 sw_if_index_set = 1;
16964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16965 sw_if_index_set = 1;
16966 else if (unformat (i, "del"))
16968 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16970 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16974 clib_warning ("parse error '%U'", format_unformat_error, i);
16979 if (sw_if_index_set == 0)
16981 errmsg ("missing interface name or sw_if_index");
16985 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16987 mp->sw_if_index = ntohl (sw_if_index);
16988 mp->ip4_table_index = ntohl (ip4_table_index);
16989 mp->ip6_table_index = ntohl (ip6_table_index);
16990 mp->is_add = is_add;
16999 api_flow_classify_dump (vat_main_t * vam)
17001 unformat_input_t *i = vam->input;
17002 vl_api_flow_classify_dump_t *mp;
17004 u8 type = FLOW_CLASSIFY_N_TABLES;
17006 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17010 errmsg ("classify table type must be specified");
17014 if (!vam->json_output)
17016 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17019 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
17024 /* Use a control ping for synchronization */
17026 vl_api_control_ping_t *mp;
17027 M (CONTROL_PING, control_ping);
17030 /* Wait for a reply... */
17038 api_feature_enable_disable (vat_main_t * vam)
17040 unformat_input_t *i = vam->input;
17041 vl_api_feature_enable_disable_t *mp;
17044 u8 *feature_name = 0;
17045 u32 sw_if_index = ~0;
17048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17050 if (unformat (i, "arc_name %s", &arc_name))
17052 else if (unformat (i, "feature_name %s", &feature_name))
17055 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17057 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17059 else if (unformat (i, "disable"))
17067 errmsg ("missing arc name");
17070 if (vec_len (arc_name) > 63)
17072 errmsg ("arc name too long");
17075 if (feature_name == 0)
17077 errmsg ("missing feature name");
17080 if (vec_len (feature_name) > 63)
17082 errmsg ("feature name too long");
17085 if (sw_if_index == ~0)
17087 errmsg ("missing interface name or sw_if_index");
17091 /* Construct the API message */
17092 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
17093 mp->sw_if_index = ntohl (sw_if_index);
17094 mp->enable = enable;
17095 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17096 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17097 vec_free (arc_name);
17098 vec_free (feature_name);
17105 api_sw_interface_tag_add_del (vat_main_t * vam)
17107 unformat_input_t *i = vam->input;
17108 vl_api_sw_interface_tag_add_del_t *mp;
17110 u32 sw_if_index = ~0;
17114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17116 if (unformat (i, "tag %s", &tag))
17118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17122 else if (unformat (i, "del"))
17128 if (sw_if_index == ~0)
17130 errmsg ("missing interface name or sw_if_index");
17134 if (enable && (tag == 0))
17136 errmsg ("no tag specified");
17140 /* Construct the API message */
17141 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
17142 mp->sw_if_index = ntohl (sw_if_index);
17143 mp->is_add = enable;
17145 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17152 static void vl_api_l2_xconnect_details_t_handler
17153 (vl_api_l2_xconnect_details_t * mp)
17155 vat_main_t *vam = &vat_main;
17157 print (vam->ofp, "%15d%15d",
17158 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17161 static void vl_api_l2_xconnect_details_t_handler_json
17162 (vl_api_l2_xconnect_details_t * mp)
17164 vat_main_t *vam = &vat_main;
17165 vat_json_node_t *node = NULL;
17167 if (VAT_JSON_ARRAY != vam->json_tree.type)
17169 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17170 vat_json_init_array (&vam->json_tree);
17172 node = vat_json_array_add (&vam->json_tree);
17174 vat_json_init_object (node);
17175 vat_json_object_add_uint (node, "rx_sw_if_index",
17176 ntohl (mp->rx_sw_if_index));
17177 vat_json_object_add_uint (node, "tx_sw_if_index",
17178 ntohl (mp->tx_sw_if_index));
17182 api_l2_xconnect_dump (vat_main_t * vam)
17184 vl_api_l2_xconnect_dump_t *mp;
17187 if (!vam->json_output)
17189 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17192 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
17196 /* Use a control ping for synchronization */
17198 vl_api_control_ping_t *mp;
17199 M (CONTROL_PING, control_ping);
17206 api_sw_interface_set_mtu (vat_main_t * vam)
17208 unformat_input_t *i = vam->input;
17209 vl_api_sw_interface_set_mtu_t *mp;
17211 u32 sw_if_index = ~0;
17214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17216 if (unformat (i, "mtu %d", &mtu))
17218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17226 if (sw_if_index == ~0)
17228 errmsg ("missing interface name or sw_if_index");
17234 errmsg ("no mtu specified");
17238 /* Construct the API message */
17239 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17240 mp->sw_if_index = ntohl (sw_if_index);
17241 mp->mtu = ntohs ((u16) mtu);
17249 q_or_quit (vat_main_t * vam)
17251 longjmp (vam->jump_buf, 1);
17252 return 0; /* not so much */
17256 q (vat_main_t * vam)
17258 return q_or_quit (vam);
17262 quit (vat_main_t * vam)
17264 return q_or_quit (vam);
17268 comment (vat_main_t * vam)
17274 cmd_cmp (void *a1, void *a2)
17279 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17283 help (vat_main_t * vam)
17288 unformat_input_t *i = vam->input;
17291 if (unformat (i, "%s", &name))
17295 vec_add1 (name, 0);
17297 hs = hash_get_mem (vam->help_by_name, name);
17299 print (vam->ofp, "usage: %s %s", name, hs[0]);
17301 print (vam->ofp, "No such msg / command '%s'", name);
17306 print (vam->ofp, "Help is available for the following:");
17309 hash_foreach_pair (p, vam->function_by_name,
17311 vec_add1 (cmds, (u8 *)(p->key));
17315 vec_sort_with_function (cmds, cmd_cmp);
17317 for (j = 0; j < vec_len (cmds); j++)
17318 print (vam->ofp, "%s", cmds[j]);
17325 set (vat_main_t * vam)
17327 u8 *name = 0, *value = 0;
17328 unformat_input_t *i = vam->input;
17330 if (unformat (i, "%s", &name))
17332 /* The input buffer is a vector, not a string. */
17333 value = vec_dup (i->buffer);
17334 vec_delete (value, i->index, 0);
17335 /* Almost certainly has a trailing newline */
17336 if (value[vec_len (value) - 1] == '\n')
17337 value[vec_len (value) - 1] = 0;
17338 /* Make sure it's a proper string, one way or the other */
17339 vec_add1 (value, 0);
17340 (void) clib_macro_set_value (&vam->macro_main,
17341 (char *) name, (char *) value);
17344 errmsg ("usage: set <name> <value>");
17352 unset (vat_main_t * vam)
17356 if (unformat (vam->input, "%s", &name))
17357 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17358 errmsg ("unset: %s wasn't set", name);
17371 macro_sort_cmp (void *a1, void *a2)
17373 macro_sort_t *s1 = a1;
17374 macro_sort_t *s2 = a2;
17376 return strcmp ((char *) (s1->name), (char *) (s2->name));
17380 dump_macro_table (vat_main_t * vam)
17382 macro_sort_t *sort_me = 0, *sm;
17387 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17389 vec_add2 (sort_me, sm, 1);
17390 sm->name = (u8 *)(p->key);
17391 sm->value = (u8 *) (p->value[0]);
17395 vec_sort_with_function (sort_me, macro_sort_cmp);
17397 if (vec_len (sort_me))
17398 print (vam->ofp, "%-15s%s", "Name", "Value");
17400 print (vam->ofp, "The macro table is empty...");
17402 for (i = 0; i < vec_len (sort_me); i++)
17403 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17408 dump_node_table (vat_main_t * vam)
17411 vlib_node_t *node, *next_node;
17413 if (vec_len (vam->graph_nodes) == 0)
17415 print (vam->ofp, "Node table empty, issue get_node_graph...");
17419 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17421 node = vam->graph_nodes[i];
17422 print (vam->ofp, "[%d] %s", i, node->name);
17423 for (j = 0; j < vec_len (node->next_nodes); j++)
17425 if (node->next_nodes[j] != ~0)
17427 next_node = vam->graph_nodes[node->next_nodes[j]];
17428 print (vam->ofp, " [%d] %s", j, next_node->name);
17436 value_sort_cmp (void *a1, void *a2)
17438 name_sort_t *n1 = a1;
17439 name_sort_t *n2 = a2;
17441 if (n1->value < n2->value)
17443 if (n1->value > n2->value)
17450 dump_msg_api_table (vat_main_t * vam)
17452 api_main_t *am = &api_main;
17453 name_sort_t *nses = 0, *ns;
17458 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17460 vec_add2 (nses, ns, 1);
17461 ns->name = (u8 *)(hp->key);
17462 ns->value = (u32) hp->value[0];
17466 vec_sort_with_function (nses, value_sort_cmp);
17468 for (i = 0; i < vec_len (nses); i++)
17469 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17475 get_msg_id (vat_main_t * vam)
17480 if (unformat (vam->input, "%s", &name_and_crc))
17482 message_index = vl_api_get_msg_index (name_and_crc);
17483 if (message_index == ~0)
17485 print (vam->ofp, " '%s' not found", name_and_crc);
17488 print (vam->ofp, " '%s' has message index %d",
17489 name_and_crc, message_index);
17492 errmsg ("name_and_crc required...");
17497 search_node_table (vat_main_t * vam)
17499 unformat_input_t *line_input = vam->input;
17502 vlib_node_t *node, *next_node;
17505 if (vam->graph_node_index_by_name == 0)
17507 print (vam->ofp, "Node table empty, issue get_node_graph...");
17511 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17513 if (unformat (line_input, "%s", &node_to_find))
17515 vec_add1 (node_to_find, 0);
17516 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17519 print (vam->ofp, "%s not found...", node_to_find);
17522 node = vam->graph_nodes[p[0]];
17523 print (vam->ofp, "[%d] %s", p[0], node->name);
17524 for (j = 0; j < vec_len (node->next_nodes); j++)
17526 if (node->next_nodes[j] != ~0)
17528 next_node = vam->graph_nodes[node->next_nodes[j]];
17529 print (vam->ofp, " [%d] %s", j, next_node->name);
17536 clib_warning ("parse error '%U'", format_unformat_error,
17542 vec_free (node_to_find);
17551 script (vat_main_t * vam)
17553 #if (VPP_API_TEST_BUILTIN==0)
17555 char *save_current_file;
17556 unformat_input_t save_input;
17557 jmp_buf save_jump_buf;
17558 u32 save_line_number;
17560 FILE *new_fp, *save_ifp;
17562 if (unformat (vam->input, "%s", &s))
17564 new_fp = fopen ((char *) s, "r");
17567 errmsg ("Couldn't open script file %s", s);
17574 errmsg ("Missing script name");
17578 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17579 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17580 save_ifp = vam->ifp;
17581 save_line_number = vam->input_line_number;
17582 save_current_file = (char *) vam->current_file;
17584 vam->input_line_number = 0;
17586 vam->current_file = s;
17589 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17590 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17591 vam->ifp = save_ifp;
17592 vam->input_line_number = save_line_number;
17593 vam->current_file = (u8 *) save_current_file;
17598 clib_warning ("use the exec command...");
17604 echo (vat_main_t * vam)
17606 print (vam->ofp, "%v", vam->input->buffer);
17610 /* List of API message constructors, CLI names map to api_xxx */
17611 #define foreach_vpe_api_msg \
17612 _(create_loopback,"[mac <mac-addr>]") \
17613 _(sw_interface_dump,"") \
17614 _(sw_interface_set_flags, \
17615 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17616 _(sw_interface_add_del_address, \
17617 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17618 _(sw_interface_set_table, \
17619 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17620 _(sw_interface_set_mpls_enable, \
17621 "<intfc> | sw_if_index [disable | dis]") \
17622 _(sw_interface_set_vpath, \
17623 "<intfc> | sw_if_index <id> enable | disable") \
17624 _(sw_interface_set_vxlan_bypass, \
17625 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17626 _(sw_interface_set_l2_xconnect, \
17627 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17628 "enable | disable") \
17629 _(sw_interface_set_l2_bridge, \
17630 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17631 "[shg <split-horizon-group>] [bvi]\n" \
17632 "enable | disable") \
17633 _(bridge_domain_add_del, \
17634 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17635 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17637 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17639 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17641 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17643 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17645 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17647 "<vpp-if-name> | sw_if_index <id>") \
17648 _(sw_interface_tap_dump, "") \
17649 _(ip_add_del_route, \
17650 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17651 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17652 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17653 "[multipath] [count <n>]") \
17654 _(ip_mroute_add_del, \
17655 "<src> <grp>/<mask> [table-id <n>]\n" \
17656 "[<intfc> | sw_if_index <id>] [local] [del]") \
17657 _(mpls_route_add_del, \
17658 "<label> <eos> via <addr> [table-id <n>]\n" \
17659 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17660 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17661 "[multipath] [count <n>]") \
17662 _(mpls_ip_bind_unbind, \
17663 "<label> <addr/len>") \
17664 _(mpls_tunnel_add_del, \
17665 " via <addr> [table-id <n>]\n" \
17666 "sw_if_index <id>] [l2] [del]") \
17667 _(proxy_arp_add_del, \
17668 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17669 _(proxy_arp_intfc_enable_disable, \
17670 "<intfc> | sw_if_index <id> enable | disable") \
17671 _(sw_interface_set_unnumbered, \
17672 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17673 _(ip_neighbor_add_del, \
17674 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17675 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17676 _(reset_vrf, "vrf <id> [ipv6]") \
17677 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17678 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17679 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17680 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17681 "[outer_vlan_id_any][inner_vlan_id_any]") \
17682 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17683 _(reset_fib, "vrf <n> [ipv6]") \
17684 _(dhcp_proxy_config, \
17685 "svr <v46-address> src <v46-address>\n" \
17686 "insert-cid <n> [del]") \
17687 _(dhcp_proxy_config_2, \
17688 "svr <v46-address> src <v46-address>\n" \
17689 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17690 _(dhcp_proxy_set_vss, \
17691 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17692 _(dhcp_client_config, \
17693 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17694 _(set_ip_flow_hash, \
17695 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17696 _(sw_interface_ip6_enable_disable, \
17697 "<intfc> | sw_if_index <id> enable | disable") \
17698 _(sw_interface_ip6_set_link_local_address, \
17699 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17700 _(sw_interface_ip6nd_ra_prefix, \
17701 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17702 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17703 "[nolink] [isno]") \
17704 _(sw_interface_ip6nd_ra_config, \
17705 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17706 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17707 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17708 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17709 _(l2_patch_add_del, \
17710 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17711 "enable | disable") \
17712 _(sr_tunnel_add_del, \
17713 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17714 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17715 "[policy <policy_name>]") \
17716 _(sr_policy_add_del, \
17717 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17718 _(sr_multicast_map_add_del, \
17719 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17720 _(classify_add_del_table, \
17721 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17722 " [del] [del-chain] mask <mask-value>\n" \
17723 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17724 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17725 _(classify_add_del_session, \
17726 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17727 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17728 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17729 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17730 _(classify_set_interface_ip_table, \
17731 "<intfc> | sw_if_index <nn> table <nn>") \
17732 _(classify_set_interface_l2_tables, \
17733 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17734 " [other-table <nn>]") \
17735 _(get_node_index, "node <node-name") \
17736 _(add_node_next, "node <node-name> next <next-node-name>") \
17737 _(l2tpv3_create_tunnel, \
17738 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17739 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17740 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17741 _(l2tpv3_set_tunnel_cookies, \
17742 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17743 "[new_remote_cookie <nn>]\n") \
17744 _(l2tpv3_interface_enable_disable, \
17745 "<intfc> | sw_if_index <nn> enable | disable") \
17746 _(l2tpv3_set_lookup_key, \
17747 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17748 _(sw_if_l2tpv3_tunnel_dump, "") \
17749 _(vxlan_add_del_tunnel, \
17750 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17751 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17752 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17753 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17754 _(gre_add_del_tunnel, \
17755 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17756 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17757 _(l2_fib_clear_table, "") \
17758 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17759 _(l2_interface_vlan_tag_rewrite, \
17760 "<intfc> | sw_if_index <nn> \n" \
17761 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17762 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17763 _(create_vhost_user_if, \
17764 "socket <filename> [server] [renumber <dev_instance>] " \
17765 "[mac <mac_address>]") \
17766 _(modify_vhost_user_if, \
17767 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17768 "[server] [renumber <dev_instance>]") \
17769 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17770 _(sw_interface_vhost_user_dump, "") \
17771 _(show_version, "") \
17772 _(vxlan_gpe_add_del_tunnel, \
17773 "local <addr> remote <addr> vni <nn>\n" \
17774 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17775 "[next-ethernet] [next-nsh]\n") \
17776 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17777 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17778 _(interface_name_renumber, \
17779 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17780 _(input_acl_set_interface, \
17781 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17782 " [l2-table <nn>] [del]") \
17783 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17784 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17785 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17786 _(ip_dump, "ipv4 | ipv6") \
17787 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17788 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17790 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17791 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17792 " integ_alg <alg> integ_key <hex>") \
17793 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17794 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17795 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17796 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17797 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17798 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17799 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17800 "(auth_data 0x<data> | auth_data <data>)") \
17801 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17802 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17803 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17804 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17805 "(local|remote)") \
17806 _(ikev2_set_local_key, "file <absolute_file_path>") \
17807 _(delete_loopback,"sw_if_index <nn>") \
17808 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17809 _(map_add_domain, \
17810 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17811 "ip6-src <ip6addr> " \
17812 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17813 _(map_del_domain, "index <n>") \
17814 _(map_add_del_rule, \
17815 "index <n> psid <n> dst <ip6addr> [del]") \
17816 _(map_domain_dump, "") \
17817 _(map_rule_dump, "index <map-domain>") \
17818 _(want_interface_events, "enable|disable") \
17819 _(want_stats,"enable|disable") \
17820 _(get_first_msg_id, "client <name>") \
17821 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17822 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17823 "fib-id <nn> [ip4][ip6][default]") \
17824 _(get_node_graph, " ") \
17825 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17826 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17827 _(ioam_disable, "") \
17828 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17829 " sw_if_index <sw_if_index> p <priority> " \
17830 "w <weight>] [del]") \
17831 _(lisp_add_del_locator, "locator-set <locator_name> " \
17832 "iface <intf> | sw_if_index <sw_if_index> " \
17833 "p <priority> w <weight> [del]") \
17834 _(lisp_add_del_local_eid,"vni <vni> eid " \
17835 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17836 "locator-set <locator_name> [del]" \
17837 "[key-id sha1|sha256 secret-key <secret-key>]") \
17838 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
17839 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
17840 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17841 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17842 _(lisp_gpe_enable_disable, "enable|disable") \
17843 _(lisp_enable_disable, "enable|disable") \
17844 _(lisp_map_register_enable_disable, "enable|disable") \
17845 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17846 _(lisp_gpe_add_del_iface, "up|down") \
17847 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17849 "rloc <locator> p <prio> " \
17850 "w <weight> [rloc <loc> ... ] " \
17851 "action <action> [del-all]") \
17852 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17854 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17855 _(lisp_map_request_mode, "src-dst|dst-only") \
17856 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17857 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17858 _(lisp_locator_set_dump, "[local | remote]") \
17859 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17860 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17861 "[local] | [remote]") \
17862 _(lisp_eid_table_vni_dump, "") \
17863 _(lisp_eid_table_map_dump, "l2|l3") \
17864 _(lisp_map_resolver_dump, "") \
17865 _(lisp_map_server_dump, "") \
17866 _(lisp_adjacencies_get, "vni <vni>") \
17867 _(show_lisp_rloc_probe_state, "") \
17868 _(show_lisp_map_register_state, "") \
17869 _(show_lisp_status, "") \
17870 _(lisp_get_map_request_itr_rlocs, "") \
17871 _(show_lisp_pitr, "") \
17872 _(show_lisp_map_request_mode, "") \
17873 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17874 _(af_packet_delete, "name <host interface name>") \
17875 _(policer_add_del, "name <policer name> <params> [del]") \
17876 _(policer_dump, "[name <policer name>]") \
17877 _(policer_classify_set_interface, \
17878 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17879 " [l2-table <nn>] [del]") \
17880 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17881 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17882 "[master|slave]") \
17883 _(netmap_delete, "name <interface name>") \
17884 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17885 _(mpls_fib_dump, "") \
17886 _(classify_table_ids, "") \
17887 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17888 _(classify_table_info, "table_id <nn>") \
17889 _(classify_session_dump, "table_id <nn>") \
17890 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17891 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17892 "[template_interval <nn>] [udp_checksum]") \
17893 _(ipfix_exporter_dump, "") \
17894 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17895 _(ipfix_classify_stream_dump, "") \
17896 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17897 _(ipfix_classify_table_dump, "") \
17898 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17899 _(sw_interface_span_dump, "") \
17900 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17901 _(pg_create_interface, "if_id <nn>") \
17902 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17903 _(pg_enable_disable, "[stream <id>] disable") \
17904 _(ip_source_and_port_range_check_add_del, \
17905 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17906 _(ip_source_and_port_range_check_interface_add_del, \
17907 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17908 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17909 _(ipsec_gre_add_del_tunnel, \
17910 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17911 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17912 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17913 _(l2_interface_pbb_tag_rewrite, \
17914 "<intfc> | sw_if_index <nn> \n" \
17915 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17916 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17917 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17918 _(flow_classify_set_interface, \
17919 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17920 _(flow_classify_dump, "type [ip4|ip6]") \
17921 _(ip_fib_dump, "") \
17922 _(ip6_fib_dump, "") \
17923 _(feature_enable_disable, "arc_name <arc_name> " \
17924 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17925 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17927 _(l2_xconnect_dump, "") \
17928 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17929 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17930 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17933 #define foreach_vpe_dpdk_api_msg \
17934 _(sw_interface_set_dpdk_hqos_pipe, \
17935 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17936 "profile <profile-id>\n") \
17937 _(sw_interface_set_dpdk_hqos_subport, \
17938 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17939 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17940 _(sw_interface_set_dpdk_hqos_tctbl, \
17941 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
17944 /* List of command functions, CLI names map directly to functions */
17945 #define foreach_cli_function \
17946 _(comment, "usage: comment <ignore-rest-of-line>") \
17947 _(dump_interface_table, "usage: dump_interface_table") \
17948 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17949 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17950 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17951 _(dump_stats_table, "usage: dump_stats_table") \
17952 _(dump_macro_table, "usage: dump_macro_table ") \
17953 _(dump_node_table, "usage: dump_node_table") \
17954 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17955 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17956 _(echo, "usage: echo <message>") \
17957 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17958 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17959 _(help, "usage: help") \
17960 _(q, "usage: quit") \
17961 _(quit, "usage: quit") \
17962 _(search_node_table, "usage: search_node_table <name>...") \
17963 _(set, "usage: set <variable-name> <value>") \
17964 _(script, "usage: script <file-name>") \
17965 _(unset, "usage: unset <variable-name>")
17968 static void vl_api_##n##_t_handler_uni \
17969 (vl_api_##n##_t * mp) \
17971 vat_main_t * vam = &vat_main; \
17972 if (vam->json_output) { \
17973 vl_api_##n##_t_handler_json(mp); \
17975 vl_api_##n##_t_handler(mp); \
17978 foreach_vpe_api_reply_msg;
17983 static void vl_api_##n##_t_handler_uni \
17984 (vl_api_##n##_t * mp) \
17986 vat_main_t * vam = &vat_main; \
17987 if (vam->json_output) { \
17988 vl_api_##n##_t_handler_json(mp); \
17990 vl_api_##n##_t_handler(mp); \
17993 foreach_vpe_dpdk_api_reply_msg;
17998 vat_api_hookup (vat_main_t * vam)
18001 vl_msg_api_set_handlers(VL_API_##N, #n, \
18002 vl_api_##n##_t_handler_uni, \
18004 vl_api_##n##_t_endian, \
18005 vl_api_##n##_t_print, \
18006 sizeof(vl_api_##n##_t), 1);
18007 foreach_vpe_api_reply_msg;
18012 vl_msg_api_set_handlers(VL_API_##N, #n, \
18013 vl_api_##n##_t_handler_uni, \
18015 vl_api_##n##_t_endian, \
18016 vl_api_##n##_t_print, \
18017 sizeof(vl_api_##n##_t), 1);
18018 foreach_vpe_dpdk_api_reply_msg;
18022 #if (VPP_API_TEST_BUILTIN==0)
18023 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18026 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18028 vam->function_by_name = hash_create_string (0, sizeof (uword));
18030 vam->help_by_name = hash_create_string (0, sizeof (uword));
18032 /* API messages we can send */
18033 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18034 foreach_vpe_api_msg;
18037 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18038 foreach_vpe_dpdk_api_msg;
18043 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18044 foreach_vpe_api_msg;
18047 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18048 foreach_vpe_dpdk_api_msg;
18052 /* CLI functions */
18053 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18054 foreach_cli_function;
18058 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18059 foreach_cli_function;
18064 * fd.io coding-style-patch-verification: ON
18067 * eval: (c-set-style "gnu")