2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
53 #include "vat/json_format.h"
58 #define vl_typedefs /* define message structures */
59 #include <vpp/api/vpe_all_api_h.h>
62 /* declare message handlers for each api */
64 #define vl_endianfun /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* instantiate all the print functions we know about */
69 #define vl_print(handle, ...)
71 #include <vpp/api/vpe_all_api_h.h>
74 #define __plugin_msg_base 0
75 #include <vlibapi/vat_helper_macros.h>
78 vat_time_now (vat_main_t * vam)
80 #if VPP_API_TEST_BUILTIN
81 return vlib_time_now (vam->vlib_main);
83 return clib_time_now (&vam->clib_time);
88 errmsg (char *fmt, ...)
90 vat_main_t *vam = &vat_main;
95 s = va_format (0, fmt, &va);
100 #if VPP_API_TEST_BUILTIN
101 vlib_cli_output (vam->vlib_main, (char *) s);
104 if (vam->ifp != stdin)
105 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
106 vam->input_line_number);
107 fformat (vam->ofp, (char *) s);
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 #if VPP_API_TEST_BUILTIN == 0
134 /* Parse an IP4 address %d.%d.%d.%d. */
136 unformat_ip4_address (unformat_input_t * input, va_list * args)
138 u8 *result = va_arg (*args, u8 *);
141 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
144 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
156 unformat_ethernet_address (unformat_input_t * input, va_list * args)
158 u8 *result = va_arg (*args, u8 *);
161 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
162 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
166 for (i = 0; i < 6; i++)
167 if (a[i] >= (1 << 8))
170 for (i = 0; i < 6; i++)
176 /* Returns ethernet type as an int in host byte order. */
178 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
181 u16 *result = va_arg (*args, u16 *);
185 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
187 if (type >= (1 << 16))
195 /* Parse an IP6 address. */
197 unformat_ip6_address (unformat_input_t * input, va_list * args)
199 ip6_address_t *result = va_arg (*args, ip6_address_t *);
201 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
202 uword c, n_colon, double_colon_index;
204 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
205 double_colon_index = ARRAY_LEN (hex_quads);
206 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
209 if (c >= '0' && c <= '9')
211 else if (c >= 'a' && c <= 'f')
212 hex_digit = c + 10 - 'a';
213 else if (c >= 'A' && c <= 'F')
214 hex_digit = c + 10 - 'A';
215 else if (c == ':' && n_colon < 2)
219 unformat_put_input (input);
223 /* Too many hex quads. */
224 if (n_hex_quads >= ARRAY_LEN (hex_quads))
229 hex_quad = (hex_quad << 4) | hex_digit;
231 /* Hex quad must fit in 16 bits. */
232 if (n_hex_digits >= 4)
239 /* Save position of :: */
242 /* More than one :: ? */
243 if (double_colon_index < ARRAY_LEN (hex_quads))
245 double_colon_index = n_hex_quads;
248 if (n_colon > 0 && n_hex_digits > 0)
250 hex_quads[n_hex_quads++] = hex_quad;
256 if (n_hex_digits > 0)
257 hex_quads[n_hex_quads++] = hex_quad;
262 /* Expand :: to appropriate number of zero hex quads. */
263 if (double_colon_index < ARRAY_LEN (hex_quads))
265 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
267 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
268 hex_quads[n_zero + i] = hex_quads[i];
270 for (i = 0; i < n_zero; i++)
271 hex_quads[double_colon_index + i] = 0;
273 n_hex_quads = ARRAY_LEN (hex_quads);
276 /* Too few hex quads given. */
277 if (n_hex_quads < ARRAY_LEN (hex_quads))
280 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
281 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
288 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
290 u32 *r = va_arg (*args, u32 *);
293 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
294 foreach_ipsec_policy_action
302 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
304 u32 *r = va_arg (*args, u32 *);
307 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
308 foreach_ipsec_crypto_alg
316 format_ipsec_crypto_alg (u8 * s, va_list * args)
318 u32 i = va_arg (*args, u32);
323 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
324 foreach_ipsec_crypto_alg
327 return format (s, "unknown");
329 return format (s, "%s", t);
333 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
339 foreach_ipsec_integ_alg
347 format_ipsec_integ_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_integ_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
370 foreach_ikev2_auth_method
378 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
380 u32 *r = va_arg (*args, u32 *);
383 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
384 foreach_ikev2_id_type
390 #endif /* VPP_API_TEST_BUILTIN */
393 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
395 u8 *r = va_arg (*args, u8 *);
397 if (unformat (input, "kbps"))
398 *r = SSE2_QOS_RATE_KBPS;
399 else if (unformat (input, "pps"))
400 *r = SSE2_QOS_RATE_PPS;
407 unformat_policer_round_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "closest"))
412 *r = SSE2_QOS_ROUND_TO_CLOSEST;
413 else if (unformat (input, "up"))
414 *r = SSE2_QOS_ROUND_TO_UP;
415 else if (unformat (input, "down"))
416 *r = SSE2_QOS_ROUND_TO_DOWN;
423 unformat_policer_type (unformat_input_t * input, va_list * args)
425 u8 *r = va_arg (*args, u8 *);
427 if (unformat (input, "1r2c"))
428 *r = SSE2_QOS_POLICER_TYPE_1R2C;
429 else if (unformat (input, "1r3c"))
430 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
431 else if (unformat (input, "2r3c-2698"))
432 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
433 else if (unformat (input, "2r3c-4115"))
434 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
435 else if (unformat (input, "2r3c-mef5cf1"))
436 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
443 unformat_dscp (unformat_input_t * input, va_list * va)
445 u8 *r = va_arg (*va, u8 *);
448 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
457 unformat_policer_action_type (unformat_input_t * input, va_list * va)
459 sse2_qos_pol_action_params_st *a
460 = va_arg (*va, sse2_qos_pol_action_params_st *);
462 if (unformat (input, "drop"))
463 a->action_type = SSE2_QOS_ACTION_DROP;
464 else if (unformat (input, "transmit"))
465 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
466 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
467 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
474 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
476 u32 *r = va_arg (*va, u32 *);
479 if (unformat (input, "ip4"))
480 tid = POLICER_CLASSIFY_TABLE_IP4;
481 else if (unformat (input, "ip6"))
482 tid = POLICER_CLASSIFY_TABLE_IP6;
483 else if (unformat (input, "l2"))
484 tid = POLICER_CLASSIFY_TABLE_L2;
493 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
495 u32 *r = va_arg (*va, u32 *);
498 if (unformat (input, "ip4"))
499 tid = FLOW_CLASSIFY_TABLE_IP4;
500 else if (unformat (input, "ip6"))
501 tid = FLOW_CLASSIFY_TABLE_IP6;
509 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
510 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
511 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
512 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
515 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
517 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
518 mfib_itf_attribute_t attr;
521 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
523 if (unformat (input, mfib_itf_flag_long_names[attr]))
524 *iflags |= (1 << attr);
526 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
528 if (unformat (input, mfib_itf_flag_names[attr]))
529 *iflags |= (1 << attr);
532 return (old == *iflags ? 0 : 1);
536 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
538 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
539 mfib_entry_attribute_t attr;
542 FOR_EACH_MFIB_ATTRIBUTE (attr)
544 if (unformat (input, mfib_flag_long_names[attr]))
545 *eflags |= (1 << attr);
547 FOR_EACH_MFIB_ATTRIBUTE (attr)
549 if (unformat (input, mfib_flag_names[attr]))
550 *eflags |= (1 << attr);
553 return (old == *eflags ? 0 : 1);
556 #if (VPP_API_TEST_BUILTIN==0)
558 format_ip4_address (u8 * s, va_list * args)
560 u8 *a = va_arg (*args, u8 *);
561 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
565 format_ip6_address (u8 * s, va_list * args)
567 ip6_address_t *a = va_arg (*args, ip6_address_t *);
568 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
570 i_max_n_zero = ARRAY_LEN (a->as_u16);
572 i_first_zero = i_max_n_zero;
574 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
576 u32 is_zero = a->as_u16[i] == 0;
577 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
583 if ((!is_zero && n_zeros > max_n_zeros)
584 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
586 i_max_n_zero = i_first_zero;
587 max_n_zeros = n_zeros;
588 i_first_zero = ARRAY_LEN (a->as_u16);
593 last_double_colon = 0;
594 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
596 if (i == i_max_n_zero && max_n_zeros > 1)
598 s = format (s, "::");
599 i += max_n_zeros - 1;
600 last_double_colon = 1;
604 s = format (s, "%s%x",
605 (last_double_colon || i == 0) ? "" : ":",
606 clib_net_to_host_u16 (a->as_u16[i]));
607 last_double_colon = 0;
614 /* Format an IP46 address. */
616 format_ip46_address (u8 * s, va_list * args)
618 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
619 ip46_type_t type = va_arg (*args, ip46_type_t);
625 is_ip4 = ip46_address_is_ip4 (ip46);
636 format (s, "%U", format_ip4_address, &ip46->ip4) :
637 format (s, "%U", format_ip6_address, &ip46->ip6);
641 format_ethernet_address (u8 * s, va_list * args)
643 u8 *a = va_arg (*args, u8 *);
645 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
646 a[0], a[1], a[2], a[3], a[4], a[5]);
651 increment_v4_address (ip4_address_t * a)
655 v = ntohl (a->as_u32) + 1;
656 a->as_u32 = ntohl (v);
660 increment_v6_address (ip6_address_t * a)
664 v0 = clib_net_to_host_u64 (a->as_u64[0]);
665 v1 = clib_net_to_host_u64 (a->as_u64[1]);
670 a->as_u64[0] = clib_net_to_host_u64 (v0);
671 a->as_u64[1] = clib_net_to_host_u64 (v1);
675 increment_mac_address (u64 * mac)
679 tmp = clib_net_to_host_u64 (tmp);
680 tmp += 1 << 16; /* skip unused (least significant) octets */
681 tmp = clib_host_to_net_u64 (tmp);
685 static void vl_api_create_loopback_reply_t_handler
686 (vl_api_create_loopback_reply_t * mp)
688 vat_main_t *vam = &vat_main;
689 i32 retval = ntohl (mp->retval);
691 vam->retval = retval;
692 vam->regenerate_interface_table = 1;
693 vam->sw_if_index = ntohl (mp->sw_if_index);
694 vam->result_ready = 1;
697 static void vl_api_create_loopback_reply_t_handler_json
698 (vl_api_create_loopback_reply_t * mp)
700 vat_main_t *vam = &vat_main;
701 vat_json_node_t node;
703 vat_json_init_object (&node);
704 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
705 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
707 vat_json_print (vam->ofp, &node);
708 vat_json_free (&node);
709 vam->retval = ntohl (mp->retval);
710 vam->result_ready = 1;
713 static void vl_api_af_packet_create_reply_t_handler
714 (vl_api_af_packet_create_reply_t * mp)
716 vat_main_t *vam = &vat_main;
717 i32 retval = ntohl (mp->retval);
719 vam->retval = retval;
720 vam->regenerate_interface_table = 1;
721 vam->sw_if_index = ntohl (mp->sw_if_index);
722 vam->result_ready = 1;
725 static void vl_api_af_packet_create_reply_t_handler_json
726 (vl_api_af_packet_create_reply_t * mp)
728 vat_main_t *vam = &vat_main;
729 vat_json_node_t node;
731 vat_json_init_object (&node);
732 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
733 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
735 vat_json_print (vam->ofp, &node);
736 vat_json_free (&node);
738 vam->retval = ntohl (mp->retval);
739 vam->result_ready = 1;
742 static void vl_api_create_vlan_subif_reply_t_handler
743 (vl_api_create_vlan_subif_reply_t * mp)
745 vat_main_t *vam = &vat_main;
746 i32 retval = ntohl (mp->retval);
748 vam->retval = retval;
749 vam->regenerate_interface_table = 1;
750 vam->sw_if_index = ntohl (mp->sw_if_index);
751 vam->result_ready = 1;
754 static void vl_api_create_vlan_subif_reply_t_handler_json
755 (vl_api_create_vlan_subif_reply_t * mp)
757 vat_main_t *vam = &vat_main;
758 vat_json_node_t node;
760 vat_json_init_object (&node);
761 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
762 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
764 vat_json_print (vam->ofp, &node);
765 vat_json_free (&node);
767 vam->retval = ntohl (mp->retval);
768 vam->result_ready = 1;
771 static void vl_api_create_subif_reply_t_handler
772 (vl_api_create_subif_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 i32 retval = ntohl (mp->retval);
777 vam->retval = retval;
778 vam->regenerate_interface_table = 1;
779 vam->sw_if_index = ntohl (mp->sw_if_index);
780 vam->result_ready = 1;
783 static void vl_api_create_subif_reply_t_handler_json
784 (vl_api_create_subif_reply_t * mp)
786 vat_main_t *vam = &vat_main;
787 vat_json_node_t node;
789 vat_json_init_object (&node);
790 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
791 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
793 vat_json_print (vam->ofp, &node);
794 vat_json_free (&node);
796 vam->retval = ntohl (mp->retval);
797 vam->result_ready = 1;
800 static void vl_api_interface_name_renumber_reply_t_handler
801 (vl_api_interface_name_renumber_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 i32 retval = ntohl (mp->retval);
806 vam->retval = retval;
807 vam->regenerate_interface_table = 1;
808 vam->result_ready = 1;
811 static void vl_api_interface_name_renumber_reply_t_handler_json
812 (vl_api_interface_name_renumber_reply_t * mp)
814 vat_main_t *vam = &vat_main;
815 vat_json_node_t node;
817 vat_json_init_object (&node);
818 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
820 vat_json_print (vam->ofp, &node);
821 vat_json_free (&node);
823 vam->retval = ntohl (mp->retval);
824 vam->result_ready = 1;
828 * Special-case: build the interface table, maintain
829 * the next loopback sw_if_index vbl.
831 static void vl_api_sw_interface_details_t_handler
832 (vl_api_sw_interface_details_t * mp)
834 vat_main_t *vam = &vat_main;
835 u8 *s = format (0, "%s%c", mp->interface_name, 0);
837 hash_set_mem (vam->sw_if_index_by_interface_name, s,
838 ntohl (mp->sw_if_index));
840 /* In sub interface case, fill the sub interface table entry */
841 if (mp->sw_if_index != mp->sup_sw_if_index)
843 sw_interface_subif_t *sub = NULL;
845 vec_add2 (vam->sw_if_subif_table, sub, 1);
847 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
848 strncpy ((char *) sub->interface_name, (char *) s,
849 vec_len (sub->interface_name));
850 sub->sw_if_index = ntohl (mp->sw_if_index);
851 sub->sub_id = ntohl (mp->sub_id);
853 sub->sub_dot1ad = mp->sub_dot1ad;
854 sub->sub_number_of_tags = mp->sub_number_of_tags;
855 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
856 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
857 sub->sub_exact_match = mp->sub_exact_match;
858 sub->sub_default = mp->sub_default;
859 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
860 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
862 /* vlan tag rewrite */
863 sub->vtr_op = ntohl (mp->vtr_op);
864 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
865 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
866 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
870 static void vl_api_sw_interface_details_t_handler_json
871 (vl_api_sw_interface_details_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t *node = NULL;
876 if (VAT_JSON_ARRAY != vam->json_tree.type)
878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
879 vat_json_init_array (&vam->json_tree);
881 node = vat_json_array_add (&vam->json_tree);
883 vat_json_init_object (node);
884 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
885 vat_json_object_add_uint (node, "sup_sw_if_index",
886 ntohl (mp->sup_sw_if_index));
887 vat_json_object_add_uint (node, "l2_address_length",
888 ntohl (mp->l2_address_length));
889 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
890 sizeof (mp->l2_address));
891 vat_json_object_add_string_copy (node, "interface_name",
893 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
894 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
895 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
896 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
897 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
898 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
899 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
900 vat_json_object_add_uint (node, "sub_number_of_tags",
901 mp->sub_number_of_tags);
902 vat_json_object_add_uint (node, "sub_outer_vlan_id",
903 ntohs (mp->sub_outer_vlan_id));
904 vat_json_object_add_uint (node, "sub_inner_vlan_id",
905 ntohs (mp->sub_inner_vlan_id));
906 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
907 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
908 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
909 mp->sub_outer_vlan_id_any);
910 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
911 mp->sub_inner_vlan_id_any);
912 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
913 vat_json_object_add_uint (node, "vtr_push_dot1q",
914 ntohl (mp->vtr_push_dot1q));
915 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
916 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
919 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
921 format_ethernet_address,
923 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
925 format_ethernet_address,
927 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
928 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
932 static void vl_api_sw_interface_set_flags_t_handler
933 (vl_api_sw_interface_set_flags_t * mp)
935 vat_main_t *vam = &vat_main;
936 if (vam->interface_event_display)
937 errmsg ("interface flags: sw_if_index %d %s %s",
938 ntohl (mp->sw_if_index),
939 mp->admin_up_down ? "admin-up" : "admin-down",
940 mp->link_up_down ? "link-up" : "link-down");
943 static void vl_api_sw_interface_set_flags_t_handler_json
944 (vl_api_sw_interface_set_flags_t * mp)
946 /* JSON output not supported */
950 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
952 vat_main_t *vam = &vat_main;
953 i32 retval = ntohl (mp->retval);
955 vam->retval = retval;
956 vam->shmem_result = (u8 *) mp->reply_in_shmem;
957 vam->result_ready = 1;
961 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
963 vat_main_t *vam = &vat_main;
964 vat_json_node_t node;
965 api_main_t *am = &api_main;
969 vat_json_init_object (&node);
970 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
971 vat_json_object_add_uint (&node, "reply_in_shmem",
972 ntohl (mp->reply_in_shmem));
973 /* Toss the shared-memory original... */
974 pthread_mutex_lock (&am->vlib_rp->mutex);
975 oldheap = svm_push_data_heap (am->vlib_rp);
977 reply = (u8 *) (mp->reply_in_shmem);
980 svm_pop_heap (oldheap);
981 pthread_mutex_unlock (&am->vlib_rp->mutex);
983 vat_json_print (vam->ofp, &node);
984 vat_json_free (&node);
986 vam->retval = ntohl (mp->retval);
987 vam->result_ready = 1;
991 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
993 vat_main_t *vam = &vat_main;
994 i32 retval = ntohl (mp->retval);
996 vam->retval = retval;
997 vam->cmd_reply = mp->reply;
998 vam->result_ready = 1;
1002 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1004 vat_main_t *vam = &vat_main;
1005 vat_json_node_t node;
1007 vat_json_init_object (&node);
1008 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1009 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1011 vat_json_print (vam->ofp, &node);
1012 vat_json_free (&node);
1014 vam->retval = ntohl (mp->retval);
1015 vam->result_ready = 1;
1018 static void vl_api_classify_add_del_table_reply_t_handler
1019 (vl_api_classify_add_del_table_reply_t * mp)
1021 vat_main_t *vam = &vat_main;
1022 i32 retval = ntohl (mp->retval);
1023 if (vam->async_mode)
1025 vam->async_errors += (retval < 0);
1029 vam->retval = retval;
1031 ((mp->new_table_index != 0xFFFFFFFF) ||
1032 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1033 (mp->match_n_vectors != 0xFFFFFFFF)))
1035 * Note: this is just barely thread-safe, depends on
1036 * the main thread spinning waiting for an answer...
1038 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1039 ntohl (mp->new_table_index),
1040 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1041 vam->result_ready = 1;
1045 static void vl_api_classify_add_del_table_reply_t_handler_json
1046 (vl_api_classify_add_del_table_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_uint (&node, "new_table_index",
1054 ntohl (mp->new_table_index));
1055 vat_json_object_add_uint (&node, "skip_n_vectors",
1056 ntohl (mp->skip_n_vectors));
1057 vat_json_object_add_uint (&node, "match_n_vectors",
1058 ntohl (mp->match_n_vectors));
1060 vat_json_print (vam->ofp, &node);
1061 vat_json_free (&node);
1063 vam->retval = ntohl (mp->retval);
1064 vam->result_ready = 1;
1067 static void vl_api_get_node_index_reply_t_handler
1068 (vl_api_get_node_index_reply_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 i32 retval = ntohl (mp->retval);
1072 if (vam->async_mode)
1074 vam->async_errors += (retval < 0);
1078 vam->retval = retval;
1080 errmsg ("node index %d", ntohl (mp->node_index));
1081 vam->result_ready = 1;
1085 static void vl_api_get_node_index_reply_t_handler_json
1086 (vl_api_get_node_index_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vat_json_init_object (&node);
1092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1093 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1095 vat_json_print (vam->ofp, &node);
1096 vat_json_free (&node);
1098 vam->retval = ntohl (mp->retval);
1099 vam->result_ready = 1;
1102 static void vl_api_get_next_index_reply_t_handler
1103 (vl_api_get_next_index_reply_t * mp)
1105 vat_main_t *vam = &vat_main;
1106 i32 retval = ntohl (mp->retval);
1107 if (vam->async_mode)
1109 vam->async_errors += (retval < 0);
1113 vam->retval = retval;
1115 errmsg ("next node index %d", ntohl (mp->next_index));
1116 vam->result_ready = 1;
1120 static void vl_api_get_next_index_reply_t_handler_json
1121 (vl_api_get_next_index_reply_t * mp)
1123 vat_main_t *vam = &vat_main;
1124 vat_json_node_t node;
1126 vat_json_init_object (&node);
1127 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1128 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1130 vat_json_print (vam->ofp, &node);
1131 vat_json_free (&node);
1133 vam->retval = ntohl (mp->retval);
1134 vam->result_ready = 1;
1137 static void vl_api_add_node_next_reply_t_handler
1138 (vl_api_add_node_next_reply_t * mp)
1140 vat_main_t *vam = &vat_main;
1141 i32 retval = ntohl (mp->retval);
1142 if (vam->async_mode)
1144 vam->async_errors += (retval < 0);
1148 vam->retval = retval;
1150 errmsg ("next index %d", ntohl (mp->next_index));
1151 vam->result_ready = 1;
1155 static void vl_api_add_node_next_reply_t_handler_json
1156 (vl_api_add_node_next_reply_t * mp)
1158 vat_main_t *vam = &vat_main;
1159 vat_json_node_t node;
1161 vat_json_init_object (&node);
1162 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1163 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1165 vat_json_print (vam->ofp, &node);
1166 vat_json_free (&node);
1168 vam->retval = ntohl (mp->retval);
1169 vam->result_ready = 1;
1172 static void vl_api_show_version_reply_t_handler
1173 (vl_api_show_version_reply_t * mp)
1175 vat_main_t *vam = &vat_main;
1176 i32 retval = ntohl (mp->retval);
1180 errmsg (" program: %s", mp->program);
1181 errmsg (" version: %s", mp->version);
1182 errmsg (" build date: %s", mp->build_date);
1183 errmsg ("build directory: %s", mp->build_directory);
1185 vam->retval = retval;
1186 vam->result_ready = 1;
1189 static void vl_api_show_version_reply_t_handler_json
1190 (vl_api_show_version_reply_t * mp)
1192 vat_main_t *vam = &vat_main;
1193 vat_json_node_t node;
1195 vat_json_init_object (&node);
1196 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1197 vat_json_object_add_string_copy (&node, "program", mp->program);
1198 vat_json_object_add_string_copy (&node, "version", mp->version);
1199 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1200 vat_json_object_add_string_copy (&node, "build_directory",
1201 mp->build_directory);
1203 vat_json_print (vam->ofp, &node);
1204 vat_json_free (&node);
1206 vam->retval = ntohl (mp->retval);
1207 vam->result_ready = 1;
1211 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1213 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1214 mp->mac_ip ? "mac/ip binding" : "address resolution",
1215 format_ip4_address, &mp->address,
1216 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1220 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1222 /* JSON output not supported */
1226 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1228 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1229 mp->mac_ip ? "mac/ip binding" : "address resolution",
1230 format_ip6_address, mp->address,
1231 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1235 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1237 /* JSON output not supported */
1241 * Special-case: build the bridge domain table, maintain
1242 * the next bd id vbl.
1244 static void vl_api_bridge_domain_details_t_handler
1245 (vl_api_bridge_domain_details_t * mp)
1247 vat_main_t *vam = &vat_main;
1248 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1250 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1251 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1253 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1254 ntohl (mp->bd_id), mp->learn, mp->forward,
1255 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1258 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1261 static void vl_api_bridge_domain_details_t_handler_json
1262 (vl_api_bridge_domain_details_t * mp)
1264 vat_main_t *vam = &vat_main;
1265 vat_json_node_t *node, *array = NULL;
1267 if (VAT_JSON_ARRAY != vam->json_tree.type)
1269 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1270 vat_json_init_array (&vam->json_tree);
1272 node = vat_json_array_add (&vam->json_tree);
1274 vat_json_init_object (node);
1275 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1276 vat_json_object_add_uint (node, "flood", mp->flood);
1277 vat_json_object_add_uint (node, "forward", mp->forward);
1278 vat_json_object_add_uint (node, "learn", mp->learn);
1279 vat_json_object_add_uint (node, "bvi_sw_if_index",
1280 ntohl (mp->bvi_sw_if_index));
1281 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1282 array = vat_json_object_add (node, "sw_if");
1283 vat_json_init_array (array);
1287 * Special-case: build the bridge domain sw if table.
1289 static void vl_api_bridge_domain_sw_if_details_t_handler
1290 (vl_api_bridge_domain_sw_if_details_t * mp)
1292 vat_main_t *vam = &vat_main;
1297 sw_if_index = ntohl (mp->sw_if_index);
1299 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1301 if ((u32) p->value[0] == sw_if_index)
1303 sw_if_name = (u8 *)(p->key);
1309 print (vam->ofp, "%7d %3d %s", sw_if_index,
1310 mp->shg, sw_if_name ? (char *) sw_if_name :
1311 "sw_if_index not found!");
1314 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1315 (vl_api_bridge_domain_sw_if_details_t * mp)
1317 vat_main_t *vam = &vat_main;
1318 vat_json_node_t *node = NULL;
1319 uword last_index = 0;
1321 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1322 ASSERT (vec_len (vam->json_tree.array) >= 1);
1323 last_index = vec_len (vam->json_tree.array) - 1;
1324 node = &vam->json_tree.array[last_index];
1325 node = vat_json_object_get_element (node, "sw_if");
1326 ASSERT (NULL != node);
1327 node = vat_json_array_add (node);
1329 vat_json_init_object (node);
1330 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1331 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1332 vat_json_object_add_uint (node, "shg", mp->shg);
1335 static void vl_api_control_ping_reply_t_handler
1336 (vl_api_control_ping_reply_t * mp)
1338 vat_main_t *vam = &vat_main;
1339 i32 retval = ntohl (mp->retval);
1340 if (vam->async_mode)
1342 vam->async_errors += (retval < 0);
1346 vam->retval = retval;
1347 vam->result_ready = 1;
1351 static void vl_api_control_ping_reply_t_handler_json
1352 (vl_api_control_ping_reply_t * mp)
1354 vat_main_t *vam = &vat_main;
1355 i32 retval = ntohl (mp->retval);
1357 if (VAT_JSON_NONE != vam->json_tree.type)
1359 vat_json_print (vam->ofp, &vam->json_tree);
1360 vat_json_free (&vam->json_tree);
1361 vam->json_tree.type = VAT_JSON_NONE;
1366 vat_json_init_array (&vam->json_tree);
1367 vat_json_print (vam->ofp, &vam->json_tree);
1368 vam->json_tree.type = VAT_JSON_NONE;
1371 vam->retval = retval;
1372 vam->result_ready = 1;
1376 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1378 vat_main_t *vam = &vat_main;
1379 i32 retval = ntohl (mp->retval);
1380 if (vam->async_mode)
1382 vam->async_errors += (retval < 0);
1386 vam->retval = retval;
1387 vam->result_ready = 1;
1391 static void vl_api_l2_flags_reply_t_handler_json
1392 (vl_api_l2_flags_reply_t * mp)
1394 vat_main_t *vam = &vat_main;
1395 vat_json_node_t node;
1397 vat_json_init_object (&node);
1398 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1399 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1400 ntohl (mp->resulting_feature_bitmap));
1402 vat_json_print (vam->ofp, &node);
1403 vat_json_free (&node);
1405 vam->retval = ntohl (mp->retval);
1406 vam->result_ready = 1;
1409 static void vl_api_bridge_flags_reply_t_handler
1410 (vl_api_bridge_flags_reply_t * mp)
1412 vat_main_t *vam = &vat_main;
1413 i32 retval = ntohl (mp->retval);
1414 if (vam->async_mode)
1416 vam->async_errors += (retval < 0);
1420 vam->retval = retval;
1421 vam->result_ready = 1;
1425 static void vl_api_bridge_flags_reply_t_handler_json
1426 (vl_api_bridge_flags_reply_t * mp)
1428 vat_main_t *vam = &vat_main;
1429 vat_json_node_t node;
1431 vat_json_init_object (&node);
1432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1433 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1434 ntohl (mp->resulting_feature_bitmap));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = ntohl (mp->retval);
1440 vam->result_ready = 1;
1443 static void vl_api_tap_connect_reply_t_handler
1444 (vl_api_tap_connect_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 i32 retval = ntohl (mp->retval);
1448 if (vam->async_mode)
1450 vam->async_errors += (retval < 0);
1454 vam->retval = retval;
1455 vam->sw_if_index = ntohl (mp->sw_if_index);
1456 vam->result_ready = 1;
1461 static void vl_api_tap_connect_reply_t_handler_json
1462 (vl_api_tap_connect_reply_t * mp)
1464 vat_main_t *vam = &vat_main;
1465 vat_json_node_t node;
1467 vat_json_init_object (&node);
1468 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1469 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1471 vat_json_print (vam->ofp, &node);
1472 vat_json_free (&node);
1474 vam->retval = ntohl (mp->retval);
1475 vam->result_ready = 1;
1480 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->sw_if_index = ntohl (mp->sw_if_index);
1492 vam->result_ready = 1;
1496 static void vl_api_tap_modify_reply_t_handler_json
1497 (vl_api_tap_modify_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 vat_json_node_t node;
1502 vat_json_init_object (&node);
1503 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1504 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1506 vat_json_print (vam->ofp, &node);
1507 vat_json_free (&node);
1509 vam->retval = ntohl (mp->retval);
1510 vam->result_ready = 1;
1514 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1516 vat_main_t *vam = &vat_main;
1517 i32 retval = ntohl (mp->retval);
1518 if (vam->async_mode)
1520 vam->async_errors += (retval < 0);
1524 vam->retval = retval;
1525 vam->result_ready = 1;
1529 static void vl_api_tap_delete_reply_t_handler_json
1530 (vl_api_tap_delete_reply_t * mp)
1532 vat_main_t *vam = &vat_main;
1533 vat_json_node_t node;
1535 vat_json_init_object (&node);
1536 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1538 vat_json_print (vam->ofp, &node);
1539 vat_json_free (&node);
1541 vam->retval = ntohl (mp->retval);
1542 vam->result_ready = 1;
1545 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1546 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 i32 retval = ntohl (mp->retval);
1550 if (vam->async_mode)
1552 vam->async_errors += (retval < 0);
1556 vam->retval = retval;
1557 vam->result_ready = 1;
1561 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1562 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1564 vat_main_t *vam = &vat_main;
1565 vat_json_node_t node;
1567 vat_json_init_object (&node);
1568 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1569 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1570 ntohl (mp->sw_if_index));
1572 vat_json_print (vam->ofp, &node);
1573 vat_json_free (&node);
1575 vam->retval = ntohl (mp->retval);
1576 vam->result_ready = 1;
1579 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1580 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1582 vat_main_t *vam = &vat_main;
1583 i32 retval = ntohl (mp->retval);
1584 if (vam->async_mode)
1586 vam->async_errors += (retval < 0);
1590 vam->retval = retval;
1591 vam->sw_if_index = ntohl (mp->sw_if_index);
1592 vam->result_ready = 1;
1596 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1597 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 vat_json_node_t node;
1602 vat_json_init_object (&node);
1603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1604 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1606 vat_json_print (vam->ofp, &node);
1607 vat_json_free (&node);
1609 vam->retval = ntohl (mp->retval);
1610 vam->result_ready = 1;
1614 static void vl_api_one_add_del_locator_set_reply_t_handler
1615 (vl_api_one_add_del_locator_set_reply_t * mp)
1617 vat_main_t *vam = &vat_main;
1618 i32 retval = ntohl (mp->retval);
1619 if (vam->async_mode)
1621 vam->async_errors += (retval < 0);
1625 vam->retval = retval;
1626 vam->result_ready = 1;
1630 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1631 (vl_api_one_add_del_locator_set_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 vat_json_node_t node;
1636 vat_json_init_object (&node);
1637 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1640 vat_json_print (vam->ofp, &node);
1641 vat_json_free (&node);
1643 vam->retval = ntohl (mp->retval);
1644 vam->result_ready = 1;
1647 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1648 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 i32 retval = ntohl (mp->retval);
1652 if (vam->async_mode)
1654 vam->async_errors += (retval < 0);
1658 vam->retval = retval;
1659 vam->sw_if_index = ntohl (mp->sw_if_index);
1660 vam->result_ready = 1;
1664 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1665 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 vat_json_node_t node;
1670 vat_json_init_object (&node);
1671 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1672 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1674 vat_json_print (vam->ofp, &node);
1675 vat_json_free (&node);
1677 vam->retval = ntohl (mp->retval);
1678 vam->result_ready = 1;
1681 static void vl_api_gre_add_del_tunnel_reply_t_handler
1682 (vl_api_gre_add_del_tunnel_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 i32 retval = ntohl (mp->retval);
1686 if (vam->async_mode)
1688 vam->async_errors += (retval < 0);
1692 vam->retval = retval;
1693 vam->sw_if_index = ntohl (mp->sw_if_index);
1694 vam->result_ready = 1;
1698 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1699 (vl_api_gre_add_del_tunnel_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 vat_json_node_t node;
1704 vat_json_init_object (&node);
1705 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1706 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1708 vat_json_print (vam->ofp, &node);
1709 vat_json_free (&node);
1711 vam->retval = ntohl (mp->retval);
1712 vam->result_ready = 1;
1715 static void vl_api_create_vhost_user_if_reply_t_handler
1716 (vl_api_create_vhost_user_if_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 i32 retval = ntohl (mp->retval);
1720 if (vam->async_mode)
1722 vam->async_errors += (retval < 0);
1726 vam->retval = retval;
1727 vam->sw_if_index = ntohl (mp->sw_if_index);
1728 vam->result_ready = 1;
1732 static void vl_api_create_vhost_user_if_reply_t_handler_json
1733 (vl_api_create_vhost_user_if_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 vat_json_node_t node;
1738 vat_json_init_object (&node);
1739 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1740 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1742 vat_json_print (vam->ofp, &node);
1743 vat_json_free (&node);
1745 vam->retval = ntohl (mp->retval);
1746 vam->result_ready = 1;
1749 static void vl_api_ip_address_details_t_handler
1750 (vl_api_ip_address_details_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 static ip_address_details_t empty_ip_address_details = { {0} };
1754 ip_address_details_t *address = NULL;
1755 ip_details_t *current_ip_details = NULL;
1756 ip_details_t *details = NULL;
1758 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1760 if (!details || vam->current_sw_if_index >= vec_len (details)
1761 || !details[vam->current_sw_if_index].present)
1763 errmsg ("ip address details arrived but not stored");
1764 errmsg ("ip_dump should be called first");
1768 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1770 #define addresses (current_ip_details->addr)
1772 vec_validate_init_empty (addresses, vec_len (addresses),
1773 empty_ip_address_details);
1775 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1777 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1778 address->prefix_length = mp->prefix_length;
1782 static void vl_api_ip_address_details_t_handler_json
1783 (vl_api_ip_address_details_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t *node = NULL;
1787 struct in6_addr ip6;
1790 if (VAT_JSON_ARRAY != vam->json_tree.type)
1792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1793 vat_json_init_array (&vam->json_tree);
1795 node = vat_json_array_add (&vam->json_tree);
1797 vat_json_init_object (node);
1800 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1801 vat_json_object_add_ip6 (node, "ip", ip6);
1805 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1806 vat_json_object_add_ip4 (node, "ip", ip4);
1808 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1812 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1814 vat_main_t *vam = &vat_main;
1815 static ip_details_t empty_ip_details = { 0 };
1816 ip_details_t *ip = NULL;
1817 u32 sw_if_index = ~0;
1819 sw_if_index = ntohl (mp->sw_if_index);
1821 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1822 sw_if_index, empty_ip_details);
1824 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1831 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1833 vat_main_t *vam = &vat_main;
1835 if (VAT_JSON_ARRAY != vam->json_tree.type)
1837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1838 vat_json_init_array (&vam->json_tree);
1840 vat_json_array_add_uint (&vam->json_tree,
1841 clib_net_to_host_u32 (mp->sw_if_index));
1844 static void vl_api_map_domain_details_t_handler_json
1845 (vl_api_map_domain_details_t * mp)
1847 vat_json_node_t *node = NULL;
1848 vat_main_t *vam = &vat_main;
1849 struct in6_addr ip6;
1852 if (VAT_JSON_ARRAY != vam->json_tree.type)
1854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1855 vat_json_init_array (&vam->json_tree);
1858 node = vat_json_array_add (&vam->json_tree);
1859 vat_json_init_object (node);
1861 vat_json_object_add_uint (node, "domain_index",
1862 clib_net_to_host_u32 (mp->domain_index));
1863 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1864 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1865 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1866 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1867 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1868 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1869 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1870 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1871 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1872 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1873 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1874 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1875 vat_json_object_add_uint (node, "flags", mp->flags);
1876 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1877 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1880 static void vl_api_map_domain_details_t_handler
1881 (vl_api_map_domain_details_t * mp)
1883 vat_main_t *vam = &vat_main;
1885 if (mp->is_translation)
1888 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1889 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1890 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1891 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1892 clib_net_to_host_u32 (mp->domain_index));
1897 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1898 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1899 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1900 format_ip6_address, mp->ip6_src,
1901 clib_net_to_host_u32 (mp->domain_index));
1903 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1904 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1905 mp->is_translation ? "map-t" : "");
1908 static void vl_api_map_rule_details_t_handler_json
1909 (vl_api_map_rule_details_t * mp)
1911 struct in6_addr ip6;
1912 vat_json_node_t *node = NULL;
1913 vat_main_t *vam = &vat_main;
1915 if (VAT_JSON_ARRAY != vam->json_tree.type)
1917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1918 vat_json_init_array (&vam->json_tree);
1921 node = vat_json_array_add (&vam->json_tree);
1922 vat_json_init_object (node);
1924 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1925 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1926 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1930 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1932 vat_main_t *vam = &vat_main;
1933 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1934 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1938 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1940 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1941 "router_addr %U host_mac %U",
1942 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1943 format_ip4_address, &mp->host_address,
1944 format_ip4_address, &mp->router_address,
1945 format_ethernet_address, mp->host_mac);
1948 static void vl_api_dhcp_compl_event_t_handler_json
1949 (vl_api_dhcp_compl_event_t * mp)
1951 /* JSON output not supported */
1955 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1958 vat_main_t *vam = &vat_main;
1959 static u64 default_counter = 0;
1961 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1963 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1964 sw_if_index, default_counter);
1965 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1969 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1970 interface_counter_t counter)
1972 vat_main_t *vam = &vat_main;
1973 static interface_counter_t default_counter = { 0, };
1975 vec_validate_init_empty (vam->combined_interface_counters,
1976 vnet_counter_type, NULL);
1977 vec_validate_init_empty (vam->combined_interface_counters
1978 [vnet_counter_type], sw_if_index, default_counter);
1979 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1982 static void vl_api_vnet_interface_counters_t_handler
1983 (vl_api_vnet_interface_counters_t * mp)
1988 static void vl_api_vnet_interface_counters_t_handler_json
1989 (vl_api_vnet_interface_counters_t * mp)
1991 interface_counter_t counter;
1996 u32 first_sw_if_index;
1999 count = ntohl (mp->count);
2000 first_sw_if_index = ntohl (mp->first_sw_if_index);
2002 if (!mp->is_combined)
2004 v_packets = (u64 *) & mp->data;
2005 for (i = 0; i < count; i++)
2008 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2009 set_simple_interface_counter (mp->vnet_counter_type,
2010 first_sw_if_index + i, packets);
2016 v = (vlib_counter_t *) & mp->data;
2017 for (i = 0; i < count; i++)
2020 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2022 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2023 set_combined_interface_counter (mp->vnet_counter_type,
2024 first_sw_if_index + i, counter);
2031 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2033 vat_main_t *vam = &vat_main;
2036 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2038 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2047 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2049 vat_main_t *vam = &vat_main;
2052 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2054 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2062 static void vl_api_vnet_ip4_fib_counters_t_handler
2063 (vl_api_vnet_ip4_fib_counters_t * mp)
2068 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2069 (vl_api_vnet_ip4_fib_counters_t * mp)
2071 vat_main_t *vam = &vat_main;
2072 vl_api_ip4_fib_counter_t *v;
2073 ip4_fib_counter_t *counter;
2080 vrf_id = ntohl (mp->vrf_id);
2081 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2082 if (~0 == vrf_index)
2084 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2085 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2086 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2087 vec_validate (vam->ip4_fib_counters, vrf_index);
2088 vam->ip4_fib_counters[vrf_index] = NULL;
2091 vec_free (vam->ip4_fib_counters[vrf_index]);
2092 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2093 count = ntohl (mp->count);
2094 for (i = 0; i < count; i++)
2096 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2097 counter = &vam->ip4_fib_counters[vrf_index][i];
2098 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2099 counter->address = ip4;
2100 counter->address_length = v->address_length;
2101 counter->packets = clib_net_to_host_u64 (v->packets);
2102 counter->bytes = clib_net_to_host_u64 (v->bytes);
2107 static void vl_api_vnet_ip4_nbr_counters_t_handler
2108 (vl_api_vnet_ip4_nbr_counters_t * mp)
2113 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2114 (vl_api_vnet_ip4_nbr_counters_t * mp)
2116 vat_main_t *vam = &vat_main;
2117 vl_api_ip4_nbr_counter_t *v;
2118 ip4_nbr_counter_t *counter;
2123 sw_if_index = ntohl (mp->sw_if_index);
2124 count = ntohl (mp->count);
2125 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2128 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2130 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2131 for (i = 0; i < count; i++)
2133 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2134 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2135 counter->address.s_addr = v->address;
2136 counter->packets = clib_net_to_host_u64 (v->packets);
2137 counter->bytes = clib_net_to_host_u64 (v->bytes);
2138 counter->linkt = v->link_type;
2143 static void vl_api_vnet_ip6_fib_counters_t_handler
2144 (vl_api_vnet_ip6_fib_counters_t * mp)
2149 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2150 (vl_api_vnet_ip6_fib_counters_t * mp)
2152 vat_main_t *vam = &vat_main;
2153 vl_api_ip6_fib_counter_t *v;
2154 ip6_fib_counter_t *counter;
2155 struct in6_addr ip6;
2161 vrf_id = ntohl (mp->vrf_id);
2162 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2163 if (~0 == vrf_index)
2165 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2166 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2167 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2168 vec_validate (vam->ip6_fib_counters, vrf_index);
2169 vam->ip6_fib_counters[vrf_index] = NULL;
2172 vec_free (vam->ip6_fib_counters[vrf_index]);
2173 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2174 count = ntohl (mp->count);
2175 for (i = 0; i < count; i++)
2177 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2178 counter = &vam->ip6_fib_counters[vrf_index][i];
2179 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2180 counter->address = ip6;
2181 counter->address_length = v->address_length;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2188 static void vl_api_vnet_ip6_nbr_counters_t_handler
2189 (vl_api_vnet_ip6_nbr_counters_t * mp)
2194 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2195 (vl_api_vnet_ip6_nbr_counters_t * mp)
2197 vat_main_t *vam = &vat_main;
2198 vl_api_ip6_nbr_counter_t *v;
2199 ip6_nbr_counter_t *counter;
2200 struct in6_addr ip6;
2205 sw_if_index = ntohl (mp->sw_if_index);
2206 count = ntohl (mp->count);
2207 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2210 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2212 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2213 for (i = 0; i < count; i++)
2215 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2216 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2217 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2218 counter->address = ip6;
2219 counter->packets = clib_net_to_host_u64 (v->packets);
2220 counter->bytes = clib_net_to_host_u64 (v->bytes);
2225 static void vl_api_get_first_msg_id_reply_t_handler
2226 (vl_api_get_first_msg_id_reply_t * mp)
2228 vat_main_t *vam = &vat_main;
2229 i32 retval = ntohl (mp->retval);
2231 if (vam->async_mode)
2233 vam->async_errors += (retval < 0);
2237 vam->retval = retval;
2238 vam->result_ready = 1;
2242 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2246 static void vl_api_get_first_msg_id_reply_t_handler_json
2247 (vl_api_get_first_msg_id_reply_t * mp)
2249 vat_main_t *vam = &vat_main;
2250 vat_json_node_t node;
2252 vat_json_init_object (&node);
2253 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2254 vat_json_object_add_uint (&node, "first_msg_id",
2255 (uint) ntohs (mp->first_msg_id));
2257 vat_json_print (vam->ofp, &node);
2258 vat_json_free (&node);
2260 vam->retval = ntohl (mp->retval);
2261 vam->result_ready = 1;
2264 static void vl_api_get_node_graph_reply_t_handler
2265 (vl_api_get_node_graph_reply_t * mp)
2267 vat_main_t *vam = &vat_main;
2268 api_main_t *am = &api_main;
2269 i32 retval = ntohl (mp->retval);
2270 u8 *pvt_copy, *reply;
2275 if (vam->async_mode)
2277 vam->async_errors += (retval < 0);
2281 vam->retval = retval;
2282 vam->result_ready = 1;
2285 /* "Should never happen..." */
2289 reply = (u8 *) (mp->reply_in_shmem);
2290 pvt_copy = vec_dup (reply);
2292 /* Toss the shared-memory original... */
2293 pthread_mutex_lock (&am->vlib_rp->mutex);
2294 oldheap = svm_push_data_heap (am->vlib_rp);
2298 svm_pop_heap (oldheap);
2299 pthread_mutex_unlock (&am->vlib_rp->mutex);
2301 if (vam->graph_nodes)
2303 hash_free (vam->graph_node_index_by_name);
2305 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2307 node = vam->graph_nodes[i];
2308 vec_free (node->name);
2309 vec_free (node->next_nodes);
2312 vec_free (vam->graph_nodes);
2315 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2316 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2317 vec_free (pvt_copy);
2319 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2321 node = vam->graph_nodes[i];
2322 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2326 static void vl_api_get_node_graph_reply_t_handler_json
2327 (vl_api_get_node_graph_reply_t * mp)
2329 vat_main_t *vam = &vat_main;
2330 api_main_t *am = &api_main;
2332 vat_json_node_t node;
2335 /* $$$$ make this real? */
2336 vat_json_init_object (&node);
2337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2338 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2340 reply = (u8 *) (mp->reply_in_shmem);
2342 /* Toss the shared-memory original... */
2343 pthread_mutex_lock (&am->vlib_rp->mutex);
2344 oldheap = svm_push_data_heap (am->vlib_rp);
2348 svm_pop_heap (oldheap);
2349 pthread_mutex_unlock (&am->vlib_rp->mutex);
2351 vat_json_print (vam->ofp, &node);
2352 vat_json_free (&node);
2354 vam->retval = ntohl (mp->retval);
2355 vam->result_ready = 1;
2359 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2361 vat_main_t *vam = &vat_main;
2366 s = format (s, "%=16d%=16d%=16d",
2367 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2371 s = format (s, "%=16U%=16d%=16d",
2372 mp->is_ipv6 ? format_ip6_address :
2374 mp->ip_address, mp->priority, mp->weight);
2377 print (vam->ofp, "%v", s);
2382 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2384 vat_main_t *vam = &vat_main;
2385 vat_json_node_t *node = NULL;
2386 struct in6_addr ip6;
2389 if (VAT_JSON_ARRAY != vam->json_tree.type)
2391 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2392 vat_json_init_array (&vam->json_tree);
2394 node = vat_json_array_add (&vam->json_tree);
2395 vat_json_init_object (node);
2397 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2398 vat_json_object_add_uint (node, "priority", mp->priority);
2399 vat_json_object_add_uint (node, "weight", mp->weight);
2402 vat_json_object_add_uint (node, "sw_if_index",
2403 clib_net_to_host_u32 (mp->sw_if_index));
2408 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2409 vat_json_object_add_ip6 (node, "address", ip6);
2413 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2414 vat_json_object_add_ip4 (node, "address", ip4);
2420 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2423 vat_main_t *vam = &vat_main;
2426 ls_name = format (0, "%s", mp->ls_name);
2428 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2434 vl_api_one_locator_set_details_t_handler_json
2435 (vl_api_one_locator_set_details_t * mp)
2437 vat_main_t *vam = &vat_main;
2438 vat_json_node_t *node = 0;
2441 ls_name = format (0, "%s", mp->ls_name);
2442 vec_add1 (ls_name, 0);
2444 if (VAT_JSON_ARRAY != vam->json_tree.type)
2446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2447 vat_json_init_array (&vam->json_tree);
2449 node = vat_json_array_add (&vam->json_tree);
2451 vat_json_init_object (node);
2452 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2453 vat_json_object_add_uint (node, "ls_index",
2454 clib_net_to_host_u32 (mp->ls_index));
2459 format_lisp_flat_eid (u8 * s, va_list * args)
2461 u32 type = va_arg (*args, u32);
2462 u8 *eid = va_arg (*args, u8 *);
2463 u32 eid_len = va_arg (*args, u32);
2468 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2470 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2472 return format (s, "%U", format_ethernet_address, eid);
2478 format_lisp_eid_vat (u8 * s, va_list * args)
2480 u32 type = va_arg (*args, u32);
2481 u8 *eid = va_arg (*args, u8 *);
2482 u32 eid_len = va_arg (*args, u32);
2483 u8 *seid = va_arg (*args, u8 *);
2484 u32 seid_len = va_arg (*args, u32);
2485 u32 is_src_dst = va_arg (*args, u32);
2488 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2490 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2496 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2498 vat_main_t *vam = &vat_main;
2499 u8 *s = 0, *eid = 0;
2501 if (~0 == mp->locator_set_index)
2502 s = format (0, "action: %d", mp->action);
2504 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2506 eid = format (0, "%U", format_lisp_eid_vat,
2510 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2513 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2514 clib_net_to_host_u32 (mp->vni),
2516 mp->is_local ? "local" : "remote",
2517 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2518 clib_net_to_host_u16 (mp->key_id), mp->key);
2525 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2528 vat_main_t *vam = &vat_main;
2529 vat_json_node_t *node = 0;
2532 if (VAT_JSON_ARRAY != vam->json_tree.type)
2534 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2535 vat_json_init_array (&vam->json_tree);
2537 node = vat_json_array_add (&vam->json_tree);
2539 vat_json_init_object (node);
2540 if (~0 == mp->locator_set_index)
2541 vat_json_object_add_uint (node, "action", mp->action);
2543 vat_json_object_add_uint (node, "locator_set_index",
2544 clib_net_to_host_u32 (mp->locator_set_index));
2546 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2547 eid = format (0, "%U", format_lisp_eid_vat,
2551 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2553 vat_json_object_add_string_copy (node, "eid", eid);
2554 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2555 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2556 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2560 vat_json_object_add_uint (node, "key_id",
2561 clib_net_to_host_u16 (mp->key_id));
2562 vat_json_object_add_string_copy (node, "key", mp->key);
2568 vl_api_one_eid_table_map_details_t_handler
2569 (vl_api_one_eid_table_map_details_t * mp)
2571 vat_main_t *vam = &vat_main;
2573 u8 *line = format (0, "%=10d%=10d",
2574 clib_net_to_host_u32 (mp->vni),
2575 clib_net_to_host_u32 (mp->dp_table));
2576 print (vam->ofp, "%v", line);
2581 vl_api_one_eid_table_map_details_t_handler_json
2582 (vl_api_one_eid_table_map_details_t * mp)
2584 vat_main_t *vam = &vat_main;
2585 vat_json_node_t *node = NULL;
2587 if (VAT_JSON_ARRAY != vam->json_tree.type)
2589 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2590 vat_json_init_array (&vam->json_tree);
2592 node = vat_json_array_add (&vam->json_tree);
2593 vat_json_init_object (node);
2594 vat_json_object_add_uint (node, "dp_table",
2595 clib_net_to_host_u32 (mp->dp_table));
2596 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2600 vl_api_one_eid_table_vni_details_t_handler
2601 (vl_api_one_eid_table_vni_details_t * mp)
2603 vat_main_t *vam = &vat_main;
2605 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2606 print (vam->ofp, "%v", line);
2611 vl_api_one_eid_table_vni_details_t_handler_json
2612 (vl_api_one_eid_table_vni_details_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 vat_json_node_t *node = NULL;
2617 if (VAT_JSON_ARRAY != vam->json_tree.type)
2619 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2620 vat_json_init_array (&vam->json_tree);
2622 node = vat_json_array_add (&vam->json_tree);
2623 vat_json_init_object (node);
2624 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2628 vl_api_show_one_map_register_state_reply_t_handler
2629 (vl_api_show_one_map_register_state_reply_t * mp)
2631 vat_main_t *vam = &vat_main;
2632 int retval = clib_net_to_host_u32 (mp->retval);
2634 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2636 vam->retval = retval;
2637 vam->result_ready = 1;
2641 vl_api_show_one_map_register_state_reply_t_handler_json
2642 (vl_api_show_one_map_register_state_reply_t * mp)
2644 vat_main_t *vam = &vat_main;
2645 vat_json_node_t _node, *node = &_node;
2646 int retval = clib_net_to_host_u32 (mp->retval);
2648 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2650 vat_json_init_object (node);
2651 vat_json_object_add_string_copy (node, "state", s);
2653 vat_json_print (vam->ofp, node);
2654 vat_json_free (node);
2656 vam->retval = retval;
2657 vam->result_ready = 1;
2662 vl_api_show_one_rloc_probe_state_reply_t_handler
2663 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2665 vat_main_t *vam = &vat_main;
2666 int retval = clib_net_to_host_u32 (mp->retval);
2671 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2673 vam->retval = retval;
2674 vam->result_ready = 1;
2678 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2679 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2681 vat_main_t *vam = &vat_main;
2682 vat_json_node_t _node, *node = &_node;
2683 int retval = clib_net_to_host_u32 (mp->retval);
2685 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2686 vat_json_init_object (node);
2687 vat_json_object_add_string_copy (node, "state", s);
2689 vat_json_print (vam->ofp, node);
2690 vat_json_free (node);
2692 vam->retval = retval;
2693 vam->result_ready = 1;
2698 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2700 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2701 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2705 gpe_fwd_entries_get_reply_t_net_to_host
2706 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2710 mp->count = clib_net_to_host_u32 (mp->count);
2711 for (i = 0; i < mp->count; i++)
2713 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2718 vl_api_gpe_fwd_entry_path_details_t_handler
2719 (vl_api_gpe_fwd_entry_path_details_t * mp)
2721 vat_main_t *vam = &vat_main;
2722 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2724 if (mp->lcl_loc.is_ip4)
2725 format_ip_address_fcn = format_ip4_address;
2727 format_ip_address_fcn = format_ip6_address;
2729 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2730 format_ip_address_fcn, &mp->lcl_loc,
2731 format_ip_address_fcn, &mp->rmt_loc);
2735 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2737 struct in6_addr ip6;
2742 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2743 vat_json_object_add_ip4 (n, "address", ip4);
2747 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2748 vat_json_object_add_ip6 (n, "address", ip6);
2750 vat_json_object_add_uint (n, "weight", loc->weight);
2754 vl_api_gpe_fwd_entry_path_details_t_handler_json
2755 (vl_api_gpe_fwd_entry_path_details_t * mp)
2757 vat_main_t *vam = &vat_main;
2758 vat_json_node_t *node = NULL;
2759 vat_json_node_t *loc_node;
2761 if (VAT_JSON_ARRAY != vam->json_tree.type)
2763 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2764 vat_json_init_array (&vam->json_tree);
2766 node = vat_json_array_add (&vam->json_tree);
2767 vat_json_init_object (node);
2769 loc_node = vat_json_object_add (node, "local_locator");
2770 vat_json_init_object (loc_node);
2771 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2773 loc_node = vat_json_object_add (node, "remote_locator");
2774 vat_json_init_object (loc_node);
2775 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2779 vl_api_gpe_fwd_entries_get_reply_t_handler
2780 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2782 vat_main_t *vam = &vat_main;
2784 int retval = clib_net_to_host_u32 (mp->retval);
2785 vl_api_gpe_fwd_entry_t *e;
2790 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2792 for (i = 0; i < mp->count; i++)
2794 e = &mp->entries[i];
2795 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2796 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2797 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2801 vam->retval = retval;
2802 vam->result_ready = 1;
2806 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2807 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2810 vat_main_t *vam = &vat_main;
2811 vat_json_node_t *e = 0, root;
2813 int retval = clib_net_to_host_u32 (mp->retval);
2814 vl_api_gpe_fwd_entry_t *fwd;
2819 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2820 vat_json_init_array (&root);
2822 for (i = 0; i < mp->count; i++)
2824 e = vat_json_array_add (&root);
2825 fwd = &mp->entries[i];
2827 vat_json_init_object (e);
2828 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2829 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2831 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2832 fwd->leid_prefix_len);
2834 vat_json_object_add_string_copy (e, "leid", s);
2837 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2838 fwd->reid_prefix_len);
2840 vat_json_object_add_string_copy (e, "reid", s);
2844 vat_json_print (vam->ofp, &root);
2845 vat_json_free (&root);
2848 vam->retval = retval;
2849 vam->result_ready = 1;
2853 vl_api_one_adjacencies_get_reply_t_handler
2854 (vl_api_one_adjacencies_get_reply_t * mp)
2856 vat_main_t *vam = &vat_main;
2858 int retval = clib_net_to_host_u32 (mp->retval);
2859 vl_api_one_adjacency_t *a;
2864 n = clib_net_to_host_u32 (mp->count);
2866 for (i = 0; i < n; i++)
2868 a = &mp->adjacencies[i];
2869 print (vam->ofp, "%U %40U",
2870 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2871 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2875 vam->retval = retval;
2876 vam->result_ready = 1;
2880 vl_api_one_adjacencies_get_reply_t_handler_json
2881 (vl_api_one_adjacencies_get_reply_t * mp)
2884 vat_main_t *vam = &vat_main;
2885 vat_json_node_t *e = 0, root;
2887 int retval = clib_net_to_host_u32 (mp->retval);
2888 vl_api_one_adjacency_t *a;
2893 n = clib_net_to_host_u32 (mp->count);
2894 vat_json_init_array (&root);
2896 for (i = 0; i < n; i++)
2898 e = vat_json_array_add (&root);
2899 a = &mp->adjacencies[i];
2901 vat_json_init_object (e);
2902 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2903 a->leid_prefix_len);
2905 vat_json_object_add_string_copy (e, "leid", s);
2908 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2909 a->reid_prefix_len);
2911 vat_json_object_add_string_copy (e, "reid", s);
2915 vat_json_print (vam->ofp, &root);
2916 vat_json_free (&root);
2919 vam->retval = retval;
2920 vam->result_ready = 1;
2924 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
2926 vat_main_t *vam = &vat_main;
2928 print (vam->ofp, "%=20U",
2929 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2934 vl_api_one_map_server_details_t_handler_json
2935 (vl_api_one_map_server_details_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 vat_json_node_t *node = NULL;
2939 struct in6_addr ip6;
2942 if (VAT_JSON_ARRAY != vam->json_tree.type)
2944 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2945 vat_json_init_array (&vam->json_tree);
2947 node = vat_json_array_add (&vam->json_tree);
2949 vat_json_init_object (node);
2952 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2953 vat_json_object_add_ip6 (node, "map-server", ip6);
2957 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2958 vat_json_object_add_ip4 (node, "map-server", ip4);
2963 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
2966 vat_main_t *vam = &vat_main;
2968 print (vam->ofp, "%=20U",
2969 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2974 vl_api_one_map_resolver_details_t_handler_json
2975 (vl_api_one_map_resolver_details_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vat_json_node_t *node = NULL;
2979 struct in6_addr ip6;
2982 if (VAT_JSON_ARRAY != vam->json_tree.type)
2984 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2985 vat_json_init_array (&vam->json_tree);
2987 node = vat_json_array_add (&vam->json_tree);
2989 vat_json_init_object (node);
2992 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2993 vat_json_object_add_ip6 (node, "map resolver", ip6);
2997 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2998 vat_json_object_add_ip4 (node, "map resolver", ip4);
3003 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3005 vat_main_t *vam = &vat_main;
3006 i32 retval = ntohl (mp->retval);
3010 print (vam->ofp, "feature: %s\ngpe: %s",
3011 mp->feature_status ? "enabled" : "disabled",
3012 mp->gpe_status ? "enabled" : "disabled");
3015 vam->retval = retval;
3016 vam->result_ready = 1;
3020 vl_api_show_one_status_reply_t_handler_json
3021 (vl_api_show_one_status_reply_t * mp)
3023 vat_main_t *vam = &vat_main;
3024 vat_json_node_t node;
3025 u8 *gpe_status = NULL;
3026 u8 *feature_status = NULL;
3028 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3029 feature_status = format (0, "%s",
3030 mp->feature_status ? "enabled" : "disabled");
3031 vec_add1 (gpe_status, 0);
3032 vec_add1 (feature_status, 0);
3034 vat_json_init_object (&node);
3035 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3036 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3038 vec_free (gpe_status);
3039 vec_free (feature_status);
3041 vat_json_print (vam->ofp, &node);
3042 vat_json_free (&node);
3044 vam->retval = ntohl (mp->retval);
3045 vam->result_ready = 1;
3049 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3050 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3052 vat_main_t *vam = &vat_main;
3053 i32 retval = ntohl (mp->retval);
3057 print (vam->ofp, "%=20s", mp->locator_set_name);
3060 vam->retval = retval;
3061 vam->result_ready = 1;
3065 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3066 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3068 vat_main_t *vam = &vat_main;
3069 vat_json_node_t *node = NULL;
3071 if (VAT_JSON_ARRAY != vam->json_tree.type)
3073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3074 vat_json_init_array (&vam->json_tree);
3076 node = vat_json_array_add (&vam->json_tree);
3078 vat_json_init_object (node);
3079 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3081 vat_json_print (vam->ofp, node);
3082 vat_json_free (node);
3084 vam->retval = ntohl (mp->retval);
3085 vam->result_ready = 1;
3089 format_lisp_map_request_mode (u8 * s, va_list * args)
3091 u32 mode = va_arg (*args, u32);
3096 return format (0, "dst-only");
3098 return format (0, "src-dst");
3104 vl_api_show_one_map_request_mode_reply_t_handler
3105 (vl_api_show_one_map_request_mode_reply_t * mp)
3107 vat_main_t *vam = &vat_main;
3108 i32 retval = ntohl (mp->retval);
3112 u32 mode = mp->mode;
3113 print (vam->ofp, "map_request_mode: %U",
3114 format_lisp_map_request_mode, mode);
3117 vam->retval = retval;
3118 vam->result_ready = 1;
3122 vl_api_show_one_map_request_mode_reply_t_handler_json
3123 (vl_api_show_one_map_request_mode_reply_t * mp)
3125 vat_main_t *vam = &vat_main;
3126 vat_json_node_t node;
3131 s = format (0, "%U", format_lisp_map_request_mode, mode);
3134 vat_json_init_object (&node);
3135 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3136 vat_json_print (vam->ofp, &node);
3137 vat_json_free (&node);
3140 vam->retval = ntohl (mp->retval);
3141 vam->result_ready = 1;
3145 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3147 vat_main_t *vam = &vat_main;
3148 i32 retval = ntohl (mp->retval);
3152 print (vam->ofp, "%-20s%-16s",
3153 mp->status ? "enabled" : "disabled",
3154 mp->status ? (char *) mp->locator_set_name : "");
3157 vam->retval = retval;
3158 vam->result_ready = 1;
3162 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3164 vat_main_t *vam = &vat_main;
3165 vat_json_node_t node;
3168 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3169 vec_add1 (status, 0);
3171 vat_json_init_object (&node);
3172 vat_json_object_add_string_copy (&node, "status", status);
3175 vat_json_object_add_string_copy (&node, "locator_set",
3176 mp->locator_set_name);
3181 vat_json_print (vam->ofp, &node);
3182 vat_json_free (&node);
3184 vam->retval = ntohl (mp->retval);
3185 vam->result_ready = 1;
3189 format_policer_type (u8 * s, va_list * va)
3191 u32 i = va_arg (*va, u32);
3193 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3194 s = format (s, "1r2c");
3195 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3196 s = format (s, "1r3c");
3197 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3198 s = format (s, "2r3c-2698");
3199 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3200 s = format (s, "2r3c-4115");
3201 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3202 s = format (s, "2r3c-mef5cf1");
3204 s = format (s, "ILLEGAL");
3209 format_policer_rate_type (u8 * s, va_list * va)
3211 u32 i = va_arg (*va, u32);
3213 if (i == SSE2_QOS_RATE_KBPS)
3214 s = format (s, "kbps");
3215 else if (i == SSE2_QOS_RATE_PPS)
3216 s = format (s, "pps");
3218 s = format (s, "ILLEGAL");
3223 format_policer_round_type (u8 * s, va_list * va)
3225 u32 i = va_arg (*va, u32);
3227 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3228 s = format (s, "closest");
3229 else if (i == SSE2_QOS_ROUND_TO_UP)
3230 s = format (s, "up");
3231 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3232 s = format (s, "down");
3234 s = format (s, "ILLEGAL");
3239 format_policer_action_type (u8 * s, va_list * va)
3241 u32 i = va_arg (*va, u32);
3243 if (i == SSE2_QOS_ACTION_DROP)
3244 s = format (s, "drop");
3245 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3246 s = format (s, "transmit");
3247 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3248 s = format (s, "mark-and-transmit");
3250 s = format (s, "ILLEGAL");
3255 format_dscp (u8 * s, va_list * va)
3257 u32 i = va_arg (*va, u32);
3262 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3266 return format (s, "ILLEGAL");
3268 s = format (s, "%s", t);
3273 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3275 vat_main_t *vam = &vat_main;
3276 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3278 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3279 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3281 conform_dscp_str = format (0, "");
3283 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3284 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3286 exceed_dscp_str = format (0, "");
3288 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3289 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3291 violate_dscp_str = format (0, "");
3293 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3294 "rate type %U, round type %U, %s rate, %s color-aware, "
3295 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3296 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3297 "conform action %U%s, exceed action %U%s, violate action %U%s",
3299 format_policer_type, mp->type,
3302 clib_net_to_host_u64 (mp->cb),
3303 clib_net_to_host_u64 (mp->eb),
3304 format_policer_rate_type, mp->rate_type,
3305 format_policer_round_type, mp->round_type,
3306 mp->single_rate ? "single" : "dual",
3307 mp->color_aware ? "is" : "not",
3308 ntohl (mp->cir_tokens_per_period),
3309 ntohl (mp->pir_tokens_per_period),
3311 ntohl (mp->current_limit),
3312 ntohl (mp->current_bucket),
3313 ntohl (mp->extended_limit),
3314 ntohl (mp->extended_bucket),
3315 clib_net_to_host_u64 (mp->last_update_time),
3316 format_policer_action_type, mp->conform_action_type,
3318 format_policer_action_type, mp->exceed_action_type,
3320 format_policer_action_type, mp->violate_action_type,
3323 vec_free (conform_dscp_str);
3324 vec_free (exceed_dscp_str);
3325 vec_free (violate_dscp_str);
3328 static void vl_api_policer_details_t_handler_json
3329 (vl_api_policer_details_t * mp)
3331 vat_main_t *vam = &vat_main;
3332 vat_json_node_t *node;
3333 u8 *rate_type_str, *round_type_str, *type_str;
3334 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3336 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3338 format (0, "%U", format_policer_round_type, mp->round_type);
3339 type_str = format (0, "%U", format_policer_type, mp->type);
3340 conform_action_str = format (0, "%U", format_policer_action_type,
3341 mp->conform_action_type);
3342 exceed_action_str = format (0, "%U", format_policer_action_type,
3343 mp->exceed_action_type);
3344 violate_action_str = format (0, "%U", format_policer_action_type,
3345 mp->violate_action_type);
3347 if (VAT_JSON_ARRAY != vam->json_tree.type)
3349 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3350 vat_json_init_array (&vam->json_tree);
3352 node = vat_json_array_add (&vam->json_tree);
3354 vat_json_init_object (node);
3355 vat_json_object_add_string_copy (node, "name", mp->name);
3356 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3357 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3358 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3359 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3360 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3361 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3362 vat_json_object_add_string_copy (node, "type", type_str);
3363 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3364 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3365 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3366 vat_json_object_add_uint (node, "cir_tokens_per_period",
3367 ntohl (mp->cir_tokens_per_period));
3368 vat_json_object_add_uint (node, "eir_tokens_per_period",
3369 ntohl (mp->pir_tokens_per_period));
3370 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3371 vat_json_object_add_uint (node, "current_bucket",
3372 ntohl (mp->current_bucket));
3373 vat_json_object_add_uint (node, "extended_limit",
3374 ntohl (mp->extended_limit));
3375 vat_json_object_add_uint (node, "extended_bucket",
3376 ntohl (mp->extended_bucket));
3377 vat_json_object_add_uint (node, "last_update_time",
3378 ntohl (mp->last_update_time));
3379 vat_json_object_add_string_copy (node, "conform_action",
3380 conform_action_str);
3381 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3383 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3384 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3385 vec_free (dscp_str);
3387 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3388 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3390 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3391 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3392 vec_free (dscp_str);
3394 vat_json_object_add_string_copy (node, "violate_action",
3395 violate_action_str);
3396 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3398 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3399 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3400 vec_free (dscp_str);
3403 vec_free (rate_type_str);
3404 vec_free (round_type_str);
3405 vec_free (type_str);
3406 vec_free (conform_action_str);
3407 vec_free (exceed_action_str);
3408 vec_free (violate_action_str);
3412 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3415 vat_main_t *vam = &vat_main;
3416 int i, count = ntohl (mp->count);
3419 print (vam->ofp, "classify table ids (%d) : ", count);
3420 for (i = 0; i < count; i++)
3422 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3423 print (vam->ofp, (i < count - 1) ? "," : "");
3425 vam->retval = ntohl (mp->retval);
3426 vam->result_ready = 1;
3430 vl_api_classify_table_ids_reply_t_handler_json
3431 (vl_api_classify_table_ids_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3434 int i, count = ntohl (mp->count);
3438 vat_json_node_t node;
3440 vat_json_init_object (&node);
3441 for (i = 0; i < count; i++)
3443 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3445 vat_json_print (vam->ofp, &node);
3446 vat_json_free (&node);
3448 vam->retval = ntohl (mp->retval);
3449 vam->result_ready = 1;
3453 vl_api_classify_table_by_interface_reply_t_handler
3454 (vl_api_classify_table_by_interface_reply_t * mp)
3456 vat_main_t *vam = &vat_main;
3459 table_id = ntohl (mp->l2_table_id);
3461 print (vam->ofp, "l2 table id : %d", table_id);
3463 print (vam->ofp, "l2 table id : No input ACL tables configured");
3464 table_id = ntohl (mp->ip4_table_id);
3466 print (vam->ofp, "ip4 table id : %d", table_id);
3468 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3469 table_id = ntohl (mp->ip6_table_id);
3471 print (vam->ofp, "ip6 table id : %d", table_id);
3473 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3474 vam->retval = ntohl (mp->retval);
3475 vam->result_ready = 1;
3479 vl_api_classify_table_by_interface_reply_t_handler_json
3480 (vl_api_classify_table_by_interface_reply_t * mp)
3482 vat_main_t *vam = &vat_main;
3483 vat_json_node_t node;
3485 vat_json_init_object (&node);
3487 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3488 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3489 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3491 vat_json_print (vam->ofp, &node);
3492 vat_json_free (&node);
3494 vam->retval = ntohl (mp->retval);
3495 vam->result_ready = 1;
3498 static void vl_api_policer_add_del_reply_t_handler
3499 (vl_api_policer_add_del_reply_t * mp)
3501 vat_main_t *vam = &vat_main;
3502 i32 retval = ntohl (mp->retval);
3503 if (vam->async_mode)
3505 vam->async_errors += (retval < 0);
3509 vam->retval = retval;
3510 vam->result_ready = 1;
3511 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3513 * Note: this is just barely thread-safe, depends on
3514 * the main thread spinning waiting for an answer...
3516 errmsg ("policer index %d", ntohl (mp->policer_index));
3520 static void vl_api_policer_add_del_reply_t_handler_json
3521 (vl_api_policer_add_del_reply_t * mp)
3523 vat_main_t *vam = &vat_main;
3524 vat_json_node_t node;
3526 vat_json_init_object (&node);
3527 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3528 vat_json_object_add_uint (&node, "policer_index",
3529 ntohl (mp->policer_index));
3531 vat_json_print (vam->ofp, &node);
3532 vat_json_free (&node);
3534 vam->retval = ntohl (mp->retval);
3535 vam->result_ready = 1;
3538 /* Format hex dump. */
3540 format_hex_bytes (u8 * s, va_list * va)
3542 u8 *bytes = va_arg (*va, u8 *);
3543 int n_bytes = va_arg (*va, int);
3546 /* Print short or long form depending on byte count. */
3547 uword short_form = n_bytes <= 32;
3548 uword indent = format_get_indent (s);
3553 for (i = 0; i < n_bytes; i++)
3555 if (!short_form && (i % 32) == 0)
3556 s = format (s, "%08x: ", i);
3557 s = format (s, "%02x", bytes[i]);
3558 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3559 s = format (s, "\n%U", format_white_space, indent);
3566 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3569 vat_main_t *vam = &vat_main;
3570 i32 retval = ntohl (mp->retval);
3573 print (vam->ofp, "classify table info :");
3574 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3575 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3576 ntohl (mp->miss_next_index));
3577 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3578 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3579 ntohl (mp->match_n_vectors));
3580 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3581 ntohl (mp->mask_length));
3583 vam->retval = retval;
3584 vam->result_ready = 1;
3588 vl_api_classify_table_info_reply_t_handler_json
3589 (vl_api_classify_table_info_reply_t * mp)
3591 vat_main_t *vam = &vat_main;
3592 vat_json_node_t node;
3594 i32 retval = ntohl (mp->retval);
3597 vat_json_init_object (&node);
3599 vat_json_object_add_int (&node, "sessions",
3600 ntohl (mp->active_sessions));
3601 vat_json_object_add_int (&node, "nexttbl",
3602 ntohl (mp->next_table_index));
3603 vat_json_object_add_int (&node, "nextnode",
3604 ntohl (mp->miss_next_index));
3605 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3606 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3607 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3608 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3609 ntohl (mp->mask_length), 0);
3610 vat_json_object_add_string_copy (&node, "mask", s);
3612 vat_json_print (vam->ofp, &node);
3613 vat_json_free (&node);
3615 vam->retval = ntohl (mp->retval);
3616 vam->result_ready = 1;
3620 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3623 vat_main_t *vam = &vat_main;
3625 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3626 ntohl (mp->hit_next_index), ntohl (mp->advance),
3627 ntohl (mp->opaque_index));
3628 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3629 ntohl (mp->match_length));
3633 vl_api_classify_session_details_t_handler_json
3634 (vl_api_classify_session_details_t * mp)
3636 vat_main_t *vam = &vat_main;
3637 vat_json_node_t *node = NULL;
3639 if (VAT_JSON_ARRAY != vam->json_tree.type)
3641 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3642 vat_json_init_array (&vam->json_tree);
3644 node = vat_json_array_add (&vam->json_tree);
3646 vat_json_init_object (node);
3647 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3648 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3649 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3651 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3653 vat_json_object_add_string_copy (node, "match", s);
3656 static void vl_api_pg_create_interface_reply_t_handler
3657 (vl_api_pg_create_interface_reply_t * mp)
3659 vat_main_t *vam = &vat_main;
3661 vam->retval = ntohl (mp->retval);
3662 vam->result_ready = 1;
3665 static void vl_api_pg_create_interface_reply_t_handler_json
3666 (vl_api_pg_create_interface_reply_t * mp)
3668 vat_main_t *vam = &vat_main;
3669 vat_json_node_t node;
3671 i32 retval = ntohl (mp->retval);
3674 vat_json_init_object (&node);
3676 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3678 vat_json_print (vam->ofp, &node);
3679 vat_json_free (&node);
3681 vam->retval = ntohl (mp->retval);
3682 vam->result_ready = 1;
3685 static void vl_api_policer_classify_details_t_handler
3686 (vl_api_policer_classify_details_t * mp)
3688 vat_main_t *vam = &vat_main;
3690 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3691 ntohl (mp->table_index));
3694 static void vl_api_policer_classify_details_t_handler_json
3695 (vl_api_policer_classify_details_t * mp)
3697 vat_main_t *vam = &vat_main;
3698 vat_json_node_t *node;
3700 if (VAT_JSON_ARRAY != vam->json_tree.type)
3702 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3703 vat_json_init_array (&vam->json_tree);
3705 node = vat_json_array_add (&vam->json_tree);
3707 vat_json_init_object (node);
3708 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3709 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3712 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3713 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3715 vat_main_t *vam = &vat_main;
3716 i32 retval = ntohl (mp->retval);
3717 if (vam->async_mode)
3719 vam->async_errors += (retval < 0);
3723 vam->retval = retval;
3724 vam->sw_if_index = ntohl (mp->sw_if_index);
3725 vam->result_ready = 1;
3729 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3730 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3732 vat_main_t *vam = &vat_main;
3733 vat_json_node_t node;
3735 vat_json_init_object (&node);
3736 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3737 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3739 vat_json_print (vam->ofp, &node);
3740 vat_json_free (&node);
3742 vam->retval = ntohl (mp->retval);
3743 vam->result_ready = 1;
3746 static void vl_api_flow_classify_details_t_handler
3747 (vl_api_flow_classify_details_t * mp)
3749 vat_main_t *vam = &vat_main;
3751 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3752 ntohl (mp->table_index));
3755 static void vl_api_flow_classify_details_t_handler_json
3756 (vl_api_flow_classify_details_t * mp)
3758 vat_main_t *vam = &vat_main;
3759 vat_json_node_t *node;
3761 if (VAT_JSON_ARRAY != vam->json_tree.type)
3763 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3764 vat_json_init_array (&vam->json_tree);
3766 node = vat_json_array_add (&vam->json_tree);
3768 vat_json_init_object (node);
3769 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3770 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3775 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3776 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3777 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3778 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3779 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3780 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3781 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3782 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3783 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3784 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3787 * Generate boilerplate reply handlers, which
3788 * dig the return value out of the xxx_reply_t API message,
3789 * stick it into vam->retval, and set vam->result_ready
3791 * Could also do this by pointing N message decode slots at
3792 * a single function, but that could break in subtle ways.
3795 #define foreach_standard_reply_retval_handler \
3796 _(sw_interface_set_flags_reply) \
3797 _(sw_interface_add_del_address_reply) \
3798 _(sw_interface_set_table_reply) \
3799 _(sw_interface_set_mpls_enable_reply) \
3800 _(sw_interface_set_vpath_reply) \
3801 _(sw_interface_set_vxlan_bypass_reply) \
3802 _(sw_interface_set_l2_bridge_reply) \
3803 _(bridge_domain_add_del_reply) \
3804 _(sw_interface_set_l2_xconnect_reply) \
3805 _(l2fib_add_del_reply) \
3806 _(ip_add_del_route_reply) \
3807 _(ip_mroute_add_del_reply) \
3808 _(mpls_route_add_del_reply) \
3809 _(mpls_ip_bind_unbind_reply) \
3810 _(proxy_arp_add_del_reply) \
3811 _(proxy_arp_intfc_enable_disable_reply) \
3812 _(sw_interface_set_unnumbered_reply) \
3813 _(ip_neighbor_add_del_reply) \
3814 _(reset_vrf_reply) \
3815 _(oam_add_del_reply) \
3816 _(reset_fib_reply) \
3817 _(dhcp_proxy_config_reply) \
3818 _(dhcp_proxy_set_vss_reply) \
3819 _(dhcp_client_config_reply) \
3820 _(set_ip_flow_hash_reply) \
3821 _(sw_interface_ip6_enable_disable_reply) \
3822 _(sw_interface_ip6_set_link_local_address_reply) \
3823 _(sw_interface_ip6nd_ra_prefix_reply) \
3824 _(sw_interface_ip6nd_ra_config_reply) \
3825 _(set_arp_neighbor_limit_reply) \
3826 _(l2_patch_add_del_reply) \
3827 _(sr_tunnel_add_del_reply) \
3828 _(sr_policy_add_del_reply) \
3829 _(sr_multicast_map_add_del_reply) \
3830 _(classify_add_del_session_reply) \
3831 _(classify_set_interface_ip_table_reply) \
3832 _(classify_set_interface_l2_tables_reply) \
3833 _(l2tpv3_set_tunnel_cookies_reply) \
3834 _(l2tpv3_interface_enable_disable_reply) \
3835 _(l2tpv3_set_lookup_key_reply) \
3836 _(l2_fib_clear_table_reply) \
3837 _(l2_interface_efp_filter_reply) \
3838 _(l2_interface_vlan_tag_rewrite_reply) \
3839 _(modify_vhost_user_if_reply) \
3840 _(delete_vhost_user_if_reply) \
3841 _(want_ip4_arp_events_reply) \
3842 _(want_ip6_nd_events_reply) \
3843 _(input_acl_set_interface_reply) \
3844 _(ipsec_spd_add_del_reply) \
3845 _(ipsec_interface_add_del_spd_reply) \
3846 _(ipsec_spd_add_del_entry_reply) \
3847 _(ipsec_sad_add_del_entry_reply) \
3848 _(ipsec_sa_set_key_reply) \
3849 _(ikev2_profile_add_del_reply) \
3850 _(ikev2_profile_set_auth_reply) \
3851 _(ikev2_profile_set_id_reply) \
3852 _(ikev2_profile_set_ts_reply) \
3853 _(ikev2_set_local_key_reply) \
3854 _(ikev2_set_responder_reply) \
3855 _(ikev2_set_ike_transforms_reply) \
3856 _(ikev2_set_esp_transforms_reply) \
3857 _(ikev2_set_sa_lifetime_reply) \
3858 _(ikev2_initiate_sa_init_reply) \
3859 _(ikev2_initiate_del_ike_sa_reply) \
3860 _(ikev2_initiate_del_child_sa_reply) \
3861 _(ikev2_initiate_rekey_child_sa_reply) \
3862 _(delete_loopback_reply) \
3863 _(bd_ip_mac_add_del_reply) \
3864 _(map_del_domain_reply) \
3865 _(map_add_del_rule_reply) \
3866 _(want_interface_events_reply) \
3867 _(want_stats_reply) \
3868 _(cop_interface_enable_disable_reply) \
3869 _(cop_whitelist_enable_disable_reply) \
3870 _(sw_interface_clear_stats_reply) \
3871 _(ioam_enable_reply) \
3872 _(ioam_disable_reply) \
3873 _(one_add_del_locator_reply) \
3874 _(one_add_del_local_eid_reply) \
3875 _(one_add_del_remote_mapping_reply) \
3876 _(one_add_del_adjacency_reply) \
3877 _(one_add_del_map_resolver_reply) \
3878 _(one_add_del_map_server_reply) \
3879 _(one_enable_disable_reply) \
3880 _(one_rloc_probe_enable_disable_reply) \
3881 _(one_map_register_enable_disable_reply) \
3882 _(one_pitr_set_locator_set_reply) \
3883 _(one_map_request_mode_reply) \
3884 _(one_add_del_map_request_itr_rlocs_reply) \
3885 _(one_eid_table_add_del_map_reply) \
3886 _(gpe_add_del_fwd_entry_reply) \
3887 _(gpe_enable_disable_reply) \
3888 _(gpe_add_del_iface_reply) \
3889 _(vxlan_gpe_add_del_tunnel_reply) \
3890 _(af_packet_delete_reply) \
3891 _(policer_classify_set_interface_reply) \
3892 _(netmap_create_reply) \
3893 _(netmap_delete_reply) \
3894 _(set_ipfix_exporter_reply) \
3895 _(set_ipfix_classify_stream_reply) \
3896 _(ipfix_classify_table_add_del_reply) \
3897 _(flow_classify_set_interface_reply) \
3898 _(sw_interface_span_enable_disable_reply) \
3899 _(pg_capture_reply) \
3900 _(pg_enable_disable_reply) \
3901 _(ip_source_and_port_range_check_add_del_reply) \
3902 _(ip_source_and_port_range_check_interface_add_del_reply)\
3903 _(delete_subif_reply) \
3904 _(l2_interface_pbb_tag_rewrite_reply) \
3906 _(feature_enable_disable_reply) \
3907 _(sw_interface_tag_add_del_reply) \
3908 _(sw_interface_set_mtu_reply)
3911 #define foreach_standard_dpdk_reply_retval_handler \
3912 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3913 _(sw_interface_set_dpdk_hqos_subport_reply) \
3914 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3918 static void vl_api_##n##_t_handler \
3919 (vl_api_##n##_t * mp) \
3921 vat_main_t * vam = &vat_main; \
3922 i32 retval = ntohl(mp->retval); \
3923 if (vam->async_mode) { \
3924 vam->async_errors += (retval < 0); \
3926 vam->retval = retval; \
3927 vam->result_ready = 1; \
3930 foreach_standard_reply_retval_handler;
3934 static void vl_api_##n##_t_handler_json \
3935 (vl_api_##n##_t * mp) \
3937 vat_main_t * vam = &vat_main; \
3938 vat_json_node_t node; \
3939 vat_json_init_object(&node); \
3940 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3941 vat_json_print(vam->ofp, &node); \
3942 vam->retval = ntohl(mp->retval); \
3943 vam->result_ready = 1; \
3945 foreach_standard_reply_retval_handler;
3950 static void vl_api_##n##_t_handler \
3951 (vl_api_##n##_t * mp) \
3953 vat_main_t * vam = &vat_main; \
3954 i32 retval = ntohl(mp->retval); \
3955 if (vam->async_mode) { \
3956 vam->async_errors += (retval < 0); \
3958 vam->retval = retval; \
3959 vam->result_ready = 1; \
3962 foreach_standard_dpdk_reply_retval_handler;
3966 static void vl_api_##n##_t_handler_json \
3967 (vl_api_##n##_t * mp) \
3969 vat_main_t * vam = &vat_main; \
3970 vat_json_node_t node; \
3971 vat_json_init_object(&node); \
3972 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3973 vat_json_print(vam->ofp, &node); \
3974 vam->retval = ntohl(mp->retval); \
3975 vam->result_ready = 1; \
3977 foreach_standard_dpdk_reply_retval_handler;
3982 * Table of message reply handlers, must include boilerplate handlers
3986 #define foreach_vpe_api_reply_msg \
3987 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3988 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3989 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3990 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3991 _(CONTROL_PING_REPLY, control_ping_reply) \
3992 _(CLI_REPLY, cli_reply) \
3993 _(CLI_INBAND_REPLY, cli_inband_reply) \
3994 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3995 sw_interface_add_del_address_reply) \
3996 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3997 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3998 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3999 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4000 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4001 sw_interface_set_l2_xconnect_reply) \
4002 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4003 sw_interface_set_l2_bridge_reply) \
4004 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4005 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4006 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4007 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4008 _(L2_FLAGS_REPLY, l2_flags_reply) \
4009 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4010 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4011 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4012 _(TAP_DELETE_REPLY, tap_delete_reply) \
4013 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4014 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4015 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4016 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4017 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4018 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4019 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4020 proxy_arp_intfc_enable_disable_reply) \
4021 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4022 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4023 sw_interface_set_unnumbered_reply) \
4024 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4025 _(RESET_VRF_REPLY, reset_vrf_reply) \
4026 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4027 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4028 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4029 _(RESET_FIB_REPLY, reset_fib_reply) \
4030 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4031 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4032 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4033 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4034 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4035 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4036 sw_interface_ip6_enable_disable_reply) \
4037 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4038 sw_interface_ip6_set_link_local_address_reply) \
4039 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4040 sw_interface_ip6nd_ra_prefix_reply) \
4041 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4042 sw_interface_ip6nd_ra_config_reply) \
4043 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4044 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4045 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4046 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4047 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4048 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4049 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4050 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4051 classify_set_interface_ip_table_reply) \
4052 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4053 classify_set_interface_l2_tables_reply) \
4054 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4055 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4056 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4057 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4058 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4059 l2tpv3_interface_enable_disable_reply) \
4060 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4061 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4062 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4063 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4064 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4065 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4066 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4067 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4068 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4069 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4070 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4071 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4072 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4073 _(SHOW_VERSION_REPLY, show_version_reply) \
4074 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4075 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4076 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4077 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4078 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4079 _(IP4_ARP_EVENT, ip4_arp_event) \
4080 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4081 _(IP6_ND_EVENT, ip6_nd_event) \
4082 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4083 _(IP_ADDRESS_DETAILS, ip_address_details) \
4084 _(IP_DETAILS, ip_details) \
4085 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4086 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4087 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4088 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4089 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4090 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4091 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4092 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4093 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4094 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4095 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4096 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4097 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4098 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4099 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4100 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4101 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4102 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4103 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4104 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4105 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4106 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4107 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4108 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4109 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4110 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4111 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4112 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4113 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4114 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4115 _(MAP_RULE_DETAILS, map_rule_details) \
4116 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4117 _(WANT_STATS_REPLY, want_stats_reply) \
4118 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4119 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4120 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4121 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4122 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4123 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4124 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4125 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4126 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4127 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4128 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4129 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4130 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4131 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4132 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4133 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4134 one_map_register_enable_disable_reply) \
4135 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4136 one_rloc_probe_enable_disable_reply) \
4137 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4138 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4139 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4140 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4141 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4142 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4143 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4144 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4145 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4146 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4147 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4148 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4149 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4150 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4151 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4152 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4153 gpe_fwd_entry_path_details) \
4154 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4155 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4156 one_add_del_map_request_itr_rlocs_reply) \
4157 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4158 one_get_map_request_itr_rlocs_reply) \
4159 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4160 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4161 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4162 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4163 show_one_map_register_state_reply) \
4164 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4165 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4166 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4167 _(POLICER_DETAILS, policer_details) \
4168 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4169 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4170 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4171 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4172 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4173 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4174 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4175 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4176 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4177 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4178 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4179 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4180 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4181 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4182 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4183 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4184 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4185 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4186 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4187 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4188 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4189 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4190 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4191 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4192 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4193 ip_source_and_port_range_check_add_del_reply) \
4194 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4195 ip_source_and_port_range_check_interface_add_del_reply) \
4196 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4197 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4198 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4199 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4200 _(PUNT_REPLY, punt_reply) \
4201 _(IP_FIB_DETAILS, ip_fib_details) \
4202 _(IP6_FIB_DETAILS, ip6_fib_details) \
4203 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4204 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4205 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4206 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4207 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4208 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4211 #define foreach_vpe_dpdk_api_reply_msg \
4212 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4213 sw_interface_set_dpdk_hqos_pipe_reply) \
4214 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4215 sw_interface_set_dpdk_hqos_subport_reply) \
4216 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4217 sw_interface_set_dpdk_hqos_tctbl_reply)
4227 #define STR_VTR_OP_CASE(op) \
4228 case L2_VTR_ ## op: \
4232 str_vtr_op (u32 vtr_op)
4236 STR_VTR_OP_CASE (DISABLED);
4237 STR_VTR_OP_CASE (PUSH_1);
4238 STR_VTR_OP_CASE (PUSH_2);
4239 STR_VTR_OP_CASE (POP_1);
4240 STR_VTR_OP_CASE (POP_2);
4241 STR_VTR_OP_CASE (TRANSLATE_1_1);
4242 STR_VTR_OP_CASE (TRANSLATE_1_2);
4243 STR_VTR_OP_CASE (TRANSLATE_2_1);
4244 STR_VTR_OP_CASE (TRANSLATE_2_2);
4251 dump_sub_interface_table (vat_main_t * vam)
4253 const sw_interface_subif_t *sub = NULL;
4255 if (vam->json_output)
4258 ("JSON output supported only for VPE API calls and dump_stats_table");
4263 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4264 "Interface", "sw_if_index",
4265 "sub id", "dot1ad", "tags", "outer id",
4266 "inner id", "exact", "default", "outer any", "inner any");
4268 vec_foreach (sub, vam->sw_if_subif_table)
4271 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4272 sub->interface_name,
4274 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4275 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4276 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4277 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4278 if (sub->vtr_op != L2_VTR_DISABLED)
4281 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4282 "tag1: %d tag2: %d ]",
4283 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4284 sub->vtr_tag1, sub->vtr_tag2);
4292 name_sort_cmp (void *a1, void *a2)
4294 name_sort_t *n1 = a1;
4295 name_sort_t *n2 = a2;
4297 return strcmp ((char *) n1->name, (char *) n2->name);
4301 dump_interface_table (vat_main_t * vam)
4304 name_sort_t *nses = 0, *ns;
4306 if (vam->json_output)
4309 ("JSON output supported only for VPE API calls and dump_stats_table");
4314 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4316 vec_add2 (nses, ns, 1);
4317 ns->name = (u8 *)(p->key);
4318 ns->value = (u32) p->value[0];
4322 vec_sort_with_function (nses, name_sort_cmp);
4324 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4325 vec_foreach (ns, nses)
4327 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4334 dump_ip_table (vat_main_t * vam, int is_ipv6)
4336 const ip_details_t *det = NULL;
4337 const ip_address_details_t *address = NULL;
4340 print (vam->ofp, "%-12s", "sw_if_index");
4342 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4349 print (vam->ofp, "%-12d", i);
4350 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4355 vec_foreach (address, det->addr)
4359 is_ipv6 ? format_ip6_address : format_ip4_address,
4360 address->ip, address->prefix_length);
4368 dump_ipv4_table (vat_main_t * vam)
4370 if (vam->json_output)
4373 ("JSON output supported only for VPE API calls and dump_stats_table");
4377 return dump_ip_table (vam, 0);
4381 dump_ipv6_table (vat_main_t * vam)
4383 if (vam->json_output)
4386 ("JSON output supported only for VPE API calls and dump_stats_table");
4390 return dump_ip_table (vam, 1);
4394 counter_type_to_str (u8 counter_type, u8 is_combined)
4398 switch (counter_type)
4400 case VNET_INTERFACE_COUNTER_DROP:
4402 case VNET_INTERFACE_COUNTER_PUNT:
4404 case VNET_INTERFACE_COUNTER_IP4:
4406 case VNET_INTERFACE_COUNTER_IP6:
4408 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4410 case VNET_INTERFACE_COUNTER_RX_MISS:
4412 case VNET_INTERFACE_COUNTER_RX_ERROR:
4414 case VNET_INTERFACE_COUNTER_TX_ERROR:
4417 return "INVALID-COUNTER-TYPE";
4422 switch (counter_type)
4424 case VNET_INTERFACE_COUNTER_RX:
4426 case VNET_INTERFACE_COUNTER_TX:
4429 return "INVALID-COUNTER-TYPE";
4435 dump_stats_table (vat_main_t * vam)
4437 vat_json_node_t node;
4438 vat_json_node_t *msg_array;
4439 vat_json_node_t *msg;
4440 vat_json_node_t *counter_array;
4441 vat_json_node_t *counter;
4442 interface_counter_t c;
4444 ip4_fib_counter_t *c4;
4445 ip6_fib_counter_t *c6;
4446 ip4_nbr_counter_t *n4;
4447 ip6_nbr_counter_t *n6;
4450 if (!vam->json_output)
4452 clib_warning ("dump_stats_table supported only in JSON format");
4456 vat_json_init_object (&node);
4458 /* interface counters */
4459 msg_array = vat_json_object_add (&node, "interface_counters");
4460 vat_json_init_array (msg_array);
4461 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4463 msg = vat_json_array_add (msg_array);
4464 vat_json_init_object (msg);
4465 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4466 (u8 *) counter_type_to_str (i, 0));
4467 vat_json_object_add_int (msg, "is_combined", 0);
4468 counter_array = vat_json_object_add (msg, "data");
4469 vat_json_init_array (counter_array);
4470 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4472 packets = vam->simple_interface_counters[i][j];
4473 vat_json_array_add_uint (counter_array, packets);
4476 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4478 msg = vat_json_array_add (msg_array);
4479 vat_json_init_object (msg);
4480 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4481 (u8 *) counter_type_to_str (i, 1));
4482 vat_json_object_add_int (msg, "is_combined", 1);
4483 counter_array = vat_json_object_add (msg, "data");
4484 vat_json_init_array (counter_array);
4485 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4487 c = vam->combined_interface_counters[i][j];
4488 counter = vat_json_array_add (counter_array);
4489 vat_json_init_object (counter);
4490 vat_json_object_add_uint (counter, "packets", c.packets);
4491 vat_json_object_add_uint (counter, "bytes", c.bytes);
4495 /* ip4 fib counters */
4496 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4497 vat_json_init_array (msg_array);
4498 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4500 msg = vat_json_array_add (msg_array);
4501 vat_json_init_object (msg);
4502 vat_json_object_add_uint (msg, "vrf_id",
4503 vam->ip4_fib_counters_vrf_id_by_index[i]);
4504 counter_array = vat_json_object_add (msg, "c");
4505 vat_json_init_array (counter_array);
4506 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4508 counter = vat_json_array_add (counter_array);
4509 vat_json_init_object (counter);
4510 c4 = &vam->ip4_fib_counters[i][j];
4511 vat_json_object_add_ip4 (counter, "address", c4->address);
4512 vat_json_object_add_uint (counter, "address_length",
4513 c4->address_length);
4514 vat_json_object_add_uint (counter, "packets", c4->packets);
4515 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4519 /* ip6 fib counters */
4520 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4521 vat_json_init_array (msg_array);
4522 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4524 msg = vat_json_array_add (msg_array);
4525 vat_json_init_object (msg);
4526 vat_json_object_add_uint (msg, "vrf_id",
4527 vam->ip6_fib_counters_vrf_id_by_index[i]);
4528 counter_array = vat_json_object_add (msg, "c");
4529 vat_json_init_array (counter_array);
4530 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4532 counter = vat_json_array_add (counter_array);
4533 vat_json_init_object (counter);
4534 c6 = &vam->ip6_fib_counters[i][j];
4535 vat_json_object_add_ip6 (counter, "address", c6->address);
4536 vat_json_object_add_uint (counter, "address_length",
4537 c6->address_length);
4538 vat_json_object_add_uint (counter, "packets", c6->packets);
4539 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4543 /* ip4 nbr counters */
4544 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4545 vat_json_init_array (msg_array);
4546 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4548 msg = vat_json_array_add (msg_array);
4549 vat_json_init_object (msg);
4550 vat_json_object_add_uint (msg, "sw_if_index", i);
4551 counter_array = vat_json_object_add (msg, "c");
4552 vat_json_init_array (counter_array);
4553 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4555 counter = vat_json_array_add (counter_array);
4556 vat_json_init_object (counter);
4557 n4 = &vam->ip4_nbr_counters[i][j];
4558 vat_json_object_add_ip4 (counter, "address", n4->address);
4559 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4560 vat_json_object_add_uint (counter, "packets", n4->packets);
4561 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4565 /* ip6 nbr counters */
4566 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4567 vat_json_init_array (msg_array);
4568 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4570 msg = vat_json_array_add (msg_array);
4571 vat_json_init_object (msg);
4572 vat_json_object_add_uint (msg, "sw_if_index", i);
4573 counter_array = vat_json_object_add (msg, "c");
4574 vat_json_init_array (counter_array);
4575 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4577 counter = vat_json_array_add (counter_array);
4578 vat_json_init_object (counter);
4579 n6 = &vam->ip6_nbr_counters[i][j];
4580 vat_json_object_add_ip6 (counter, "address", n6->address);
4581 vat_json_object_add_uint (counter, "packets", n6->packets);
4582 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4586 vat_json_print (vam->ofp, &node);
4587 vat_json_free (&node);
4593 exec (vat_main_t * vam)
4595 api_main_t *am = &api_main;
4596 vl_api_cli_request_t *mp;
4600 unformat_input_t *i = vam->input;
4602 if (vec_len (i->buffer) == 0)
4605 if (vam->exec_mode == 0 && unformat (i, "mode"))
4610 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4617 M (CLI_REQUEST, mp);
4620 * Copy cmd into shared memory.
4621 * In order for the CLI command to work, it
4622 * must be a vector ending in \n, not a C-string ending
4625 pthread_mutex_lock (&am->vlib_rp->mutex);
4626 oldheap = svm_push_data_heap (am->vlib_rp);
4628 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4629 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4631 svm_pop_heap (oldheap);
4632 pthread_mutex_unlock (&am->vlib_rp->mutex);
4634 mp->cmd_in_shmem = (u64) cmd;
4636 timeout = vat_time_now (vam) + 10.0;
4638 while (vat_time_now (vam) < timeout)
4640 if (vam->result_ready == 1)
4643 if (vam->shmem_result != NULL)
4644 print (vam->ofp, "%s", vam->shmem_result);
4645 pthread_mutex_lock (&am->vlib_rp->mutex);
4646 oldheap = svm_push_data_heap (am->vlib_rp);
4648 free_me = (u8 *) vam->shmem_result;
4651 svm_pop_heap (oldheap);
4652 pthread_mutex_unlock (&am->vlib_rp->mutex);
4660 * Future replacement of exec() that passes CLI buffers directly in
4661 * the API messages instead of an additional shared memory area.
4664 exec_inband (vat_main_t * vam)
4666 vl_api_cli_inband_t *mp;
4667 unformat_input_t *i = vam->input;
4670 if (vec_len (i->buffer) == 0)
4673 if (vam->exec_mode == 0 && unformat (i, "mode"))
4678 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4685 * In order for the CLI command to work, it
4686 * must be a vector ending in \n, not a C-string ending
4689 u32 len = vec_len (vam->input->buffer);
4690 M2 (CLI_INBAND, mp, len);
4691 clib_memcpy (mp->cmd, vam->input->buffer, len);
4692 mp->length = htonl (len);
4695 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4700 api_create_loopback (vat_main_t * vam)
4702 unformat_input_t *i = vam->input;
4703 vl_api_create_loopback_t *mp;
4708 memset (mac_address, 0, sizeof (mac_address));
4710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4712 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4718 /* Construct the API message */
4719 M (CREATE_LOOPBACK, mp);
4721 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4729 api_delete_loopback (vat_main_t * vam)
4731 unformat_input_t *i = vam->input;
4732 vl_api_delete_loopback_t *mp;
4733 u32 sw_if_index = ~0;
4736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4738 if (unformat (i, "sw_if_index %d", &sw_if_index))
4744 if (sw_if_index == ~0)
4746 errmsg ("missing sw_if_index");
4750 /* Construct the API message */
4751 M (DELETE_LOOPBACK, mp);
4752 mp->sw_if_index = ntohl (sw_if_index);
4760 api_want_stats (vat_main_t * vam)
4762 unformat_input_t *i = vam->input;
4763 vl_api_want_stats_t *mp;
4767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4769 if (unformat (i, "enable"))
4771 else if (unformat (i, "disable"))
4779 errmsg ("missing enable|disable");
4784 mp->enable_disable = enable;
4792 api_want_interface_events (vat_main_t * vam)
4794 unformat_input_t *i = vam->input;
4795 vl_api_want_interface_events_t *mp;
4799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4801 if (unformat (i, "enable"))
4803 else if (unformat (i, "disable"))
4811 errmsg ("missing enable|disable");
4815 M (WANT_INTERFACE_EVENTS, mp);
4816 mp->enable_disable = enable;
4818 vam->interface_event_display = enable;
4826 /* Note: non-static, called once to set up the initial intfc table */
4828 api_sw_interface_dump (vat_main_t * vam)
4830 vl_api_sw_interface_dump_t *mp;
4831 vl_api_control_ping_t *mp_ping;
4833 name_sort_t *nses = 0, *ns;
4834 sw_interface_subif_t *sub = NULL;
4837 /* Toss the old name table */
4839 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4841 vec_add2 (nses, ns, 1);
4842 ns->name = (u8 *)(p->key);
4843 ns->value = (u32) p->value[0];
4847 hash_free (vam->sw_if_index_by_interface_name);
4849 vec_foreach (ns, nses) vec_free (ns->name);
4853 vec_foreach (sub, vam->sw_if_subif_table)
4855 vec_free (sub->interface_name);
4857 vec_free (vam->sw_if_subif_table);
4859 /* recreate the interface name hash table */
4860 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4862 /* Get list of ethernets */
4863 M (SW_INTERFACE_DUMP, mp);
4864 mp->name_filter_valid = 1;
4865 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4868 /* and local / loopback interfaces */
4869 M (SW_INTERFACE_DUMP, mp);
4870 mp->name_filter_valid = 1;
4871 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4874 /* and packet-generator interfaces */
4875 M (SW_INTERFACE_DUMP, mp);
4876 mp->name_filter_valid = 1;
4877 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4880 /* and vxlan-gpe tunnel interfaces */
4881 M (SW_INTERFACE_DUMP, mp);
4882 mp->name_filter_valid = 1;
4883 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4884 sizeof (mp->name_filter) - 1);
4887 /* and vxlan tunnel interfaces */
4888 M (SW_INTERFACE_DUMP, mp);
4889 mp->name_filter_valid = 1;
4890 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4893 /* and host (af_packet) interfaces */
4894 M (SW_INTERFACE_DUMP, mp);
4895 mp->name_filter_valid = 1;
4896 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4899 /* and l2tpv3 tunnel interfaces */
4900 M (SW_INTERFACE_DUMP, mp);
4901 mp->name_filter_valid = 1;
4902 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4903 sizeof (mp->name_filter) - 1);
4906 /* and GRE tunnel interfaces */
4907 M (SW_INTERFACE_DUMP, mp);
4908 mp->name_filter_valid = 1;
4909 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4912 /* and LISP-GPE interfaces */
4913 M (SW_INTERFACE_DUMP, mp);
4914 mp->name_filter_valid = 1;
4915 strncpy ((char *) mp->name_filter, "lisp_gpe",
4916 sizeof (mp->name_filter) - 1);
4919 /* and IPSEC tunnel interfaces */
4920 M (SW_INTERFACE_DUMP, mp);
4921 mp->name_filter_valid = 1;
4922 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4925 /* Use a control ping for synchronization */
4926 M (CONTROL_PING, mp_ping);
4934 api_sw_interface_set_flags (vat_main_t * vam)
4936 unformat_input_t *i = vam->input;
4937 vl_api_sw_interface_set_flags_t *mp;
4939 u8 sw_if_index_set = 0;
4940 u8 admin_up = 0, link_up = 0;
4943 /* Parse args required to build the message */
4944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4946 if (unformat (i, "admin-up"))
4948 else if (unformat (i, "admin-down"))
4950 else if (unformat (i, "link-up"))
4952 else if (unformat (i, "link-down"))
4955 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4956 sw_if_index_set = 1;
4957 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4958 sw_if_index_set = 1;
4963 if (sw_if_index_set == 0)
4965 errmsg ("missing interface name or sw_if_index");
4969 /* Construct the API message */
4970 M (SW_INTERFACE_SET_FLAGS, mp);
4971 mp->sw_if_index = ntohl (sw_if_index);
4972 mp->admin_up_down = admin_up;
4973 mp->link_up_down = link_up;
4978 /* Wait for a reply, return the good/bad news... */
4984 api_sw_interface_clear_stats (vat_main_t * vam)
4986 unformat_input_t *i = vam->input;
4987 vl_api_sw_interface_clear_stats_t *mp;
4989 u8 sw_if_index_set = 0;
4992 /* Parse args required to build the message */
4993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4996 sw_if_index_set = 1;
4997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4998 sw_if_index_set = 1;
5003 /* Construct the API message */
5004 M (SW_INTERFACE_CLEAR_STATS, mp);
5006 if (sw_if_index_set == 1)
5007 mp->sw_if_index = ntohl (sw_if_index);
5009 mp->sw_if_index = ~0;
5014 /* Wait for a reply, return the good/bad news... */
5021 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
5023 unformat_input_t *i = vam->input;
5024 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
5026 u8 sw_if_index_set = 0;
5035 /* Parse args required to build the message */
5036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5038 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5039 sw_if_index_set = 1;
5040 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5041 sw_if_index_set = 1;
5042 else if (unformat (i, "subport %u", &subport))
5045 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5046 sw_if_index_set = 1;
5047 else if (unformat (i, "pipe %u", &pipe))
5049 else if (unformat (i, "profile %u", &profile))
5055 if (sw_if_index_set == 0)
5057 errmsg ("missing interface name or sw_if_index");
5061 if (subport_set == 0)
5063 errmsg ("missing subport ");
5069 errmsg ("missing pipe");
5073 if (profile_set == 0)
5075 errmsg ("missing profile");
5079 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
5081 mp->sw_if_index = ntohl (sw_if_index);
5082 mp->subport = ntohl (subport);
5083 mp->pipe = ntohl (pipe);
5084 mp->profile = ntohl (profile);
5093 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
5095 unformat_input_t *i = vam->input;
5096 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
5098 u8 sw_if_index_set = 0;
5101 u32 tb_rate = 1250000000; /* 10GbE */
5102 u32 tb_size = 1000000;
5103 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
5107 /* Parse args required to build the message */
5108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5110 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5111 sw_if_index_set = 1;
5112 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5113 sw_if_index_set = 1;
5114 else if (unformat (i, "subport %u", &subport))
5117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5118 sw_if_index_set = 1;
5119 else if (unformat (i, "rate %u", &tb_rate))
5123 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
5125 tc_rate[tc_id] = tb_rate;
5127 else if (unformat (i, "bktsize %u", &tb_size))
5129 else if (unformat (i, "tc0 %u", &tc_rate[0]))
5131 else if (unformat (i, "tc1 %u", &tc_rate[1]))
5133 else if (unformat (i, "tc2 %u", &tc_rate[2]))
5135 else if (unformat (i, "tc3 %u", &tc_rate[3]))
5137 else if (unformat (i, "period %u", &tc_period))
5143 if (sw_if_index_set == 0)
5145 errmsg ("missing interface name or sw_if_index");
5149 if (subport_set == 0)
5151 errmsg ("missing subport ");
5155 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
5157 mp->sw_if_index = ntohl (sw_if_index);
5158 mp->subport = ntohl (subport);
5159 mp->tb_rate = ntohl (tb_rate);
5160 mp->tb_size = ntohl (tb_size);
5161 mp->tc_rate[0] = ntohl (tc_rate[0]);
5162 mp->tc_rate[1] = ntohl (tc_rate[1]);
5163 mp->tc_rate[2] = ntohl (tc_rate[2]);
5164 mp->tc_rate[3] = ntohl (tc_rate[3]);
5165 mp->tc_period = ntohl (tc_period);
5173 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
5175 unformat_input_t *i = vam->input;
5176 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
5178 u8 sw_if_index_set = 0;
5182 u32 entry, tc, queue;
5185 /* Parse args required to build the message */
5186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5188 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5189 sw_if_index_set = 1;
5190 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5191 sw_if_index_set = 1;
5192 else if (unformat (i, "entry %d", &entry))
5194 else if (unformat (i, "tc %d", &tc))
5196 else if (unformat (i, "queue %d", &queue))
5202 if (sw_if_index_set == 0)
5204 errmsg ("missing interface name or sw_if_index");
5210 errmsg ("missing entry ");
5216 errmsg ("missing traffic class ");
5222 errmsg ("missing queue ");
5226 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
5228 mp->sw_if_index = ntohl (sw_if_index);
5229 mp->entry = ntohl (entry);
5230 mp->tc = ntohl (tc);
5231 mp->queue = ntohl (queue);
5240 api_sw_interface_add_del_address (vat_main_t * vam)
5242 unformat_input_t *i = vam->input;
5243 vl_api_sw_interface_add_del_address_t *mp;
5245 u8 sw_if_index_set = 0;
5246 u8 is_add = 1, del_all = 0;
5247 u32 address_length = 0;
5248 u8 v4_address_set = 0;
5249 u8 v6_address_set = 0;
5250 ip4_address_t v4address;
5251 ip6_address_t v6address;
5254 /* Parse args required to build the message */
5255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5257 if (unformat (i, "del-all"))
5259 else if (unformat (i, "del"))
5262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5263 sw_if_index_set = 1;
5264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5265 sw_if_index_set = 1;
5266 else if (unformat (i, "%U/%d",
5267 unformat_ip4_address, &v4address, &address_length))
5269 else if (unformat (i, "%U/%d",
5270 unformat_ip6_address, &v6address, &address_length))
5276 if (sw_if_index_set == 0)
5278 errmsg ("missing interface name or sw_if_index");
5281 if (v4_address_set && v6_address_set)
5283 errmsg ("both v4 and v6 addresses set");
5286 if (!v4_address_set && !v6_address_set && !del_all)
5288 errmsg ("no addresses set");
5292 /* Construct the API message */
5293 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5295 mp->sw_if_index = ntohl (sw_if_index);
5296 mp->is_add = is_add;
5297 mp->del_all = del_all;
5301 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5305 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5307 mp->address_length = address_length;
5312 /* Wait for a reply, return good/bad news */
5318 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5320 unformat_input_t *i = vam->input;
5321 vl_api_sw_interface_set_mpls_enable_t *mp;
5323 u8 sw_if_index_set = 0;
5327 /* Parse args required to build the message */
5328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5330 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5331 sw_if_index_set = 1;
5332 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5333 sw_if_index_set = 1;
5334 else if (unformat (i, "disable"))
5336 else if (unformat (i, "dis"))
5342 if (sw_if_index_set == 0)
5344 errmsg ("missing interface name or sw_if_index");
5348 /* Construct the API message */
5349 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5351 mp->sw_if_index = ntohl (sw_if_index);
5352 mp->enable = enable;
5357 /* Wait for a reply... */
5363 api_sw_interface_set_table (vat_main_t * vam)
5365 unformat_input_t *i = vam->input;
5366 vl_api_sw_interface_set_table_t *mp;
5367 u32 sw_if_index, vrf_id = 0;
5368 u8 sw_if_index_set = 0;
5372 /* Parse args required to build the message */
5373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5375 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5376 sw_if_index_set = 1;
5377 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5378 sw_if_index_set = 1;
5379 else if (unformat (i, "vrf %d", &vrf_id))
5381 else if (unformat (i, "ipv6"))
5387 if (sw_if_index_set == 0)
5389 errmsg ("missing interface name or sw_if_index");
5393 /* Construct the API message */
5394 M (SW_INTERFACE_SET_TABLE, mp);
5396 mp->sw_if_index = ntohl (sw_if_index);
5397 mp->is_ipv6 = is_ipv6;
5398 mp->vrf_id = ntohl (vrf_id);
5403 /* Wait for a reply... */
5408 static void vl_api_sw_interface_get_table_reply_t_handler
5409 (vl_api_sw_interface_get_table_reply_t * mp)
5411 vat_main_t *vam = &vat_main;
5413 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5415 vam->retval = ntohl (mp->retval);
5416 vam->result_ready = 1;
5420 static void vl_api_sw_interface_get_table_reply_t_handler_json
5421 (vl_api_sw_interface_get_table_reply_t * mp)
5423 vat_main_t *vam = &vat_main;
5424 vat_json_node_t node;
5426 vat_json_init_object (&node);
5427 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5428 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5430 vat_json_print (vam->ofp, &node);
5431 vat_json_free (&node);
5433 vam->retval = ntohl (mp->retval);
5434 vam->result_ready = 1;
5438 api_sw_interface_get_table (vat_main_t * vam)
5440 unformat_input_t *i = vam->input;
5441 vl_api_sw_interface_get_table_t *mp;
5443 u8 sw_if_index_set = 0;
5447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5449 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5450 sw_if_index_set = 1;
5451 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5452 sw_if_index_set = 1;
5453 else if (unformat (i, "ipv6"))
5459 if (sw_if_index_set == 0)
5461 errmsg ("missing interface name or sw_if_index");
5465 M (SW_INTERFACE_GET_TABLE, mp);
5466 mp->sw_if_index = htonl (sw_if_index);
5467 mp->is_ipv6 = is_ipv6;
5475 api_sw_interface_set_vpath (vat_main_t * vam)
5477 unformat_input_t *i = vam->input;
5478 vl_api_sw_interface_set_vpath_t *mp;
5479 u32 sw_if_index = 0;
5480 u8 sw_if_index_set = 0;
5484 /* Parse args required to build the message */
5485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5487 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5488 sw_if_index_set = 1;
5489 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5490 sw_if_index_set = 1;
5491 else if (unformat (i, "enable"))
5493 else if (unformat (i, "disable"))
5499 if (sw_if_index_set == 0)
5501 errmsg ("missing interface name or sw_if_index");
5505 /* Construct the API message */
5506 M (SW_INTERFACE_SET_VPATH, mp);
5508 mp->sw_if_index = ntohl (sw_if_index);
5509 mp->enable = is_enable;
5514 /* Wait for a reply... */
5520 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5522 unformat_input_t *i = vam->input;
5523 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5524 u32 sw_if_index = 0;
5525 u8 sw_if_index_set = 0;
5530 /* Parse args required to build the message */
5531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5534 sw_if_index_set = 1;
5535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5536 sw_if_index_set = 1;
5537 else if (unformat (i, "enable"))
5539 else if (unformat (i, "disable"))
5541 else if (unformat (i, "ip4"))
5543 else if (unformat (i, "ip6"))
5549 if (sw_if_index_set == 0)
5551 errmsg ("missing interface name or sw_if_index");
5555 /* Construct the API message */
5556 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5558 mp->sw_if_index = ntohl (sw_if_index);
5559 mp->enable = is_enable;
5560 mp->is_ipv6 = is_ipv6;
5565 /* Wait for a reply... */
5571 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5573 unformat_input_t *i = vam->input;
5574 vl_api_sw_interface_set_l2_xconnect_t *mp;
5576 u8 rx_sw_if_index_set = 0;
5578 u8 tx_sw_if_index_set = 0;
5582 /* Parse args required to build the message */
5583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5585 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5586 rx_sw_if_index_set = 1;
5587 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5588 tx_sw_if_index_set = 1;
5589 else if (unformat (i, "rx"))
5591 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5593 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5595 rx_sw_if_index_set = 1;
5600 else if (unformat (i, "tx"))
5602 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5604 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5606 tx_sw_if_index_set = 1;
5611 else if (unformat (i, "enable"))
5613 else if (unformat (i, "disable"))
5619 if (rx_sw_if_index_set == 0)
5621 errmsg ("missing rx interface name or rx_sw_if_index");
5625 if (enable && (tx_sw_if_index_set == 0))
5627 errmsg ("missing tx interface name or tx_sw_if_index");
5631 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5633 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5634 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5635 mp->enable = enable;
5643 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5645 unformat_input_t *i = vam->input;
5646 vl_api_sw_interface_set_l2_bridge_t *mp;
5648 u8 rx_sw_if_index_set = 0;
5656 /* Parse args required to build the message */
5657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5659 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5660 rx_sw_if_index_set = 1;
5661 else if (unformat (i, "bd_id %d", &bd_id))
5665 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5666 rx_sw_if_index_set = 1;
5667 else if (unformat (i, "shg %d", &shg))
5669 else if (unformat (i, "bvi"))
5671 else if (unformat (i, "enable"))
5673 else if (unformat (i, "disable"))
5679 if (rx_sw_if_index_set == 0)
5681 errmsg ("missing rx interface name or sw_if_index");
5685 if (enable && (bd_id_set == 0))
5687 errmsg ("missing bridge domain");
5691 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5693 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5694 mp->bd_id = ntohl (bd_id);
5697 mp->enable = enable;
5705 api_bridge_domain_dump (vat_main_t * vam)
5707 unformat_input_t *i = vam->input;
5708 vl_api_bridge_domain_dump_t *mp;
5709 vl_api_control_ping_t *mp_ping;
5713 /* Parse args required to build the message */
5714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5716 if (unformat (i, "bd_id %d", &bd_id))
5722 M (BRIDGE_DOMAIN_DUMP, mp);
5723 mp->bd_id = ntohl (bd_id);
5726 /* Use a control ping for synchronization */
5727 M (CONTROL_PING, mp_ping);
5735 api_bridge_domain_add_del (vat_main_t * vam)
5737 unformat_input_t *i = vam->input;
5738 vl_api_bridge_domain_add_del_t *mp;
5741 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5745 /* Parse args required to build the message */
5746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5748 if (unformat (i, "bd_id %d", &bd_id))
5750 else if (unformat (i, "flood %d", &flood))
5752 else if (unformat (i, "uu-flood %d", &uu_flood))
5754 else if (unformat (i, "forward %d", &forward))
5756 else if (unformat (i, "learn %d", &learn))
5758 else if (unformat (i, "arp-term %d", &arp_term))
5760 else if (unformat (i, "mac-age %d", &mac_age))
5762 else if (unformat (i, "del"))
5765 flood = uu_flood = forward = learn = 0;
5773 errmsg ("missing bridge domain");
5779 errmsg ("mac age must be less than 256 ");
5783 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5785 mp->bd_id = ntohl (bd_id);
5787 mp->uu_flood = uu_flood;
5788 mp->forward = forward;
5790 mp->arp_term = arp_term;
5791 mp->is_add = is_add;
5792 mp->mac_age = (u8) mac_age;
5800 api_l2fib_add_del (vat_main_t * vam)
5802 unformat_input_t *i = vam->input;
5803 vl_api_l2fib_add_del_t *mp;
5809 u32 sw_if_index = ~0;
5810 u8 sw_if_index_set = 0;
5819 /* Parse args required to build the message */
5820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5822 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5824 else if (unformat (i, "bd_id %d", &bd_id))
5826 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5827 sw_if_index_set = 1;
5828 else if (unformat (i, "sw_if"))
5830 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5833 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5834 sw_if_index_set = 1;
5839 else if (unformat (i, "static"))
5841 else if (unformat (i, "filter"))
5846 else if (unformat (i, "bvi"))
5851 else if (unformat (i, "del"))
5853 else if (unformat (i, "count %d", &count))
5861 errmsg ("missing mac address");
5867 errmsg ("missing bridge domain");
5871 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5873 errmsg ("missing interface name or sw_if_index");
5879 /* Turn on async mode */
5880 vam->async_mode = 1;
5881 vam->async_errors = 0;
5882 before = vat_time_now (vam);
5885 for (j = 0; j < count; j++)
5887 M (L2FIB_ADD_DEL, mp);
5890 mp->bd_id = ntohl (bd_id);
5891 mp->is_add = is_add;
5895 mp->sw_if_index = ntohl (sw_if_index);
5896 mp->static_mac = static_mac;
5897 mp->filter_mac = filter_mac;
5898 mp->bvi_mac = bvi_mac;
5900 increment_mac_address (&mac);
5907 vl_api_control_ping_t *mp_ping;
5910 /* Shut off async mode */
5911 vam->async_mode = 0;
5913 M (CONTROL_PING, mp_ping);
5916 timeout = vat_time_now (vam) + 1.0;
5917 while (vat_time_now (vam) < timeout)
5918 if (vam->result_ready == 1)
5923 if (vam->retval == -99)
5926 if (vam->async_errors > 0)
5928 errmsg ("%d asynchronous errors", vam->async_errors);
5931 vam->async_errors = 0;
5932 after = vat_time_now (vam);
5934 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5935 count, after - before, count / (after - before));
5941 /* Wait for a reply... */
5945 /* Return the good/bad news */
5946 return (vam->retval);
5950 api_l2_flags (vat_main_t * vam)
5952 unformat_input_t *i = vam->input;
5953 vl_api_l2_flags_t *mp;
5955 u32 feature_bitmap = 0;
5956 u8 sw_if_index_set = 0;
5959 /* Parse args required to build the message */
5960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5962 if (unformat (i, "sw_if_index %d", &sw_if_index))
5963 sw_if_index_set = 1;
5964 else if (unformat (i, "sw_if"))
5966 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5969 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5970 sw_if_index_set = 1;
5975 else if (unformat (i, "learn"))
5976 feature_bitmap |= L2INPUT_FEAT_LEARN;
5977 else if (unformat (i, "forward"))
5978 feature_bitmap |= L2INPUT_FEAT_FWD;
5979 else if (unformat (i, "flood"))
5980 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5981 else if (unformat (i, "uu-flood"))
5982 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5987 if (sw_if_index_set == 0)
5989 errmsg ("missing interface name or sw_if_index");
5995 mp->sw_if_index = ntohl (sw_if_index);
5996 mp->feature_bitmap = ntohl (feature_bitmap);
6004 api_bridge_flags (vat_main_t * vam)
6006 unformat_input_t *i = vam->input;
6007 vl_api_bridge_flags_t *mp;
6014 /* Parse args required to build the message */
6015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6017 if (unformat (i, "bd_id %d", &bd_id))
6019 else if (unformat (i, "learn"))
6021 else if (unformat (i, "forward"))
6023 else if (unformat (i, "flood"))
6025 else if (unformat (i, "uu-flood"))
6026 flags |= L2_UU_FLOOD;
6027 else if (unformat (i, "arp-term"))
6028 flags |= L2_ARP_TERM;
6029 else if (unformat (i, "off"))
6031 else if (unformat (i, "disable"))
6039 errmsg ("missing bridge domain");
6043 M (BRIDGE_FLAGS, mp);
6045 mp->bd_id = ntohl (bd_id);
6046 mp->feature_bitmap = ntohl (flags);
6047 mp->is_set = is_set;
6055 api_bd_ip_mac_add_del (vat_main_t * vam)
6057 unformat_input_t *i = vam->input;
6058 vl_api_bd_ip_mac_add_del_t *mp;
6065 ip4_address_t v4addr;
6066 ip6_address_t v6addr;
6071 /* Parse args required to build the message */
6072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6074 if (unformat (i, "bd_id %d", &bd_id))
6078 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6082 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6087 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6091 else if (unformat (i, "del"))
6099 errmsg ("missing bridge domain");
6102 else if (ip_set == 0)
6104 errmsg ("missing IP address");
6107 else if (mac_set == 0)
6109 errmsg ("missing MAC address");
6113 M (BD_IP_MAC_ADD_DEL, mp);
6115 mp->bd_id = ntohl (bd_id);
6116 mp->is_ipv6 = is_ipv6;
6117 mp->is_add = is_add;
6119 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6121 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6122 clib_memcpy (mp->mac_address, macaddr, 6);
6129 api_tap_connect (vat_main_t * vam)
6131 unformat_input_t *i = vam->input;
6132 vl_api_tap_connect_t *mp;
6138 ip4_address_t ip4_address;
6140 int ip4_address_set = 0;
6141 ip6_address_t ip6_address;
6143 int ip6_address_set = 0;
6146 memset (mac_address, 0, sizeof (mac_address));
6148 /* Parse args required to build the message */
6149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6151 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6155 else if (unformat (i, "random-mac"))
6157 else if (unformat (i, "tapname %s", &tap_name))
6159 else if (unformat (i, "tag %s", &tag))
6161 else if (unformat (i, "address %U/%d",
6162 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6163 ip4_address_set = 1;
6164 else if (unformat (i, "address %U/%d",
6165 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6166 ip6_address_set = 1;
6173 errmsg ("missing tap name");
6176 if (vec_len (tap_name) > 63)
6178 errmsg ("tap name too long");
6181 vec_add1 (tap_name, 0);
6183 if (vec_len (tag) > 63)
6185 errmsg ("tag too long");
6189 /* Construct the API message */
6190 M (TAP_CONNECT, mp);
6192 mp->use_random_mac = random_mac;
6193 clib_memcpy (mp->mac_address, mac_address, 6);
6194 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6196 clib_memcpy (mp->tag, tag, vec_len (tag));
6198 if (ip4_address_set)
6200 mp->ip4_address_set = 1;
6201 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6202 mp->ip4_mask_width = ip4_mask_width;
6204 if (ip6_address_set)
6206 mp->ip6_address_set = 1;
6207 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6208 mp->ip6_mask_width = ip6_mask_width;
6211 vec_free (tap_name);
6217 /* Wait for a reply... */
6223 api_tap_modify (vat_main_t * vam)
6225 unformat_input_t *i = vam->input;
6226 vl_api_tap_modify_t *mp;
6231 u32 sw_if_index = ~0;
6232 u8 sw_if_index_set = 0;
6235 memset (mac_address, 0, sizeof (mac_address));
6237 /* Parse args required to build the message */
6238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6240 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6241 sw_if_index_set = 1;
6242 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6243 sw_if_index_set = 1;
6244 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6248 else if (unformat (i, "random-mac"))
6250 else if (unformat (i, "tapname %s", &tap_name))
6256 if (sw_if_index_set == 0)
6258 errmsg ("missing vpp interface name");
6263 errmsg ("missing tap name");
6266 if (vec_len (tap_name) > 63)
6268 errmsg ("tap name too long");
6270 vec_add1 (tap_name, 0);
6272 /* Construct the API message */
6275 mp->use_random_mac = random_mac;
6276 mp->sw_if_index = ntohl (sw_if_index);
6277 clib_memcpy (mp->mac_address, mac_address, 6);
6278 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6279 vec_free (tap_name);
6284 /* Wait for a reply... */
6290 api_tap_delete (vat_main_t * vam)
6292 unformat_input_t *i = vam->input;
6293 vl_api_tap_delete_t *mp;
6294 u32 sw_if_index = ~0;
6295 u8 sw_if_index_set = 0;
6298 /* Parse args required to build the message */
6299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6302 sw_if_index_set = 1;
6303 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6304 sw_if_index_set = 1;
6309 if (sw_if_index_set == 0)
6311 errmsg ("missing vpp interface name");
6315 /* Construct the API message */
6318 mp->sw_if_index = ntohl (sw_if_index);
6323 /* Wait for a reply... */
6329 api_ip_add_del_route (vat_main_t * vam)
6331 unformat_input_t *i = vam->input;
6332 vl_api_ip_add_del_route_t *mp;
6333 u32 sw_if_index = ~0, vrf_id = 0;
6335 u8 is_local = 0, is_drop = 0;
6336 u8 is_unreach = 0, is_prohibit = 0;
6337 u8 create_vrf_if_needed = 0;
6339 u32 next_hop_weight = 1;
6341 u8 is_multipath = 0;
6343 u8 address_length_set = 0;
6344 u32 next_hop_table_id = 0;
6345 u32 resolve_attempts = 0;
6346 u32 dst_address_length = 0;
6347 u8 next_hop_set = 0;
6348 ip4_address_t v4_dst_address, v4_next_hop_address;
6349 ip6_address_t v6_dst_address, v6_next_hop_address;
6353 u32 random_add_del = 0;
6354 u32 *random_vector = 0;
6356 u32 random_seed = 0xdeaddabe;
6357 u32 classify_table_index = ~0;
6359 u8 resolve_host = 0, resolve_attached = 0;
6360 mpls_label_t *next_hop_out_label_stack = NULL;
6361 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6362 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6364 /* Parse args required to build the message */
6365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6371 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6376 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6381 else if (unformat (i, "/%d", &dst_address_length))
6383 address_length_set = 1;
6386 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6387 &v4_next_hop_address))
6391 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6392 &v6_next_hop_address))
6396 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6398 else if (unformat (i, "weight %d", &next_hop_weight))
6400 else if (unformat (i, "drop"))
6404 else if (unformat (i, "null-send-unreach"))
6408 else if (unformat (i, "null-send-prohibit"))
6412 else if (unformat (i, "local"))
6416 else if (unformat (i, "classify %d", &classify_table_index))
6420 else if (unformat (i, "del"))
6422 else if (unformat (i, "add"))
6424 else if (unformat (i, "not-last"))
6426 else if (unformat (i, "resolve-via-host"))
6428 else if (unformat (i, "resolve-via-attached"))
6429 resolve_attached = 1;
6430 else if (unformat (i, "multipath"))
6432 else if (unformat (i, "vrf %d", &vrf_id))
6434 else if (unformat (i, "create-vrf"))
6435 create_vrf_if_needed = 1;
6436 else if (unformat (i, "count %d", &count))
6438 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6440 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6442 else if (unformat (i, "out-label %d", &next_hop_out_label))
6443 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6444 else if (unformat (i, "via-label %d", &next_hop_via_label))
6446 else if (unformat (i, "random"))
6448 else if (unformat (i, "seed %d", &random_seed))
6452 clib_warning ("parse error '%U'", format_unformat_error, i);
6457 if (!next_hop_set && !is_drop && !is_local &&
6458 !is_classify && !is_unreach && !is_prohibit &&
6459 MPLS_LABEL_INVALID == next_hop_via_label)
6462 ("next hop / local / drop / unreach / prohibit / classify not set");
6466 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6468 errmsg ("next hop and next-hop via label set");
6471 if (address_set == 0)
6473 errmsg ("missing addresses");
6477 if (address_length_set == 0)
6479 errmsg ("missing address length");
6483 /* Generate a pile of unique, random routes */
6486 u32 this_random_address;
6487 random_hash = hash_create (count, sizeof (uword));
6489 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6490 for (j = 0; j <= count; j++)
6494 this_random_address = random_u32 (&random_seed);
6495 this_random_address =
6496 clib_host_to_net_u32 (this_random_address);
6498 while (hash_get (random_hash, this_random_address));
6499 vec_add1 (random_vector, this_random_address);
6500 hash_set (random_hash, this_random_address, 1);
6502 hash_free (random_hash);
6503 v4_dst_address.as_u32 = random_vector[0];
6508 /* Turn on async mode */
6509 vam->async_mode = 1;
6510 vam->async_errors = 0;
6511 before = vat_time_now (vam);
6514 for (j = 0; j < count; j++)
6516 /* Construct the API message */
6517 M2 (IP_ADD_DEL_ROUTE, mp,
6518 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6520 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6521 mp->table_id = ntohl (vrf_id);
6522 mp->create_vrf_if_needed = create_vrf_if_needed;
6524 mp->is_add = is_add;
6525 mp->is_drop = is_drop;
6526 mp->is_unreach = is_unreach;
6527 mp->is_prohibit = is_prohibit;
6528 mp->is_ipv6 = is_ipv6;
6529 mp->is_local = is_local;
6530 mp->is_classify = is_classify;
6531 mp->is_multipath = is_multipath;
6532 mp->is_resolve_host = resolve_host;
6533 mp->is_resolve_attached = resolve_attached;
6534 mp->not_last = not_last;
6535 mp->next_hop_weight = next_hop_weight;
6536 mp->dst_address_length = dst_address_length;
6537 mp->next_hop_table_id = ntohl (next_hop_table_id);
6538 mp->classify_table_index = ntohl (classify_table_index);
6539 mp->next_hop_via_label = ntohl (next_hop_via_label);
6540 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6541 if (0 != mp->next_hop_n_out_labels)
6543 memcpy (mp->next_hop_out_label_stack,
6544 next_hop_out_label_stack,
6545 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6546 vec_free (next_hop_out_label_stack);
6551 clib_memcpy (mp->dst_address, &v6_dst_address,
6552 sizeof (v6_dst_address));
6554 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6555 sizeof (v6_next_hop_address));
6556 increment_v6_address (&v6_dst_address);
6560 clib_memcpy (mp->dst_address, &v4_dst_address,
6561 sizeof (v4_dst_address));
6563 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6564 sizeof (v4_next_hop_address));
6566 v4_dst_address.as_u32 = random_vector[j + 1];
6568 increment_v4_address (&v4_dst_address);
6572 /* If we receive SIGTERM, stop now... */
6577 /* When testing multiple add/del ops, use a control-ping to sync */
6580 vl_api_control_ping_t *mp_ping;
6584 /* Shut off async mode */
6585 vam->async_mode = 0;
6587 M (CONTROL_PING, mp_ping);
6590 timeout = vat_time_now (vam) + 1.0;
6591 while (vat_time_now (vam) < timeout)
6592 if (vam->result_ready == 1)
6597 if (vam->retval == -99)
6600 if (vam->async_errors > 0)
6602 errmsg ("%d asynchronous errors", vam->async_errors);
6605 vam->async_errors = 0;
6606 after = vat_time_now (vam);
6608 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6612 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6613 count, after - before, count / (after - before));
6619 /* Wait for a reply... */
6624 /* Return the good/bad news */
6625 return (vam->retval);
6629 api_ip_mroute_add_del (vat_main_t * vam)
6631 unformat_input_t *i = vam->input;
6632 vl_api_ip_mroute_add_del_t *mp;
6633 u32 sw_if_index = ~0, vrf_id = 0;
6636 u8 create_vrf_if_needed = 0;
6639 u32 grp_address_length = 0;
6640 ip4_address_t v4_grp_address, v4_src_address;
6641 ip6_address_t v6_grp_address, v6_src_address;
6642 mfib_itf_flags_t iflags = 0;
6643 mfib_entry_flags_t eflags = 0;
6646 /* Parse args required to build the message */
6647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6649 if (unformat (i, "sw_if_index %d", &sw_if_index))
6651 else if (unformat (i, "%U %U",
6652 unformat_ip4_address, &v4_src_address,
6653 unformat_ip4_address, &v4_grp_address))
6655 grp_address_length = 64;
6659 else if (unformat (i, "%U %U",
6660 unformat_ip6_address, &v6_src_address,
6661 unformat_ip6_address, &v6_grp_address))
6663 grp_address_length = 256;
6667 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6669 memset (&v4_src_address, 0, sizeof (v4_src_address));
6670 grp_address_length = 32;
6674 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6676 memset (&v6_src_address, 0, sizeof (v6_src_address));
6677 grp_address_length = 128;
6681 else if (unformat (i, "/%d", &grp_address_length))
6683 else if (unformat (i, "local"))
6687 else if (unformat (i, "del"))
6689 else if (unformat (i, "add"))
6691 else if (unformat (i, "vrf %d", &vrf_id))
6693 else if (unformat (i, "create-vrf"))
6694 create_vrf_if_needed = 1;
6695 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6697 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6701 clib_warning ("parse error '%U'", format_unformat_error, i);
6706 if (address_set == 0)
6708 errmsg ("missing addresses\n");
6712 /* Construct the API message */
6713 M (IP_MROUTE_ADD_DEL, mp);
6715 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6716 mp->table_id = ntohl (vrf_id);
6717 mp->create_vrf_if_needed = create_vrf_if_needed;
6719 mp->is_add = is_add;
6720 mp->is_ipv6 = is_ipv6;
6721 mp->is_local = is_local;
6722 mp->itf_flags = ntohl (iflags);
6723 mp->entry_flags = ntohl (eflags);
6724 mp->grp_address_length = grp_address_length;
6725 mp->grp_address_length = ntohs (mp->grp_address_length);
6729 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6730 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6734 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6735 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6741 /* Wait for a reply... */
6747 api_mpls_route_add_del (vat_main_t * vam)
6749 unformat_input_t *i = vam->input;
6750 vl_api_mpls_route_add_del_t *mp;
6751 u32 sw_if_index = ~0, table_id = 0;
6752 u8 create_table_if_needed = 0;
6754 u32 next_hop_weight = 1;
6755 u8 is_multipath = 0;
6756 u32 next_hop_table_id = 0;
6757 u8 next_hop_set = 0;
6758 ip4_address_t v4_next_hop_address = {
6761 ip6_address_t v6_next_hop_address = { {0} };
6765 u32 classify_table_index = ~0;
6767 u8 resolve_host = 0, resolve_attached = 0;
6768 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6769 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6770 mpls_label_t *next_hop_out_label_stack = NULL;
6771 mpls_label_t local_label = MPLS_LABEL_INVALID;
6773 u8 next_hop_proto_is_ip4 = 1;
6775 /* Parse args required to build the message */
6776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6778 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6780 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6782 else if (unformat (i, "%d", &local_label))
6784 else if (unformat (i, "eos"))
6786 else if (unformat (i, "non-eos"))
6788 else if (unformat (i, "via %U", unformat_ip4_address,
6789 &v4_next_hop_address))
6792 next_hop_proto_is_ip4 = 1;
6794 else if (unformat (i, "via %U", unformat_ip6_address,
6795 &v6_next_hop_address))
6798 next_hop_proto_is_ip4 = 0;
6800 else if (unformat (i, "weight %d", &next_hop_weight))
6802 else if (unformat (i, "create-table"))
6803 create_table_if_needed = 1;
6804 else if (unformat (i, "classify %d", &classify_table_index))
6808 else if (unformat (i, "del"))
6810 else if (unformat (i, "add"))
6812 else if (unformat (i, "resolve-via-host"))
6814 else if (unformat (i, "resolve-via-attached"))
6815 resolve_attached = 1;
6816 else if (unformat (i, "multipath"))
6818 else if (unformat (i, "count %d", &count))
6820 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6823 next_hop_proto_is_ip4 = 1;
6825 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6828 next_hop_proto_is_ip4 = 0;
6830 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6832 else if (unformat (i, "via-label %d", &next_hop_via_label))
6834 else if (unformat (i, "out-label %d", &next_hop_out_label))
6835 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6838 clib_warning ("parse error '%U'", format_unformat_error, i);
6843 if (!next_hop_set && !is_classify)
6845 errmsg ("next hop / classify not set");
6849 if (MPLS_LABEL_INVALID == local_label)
6851 errmsg ("missing label");
6857 /* Turn on async mode */
6858 vam->async_mode = 1;
6859 vam->async_errors = 0;
6860 before = vat_time_now (vam);
6863 for (j = 0; j < count; j++)
6865 /* Construct the API message */
6866 M2 (MPLS_ROUTE_ADD_DEL, mp,
6867 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6869 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6870 mp->mr_table_id = ntohl (table_id);
6871 mp->mr_create_table_if_needed = create_table_if_needed;
6873 mp->mr_is_add = is_add;
6874 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6875 mp->mr_is_classify = is_classify;
6876 mp->mr_is_multipath = is_multipath;
6877 mp->mr_is_resolve_host = resolve_host;
6878 mp->mr_is_resolve_attached = resolve_attached;
6879 mp->mr_next_hop_weight = next_hop_weight;
6880 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6881 mp->mr_classify_table_index = ntohl (classify_table_index);
6882 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6883 mp->mr_label = ntohl (local_label);
6884 mp->mr_eos = is_eos;
6886 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6887 if (0 != mp->mr_next_hop_n_out_labels)
6889 memcpy (mp->mr_next_hop_out_label_stack,
6890 next_hop_out_label_stack,
6891 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6892 vec_free (next_hop_out_label_stack);
6897 if (next_hop_proto_is_ip4)
6899 clib_memcpy (mp->mr_next_hop,
6900 &v4_next_hop_address,
6901 sizeof (v4_next_hop_address));
6905 clib_memcpy (mp->mr_next_hop,
6906 &v6_next_hop_address,
6907 sizeof (v6_next_hop_address));
6914 /* If we receive SIGTERM, stop now... */
6919 /* When testing multiple add/del ops, use a control-ping to sync */
6922 vl_api_control_ping_t *mp_ping;
6926 /* Shut off async mode */
6927 vam->async_mode = 0;
6929 M (CONTROL_PING, mp_ping);
6932 timeout = vat_time_now (vam) + 1.0;
6933 while (vat_time_now (vam) < timeout)
6934 if (vam->result_ready == 1)
6939 if (vam->retval == -99)
6942 if (vam->async_errors > 0)
6944 errmsg ("%d asynchronous errors", vam->async_errors);
6947 vam->async_errors = 0;
6948 after = vat_time_now (vam);
6950 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6954 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6955 count, after - before, count / (after - before));
6961 /* Wait for a reply... */
6966 /* Return the good/bad news */
6967 return (vam->retval);
6971 api_mpls_ip_bind_unbind (vat_main_t * vam)
6973 unformat_input_t *i = vam->input;
6974 vl_api_mpls_ip_bind_unbind_t *mp;
6975 u32 ip_table_id = 0;
6976 u8 create_table_if_needed = 0;
6979 ip4_address_t v4_address;
6980 ip6_address_t v6_address;
6983 mpls_label_t local_label = MPLS_LABEL_INVALID;
6986 /* Parse args required to build the message */
6987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6989 if (unformat (i, "%U/%d", unformat_ip4_address,
6990 &v4_address, &address_length))
6995 else if (unformat (i, "%U/%d", unformat_ip6_address,
6996 &v6_address, &address_length))
7001 else if (unformat (i, "%d", &local_label))
7003 else if (unformat (i, "create-table"))
7004 create_table_if_needed = 1;
7005 else if (unformat (i, "table-id %d", &ip_table_id))
7007 else if (unformat (i, "unbind"))
7009 else if (unformat (i, "bind"))
7013 clib_warning ("parse error '%U'", format_unformat_error, i);
7020 errmsg ("IP addres not set");
7024 if (MPLS_LABEL_INVALID == local_label)
7026 errmsg ("missing label");
7030 /* Construct the API message */
7031 M (MPLS_IP_BIND_UNBIND, mp);
7033 mp->mb_create_table_if_needed = create_table_if_needed;
7034 mp->mb_is_bind = is_bind;
7035 mp->mb_is_ip4 = is_ip4;
7036 mp->mb_ip_table_id = ntohl (ip_table_id);
7037 mp->mb_mpls_table_id = 0;
7038 mp->mb_label = ntohl (local_label);
7039 mp->mb_address_length = address_length;
7042 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7044 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7049 /* Wait for a reply... */
7055 api_proxy_arp_add_del (vat_main_t * vam)
7057 unformat_input_t *i = vam->input;
7058 vl_api_proxy_arp_add_del_t *mp;
7061 ip4_address_t lo, hi;
7065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7067 if (unformat (i, "vrf %d", &vrf_id))
7069 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7070 unformat_ip4_address, &hi))
7072 else if (unformat (i, "del"))
7076 clib_warning ("parse error '%U'", format_unformat_error, i);
7083 errmsg ("address range not set");
7087 M (PROXY_ARP_ADD_DEL, mp);
7089 mp->vrf_id = ntohl (vrf_id);
7090 mp->is_add = is_add;
7091 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7092 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7100 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7102 unformat_input_t *i = vam->input;
7103 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7106 u8 sw_if_index_set = 0;
7109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7111 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7112 sw_if_index_set = 1;
7113 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7114 sw_if_index_set = 1;
7115 else if (unformat (i, "enable"))
7117 else if (unformat (i, "disable"))
7121 clib_warning ("parse error '%U'", format_unformat_error, i);
7126 if (sw_if_index_set == 0)
7128 errmsg ("missing interface name or sw_if_index");
7132 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7134 mp->sw_if_index = ntohl (sw_if_index);
7135 mp->enable_disable = enable;
7143 api_mpls_tunnel_add_del (vat_main_t * vam)
7145 unformat_input_t *i = vam->input;
7146 vl_api_mpls_tunnel_add_del_t *mp;
7150 u32 sw_if_index = ~0;
7151 u32 next_hop_sw_if_index = ~0;
7152 u32 next_hop_proto_is_ip4 = 1;
7154 u32 next_hop_table_id = 0;
7155 ip4_address_t v4_next_hop_address = {
7158 ip6_address_t v6_next_hop_address = { {0} };
7159 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7164 if (unformat (i, "add"))
7166 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7168 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7170 else if (unformat (i, "via %U",
7171 unformat_ip4_address, &v4_next_hop_address))
7173 next_hop_proto_is_ip4 = 1;
7175 else if (unformat (i, "via %U",
7176 unformat_ip6_address, &v6_next_hop_address))
7178 next_hop_proto_is_ip4 = 0;
7180 else if (unformat (i, "l2-only"))
7182 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7184 else if (unformat (i, "out-label %d", &next_hop_out_label))
7185 vec_add1 (labels, ntohl (next_hop_out_label));
7188 clib_warning ("parse error '%U'", format_unformat_error, i);
7193 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7195 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7196 mp->mt_sw_if_index = ntohl (sw_if_index);
7197 mp->mt_is_add = is_add;
7198 mp->mt_l2_only = l2_only;
7199 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7200 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7202 mp->mt_next_hop_n_out_labels = vec_len (labels);
7204 if (0 != mp->mt_next_hop_n_out_labels)
7206 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7207 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7211 if (next_hop_proto_is_ip4)
7213 clib_memcpy (mp->mt_next_hop,
7214 &v4_next_hop_address, sizeof (v4_next_hop_address));
7218 clib_memcpy (mp->mt_next_hop,
7219 &v6_next_hop_address, sizeof (v6_next_hop_address));
7228 api_sw_interface_set_unnumbered (vat_main_t * vam)
7230 unformat_input_t *i = vam->input;
7231 vl_api_sw_interface_set_unnumbered_t *mp;
7233 u32 unnum_sw_index = ~0;
7235 u8 sw_if_index_set = 0;
7238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7240 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7241 sw_if_index_set = 1;
7242 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7243 sw_if_index_set = 1;
7244 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7246 else if (unformat (i, "del"))
7250 clib_warning ("parse error '%U'", format_unformat_error, i);
7255 if (sw_if_index_set == 0)
7257 errmsg ("missing interface name or sw_if_index");
7261 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7263 mp->sw_if_index = ntohl (sw_if_index);
7264 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7265 mp->is_add = is_add;
7273 api_ip_neighbor_add_del (vat_main_t * vam)
7275 unformat_input_t *i = vam->input;
7276 vl_api_ip_neighbor_add_del_t *mp;
7278 u8 sw_if_index_set = 0;
7284 u8 v4_address_set = 0;
7285 u8 v6_address_set = 0;
7286 ip4_address_t v4address;
7287 ip6_address_t v6address;
7290 memset (mac_address, 0, sizeof (mac_address));
7292 /* Parse args required to build the message */
7293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7295 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7299 else if (unformat (i, "del"))
7302 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7303 sw_if_index_set = 1;
7304 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7305 sw_if_index_set = 1;
7306 else if (unformat (i, "is_static"))
7308 else if (unformat (i, "vrf %d", &vrf_id))
7310 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7312 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7316 clib_warning ("parse error '%U'", format_unformat_error, i);
7321 if (sw_if_index_set == 0)
7323 errmsg ("missing interface name or sw_if_index");
7326 if (v4_address_set && v6_address_set)
7328 errmsg ("both v4 and v6 addresses set");
7331 if (!v4_address_set && !v6_address_set)
7333 errmsg ("no address set");
7337 /* Construct the API message */
7338 M (IP_NEIGHBOR_ADD_DEL, mp);
7340 mp->sw_if_index = ntohl (sw_if_index);
7341 mp->is_add = is_add;
7342 mp->vrf_id = ntohl (vrf_id);
7343 mp->is_static = is_static;
7345 clib_memcpy (mp->mac_address, mac_address, 6);
7349 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7353 /* mp->is_ipv6 = 0; via memset in M macro above */
7354 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7360 /* Wait for a reply, return good/bad news */
7366 api_reset_vrf (vat_main_t * vam)
7368 unformat_input_t *i = vam->input;
7369 vl_api_reset_vrf_t *mp;
7375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7377 if (unformat (i, "vrf %d", &vrf_id))
7379 else if (unformat (i, "ipv6"))
7383 clib_warning ("parse error '%U'", format_unformat_error, i);
7388 if (vrf_id_set == 0)
7390 errmsg ("missing vrf id");
7396 mp->vrf_id = ntohl (vrf_id);
7397 mp->is_ipv6 = is_ipv6;
7405 api_create_vlan_subif (vat_main_t * vam)
7407 unformat_input_t *i = vam->input;
7408 vl_api_create_vlan_subif_t *mp;
7410 u8 sw_if_index_set = 0;
7415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7417 if (unformat (i, "sw_if_index %d", &sw_if_index))
7418 sw_if_index_set = 1;
7420 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7421 sw_if_index_set = 1;
7422 else if (unformat (i, "vlan %d", &vlan_id))
7426 clib_warning ("parse error '%U'", format_unformat_error, i);
7431 if (sw_if_index_set == 0)
7433 errmsg ("missing interface name or sw_if_index");
7437 if (vlan_id_set == 0)
7439 errmsg ("missing vlan_id");
7442 M (CREATE_VLAN_SUBIF, mp);
7444 mp->sw_if_index = ntohl (sw_if_index);
7445 mp->vlan_id = ntohl (vlan_id);
7452 #define foreach_create_subif_bit \
7459 _(outer_vlan_id_any) \
7460 _(inner_vlan_id_any)
7463 api_create_subif (vat_main_t * vam)
7465 unformat_input_t *i = vam->input;
7466 vl_api_create_subif_t *mp;
7468 u8 sw_if_index_set = 0;
7475 u32 exact_match = 0;
7476 u32 default_sub = 0;
7477 u32 outer_vlan_id_any = 0;
7478 u32 inner_vlan_id_any = 0;
7480 u16 outer_vlan_id = 0;
7481 u16 inner_vlan_id = 0;
7484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7486 if (unformat (i, "sw_if_index %d", &sw_if_index))
7487 sw_if_index_set = 1;
7489 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7490 sw_if_index_set = 1;
7491 else if (unformat (i, "sub_id %d", &sub_id))
7493 else if (unformat (i, "outer_vlan_id %d", &tmp))
7494 outer_vlan_id = tmp;
7495 else if (unformat (i, "inner_vlan_id %d", &tmp))
7496 inner_vlan_id = tmp;
7498 #define _(a) else if (unformat (i, #a)) a = 1 ;
7499 foreach_create_subif_bit
7503 clib_warning ("parse error '%U'", format_unformat_error, i);
7508 if (sw_if_index_set == 0)
7510 errmsg ("missing interface name or sw_if_index");
7514 if (sub_id_set == 0)
7516 errmsg ("missing sub_id");
7519 M (CREATE_SUBIF, mp);
7521 mp->sw_if_index = ntohl (sw_if_index);
7522 mp->sub_id = ntohl (sub_id);
7524 #define _(a) mp->a = a;
7525 foreach_create_subif_bit;
7528 mp->outer_vlan_id = ntohs (outer_vlan_id);
7529 mp->inner_vlan_id = ntohs (inner_vlan_id);
7537 api_oam_add_del (vat_main_t * vam)
7539 unformat_input_t *i = vam->input;
7540 vl_api_oam_add_del_t *mp;
7543 ip4_address_t src, dst;
7548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7550 if (unformat (i, "vrf %d", &vrf_id))
7552 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7554 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7556 else if (unformat (i, "del"))
7560 clib_warning ("parse error '%U'", format_unformat_error, i);
7567 errmsg ("missing src addr");
7573 errmsg ("missing dst addr");
7577 M (OAM_ADD_DEL, mp);
7579 mp->vrf_id = ntohl (vrf_id);
7580 mp->is_add = is_add;
7581 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7582 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7590 api_reset_fib (vat_main_t * vam)
7592 unformat_input_t *i = vam->input;
7593 vl_api_reset_fib_t *mp;
7599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7601 if (unformat (i, "vrf %d", &vrf_id))
7603 else if (unformat (i, "ipv6"))
7607 clib_warning ("parse error '%U'", format_unformat_error, i);
7612 if (vrf_id_set == 0)
7614 errmsg ("missing vrf id");
7620 mp->vrf_id = ntohl (vrf_id);
7621 mp->is_ipv6 = is_ipv6;
7629 api_dhcp_proxy_config (vat_main_t * vam)
7631 unformat_input_t *i = vam->input;
7632 vl_api_dhcp_proxy_config_t *mp;
7634 u32 server_vrf_id = 0;
7636 u8 v4_address_set = 0;
7637 u8 v6_address_set = 0;
7638 ip4_address_t v4address;
7639 ip6_address_t v6address;
7640 u8 v4_src_address_set = 0;
7641 u8 v6_src_address_set = 0;
7642 ip4_address_t v4srcaddress;
7643 ip6_address_t v6srcaddress;
7646 /* Parse args required to build the message */
7647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7649 if (unformat (i, "del"))
7651 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7653 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7655 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7657 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7659 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7660 v4_src_address_set = 1;
7661 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7662 v6_src_address_set = 1;
7667 if (v4_address_set && v6_address_set)
7669 errmsg ("both v4 and v6 server addresses set");
7672 if (!v4_address_set && !v6_address_set)
7674 errmsg ("no server addresses set");
7678 if (v4_src_address_set && v6_src_address_set)
7680 errmsg ("both v4 and v6 src addresses set");
7683 if (!v4_src_address_set && !v6_src_address_set)
7685 errmsg ("no src addresses set");
7689 if (!(v4_src_address_set && v4_address_set) &&
7690 !(v6_src_address_set && v6_address_set))
7692 errmsg ("no matching server and src addresses set");
7696 /* Construct the API message */
7697 M (DHCP_PROXY_CONFIG, mp);
7699 mp->is_add = is_add;
7700 mp->rx_vrf_id = ntohl (rx_vrf_id);
7701 mp->server_vrf_id = ntohl (server_vrf_id);
7705 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7706 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7710 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7711 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7717 /* Wait for a reply, return good/bad news */
7722 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7723 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7726 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7728 vat_main_t *vam = &vat_main;
7732 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7733 ntohl (mp->rx_vrf_id),
7734 ntohl (mp->server_vrf_id),
7735 format_ip6_address, mp->dhcp_server,
7736 format_ip6_address, mp->dhcp_src_address,
7737 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7740 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7741 ntohl (mp->rx_vrf_id),
7742 ntohl (mp->server_vrf_id),
7743 format_ip4_address, mp->dhcp_server,
7744 format_ip4_address, mp->dhcp_src_address,
7745 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7748 static void vl_api_dhcp_proxy_details_t_handler_json
7749 (vl_api_dhcp_proxy_details_t * mp)
7751 vat_main_t *vam = &vat_main;
7752 vat_json_node_t *node = NULL;
7754 struct in6_addr ip6;
7756 if (VAT_JSON_ARRAY != vam->json_tree.type)
7758 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7759 vat_json_init_array (&vam->json_tree);
7761 node = vat_json_array_add (&vam->json_tree);
7763 vat_json_init_object (node);
7764 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7765 vat_json_object_add_uint (node, "server-table-id",
7766 ntohl (mp->server_vrf_id));
7769 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7770 vat_json_object_add_ip6 (node, "server_address", ip6);
7771 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7772 vat_json_object_add_ip6 (node, "src_address", ip6);
7776 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7777 vat_json_object_add_ip4 (node, "server_address", ip4);
7778 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7779 vat_json_object_add_ip4 (node, "src_address", ip4);
7781 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7782 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7786 api_dhcp_proxy_dump (vat_main_t * vam)
7788 unformat_input_t *i = vam->input;
7789 vl_api_control_ping_t *mp_ping;
7790 vl_api_dhcp_proxy_dump_t *mp;
7794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7796 if (unformat (i, "ipv6"))
7800 clib_warning ("parse error '%U'", format_unformat_error, i);
7805 M (DHCP_PROXY_DUMP, mp);
7807 mp->is_ip6 = is_ipv6;
7810 /* Use a control ping for synchronization */
7811 M (CONTROL_PING, mp_ping);
7819 api_dhcp_proxy_set_vss (vat_main_t * vam)
7821 unformat_input_t *i = vam->input;
7822 vl_api_dhcp_proxy_set_vss_t *mp;
7833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7835 if (unformat (i, "tbl_id %d", &tbl_id))
7837 if (unformat (i, "fib_id %d", &fib_id))
7839 if (unformat (i, "oui %d", &oui))
7841 else if (unformat (i, "ipv6"))
7843 else if (unformat (i, "del"))
7847 clib_warning ("parse error '%U'", format_unformat_error, i);
7852 if (tbl_id_set == 0)
7854 errmsg ("missing tbl id");
7858 if (fib_id_set == 0)
7860 errmsg ("missing fib id");
7865 errmsg ("missing oui");
7869 M (DHCP_PROXY_SET_VSS, mp);
7870 mp->tbl_id = ntohl (tbl_id);
7871 mp->fib_id = ntohl (fib_id);
7872 mp->oui = ntohl (oui);
7873 mp->is_ipv6 = is_ipv6;
7874 mp->is_add = is_add;
7882 api_dhcp_client_config (vat_main_t * vam)
7884 unformat_input_t *i = vam->input;
7885 vl_api_dhcp_client_config_t *mp;
7887 u8 sw_if_index_set = 0;
7890 u8 disable_event = 0;
7893 /* Parse args required to build the message */
7894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7896 if (unformat (i, "del"))
7899 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7900 sw_if_index_set = 1;
7901 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7902 sw_if_index_set = 1;
7903 else if (unformat (i, "hostname %s", &hostname))
7905 else if (unformat (i, "disable_event"))
7911 if (sw_if_index_set == 0)
7913 errmsg ("missing interface name or sw_if_index");
7917 if (vec_len (hostname) > 63)
7919 errmsg ("hostname too long");
7921 vec_add1 (hostname, 0);
7923 /* Construct the API message */
7924 M (DHCP_CLIENT_CONFIG, mp);
7926 mp->sw_if_index = ntohl (sw_if_index);
7927 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7928 vec_free (hostname);
7929 mp->is_add = is_add;
7930 mp->want_dhcp_event = disable_event ? 0 : 1;
7931 mp->pid = getpid ();
7936 /* Wait for a reply, return good/bad news */
7942 api_set_ip_flow_hash (vat_main_t * vam)
7944 unformat_input_t *i = vam->input;
7945 vl_api_set_ip_flow_hash_t *mp;
7957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7959 if (unformat (i, "vrf %d", &vrf_id))
7961 else if (unformat (i, "ipv6"))
7963 else if (unformat (i, "src"))
7965 else if (unformat (i, "dst"))
7967 else if (unformat (i, "sport"))
7969 else if (unformat (i, "dport"))
7971 else if (unformat (i, "proto"))
7973 else if (unformat (i, "reverse"))
7978 clib_warning ("parse error '%U'", format_unformat_error, i);
7983 if (vrf_id_set == 0)
7985 errmsg ("missing vrf id");
7989 M (SET_IP_FLOW_HASH, mp);
7995 mp->reverse = reverse;
7996 mp->vrf_id = ntohl (vrf_id);
7997 mp->is_ipv6 = is_ipv6;
8005 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8007 unformat_input_t *i = vam->input;
8008 vl_api_sw_interface_ip6_enable_disable_t *mp;
8010 u8 sw_if_index_set = 0;
8014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8017 sw_if_index_set = 1;
8018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8019 sw_if_index_set = 1;
8020 else if (unformat (i, "enable"))
8022 else if (unformat (i, "disable"))
8026 clib_warning ("parse error '%U'", format_unformat_error, i);
8031 if (sw_if_index_set == 0)
8033 errmsg ("missing interface name or sw_if_index");
8037 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8039 mp->sw_if_index = ntohl (sw_if_index);
8040 mp->enable = enable;
8048 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8050 unformat_input_t *i = vam->input;
8051 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8053 u8 sw_if_index_set = 0;
8054 u8 v6_address_set = 0;
8055 ip6_address_t v6address;
8058 /* Parse args required to build the message */
8059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8061 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8062 sw_if_index_set = 1;
8063 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8064 sw_if_index_set = 1;
8065 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8071 if (sw_if_index_set == 0)
8073 errmsg ("missing interface name or sw_if_index");
8076 if (!v6_address_set)
8078 errmsg ("no address set");
8082 /* Construct the API message */
8083 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8085 mp->sw_if_index = ntohl (sw_if_index);
8086 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8091 /* Wait for a reply, return good/bad news */
8098 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8100 unformat_input_t *i = vam->input;
8101 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8103 u8 sw_if_index_set = 0;
8104 u32 address_length = 0;
8105 u8 v6_address_set = 0;
8106 ip6_address_t v6address;
8108 u8 no_advertise = 0;
8110 u8 no_autoconfig = 0;
8113 u32 val_lifetime = 0;
8114 u32 pref_lifetime = 0;
8117 /* Parse args required to build the message */
8118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8120 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8121 sw_if_index_set = 1;
8122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8123 sw_if_index_set = 1;
8124 else if (unformat (i, "%U/%d",
8125 unformat_ip6_address, &v6address, &address_length))
8127 else if (unformat (i, "val_life %d", &val_lifetime))
8129 else if (unformat (i, "pref_life %d", &pref_lifetime))
8131 else if (unformat (i, "def"))
8133 else if (unformat (i, "noadv"))
8135 else if (unformat (i, "offl"))
8137 else if (unformat (i, "noauto"))
8139 else if (unformat (i, "nolink"))
8141 else if (unformat (i, "isno"))
8145 clib_warning ("parse error '%U'", format_unformat_error, i);
8150 if (sw_if_index_set == 0)
8152 errmsg ("missing interface name or sw_if_index");
8155 if (!v6_address_set)
8157 errmsg ("no address set");
8161 /* Construct the API message */
8162 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8164 mp->sw_if_index = ntohl (sw_if_index);
8165 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8166 mp->address_length = address_length;
8167 mp->use_default = use_default;
8168 mp->no_advertise = no_advertise;
8169 mp->off_link = off_link;
8170 mp->no_autoconfig = no_autoconfig;
8171 mp->no_onlink = no_onlink;
8173 mp->val_lifetime = ntohl (val_lifetime);
8174 mp->pref_lifetime = ntohl (pref_lifetime);
8179 /* Wait for a reply, return good/bad news */
8185 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8187 unformat_input_t *i = vam->input;
8188 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8190 u8 sw_if_index_set = 0;
8195 u8 send_unicast = 0;
8198 u8 default_router = 0;
8199 u32 max_interval = 0;
8200 u32 min_interval = 0;
8202 u32 initial_count = 0;
8203 u32 initial_interval = 0;
8207 /* Parse args required to build the message */
8208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8211 sw_if_index_set = 1;
8212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8213 sw_if_index_set = 1;
8214 else if (unformat (i, "maxint %d", &max_interval))
8216 else if (unformat (i, "minint %d", &min_interval))
8218 else if (unformat (i, "life %d", &lifetime))
8220 else if (unformat (i, "count %d", &initial_count))
8222 else if (unformat (i, "interval %d", &initial_interval))
8224 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8226 else if (unformat (i, "managed"))
8228 else if (unformat (i, "other"))
8230 else if (unformat (i, "ll"))
8232 else if (unformat (i, "send"))
8234 else if (unformat (i, "cease"))
8236 else if (unformat (i, "isno"))
8238 else if (unformat (i, "def"))
8242 clib_warning ("parse error '%U'", format_unformat_error, i);
8247 if (sw_if_index_set == 0)
8249 errmsg ("missing interface name or sw_if_index");
8253 /* Construct the API message */
8254 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8256 mp->sw_if_index = ntohl (sw_if_index);
8257 mp->max_interval = ntohl (max_interval);
8258 mp->min_interval = ntohl (min_interval);
8259 mp->lifetime = ntohl (lifetime);
8260 mp->initial_count = ntohl (initial_count);
8261 mp->initial_interval = ntohl (initial_interval);
8262 mp->suppress = suppress;
8263 mp->managed = managed;
8265 mp->ll_option = ll_option;
8266 mp->send_unicast = send_unicast;
8269 mp->default_router = default_router;
8274 /* Wait for a reply, return good/bad news */
8280 api_set_arp_neighbor_limit (vat_main_t * vam)
8282 unformat_input_t *i = vam->input;
8283 vl_api_set_arp_neighbor_limit_t *mp;
8289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8291 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8293 else if (unformat (i, "ipv6"))
8297 clib_warning ("parse error '%U'", format_unformat_error, i);
8304 errmsg ("missing limit value");
8308 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8310 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8311 mp->is_ipv6 = is_ipv6;
8319 api_l2_patch_add_del (vat_main_t * vam)
8321 unformat_input_t *i = vam->input;
8322 vl_api_l2_patch_add_del_t *mp;
8324 u8 rx_sw_if_index_set = 0;
8326 u8 tx_sw_if_index_set = 0;
8330 /* Parse args required to build the message */
8331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8333 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8334 rx_sw_if_index_set = 1;
8335 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8336 tx_sw_if_index_set = 1;
8337 else if (unformat (i, "rx"))
8339 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8341 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8343 rx_sw_if_index_set = 1;
8348 else if (unformat (i, "tx"))
8350 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8352 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8354 tx_sw_if_index_set = 1;
8359 else if (unformat (i, "del"))
8365 if (rx_sw_if_index_set == 0)
8367 errmsg ("missing rx interface name or rx_sw_if_index");
8371 if (tx_sw_if_index_set == 0)
8373 errmsg ("missing tx interface name or tx_sw_if_index");
8377 M (L2_PATCH_ADD_DEL, mp);
8379 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8380 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8381 mp->is_add = is_add;
8389 api_ioam_enable (vat_main_t * vam)
8391 unformat_input_t *input = vam->input;
8392 vl_api_ioam_enable_t *mp;
8394 int has_trace_option = 0;
8395 int has_pot_option = 0;
8396 int has_seqno_option = 0;
8397 int has_analyse_option = 0;
8400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8402 if (unformat (input, "trace"))
8403 has_trace_option = 1;
8404 else if (unformat (input, "pot"))
8406 else if (unformat (input, "seqno"))
8407 has_seqno_option = 1;
8408 else if (unformat (input, "analyse"))
8409 has_analyse_option = 1;
8413 M (IOAM_ENABLE, mp);
8414 mp->id = htons (id);
8415 mp->seqno = has_seqno_option;
8416 mp->analyse = has_analyse_option;
8417 mp->pot_enable = has_pot_option;
8418 mp->trace_enable = has_trace_option;
8427 api_ioam_disable (vat_main_t * vam)
8429 vl_api_ioam_disable_t *mp;
8432 M (IOAM_DISABLE, mp);
8439 api_sr_tunnel_add_del (vat_main_t * vam)
8441 unformat_input_t *i = vam->input;
8442 vl_api_sr_tunnel_add_del_t *mp;
8445 ip6_address_t src_address;
8446 int src_address_set = 0;
8447 ip6_address_t dst_address;
8449 int dst_address_set = 0;
8451 u32 rx_table_id = 0;
8452 u32 tx_table_id = 0;
8453 ip6_address_t *segments = 0;
8454 ip6_address_t *this_seg;
8455 ip6_address_t *tags = 0;
8456 ip6_address_t *this_tag;
8457 ip6_address_t next_address, tag;
8459 u8 *policy_name = 0;
8462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8464 if (unformat (i, "del"))
8466 else if (unformat (i, "name %s", &name))
8468 else if (unformat (i, "policy %s", &policy_name))
8470 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8472 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8474 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8475 src_address_set = 1;
8476 else if (unformat (i, "dst %U/%d",
8477 unformat_ip6_address, &dst_address, &dst_mask_width))
8478 dst_address_set = 1;
8479 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8481 vec_add2 (segments, this_seg, 1);
8482 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8483 sizeof (*this_seg));
8485 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8487 vec_add2 (tags, this_tag, 1);
8488 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8490 else if (unformat (i, "clean"))
8491 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8492 else if (unformat (i, "protected"))
8493 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8494 else if (unformat (i, "InPE %d", &pl_index))
8496 if (pl_index <= 0 || pl_index > 4)
8498 pl_index_range_error:
8499 errmsg ("pl index %d out of range", pl_index);
8503 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8505 else if (unformat (i, "EgPE %d", &pl_index))
8507 if (pl_index <= 0 || pl_index > 4)
8508 goto pl_index_range_error;
8510 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8512 else if (unformat (i, "OrgSrc %d", &pl_index))
8514 if (pl_index <= 0 || pl_index > 4)
8515 goto pl_index_range_error;
8517 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8523 if (!src_address_set)
8525 errmsg ("src address required");
8529 if (!dst_address_set)
8531 errmsg ("dst address required");
8537 errmsg ("at least one sr segment required");
8541 M2 (SR_TUNNEL_ADD_DEL, mp,
8542 vec_len (segments) * sizeof (ip6_address_t)
8543 + vec_len (tags) * sizeof (ip6_address_t));
8545 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8546 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8547 mp->dst_mask_width = dst_mask_width;
8548 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8549 mp->n_segments = vec_len (segments);
8550 mp->n_tags = vec_len (tags);
8551 mp->is_add = is_del == 0;
8552 clib_memcpy (mp->segs_and_tags, segments,
8553 vec_len (segments) * sizeof (ip6_address_t));
8554 clib_memcpy (mp->segs_and_tags +
8555 vec_len (segments) * sizeof (ip6_address_t), tags,
8556 vec_len (tags) * sizeof (ip6_address_t));
8558 mp->outer_vrf_id = ntohl (rx_table_id);
8559 mp->inner_vrf_id = ntohl (tx_table_id);
8560 memcpy (mp->name, name, vec_len (name));
8561 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8563 vec_free (segments);
8572 api_sr_policy_add_del (vat_main_t * vam)
8574 unformat_input_t *input = vam->input;
8575 vl_api_sr_policy_add_del_t *mp;
8578 u8 *tunnel_name = 0;
8579 u8 **tunnel_names = 0;
8584 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8585 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8590 if (unformat (input, "del"))
8592 else if (unformat (input, "name %s", &name))
8594 else if (unformat (input, "tunnel %s", &tunnel_name))
8598 vec_add1 (tunnel_names, tunnel_name);
8600 - length = #bytes to store in serial vector
8601 - +1 = byte to store that length
8603 tunnel_names_length += (vec_len (tunnel_name) + 1);
8614 errmsg ("policy name required");
8618 if ((!tunnel_set) && (!is_del))
8620 errmsg ("tunnel name required");
8624 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8628 mp->is_add = !is_del;
8630 memcpy (mp->name, name, vec_len (name));
8631 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8632 u8 *serial_orig = 0;
8633 vec_validate (serial_orig, tunnel_names_length);
8634 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8635 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8637 for (j = 0; j < vec_len (tunnel_names); j++)
8639 tun_name_len = vec_len (tunnel_names[j]);
8640 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8641 serial_orig += 1; // Move along one byte to store the actual tunnel name
8642 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8643 serial_orig += tun_name_len; // Advance past the copy
8645 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8647 vec_free (tunnel_names);
8648 vec_free (tunnel_name);
8656 api_sr_multicast_map_add_del (vat_main_t * vam)
8658 unformat_input_t *input = vam->input;
8659 vl_api_sr_multicast_map_add_del_t *mp;
8661 ip6_address_t multicast_address;
8662 u8 *policy_name = 0;
8663 int multicast_address_set = 0;
8666 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8668 if (unformat (input, "del"))
8672 (input, "address %U", unformat_ip6_address, &multicast_address))
8673 multicast_address_set = 1;
8674 else if (unformat (input, "sr-policy %s", &policy_name))
8680 if (!is_del && !policy_name)
8682 errmsg ("sr-policy name required");
8687 if (!multicast_address_set)
8689 errmsg ("address required");
8693 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8695 mp->is_add = !is_del;
8696 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8697 clib_memcpy (mp->multicast_address, &multicast_address,
8698 sizeof (mp->multicast_address));
8701 vec_free (policy_name);
8709 #define foreach_tcp_proto_field \
8713 #define foreach_udp_proto_field \
8717 #define foreach_ip4_proto_field \
8728 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8730 u8 **maskp = va_arg (*args, u8 **);
8732 u8 found_something = 0;
8735 #define _(a) u8 a=0;
8736 foreach_tcp_proto_field;
8739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8742 #define _(a) else if (unformat (input, #a)) a=1;
8743 foreach_tcp_proto_field
8749 #define _(a) found_something += a;
8750 foreach_tcp_proto_field;
8753 if (found_something == 0)
8756 vec_validate (mask, sizeof (*tcp) - 1);
8758 tcp = (tcp_header_t *) mask;
8760 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8761 foreach_tcp_proto_field;
8769 unformat_udp_mask (unformat_input_t * input, va_list * args)
8771 u8 **maskp = va_arg (*args, u8 **);
8773 u8 found_something = 0;
8776 #define _(a) u8 a=0;
8777 foreach_udp_proto_field;
8780 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8783 #define _(a) else if (unformat (input, #a)) a=1;
8784 foreach_udp_proto_field
8790 #define _(a) found_something += a;
8791 foreach_udp_proto_field;
8794 if (found_something == 0)
8797 vec_validate (mask, sizeof (*udp) - 1);
8799 udp = (udp_header_t *) mask;
8801 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8802 foreach_udp_proto_field;
8811 u16 src_port, dst_port;
8815 unformat_l4_mask (unformat_input_t * input, va_list * args)
8817 u8 **maskp = va_arg (*args, u8 **);
8818 u16 src_port = 0, dst_port = 0;
8819 tcpudp_header_t *tcpudp;
8821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8823 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8825 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8827 else if (unformat (input, "src_port"))
8829 else if (unformat (input, "dst_port"))
8835 if (!src_port && !dst_port)
8839 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8841 tcpudp = (tcpudp_header_t *) mask;
8842 tcpudp->src_port = src_port;
8843 tcpudp->dst_port = dst_port;
8851 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8853 u8 **maskp = va_arg (*args, u8 **);
8855 u8 found_something = 0;
8858 #define _(a) u8 a=0;
8859 foreach_ip4_proto_field;
8865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8867 if (unformat (input, "version"))
8869 else if (unformat (input, "hdr_length"))
8871 else if (unformat (input, "src"))
8873 else if (unformat (input, "dst"))
8875 else if (unformat (input, "proto"))
8878 #define _(a) else if (unformat (input, #a)) a=1;
8879 foreach_ip4_proto_field
8885 #define _(a) found_something += a;
8886 foreach_ip4_proto_field;
8889 if (found_something == 0)
8892 vec_validate (mask, sizeof (*ip) - 1);
8894 ip = (ip4_header_t *) mask;
8896 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8897 foreach_ip4_proto_field;
8900 ip->ip_version_and_header_length = 0;
8903 ip->ip_version_and_header_length |= 0xF0;
8906 ip->ip_version_and_header_length |= 0x0F;
8912 #define foreach_ip6_proto_field \
8920 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8922 u8 **maskp = va_arg (*args, u8 **);
8924 u8 found_something = 0;
8926 u32 ip_version_traffic_class_and_flow_label;
8928 #define _(a) u8 a=0;
8929 foreach_ip6_proto_field;
8932 u8 traffic_class = 0;
8935 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8937 if (unformat (input, "version"))
8939 else if (unformat (input, "traffic-class"))
8941 else if (unformat (input, "flow-label"))
8943 else if (unformat (input, "src"))
8945 else if (unformat (input, "dst"))
8947 else if (unformat (input, "proto"))
8950 #define _(a) else if (unformat (input, #a)) a=1;
8951 foreach_ip6_proto_field
8957 #define _(a) found_something += a;
8958 foreach_ip6_proto_field;
8961 if (found_something == 0)
8964 vec_validate (mask, sizeof (*ip) - 1);
8966 ip = (ip6_header_t *) mask;
8968 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8969 foreach_ip6_proto_field;
8972 ip_version_traffic_class_and_flow_label = 0;
8975 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8978 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8981 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8983 ip->ip_version_traffic_class_and_flow_label =
8984 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8991 unformat_l3_mask (unformat_input_t * input, va_list * args)
8993 u8 **maskp = va_arg (*args, u8 **);
8995 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8997 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8999 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9008 unformat_l2_mask (unformat_input_t * input, va_list * args)
9010 u8 **maskp = va_arg (*args, u8 **);
9025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9027 if (unformat (input, "src"))
9029 else if (unformat (input, "dst"))
9031 else if (unformat (input, "proto"))
9033 else if (unformat (input, "tag1"))
9035 else if (unformat (input, "tag2"))
9037 else if (unformat (input, "ignore-tag1"))
9039 else if (unformat (input, "ignore-tag2"))
9041 else if (unformat (input, "cos1"))
9043 else if (unformat (input, "cos2"))
9045 else if (unformat (input, "dot1q"))
9047 else if (unformat (input, "dot1ad"))
9052 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9053 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9056 if (tag1 || ignore_tag1 || cos1 || dot1q)
9058 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9061 vec_validate (mask, len - 1);
9064 memset (mask, 0xff, 6);
9067 memset (mask + 6, 0xff, 6);
9071 /* inner vlan tag */
9080 mask[21] = mask[20] = 0xff;
9101 mask[16] = mask[17] = 0xff;
9111 mask[12] = mask[13] = 0xff;
9118 unformat_classify_mask (unformat_input_t * input, va_list * args)
9120 u8 **maskp = va_arg (*args, u8 **);
9121 u32 *skipp = va_arg (*args, u32 *);
9122 u32 *matchp = va_arg (*args, u32 *);
9130 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9132 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9134 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9136 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9138 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9152 if (mask || l2 || l3 || l4)
9156 /* "With a free Ethernet header in every package" */
9158 vec_validate (l2, 13);
9162 vec_append (mask, l3);
9167 vec_append (mask, l4);
9172 /* Scan forward looking for the first significant mask octet */
9173 for (i = 0; i < vec_len (mask); i++)
9177 /* compute (skip, match) params */
9178 *skipp = i / sizeof (u32x4);
9179 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9181 /* Pad mask to an even multiple of the vector size */
9182 while (vec_len (mask) % sizeof (u32x4))
9185 match = vec_len (mask) / sizeof (u32x4);
9187 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9189 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9190 if (*tmp || *(tmp + 1))
9195 clib_warning ("BUG: match 0");
9197 _vec_len (mask) = match * sizeof (u32x4);
9208 #define foreach_l2_next \
9210 _(ethernet, ETHERNET_INPUT) \
9215 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9217 u32 *miss_next_indexp = va_arg (*args, u32 *);
9222 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9226 if (unformat (input, "%d", &tmp))
9235 *miss_next_indexp = next_index;
9239 #define foreach_ip_next \
9245 unformat_ip_next_index (unformat_input_t * input, va_list * args)
9247 u32 *miss_next_indexp = va_arg (*args, u32 *);
9252 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9256 if (unformat (input, "%d", &tmp))
9265 *miss_next_indexp = next_index;
9269 #define foreach_acl_next \
9273 unformat_acl_next_index (unformat_input_t * input, va_list * args)
9275 u32 *miss_next_indexp = va_arg (*args, u32 *);
9280 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9284 if (unformat (input, "permit"))
9289 else if (unformat (input, "%d", &tmp))
9298 *miss_next_indexp = next_index;
9303 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9305 u32 *r = va_arg (*args, u32 *);
9307 if (unformat (input, "conform-color"))
9308 *r = POLICE_CONFORM;
9309 else if (unformat (input, "exceed-color"))
9318 api_classify_add_del_table (vat_main_t * vam)
9320 unformat_input_t *i = vam->input;
9321 vl_api_classify_add_del_table_t *mp;
9328 u32 table_index = ~0;
9329 u32 next_table_index = ~0;
9330 u32 miss_next_index = ~0;
9331 u32 memory_size = 32 << 20;
9333 u32 current_data_flag = 0;
9334 int current_data_offset = 0;
9337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9339 if (unformat (i, "del"))
9341 else if (unformat (i, "del-chain"))
9346 else if (unformat (i, "buckets %d", &nbuckets))
9348 else if (unformat (i, "memory_size %d", &memory_size))
9350 else if (unformat (i, "skip %d", &skip))
9352 else if (unformat (i, "match %d", &match))
9354 else if (unformat (i, "table %d", &table_index))
9356 else if (unformat (i, "mask %U", unformat_classify_mask,
9357 &mask, &skip, &match))
9359 else if (unformat (i, "next-table %d", &next_table_index))
9361 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
9364 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9367 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9370 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9372 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9378 if (is_add && mask == 0)
9380 errmsg ("Mask required");
9384 if (is_add && skip == ~0)
9386 errmsg ("skip count required");
9390 if (is_add && match == ~0)
9392 errmsg ("match count required");
9396 if (!is_add && table_index == ~0)
9398 errmsg ("table index required for delete");
9402 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9404 mp->is_add = is_add;
9405 mp->del_chain = del_chain;
9406 mp->table_index = ntohl (table_index);
9407 mp->nbuckets = ntohl (nbuckets);
9408 mp->memory_size = ntohl (memory_size);
9409 mp->skip_n_vectors = ntohl (skip);
9410 mp->match_n_vectors = ntohl (match);
9411 mp->next_table_index = ntohl (next_table_index);
9412 mp->miss_next_index = ntohl (miss_next_index);
9413 mp->current_data_flag = ntohl (current_data_flag);
9414 mp->current_data_offset = ntohl (current_data_offset);
9415 clib_memcpy (mp->mask, mask, vec_len (mask));
9425 unformat_l4_match (unformat_input_t * input, va_list * args)
9427 u8 **matchp = va_arg (*args, u8 **);
9429 u8 *proto_header = 0;
9435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9437 if (unformat (input, "src_port %d", &src_port))
9439 else if (unformat (input, "dst_port %d", &dst_port))
9445 h.src_port = clib_host_to_net_u16 (src_port);
9446 h.dst_port = clib_host_to_net_u16 (dst_port);
9447 vec_validate (proto_header, sizeof (h) - 1);
9448 memcpy (proto_header, &h, sizeof (h));
9450 *matchp = proto_header;
9456 unformat_ip4_match (unformat_input_t * input, va_list * args)
9458 u8 **matchp = va_arg (*args, u8 **);
9465 int src = 0, dst = 0;
9466 ip4_address_t src_val, dst_val;
9473 int fragment_id = 0;
9474 u32 fragment_id_val;
9480 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9482 if (unformat (input, "version %d", &version_val))
9484 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9486 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9488 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9490 else if (unformat (input, "proto %d", &proto_val))
9492 else if (unformat (input, "tos %d", &tos_val))
9494 else if (unformat (input, "length %d", &length_val))
9496 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9498 else if (unformat (input, "ttl %d", &ttl_val))
9500 else if (unformat (input, "checksum %d", &checksum_val))
9506 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9507 + ttl + checksum == 0)
9511 * Aligned because we use the real comparison functions
9513 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9515 ip = (ip4_header_t *) match;
9517 /* These are realistically matched in practice */
9519 ip->src_address.as_u32 = src_val.as_u32;
9522 ip->dst_address.as_u32 = dst_val.as_u32;
9525 ip->protocol = proto_val;
9528 /* These are not, but they're included for completeness */
9530 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9533 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9539 ip->length = clib_host_to_net_u16 (length_val);
9545 ip->checksum = clib_host_to_net_u16 (checksum_val);
9552 unformat_ip6_match (unformat_input_t * input, va_list * args)
9554 u8 **matchp = va_arg (*args, u8 **);
9559 u8 traffic_class = 0;
9560 u32 traffic_class_val = 0;
9563 int src = 0, dst = 0;
9564 ip6_address_t src_val, dst_val;
9567 int payload_length = 0;
9568 u32 payload_length_val;
9571 u32 ip_version_traffic_class_and_flow_label;
9573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9575 if (unformat (input, "version %d", &version_val))
9577 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9579 else if (unformat (input, "flow_label %d", &flow_label_val))
9581 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9583 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9585 else if (unformat (input, "proto %d", &proto_val))
9587 else if (unformat (input, "payload_length %d", &payload_length_val))
9589 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9595 if (version + traffic_class + flow_label + src + dst + proto +
9596 payload_length + hop_limit == 0)
9600 * Aligned because we use the real comparison functions
9602 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9604 ip = (ip6_header_t *) match;
9607 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9610 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9613 ip->protocol = proto_val;
9615 ip_version_traffic_class_and_flow_label = 0;
9618 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9621 ip_version_traffic_class_and_flow_label |=
9622 (traffic_class_val & 0xFF) << 20;
9625 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9627 ip->ip_version_traffic_class_and_flow_label =
9628 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9631 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9634 ip->hop_limit = hop_limit_val;
9641 unformat_l3_match (unformat_input_t * input, va_list * args)
9643 u8 **matchp = va_arg (*args, u8 **);
9645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9647 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9649 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9658 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9660 u8 *tagp = va_arg (*args, u8 *);
9663 if (unformat (input, "%d", &tag))
9665 tagp[0] = (tag >> 8) & 0x0F;
9666 tagp[1] = tag & 0xFF;
9674 unformat_l2_match (unformat_input_t * input, va_list * args)
9676 u8 **matchp = va_arg (*args, u8 **);
9696 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9698 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9701 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9703 else if (unformat (input, "proto %U",
9704 unformat_ethernet_type_host_byte_order, &proto_val))
9706 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9708 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9710 else if (unformat (input, "ignore-tag1"))
9712 else if (unformat (input, "ignore-tag2"))
9714 else if (unformat (input, "cos1 %d", &cos1_val))
9716 else if (unformat (input, "cos2 %d", &cos2_val))
9721 if ((src + dst + proto + tag1 + tag2 +
9722 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9725 if (tag1 || ignore_tag1 || cos1)
9727 if (tag2 || ignore_tag2 || cos2)
9730 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9733 clib_memcpy (match, dst_val, 6);
9736 clib_memcpy (match + 6, src_val, 6);
9740 /* inner vlan tag */
9741 match[19] = tag2_val[1];
9742 match[18] = tag2_val[0];
9744 match[18] |= (cos2_val & 0x7) << 5;
9747 match[21] = proto_val & 0xff;
9748 match[20] = proto_val >> 8;
9752 match[15] = tag1_val[1];
9753 match[14] = tag1_val[0];
9756 match[14] |= (cos1_val & 0x7) << 5;
9762 match[15] = tag1_val[1];
9763 match[14] = tag1_val[0];
9766 match[17] = proto_val & 0xff;
9767 match[16] = proto_val >> 8;
9770 match[14] |= (cos1_val & 0x7) << 5;
9776 match[18] |= (cos2_val & 0x7) << 5;
9778 match[14] |= (cos1_val & 0x7) << 5;
9781 match[13] = proto_val & 0xff;
9782 match[12] = proto_val >> 8;
9791 unformat_classify_match (unformat_input_t * input, va_list * args)
9793 u8 **matchp = va_arg (*args, u8 **);
9794 u32 skip_n_vectors = va_arg (*args, u32);
9795 u32 match_n_vectors = va_arg (*args, u32);
9802 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9804 if (unformat (input, "hex %U", unformat_hex_string, &match))
9806 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9808 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9810 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9824 if (match || l2 || l3 || l4)
9828 /* "Win a free Ethernet header in every packet" */
9830 vec_validate_aligned (l2, 13, sizeof (u32x4));
9834 vec_append_aligned (match, l3, sizeof (u32x4));
9839 vec_append_aligned (match, l4, sizeof (u32x4));
9844 /* Make sure the vector is big enough even if key is all 0's */
9845 vec_validate_aligned
9846 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9849 /* Set size, include skipped vectors */
9850 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9861 api_classify_add_del_session (vat_main_t * vam)
9863 unformat_input_t *i = vam->input;
9864 vl_api_classify_add_del_session_t *mp;
9866 u32 table_index = ~0;
9867 u32 hit_next_index = ~0;
9868 u32 opaque_index = ~0;
9871 u32 skip_n_vectors = 0;
9872 u32 match_n_vectors = 0;
9878 * Warning: you have to supply skip_n and match_n
9879 * because the API client cant simply look at the classify
9883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9885 if (unformat (i, "del"))
9887 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9890 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9893 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9896 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9898 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9900 else if (unformat (i, "opaque-index %d", &opaque_index))
9902 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9904 else if (unformat (i, "match_n %d", &match_n_vectors))
9906 else if (unformat (i, "match %U", unformat_classify_match,
9907 &match, skip_n_vectors, match_n_vectors))
9909 else if (unformat (i, "advance %d", &advance))
9911 else if (unformat (i, "table-index %d", &table_index))
9913 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9915 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9917 else if (unformat (i, "action %d", &action))
9919 else if (unformat (i, "metadata %d", &metadata))
9925 if (table_index == ~0)
9927 errmsg ("Table index required");
9931 if (is_add && match == 0)
9933 errmsg ("Match value required");
9937 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9939 mp->is_add = is_add;
9940 mp->table_index = ntohl (table_index);
9941 mp->hit_next_index = ntohl (hit_next_index);
9942 mp->opaque_index = ntohl (opaque_index);
9943 mp->advance = ntohl (advance);
9944 mp->action = action;
9945 mp->metadata = ntohl (metadata);
9946 clib_memcpy (mp->match, match, vec_len (match));
9955 api_classify_set_interface_ip_table (vat_main_t * vam)
9957 unformat_input_t *i = vam->input;
9958 vl_api_classify_set_interface_ip_table_t *mp;
9960 int sw_if_index_set;
9961 u32 table_index = ~0;
9965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9967 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9968 sw_if_index_set = 1;
9969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9970 sw_if_index_set = 1;
9971 else if (unformat (i, "table %d", &table_index))
9975 clib_warning ("parse error '%U'", format_unformat_error, i);
9980 if (sw_if_index_set == 0)
9982 errmsg ("missing interface name or sw_if_index");
9987 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9989 mp->sw_if_index = ntohl (sw_if_index);
9990 mp->table_index = ntohl (table_index);
9991 mp->is_ipv6 = is_ipv6;
9999 api_classify_set_interface_l2_tables (vat_main_t * vam)
10001 unformat_input_t *i = vam->input;
10002 vl_api_classify_set_interface_l2_tables_t *mp;
10004 int sw_if_index_set;
10005 u32 ip4_table_index = ~0;
10006 u32 ip6_table_index = ~0;
10007 u32 other_table_index = ~0;
10011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10014 sw_if_index_set = 1;
10015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10016 sw_if_index_set = 1;
10017 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10019 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10021 else if (unformat (i, "other-table %d", &other_table_index))
10023 else if (unformat (i, "is-input %d", &is_input))
10027 clib_warning ("parse error '%U'", format_unformat_error, i);
10032 if (sw_if_index_set == 0)
10034 errmsg ("missing interface name or sw_if_index");
10039 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10041 mp->sw_if_index = ntohl (sw_if_index);
10042 mp->ip4_table_index = ntohl (ip4_table_index);
10043 mp->ip6_table_index = ntohl (ip6_table_index);
10044 mp->other_table_index = ntohl (other_table_index);
10045 mp->is_input = (u8) is_input;
10053 api_set_ipfix_exporter (vat_main_t * vam)
10055 unformat_input_t *i = vam->input;
10056 vl_api_set_ipfix_exporter_t *mp;
10057 ip4_address_t collector_address;
10058 u8 collector_address_set = 0;
10059 u32 collector_port = ~0;
10060 ip4_address_t src_address;
10061 u8 src_address_set = 0;
10064 u32 template_interval = ~0;
10065 u8 udp_checksum = 0;
10068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10070 if (unformat (i, "collector_address %U", unformat_ip4_address,
10071 &collector_address))
10072 collector_address_set = 1;
10073 else if (unformat (i, "collector_port %d", &collector_port))
10075 else if (unformat (i, "src_address %U", unformat_ip4_address,
10077 src_address_set = 1;
10078 else if (unformat (i, "vrf_id %d", &vrf_id))
10080 else if (unformat (i, "path_mtu %d", &path_mtu))
10082 else if (unformat (i, "template_interval %d", &template_interval))
10084 else if (unformat (i, "udp_checksum"))
10090 if (collector_address_set == 0)
10092 errmsg ("collector_address required");
10096 if (src_address_set == 0)
10098 errmsg ("src_address required");
10102 M (SET_IPFIX_EXPORTER, mp);
10104 memcpy (mp->collector_address, collector_address.data,
10105 sizeof (collector_address.data));
10106 mp->collector_port = htons ((u16) collector_port);
10107 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10108 mp->vrf_id = htonl (vrf_id);
10109 mp->path_mtu = htonl (path_mtu);
10110 mp->template_interval = htonl (template_interval);
10111 mp->udp_checksum = udp_checksum;
10119 api_set_ipfix_classify_stream (vat_main_t * vam)
10121 unformat_input_t *i = vam->input;
10122 vl_api_set_ipfix_classify_stream_t *mp;
10124 u32 src_port = UDP_DST_PORT_ipfix;
10127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10129 if (unformat (i, "domain %d", &domain_id))
10131 else if (unformat (i, "src_port %d", &src_port))
10135 errmsg ("unknown input `%U'", format_unformat_error, i);
10140 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10142 mp->domain_id = htonl (domain_id);
10143 mp->src_port = htons ((u16) src_port);
10151 api_ipfix_classify_table_add_del (vat_main_t * vam)
10153 unformat_input_t *i = vam->input;
10154 vl_api_ipfix_classify_table_add_del_t *mp;
10156 u32 classify_table_index = ~0;
10158 u8 transport_protocol = 255;
10161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10163 if (unformat (i, "add"))
10165 else if (unformat (i, "del"))
10167 else if (unformat (i, "table %d", &classify_table_index))
10169 else if (unformat (i, "ip4"))
10171 else if (unformat (i, "ip6"))
10173 else if (unformat (i, "tcp"))
10174 transport_protocol = 6;
10175 else if (unformat (i, "udp"))
10176 transport_protocol = 17;
10179 errmsg ("unknown input `%U'", format_unformat_error, i);
10186 errmsg ("expecting: add|del");
10189 if (classify_table_index == ~0)
10191 errmsg ("classifier table not specified");
10194 if (ip_version == 0)
10196 errmsg ("IP version not specified");
10200 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10202 mp->is_add = is_add;
10203 mp->table_id = htonl (classify_table_index);
10204 mp->ip_version = ip_version;
10205 mp->transport_protocol = transport_protocol;
10213 api_get_node_index (vat_main_t * vam)
10215 unformat_input_t *i = vam->input;
10216 vl_api_get_node_index_t *mp;
10220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10222 if (unformat (i, "node %s", &name))
10229 errmsg ("node name required");
10232 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10234 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10238 M (GET_NODE_INDEX, mp);
10239 clib_memcpy (mp->node_name, name, vec_len (name));
10248 api_get_next_index (vat_main_t * vam)
10250 unformat_input_t *i = vam->input;
10251 vl_api_get_next_index_t *mp;
10252 u8 *node_name = 0, *next_node_name = 0;
10255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10257 if (unformat (i, "node-name %s", &node_name))
10259 else if (unformat (i, "next-node-name %s", &next_node_name))
10263 if (node_name == 0)
10265 errmsg ("node name required");
10268 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10270 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10274 if (next_node_name == 0)
10276 errmsg ("next node name required");
10279 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10281 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10285 M (GET_NEXT_INDEX, mp);
10286 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10287 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10288 vec_free (node_name);
10289 vec_free (next_node_name);
10297 api_add_node_next (vat_main_t * vam)
10299 unformat_input_t *i = vam->input;
10300 vl_api_add_node_next_t *mp;
10305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10307 if (unformat (i, "node %s", &name))
10309 else if (unformat (i, "next %s", &next))
10316 errmsg ("node name required");
10319 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10321 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10326 errmsg ("next node required");
10329 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10331 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10335 M (ADD_NODE_NEXT, mp);
10336 clib_memcpy (mp->node_name, name, vec_len (name));
10337 clib_memcpy (mp->next_name, next, vec_len (next));
10347 api_l2tpv3_create_tunnel (vat_main_t * vam)
10349 unformat_input_t *i = vam->input;
10350 ip6_address_t client_address, our_address;
10351 int client_address_set = 0;
10352 int our_address_set = 0;
10353 u32 local_session_id = 0;
10354 u32 remote_session_id = 0;
10355 u64 local_cookie = 0;
10356 u64 remote_cookie = 0;
10357 u8 l2_sublayer_present = 0;
10358 vl_api_l2tpv3_create_tunnel_t *mp;
10361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10363 if (unformat (i, "client_address %U", unformat_ip6_address,
10365 client_address_set = 1;
10366 else if (unformat (i, "our_address %U", unformat_ip6_address,
10368 our_address_set = 1;
10369 else if (unformat (i, "local_session_id %d", &local_session_id))
10371 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10373 else if (unformat (i, "local_cookie %lld", &local_cookie))
10375 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10377 else if (unformat (i, "l2-sublayer-present"))
10378 l2_sublayer_present = 1;
10383 if (client_address_set == 0)
10385 errmsg ("client_address required");
10389 if (our_address_set == 0)
10391 errmsg ("our_address required");
10395 M (L2TPV3_CREATE_TUNNEL, mp);
10397 clib_memcpy (mp->client_address, client_address.as_u8,
10398 sizeof (mp->client_address));
10400 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10402 mp->local_session_id = ntohl (local_session_id);
10403 mp->remote_session_id = ntohl (remote_session_id);
10404 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10405 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10406 mp->l2_sublayer_present = l2_sublayer_present;
10415 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10417 unformat_input_t *i = vam->input;
10419 u8 sw_if_index_set = 0;
10420 u64 new_local_cookie = 0;
10421 u64 new_remote_cookie = 0;
10422 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10427 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10428 sw_if_index_set = 1;
10429 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10430 sw_if_index_set = 1;
10431 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10433 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10439 if (sw_if_index_set == 0)
10441 errmsg ("missing interface name or sw_if_index");
10445 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10447 mp->sw_if_index = ntohl (sw_if_index);
10448 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10449 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10457 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10459 unformat_input_t *i = vam->input;
10460 vl_api_l2tpv3_interface_enable_disable_t *mp;
10462 u8 sw_if_index_set = 0;
10463 u8 enable_disable = 1;
10466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10468 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10469 sw_if_index_set = 1;
10470 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10471 sw_if_index_set = 1;
10472 else if (unformat (i, "enable"))
10473 enable_disable = 1;
10474 else if (unformat (i, "disable"))
10475 enable_disable = 0;
10480 if (sw_if_index_set == 0)
10482 errmsg ("missing interface name or sw_if_index");
10486 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10488 mp->sw_if_index = ntohl (sw_if_index);
10489 mp->enable_disable = enable_disable;
10497 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10499 unformat_input_t *i = vam->input;
10500 vl_api_l2tpv3_set_lookup_key_t *mp;
10504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10506 if (unformat (i, "lookup_v6_src"))
10507 key = L2T_LOOKUP_SRC_ADDRESS;
10508 else if (unformat (i, "lookup_v6_dst"))
10509 key = L2T_LOOKUP_DST_ADDRESS;
10510 else if (unformat (i, "lookup_session_id"))
10511 key = L2T_LOOKUP_SESSION_ID;
10516 if (key == (u8) ~ 0)
10518 errmsg ("l2tp session lookup key unset");
10522 M (L2TPV3_SET_LOOKUP_KEY, mp);
10531 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10532 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10534 vat_main_t *vam = &vat_main;
10536 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10537 format_ip6_address, mp->our_address,
10538 format_ip6_address, mp->client_address,
10539 clib_net_to_host_u32 (mp->sw_if_index));
10542 " local cookies %016llx %016llx remote cookie %016llx",
10543 clib_net_to_host_u64 (mp->local_cookie[0]),
10544 clib_net_to_host_u64 (mp->local_cookie[1]),
10545 clib_net_to_host_u64 (mp->remote_cookie));
10547 print (vam->ofp, " local session-id %d remote session-id %d",
10548 clib_net_to_host_u32 (mp->local_session_id),
10549 clib_net_to_host_u32 (mp->remote_session_id));
10551 print (vam->ofp, " l2 specific sublayer %s\n",
10552 mp->l2_sublayer_present ? "preset" : "absent");
10556 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10557 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10559 vat_main_t *vam = &vat_main;
10560 vat_json_node_t *node = NULL;
10561 struct in6_addr addr;
10563 if (VAT_JSON_ARRAY != vam->json_tree.type)
10565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10566 vat_json_init_array (&vam->json_tree);
10568 node = vat_json_array_add (&vam->json_tree);
10570 vat_json_init_object (node);
10572 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10573 vat_json_object_add_ip6 (node, "our_address", addr);
10574 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10575 vat_json_object_add_ip6 (node, "client_address", addr);
10577 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10578 vat_json_init_array (lc);
10579 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10580 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10581 vat_json_object_add_uint (node, "remote_cookie",
10582 clib_net_to_host_u64 (mp->remote_cookie));
10584 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10585 vat_json_object_add_uint (node, "local_session_id",
10586 clib_net_to_host_u32 (mp->local_session_id));
10587 vat_json_object_add_uint (node, "remote_session_id",
10588 clib_net_to_host_u32 (mp->remote_session_id));
10589 vat_json_object_add_string_copy (node, "l2_sublayer",
10590 mp->l2_sublayer_present ? (u8 *) "present"
10591 : (u8 *) "absent");
10595 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10597 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10598 vl_api_control_ping_t *mp_ping;
10601 /* Get list of l2tpv3-tunnel interfaces */
10602 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10605 /* Use a control ping for synchronization */
10606 M (CONTROL_PING, mp_ping);
10614 static void vl_api_sw_interface_tap_details_t_handler
10615 (vl_api_sw_interface_tap_details_t * mp)
10617 vat_main_t *vam = &vat_main;
10619 print (vam->ofp, "%-16s %d",
10620 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10623 static void vl_api_sw_interface_tap_details_t_handler_json
10624 (vl_api_sw_interface_tap_details_t * mp)
10626 vat_main_t *vam = &vat_main;
10627 vat_json_node_t *node = NULL;
10629 if (VAT_JSON_ARRAY != vam->json_tree.type)
10631 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10632 vat_json_init_array (&vam->json_tree);
10634 node = vat_json_array_add (&vam->json_tree);
10636 vat_json_init_object (node);
10637 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10638 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10642 api_sw_interface_tap_dump (vat_main_t * vam)
10644 vl_api_sw_interface_tap_dump_t *mp;
10645 vl_api_control_ping_t *mp_ping;
10648 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10649 /* Get list of tap interfaces */
10650 M (SW_INTERFACE_TAP_DUMP, mp);
10653 /* Use a control ping for synchronization */
10654 M (CONTROL_PING, mp_ping);
10661 static uword unformat_vxlan_decap_next
10662 (unformat_input_t * input, va_list * args)
10664 u32 *result = va_arg (*args, u32 *);
10667 if (unformat (input, "l2"))
10668 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10669 else if (unformat (input, "%d", &tmp))
10677 api_vxlan_add_del_tunnel (vat_main_t * vam)
10679 unformat_input_t *line_input = vam->input;
10680 vl_api_vxlan_add_del_tunnel_t *mp;
10681 ip46_address_t src, dst;
10683 u8 ipv4_set = 0, ipv6_set = 0;
10687 u32 mcast_sw_if_index = ~0;
10688 u32 encap_vrf_id = 0;
10689 u32 decap_next_index = ~0;
10693 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10694 memset (&src, 0, sizeof src);
10695 memset (&dst, 0, sizeof dst);
10697 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10699 if (unformat (line_input, "del"))
10702 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10708 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10714 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10720 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10725 else if (unformat (line_input, "group %U %U",
10726 unformat_ip4_address, &dst.ip4,
10727 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10729 grp_set = dst_set = 1;
10732 else if (unformat (line_input, "group %U",
10733 unformat_ip4_address, &dst.ip4))
10735 grp_set = dst_set = 1;
10738 else if (unformat (line_input, "group %U %U",
10739 unformat_ip6_address, &dst.ip6,
10740 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10742 grp_set = dst_set = 1;
10745 else if (unformat (line_input, "group %U",
10746 unformat_ip6_address, &dst.ip6))
10748 grp_set = dst_set = 1;
10752 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10754 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10756 else if (unformat (line_input, "decap-next %U",
10757 unformat_vxlan_decap_next, &decap_next_index))
10759 else if (unformat (line_input, "vni %d", &vni))
10763 errmsg ("parse error '%U'", format_unformat_error, line_input);
10770 errmsg ("tunnel src address not specified");
10775 errmsg ("tunnel dst address not specified");
10779 if (grp_set && !ip46_address_is_multicast (&dst))
10781 errmsg ("tunnel group address not multicast");
10784 if (grp_set && mcast_sw_if_index == ~0)
10786 errmsg ("tunnel nonexistent multicast device");
10789 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10791 errmsg ("tunnel dst address must be unicast");
10796 if (ipv4_set && ipv6_set)
10798 errmsg ("both IPv4 and IPv6 addresses specified");
10802 if ((vni == 0) || (vni >> 24))
10804 errmsg ("vni not specified or out of range");
10808 M (VXLAN_ADD_DEL_TUNNEL, mp);
10812 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10813 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10817 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10818 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10820 mp->encap_vrf_id = ntohl (encap_vrf_id);
10821 mp->decap_next_index = ntohl (decap_next_index);
10822 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10823 mp->vni = ntohl (vni);
10824 mp->is_add = is_add;
10825 mp->is_ipv6 = ipv6_set;
10832 static void vl_api_vxlan_tunnel_details_t_handler
10833 (vl_api_vxlan_tunnel_details_t * mp)
10835 vat_main_t *vam = &vat_main;
10836 ip46_address_t src, dst;
10838 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10839 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10841 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10842 ntohl (mp->sw_if_index),
10843 format_ip46_address, &src, IP46_TYPE_ANY,
10844 format_ip46_address, &dst, IP46_TYPE_ANY,
10845 ntohl (mp->encap_vrf_id),
10846 ntohl (mp->decap_next_index), ntohl (mp->vni),
10847 ntohl (mp->mcast_sw_if_index));
10850 static void vl_api_vxlan_tunnel_details_t_handler_json
10851 (vl_api_vxlan_tunnel_details_t * mp)
10853 vat_main_t *vam = &vat_main;
10854 vat_json_node_t *node = NULL;
10856 if (VAT_JSON_ARRAY != vam->json_tree.type)
10858 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10859 vat_json_init_array (&vam->json_tree);
10861 node = vat_json_array_add (&vam->json_tree);
10863 vat_json_init_object (node);
10864 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10867 struct in6_addr ip6;
10869 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10870 vat_json_object_add_ip6 (node, "src_address", ip6);
10871 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10872 vat_json_object_add_ip6 (node, "dst_address", ip6);
10876 struct in_addr ip4;
10878 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10879 vat_json_object_add_ip4 (node, "src_address", ip4);
10880 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10881 vat_json_object_add_ip4 (node, "dst_address", ip4);
10883 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10884 vat_json_object_add_uint (node, "decap_next_index",
10885 ntohl (mp->decap_next_index));
10886 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10887 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10888 vat_json_object_add_uint (node, "mcast_sw_if_index",
10889 ntohl (mp->mcast_sw_if_index));
10893 api_vxlan_tunnel_dump (vat_main_t * vam)
10895 unformat_input_t *i = vam->input;
10896 vl_api_vxlan_tunnel_dump_t *mp;
10897 vl_api_control_ping_t *mp_ping;
10899 u8 sw_if_index_set = 0;
10902 /* Parse args required to build the message */
10903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10905 if (unformat (i, "sw_if_index %d", &sw_if_index))
10906 sw_if_index_set = 1;
10911 if (sw_if_index_set == 0)
10916 if (!vam->json_output)
10918 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10919 "sw_if_index", "src_address", "dst_address",
10920 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10923 /* Get list of vxlan-tunnel interfaces */
10924 M (VXLAN_TUNNEL_DUMP, mp);
10926 mp->sw_if_index = htonl (sw_if_index);
10930 /* Use a control ping for synchronization */
10931 M (CONTROL_PING, mp_ping);
10939 api_gre_add_del_tunnel (vat_main_t * vam)
10941 unformat_input_t *line_input = vam->input;
10942 vl_api_gre_add_del_tunnel_t *mp;
10943 ip4_address_t src4, dst4;
10948 u32 outer_fib_id = 0;
10951 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10953 if (unformat (line_input, "del"))
10955 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10957 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10959 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10961 else if (unformat (line_input, "teb"))
10965 errmsg ("parse error '%U'", format_unformat_error, line_input);
10972 errmsg ("tunnel src address not specified");
10977 errmsg ("tunnel dst address not specified");
10982 M (GRE_ADD_DEL_TUNNEL, mp);
10984 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10985 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10986 mp->outer_fib_id = ntohl (outer_fib_id);
10987 mp->is_add = is_add;
10995 static void vl_api_gre_tunnel_details_t_handler
10996 (vl_api_gre_tunnel_details_t * mp)
10998 vat_main_t *vam = &vat_main;
11000 print (vam->ofp, "%11d%15U%15U%6d%14d",
11001 ntohl (mp->sw_if_index),
11002 format_ip4_address, &mp->src_address,
11003 format_ip4_address, &mp->dst_address,
11004 mp->teb, ntohl (mp->outer_fib_id));
11007 static void vl_api_gre_tunnel_details_t_handler_json
11008 (vl_api_gre_tunnel_details_t * mp)
11010 vat_main_t *vam = &vat_main;
11011 vat_json_node_t *node = NULL;
11012 struct in_addr ip4;
11014 if (VAT_JSON_ARRAY != vam->json_tree.type)
11016 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11017 vat_json_init_array (&vam->json_tree);
11019 node = vat_json_array_add (&vam->json_tree);
11021 vat_json_init_object (node);
11022 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11023 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11024 vat_json_object_add_ip4 (node, "src_address", ip4);
11025 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11026 vat_json_object_add_ip4 (node, "dst_address", ip4);
11027 vat_json_object_add_uint (node, "teb", mp->teb);
11028 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11032 api_gre_tunnel_dump (vat_main_t * vam)
11034 unformat_input_t *i = vam->input;
11035 vl_api_gre_tunnel_dump_t *mp;
11036 vl_api_control_ping_t *mp_ping;
11038 u8 sw_if_index_set = 0;
11041 /* Parse args required to build the message */
11042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11044 if (unformat (i, "sw_if_index %d", &sw_if_index))
11045 sw_if_index_set = 1;
11050 if (sw_if_index_set == 0)
11055 if (!vam->json_output)
11057 print (vam->ofp, "%11s%15s%15s%6s%14s",
11058 "sw_if_index", "src_address", "dst_address", "teb",
11062 /* Get list of gre-tunnel interfaces */
11063 M (GRE_TUNNEL_DUMP, mp);
11065 mp->sw_if_index = htonl (sw_if_index);
11069 /* Use a control ping for synchronization */
11070 M (CONTROL_PING, mp_ping);
11078 api_l2_fib_clear_table (vat_main_t * vam)
11080 // unformat_input_t * i = vam->input;
11081 vl_api_l2_fib_clear_table_t *mp;
11084 M (L2_FIB_CLEAR_TABLE, mp);
11092 api_l2_interface_efp_filter (vat_main_t * vam)
11094 unformat_input_t *i = vam->input;
11095 vl_api_l2_interface_efp_filter_t *mp;
11098 u8 sw_if_index_set = 0;
11101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11103 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11104 sw_if_index_set = 1;
11105 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11106 sw_if_index_set = 1;
11107 else if (unformat (i, "enable"))
11109 else if (unformat (i, "disable"))
11113 clib_warning ("parse error '%U'", format_unformat_error, i);
11118 if (sw_if_index_set == 0)
11120 errmsg ("missing sw_if_index");
11124 M (L2_INTERFACE_EFP_FILTER, mp);
11126 mp->sw_if_index = ntohl (sw_if_index);
11127 mp->enable_disable = enable;
11134 #define foreach_vtr_op \
11135 _("disable", L2_VTR_DISABLED) \
11136 _("push-1", L2_VTR_PUSH_1) \
11137 _("push-2", L2_VTR_PUSH_2) \
11138 _("pop-1", L2_VTR_POP_1) \
11139 _("pop-2", L2_VTR_POP_2) \
11140 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11141 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11142 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11143 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11146 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11148 unformat_input_t *i = vam->input;
11149 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11151 u8 sw_if_index_set = 0;
11154 u32 push_dot1q = 1;
11159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11162 sw_if_index_set = 1;
11163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11164 sw_if_index_set = 1;
11165 else if (unformat (i, "vtr_op %d", &vtr_op))
11167 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11170 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11172 else if (unformat (i, "tag1 %d", &tag1))
11174 else if (unformat (i, "tag2 %d", &tag2))
11178 clib_warning ("parse error '%U'", format_unformat_error, i);
11183 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11185 errmsg ("missing vtr operation or sw_if_index");
11189 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11190 mp->sw_if_index = ntohl (sw_if_index);
11191 mp->vtr_op = ntohl (vtr_op);
11192 mp->push_dot1q = ntohl (push_dot1q);
11193 mp->tag1 = ntohl (tag1);
11194 mp->tag2 = ntohl (tag2);
11202 api_create_vhost_user_if (vat_main_t * vam)
11204 unformat_input_t *i = vam->input;
11205 vl_api_create_vhost_user_if_t *mp;
11208 u8 file_name_set = 0;
11209 u32 custom_dev_instance = ~0;
11211 u8 use_custom_mac = 0;
11215 /* Shut up coverity */
11216 memset (hwaddr, 0, sizeof (hwaddr));
11218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11220 if (unformat (i, "socket %s", &file_name))
11224 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11226 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11227 use_custom_mac = 1;
11228 else if (unformat (i, "server"))
11230 else if (unformat (i, "tag %s", &tag))
11236 if (file_name_set == 0)
11238 errmsg ("missing socket file name");
11242 if (vec_len (file_name) > 255)
11244 errmsg ("socket file name too long");
11247 vec_add1 (file_name, 0);
11249 M (CREATE_VHOST_USER_IF, mp);
11251 mp->is_server = is_server;
11252 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11253 vec_free (file_name);
11254 if (custom_dev_instance != ~0)
11257 mp->custom_dev_instance = ntohl (custom_dev_instance);
11259 mp->use_custom_mac = use_custom_mac;
11260 clib_memcpy (mp->mac_address, hwaddr, 6);
11262 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11271 api_modify_vhost_user_if (vat_main_t * vam)
11273 unformat_input_t *i = vam->input;
11274 vl_api_modify_vhost_user_if_t *mp;
11277 u8 file_name_set = 0;
11278 u32 custom_dev_instance = ~0;
11279 u8 sw_if_index_set = 0;
11280 u32 sw_if_index = (u32) ~ 0;
11283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11285 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11286 sw_if_index_set = 1;
11287 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11288 sw_if_index_set = 1;
11289 else if (unformat (i, "socket %s", &file_name))
11293 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11295 else if (unformat (i, "server"))
11301 if (sw_if_index_set == 0)
11303 errmsg ("missing sw_if_index or interface name");
11307 if (file_name_set == 0)
11309 errmsg ("missing socket file name");
11313 if (vec_len (file_name) > 255)
11315 errmsg ("socket file name too long");
11318 vec_add1 (file_name, 0);
11320 M (MODIFY_VHOST_USER_IF, mp);
11322 mp->sw_if_index = ntohl (sw_if_index);
11323 mp->is_server = is_server;
11324 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11325 vec_free (file_name);
11326 if (custom_dev_instance != ~0)
11329 mp->custom_dev_instance = ntohl (custom_dev_instance);
11338 api_delete_vhost_user_if (vat_main_t * vam)
11340 unformat_input_t *i = vam->input;
11341 vl_api_delete_vhost_user_if_t *mp;
11342 u32 sw_if_index = ~0;
11343 u8 sw_if_index_set = 0;
11346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11348 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11349 sw_if_index_set = 1;
11350 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11351 sw_if_index_set = 1;
11356 if (sw_if_index_set == 0)
11358 errmsg ("missing sw_if_index or interface name");
11363 M (DELETE_VHOST_USER_IF, mp);
11365 mp->sw_if_index = ntohl (sw_if_index);
11372 static void vl_api_sw_interface_vhost_user_details_t_handler
11373 (vl_api_sw_interface_vhost_user_details_t * mp)
11375 vat_main_t *vam = &vat_main;
11377 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11378 (char *) mp->interface_name,
11379 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11380 clib_net_to_host_u64 (mp->features), mp->is_server,
11381 ntohl (mp->num_regions), (char *) mp->sock_filename);
11382 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11385 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11386 (vl_api_sw_interface_vhost_user_details_t * mp)
11388 vat_main_t *vam = &vat_main;
11389 vat_json_node_t *node = NULL;
11391 if (VAT_JSON_ARRAY != vam->json_tree.type)
11393 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11394 vat_json_init_array (&vam->json_tree);
11396 node = vat_json_array_add (&vam->json_tree);
11398 vat_json_init_object (node);
11399 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11400 vat_json_object_add_string_copy (node, "interface_name",
11401 mp->interface_name);
11402 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11403 ntohl (mp->virtio_net_hdr_sz));
11404 vat_json_object_add_uint (node, "features",
11405 clib_net_to_host_u64 (mp->features));
11406 vat_json_object_add_uint (node, "is_server", mp->is_server);
11407 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11408 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11409 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11413 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11415 vl_api_sw_interface_vhost_user_dump_t *mp;
11416 vl_api_control_ping_t *mp_ping;
11419 "Interface name idx hdr_sz features server regions filename");
11421 /* Get list of vhost-user interfaces */
11422 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11425 /* Use a control ping for synchronization */
11426 M (CONTROL_PING, mp_ping);
11434 api_show_version (vat_main_t * vam)
11436 vl_api_show_version_t *mp;
11439 M (SHOW_VERSION, mp);
11448 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11450 unformat_input_t *line_input = vam->input;
11451 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11452 ip4_address_t local4, remote4;
11453 ip6_address_t local6, remote6;
11455 u8 ipv4_set = 0, ipv6_set = 0;
11458 u32 encap_vrf_id = 0;
11459 u32 decap_vrf_id = 0;
11465 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11467 if (unformat (line_input, "del"))
11469 else if (unformat (line_input, "local %U",
11470 unformat_ip4_address, &local4))
11475 else if (unformat (line_input, "remote %U",
11476 unformat_ip4_address, &remote4))
11481 else if (unformat (line_input, "local %U",
11482 unformat_ip6_address, &local6))
11487 else if (unformat (line_input, "remote %U",
11488 unformat_ip6_address, &remote6))
11493 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11495 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11497 else if (unformat (line_input, "vni %d", &vni))
11499 else if (unformat (line_input, "next-ip4"))
11501 else if (unformat (line_input, "next-ip6"))
11503 else if (unformat (line_input, "next-ethernet"))
11505 else if (unformat (line_input, "next-nsh"))
11509 errmsg ("parse error '%U'", format_unformat_error, line_input);
11514 if (local_set == 0)
11516 errmsg ("tunnel local address not specified");
11519 if (remote_set == 0)
11521 errmsg ("tunnel remote address not specified");
11524 if (ipv4_set && ipv6_set)
11526 errmsg ("both IPv4 and IPv6 addresses specified");
11532 errmsg ("vni not specified");
11536 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11541 clib_memcpy (&mp->local, &local6, sizeof (local6));
11542 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11546 clib_memcpy (&mp->local, &local4, sizeof (local4));
11547 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11550 mp->encap_vrf_id = ntohl (encap_vrf_id);
11551 mp->decap_vrf_id = ntohl (decap_vrf_id);
11552 mp->protocol = protocol;
11553 mp->vni = ntohl (vni);
11554 mp->is_add = is_add;
11555 mp->is_ipv6 = ipv6_set;
11562 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11563 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11565 vat_main_t *vam = &vat_main;
11567 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11568 ntohl (mp->sw_if_index),
11569 format_ip46_address, &(mp->local[0]),
11570 format_ip46_address, &(mp->remote[0]),
11572 ntohl (mp->protocol),
11573 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11576 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11577 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11579 vat_main_t *vam = &vat_main;
11580 vat_json_node_t *node = NULL;
11581 struct in_addr ip4;
11582 struct in6_addr ip6;
11584 if (VAT_JSON_ARRAY != vam->json_tree.type)
11586 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11587 vat_json_init_array (&vam->json_tree);
11589 node = vat_json_array_add (&vam->json_tree);
11591 vat_json_init_object (node);
11592 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11595 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11596 vat_json_object_add_ip6 (node, "local", ip6);
11597 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11598 vat_json_object_add_ip6 (node, "remote", ip6);
11602 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11603 vat_json_object_add_ip4 (node, "local", ip4);
11604 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11605 vat_json_object_add_ip4 (node, "remote", ip4);
11607 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11608 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11609 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11610 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11611 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11615 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11617 unformat_input_t *i = vam->input;
11618 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11619 vl_api_control_ping_t *mp_ping;
11621 u8 sw_if_index_set = 0;
11624 /* Parse args required to build the message */
11625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11627 if (unformat (i, "sw_if_index %d", &sw_if_index))
11628 sw_if_index_set = 1;
11633 if (sw_if_index_set == 0)
11638 if (!vam->json_output)
11640 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11641 "sw_if_index", "local", "remote", "vni",
11642 "protocol", "encap_vrf_id", "decap_vrf_id");
11645 /* Get list of vxlan-tunnel interfaces */
11646 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11648 mp->sw_if_index = htonl (sw_if_index);
11652 /* Use a control ping for synchronization */
11653 M (CONTROL_PING, mp_ping);
11661 format_l2_fib_mac_address (u8 * s, va_list * args)
11663 u8 *a = va_arg (*args, u8 *);
11665 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11666 a[2], a[3], a[4], a[5], a[6], a[7]);
11669 static void vl_api_l2_fib_table_entry_t_handler
11670 (vl_api_l2_fib_table_entry_t * mp)
11672 vat_main_t *vam = &vat_main;
11674 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11676 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11677 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11681 static void vl_api_l2_fib_table_entry_t_handler_json
11682 (vl_api_l2_fib_table_entry_t * mp)
11684 vat_main_t *vam = &vat_main;
11685 vat_json_node_t *node = NULL;
11687 if (VAT_JSON_ARRAY != vam->json_tree.type)
11689 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11690 vat_json_init_array (&vam->json_tree);
11692 node = vat_json_array_add (&vam->json_tree);
11694 vat_json_init_object (node);
11695 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11696 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11697 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11698 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11699 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11700 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11704 api_l2_fib_table_dump (vat_main_t * vam)
11706 unformat_input_t *i = vam->input;
11707 vl_api_l2_fib_table_dump_t *mp;
11708 vl_api_control_ping_t *mp_ping;
11713 /* Parse args required to build the message */
11714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11716 if (unformat (i, "bd_id %d", &bd_id))
11722 if (bd_id_set == 0)
11724 errmsg ("missing bridge domain");
11728 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11730 /* Get list of l2 fib entries */
11731 M (L2_FIB_TABLE_DUMP, mp);
11733 mp->bd_id = ntohl (bd_id);
11736 /* Use a control ping for synchronization */
11737 M (CONTROL_PING, mp_ping);
11746 api_interface_name_renumber (vat_main_t * vam)
11748 unformat_input_t *line_input = vam->input;
11749 vl_api_interface_name_renumber_t *mp;
11750 u32 sw_if_index = ~0;
11751 u32 new_show_dev_instance = ~0;
11754 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11756 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11759 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11761 else if (unformat (line_input, "new_show_dev_instance %d",
11762 &new_show_dev_instance))
11768 if (sw_if_index == ~0)
11770 errmsg ("missing interface name or sw_if_index");
11774 if (new_show_dev_instance == ~0)
11776 errmsg ("missing new_show_dev_instance");
11780 M (INTERFACE_NAME_RENUMBER, mp);
11782 mp->sw_if_index = ntohl (sw_if_index);
11783 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11791 api_want_ip4_arp_events (vat_main_t * vam)
11793 unformat_input_t *line_input = vam->input;
11794 vl_api_want_ip4_arp_events_t *mp;
11795 ip4_address_t address;
11796 int address_set = 0;
11797 u32 enable_disable = 1;
11800 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11802 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11804 else if (unformat (line_input, "del"))
11805 enable_disable = 0;
11810 if (address_set == 0)
11812 errmsg ("missing addresses");
11816 M (WANT_IP4_ARP_EVENTS, mp);
11817 mp->enable_disable = enable_disable;
11818 mp->pid = getpid ();
11819 mp->address = address.as_u32;
11827 api_want_ip6_nd_events (vat_main_t * vam)
11829 unformat_input_t *line_input = vam->input;
11830 vl_api_want_ip6_nd_events_t *mp;
11831 ip6_address_t address;
11832 int address_set = 0;
11833 u32 enable_disable = 1;
11836 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11838 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11840 else if (unformat (line_input, "del"))
11841 enable_disable = 0;
11846 if (address_set == 0)
11848 errmsg ("missing addresses");
11852 M (WANT_IP6_ND_EVENTS, mp);
11853 mp->enable_disable = enable_disable;
11854 mp->pid = getpid ();
11855 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11863 api_input_acl_set_interface (vat_main_t * vam)
11865 unformat_input_t *i = vam->input;
11866 vl_api_input_acl_set_interface_t *mp;
11868 int sw_if_index_set;
11869 u32 ip4_table_index = ~0;
11870 u32 ip6_table_index = ~0;
11871 u32 l2_table_index = ~0;
11875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11878 sw_if_index_set = 1;
11879 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11880 sw_if_index_set = 1;
11881 else if (unformat (i, "del"))
11883 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11885 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11887 else if (unformat (i, "l2-table %d", &l2_table_index))
11891 clib_warning ("parse error '%U'", format_unformat_error, i);
11896 if (sw_if_index_set == 0)
11898 errmsg ("missing interface name or sw_if_index");
11902 M (INPUT_ACL_SET_INTERFACE, mp);
11904 mp->sw_if_index = ntohl (sw_if_index);
11905 mp->ip4_table_index = ntohl (ip4_table_index);
11906 mp->ip6_table_index = ntohl (ip6_table_index);
11907 mp->l2_table_index = ntohl (l2_table_index);
11908 mp->is_add = is_add;
11916 api_ip_address_dump (vat_main_t * vam)
11918 unformat_input_t *i = vam->input;
11919 vl_api_ip_address_dump_t *mp;
11920 vl_api_control_ping_t *mp_ping;
11921 u32 sw_if_index = ~0;
11922 u8 sw_if_index_set = 0;
11927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11929 if (unformat (i, "sw_if_index %d", &sw_if_index))
11930 sw_if_index_set = 1;
11932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11933 sw_if_index_set = 1;
11934 else if (unformat (i, "ipv4"))
11936 else if (unformat (i, "ipv6"))
11942 if (ipv4_set && ipv6_set)
11944 errmsg ("ipv4 and ipv6 flags cannot be both set");
11948 if ((!ipv4_set) && (!ipv6_set))
11950 errmsg ("no ipv4 nor ipv6 flag set");
11954 if (sw_if_index_set == 0)
11956 errmsg ("missing interface name or sw_if_index");
11960 vam->current_sw_if_index = sw_if_index;
11961 vam->is_ipv6 = ipv6_set;
11963 M (IP_ADDRESS_DUMP, mp);
11964 mp->sw_if_index = ntohl (sw_if_index);
11965 mp->is_ipv6 = ipv6_set;
11968 /* Use a control ping for synchronization */
11969 M (CONTROL_PING, mp_ping);
11977 api_ip_dump (vat_main_t * vam)
11979 vl_api_ip_dump_t *mp;
11980 vl_api_control_ping_t *mp_ping;
11981 unformat_input_t *in = vam->input;
11988 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11990 if (unformat (in, "ipv4"))
11992 else if (unformat (in, "ipv6"))
11998 if (ipv4_set && ipv6_set)
12000 errmsg ("ipv4 and ipv6 flags cannot be both set");
12004 if ((!ipv4_set) && (!ipv6_set))
12006 errmsg ("no ipv4 nor ipv6 flag set");
12010 is_ipv6 = ipv6_set;
12011 vam->is_ipv6 = is_ipv6;
12013 /* free old data */
12014 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12016 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12018 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12021 mp->is_ipv6 = ipv6_set;
12024 /* Use a control ping for synchronization */
12025 M (CONTROL_PING, mp_ping);
12033 api_ipsec_spd_add_del (vat_main_t * vam)
12035 unformat_input_t *i = vam->input;
12036 vl_api_ipsec_spd_add_del_t *mp;
12041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12043 if (unformat (i, "spd_id %d", &spd_id))
12045 else if (unformat (i, "del"))
12049 clib_warning ("parse error '%U'", format_unformat_error, i);
12055 errmsg ("spd_id must be set");
12059 M (IPSEC_SPD_ADD_DEL, mp);
12061 mp->spd_id = ntohl (spd_id);
12062 mp->is_add = is_add;
12070 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12072 unformat_input_t *i = vam->input;
12073 vl_api_ipsec_interface_add_del_spd_t *mp;
12075 u8 sw_if_index_set = 0;
12076 u32 spd_id = (u32) ~ 0;
12080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12082 if (unformat (i, "del"))
12084 else if (unformat (i, "spd_id %d", &spd_id))
12087 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12088 sw_if_index_set = 1;
12089 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12090 sw_if_index_set = 1;
12093 clib_warning ("parse error '%U'", format_unformat_error, i);
12099 if (spd_id == (u32) ~ 0)
12101 errmsg ("spd_id must be set");
12105 if (sw_if_index_set == 0)
12107 errmsg ("missing interface name or sw_if_index");
12111 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12113 mp->spd_id = ntohl (spd_id);
12114 mp->sw_if_index = ntohl (sw_if_index);
12115 mp->is_add = is_add;
12123 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12125 unformat_input_t *i = vam->input;
12126 vl_api_ipsec_spd_add_del_entry_t *mp;
12127 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12128 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12130 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12131 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12132 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12133 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12136 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12137 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12138 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12139 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12140 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12141 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12145 if (unformat (i, "del"))
12147 if (unformat (i, "outbound"))
12149 if (unformat (i, "inbound"))
12151 else if (unformat (i, "spd_id %d", &spd_id))
12153 else if (unformat (i, "sa_id %d", &sa_id))
12155 else if (unformat (i, "priority %d", &priority))
12157 else if (unformat (i, "protocol %d", &protocol))
12159 else if (unformat (i, "lport_start %d", &lport_start))
12161 else if (unformat (i, "lport_stop %d", &lport_stop))
12163 else if (unformat (i, "rport_start %d", &rport_start))
12165 else if (unformat (i, "rport_stop %d", &rport_stop))
12169 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12175 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12182 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12188 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12195 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12201 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12208 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12214 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12220 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12222 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12224 clib_warning ("unsupported action: 'resolve'");
12230 clib_warning ("parse error '%U'", format_unformat_error, i);
12236 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12238 mp->spd_id = ntohl (spd_id);
12239 mp->priority = ntohl (priority);
12240 mp->is_outbound = is_outbound;
12242 mp->is_ipv6 = is_ipv6;
12243 if (is_ipv6 || is_ip_any)
12245 clib_memcpy (mp->remote_address_start, &raddr6_start,
12246 sizeof (ip6_address_t));
12247 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12248 sizeof (ip6_address_t));
12249 clib_memcpy (mp->local_address_start, &laddr6_start,
12250 sizeof (ip6_address_t));
12251 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12252 sizeof (ip6_address_t));
12256 clib_memcpy (mp->remote_address_start, &raddr4_start,
12257 sizeof (ip4_address_t));
12258 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12259 sizeof (ip4_address_t));
12260 clib_memcpy (mp->local_address_start, &laddr4_start,
12261 sizeof (ip4_address_t));
12262 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12263 sizeof (ip4_address_t));
12265 mp->protocol = (u8) protocol;
12266 mp->local_port_start = ntohs ((u16) lport_start);
12267 mp->local_port_stop = ntohs ((u16) lport_stop);
12268 mp->remote_port_start = ntohs ((u16) rport_start);
12269 mp->remote_port_stop = ntohs ((u16) rport_stop);
12270 mp->policy = (u8) policy;
12271 mp->sa_id = ntohl (sa_id);
12272 mp->is_add = is_add;
12273 mp->is_ip_any = is_ip_any;
12280 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12282 unformat_input_t *i = vam->input;
12283 vl_api_ipsec_sad_add_del_entry_t *mp;
12284 u32 sad_id = 0, spi = 0;
12285 u8 *ck = 0, *ik = 0;
12288 u8 protocol = IPSEC_PROTOCOL_AH;
12289 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12290 u32 crypto_alg = 0, integ_alg = 0;
12291 ip4_address_t tun_src4;
12292 ip4_address_t tun_dst4;
12293 ip6_address_t tun_src6;
12294 ip6_address_t tun_dst6;
12297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12299 if (unformat (i, "del"))
12301 else if (unformat (i, "sad_id %d", &sad_id))
12303 else if (unformat (i, "spi %d", &spi))
12305 else if (unformat (i, "esp"))
12306 protocol = IPSEC_PROTOCOL_ESP;
12307 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12310 is_tunnel_ipv6 = 0;
12312 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12315 is_tunnel_ipv6 = 0;
12317 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12320 is_tunnel_ipv6 = 1;
12322 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12325 is_tunnel_ipv6 = 1;
12329 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12331 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12332 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12334 clib_warning ("unsupported crypto-alg: '%U'",
12335 format_ipsec_crypto_alg, crypto_alg);
12339 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12343 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12345 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12346 integ_alg >= IPSEC_INTEG_N_ALG)
12348 clib_warning ("unsupported integ-alg: '%U'",
12349 format_ipsec_integ_alg, integ_alg);
12353 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12357 clib_warning ("parse error '%U'", format_unformat_error, i);
12363 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12365 mp->sad_id = ntohl (sad_id);
12366 mp->is_add = is_add;
12367 mp->protocol = protocol;
12368 mp->spi = ntohl (spi);
12369 mp->is_tunnel = is_tunnel;
12370 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12371 mp->crypto_algorithm = crypto_alg;
12372 mp->integrity_algorithm = integ_alg;
12373 mp->crypto_key_length = vec_len (ck);
12374 mp->integrity_key_length = vec_len (ik);
12376 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12377 mp->crypto_key_length = sizeof (mp->crypto_key);
12379 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12380 mp->integrity_key_length = sizeof (mp->integrity_key);
12383 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12385 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12389 if (is_tunnel_ipv6)
12391 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12392 sizeof (ip6_address_t));
12393 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12394 sizeof (ip6_address_t));
12398 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12399 sizeof (ip4_address_t));
12400 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12401 sizeof (ip4_address_t));
12411 api_ipsec_sa_set_key (vat_main_t * vam)
12413 unformat_input_t *i = vam->input;
12414 vl_api_ipsec_sa_set_key_t *mp;
12416 u8 *ck = 0, *ik = 0;
12419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12421 if (unformat (i, "sa_id %d", &sa_id))
12423 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12425 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12429 clib_warning ("parse error '%U'", format_unformat_error, i);
12434 M (IPSEC_SA_SET_KEY, mp);
12436 mp->sa_id = ntohl (sa_id);
12437 mp->crypto_key_length = vec_len (ck);
12438 mp->integrity_key_length = vec_len (ik);
12440 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12441 mp->crypto_key_length = sizeof (mp->crypto_key);
12443 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12444 mp->integrity_key_length = sizeof (mp->integrity_key);
12447 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12449 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12457 api_ikev2_profile_add_del (vat_main_t * vam)
12459 unformat_input_t *i = vam->input;
12460 vl_api_ikev2_profile_add_del_t *mp;
12465 const char *valid_chars = "a-zA-Z0-9_";
12467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12469 if (unformat (i, "del"))
12471 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12472 vec_add1 (name, 0);
12475 errmsg ("parse error '%U'", format_unformat_error, i);
12480 if (!vec_len (name))
12482 errmsg ("profile name must be specified");
12486 if (vec_len (name) > 64)
12488 errmsg ("profile name too long");
12492 M (IKEV2_PROFILE_ADD_DEL, mp);
12494 clib_memcpy (mp->name, name, vec_len (name));
12495 mp->is_add = is_add;
12504 api_ikev2_profile_set_auth (vat_main_t * vam)
12506 unformat_input_t *i = vam->input;
12507 vl_api_ikev2_profile_set_auth_t *mp;
12510 u32 auth_method = 0;
12514 const char *valid_chars = "a-zA-Z0-9_";
12516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12518 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12519 vec_add1 (name, 0);
12520 else if (unformat (i, "auth_method %U",
12521 unformat_ikev2_auth_method, &auth_method))
12523 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12525 else if (unformat (i, "auth_data %v", &data))
12529 errmsg ("parse error '%U'", format_unformat_error, i);
12534 if (!vec_len (name))
12536 errmsg ("profile name must be specified");
12540 if (vec_len (name) > 64)
12542 errmsg ("profile name too long");
12546 if (!vec_len (data))
12548 errmsg ("auth_data must be specified");
12554 errmsg ("auth_method must be specified");
12558 M (IKEV2_PROFILE_SET_AUTH, mp);
12560 mp->is_hex = is_hex;
12561 mp->auth_method = (u8) auth_method;
12562 mp->data_len = vec_len (data);
12563 clib_memcpy (mp->name, name, vec_len (name));
12564 clib_memcpy (mp->data, data, vec_len (data));
12574 api_ikev2_profile_set_id (vat_main_t * vam)
12576 unformat_input_t *i = vam->input;
12577 vl_api_ikev2_profile_set_id_t *mp;
12585 const char *valid_chars = "a-zA-Z0-9_";
12587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12589 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12590 vec_add1 (name, 0);
12591 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12593 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12595 data = vec_new (u8, 4);
12596 clib_memcpy (data, ip4.as_u8, 4);
12598 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12600 else if (unformat (i, "id_data %v", &data))
12602 else if (unformat (i, "local"))
12604 else if (unformat (i, "remote"))
12608 errmsg ("parse error '%U'", format_unformat_error, i);
12613 if (!vec_len (name))
12615 errmsg ("profile name must be specified");
12619 if (vec_len (name) > 64)
12621 errmsg ("profile name too long");
12625 if (!vec_len (data))
12627 errmsg ("id_data must be specified");
12633 errmsg ("id_type must be specified");
12637 M (IKEV2_PROFILE_SET_ID, mp);
12639 mp->is_local = is_local;
12640 mp->id_type = (u8) id_type;
12641 mp->data_len = vec_len (data);
12642 clib_memcpy (mp->name, name, vec_len (name));
12643 clib_memcpy (mp->data, data, vec_len (data));
12653 api_ikev2_profile_set_ts (vat_main_t * vam)
12655 unformat_input_t *i = vam->input;
12656 vl_api_ikev2_profile_set_ts_t *mp;
12659 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12660 ip4_address_t start_addr, end_addr;
12662 const char *valid_chars = "a-zA-Z0-9_";
12665 start_addr.as_u32 = 0;
12666 end_addr.as_u32 = (u32) ~ 0;
12668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12670 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12671 vec_add1 (name, 0);
12672 else if (unformat (i, "protocol %d", &proto))
12674 else if (unformat (i, "start_port %d", &start_port))
12676 else if (unformat (i, "end_port %d", &end_port))
12679 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12681 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12683 else if (unformat (i, "local"))
12685 else if (unformat (i, "remote"))
12689 errmsg ("parse error '%U'", format_unformat_error, i);
12694 if (!vec_len (name))
12696 errmsg ("profile name must be specified");
12700 if (vec_len (name) > 64)
12702 errmsg ("profile name too long");
12706 M (IKEV2_PROFILE_SET_TS, mp);
12708 mp->is_local = is_local;
12709 mp->proto = (u8) proto;
12710 mp->start_port = (u16) start_port;
12711 mp->end_port = (u16) end_port;
12712 mp->start_addr = start_addr.as_u32;
12713 mp->end_addr = end_addr.as_u32;
12714 clib_memcpy (mp->name, name, vec_len (name));
12723 api_ikev2_set_local_key (vat_main_t * vam)
12725 unformat_input_t *i = vam->input;
12726 vl_api_ikev2_set_local_key_t *mp;
12730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12732 if (unformat (i, "file %v", &file))
12733 vec_add1 (file, 0);
12736 errmsg ("parse error '%U'", format_unformat_error, i);
12741 if (!vec_len (file))
12743 errmsg ("RSA key file must be specified");
12747 if (vec_len (file) > 256)
12749 errmsg ("file name too long");
12753 M (IKEV2_SET_LOCAL_KEY, mp);
12755 clib_memcpy (mp->key_file, file, vec_len (file));
12764 api_ikev2_set_responder (vat_main_t * vam)
12766 unformat_input_t *i = vam->input;
12767 vl_api_ikev2_set_responder_t *mp;
12770 u32 sw_if_index = ~0;
12771 ip4_address_t address;
12773 const char *valid_chars = "a-zA-Z0-9_";
12775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12778 (i, "%U interface %d address %U", unformat_token, valid_chars,
12779 &name, &sw_if_index, unformat_ip4_address, &address))
12780 vec_add1 (name, 0);
12783 errmsg ("parse error '%U'", format_unformat_error, i);
12788 if (!vec_len (name))
12790 errmsg ("profile name must be specified");
12794 if (vec_len (name) > 64)
12796 errmsg ("profile name too long");
12800 M (IKEV2_SET_RESPONDER, mp);
12802 clib_memcpy (mp->name, name, vec_len (name));
12805 mp->sw_if_index = sw_if_index;
12806 clib_memcpy (mp->address, &address, sizeof (address));
12814 api_ikev2_set_ike_transforms (vat_main_t * vam)
12816 unformat_input_t *i = vam->input;
12817 vl_api_ikev2_set_ike_transforms_t *mp;
12820 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12822 const char *valid_chars = "a-zA-Z0-9_";
12824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12826 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12827 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12828 vec_add1 (name, 0);
12831 errmsg ("parse error '%U'", format_unformat_error, i);
12836 if (!vec_len (name))
12838 errmsg ("profile name must be specified");
12842 if (vec_len (name) > 64)
12844 errmsg ("profile name too long");
12848 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12850 clib_memcpy (mp->name, name, vec_len (name));
12852 mp->crypto_alg = crypto_alg;
12853 mp->crypto_key_size = crypto_key_size;
12854 mp->integ_alg = integ_alg;
12855 mp->dh_group = dh_group;
12864 api_ikev2_set_esp_transforms (vat_main_t * vam)
12866 unformat_input_t *i = vam->input;
12867 vl_api_ikev2_set_esp_transforms_t *mp;
12870 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12872 const char *valid_chars = "a-zA-Z0-9_";
12874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12876 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12877 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12878 vec_add1 (name, 0);
12881 errmsg ("parse error '%U'", format_unformat_error, i);
12886 if (!vec_len (name))
12888 errmsg ("profile name must be specified");
12892 if (vec_len (name) > 64)
12894 errmsg ("profile name too long");
12898 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12900 clib_memcpy (mp->name, name, vec_len (name));
12902 mp->crypto_alg = crypto_alg;
12903 mp->crypto_key_size = crypto_key_size;
12904 mp->integ_alg = integ_alg;
12905 mp->dh_group = dh_group;
12913 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12915 unformat_input_t *i = vam->input;
12916 vl_api_ikev2_set_sa_lifetime_t *mp;
12919 u64 lifetime, lifetime_maxdata;
12920 u32 lifetime_jitter, handover;
12922 const char *valid_chars = "a-zA-Z0-9_";
12924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12926 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12927 &lifetime, &lifetime_jitter, &handover,
12928 &lifetime_maxdata))
12929 vec_add1 (name, 0);
12932 errmsg ("parse error '%U'", format_unformat_error, i);
12937 if (!vec_len (name))
12939 errmsg ("profile name must be specified");
12943 if (vec_len (name) > 64)
12945 errmsg ("profile name too long");
12949 M (IKEV2_SET_SA_LIFETIME, mp);
12951 clib_memcpy (mp->name, name, vec_len (name));
12953 mp->lifetime = lifetime;
12954 mp->lifetime_jitter = lifetime_jitter;
12955 mp->handover = handover;
12956 mp->lifetime_maxdata = lifetime_maxdata;
12964 api_ikev2_initiate_sa_init (vat_main_t * vam)
12966 unformat_input_t *i = vam->input;
12967 vl_api_ikev2_initiate_sa_init_t *mp;
12971 const char *valid_chars = "a-zA-Z0-9_";
12973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12975 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12976 vec_add1 (name, 0);
12979 errmsg ("parse error '%U'", format_unformat_error, i);
12984 if (!vec_len (name))
12986 errmsg ("profile name must be specified");
12990 if (vec_len (name) > 64)
12992 errmsg ("profile name too long");
12996 M (IKEV2_INITIATE_SA_INIT, mp);
12998 clib_memcpy (mp->name, name, vec_len (name));
13007 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13009 unformat_input_t *i = vam->input;
13010 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13017 if (unformat (i, "%lx", &ispi))
13021 errmsg ("parse error '%U'", format_unformat_error, i);
13026 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13036 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13038 unformat_input_t *i = vam->input;
13039 vl_api_ikev2_initiate_del_child_sa_t *mp;
13044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13046 if (unformat (i, "%x", &ispi))
13050 errmsg ("parse error '%U'", format_unformat_error, i);
13055 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13065 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13067 unformat_input_t *i = vam->input;
13068 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13075 if (unformat (i, "%x", &ispi))
13079 errmsg ("parse error '%U'", format_unformat_error, i);
13084 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13097 api_map_add_domain (vat_main_t * vam)
13099 unformat_input_t *i = vam->input;
13100 vl_api_map_add_domain_t *mp;
13102 ip4_address_t ip4_prefix;
13103 ip6_address_t ip6_prefix;
13104 ip6_address_t ip6_src;
13105 u32 num_m_args = 0;
13106 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13107 0, psid_length = 0;
13108 u8 is_translation = 0;
13110 u32 ip6_src_len = 128;
13113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13115 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13116 &ip4_prefix, &ip4_prefix_len))
13118 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13119 &ip6_prefix, &ip6_prefix_len))
13123 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13126 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13128 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13130 else if (unformat (i, "psid-offset %d", &psid_offset))
13132 else if (unformat (i, "psid-len %d", &psid_length))
13134 else if (unformat (i, "mtu %d", &mtu))
13136 else if (unformat (i, "map-t"))
13137 is_translation = 1;
13140 clib_warning ("parse error '%U'", format_unformat_error, i);
13145 if (num_m_args < 3)
13147 errmsg ("mandatory argument(s) missing");
13151 /* Construct the API message */
13152 M (MAP_ADD_DOMAIN, mp);
13154 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13155 mp->ip4_prefix_len = ip4_prefix_len;
13157 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13158 mp->ip6_prefix_len = ip6_prefix_len;
13160 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13161 mp->ip6_src_prefix_len = ip6_src_len;
13163 mp->ea_bits_len = ea_bits_len;
13164 mp->psid_offset = psid_offset;
13165 mp->psid_length = psid_length;
13166 mp->is_translation = is_translation;
13167 mp->mtu = htons (mtu);
13172 /* Wait for a reply, return good/bad news */
13178 api_map_del_domain (vat_main_t * vam)
13180 unformat_input_t *i = vam->input;
13181 vl_api_map_del_domain_t *mp;
13183 u32 num_m_args = 0;
13187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13189 if (unformat (i, "index %d", &index))
13193 clib_warning ("parse error '%U'", format_unformat_error, i);
13198 if (num_m_args != 1)
13200 errmsg ("mandatory argument(s) missing");
13204 /* Construct the API message */
13205 M (MAP_DEL_DOMAIN, mp);
13207 mp->index = ntohl (index);
13212 /* Wait for a reply, return good/bad news */
13218 api_map_add_del_rule (vat_main_t * vam)
13220 unformat_input_t *i = vam->input;
13221 vl_api_map_add_del_rule_t *mp;
13223 ip6_address_t ip6_dst;
13224 u32 num_m_args = 0, index, psid = 0;
13227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13229 if (unformat (i, "index %d", &index))
13231 else if (unformat (i, "psid %d", &psid))
13233 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13235 else if (unformat (i, "del"))
13241 clib_warning ("parse error '%U'", format_unformat_error, i);
13246 /* Construct the API message */
13247 M (MAP_ADD_DEL_RULE, mp);
13249 mp->index = ntohl (index);
13250 mp->is_add = is_add;
13251 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13252 mp->psid = ntohs (psid);
13257 /* Wait for a reply, return good/bad news */
13263 api_map_domain_dump (vat_main_t * vam)
13265 vl_api_map_domain_dump_t *mp;
13266 vl_api_control_ping_t *mp_ping;
13269 /* Construct the API message */
13270 M (MAP_DOMAIN_DUMP, mp);
13275 /* Use a control ping for synchronization */
13276 M (CONTROL_PING, mp_ping);
13284 api_map_rule_dump (vat_main_t * vam)
13286 unformat_input_t *i = vam->input;
13287 vl_api_map_rule_dump_t *mp;
13288 vl_api_control_ping_t *mp_ping;
13289 u32 domain_index = ~0;
13292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13294 if (unformat (i, "index %u", &domain_index))
13300 if (domain_index == ~0)
13302 clib_warning ("parse error: domain index expected");
13306 /* Construct the API message */
13307 M (MAP_RULE_DUMP, mp);
13309 mp->domain_index = htonl (domain_index);
13314 /* Use a control ping for synchronization */
13315 M (CONTROL_PING, mp_ping);
13322 static void vl_api_map_add_domain_reply_t_handler
13323 (vl_api_map_add_domain_reply_t * mp)
13325 vat_main_t *vam = &vat_main;
13326 i32 retval = ntohl (mp->retval);
13328 if (vam->async_mode)
13330 vam->async_errors += (retval < 0);
13334 vam->retval = retval;
13335 vam->result_ready = 1;
13339 static void vl_api_map_add_domain_reply_t_handler_json
13340 (vl_api_map_add_domain_reply_t * mp)
13342 vat_main_t *vam = &vat_main;
13343 vat_json_node_t node;
13345 vat_json_init_object (&node);
13346 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13347 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13349 vat_json_print (vam->ofp, &node);
13350 vat_json_free (&node);
13352 vam->retval = ntohl (mp->retval);
13353 vam->result_ready = 1;
13357 api_get_first_msg_id (vat_main_t * vam)
13359 vl_api_get_first_msg_id_t *mp;
13360 unformat_input_t *i = vam->input;
13365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13367 if (unformat (i, "client %s", &name))
13375 errmsg ("missing client name");
13378 vec_add1 (name, 0);
13380 if (vec_len (name) > 63)
13382 errmsg ("client name too long");
13386 M (GET_FIRST_MSG_ID, mp);
13387 clib_memcpy (mp->name, name, vec_len (name));
13394 api_cop_interface_enable_disable (vat_main_t * vam)
13396 unformat_input_t *line_input = vam->input;
13397 vl_api_cop_interface_enable_disable_t *mp;
13398 u32 sw_if_index = ~0;
13399 u8 enable_disable = 1;
13402 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13404 if (unformat (line_input, "disable"))
13405 enable_disable = 0;
13406 if (unformat (line_input, "enable"))
13407 enable_disable = 1;
13408 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13409 vam, &sw_if_index))
13411 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13417 if (sw_if_index == ~0)
13419 errmsg ("missing interface name or sw_if_index");
13423 /* Construct the API message */
13424 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13425 mp->sw_if_index = ntohl (sw_if_index);
13426 mp->enable_disable = enable_disable;
13430 /* Wait for the reply */
13436 api_cop_whitelist_enable_disable (vat_main_t * vam)
13438 unformat_input_t *line_input = vam->input;
13439 vl_api_cop_whitelist_enable_disable_t *mp;
13440 u32 sw_if_index = ~0;
13441 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13445 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13447 if (unformat (line_input, "ip4"))
13449 else if (unformat (line_input, "ip6"))
13451 else if (unformat (line_input, "default"))
13453 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13454 vam, &sw_if_index))
13456 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13458 else if (unformat (line_input, "fib-id %d", &fib_id))
13464 if (sw_if_index == ~0)
13466 errmsg ("missing interface name or sw_if_index");
13470 /* Construct the API message */
13471 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13472 mp->sw_if_index = ntohl (sw_if_index);
13473 mp->fib_id = ntohl (fib_id);
13476 mp->default_cop = default_cop;
13480 /* Wait for the reply */
13486 api_get_node_graph (vat_main_t * vam)
13488 vl_api_get_node_graph_t *mp;
13491 M (GET_NODE_GRAPH, mp);
13495 /* Wait for the reply */
13501 /** Used for parsing LISP eids */
13502 typedef CLIB_PACKED(struct{
13503 u8 addr[16]; /**< eid address */
13504 u32 len; /**< prefix length if IP */
13505 u8 type; /**< type of eid */
13510 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13512 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13514 memset (a, 0, sizeof (a[0]));
13516 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13518 a->type = 0; /* ipv4 type */
13520 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13522 a->type = 1; /* ipv6 type */
13524 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13526 a->type = 2; /* mac type */
13533 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13542 lisp_eid_size_vat (u8 type)
13557 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13559 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13563 api_one_add_del_locator_set (vat_main_t * vam)
13565 unformat_input_t *input = vam->input;
13566 vl_api_one_add_del_locator_set_t *mp;
13568 u8 *locator_set_name = NULL;
13569 u8 locator_set_name_set = 0;
13570 vl_api_local_locator_t locator, *locators = 0;
13571 u32 sw_if_index, priority, weight;
13575 /* Parse args required to build the message */
13576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13578 if (unformat (input, "del"))
13582 else if (unformat (input, "locator-set %s", &locator_set_name))
13584 locator_set_name_set = 1;
13586 else if (unformat (input, "sw_if_index %u p %u w %u",
13587 &sw_if_index, &priority, &weight))
13589 locator.sw_if_index = htonl (sw_if_index);
13590 locator.priority = priority;
13591 locator.weight = weight;
13592 vec_add1 (locators, locator);
13596 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13597 &sw_if_index, &priority, &weight))
13599 locator.sw_if_index = htonl (sw_if_index);
13600 locator.priority = priority;
13601 locator.weight = weight;
13602 vec_add1 (locators, locator);
13608 if (locator_set_name_set == 0)
13610 errmsg ("missing locator-set name");
13611 vec_free (locators);
13615 if (vec_len (locator_set_name) > 64)
13617 errmsg ("locator-set name too long");
13618 vec_free (locator_set_name);
13619 vec_free (locators);
13622 vec_add1 (locator_set_name, 0);
13624 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13626 /* Construct the API message */
13627 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13629 mp->is_add = is_add;
13630 clib_memcpy (mp->locator_set_name, locator_set_name,
13631 vec_len (locator_set_name));
13632 vec_free (locator_set_name);
13634 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13636 clib_memcpy (mp->locators, locators, data_len);
13637 vec_free (locators);
13642 /* Wait for a reply... */
13647 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13650 api_one_add_del_locator (vat_main_t * vam)
13652 unformat_input_t *input = vam->input;
13653 vl_api_one_add_del_locator_t *mp;
13654 u32 tmp_if_index = ~0;
13655 u32 sw_if_index = ~0;
13656 u8 sw_if_index_set = 0;
13657 u8 sw_if_index_if_name_set = 0;
13659 u8 priority_set = 0;
13663 u8 *locator_set_name = NULL;
13664 u8 locator_set_name_set = 0;
13667 /* Parse args required to build the message */
13668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13670 if (unformat (input, "del"))
13674 else if (unformat (input, "locator-set %s", &locator_set_name))
13676 locator_set_name_set = 1;
13678 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13681 sw_if_index_if_name_set = 1;
13682 sw_if_index = tmp_if_index;
13684 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13686 sw_if_index_set = 1;
13687 sw_if_index = tmp_if_index;
13689 else if (unformat (input, "p %d", &priority))
13693 else if (unformat (input, "w %d", &weight))
13701 if (locator_set_name_set == 0)
13703 errmsg ("missing locator-set name");
13707 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13709 errmsg ("missing sw_if_index");
13710 vec_free (locator_set_name);
13714 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13716 errmsg ("cannot use both params interface name and sw_if_index");
13717 vec_free (locator_set_name);
13721 if (priority_set == 0)
13723 errmsg ("missing locator-set priority");
13724 vec_free (locator_set_name);
13728 if (weight_set == 0)
13730 errmsg ("missing locator-set weight");
13731 vec_free (locator_set_name);
13735 if (vec_len (locator_set_name) > 64)
13737 errmsg ("locator-set name too long");
13738 vec_free (locator_set_name);
13741 vec_add1 (locator_set_name, 0);
13743 /* Construct the API message */
13744 M (ONE_ADD_DEL_LOCATOR, mp);
13746 mp->is_add = is_add;
13747 mp->sw_if_index = ntohl (sw_if_index);
13748 mp->priority = priority;
13749 mp->weight = weight;
13750 clib_memcpy (mp->locator_set_name, locator_set_name,
13751 vec_len (locator_set_name));
13752 vec_free (locator_set_name);
13757 /* Wait for a reply... */
13762 #define api_lisp_add_del_locator api_one_add_del_locator
13765 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13767 u32 *key_id = va_arg (*args, u32 *);
13770 if (unformat (input, "%s", &s))
13772 if (!strcmp ((char *) s, "sha1"))
13773 key_id[0] = HMAC_SHA_1_96;
13774 else if (!strcmp ((char *) s, "sha256"))
13775 key_id[0] = HMAC_SHA_256_128;
13778 clib_warning ("invalid key_id: '%s'", s);
13779 key_id[0] = HMAC_NO_KEY;
13790 api_one_add_del_local_eid (vat_main_t * vam)
13792 unformat_input_t *input = vam->input;
13793 vl_api_one_add_del_local_eid_t *mp;
13796 lisp_eid_vat_t _eid, *eid = &_eid;
13797 u8 *locator_set_name = 0;
13798 u8 locator_set_name_set = 0;
13804 /* Parse args required to build the message */
13805 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13807 if (unformat (input, "del"))
13811 else if (unformat (input, "vni %d", &vni))
13815 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13819 else if (unformat (input, "locator-set %s", &locator_set_name))
13821 locator_set_name_set = 1;
13823 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13825 else if (unformat (input, "secret-key %_%v%_", &key))
13831 if (locator_set_name_set == 0)
13833 errmsg ("missing locator-set name");
13839 errmsg ("EID address not set!");
13840 vec_free (locator_set_name);
13844 if (key && (0 == key_id))
13846 errmsg ("invalid key_id!");
13850 if (vec_len (key) > 64)
13852 errmsg ("key too long");
13857 if (vec_len (locator_set_name) > 64)
13859 errmsg ("locator-set name too long");
13860 vec_free (locator_set_name);
13863 vec_add1 (locator_set_name, 0);
13865 /* Construct the API message */
13866 M (ONE_ADD_DEL_LOCAL_EID, mp);
13868 mp->is_add = is_add;
13869 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13870 mp->eid_type = eid->type;
13871 mp->prefix_len = eid->len;
13872 mp->vni = clib_host_to_net_u32 (vni);
13873 mp->key_id = clib_host_to_net_u16 (key_id);
13874 clib_memcpy (mp->locator_set_name, locator_set_name,
13875 vec_len (locator_set_name));
13876 clib_memcpy (mp->key, key, vec_len (key));
13878 vec_free (locator_set_name);
13884 /* Wait for a reply... */
13889 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13892 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13894 u32 dp_table = 0, vni = 0;;
13895 unformat_input_t *input = vam->input;
13896 vl_api_gpe_add_del_fwd_entry_t *mp;
13898 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13899 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13900 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13901 u32 action = ~0, w;
13902 ip4_address_t rmt_rloc4, lcl_rloc4;
13903 ip6_address_t rmt_rloc6, lcl_rloc6;
13904 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13907 memset (&rloc, 0, sizeof (rloc));
13909 /* Parse args required to build the message */
13910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13912 if (unformat (input, "del"))
13914 else if (unformat (input, "add"))
13916 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13920 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13924 else if (unformat (input, "vrf %d", &dp_table))
13926 else if (unformat (input, "bd %d", &dp_table))
13928 else if (unformat (input, "vni %d", &vni))
13930 else if (unformat (input, "w %d", &w))
13934 errmsg ("No RLOC configured for setting priority/weight!");
13937 curr_rloc->weight = w;
13939 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13940 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13944 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13946 vec_add1 (lcl_locs, rloc);
13948 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13949 vec_add1 (rmt_locs, rloc);
13950 /* weight saved in rmt loc */
13951 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13953 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13954 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13957 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13959 vec_add1 (lcl_locs, rloc);
13961 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13962 vec_add1 (rmt_locs, rloc);
13963 /* weight saved in rmt loc */
13964 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13966 else if (unformat (input, "action %d", &action))
13972 clib_warning ("parse error '%U'", format_unformat_error, input);
13979 errmsg ("remote eid addresses not set");
13983 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13985 errmsg ("eid types don't match");
13989 if (0 == rmt_locs && (u32) ~ 0 == action)
13991 errmsg ("action not set for negative mapping");
13995 /* Construct the API message */
13996 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13997 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13999 mp->is_add = is_add;
14000 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14001 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14002 mp->eid_type = rmt_eid->type;
14003 mp->dp_table = clib_host_to_net_u32 (dp_table);
14004 mp->vni = clib_host_to_net_u32 (vni);
14005 mp->rmt_len = rmt_eid->len;
14006 mp->lcl_len = lcl_eid->len;
14007 mp->action = action;
14009 if (0 != rmt_locs && 0 != lcl_locs)
14011 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14012 clib_memcpy (mp->locs, lcl_locs,
14013 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14015 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14016 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14017 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14019 vec_free (lcl_locs);
14020 vec_free (rmt_locs);
14025 /* Wait for a reply... */
14031 api_one_add_del_map_server (vat_main_t * vam)
14033 unformat_input_t *input = vam->input;
14034 vl_api_one_add_del_map_server_t *mp;
14038 ip4_address_t ipv4;
14039 ip6_address_t ipv6;
14042 /* Parse args required to build the message */
14043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14045 if (unformat (input, "del"))
14049 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14053 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14061 if (ipv4_set && ipv6_set)
14063 errmsg ("both eid v4 and v6 addresses set");
14067 if (!ipv4_set && !ipv6_set)
14069 errmsg ("eid addresses not set");
14073 /* Construct the API message */
14074 M (ONE_ADD_DEL_MAP_SERVER, mp);
14076 mp->is_add = is_add;
14080 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14085 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14091 /* Wait for a reply... */
14096 #define api_lisp_add_del_map_server api_one_add_del_map_server
14099 api_one_add_del_map_resolver (vat_main_t * vam)
14101 unformat_input_t *input = vam->input;
14102 vl_api_one_add_del_map_resolver_t *mp;
14106 ip4_address_t ipv4;
14107 ip6_address_t ipv6;
14110 /* Parse args required to build the message */
14111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14113 if (unformat (input, "del"))
14117 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14121 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14129 if (ipv4_set && ipv6_set)
14131 errmsg ("both eid v4 and v6 addresses set");
14135 if (!ipv4_set && !ipv6_set)
14137 errmsg ("eid addresses not set");
14141 /* Construct the API message */
14142 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14144 mp->is_add = is_add;
14148 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14153 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14159 /* Wait for a reply... */
14164 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14167 api_lisp_gpe_enable_disable (vat_main_t * vam)
14169 unformat_input_t *input = vam->input;
14170 vl_api_gpe_enable_disable_t *mp;
14175 /* Parse args required to build the message */
14176 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14178 if (unformat (input, "enable"))
14183 else if (unformat (input, "disable"))
14194 errmsg ("Value not set");
14198 /* Construct the API message */
14199 M (GPE_ENABLE_DISABLE, mp);
14206 /* Wait for a reply... */
14212 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14214 unformat_input_t *input = vam->input;
14215 vl_api_one_rloc_probe_enable_disable_t *mp;
14220 /* Parse args required to build the message */
14221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14223 if (unformat (input, "enable"))
14228 else if (unformat (input, "disable"))
14236 errmsg ("Value not set");
14240 /* Construct the API message */
14241 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14243 mp->is_enabled = is_en;
14248 /* Wait for a reply... */
14253 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14256 api_one_map_register_enable_disable (vat_main_t * vam)
14258 unformat_input_t *input = vam->input;
14259 vl_api_one_map_register_enable_disable_t *mp;
14264 /* Parse args required to build the message */
14265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14267 if (unformat (input, "enable"))
14272 else if (unformat (input, "disable"))
14280 errmsg ("Value not set");
14284 /* Construct the API message */
14285 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14287 mp->is_enabled = is_en;
14292 /* Wait for a reply... */
14297 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14300 api_one_enable_disable (vat_main_t * vam)
14302 unformat_input_t *input = vam->input;
14303 vl_api_one_enable_disable_t *mp;
14308 /* Parse args required to build the message */
14309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14311 if (unformat (input, "enable"))
14316 else if (unformat (input, "disable"))
14326 errmsg ("Value not set");
14330 /* Construct the API message */
14331 M (ONE_ENABLE_DISABLE, mp);
14338 /* Wait for a reply... */
14343 #define api_lisp_enable_disable api_one_enable_disable
14346 api_show_one_map_register_state (vat_main_t * vam)
14348 vl_api_show_one_map_register_state_t *mp;
14351 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14356 /* wait for reply */
14361 #define api_show_lisp_map_register_state api_show_one_map_register_state
14364 api_show_one_rloc_probe_state (vat_main_t * vam)
14366 vl_api_show_one_rloc_probe_state_t *mp;
14369 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14374 /* wait for reply */
14379 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14382 api_show_one_map_request_mode (vat_main_t * vam)
14384 vl_api_show_one_map_request_mode_t *mp;
14387 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14392 /* wait for reply */
14397 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14400 api_one_map_request_mode (vat_main_t * vam)
14402 unformat_input_t *input = vam->input;
14403 vl_api_one_map_request_mode_t *mp;
14407 /* Parse args required to build the message */
14408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14410 if (unformat (input, "dst-only"))
14412 else if (unformat (input, "src-dst"))
14416 errmsg ("parse error '%U'", format_unformat_error, input);
14421 M (ONE_MAP_REQUEST_MODE, mp);
14428 /* wait for reply */
14433 #define api_lisp_map_request_mode api_one_map_request_mode
14436 * Enable/disable ONE proxy ITR.
14438 * @param vam vpp API test context
14439 * @return return code
14442 api_one_pitr_set_locator_set (vat_main_t * vam)
14444 u8 ls_name_set = 0;
14445 unformat_input_t *input = vam->input;
14446 vl_api_one_pitr_set_locator_set_t *mp;
14451 /* Parse args required to build the message */
14452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14454 if (unformat (input, "del"))
14456 else if (unformat (input, "locator-set %s", &ls_name))
14460 errmsg ("parse error '%U'", format_unformat_error, input);
14467 errmsg ("locator-set name not set!");
14471 M (ONE_PITR_SET_LOCATOR_SET, mp);
14473 mp->is_add = is_add;
14474 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14475 vec_free (ls_name);
14480 /* wait for reply */
14485 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14488 api_show_one_pitr (vat_main_t * vam)
14490 vl_api_show_one_pitr_t *mp;
14493 if (!vam->json_output)
14495 print (vam->ofp, "%=20s", "lisp status:");
14498 M (SHOW_ONE_PITR, mp);
14502 /* Wait for a reply... */
14507 #define api_show_lisp_pitr api_show_one_pitr
14510 * Add/delete mapping between vni and vrf
14513 api_one_eid_table_add_del_map (vat_main_t * vam)
14515 unformat_input_t *input = vam->input;
14516 vl_api_one_eid_table_add_del_map_t *mp;
14517 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14518 u32 vni, vrf, bd_index;
14521 /* Parse args required to build the message */
14522 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14524 if (unformat (input, "del"))
14526 else if (unformat (input, "vrf %d", &vrf))
14528 else if (unformat (input, "bd_index %d", &bd_index))
14530 else if (unformat (input, "vni %d", &vni))
14536 if (!vni_set || (!vrf_set && !bd_index_set))
14538 errmsg ("missing arguments!");
14542 if (vrf_set && bd_index_set)
14544 errmsg ("error: both vrf and bd entered!");
14548 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14550 mp->is_add = is_add;
14551 mp->vni = htonl (vni);
14552 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14553 mp->is_l2 = bd_index_set;
14558 /* wait for reply */
14563 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14566 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14568 u32 *action = va_arg (*args, u32 *);
14571 if (unformat (input, "%s", &s))
14573 if (!strcmp ((char *) s, "no-action"))
14575 else if (!strcmp ((char *) s, "natively-forward"))
14577 else if (!strcmp ((char *) s, "send-map-request"))
14579 else if (!strcmp ((char *) s, "drop"))
14583 clib_warning ("invalid action: '%s'", s);
14595 * Add/del remote mapping to/from ONE control plane
14597 * @param vam vpp API test context
14598 * @return return code
14601 api_one_add_del_remote_mapping (vat_main_t * vam)
14603 unformat_input_t *input = vam->input;
14604 vl_api_one_add_del_remote_mapping_t *mp;
14606 lisp_eid_vat_t _eid, *eid = &_eid;
14607 lisp_eid_vat_t _seid, *seid = &_seid;
14608 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14609 u32 action = ~0, p, w, data_len;
14610 ip4_address_t rloc4;
14611 ip6_address_t rloc6;
14612 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14615 memset (&rloc, 0, sizeof (rloc));
14617 /* Parse args required to build the message */
14618 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14620 if (unformat (input, "del-all"))
14624 else if (unformat (input, "del"))
14628 else if (unformat (input, "add"))
14632 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14636 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14640 else if (unformat (input, "vni %d", &vni))
14644 else if (unformat (input, "p %d w %d", &p, &w))
14648 errmsg ("No RLOC configured for setting priority/weight!");
14651 curr_rloc->priority = p;
14652 curr_rloc->weight = w;
14654 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14657 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14658 vec_add1 (rlocs, rloc);
14659 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14661 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14664 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14665 vec_add1 (rlocs, rloc);
14666 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14668 else if (unformat (input, "action %U",
14669 unformat_negative_mapping_action, &action))
14675 clib_warning ("parse error '%U'", format_unformat_error, input);
14682 errmsg ("missing params!");
14686 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14688 errmsg ("no action set for negative map-reply!");
14692 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14694 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14695 mp->is_add = is_add;
14696 mp->vni = htonl (vni);
14697 mp->action = (u8) action;
14698 mp->is_src_dst = seid_set;
14699 mp->eid_len = eid->len;
14700 mp->seid_len = seid->len;
14701 mp->del_all = del_all;
14702 mp->eid_type = eid->type;
14703 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14704 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14706 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14707 clib_memcpy (mp->rlocs, rlocs, data_len);
14713 /* Wait for a reply... */
14718 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14721 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14722 * forwarding entries in data-plane accordingly.
14724 * @param vam vpp API test context
14725 * @return return code
14728 api_one_add_del_adjacency (vat_main_t * vam)
14730 unformat_input_t *input = vam->input;
14731 vl_api_one_add_del_adjacency_t *mp;
14733 ip4_address_t leid4, reid4;
14734 ip6_address_t leid6, reid6;
14735 u8 reid_mac[6] = { 0 };
14736 u8 leid_mac[6] = { 0 };
14737 u8 reid_type, leid_type;
14738 u32 leid_len = 0, reid_len = 0, len;
14742 leid_type = reid_type = (u8) ~ 0;
14744 /* Parse args required to build the message */
14745 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14747 if (unformat (input, "del"))
14751 else if (unformat (input, "add"))
14755 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14758 reid_type = 0; /* ipv4 */
14761 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14764 reid_type = 1; /* ipv6 */
14767 else if (unformat (input, "reid %U", unformat_ethernet_address,
14770 reid_type = 2; /* mac */
14772 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14775 leid_type = 0; /* ipv4 */
14778 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14781 leid_type = 1; /* ipv6 */
14784 else if (unformat (input, "leid %U", unformat_ethernet_address,
14787 leid_type = 2; /* mac */
14789 else if (unformat (input, "vni %d", &vni))
14795 errmsg ("parse error '%U'", format_unformat_error, input);
14800 if ((u8) ~ 0 == reid_type)
14802 errmsg ("missing params!");
14806 if (leid_type != reid_type)
14808 errmsg ("remote and local EIDs are of different types!");
14812 M (ONE_ADD_DEL_ADJACENCY, mp);
14813 mp->is_add = is_add;
14814 mp->vni = htonl (vni);
14815 mp->leid_len = leid_len;
14816 mp->reid_len = reid_len;
14817 mp->eid_type = reid_type;
14819 switch (mp->eid_type)
14822 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14823 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14826 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14827 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14830 clib_memcpy (mp->leid, leid_mac, 6);
14831 clib_memcpy (mp->reid, reid_mac, 6);
14834 errmsg ("unknown EID type %d!", mp->eid_type);
14841 /* Wait for a reply... */
14846 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14849 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14851 unformat_input_t *input = vam->input;
14852 vl_api_gpe_add_del_iface_t *mp;
14853 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14854 u32 dp_table = 0, vni = 0;
14857 /* Parse args required to build the message */
14858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14860 if (unformat (input, "up"))
14865 else if (unformat (input, "down"))
14870 else if (unformat (input, "table_id %d", &dp_table))
14874 else if (unformat (input, "bd_id %d", &dp_table))
14879 else if (unformat (input, "vni %d", &vni))
14887 if (action_set == 0)
14889 errmsg ("Action not set");
14892 if (dp_table_set == 0 || vni_set == 0)
14894 errmsg ("vni and dp_table must be set");
14898 /* Construct the API message */
14899 M (GPE_ADD_DEL_IFACE, mp);
14901 mp->is_add = is_add;
14902 mp->dp_table = dp_table;
14909 /* Wait for a reply... */
14915 * Add/del map request itr rlocs from ONE control plane and updates
14917 * @param vam vpp API test context
14918 * @return return code
14921 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14923 unformat_input_t *input = vam->input;
14924 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14925 u8 *locator_set_name = 0;
14926 u8 locator_set_name_set = 0;
14930 /* Parse args required to build the message */
14931 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14933 if (unformat (input, "del"))
14937 else if (unformat (input, "%_%v%_", &locator_set_name))
14939 locator_set_name_set = 1;
14943 clib_warning ("parse error '%U'", format_unformat_error, input);
14948 if (is_add && !locator_set_name_set)
14950 errmsg ("itr-rloc is not set!");
14954 if (is_add && vec_len (locator_set_name) > 64)
14956 errmsg ("itr-rloc locator-set name too long");
14957 vec_free (locator_set_name);
14961 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14962 mp->is_add = is_add;
14965 clib_memcpy (mp->locator_set_name, locator_set_name,
14966 vec_len (locator_set_name));
14970 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14972 vec_free (locator_set_name);
14977 /* Wait for a reply... */
14982 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14985 api_one_locator_dump (vat_main_t * vam)
14987 unformat_input_t *input = vam->input;
14988 vl_api_one_locator_dump_t *mp;
14989 vl_api_control_ping_t *mp_ping;
14990 u8 is_index_set = 0, is_name_set = 0;
14995 /* Parse args required to build the message */
14996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14998 if (unformat (input, "ls_name %_%v%_", &ls_name))
15002 else if (unformat (input, "ls_index %d", &ls_index))
15008 errmsg ("parse error '%U'", format_unformat_error, input);
15013 if (!is_index_set && !is_name_set)
15015 errmsg ("error: expected one of index or name!");
15019 if (is_index_set && is_name_set)
15021 errmsg ("error: only one param expected!");
15025 if (vec_len (ls_name) > 62)
15027 errmsg ("error: locator set name too long!");
15031 if (!vam->json_output)
15033 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15036 M (ONE_LOCATOR_DUMP, mp);
15037 mp->is_index_set = is_index_set;
15040 mp->ls_index = clib_host_to_net_u32 (ls_index);
15043 vec_add1 (ls_name, 0);
15044 strncpy ((char *) mp->ls_name, (char *) ls_name,
15045 sizeof (mp->ls_name) - 1);
15051 /* Use a control ping for synchronization */
15052 M (CONTROL_PING, mp_ping);
15055 /* Wait for a reply... */
15060 #define api_lisp_locator_dump api_one_locator_dump
15063 api_one_locator_set_dump (vat_main_t * vam)
15065 vl_api_one_locator_set_dump_t *mp;
15066 vl_api_control_ping_t *mp_ping;
15067 unformat_input_t *input = vam->input;
15071 /* Parse args required to build the message */
15072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15074 if (unformat (input, "local"))
15078 else if (unformat (input, "remote"))
15084 errmsg ("parse error '%U'", format_unformat_error, input);
15089 if (!vam->json_output)
15091 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15094 M (ONE_LOCATOR_SET_DUMP, mp);
15096 mp->filter = filter;
15101 /* Use a control ping for synchronization */
15102 M (CONTROL_PING, mp_ping);
15105 /* Wait for a reply... */
15110 #define api_lisp_locator_set_dump api_one_locator_set_dump
15113 api_one_eid_table_map_dump (vat_main_t * vam)
15117 unformat_input_t *input = vam->input;
15118 vl_api_one_eid_table_map_dump_t *mp;
15119 vl_api_control_ping_t *mp_ping;
15122 /* Parse args required to build the message */
15123 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15125 if (unformat (input, "l2"))
15130 else if (unformat (input, "l3"))
15137 errmsg ("parse error '%U'", format_unformat_error, input);
15144 errmsg ("expected one of 'l2' or 'l3' parameter!");
15148 if (!vam->json_output)
15150 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15153 M (ONE_EID_TABLE_MAP_DUMP, mp);
15159 /* Use a control ping for synchronization */
15160 M (CONTROL_PING, mp_ping);
15163 /* Wait for a reply... */
15168 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15171 api_one_eid_table_vni_dump (vat_main_t * vam)
15173 vl_api_one_eid_table_vni_dump_t *mp;
15174 vl_api_control_ping_t *mp_ping;
15177 if (!vam->json_output)
15179 print (vam->ofp, "VNI");
15182 M (ONE_EID_TABLE_VNI_DUMP, mp);
15187 /* Use a control ping for synchronization */
15188 M (CONTROL_PING, mp_ping);
15191 /* Wait for a reply... */
15196 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15199 api_one_eid_table_dump (vat_main_t * vam)
15201 unformat_input_t *i = vam->input;
15202 vl_api_one_eid_table_dump_t *mp;
15203 vl_api_control_ping_t *mp_ping;
15204 struct in_addr ip4;
15205 struct in6_addr ip6;
15207 u8 eid_type = ~0, eid_set = 0;
15208 u32 prefix_length = ~0, t, vni = 0;
15212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15214 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15220 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15226 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15231 else if (unformat (i, "vni %d", &t))
15235 else if (unformat (i, "local"))
15239 else if (unformat (i, "remote"))
15245 errmsg ("parse error '%U'", format_unformat_error, i);
15250 if (!vam->json_output)
15252 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15253 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15256 M (ONE_EID_TABLE_DUMP, mp);
15258 mp->filter = filter;
15262 mp->vni = htonl (vni);
15263 mp->eid_type = eid_type;
15267 mp->prefix_length = prefix_length;
15268 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15271 mp->prefix_length = prefix_length;
15272 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15275 clib_memcpy (mp->eid, mac, sizeof (mac));
15278 errmsg ("unknown EID type %d!", eid_type);
15286 /* Use a control ping for synchronization */
15287 M (CONTROL_PING, mp_ping);
15290 /* Wait for a reply... */
15295 #define api_lisp_eid_table_dump api_one_eid_table_dump
15298 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15300 unformat_input_t *i = vam->input;
15301 vl_api_gpe_fwd_entries_get_t *mp;
15306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15308 if (unformat (i, "vni %d", &vni))
15314 errmsg ("parse error '%U'", format_unformat_error, i);
15321 errmsg ("vni not set!");
15325 if (!vam->json_output)
15327 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15331 M (GPE_FWD_ENTRIES_GET, mp);
15332 mp->vni = clib_host_to_net_u32 (vni);
15337 /* Wait for a reply... */
15342 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15343 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15344 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15345 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15348 api_one_adjacencies_get (vat_main_t * vam)
15350 unformat_input_t *i = vam->input;
15351 vl_api_one_adjacencies_get_t *mp;
15356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15358 if (unformat (i, "vni %d", &vni))
15364 errmsg ("parse error '%U'", format_unformat_error, i);
15371 errmsg ("vni not set!");
15375 if (!vam->json_output)
15377 print (vam->ofp, "%s %40s", "leid", "reid");
15380 M (ONE_ADJACENCIES_GET, mp);
15381 mp->vni = clib_host_to_net_u32 (vni);
15386 /* Wait for a reply... */
15391 #define api_lisp_adjacencies_get api_one_adjacencies_get
15394 api_one_map_server_dump (vat_main_t * vam)
15396 vl_api_one_map_server_dump_t *mp;
15397 vl_api_control_ping_t *mp_ping;
15400 if (!vam->json_output)
15402 print (vam->ofp, "%=20s", "Map server");
15405 M (ONE_MAP_SERVER_DUMP, mp);
15409 /* Use a control ping for synchronization */
15410 M (CONTROL_PING, mp_ping);
15413 /* Wait for a reply... */
15418 #define api_lisp_map_server_dump api_one_map_server_dump
15421 api_one_map_resolver_dump (vat_main_t * vam)
15423 vl_api_one_map_resolver_dump_t *mp;
15424 vl_api_control_ping_t *mp_ping;
15427 if (!vam->json_output)
15429 print (vam->ofp, "%=20s", "Map resolver");
15432 M (ONE_MAP_RESOLVER_DUMP, mp);
15436 /* Use a control ping for synchronization */
15437 M (CONTROL_PING, mp_ping);
15440 /* Wait for a reply... */
15445 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15448 api_show_one_status (vat_main_t * vam)
15450 vl_api_show_one_status_t *mp;
15453 if (!vam->json_output)
15455 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15458 M (SHOW_ONE_STATUS, mp);
15461 /* Wait for a reply... */
15466 #define api_show_lisp_status api_show_one_status
15469 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15471 vl_api_gpe_fwd_entry_path_dump_t *mp;
15472 vl_api_control_ping_t *mp_ping;
15473 unformat_input_t *i = vam->input;
15474 u32 fwd_entry_index = ~0;
15477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15479 if (unformat (i, "index %d", &fwd_entry_index))
15485 if (~0 == fwd_entry_index)
15487 errmsg ("no index specified!");
15491 if (!vam->json_output)
15493 print (vam->ofp, "first line");
15496 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15500 /* Use a control ping for synchronization */
15501 M (CONTROL_PING, mp_ping);
15504 /* Wait for a reply... */
15510 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15512 vl_api_one_get_map_request_itr_rlocs_t *mp;
15515 if (!vam->json_output)
15517 print (vam->ofp, "%=20s", "itr-rlocs:");
15520 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15523 /* Wait for a reply... */
15528 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15531 api_af_packet_create (vat_main_t * vam)
15533 unformat_input_t *i = vam->input;
15534 vl_api_af_packet_create_t *mp;
15535 u8 *host_if_name = 0;
15537 u8 random_hw_addr = 1;
15540 memset (hw_addr, 0, sizeof (hw_addr));
15542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15544 if (unformat (i, "name %s", &host_if_name))
15545 vec_add1 (host_if_name, 0);
15546 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15547 random_hw_addr = 0;
15552 if (!vec_len (host_if_name))
15554 errmsg ("host-interface name must be specified");
15558 if (vec_len (host_if_name) > 64)
15560 errmsg ("host-interface name too long");
15564 M (AF_PACKET_CREATE, mp);
15566 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15567 clib_memcpy (mp->hw_addr, hw_addr, 6);
15568 mp->use_random_hw_addr = random_hw_addr;
15569 vec_free (host_if_name);
15572 W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15577 api_af_packet_delete (vat_main_t * vam)
15579 unformat_input_t *i = vam->input;
15580 vl_api_af_packet_delete_t *mp;
15581 u8 *host_if_name = 0;
15584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15586 if (unformat (i, "name %s", &host_if_name))
15587 vec_add1 (host_if_name, 0);
15592 if (!vec_len (host_if_name))
15594 errmsg ("host-interface name must be specified");
15598 if (vec_len (host_if_name) > 64)
15600 errmsg ("host-interface name too long");
15604 M (AF_PACKET_DELETE, mp);
15606 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15607 vec_free (host_if_name);
15615 api_policer_add_del (vat_main_t * vam)
15617 unformat_input_t *i = vam->input;
15618 vl_api_policer_add_del_t *mp;
15628 u8 color_aware = 0;
15629 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15632 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15633 conform_action.dscp = 0;
15634 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15635 exceed_action.dscp = 0;
15636 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15637 violate_action.dscp = 0;
15639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15641 if (unformat (i, "del"))
15643 else if (unformat (i, "name %s", &name))
15644 vec_add1 (name, 0);
15645 else if (unformat (i, "cir %u", &cir))
15647 else if (unformat (i, "eir %u", &eir))
15649 else if (unformat (i, "cb %u", &cb))
15651 else if (unformat (i, "eb %u", &eb))
15653 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15656 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15659 else if (unformat (i, "type %U", unformat_policer_type, &type))
15661 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15664 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15667 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15670 else if (unformat (i, "color-aware"))
15676 if (!vec_len (name))
15678 errmsg ("policer name must be specified");
15682 if (vec_len (name) > 64)
15684 errmsg ("policer name too long");
15688 M (POLICER_ADD_DEL, mp);
15690 clib_memcpy (mp->name, name, vec_len (name));
15692 mp->is_add = is_add;
15697 mp->rate_type = rate_type;
15698 mp->round_type = round_type;
15700 mp->conform_action_type = conform_action.action_type;
15701 mp->conform_dscp = conform_action.dscp;
15702 mp->exceed_action_type = exceed_action.action_type;
15703 mp->exceed_dscp = exceed_action.dscp;
15704 mp->violate_action_type = violate_action.action_type;
15705 mp->violate_dscp = violate_action.dscp;
15706 mp->color_aware = color_aware;
15714 api_policer_dump (vat_main_t * vam)
15716 unformat_input_t *i = vam->input;
15717 vl_api_policer_dump_t *mp;
15718 vl_api_control_ping_t *mp_ping;
15719 u8 *match_name = 0;
15720 u8 match_name_valid = 0;
15723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15725 if (unformat (i, "name %s", &match_name))
15727 vec_add1 (match_name, 0);
15728 match_name_valid = 1;
15734 M (POLICER_DUMP, mp);
15735 mp->match_name_valid = match_name_valid;
15736 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15737 vec_free (match_name);
15741 /* Use a control ping for synchronization */
15742 M (CONTROL_PING, mp_ping);
15745 /* Wait for a reply... */
15751 api_policer_classify_set_interface (vat_main_t * vam)
15753 unformat_input_t *i = vam->input;
15754 vl_api_policer_classify_set_interface_t *mp;
15756 int sw_if_index_set;
15757 u32 ip4_table_index = ~0;
15758 u32 ip6_table_index = ~0;
15759 u32 l2_table_index = ~0;
15763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15765 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15766 sw_if_index_set = 1;
15767 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15768 sw_if_index_set = 1;
15769 else if (unformat (i, "del"))
15771 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15773 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15775 else if (unformat (i, "l2-table %d", &l2_table_index))
15779 clib_warning ("parse error '%U'", format_unformat_error, i);
15784 if (sw_if_index_set == 0)
15786 errmsg ("missing interface name or sw_if_index");
15790 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15792 mp->sw_if_index = ntohl (sw_if_index);
15793 mp->ip4_table_index = ntohl (ip4_table_index);
15794 mp->ip6_table_index = ntohl (ip6_table_index);
15795 mp->l2_table_index = ntohl (l2_table_index);
15796 mp->is_add = is_add;
15804 api_policer_classify_dump (vat_main_t * vam)
15806 unformat_input_t *i = vam->input;
15807 vl_api_policer_classify_dump_t *mp;
15808 vl_api_control_ping_t *mp_ping;
15809 u8 type = POLICER_CLASSIFY_N_TABLES;
15812 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15816 errmsg ("classify table type must be specified");
15820 if (!vam->json_output)
15822 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15825 M (POLICER_CLASSIFY_DUMP, mp);
15830 /* Use a control ping for synchronization */
15831 M (CONTROL_PING, mp_ping);
15834 /* Wait for a reply... */
15840 api_netmap_create (vat_main_t * vam)
15842 unformat_input_t *i = vam->input;
15843 vl_api_netmap_create_t *mp;
15846 u8 random_hw_addr = 1;
15851 memset (hw_addr, 0, sizeof (hw_addr));
15853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15855 if (unformat (i, "name %s", &if_name))
15856 vec_add1 (if_name, 0);
15857 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15858 random_hw_addr = 0;
15859 else if (unformat (i, "pipe"))
15861 else if (unformat (i, "master"))
15863 else if (unformat (i, "slave"))
15869 if (!vec_len (if_name))
15871 errmsg ("interface name must be specified");
15875 if (vec_len (if_name) > 64)
15877 errmsg ("interface name too long");
15881 M (NETMAP_CREATE, mp);
15883 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15884 clib_memcpy (mp->hw_addr, hw_addr, 6);
15885 mp->use_random_hw_addr = random_hw_addr;
15886 mp->is_pipe = is_pipe;
15887 mp->is_master = is_master;
15888 vec_free (if_name);
15896 api_netmap_delete (vat_main_t * vam)
15898 unformat_input_t *i = vam->input;
15899 vl_api_netmap_delete_t *mp;
15903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15905 if (unformat (i, "name %s", &if_name))
15906 vec_add1 (if_name, 0);
15911 if (!vec_len (if_name))
15913 errmsg ("interface name must be specified");
15917 if (vec_len (if_name) > 64)
15919 errmsg ("interface name too long");
15923 M (NETMAP_DELETE, mp);
15925 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15926 vec_free (if_name);
15933 static void vl_api_mpls_tunnel_details_t_handler
15934 (vl_api_mpls_tunnel_details_t * mp)
15936 vat_main_t *vam = &vat_main;
15937 i32 len = mp->mt_next_hop_n_labels;
15940 print (vam->ofp, "[%d]: via %U %d labels ",
15942 format_ip4_address, mp->mt_next_hop,
15943 ntohl (mp->mt_next_hop_sw_if_index));
15944 for (i = 0; i < len; i++)
15946 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15948 print (vam->ofp, "");
15951 static void vl_api_mpls_tunnel_details_t_handler_json
15952 (vl_api_mpls_tunnel_details_t * mp)
15954 vat_main_t *vam = &vat_main;
15955 vat_json_node_t *node = NULL;
15956 struct in_addr ip4;
15958 i32 len = mp->mt_next_hop_n_labels;
15960 if (VAT_JSON_ARRAY != vam->json_tree.type)
15962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15963 vat_json_init_array (&vam->json_tree);
15965 node = vat_json_array_add (&vam->json_tree);
15967 vat_json_init_object (node);
15968 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15969 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15970 vat_json_object_add_ip4 (node, "next_hop", ip4);
15971 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15972 ntohl (mp->mt_next_hop_sw_if_index));
15973 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15974 vat_json_object_add_uint (node, "label_count", len);
15975 for (i = 0; i < len; i++)
15977 vat_json_object_add_uint (node, "label",
15978 ntohl (mp->mt_next_hop_out_labels[i]));
15983 api_mpls_tunnel_dump (vat_main_t * vam)
15985 vl_api_mpls_tunnel_dump_t *mp;
15986 vl_api_control_ping_t *mp_ping;
15990 /* Parse args required to build the message */
15991 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15993 if (!unformat (vam->input, "tunnel_index %d", &index))
16000 print (vam->ofp, " tunnel_index %d", index);
16002 M (MPLS_TUNNEL_DUMP, mp);
16003 mp->tunnel_index = htonl (index);
16006 /* Use a control ping for synchronization */
16007 M (CONTROL_PING, mp_ping);
16014 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16015 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16018 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16020 vat_main_t *vam = &vat_main;
16021 int count = ntohl (mp->count);
16022 vl_api_fib_path2_t *fp;
16026 "table-id %d, label %u, ess_bit %u",
16027 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16029 for (i = 0; i < count; i++)
16031 if (fp->afi == IP46_TYPE_IP6)
16033 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16034 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16035 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16036 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16037 format_ip6_address, fp->next_hop);
16038 else if (fp->afi == IP46_TYPE_IP4)
16040 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16041 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16042 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16043 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16044 format_ip4_address, fp->next_hop);
16049 static void vl_api_mpls_fib_details_t_handler_json
16050 (vl_api_mpls_fib_details_t * mp)
16052 vat_main_t *vam = &vat_main;
16053 int count = ntohl (mp->count);
16054 vat_json_node_t *node = NULL;
16055 struct in_addr ip4;
16056 struct in6_addr ip6;
16057 vl_api_fib_path2_t *fp;
16060 if (VAT_JSON_ARRAY != vam->json_tree.type)
16062 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16063 vat_json_init_array (&vam->json_tree);
16065 node = vat_json_array_add (&vam->json_tree);
16067 vat_json_init_object (node);
16068 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16069 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16070 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16071 vat_json_object_add_uint (node, "path_count", count);
16073 for (i = 0; i < count; i++)
16075 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16076 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16077 vat_json_object_add_uint (node, "is_local", fp->is_local);
16078 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16079 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16080 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16081 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16082 if (fp->afi == IP46_TYPE_IP4)
16084 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16085 vat_json_object_add_ip4 (node, "next_hop", ip4);
16087 else if (fp->afi == IP46_TYPE_IP6)
16089 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16090 vat_json_object_add_ip6 (node, "next_hop", ip6);
16096 api_mpls_fib_dump (vat_main_t * vam)
16098 vl_api_mpls_fib_dump_t *mp;
16099 vl_api_control_ping_t *mp_ping;
16102 M (MPLS_FIB_DUMP, mp);
16105 /* Use a control ping for synchronization */
16106 M (CONTROL_PING, mp_ping);
16113 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16114 #define vl_api_ip_fib_details_t_print vl_noop_handler
16117 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16119 vat_main_t *vam = &vat_main;
16120 int count = ntohl (mp->count);
16121 vl_api_fib_path_t *fp;
16125 "table-id %d, prefix %U/%d",
16126 ntohl (mp->table_id), format_ip4_address, mp->address,
16127 mp->address_length);
16129 for (i = 0; i < count; i++)
16131 if (fp->afi == IP46_TYPE_IP6)
16133 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16134 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16135 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16136 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16137 format_ip6_address, fp->next_hop);
16138 else if (fp->afi == IP46_TYPE_IP4)
16140 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16141 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16142 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16143 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16144 format_ip4_address, fp->next_hop);
16149 static void vl_api_ip_fib_details_t_handler_json
16150 (vl_api_ip_fib_details_t * mp)
16152 vat_main_t *vam = &vat_main;
16153 int count = ntohl (mp->count);
16154 vat_json_node_t *node = NULL;
16155 struct in_addr ip4;
16156 struct in6_addr ip6;
16157 vl_api_fib_path_t *fp;
16160 if (VAT_JSON_ARRAY != vam->json_tree.type)
16162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16163 vat_json_init_array (&vam->json_tree);
16165 node = vat_json_array_add (&vam->json_tree);
16167 vat_json_init_object (node);
16168 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16169 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16170 vat_json_object_add_ip4 (node, "prefix", ip4);
16171 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16172 vat_json_object_add_uint (node, "path_count", count);
16174 for (i = 0; i < count; i++)
16176 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16177 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16178 vat_json_object_add_uint (node, "is_local", fp->is_local);
16179 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16180 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16181 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16182 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16183 if (fp->afi == IP46_TYPE_IP4)
16185 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16186 vat_json_object_add_ip4 (node, "next_hop", ip4);
16188 else if (fp->afi == IP46_TYPE_IP6)
16190 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16191 vat_json_object_add_ip6 (node, "next_hop", ip6);
16197 api_ip_fib_dump (vat_main_t * vam)
16199 vl_api_ip_fib_dump_t *mp;
16200 vl_api_control_ping_t *mp_ping;
16203 M (IP_FIB_DUMP, mp);
16206 /* Use a control ping for synchronization */
16207 M (CONTROL_PING, mp_ping);
16215 api_ip_mfib_dump (vat_main_t * vam)
16217 vl_api_ip_mfib_dump_t *mp;
16218 vl_api_control_ping_t *mp_ping;
16221 M (IP_MFIB_DUMP, mp);
16224 /* Use a control ping for synchronization */
16225 M (CONTROL_PING, mp_ping);
16232 static void vl_api_ip_neighbor_details_t_handler
16233 (vl_api_ip_neighbor_details_t * mp)
16235 vat_main_t *vam = &vat_main;
16237 print (vam->ofp, "%c %U %U",
16238 (mp->is_static) ? 'S' : 'D',
16239 format_ethernet_address, &mp->mac_address,
16240 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16244 static void vl_api_ip_neighbor_details_t_handler_json
16245 (vl_api_ip_neighbor_details_t * mp)
16248 vat_main_t *vam = &vat_main;
16249 vat_json_node_t *node;
16250 struct in_addr ip4;
16251 struct in6_addr ip6;
16253 if (VAT_JSON_ARRAY != vam->json_tree.type)
16255 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16256 vat_json_init_array (&vam->json_tree);
16258 node = vat_json_array_add (&vam->json_tree);
16260 vat_json_init_object (node);
16261 vat_json_object_add_string_copy (node, "flag",
16262 (mp->is_static) ? (u8 *) "static" : (u8 *)
16265 vat_json_object_add_string_copy (node, "link_layer",
16266 format (0, "%U", format_ethernet_address,
16267 &mp->mac_address));
16271 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16272 vat_json_object_add_ip6 (node, "ip_address", ip6);
16276 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16277 vat_json_object_add_ip4 (node, "ip_address", ip4);
16282 api_ip_neighbor_dump (vat_main_t * vam)
16284 unformat_input_t *i = vam->input;
16285 vl_api_ip_neighbor_dump_t *mp;
16286 vl_api_control_ping_t *mp_ping;
16288 u32 sw_if_index = ~0;
16291 /* Parse args required to build the message */
16292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16294 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16296 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16298 else if (unformat (i, "ip6"))
16304 if (sw_if_index == ~0)
16306 errmsg ("missing interface name or sw_if_index");
16310 M (IP_NEIGHBOR_DUMP, mp);
16311 mp->is_ipv6 = (u8) is_ipv6;
16312 mp->sw_if_index = ntohl (sw_if_index);
16315 /* Use a control ping for synchronization */
16316 M (CONTROL_PING, mp_ping);
16323 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16324 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16327 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16329 vat_main_t *vam = &vat_main;
16330 int count = ntohl (mp->count);
16331 vl_api_fib_path_t *fp;
16335 "table-id %d, prefix %U/%d",
16336 ntohl (mp->table_id), format_ip6_address, mp->address,
16337 mp->address_length);
16339 for (i = 0; i < count; i++)
16341 if (fp->afi == IP46_TYPE_IP6)
16343 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16344 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16345 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16346 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16347 format_ip6_address, fp->next_hop);
16348 else if (fp->afi == IP46_TYPE_IP4)
16350 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16351 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16352 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16353 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16354 format_ip4_address, fp->next_hop);
16359 static void vl_api_ip6_fib_details_t_handler_json
16360 (vl_api_ip6_fib_details_t * mp)
16362 vat_main_t *vam = &vat_main;
16363 int count = ntohl (mp->count);
16364 vat_json_node_t *node = NULL;
16365 struct in_addr ip4;
16366 struct in6_addr ip6;
16367 vl_api_fib_path_t *fp;
16370 if (VAT_JSON_ARRAY != vam->json_tree.type)
16372 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16373 vat_json_init_array (&vam->json_tree);
16375 node = vat_json_array_add (&vam->json_tree);
16377 vat_json_init_object (node);
16378 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16379 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16380 vat_json_object_add_ip6 (node, "prefix", ip6);
16381 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16382 vat_json_object_add_uint (node, "path_count", count);
16384 for (i = 0; i < count; i++)
16386 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16387 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16388 vat_json_object_add_uint (node, "is_local", fp->is_local);
16389 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16390 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16391 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16392 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16393 if (fp->afi == IP46_TYPE_IP4)
16395 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16396 vat_json_object_add_ip4 (node, "next_hop", ip4);
16398 else if (fp->afi == IP46_TYPE_IP6)
16400 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16401 vat_json_object_add_ip6 (node, "next_hop", ip6);
16407 api_ip6_fib_dump (vat_main_t * vam)
16409 vl_api_ip6_fib_dump_t *mp;
16410 vl_api_control_ping_t *mp_ping;
16413 M (IP6_FIB_DUMP, mp);
16416 /* Use a control ping for synchronization */
16417 M (CONTROL_PING, mp_ping);
16425 api_ip6_mfib_dump (vat_main_t * vam)
16427 vl_api_ip6_mfib_dump_t *mp;
16428 vl_api_control_ping_t *mp_ping;
16431 M (IP6_MFIB_DUMP, mp);
16434 /* Use a control ping for synchronization */
16435 M (CONTROL_PING, mp_ping);
16443 api_classify_table_ids (vat_main_t * vam)
16445 vl_api_classify_table_ids_t *mp;
16448 /* Construct the API message */
16449 M (CLASSIFY_TABLE_IDS, mp);
16458 api_classify_table_by_interface (vat_main_t * vam)
16460 unformat_input_t *input = vam->input;
16461 vl_api_classify_table_by_interface_t *mp;
16463 u32 sw_if_index = ~0;
16465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16467 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16469 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16474 if (sw_if_index == ~0)
16476 errmsg ("missing interface name or sw_if_index");
16480 /* Construct the API message */
16481 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16483 mp->sw_if_index = ntohl (sw_if_index);
16491 api_classify_table_info (vat_main_t * vam)
16493 unformat_input_t *input = vam->input;
16494 vl_api_classify_table_info_t *mp;
16498 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16500 if (unformat (input, "table_id %d", &table_id))
16505 if (table_id == ~0)
16507 errmsg ("missing table id");
16511 /* Construct the API message */
16512 M (CLASSIFY_TABLE_INFO, mp);
16514 mp->table_id = ntohl (table_id);
16522 api_classify_session_dump (vat_main_t * vam)
16524 unformat_input_t *input = vam->input;
16525 vl_api_classify_session_dump_t *mp;
16526 vl_api_control_ping_t *mp_ping;
16530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16532 if (unformat (input, "table_id %d", &table_id))
16537 if (table_id == ~0)
16539 errmsg ("missing table id");
16543 /* Construct the API message */
16544 M (CLASSIFY_SESSION_DUMP, mp);
16546 mp->table_id = ntohl (table_id);
16549 /* Use a control ping for synchronization */
16550 M (CONTROL_PING, mp_ping);
16558 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16560 vat_main_t *vam = &vat_main;
16562 print (vam->ofp, "collector_address %U, collector_port %d, "
16563 "src_address %U, vrf_id %d, path_mtu %u, "
16564 "template_interval %u, udp_checksum %d",
16565 format_ip4_address, mp->collector_address,
16566 ntohs (mp->collector_port),
16567 format_ip4_address, mp->src_address,
16568 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16569 ntohl (mp->template_interval), mp->udp_checksum);
16572 vam->result_ready = 1;
16576 vl_api_ipfix_exporter_details_t_handler_json
16577 (vl_api_ipfix_exporter_details_t * mp)
16579 vat_main_t *vam = &vat_main;
16580 vat_json_node_t node;
16581 struct in_addr collector_address;
16582 struct in_addr src_address;
16584 vat_json_init_object (&node);
16585 clib_memcpy (&collector_address, &mp->collector_address,
16586 sizeof (collector_address));
16587 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16588 vat_json_object_add_uint (&node, "collector_port",
16589 ntohs (mp->collector_port));
16590 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16591 vat_json_object_add_ip4 (&node, "src_address", src_address);
16592 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16593 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16594 vat_json_object_add_uint (&node, "template_interval",
16595 ntohl (mp->template_interval));
16596 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16598 vat_json_print (vam->ofp, &node);
16599 vat_json_free (&node);
16601 vam->result_ready = 1;
16605 api_ipfix_exporter_dump (vat_main_t * vam)
16607 vl_api_ipfix_exporter_dump_t *mp;
16610 /* Construct the API message */
16611 M (IPFIX_EXPORTER_DUMP, mp);
16620 api_ipfix_classify_stream_dump (vat_main_t * vam)
16622 vl_api_ipfix_classify_stream_dump_t *mp;
16625 /* Construct the API message */
16626 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16637 vl_api_ipfix_classify_stream_details_t_handler
16638 (vl_api_ipfix_classify_stream_details_t * mp)
16640 vat_main_t *vam = &vat_main;
16641 print (vam->ofp, "domain_id %d, src_port %d",
16642 ntohl (mp->domain_id), ntohs (mp->src_port));
16644 vam->result_ready = 1;
16648 vl_api_ipfix_classify_stream_details_t_handler_json
16649 (vl_api_ipfix_classify_stream_details_t * mp)
16651 vat_main_t *vam = &vat_main;
16652 vat_json_node_t node;
16654 vat_json_init_object (&node);
16655 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16656 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16658 vat_json_print (vam->ofp, &node);
16659 vat_json_free (&node);
16661 vam->result_ready = 1;
16665 api_ipfix_classify_table_dump (vat_main_t * vam)
16667 vl_api_ipfix_classify_table_dump_t *mp;
16668 vl_api_control_ping_t *mp_ping;
16671 if (!vam->json_output)
16673 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16674 "transport_protocol");
16677 /* Construct the API message */
16678 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16683 /* Use a control ping for synchronization */
16684 M (CONTROL_PING, mp_ping);
16692 vl_api_ipfix_classify_table_details_t_handler
16693 (vl_api_ipfix_classify_table_details_t * mp)
16695 vat_main_t *vam = &vat_main;
16696 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16697 mp->transport_protocol);
16701 vl_api_ipfix_classify_table_details_t_handler_json
16702 (vl_api_ipfix_classify_table_details_t * mp)
16704 vat_json_node_t *node = NULL;
16705 vat_main_t *vam = &vat_main;
16707 if (VAT_JSON_ARRAY != vam->json_tree.type)
16709 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16710 vat_json_init_array (&vam->json_tree);
16713 node = vat_json_array_add (&vam->json_tree);
16714 vat_json_init_object (node);
16716 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16717 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16718 vat_json_object_add_uint (node, "transport_protocol",
16719 mp->transport_protocol);
16723 api_sw_interface_span_enable_disable (vat_main_t * vam)
16725 unformat_input_t *i = vam->input;
16726 vl_api_sw_interface_span_enable_disable_t *mp;
16727 u32 src_sw_if_index = ~0;
16728 u32 dst_sw_if_index = ~0;
16732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16735 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16737 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16741 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16743 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16745 else if (unformat (i, "disable"))
16747 else if (unformat (i, "rx"))
16749 else if (unformat (i, "tx"))
16751 else if (unformat (i, "both"))
16757 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16759 mp->sw_if_index_from = htonl (src_sw_if_index);
16760 mp->sw_if_index_to = htonl (dst_sw_if_index);
16769 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16772 vat_main_t *vam = &vat_main;
16773 u8 *sw_if_from_name = 0;
16774 u8 *sw_if_to_name = 0;
16775 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16776 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16777 char *states[] = { "none", "rx", "tx", "both" };
16781 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16783 if ((u32) p->value[0] == sw_if_index_from)
16785 sw_if_from_name = (u8 *)(p->key);
16789 if ((u32) p->value[0] == sw_if_index_to)
16791 sw_if_to_name = (u8 *)(p->key);
16792 if (sw_if_from_name)
16797 print (vam->ofp, "%20s => %20s (%s)",
16798 sw_if_from_name, sw_if_to_name, states[mp->state]);
16802 vl_api_sw_interface_span_details_t_handler_json
16803 (vl_api_sw_interface_span_details_t * mp)
16805 vat_main_t *vam = &vat_main;
16806 vat_json_node_t *node = NULL;
16807 u8 *sw_if_from_name = 0;
16808 u8 *sw_if_to_name = 0;
16809 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16810 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16814 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16816 if ((u32) p->value[0] == sw_if_index_from)
16818 sw_if_from_name = (u8 *)(p->key);
16822 if ((u32) p->value[0] == sw_if_index_to)
16824 sw_if_to_name = (u8 *)(p->key);
16825 if (sw_if_from_name)
16831 if (VAT_JSON_ARRAY != vam->json_tree.type)
16833 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16834 vat_json_init_array (&vam->json_tree);
16836 node = vat_json_array_add (&vam->json_tree);
16838 vat_json_init_object (node);
16839 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16840 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16841 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16842 if (0 != sw_if_to_name)
16844 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16846 vat_json_object_add_uint (node, "state", mp->state);
16850 api_sw_interface_span_dump (vat_main_t * vam)
16852 vl_api_sw_interface_span_dump_t *mp;
16853 vl_api_control_ping_t *mp_ping;
16856 M (SW_INTERFACE_SPAN_DUMP, mp);
16859 /* Use a control ping for synchronization */
16860 M (CONTROL_PING, mp_ping);
16868 api_pg_create_interface (vat_main_t * vam)
16870 unformat_input_t *input = vam->input;
16871 vl_api_pg_create_interface_t *mp;
16875 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16877 if (unformat (input, "if_id %d", &if_id))
16884 errmsg ("missing pg interface index");
16888 /* Construct the API message */
16889 M (PG_CREATE_INTERFACE, mp);
16891 mp->interface_id = ntohl (if_id);
16899 api_pg_capture (vat_main_t * vam)
16901 unformat_input_t *input = vam->input;
16902 vl_api_pg_capture_t *mp;
16907 u8 pcap_file_set = 0;
16910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16912 if (unformat (input, "if_id %d", &if_id))
16914 else if (unformat (input, "pcap %s", &pcap_file))
16916 else if (unformat (input, "count %d", &count))
16918 else if (unformat (input, "disable"))
16925 errmsg ("missing pg interface index");
16928 if (pcap_file_set > 0)
16930 if (vec_len (pcap_file) > 255)
16932 errmsg ("pcap file name is too long");
16937 u32 name_len = vec_len (pcap_file);
16938 /* Construct the API message */
16939 M (PG_CAPTURE, mp);
16941 mp->interface_id = ntohl (if_id);
16942 mp->is_enabled = enable;
16943 mp->count = ntohl (count);
16944 mp->pcap_name_length = ntohl (name_len);
16945 if (pcap_file_set != 0)
16947 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16949 vec_free (pcap_file);
16957 api_pg_enable_disable (vat_main_t * vam)
16959 unformat_input_t *input = vam->input;
16960 vl_api_pg_enable_disable_t *mp;
16963 u8 stream_name_set = 0;
16964 u8 *stream_name = 0;
16966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16968 if (unformat (input, "stream %s", &stream_name))
16969 stream_name_set = 1;
16970 else if (unformat (input, "disable"))
16976 if (stream_name_set > 0)
16978 if (vec_len (stream_name) > 255)
16980 errmsg ("stream name too long");
16985 u32 name_len = vec_len (stream_name);
16986 /* Construct the API message */
16987 M (PG_ENABLE_DISABLE, mp);
16989 mp->is_enabled = enable;
16990 if (stream_name_set != 0)
16992 mp->stream_name_length = ntohl (name_len);
16993 clib_memcpy (mp->stream_name, stream_name, name_len);
16995 vec_free (stream_name);
17003 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17005 unformat_input_t *input = vam->input;
17006 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17008 u16 *low_ports = 0;
17009 u16 *high_ports = 0;
17012 ip4_address_t ip4_addr;
17013 ip6_address_t ip6_addr;
17022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17024 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17030 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17035 else if (unformat (input, "vrf %d", &vrf_id))
17037 else if (unformat (input, "del"))
17039 else if (unformat (input, "port %d", &tmp))
17041 if (tmp == 0 || tmp > 65535)
17043 errmsg ("port %d out of range", tmp);
17047 this_hi = this_low + 1;
17048 vec_add1 (low_ports, this_low);
17049 vec_add1 (high_ports, this_hi);
17051 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17053 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17055 errmsg ("incorrect range parameters");
17059 /* Note: in debug CLI +1 is added to high before
17060 passing to real fn that does "the work"
17061 (ip_source_and_port_range_check_add_del).
17062 This fn is a wrapper around the binary API fn a
17063 control plane will call, which expects this increment
17064 to have occurred. Hence letting the binary API control
17065 plane fn do the increment for consistency between VAT
17066 and other control planes.
17069 vec_add1 (low_ports, this_low);
17070 vec_add1 (high_ports, this_hi);
17076 if (prefix_set == 0)
17078 errmsg ("<address>/<mask> not specified");
17084 errmsg ("VRF ID required, not specified");
17091 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17095 if (vec_len (low_ports) == 0)
17097 errmsg ("At least one port or port range required");
17101 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17103 mp->is_add = is_add;
17108 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17113 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17116 mp->mask_length = length;
17117 mp->number_of_ranges = vec_len (low_ports);
17119 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17120 vec_free (low_ports);
17122 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17123 vec_free (high_ports);
17125 mp->vrf_id = ntohl (vrf_id);
17133 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17135 unformat_input_t *input = vam->input;
17136 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17137 u32 sw_if_index = ~0;
17139 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17140 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17146 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17148 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17150 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17152 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17154 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17156 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17158 else if (unformat (input, "del"))
17164 if (sw_if_index == ~0)
17166 errmsg ("Interface required but not specified");
17172 errmsg ("VRF ID required but not specified");
17176 if (tcp_out_vrf_id == 0
17177 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17180 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17184 /* Construct the API message */
17185 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17187 mp->sw_if_index = ntohl (sw_if_index);
17188 mp->is_add = is_add;
17189 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17190 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17191 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17192 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17197 /* Wait for a reply... */
17203 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17205 unformat_input_t *i = vam->input;
17206 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17207 u32 local_sa_id = 0;
17208 u32 remote_sa_id = 0;
17209 ip4_address_t src_address;
17210 ip4_address_t dst_address;
17214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17216 if (unformat (i, "local_sa %d", &local_sa_id))
17218 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17220 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17222 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17224 else if (unformat (i, "del"))
17228 clib_warning ("parse error '%U'", format_unformat_error, i);
17233 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17235 mp->local_sa_id = ntohl (local_sa_id);
17236 mp->remote_sa_id = ntohl (remote_sa_id);
17237 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17238 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17239 mp->is_add = is_add;
17247 api_punt (vat_main_t * vam)
17249 unformat_input_t *i = vam->input;
17257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17259 if (unformat (i, "ip %d", &ipv))
17261 else if (unformat (i, "protocol %d", &protocol))
17263 else if (unformat (i, "port %d", &port))
17265 else if (unformat (i, "del"))
17269 clib_warning ("parse error '%U'", format_unformat_error, i);
17276 mp->is_add = (u8) is_add;
17277 mp->ipv = (u8) ipv;
17278 mp->l4_protocol = (u8) protocol;
17279 mp->l4_port = htons ((u16) port);
17286 static void vl_api_ipsec_gre_tunnel_details_t_handler
17287 (vl_api_ipsec_gre_tunnel_details_t * mp)
17289 vat_main_t *vam = &vat_main;
17291 print (vam->ofp, "%11d%15U%15U%14d%14d",
17292 ntohl (mp->sw_if_index),
17293 format_ip4_address, &mp->src_address,
17294 format_ip4_address, &mp->dst_address,
17295 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17298 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17299 (vl_api_ipsec_gre_tunnel_details_t * mp)
17301 vat_main_t *vam = &vat_main;
17302 vat_json_node_t *node = NULL;
17303 struct in_addr ip4;
17305 if (VAT_JSON_ARRAY != vam->json_tree.type)
17307 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17308 vat_json_init_array (&vam->json_tree);
17310 node = vat_json_array_add (&vam->json_tree);
17312 vat_json_init_object (node);
17313 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17314 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17315 vat_json_object_add_ip4 (node, "src_address", ip4);
17316 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17317 vat_json_object_add_ip4 (node, "dst_address", ip4);
17318 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17319 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17323 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17325 unformat_input_t *i = vam->input;
17326 vl_api_ipsec_gre_tunnel_dump_t *mp;
17327 vl_api_control_ping_t *mp_ping;
17329 u8 sw_if_index_set = 0;
17332 /* Parse args required to build the message */
17333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17335 if (unformat (i, "sw_if_index %d", &sw_if_index))
17336 sw_if_index_set = 1;
17341 if (sw_if_index_set == 0)
17346 if (!vam->json_output)
17348 print (vam->ofp, "%11s%15s%15s%14s%14s",
17349 "sw_if_index", "src_address", "dst_address",
17350 "local_sa_id", "remote_sa_id");
17353 /* Get list of gre-tunnel interfaces */
17354 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17356 mp->sw_if_index = htonl (sw_if_index);
17360 /* Use a control ping for synchronization */
17361 M (CONTROL_PING, mp_ping);
17369 api_delete_subif (vat_main_t * vam)
17371 unformat_input_t *i = vam->input;
17372 vl_api_delete_subif_t *mp;
17373 u32 sw_if_index = ~0;
17376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17378 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17380 if (unformat (i, "sw_if_index %d", &sw_if_index))
17386 if (sw_if_index == ~0)
17388 errmsg ("missing sw_if_index");
17392 /* Construct the API message */
17393 M (DELETE_SUBIF, mp);
17394 mp->sw_if_index = ntohl (sw_if_index);
17401 #define foreach_pbb_vtr_op \
17402 _("disable", L2_VTR_DISABLED) \
17403 _("pop", L2_VTR_POP_2) \
17404 _("push", L2_VTR_PUSH_2)
17407 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17409 unformat_input_t *i = vam->input;
17410 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17411 u32 sw_if_index = ~0, vtr_op = ~0;
17412 u16 outer_tag = ~0;
17413 u8 dmac[6], smac[6];
17414 u8 dmac_set = 0, smac_set = 0;
17420 /* Shut up coverity */
17421 memset (dmac, 0, sizeof (dmac));
17422 memset (smac, 0, sizeof (smac));
17424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17428 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17430 else if (unformat (i, "vtr_op %d", &vtr_op))
17432 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17435 else if (unformat (i, "translate_pbb_stag"))
17437 if (unformat (i, "%d", &tmp))
17439 vtr_op = L2_VTR_TRANSLATE_2_1;
17445 ("translate_pbb_stag operation requires outer tag definition");
17449 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17451 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17453 else if (unformat (i, "sid %d", &sid))
17455 else if (unformat (i, "vlanid %d", &tmp))
17459 clib_warning ("parse error '%U'", format_unformat_error, i);
17464 if ((sw_if_index == ~0) || (vtr_op == ~0))
17466 errmsg ("missing sw_if_index or vtr operation");
17469 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17470 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17473 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17477 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17478 mp->sw_if_index = ntohl (sw_if_index);
17479 mp->vtr_op = ntohl (vtr_op);
17480 mp->outer_tag = ntohs (outer_tag);
17481 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17482 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17483 mp->b_vlanid = ntohs (vlanid);
17484 mp->i_sid = ntohl (sid);
17492 api_flow_classify_set_interface (vat_main_t * vam)
17494 unformat_input_t *i = vam->input;
17495 vl_api_flow_classify_set_interface_t *mp;
17497 int sw_if_index_set;
17498 u32 ip4_table_index = ~0;
17499 u32 ip6_table_index = ~0;
17503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17505 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17506 sw_if_index_set = 1;
17507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17508 sw_if_index_set = 1;
17509 else if (unformat (i, "del"))
17511 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17513 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17517 clib_warning ("parse error '%U'", format_unformat_error, i);
17522 if (sw_if_index_set == 0)
17524 errmsg ("missing interface name or sw_if_index");
17528 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17530 mp->sw_if_index = ntohl (sw_if_index);
17531 mp->ip4_table_index = ntohl (ip4_table_index);
17532 mp->ip6_table_index = ntohl (ip6_table_index);
17533 mp->is_add = is_add;
17541 api_flow_classify_dump (vat_main_t * vam)
17543 unformat_input_t *i = vam->input;
17544 vl_api_flow_classify_dump_t *mp;
17545 vl_api_control_ping_t *mp_ping;
17546 u8 type = FLOW_CLASSIFY_N_TABLES;
17549 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17553 errmsg ("classify table type must be specified");
17557 if (!vam->json_output)
17559 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17562 M (FLOW_CLASSIFY_DUMP, mp);
17567 /* Use a control ping for synchronization */
17568 M (CONTROL_PING, mp_ping);
17571 /* Wait for a reply... */
17577 api_feature_enable_disable (vat_main_t * vam)
17579 unformat_input_t *i = vam->input;
17580 vl_api_feature_enable_disable_t *mp;
17582 u8 *feature_name = 0;
17583 u32 sw_if_index = ~0;
17587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17589 if (unformat (i, "arc_name %s", &arc_name))
17591 else if (unformat (i, "feature_name %s", &feature_name))
17594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17598 else if (unformat (i, "disable"))
17606 errmsg ("missing arc name");
17609 if (vec_len (arc_name) > 63)
17611 errmsg ("arc name too long");
17614 if (feature_name == 0)
17616 errmsg ("missing feature name");
17619 if (vec_len (feature_name) > 63)
17621 errmsg ("feature name too long");
17624 if (sw_if_index == ~0)
17626 errmsg ("missing interface name or sw_if_index");
17630 /* Construct the API message */
17631 M (FEATURE_ENABLE_DISABLE, mp);
17632 mp->sw_if_index = ntohl (sw_if_index);
17633 mp->enable = enable;
17634 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17635 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17636 vec_free (arc_name);
17637 vec_free (feature_name);
17645 api_sw_interface_tag_add_del (vat_main_t * vam)
17647 unformat_input_t *i = vam->input;
17648 vl_api_sw_interface_tag_add_del_t *mp;
17649 u32 sw_if_index = ~0;
17654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17656 if (unformat (i, "tag %s", &tag))
17658 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17660 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17662 else if (unformat (i, "del"))
17668 if (sw_if_index == ~0)
17670 errmsg ("missing interface name or sw_if_index");
17674 if (enable && (tag == 0))
17676 errmsg ("no tag specified");
17680 /* Construct the API message */
17681 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17682 mp->sw_if_index = ntohl (sw_if_index);
17683 mp->is_add = enable;
17685 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17693 static void vl_api_l2_xconnect_details_t_handler
17694 (vl_api_l2_xconnect_details_t * mp)
17696 vat_main_t *vam = &vat_main;
17698 print (vam->ofp, "%15d%15d",
17699 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17702 static void vl_api_l2_xconnect_details_t_handler_json
17703 (vl_api_l2_xconnect_details_t * mp)
17705 vat_main_t *vam = &vat_main;
17706 vat_json_node_t *node = NULL;
17708 if (VAT_JSON_ARRAY != vam->json_tree.type)
17710 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17711 vat_json_init_array (&vam->json_tree);
17713 node = vat_json_array_add (&vam->json_tree);
17715 vat_json_init_object (node);
17716 vat_json_object_add_uint (node, "rx_sw_if_index",
17717 ntohl (mp->rx_sw_if_index));
17718 vat_json_object_add_uint (node, "tx_sw_if_index",
17719 ntohl (mp->tx_sw_if_index));
17723 api_l2_xconnect_dump (vat_main_t * vam)
17725 vl_api_l2_xconnect_dump_t *mp;
17726 vl_api_control_ping_t *mp_ping;
17729 if (!vam->json_output)
17731 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17734 M (L2_XCONNECT_DUMP, mp);
17738 /* Use a control ping for synchronization */
17739 M (CONTROL_PING, mp_ping);
17747 api_sw_interface_set_mtu (vat_main_t * vam)
17749 unformat_input_t *i = vam->input;
17750 vl_api_sw_interface_set_mtu_t *mp;
17751 u32 sw_if_index = ~0;
17755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17757 if (unformat (i, "mtu %d", &mtu))
17759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17767 if (sw_if_index == ~0)
17769 errmsg ("missing interface name or sw_if_index");
17775 errmsg ("no mtu specified");
17779 /* Construct the API message */
17780 M (SW_INTERFACE_SET_MTU, mp);
17781 mp->sw_if_index = ntohl (sw_if_index);
17782 mp->mtu = ntohs ((u16) mtu);
17791 q_or_quit (vat_main_t * vam)
17793 #if VPP_API_TEST_BUILTIN == 0
17794 longjmp (vam->jump_buf, 1);
17796 return 0; /* not so much */
17800 q (vat_main_t * vam)
17802 return q_or_quit (vam);
17806 quit (vat_main_t * vam)
17808 return q_or_quit (vam);
17812 comment (vat_main_t * vam)
17818 cmd_cmp (void *a1, void *a2)
17823 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17827 help (vat_main_t * vam)
17832 unformat_input_t *i = vam->input;
17835 if (unformat (i, "%s", &name))
17839 vec_add1 (name, 0);
17841 hs = hash_get_mem (vam->help_by_name, name);
17843 print (vam->ofp, "usage: %s %s", name, hs[0]);
17845 print (vam->ofp, "No such msg / command '%s'", name);
17850 print (vam->ofp, "Help is available for the following:");
17853 hash_foreach_pair (p, vam->function_by_name,
17855 vec_add1 (cmds, (u8 *)(p->key));
17859 vec_sort_with_function (cmds, cmd_cmp);
17861 for (j = 0; j < vec_len (cmds); j++)
17862 print (vam->ofp, "%s", cmds[j]);
17869 set (vat_main_t * vam)
17871 u8 *name = 0, *value = 0;
17872 unformat_input_t *i = vam->input;
17874 if (unformat (i, "%s", &name))
17876 /* The input buffer is a vector, not a string. */
17877 value = vec_dup (i->buffer);
17878 vec_delete (value, i->index, 0);
17879 /* Almost certainly has a trailing newline */
17880 if (value[vec_len (value) - 1] == '\n')
17881 value[vec_len (value) - 1] = 0;
17882 /* Make sure it's a proper string, one way or the other */
17883 vec_add1 (value, 0);
17884 (void) clib_macro_set_value (&vam->macro_main,
17885 (char *) name, (char *) value);
17888 errmsg ("usage: set <name> <value>");
17896 unset (vat_main_t * vam)
17900 if (unformat (vam->input, "%s", &name))
17901 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17902 errmsg ("unset: %s wasn't set", name);
17915 macro_sort_cmp (void *a1, void *a2)
17917 macro_sort_t *s1 = a1;
17918 macro_sort_t *s2 = a2;
17920 return strcmp ((char *) (s1->name), (char *) (s2->name));
17924 dump_macro_table (vat_main_t * vam)
17926 macro_sort_t *sort_me = 0, *sm;
17931 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17933 vec_add2 (sort_me, sm, 1);
17934 sm->name = (u8 *)(p->key);
17935 sm->value = (u8 *) (p->value[0]);
17939 vec_sort_with_function (sort_me, macro_sort_cmp);
17941 if (vec_len (sort_me))
17942 print (vam->ofp, "%-15s%s", "Name", "Value");
17944 print (vam->ofp, "The macro table is empty...");
17946 for (i = 0; i < vec_len (sort_me); i++)
17947 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17952 dump_node_table (vat_main_t * vam)
17955 vlib_node_t *node, *next_node;
17957 if (vec_len (vam->graph_nodes) == 0)
17959 print (vam->ofp, "Node table empty, issue get_node_graph...");
17963 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17965 node = vam->graph_nodes[i];
17966 print (vam->ofp, "[%d] %s", i, node->name);
17967 for (j = 0; j < vec_len (node->next_nodes); j++)
17969 if (node->next_nodes[j] != ~0)
17971 next_node = vam->graph_nodes[node->next_nodes[j]];
17972 print (vam->ofp, " [%d] %s", j, next_node->name);
17980 value_sort_cmp (void *a1, void *a2)
17982 name_sort_t *n1 = a1;
17983 name_sort_t *n2 = a2;
17985 if (n1->value < n2->value)
17987 if (n1->value > n2->value)
17994 dump_msg_api_table (vat_main_t * vam)
17996 api_main_t *am = &api_main;
17997 name_sort_t *nses = 0, *ns;
18002 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18004 vec_add2 (nses, ns, 1);
18005 ns->name = (u8 *)(hp->key);
18006 ns->value = (u32) hp->value[0];
18010 vec_sort_with_function (nses, value_sort_cmp);
18012 for (i = 0; i < vec_len (nses); i++)
18013 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18019 get_msg_id (vat_main_t * vam)
18024 if (unformat (vam->input, "%s", &name_and_crc))
18026 message_index = vl_api_get_msg_index (name_and_crc);
18027 if (message_index == ~0)
18029 print (vam->ofp, " '%s' not found", name_and_crc);
18032 print (vam->ofp, " '%s' has message index %d",
18033 name_and_crc, message_index);
18036 errmsg ("name_and_crc required...");
18041 search_node_table (vat_main_t * vam)
18043 unformat_input_t *line_input = vam->input;
18046 vlib_node_t *node, *next_node;
18049 if (vam->graph_node_index_by_name == 0)
18051 print (vam->ofp, "Node table empty, issue get_node_graph...");
18055 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18057 if (unformat (line_input, "%s", &node_to_find))
18059 vec_add1 (node_to_find, 0);
18060 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18063 print (vam->ofp, "%s not found...", node_to_find);
18066 node = vam->graph_nodes[p[0]];
18067 print (vam->ofp, "[%d] %s", p[0], node->name);
18068 for (j = 0; j < vec_len (node->next_nodes); j++)
18070 if (node->next_nodes[j] != ~0)
18072 next_node = vam->graph_nodes[node->next_nodes[j]];
18073 print (vam->ofp, " [%d] %s", j, next_node->name);
18080 clib_warning ("parse error '%U'", format_unformat_error,
18086 vec_free (node_to_find);
18095 script (vat_main_t * vam)
18097 #if (VPP_API_TEST_BUILTIN==0)
18099 char *save_current_file;
18100 unformat_input_t save_input;
18101 jmp_buf save_jump_buf;
18102 u32 save_line_number;
18104 FILE *new_fp, *save_ifp;
18106 if (unformat (vam->input, "%s", &s))
18108 new_fp = fopen ((char *) s, "r");
18111 errmsg ("Couldn't open script file %s", s);
18118 errmsg ("Missing script name");
18122 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18123 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18124 save_ifp = vam->ifp;
18125 save_line_number = vam->input_line_number;
18126 save_current_file = (char *) vam->current_file;
18128 vam->input_line_number = 0;
18130 vam->current_file = s;
18133 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18134 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18135 vam->ifp = save_ifp;
18136 vam->input_line_number = save_line_number;
18137 vam->current_file = (u8 *) save_current_file;
18142 clib_warning ("use the exec command...");
18148 echo (vat_main_t * vam)
18150 print (vam->ofp, "%v", vam->input->buffer);
18154 /* List of API message constructors, CLI names map to api_xxx */
18155 #define foreach_vpe_api_msg \
18156 _(create_loopback,"[mac <mac-addr>]") \
18157 _(sw_interface_dump,"") \
18158 _(sw_interface_set_flags, \
18159 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18160 _(sw_interface_add_del_address, \
18161 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18162 _(sw_interface_set_table, \
18163 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18164 _(sw_interface_set_mpls_enable, \
18165 "<intfc> | sw_if_index [disable | dis]") \
18166 _(sw_interface_set_vpath, \
18167 "<intfc> | sw_if_index <id> enable | disable") \
18168 _(sw_interface_set_vxlan_bypass, \
18169 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18170 _(sw_interface_set_l2_xconnect, \
18171 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18172 "enable | disable") \
18173 _(sw_interface_set_l2_bridge, \
18174 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18175 "[shg <split-horizon-group>] [bvi]\n" \
18176 "enable | disable") \
18177 _(bridge_domain_add_del, \
18178 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18179 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18181 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18183 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18185 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18187 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18189 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18191 "<vpp-if-name> | sw_if_index <id>") \
18192 _(sw_interface_tap_dump, "") \
18193 _(ip_add_del_route, \
18194 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18195 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18196 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18197 "[multipath] [count <n>]") \
18198 _(ip_mroute_add_del, \
18199 "<src> <grp>/<mask> [table-id <n>]\n" \
18200 "[<intfc> | sw_if_index <id>] [local] [del]") \
18201 _(mpls_route_add_del, \
18202 "<label> <eos> via <addr> [table-id <n>]\n" \
18203 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18204 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18205 "[multipath] [count <n>]") \
18206 _(mpls_ip_bind_unbind, \
18207 "<label> <addr/len>") \
18208 _(mpls_tunnel_add_del, \
18209 " via <addr> [table-id <n>]\n" \
18210 "sw_if_index <id>] [l2] [del]") \
18211 _(proxy_arp_add_del, \
18212 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18213 _(proxy_arp_intfc_enable_disable, \
18214 "<intfc> | sw_if_index <id> enable | disable") \
18215 _(sw_interface_set_unnumbered, \
18216 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18217 _(ip_neighbor_add_del, \
18218 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18219 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18220 _(reset_vrf, "vrf <id> [ipv6]") \
18221 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18222 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18223 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18224 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18225 "[outer_vlan_id_any][inner_vlan_id_any]") \
18226 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18227 _(reset_fib, "vrf <n> [ipv6]") \
18228 _(dhcp_proxy_config, \
18229 "svr <v46-address> src <v46-address>\n" \
18230 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18231 _(dhcp_proxy_set_vss, \
18232 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18233 _(dhcp_proxy_dump, "ip6") \
18234 _(dhcp_client_config, \
18235 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18236 _(set_ip_flow_hash, \
18237 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18238 _(sw_interface_ip6_enable_disable, \
18239 "<intfc> | sw_if_index <id> enable | disable") \
18240 _(sw_interface_ip6_set_link_local_address, \
18241 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18242 _(sw_interface_ip6nd_ra_prefix, \
18243 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18244 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18245 "[nolink] [isno]") \
18246 _(sw_interface_ip6nd_ra_config, \
18247 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18248 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18249 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18250 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18251 _(l2_patch_add_del, \
18252 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18253 "enable | disable") \
18254 _(sr_tunnel_add_del, \
18255 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
18256 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
18257 "[policy <policy_name>]") \
18258 _(sr_policy_add_del, \
18259 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
18260 _(sr_multicast_map_add_del, \
18261 "address [ip6 multicast address] sr-policy [policy name] [del]") \
18262 _(classify_add_del_table, \
18263 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18264 " [del] [del-chain] mask <mask-value>\n" \
18265 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18266 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18267 _(classify_add_del_session, \
18268 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18269 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18270 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18271 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18272 _(classify_set_interface_ip_table, \
18273 "<intfc> | sw_if_index <nn> table <nn>") \
18274 _(classify_set_interface_l2_tables, \
18275 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18276 " [other-table <nn>]") \
18277 _(get_node_index, "node <node-name") \
18278 _(add_node_next, "node <node-name> next <next-node-name>") \
18279 _(l2tpv3_create_tunnel, \
18280 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18281 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18282 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18283 _(l2tpv3_set_tunnel_cookies, \
18284 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18285 "[new_remote_cookie <nn>]\n") \
18286 _(l2tpv3_interface_enable_disable, \
18287 "<intfc> | sw_if_index <nn> enable | disable") \
18288 _(l2tpv3_set_lookup_key, \
18289 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18290 _(sw_if_l2tpv3_tunnel_dump, "") \
18291 _(vxlan_add_del_tunnel, \
18292 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18293 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18294 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18295 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18296 _(gre_add_del_tunnel, \
18297 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18298 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18299 _(l2_fib_clear_table, "") \
18300 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18301 _(l2_interface_vlan_tag_rewrite, \
18302 "<intfc> | sw_if_index <nn> \n" \
18303 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18304 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18305 _(create_vhost_user_if, \
18306 "socket <filename> [server] [renumber <dev_instance>] " \
18307 "[mac <mac_address>]") \
18308 _(modify_vhost_user_if, \
18309 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18310 "[server] [renumber <dev_instance>]") \
18311 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18312 _(sw_interface_vhost_user_dump, "") \
18313 _(show_version, "") \
18314 _(vxlan_gpe_add_del_tunnel, \
18315 "local <addr> remote <addr> vni <nn>\n" \
18316 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18317 "[next-ethernet] [next-nsh]\n") \
18318 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18319 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18320 _(interface_name_renumber, \
18321 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18322 _(input_acl_set_interface, \
18323 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18324 " [l2-table <nn>] [del]") \
18325 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18326 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18327 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18328 _(ip_dump, "ipv4 | ipv6") \
18329 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18330 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18332 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18333 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18334 " integ_alg <alg> integ_key <hex>") \
18335 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18336 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18337 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18338 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18339 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18340 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18341 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18342 "(auth_data 0x<data> | auth_data <data>)") \
18343 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18344 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18345 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18346 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18347 "(local|remote)") \
18348 _(ikev2_set_local_key, "file <absolute_file_path>") \
18349 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18350 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18351 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18352 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18353 _(ikev2_initiate_sa_init, "<profile_name>") \
18354 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18355 _(ikev2_initiate_del_child_sa, "<ispi>") \
18356 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18357 _(delete_loopback,"sw_if_index <nn>") \
18358 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18359 _(map_add_domain, \
18360 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18361 "ip6-src <ip6addr> " \
18362 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18363 _(map_del_domain, "index <n>") \
18364 _(map_add_del_rule, \
18365 "index <n> psid <n> dst <ip6addr> [del]") \
18366 _(map_domain_dump, "") \
18367 _(map_rule_dump, "index <map-domain>") \
18368 _(want_interface_events, "enable|disable") \
18369 _(want_stats,"enable|disable") \
18370 _(get_first_msg_id, "client <name>") \
18371 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18372 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18373 "fib-id <nn> [ip4][ip6][default]") \
18374 _(get_node_graph, " ") \
18375 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18376 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18377 _(ioam_disable, "") \
18378 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18379 " sw_if_index <sw_if_index> p <priority> " \
18380 "w <weight>] [del]") \
18381 _(one_add_del_locator, "locator-set <locator_name> " \
18382 "iface <intf> | sw_if_index <sw_if_index> " \
18383 "p <priority> w <weight> [del]") \
18384 _(one_add_del_local_eid,"vni <vni> eid " \
18385 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18386 "locator-set <locator_name> [del]" \
18387 "[key-id sha1|sha256 secret-key <secret-key>]")\
18388 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18389 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18390 _(one_enable_disable, "enable|disable") \
18391 _(one_map_register_enable_disable, "enable|disable") \
18392 _(one_rloc_probe_enable_disable, "enable|disable") \
18393 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18395 "rloc <locator> p <prio> " \
18396 "w <weight> [rloc <loc> ... ] " \
18397 "action <action> [del-all]") \
18398 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18400 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18401 _(one_map_request_mode, "src-dst|dst-only") \
18402 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18403 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18404 _(one_locator_set_dump, "[local | remote]") \
18405 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18406 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18407 "[local] | [remote]") \
18408 _(one_eid_table_vni_dump, "") \
18409 _(one_eid_table_map_dump, "l2|l3") \
18410 _(one_map_resolver_dump, "") \
18411 _(one_map_server_dump, "") \
18412 _(one_adjacencies_get, "vni <vni>") \
18413 _(show_one_rloc_probe_state, "") \
18414 _(show_one_map_register_state, "") \
18415 _(show_one_status, "") \
18416 _(one_get_map_request_itr_rlocs, "") \
18417 _(show_one_pitr, "") \
18418 _(show_one_map_request_mode, "") \
18419 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18420 " sw_if_index <sw_if_index> p <priority> " \
18421 "w <weight>] [del]") \
18422 _(lisp_add_del_locator, "locator-set <locator_name> " \
18423 "iface <intf> | sw_if_index <sw_if_index> " \
18424 "p <priority> w <weight> [del]") \
18425 _(lisp_add_del_local_eid,"vni <vni> eid " \
18426 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18427 "locator-set <locator_name> [del]" \
18428 "[key-id sha1|sha256 secret-key <secret-key>]") \
18429 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18430 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18431 _(lisp_enable_disable, "enable|disable") \
18432 _(lisp_map_register_enable_disable, "enable|disable") \
18433 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18434 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18436 "rloc <locator> p <prio> " \
18437 "w <weight> [rloc <loc> ... ] " \
18438 "action <action> [del-all]") \
18439 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18441 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18442 _(lisp_map_request_mode, "src-dst|dst-only") \
18443 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18444 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18445 _(lisp_locator_set_dump, "[local | remote]") \
18446 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18447 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18448 "[local] | [remote]") \
18449 _(lisp_eid_table_vni_dump, "") \
18450 _(lisp_eid_table_map_dump, "l2|l3") \
18451 _(lisp_map_resolver_dump, "") \
18452 _(lisp_map_server_dump, "") \
18453 _(lisp_adjacencies_get, "vni <vni>") \
18454 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18455 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18456 _(lisp_gpe_add_del_iface, "up|down") \
18457 _(lisp_gpe_enable_disable, "enable|disable") \
18458 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18459 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18460 _(show_lisp_rloc_probe_state, "") \
18461 _(show_lisp_map_register_state, "") \
18462 _(show_lisp_status, "") \
18463 _(lisp_get_map_request_itr_rlocs, "") \
18464 _(show_lisp_pitr, "") \
18465 _(show_lisp_map_request_mode, "") \
18466 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18467 _(af_packet_delete, "name <host interface name>") \
18468 _(policer_add_del, "name <policer name> <params> [del]") \
18469 _(policer_dump, "[name <policer name>]") \
18470 _(policer_classify_set_interface, \
18471 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18472 " [l2-table <nn>] [del]") \
18473 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18474 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18475 "[master|slave]") \
18476 _(netmap_delete, "name <interface name>") \
18477 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18478 _(mpls_fib_dump, "") \
18479 _(classify_table_ids, "") \
18480 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18481 _(classify_table_info, "table_id <nn>") \
18482 _(classify_session_dump, "table_id <nn>") \
18483 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18484 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18485 "[template_interval <nn>] [udp_checksum]") \
18486 _(ipfix_exporter_dump, "") \
18487 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18488 _(ipfix_classify_stream_dump, "") \
18489 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18490 _(ipfix_classify_table_dump, "") \
18491 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18492 _(sw_interface_span_dump, "") \
18493 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18494 _(pg_create_interface, "if_id <nn>") \
18495 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18496 _(pg_enable_disable, "[stream <id>] disable") \
18497 _(ip_source_and_port_range_check_add_del, \
18498 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18499 _(ip_source_and_port_range_check_interface_add_del, \
18500 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18501 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18502 _(ipsec_gre_add_del_tunnel, \
18503 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18504 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18505 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18506 _(l2_interface_pbb_tag_rewrite, \
18507 "<intfc> | sw_if_index <nn> \n" \
18508 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18509 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18510 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18511 _(flow_classify_set_interface, \
18512 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18513 _(flow_classify_dump, "type [ip4|ip6]") \
18514 _(ip_fib_dump, "") \
18515 _(ip_mfib_dump, "") \
18516 _(ip6_fib_dump, "") \
18517 _(ip6_mfib_dump, "") \
18518 _(feature_enable_disable, "arc_name <arc_name> " \
18519 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18520 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18522 _(l2_xconnect_dump, "") \
18523 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18524 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18525 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18528 #define foreach_vpe_dpdk_api_msg \
18529 _(sw_interface_set_dpdk_hqos_pipe, \
18530 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
18531 "profile <profile-id>\n") \
18532 _(sw_interface_set_dpdk_hqos_subport, \
18533 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
18534 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
18535 _(sw_interface_set_dpdk_hqos_tctbl, \
18536 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
18539 /* List of command functions, CLI names map directly to functions */
18540 #define foreach_cli_function \
18541 _(comment, "usage: comment <ignore-rest-of-line>") \
18542 _(dump_interface_table, "usage: dump_interface_table") \
18543 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18544 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18545 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18546 _(dump_stats_table, "usage: dump_stats_table") \
18547 _(dump_macro_table, "usage: dump_macro_table ") \
18548 _(dump_node_table, "usage: dump_node_table") \
18549 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18550 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18551 _(echo, "usage: echo <message>") \
18552 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18553 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18554 _(help, "usage: help") \
18555 _(q, "usage: quit") \
18556 _(quit, "usage: quit") \
18557 _(search_node_table, "usage: search_node_table <name>...") \
18558 _(set, "usage: set <variable-name> <value>") \
18559 _(script, "usage: script <file-name>") \
18560 _(unset, "usage: unset <variable-name>")
18563 static void vl_api_##n##_t_handler_uni \
18564 (vl_api_##n##_t * mp) \
18566 vat_main_t * vam = &vat_main; \
18567 if (vam->json_output) { \
18568 vl_api_##n##_t_handler_json(mp); \
18570 vl_api_##n##_t_handler(mp); \
18573 foreach_vpe_api_reply_msg;
18578 static void vl_api_##n##_t_handler_uni \
18579 (vl_api_##n##_t * mp) \
18581 vat_main_t * vam = &vat_main; \
18582 if (vam->json_output) { \
18583 vl_api_##n##_t_handler_json(mp); \
18585 vl_api_##n##_t_handler(mp); \
18588 foreach_vpe_dpdk_api_reply_msg;
18593 vat_api_hookup (vat_main_t * vam)
18596 vl_msg_api_set_handlers(VL_API_##N, #n, \
18597 vl_api_##n##_t_handler_uni, \
18599 vl_api_##n##_t_endian, \
18600 vl_api_##n##_t_print, \
18601 sizeof(vl_api_##n##_t), 1);
18602 foreach_vpe_api_reply_msg;
18607 vl_msg_api_set_handlers(VL_API_##N, #n, \
18608 vl_api_##n##_t_handler_uni, \
18610 vl_api_##n##_t_endian, \
18611 vl_api_##n##_t_print, \
18612 sizeof(vl_api_##n##_t), 1);
18613 foreach_vpe_dpdk_api_reply_msg;
18617 #if (VPP_API_TEST_BUILTIN==0)
18618 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18621 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18623 vam->function_by_name = hash_create_string (0, sizeof (uword));
18625 vam->help_by_name = hash_create_string (0, sizeof (uword));
18627 /* API messages we can send */
18628 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18629 foreach_vpe_api_msg;
18632 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18633 foreach_vpe_dpdk_api_msg;
18638 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18639 foreach_vpe_api_msg;
18642 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18643 foreach_vpe_dpdk_api_msg;
18647 /* CLI functions */
18648 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18649 foreach_cli_function;
18653 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18654 foreach_cli_function;
18659 * fd.io coding-style-patch-verification: ON
18662 * eval: (c-set-style "gnu")