2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
51 #include <vnet/mfib/mfib_types.h>
53 #include "vat/json_format.h"
58 #define vl_typedefs /* define message structures */
59 #include <vpp/api/vpe_all_api_h.h>
62 /* declare message handlers for each api */
64 #define vl_endianfun /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* instantiate all the print functions we know about */
69 #define vl_print(handle, ...)
71 #include <vpp/api/vpe_all_api_h.h>
74 #define __plugin_msg_base 0
75 #include <vlibapi/vat_helper_macros.h>
78 vat_time_now (vat_main_t * vam)
80 #if VPP_API_TEST_BUILTIN
81 return vlib_time_now (vam->vlib_main);
83 return clib_time_now (&vam->clib_time);
88 errmsg (char *fmt, ...)
90 vat_main_t *vam = &vat_main;
95 s = va_format (0, fmt, &va);
100 #if VPP_API_TEST_BUILTIN
101 vlib_cli_output (vam->vlib_main, (char *) s);
104 if (vam->ifp != stdin)
105 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
106 vam->input_line_number);
107 fformat (vam->ofp, (char *) s);
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 #if VPP_API_TEST_BUILTIN == 0
134 /* Parse an IP4 address %d.%d.%d.%d. */
136 unformat_ip4_address (unformat_input_t * input, va_list * args)
138 u8 *result = va_arg (*args, u8 *);
141 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
144 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
156 unformat_ethernet_address (unformat_input_t * input, va_list * args)
158 u8 *result = va_arg (*args, u8 *);
161 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
162 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
166 for (i = 0; i < 6; i++)
167 if (a[i] >= (1 << 8))
170 for (i = 0; i < 6; i++)
176 /* Returns ethernet type as an int in host byte order. */
178 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
181 u16 *result = va_arg (*args, u16 *);
185 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
187 if (type >= (1 << 16))
195 /* Parse an IP6 address. */
197 unformat_ip6_address (unformat_input_t * input, va_list * args)
199 ip6_address_t *result = va_arg (*args, ip6_address_t *);
201 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
202 uword c, n_colon, double_colon_index;
204 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
205 double_colon_index = ARRAY_LEN (hex_quads);
206 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
209 if (c >= '0' && c <= '9')
211 else if (c >= 'a' && c <= 'f')
212 hex_digit = c + 10 - 'a';
213 else if (c >= 'A' && c <= 'F')
214 hex_digit = c + 10 - 'A';
215 else if (c == ':' && n_colon < 2)
219 unformat_put_input (input);
223 /* Too many hex quads. */
224 if (n_hex_quads >= ARRAY_LEN (hex_quads))
229 hex_quad = (hex_quad << 4) | hex_digit;
231 /* Hex quad must fit in 16 bits. */
232 if (n_hex_digits >= 4)
239 /* Save position of :: */
242 /* More than one :: ? */
243 if (double_colon_index < ARRAY_LEN (hex_quads))
245 double_colon_index = n_hex_quads;
248 if (n_colon > 0 && n_hex_digits > 0)
250 hex_quads[n_hex_quads++] = hex_quad;
256 if (n_hex_digits > 0)
257 hex_quads[n_hex_quads++] = hex_quad;
262 /* Expand :: to appropriate number of zero hex quads. */
263 if (double_colon_index < ARRAY_LEN (hex_quads))
265 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
267 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
268 hex_quads[n_zero + i] = hex_quads[i];
270 for (i = 0; i < n_zero; i++)
271 hex_quads[double_colon_index + i] = 0;
273 n_hex_quads = ARRAY_LEN (hex_quads);
276 /* Too few hex quads given. */
277 if (n_hex_quads < ARRAY_LEN (hex_quads))
280 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
281 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
288 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
290 u32 *r = va_arg (*args, u32 *);
293 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
294 foreach_ipsec_policy_action
302 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
304 u32 *r = va_arg (*args, u32 *);
307 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
308 foreach_ipsec_crypto_alg
316 format_ipsec_crypto_alg (u8 * s, va_list * args)
318 u32 i = va_arg (*args, u32);
323 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
324 foreach_ipsec_crypto_alg
327 return format (s, "unknown");
329 return format (s, "%s", t);
333 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
339 foreach_ipsec_integ_alg
347 format_ipsec_integ_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_integ_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
370 foreach_ikev2_auth_method
378 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
380 u32 *r = va_arg (*args, u32 *);
383 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
384 foreach_ikev2_id_type
390 #endif /* VPP_API_TEST_BUILTIN */
393 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
395 u8 *r = va_arg (*args, u8 *);
397 if (unformat (input, "kbps"))
398 *r = SSE2_QOS_RATE_KBPS;
399 else if (unformat (input, "pps"))
400 *r = SSE2_QOS_RATE_PPS;
407 unformat_policer_round_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "closest"))
412 *r = SSE2_QOS_ROUND_TO_CLOSEST;
413 else if (unformat (input, "up"))
414 *r = SSE2_QOS_ROUND_TO_UP;
415 else if (unformat (input, "down"))
416 *r = SSE2_QOS_ROUND_TO_DOWN;
423 unformat_policer_type (unformat_input_t * input, va_list * args)
425 u8 *r = va_arg (*args, u8 *);
427 if (unformat (input, "1r2c"))
428 *r = SSE2_QOS_POLICER_TYPE_1R2C;
429 else if (unformat (input, "1r3c"))
430 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
431 else if (unformat (input, "2r3c-2698"))
432 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
433 else if (unformat (input, "2r3c-4115"))
434 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
435 else if (unformat (input, "2r3c-mef5cf1"))
436 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
443 unformat_dscp (unformat_input_t * input, va_list * va)
445 u8 *r = va_arg (*va, u8 *);
448 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
457 unformat_policer_action_type (unformat_input_t * input, va_list * va)
459 sse2_qos_pol_action_params_st *a
460 = va_arg (*va, sse2_qos_pol_action_params_st *);
462 if (unformat (input, "drop"))
463 a->action_type = SSE2_QOS_ACTION_DROP;
464 else if (unformat (input, "transmit"))
465 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
466 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
467 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
474 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
476 u32 *r = va_arg (*va, u32 *);
479 if (unformat (input, "ip4"))
480 tid = POLICER_CLASSIFY_TABLE_IP4;
481 else if (unformat (input, "ip6"))
482 tid = POLICER_CLASSIFY_TABLE_IP6;
483 else if (unformat (input, "l2"))
484 tid = POLICER_CLASSIFY_TABLE_L2;
493 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
495 u32 *r = va_arg (*va, u32 *);
498 if (unformat (input, "ip4"))
499 tid = FLOW_CLASSIFY_TABLE_IP4;
500 else if (unformat (input, "ip6"))
501 tid = FLOW_CLASSIFY_TABLE_IP6;
509 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
510 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
511 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
512 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
515 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
517 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
518 mfib_itf_attribute_t attr;
521 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
523 if (unformat (input, mfib_itf_flag_long_names[attr]))
524 *iflags |= (1 << attr);
526 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
528 if (unformat (input, mfib_itf_flag_names[attr]))
529 *iflags |= (1 << attr);
532 return (old == *iflags ? 0 : 1);
536 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
538 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
539 mfib_entry_attribute_t attr;
542 FOR_EACH_MFIB_ATTRIBUTE (attr)
544 if (unformat (input, mfib_flag_long_names[attr]))
545 *eflags |= (1 << attr);
547 FOR_EACH_MFIB_ATTRIBUTE (attr)
549 if (unformat (input, mfib_flag_names[attr]))
550 *eflags |= (1 << attr);
553 return (old == *eflags ? 0 : 1);
556 #if (VPP_API_TEST_BUILTIN==0)
558 format_ip4_address (u8 * s, va_list * args)
560 u8 *a = va_arg (*args, u8 *);
561 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
565 format_ip6_address (u8 * s, va_list * args)
567 ip6_address_t *a = va_arg (*args, ip6_address_t *);
568 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
570 i_max_n_zero = ARRAY_LEN (a->as_u16);
572 i_first_zero = i_max_n_zero;
574 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
576 u32 is_zero = a->as_u16[i] == 0;
577 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
583 if ((!is_zero && n_zeros > max_n_zeros)
584 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
586 i_max_n_zero = i_first_zero;
587 max_n_zeros = n_zeros;
588 i_first_zero = ARRAY_LEN (a->as_u16);
593 last_double_colon = 0;
594 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
596 if (i == i_max_n_zero && max_n_zeros > 1)
598 s = format (s, "::");
599 i += max_n_zeros - 1;
600 last_double_colon = 1;
604 s = format (s, "%s%x",
605 (last_double_colon || i == 0) ? "" : ":",
606 clib_net_to_host_u16 (a->as_u16[i]));
607 last_double_colon = 0;
614 /* Format an IP46 address. */
616 format_ip46_address (u8 * s, va_list * args)
618 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
619 ip46_type_t type = va_arg (*args, ip46_type_t);
625 is_ip4 = ip46_address_is_ip4 (ip46);
636 format (s, "%U", format_ip4_address, &ip46->ip4) :
637 format (s, "%U", format_ip6_address, &ip46->ip6);
641 format_ethernet_address (u8 * s, va_list * args)
643 u8 *a = va_arg (*args, u8 *);
645 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
646 a[0], a[1], a[2], a[3], a[4], a[5]);
651 increment_v4_address (ip4_address_t * a)
655 v = ntohl (a->as_u32) + 1;
656 a->as_u32 = ntohl (v);
660 increment_v6_address (ip6_address_t * a)
664 v0 = clib_net_to_host_u64 (a->as_u64[0]);
665 v1 = clib_net_to_host_u64 (a->as_u64[1]);
670 a->as_u64[0] = clib_net_to_host_u64 (v0);
671 a->as_u64[1] = clib_net_to_host_u64 (v1);
675 increment_mac_address (u64 * mac)
679 tmp = clib_net_to_host_u64 (tmp);
680 tmp += 1 << 16; /* skip unused (least significant) octets */
681 tmp = clib_host_to_net_u64 (tmp);
685 static void vl_api_create_loopback_reply_t_handler
686 (vl_api_create_loopback_reply_t * mp)
688 vat_main_t *vam = &vat_main;
689 i32 retval = ntohl (mp->retval);
691 vam->retval = retval;
692 vam->regenerate_interface_table = 1;
693 vam->sw_if_index = ntohl (mp->sw_if_index);
694 vam->result_ready = 1;
697 static void vl_api_create_loopback_reply_t_handler_json
698 (vl_api_create_loopback_reply_t * mp)
700 vat_main_t *vam = &vat_main;
701 vat_json_node_t node;
703 vat_json_init_object (&node);
704 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
705 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
707 vat_json_print (vam->ofp, &node);
708 vat_json_free (&node);
709 vam->retval = ntohl (mp->retval);
710 vam->result_ready = 1;
713 static void vl_api_af_packet_create_reply_t_handler
714 (vl_api_af_packet_create_reply_t * mp)
716 vat_main_t *vam = &vat_main;
717 i32 retval = ntohl (mp->retval);
719 vam->retval = retval;
720 vam->regenerate_interface_table = 1;
721 vam->sw_if_index = ntohl (mp->sw_if_index);
722 vam->result_ready = 1;
725 static void vl_api_af_packet_create_reply_t_handler_json
726 (vl_api_af_packet_create_reply_t * mp)
728 vat_main_t *vam = &vat_main;
729 vat_json_node_t node;
731 vat_json_init_object (&node);
732 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
733 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
735 vat_json_print (vam->ofp, &node);
736 vat_json_free (&node);
738 vam->retval = ntohl (mp->retval);
739 vam->result_ready = 1;
742 static void vl_api_create_vlan_subif_reply_t_handler
743 (vl_api_create_vlan_subif_reply_t * mp)
745 vat_main_t *vam = &vat_main;
746 i32 retval = ntohl (mp->retval);
748 vam->retval = retval;
749 vam->regenerate_interface_table = 1;
750 vam->sw_if_index = ntohl (mp->sw_if_index);
751 vam->result_ready = 1;
754 static void vl_api_create_vlan_subif_reply_t_handler_json
755 (vl_api_create_vlan_subif_reply_t * mp)
757 vat_main_t *vam = &vat_main;
758 vat_json_node_t node;
760 vat_json_init_object (&node);
761 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
762 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
764 vat_json_print (vam->ofp, &node);
765 vat_json_free (&node);
767 vam->retval = ntohl (mp->retval);
768 vam->result_ready = 1;
771 static void vl_api_create_subif_reply_t_handler
772 (vl_api_create_subif_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 i32 retval = ntohl (mp->retval);
777 vam->retval = retval;
778 vam->regenerate_interface_table = 1;
779 vam->sw_if_index = ntohl (mp->sw_if_index);
780 vam->result_ready = 1;
783 static void vl_api_create_subif_reply_t_handler_json
784 (vl_api_create_subif_reply_t * mp)
786 vat_main_t *vam = &vat_main;
787 vat_json_node_t node;
789 vat_json_init_object (&node);
790 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
791 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
793 vat_json_print (vam->ofp, &node);
794 vat_json_free (&node);
796 vam->retval = ntohl (mp->retval);
797 vam->result_ready = 1;
800 static void vl_api_interface_name_renumber_reply_t_handler
801 (vl_api_interface_name_renumber_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 i32 retval = ntohl (mp->retval);
806 vam->retval = retval;
807 vam->regenerate_interface_table = 1;
808 vam->result_ready = 1;
811 static void vl_api_interface_name_renumber_reply_t_handler_json
812 (vl_api_interface_name_renumber_reply_t * mp)
814 vat_main_t *vam = &vat_main;
815 vat_json_node_t node;
817 vat_json_init_object (&node);
818 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
820 vat_json_print (vam->ofp, &node);
821 vat_json_free (&node);
823 vam->retval = ntohl (mp->retval);
824 vam->result_ready = 1;
828 * Special-case: build the interface table, maintain
829 * the next loopback sw_if_index vbl.
831 static void vl_api_sw_interface_details_t_handler
832 (vl_api_sw_interface_details_t * mp)
834 vat_main_t *vam = &vat_main;
835 u8 *s = format (0, "%s%c", mp->interface_name, 0);
837 hash_set_mem (vam->sw_if_index_by_interface_name, s,
838 ntohl (mp->sw_if_index));
840 /* In sub interface case, fill the sub interface table entry */
841 if (mp->sw_if_index != mp->sup_sw_if_index)
843 sw_interface_subif_t *sub = NULL;
845 vec_add2 (vam->sw_if_subif_table, sub, 1);
847 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
848 strncpy ((char *) sub->interface_name, (char *) s,
849 vec_len (sub->interface_name));
850 sub->sw_if_index = ntohl (mp->sw_if_index);
851 sub->sub_id = ntohl (mp->sub_id);
853 sub->sub_dot1ad = mp->sub_dot1ad;
854 sub->sub_number_of_tags = mp->sub_number_of_tags;
855 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
856 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
857 sub->sub_exact_match = mp->sub_exact_match;
858 sub->sub_default = mp->sub_default;
859 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
860 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
862 /* vlan tag rewrite */
863 sub->vtr_op = ntohl (mp->vtr_op);
864 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
865 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
866 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
870 static void vl_api_sw_interface_details_t_handler_json
871 (vl_api_sw_interface_details_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t *node = NULL;
876 if (VAT_JSON_ARRAY != vam->json_tree.type)
878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
879 vat_json_init_array (&vam->json_tree);
881 node = vat_json_array_add (&vam->json_tree);
883 vat_json_init_object (node);
884 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
885 vat_json_object_add_uint (node, "sup_sw_if_index",
886 ntohl (mp->sup_sw_if_index));
887 vat_json_object_add_uint (node, "l2_address_length",
888 ntohl (mp->l2_address_length));
889 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
890 sizeof (mp->l2_address));
891 vat_json_object_add_string_copy (node, "interface_name",
893 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
894 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
895 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
896 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
897 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
898 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
899 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
900 vat_json_object_add_uint (node, "sub_number_of_tags",
901 mp->sub_number_of_tags);
902 vat_json_object_add_uint (node, "sub_outer_vlan_id",
903 ntohs (mp->sub_outer_vlan_id));
904 vat_json_object_add_uint (node, "sub_inner_vlan_id",
905 ntohs (mp->sub_inner_vlan_id));
906 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
907 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
908 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
909 mp->sub_outer_vlan_id_any);
910 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
911 mp->sub_inner_vlan_id_any);
912 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
913 vat_json_object_add_uint (node, "vtr_push_dot1q",
914 ntohl (mp->vtr_push_dot1q));
915 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
916 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
919 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
921 format_ethernet_address,
923 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
925 format_ethernet_address,
927 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
928 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
932 static void vl_api_sw_interface_set_flags_t_handler
933 (vl_api_sw_interface_set_flags_t * mp)
935 vat_main_t *vam = &vat_main;
936 if (vam->interface_event_display)
937 errmsg ("interface flags: sw_if_index %d %s %s",
938 ntohl (mp->sw_if_index),
939 mp->admin_up_down ? "admin-up" : "admin-down",
940 mp->link_up_down ? "link-up" : "link-down");
943 static void vl_api_sw_interface_set_flags_t_handler_json
944 (vl_api_sw_interface_set_flags_t * mp)
946 /* JSON output not supported */
950 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
952 vat_main_t *vam = &vat_main;
953 i32 retval = ntohl (mp->retval);
955 vam->retval = retval;
956 vam->shmem_result = (u8 *) mp->reply_in_shmem;
957 vam->result_ready = 1;
961 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
963 vat_main_t *vam = &vat_main;
964 vat_json_node_t node;
965 api_main_t *am = &api_main;
969 vat_json_init_object (&node);
970 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
971 vat_json_object_add_uint (&node, "reply_in_shmem",
972 ntohl (mp->reply_in_shmem));
973 /* Toss the shared-memory original... */
974 pthread_mutex_lock (&am->vlib_rp->mutex);
975 oldheap = svm_push_data_heap (am->vlib_rp);
977 reply = (u8 *) (mp->reply_in_shmem);
980 svm_pop_heap (oldheap);
981 pthread_mutex_unlock (&am->vlib_rp->mutex);
983 vat_json_print (vam->ofp, &node);
984 vat_json_free (&node);
986 vam->retval = ntohl (mp->retval);
987 vam->result_ready = 1;
991 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
993 vat_main_t *vam = &vat_main;
994 i32 retval = ntohl (mp->retval);
996 vam->retval = retval;
997 vam->cmd_reply = mp->reply;
998 vam->result_ready = 1;
1002 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1004 vat_main_t *vam = &vat_main;
1005 vat_json_node_t node;
1007 vat_json_init_object (&node);
1008 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1009 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1011 vat_json_print (vam->ofp, &node);
1012 vat_json_free (&node);
1014 vam->retval = ntohl (mp->retval);
1015 vam->result_ready = 1;
1018 static void vl_api_classify_add_del_table_reply_t_handler
1019 (vl_api_classify_add_del_table_reply_t * mp)
1021 vat_main_t *vam = &vat_main;
1022 i32 retval = ntohl (mp->retval);
1023 if (vam->async_mode)
1025 vam->async_errors += (retval < 0);
1029 vam->retval = retval;
1031 ((mp->new_table_index != 0xFFFFFFFF) ||
1032 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1033 (mp->match_n_vectors != 0xFFFFFFFF)))
1035 * Note: this is just barely thread-safe, depends on
1036 * the main thread spinning waiting for an answer...
1038 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1039 ntohl (mp->new_table_index),
1040 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1041 vam->result_ready = 1;
1045 static void vl_api_classify_add_del_table_reply_t_handler_json
1046 (vl_api_classify_add_del_table_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_uint (&node, "new_table_index",
1054 ntohl (mp->new_table_index));
1055 vat_json_object_add_uint (&node, "skip_n_vectors",
1056 ntohl (mp->skip_n_vectors));
1057 vat_json_object_add_uint (&node, "match_n_vectors",
1058 ntohl (mp->match_n_vectors));
1060 vat_json_print (vam->ofp, &node);
1061 vat_json_free (&node);
1063 vam->retval = ntohl (mp->retval);
1064 vam->result_ready = 1;
1067 static void vl_api_get_node_index_reply_t_handler
1068 (vl_api_get_node_index_reply_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 i32 retval = ntohl (mp->retval);
1072 if (vam->async_mode)
1074 vam->async_errors += (retval < 0);
1078 vam->retval = retval;
1080 errmsg ("node index %d", ntohl (mp->node_index));
1081 vam->result_ready = 1;
1085 static void vl_api_get_node_index_reply_t_handler_json
1086 (vl_api_get_node_index_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vat_json_init_object (&node);
1092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1093 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1095 vat_json_print (vam->ofp, &node);
1096 vat_json_free (&node);
1098 vam->retval = ntohl (mp->retval);
1099 vam->result_ready = 1;
1102 static void vl_api_get_next_index_reply_t_handler
1103 (vl_api_get_next_index_reply_t * mp)
1105 vat_main_t *vam = &vat_main;
1106 i32 retval = ntohl (mp->retval);
1107 if (vam->async_mode)
1109 vam->async_errors += (retval < 0);
1113 vam->retval = retval;
1115 errmsg ("next node index %d", ntohl (mp->next_index));
1116 vam->result_ready = 1;
1120 static void vl_api_get_next_index_reply_t_handler_json
1121 (vl_api_get_next_index_reply_t * mp)
1123 vat_main_t *vam = &vat_main;
1124 vat_json_node_t node;
1126 vat_json_init_object (&node);
1127 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1128 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1130 vat_json_print (vam->ofp, &node);
1131 vat_json_free (&node);
1133 vam->retval = ntohl (mp->retval);
1134 vam->result_ready = 1;
1137 static void vl_api_add_node_next_reply_t_handler
1138 (vl_api_add_node_next_reply_t * mp)
1140 vat_main_t *vam = &vat_main;
1141 i32 retval = ntohl (mp->retval);
1142 if (vam->async_mode)
1144 vam->async_errors += (retval < 0);
1148 vam->retval = retval;
1150 errmsg ("next index %d", ntohl (mp->next_index));
1151 vam->result_ready = 1;
1155 static void vl_api_add_node_next_reply_t_handler_json
1156 (vl_api_add_node_next_reply_t * mp)
1158 vat_main_t *vam = &vat_main;
1159 vat_json_node_t node;
1161 vat_json_init_object (&node);
1162 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1163 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1165 vat_json_print (vam->ofp, &node);
1166 vat_json_free (&node);
1168 vam->retval = ntohl (mp->retval);
1169 vam->result_ready = 1;
1172 static void vl_api_show_version_reply_t_handler
1173 (vl_api_show_version_reply_t * mp)
1175 vat_main_t *vam = &vat_main;
1176 i32 retval = ntohl (mp->retval);
1180 errmsg (" program: %s", mp->program);
1181 errmsg (" version: %s", mp->version);
1182 errmsg (" build date: %s", mp->build_date);
1183 errmsg ("build directory: %s", mp->build_directory);
1185 vam->retval = retval;
1186 vam->result_ready = 1;
1189 static void vl_api_show_version_reply_t_handler_json
1190 (vl_api_show_version_reply_t * mp)
1192 vat_main_t *vam = &vat_main;
1193 vat_json_node_t node;
1195 vat_json_init_object (&node);
1196 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1197 vat_json_object_add_string_copy (&node, "program", mp->program);
1198 vat_json_object_add_string_copy (&node, "version", mp->version);
1199 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1200 vat_json_object_add_string_copy (&node, "build_directory",
1201 mp->build_directory);
1203 vat_json_print (vam->ofp, &node);
1204 vat_json_free (&node);
1206 vam->retval = ntohl (mp->retval);
1207 vam->result_ready = 1;
1211 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1213 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1214 mp->mac_ip ? "mac/ip binding" : "address resolution",
1215 format_ip4_address, &mp->address,
1216 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1220 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1222 /* JSON output not supported */
1226 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1228 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1229 mp->mac_ip ? "mac/ip binding" : "address resolution",
1230 format_ip6_address, mp->address,
1231 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1235 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1237 /* JSON output not supported */
1241 * Special-case: build the bridge domain table, maintain
1242 * the next bd id vbl.
1244 static void vl_api_bridge_domain_details_t_handler
1245 (vl_api_bridge_domain_details_t * mp)
1247 vat_main_t *vam = &vat_main;
1248 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1250 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1251 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1253 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1254 ntohl (mp->bd_id), mp->learn, mp->forward,
1255 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1258 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1261 static void vl_api_bridge_domain_details_t_handler_json
1262 (vl_api_bridge_domain_details_t * mp)
1264 vat_main_t *vam = &vat_main;
1265 vat_json_node_t *node, *array = NULL;
1267 if (VAT_JSON_ARRAY != vam->json_tree.type)
1269 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1270 vat_json_init_array (&vam->json_tree);
1272 node = vat_json_array_add (&vam->json_tree);
1274 vat_json_init_object (node);
1275 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1276 vat_json_object_add_uint (node, "flood", mp->flood);
1277 vat_json_object_add_uint (node, "forward", mp->forward);
1278 vat_json_object_add_uint (node, "learn", mp->learn);
1279 vat_json_object_add_uint (node, "bvi_sw_if_index",
1280 ntohl (mp->bvi_sw_if_index));
1281 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1282 array = vat_json_object_add (node, "sw_if");
1283 vat_json_init_array (array);
1287 * Special-case: build the bridge domain sw if table.
1289 static void vl_api_bridge_domain_sw_if_details_t_handler
1290 (vl_api_bridge_domain_sw_if_details_t * mp)
1292 vat_main_t *vam = &vat_main;
1297 sw_if_index = ntohl (mp->sw_if_index);
1299 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1301 if ((u32) p->value[0] == sw_if_index)
1303 sw_if_name = (u8 *)(p->key);
1309 print (vam->ofp, "%7d %3d %s", sw_if_index,
1310 mp->shg, sw_if_name ? (char *) sw_if_name :
1311 "sw_if_index not found!");
1314 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1315 (vl_api_bridge_domain_sw_if_details_t * mp)
1317 vat_main_t *vam = &vat_main;
1318 vat_json_node_t *node = NULL;
1319 uword last_index = 0;
1321 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1322 ASSERT (vec_len (vam->json_tree.array) >= 1);
1323 last_index = vec_len (vam->json_tree.array) - 1;
1324 node = &vam->json_tree.array[last_index];
1325 node = vat_json_object_get_element (node, "sw_if");
1326 ASSERT (NULL != node);
1327 node = vat_json_array_add (node);
1329 vat_json_init_object (node);
1330 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1331 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1332 vat_json_object_add_uint (node, "shg", mp->shg);
1335 static void vl_api_control_ping_reply_t_handler
1336 (vl_api_control_ping_reply_t * mp)
1338 vat_main_t *vam = &vat_main;
1339 i32 retval = ntohl (mp->retval);
1340 if (vam->async_mode)
1342 vam->async_errors += (retval < 0);
1346 vam->retval = retval;
1347 vam->result_ready = 1;
1351 static void vl_api_control_ping_reply_t_handler_json
1352 (vl_api_control_ping_reply_t * mp)
1354 vat_main_t *vam = &vat_main;
1355 i32 retval = ntohl (mp->retval);
1357 if (VAT_JSON_NONE != vam->json_tree.type)
1359 vat_json_print (vam->ofp, &vam->json_tree);
1360 vat_json_free (&vam->json_tree);
1361 vam->json_tree.type = VAT_JSON_NONE;
1366 vat_json_init_array (&vam->json_tree);
1367 vat_json_print (vam->ofp, &vam->json_tree);
1368 vam->json_tree.type = VAT_JSON_NONE;
1371 vam->retval = retval;
1372 vam->result_ready = 1;
1376 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1378 vat_main_t *vam = &vat_main;
1379 i32 retval = ntohl (mp->retval);
1380 if (vam->async_mode)
1382 vam->async_errors += (retval < 0);
1386 vam->retval = retval;
1387 vam->result_ready = 1;
1391 static void vl_api_l2_flags_reply_t_handler_json
1392 (vl_api_l2_flags_reply_t * mp)
1394 vat_main_t *vam = &vat_main;
1395 vat_json_node_t node;
1397 vat_json_init_object (&node);
1398 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1399 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1400 ntohl (mp->resulting_feature_bitmap));
1402 vat_json_print (vam->ofp, &node);
1403 vat_json_free (&node);
1405 vam->retval = ntohl (mp->retval);
1406 vam->result_ready = 1;
1409 static void vl_api_bridge_flags_reply_t_handler
1410 (vl_api_bridge_flags_reply_t * mp)
1412 vat_main_t *vam = &vat_main;
1413 i32 retval = ntohl (mp->retval);
1414 if (vam->async_mode)
1416 vam->async_errors += (retval < 0);
1420 vam->retval = retval;
1421 vam->result_ready = 1;
1425 static void vl_api_bridge_flags_reply_t_handler_json
1426 (vl_api_bridge_flags_reply_t * mp)
1428 vat_main_t *vam = &vat_main;
1429 vat_json_node_t node;
1431 vat_json_init_object (&node);
1432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1433 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1434 ntohl (mp->resulting_feature_bitmap));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = ntohl (mp->retval);
1440 vam->result_ready = 1;
1443 static void vl_api_tap_connect_reply_t_handler
1444 (vl_api_tap_connect_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 i32 retval = ntohl (mp->retval);
1448 if (vam->async_mode)
1450 vam->async_errors += (retval < 0);
1454 vam->retval = retval;
1455 vam->sw_if_index = ntohl (mp->sw_if_index);
1456 vam->result_ready = 1;
1461 static void vl_api_tap_connect_reply_t_handler_json
1462 (vl_api_tap_connect_reply_t * mp)
1464 vat_main_t *vam = &vat_main;
1465 vat_json_node_t node;
1467 vat_json_init_object (&node);
1468 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1469 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1471 vat_json_print (vam->ofp, &node);
1472 vat_json_free (&node);
1474 vam->retval = ntohl (mp->retval);
1475 vam->result_ready = 1;
1480 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->sw_if_index = ntohl (mp->sw_if_index);
1492 vam->result_ready = 1;
1496 static void vl_api_tap_modify_reply_t_handler_json
1497 (vl_api_tap_modify_reply_t * mp)
1499 vat_main_t *vam = &vat_main;
1500 vat_json_node_t node;
1502 vat_json_init_object (&node);
1503 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1504 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1506 vat_json_print (vam->ofp, &node);
1507 vat_json_free (&node);
1509 vam->retval = ntohl (mp->retval);
1510 vam->result_ready = 1;
1514 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1516 vat_main_t *vam = &vat_main;
1517 i32 retval = ntohl (mp->retval);
1518 if (vam->async_mode)
1520 vam->async_errors += (retval < 0);
1524 vam->retval = retval;
1525 vam->result_ready = 1;
1529 static void vl_api_tap_delete_reply_t_handler_json
1530 (vl_api_tap_delete_reply_t * mp)
1532 vat_main_t *vam = &vat_main;
1533 vat_json_node_t node;
1535 vat_json_init_object (&node);
1536 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1538 vat_json_print (vam->ofp, &node);
1539 vat_json_free (&node);
1541 vam->retval = ntohl (mp->retval);
1542 vam->result_ready = 1;
1545 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1546 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 i32 retval = ntohl (mp->retval);
1550 if (vam->async_mode)
1552 vam->async_errors += (retval < 0);
1556 vam->retval = retval;
1557 vam->result_ready = 1;
1561 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1562 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1564 vat_main_t *vam = &vat_main;
1565 vat_json_node_t node;
1567 vat_json_init_object (&node);
1568 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1569 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1570 ntohl (mp->sw_if_index));
1572 vat_json_print (vam->ofp, &node);
1573 vat_json_free (&node);
1575 vam->retval = ntohl (mp->retval);
1576 vam->result_ready = 1;
1579 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1580 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1582 vat_main_t *vam = &vat_main;
1583 i32 retval = ntohl (mp->retval);
1584 if (vam->async_mode)
1586 vam->async_errors += (retval < 0);
1590 vam->retval = retval;
1591 vam->sw_if_index = ntohl (mp->sw_if_index);
1592 vam->result_ready = 1;
1596 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1597 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 vat_json_node_t node;
1602 vat_json_init_object (&node);
1603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1604 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1606 vat_json_print (vam->ofp, &node);
1607 vat_json_free (&node);
1609 vam->retval = ntohl (mp->retval);
1610 vam->result_ready = 1;
1614 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1615 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1617 vat_main_t *vam = &vat_main;
1618 i32 retval = ntohl (mp->retval);
1619 if (vam->async_mode)
1621 vam->async_errors += (retval < 0);
1625 vam->retval = retval;
1626 vam->result_ready = 1;
1630 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1631 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 vat_json_node_t node;
1636 vat_json_init_object (&node);
1637 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1640 vat_json_print (vam->ofp, &node);
1641 vat_json_free (&node);
1643 vam->retval = ntohl (mp->retval);
1644 vam->result_ready = 1;
1647 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1648 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 i32 retval = ntohl (mp->retval);
1652 if (vam->async_mode)
1654 vam->async_errors += (retval < 0);
1658 vam->retval = retval;
1659 vam->sw_if_index = ntohl (mp->sw_if_index);
1660 vam->result_ready = 1;
1664 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1665 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 vat_json_node_t node;
1670 vat_json_init_object (&node);
1671 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1672 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1674 vat_json_print (vam->ofp, &node);
1675 vat_json_free (&node);
1677 vam->retval = ntohl (mp->retval);
1678 vam->result_ready = 1;
1681 static void vl_api_gre_add_del_tunnel_reply_t_handler
1682 (vl_api_gre_add_del_tunnel_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 i32 retval = ntohl (mp->retval);
1686 if (vam->async_mode)
1688 vam->async_errors += (retval < 0);
1692 vam->retval = retval;
1693 vam->sw_if_index = ntohl (mp->sw_if_index);
1694 vam->result_ready = 1;
1698 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1699 (vl_api_gre_add_del_tunnel_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 vat_json_node_t node;
1704 vat_json_init_object (&node);
1705 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1706 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1708 vat_json_print (vam->ofp, &node);
1709 vat_json_free (&node);
1711 vam->retval = ntohl (mp->retval);
1712 vam->result_ready = 1;
1715 static void vl_api_create_vhost_user_if_reply_t_handler
1716 (vl_api_create_vhost_user_if_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 i32 retval = ntohl (mp->retval);
1720 if (vam->async_mode)
1722 vam->async_errors += (retval < 0);
1726 vam->retval = retval;
1727 vam->sw_if_index = ntohl (mp->sw_if_index);
1728 vam->result_ready = 1;
1732 static void vl_api_create_vhost_user_if_reply_t_handler_json
1733 (vl_api_create_vhost_user_if_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 vat_json_node_t node;
1738 vat_json_init_object (&node);
1739 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1740 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1742 vat_json_print (vam->ofp, &node);
1743 vat_json_free (&node);
1745 vam->retval = ntohl (mp->retval);
1746 vam->result_ready = 1;
1749 static void vl_api_ip_address_details_t_handler
1750 (vl_api_ip_address_details_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 static ip_address_details_t empty_ip_address_details = { {0} };
1754 ip_address_details_t *address = NULL;
1755 ip_details_t *current_ip_details = NULL;
1756 ip_details_t *details = NULL;
1758 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1760 if (!details || vam->current_sw_if_index >= vec_len (details)
1761 || !details[vam->current_sw_if_index].present)
1763 errmsg ("ip address details arrived but not stored");
1764 errmsg ("ip_dump should be called first");
1768 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1770 #define addresses (current_ip_details->addr)
1772 vec_validate_init_empty (addresses, vec_len (addresses),
1773 empty_ip_address_details);
1775 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1777 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1778 address->prefix_length = mp->prefix_length;
1782 static void vl_api_ip_address_details_t_handler_json
1783 (vl_api_ip_address_details_t * mp)
1785 vat_main_t *vam = &vat_main;
1786 vat_json_node_t *node = NULL;
1787 struct in6_addr ip6;
1790 if (VAT_JSON_ARRAY != vam->json_tree.type)
1792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1793 vat_json_init_array (&vam->json_tree);
1795 node = vat_json_array_add (&vam->json_tree);
1797 vat_json_init_object (node);
1800 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1801 vat_json_object_add_ip6 (node, "ip", ip6);
1805 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1806 vat_json_object_add_ip4 (node, "ip", ip4);
1808 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1812 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1814 vat_main_t *vam = &vat_main;
1815 static ip_details_t empty_ip_details = { 0 };
1816 ip_details_t *ip = NULL;
1817 u32 sw_if_index = ~0;
1819 sw_if_index = ntohl (mp->sw_if_index);
1821 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1822 sw_if_index, empty_ip_details);
1824 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1831 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1833 vat_main_t *vam = &vat_main;
1835 if (VAT_JSON_ARRAY != vam->json_tree.type)
1837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1838 vat_json_init_array (&vam->json_tree);
1840 vat_json_array_add_uint (&vam->json_tree,
1841 clib_net_to_host_u32 (mp->sw_if_index));
1844 static void vl_api_map_domain_details_t_handler_json
1845 (vl_api_map_domain_details_t * mp)
1847 vat_json_node_t *node = NULL;
1848 vat_main_t *vam = &vat_main;
1849 struct in6_addr ip6;
1852 if (VAT_JSON_ARRAY != vam->json_tree.type)
1854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1855 vat_json_init_array (&vam->json_tree);
1858 node = vat_json_array_add (&vam->json_tree);
1859 vat_json_init_object (node);
1861 vat_json_object_add_uint (node, "domain_index",
1862 clib_net_to_host_u32 (mp->domain_index));
1863 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1864 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1865 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1866 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1867 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1868 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1869 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1870 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1871 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1872 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1873 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1874 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1875 vat_json_object_add_uint (node, "flags", mp->flags);
1876 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1877 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1880 static void vl_api_map_domain_details_t_handler
1881 (vl_api_map_domain_details_t * mp)
1883 vat_main_t *vam = &vat_main;
1885 if (mp->is_translation)
1888 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1889 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1890 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1891 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1892 clib_net_to_host_u32 (mp->domain_index));
1897 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1898 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1899 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1900 format_ip6_address, mp->ip6_src,
1901 clib_net_to_host_u32 (mp->domain_index));
1903 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1904 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1905 mp->is_translation ? "map-t" : "");
1908 static void vl_api_map_rule_details_t_handler_json
1909 (vl_api_map_rule_details_t * mp)
1911 struct in6_addr ip6;
1912 vat_json_node_t *node = NULL;
1913 vat_main_t *vam = &vat_main;
1915 if (VAT_JSON_ARRAY != vam->json_tree.type)
1917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1918 vat_json_init_array (&vam->json_tree);
1921 node = vat_json_array_add (&vam->json_tree);
1922 vat_json_init_object (node);
1924 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1925 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1926 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1930 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1932 vat_main_t *vam = &vat_main;
1933 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1934 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1938 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1940 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1941 "router_addr %U host_mac %U",
1942 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1943 format_ip4_address, &mp->host_address,
1944 format_ip4_address, &mp->router_address,
1945 format_ethernet_address, mp->host_mac);
1948 static void vl_api_dhcp_compl_event_t_handler_json
1949 (vl_api_dhcp_compl_event_t * mp)
1951 /* JSON output not supported */
1955 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1958 vat_main_t *vam = &vat_main;
1959 static u64 default_counter = 0;
1961 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1963 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1964 sw_if_index, default_counter);
1965 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1969 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1970 interface_counter_t counter)
1972 vat_main_t *vam = &vat_main;
1973 static interface_counter_t default_counter = { 0, };
1975 vec_validate_init_empty (vam->combined_interface_counters,
1976 vnet_counter_type, NULL);
1977 vec_validate_init_empty (vam->combined_interface_counters
1978 [vnet_counter_type], sw_if_index, default_counter);
1979 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1982 static void vl_api_vnet_interface_counters_t_handler
1983 (vl_api_vnet_interface_counters_t * mp)
1988 static void vl_api_vnet_interface_counters_t_handler_json
1989 (vl_api_vnet_interface_counters_t * mp)
1991 interface_counter_t counter;
1996 u32 first_sw_if_index;
1999 count = ntohl (mp->count);
2000 first_sw_if_index = ntohl (mp->first_sw_if_index);
2002 if (!mp->is_combined)
2004 v_packets = (u64 *) & mp->data;
2005 for (i = 0; i < count; i++)
2008 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2009 set_simple_interface_counter (mp->vnet_counter_type,
2010 first_sw_if_index + i, packets);
2016 v = (vlib_counter_t *) & mp->data;
2017 for (i = 0; i < count; i++)
2020 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2022 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2023 set_combined_interface_counter (mp->vnet_counter_type,
2024 first_sw_if_index + i, counter);
2031 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2033 vat_main_t *vam = &vat_main;
2036 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2038 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2047 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2049 vat_main_t *vam = &vat_main;
2052 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2054 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2062 static void vl_api_vnet_ip4_fib_counters_t_handler
2063 (vl_api_vnet_ip4_fib_counters_t * mp)
2068 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2069 (vl_api_vnet_ip4_fib_counters_t * mp)
2071 vat_main_t *vam = &vat_main;
2072 vl_api_ip4_fib_counter_t *v;
2073 ip4_fib_counter_t *counter;
2080 vrf_id = ntohl (mp->vrf_id);
2081 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2082 if (~0 == vrf_index)
2084 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2085 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2086 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2087 vec_validate (vam->ip4_fib_counters, vrf_index);
2088 vam->ip4_fib_counters[vrf_index] = NULL;
2091 vec_free (vam->ip4_fib_counters[vrf_index]);
2092 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2093 count = ntohl (mp->count);
2094 for (i = 0; i < count; i++)
2096 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2097 counter = &vam->ip4_fib_counters[vrf_index][i];
2098 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2099 counter->address = ip4;
2100 counter->address_length = v->address_length;
2101 counter->packets = clib_net_to_host_u64 (v->packets);
2102 counter->bytes = clib_net_to_host_u64 (v->bytes);
2107 static void vl_api_vnet_ip4_nbr_counters_t_handler
2108 (vl_api_vnet_ip4_nbr_counters_t * mp)
2113 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2114 (vl_api_vnet_ip4_nbr_counters_t * mp)
2116 vat_main_t *vam = &vat_main;
2117 vl_api_ip4_nbr_counter_t *v;
2118 ip4_nbr_counter_t *counter;
2123 sw_if_index = ntohl (mp->sw_if_index);
2124 count = ntohl (mp->count);
2125 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2128 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2130 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2131 for (i = 0; i < count; i++)
2133 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2134 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2135 counter->address.s_addr = v->address;
2136 counter->packets = clib_net_to_host_u64 (v->packets);
2137 counter->bytes = clib_net_to_host_u64 (v->bytes);
2138 counter->linkt = v->link_type;
2143 static void vl_api_vnet_ip6_fib_counters_t_handler
2144 (vl_api_vnet_ip6_fib_counters_t * mp)
2149 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2150 (vl_api_vnet_ip6_fib_counters_t * mp)
2152 vat_main_t *vam = &vat_main;
2153 vl_api_ip6_fib_counter_t *v;
2154 ip6_fib_counter_t *counter;
2155 struct in6_addr ip6;
2161 vrf_id = ntohl (mp->vrf_id);
2162 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2163 if (~0 == vrf_index)
2165 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2166 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2167 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2168 vec_validate (vam->ip6_fib_counters, vrf_index);
2169 vam->ip6_fib_counters[vrf_index] = NULL;
2172 vec_free (vam->ip6_fib_counters[vrf_index]);
2173 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2174 count = ntohl (mp->count);
2175 for (i = 0; i < count; i++)
2177 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2178 counter = &vam->ip6_fib_counters[vrf_index][i];
2179 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2180 counter->address = ip6;
2181 counter->address_length = v->address_length;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2188 static void vl_api_vnet_ip6_nbr_counters_t_handler
2189 (vl_api_vnet_ip6_nbr_counters_t * mp)
2194 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2195 (vl_api_vnet_ip6_nbr_counters_t * mp)
2197 vat_main_t *vam = &vat_main;
2198 vl_api_ip6_nbr_counter_t *v;
2199 ip6_nbr_counter_t *counter;
2200 struct in6_addr ip6;
2205 sw_if_index = ntohl (mp->sw_if_index);
2206 count = ntohl (mp->count);
2207 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2210 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2212 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2213 for (i = 0; i < count; i++)
2215 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2216 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2217 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2218 counter->address = ip6;
2219 counter->packets = clib_net_to_host_u64 (v->packets);
2220 counter->bytes = clib_net_to_host_u64 (v->bytes);
2225 static void vl_api_get_first_msg_id_reply_t_handler
2226 (vl_api_get_first_msg_id_reply_t * mp)
2228 vat_main_t *vam = &vat_main;
2229 i32 retval = ntohl (mp->retval);
2231 if (vam->async_mode)
2233 vam->async_errors += (retval < 0);
2237 vam->retval = retval;
2238 vam->result_ready = 1;
2242 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2246 static void vl_api_get_first_msg_id_reply_t_handler_json
2247 (vl_api_get_first_msg_id_reply_t * mp)
2249 vat_main_t *vam = &vat_main;
2250 vat_json_node_t node;
2252 vat_json_init_object (&node);
2253 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2254 vat_json_object_add_uint (&node, "first_msg_id",
2255 (uint) ntohs (mp->first_msg_id));
2257 vat_json_print (vam->ofp, &node);
2258 vat_json_free (&node);
2260 vam->retval = ntohl (mp->retval);
2261 vam->result_ready = 1;
2264 static void vl_api_get_node_graph_reply_t_handler
2265 (vl_api_get_node_graph_reply_t * mp)
2267 vat_main_t *vam = &vat_main;
2268 api_main_t *am = &api_main;
2269 i32 retval = ntohl (mp->retval);
2270 u8 *pvt_copy, *reply;
2275 if (vam->async_mode)
2277 vam->async_errors += (retval < 0);
2281 vam->retval = retval;
2282 vam->result_ready = 1;
2285 /* "Should never happen..." */
2289 reply = (u8 *) (mp->reply_in_shmem);
2290 pvt_copy = vec_dup (reply);
2292 /* Toss the shared-memory original... */
2293 pthread_mutex_lock (&am->vlib_rp->mutex);
2294 oldheap = svm_push_data_heap (am->vlib_rp);
2298 svm_pop_heap (oldheap);
2299 pthread_mutex_unlock (&am->vlib_rp->mutex);
2301 if (vam->graph_nodes)
2303 hash_free (vam->graph_node_index_by_name);
2305 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2307 node = vam->graph_nodes[i];
2308 vec_free (node->name);
2309 vec_free (node->next_nodes);
2312 vec_free (vam->graph_nodes);
2315 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2316 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2317 vec_free (pvt_copy);
2319 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2321 node = vam->graph_nodes[i];
2322 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2326 static void vl_api_get_node_graph_reply_t_handler_json
2327 (vl_api_get_node_graph_reply_t * mp)
2329 vat_main_t *vam = &vat_main;
2330 api_main_t *am = &api_main;
2332 vat_json_node_t node;
2335 /* $$$$ make this real? */
2336 vat_json_init_object (&node);
2337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2338 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2340 reply = (u8 *) (mp->reply_in_shmem);
2342 /* Toss the shared-memory original... */
2343 pthread_mutex_lock (&am->vlib_rp->mutex);
2344 oldheap = svm_push_data_heap (am->vlib_rp);
2348 svm_pop_heap (oldheap);
2349 pthread_mutex_unlock (&am->vlib_rp->mutex);
2351 vat_json_print (vam->ofp, &node);
2352 vat_json_free (&node);
2354 vam->retval = ntohl (mp->retval);
2355 vam->result_ready = 1;
2359 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2361 vat_main_t *vam = &vat_main;
2366 s = format (s, "%=16d%=16d%=16d",
2367 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2371 s = format (s, "%=16U%=16d%=16d",
2372 mp->is_ipv6 ? format_ip6_address :
2374 mp->ip_address, mp->priority, mp->weight);
2377 print (vam->ofp, "%v", s);
2382 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2385 vat_main_t *vam = &vat_main;
2386 vat_json_node_t *node = NULL;
2387 struct in6_addr ip6;
2390 if (VAT_JSON_ARRAY != vam->json_tree.type)
2392 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2393 vat_json_init_array (&vam->json_tree);
2395 node = vat_json_array_add (&vam->json_tree);
2396 vat_json_init_object (node);
2398 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2399 vat_json_object_add_uint (node, "priority", mp->priority);
2400 vat_json_object_add_uint (node, "weight", mp->weight);
2403 vat_json_object_add_uint (node, "sw_if_index",
2404 clib_net_to_host_u32 (mp->sw_if_index));
2409 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2410 vat_json_object_add_ip6 (node, "address", ip6);
2414 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2415 vat_json_object_add_ip4 (node, "address", ip4);
2421 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2424 vat_main_t *vam = &vat_main;
2427 ls_name = format (0, "%s", mp->ls_name);
2429 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2435 vl_api_lisp_locator_set_details_t_handler_json
2436 (vl_api_lisp_locator_set_details_t * mp)
2438 vat_main_t *vam = &vat_main;
2439 vat_json_node_t *node = 0;
2442 ls_name = format (0, "%s", mp->ls_name);
2443 vec_add1 (ls_name, 0);
2445 if (VAT_JSON_ARRAY != vam->json_tree.type)
2447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2448 vat_json_init_array (&vam->json_tree);
2450 node = vat_json_array_add (&vam->json_tree);
2452 vat_json_init_object (node);
2453 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2454 vat_json_object_add_uint (node, "ls_index",
2455 clib_net_to_host_u32 (mp->ls_index));
2460 format_lisp_flat_eid (u8 * s, va_list * args)
2462 u32 type = va_arg (*args, u32);
2463 u8 *eid = va_arg (*args, u8 *);
2464 u32 eid_len = va_arg (*args, u32);
2469 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2471 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2473 return format (s, "%U", format_ethernet_address, eid);
2479 format_lisp_eid_vat (u8 * s, va_list * args)
2481 u32 type = va_arg (*args, u32);
2482 u8 *eid = va_arg (*args, u8 *);
2483 u32 eid_len = va_arg (*args, u32);
2484 u8 *seid = va_arg (*args, u8 *);
2485 u32 seid_len = va_arg (*args, u32);
2486 u32 is_src_dst = va_arg (*args, u32);
2489 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2491 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2497 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2499 vat_main_t *vam = &vat_main;
2500 u8 *s = 0, *eid = 0;
2502 if (~0 == mp->locator_set_index)
2503 s = format (0, "action: %d", mp->action);
2505 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2507 eid = format (0, "%U", format_lisp_eid_vat,
2511 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2514 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2515 clib_net_to_host_u32 (mp->vni),
2517 mp->is_local ? "local" : "remote",
2518 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2519 clib_net_to_host_u16 (mp->key_id), mp->key);
2526 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2529 vat_main_t *vam = &vat_main;
2530 vat_json_node_t *node = 0;
2533 if (VAT_JSON_ARRAY != vam->json_tree.type)
2535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2536 vat_json_init_array (&vam->json_tree);
2538 node = vat_json_array_add (&vam->json_tree);
2540 vat_json_init_object (node);
2541 if (~0 == mp->locator_set_index)
2542 vat_json_object_add_uint (node, "action", mp->action);
2544 vat_json_object_add_uint (node, "locator_set_index",
2545 clib_net_to_host_u32 (mp->locator_set_index));
2547 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2548 eid = format (0, "%U", format_lisp_eid_vat,
2552 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2554 vat_json_object_add_string_copy (node, "eid", eid);
2555 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2556 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2557 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2561 vat_json_object_add_uint (node, "key_id",
2562 clib_net_to_host_u16 (mp->key_id));
2563 vat_json_object_add_string_copy (node, "key", mp->key);
2569 vl_api_lisp_eid_table_map_details_t_handler
2570 (vl_api_lisp_eid_table_map_details_t * mp)
2572 vat_main_t *vam = &vat_main;
2574 u8 *line = format (0, "%=10d%=10d",
2575 clib_net_to_host_u32 (mp->vni),
2576 clib_net_to_host_u32 (mp->dp_table));
2577 print (vam->ofp, "%v", line);
2582 vl_api_lisp_eid_table_map_details_t_handler_json
2583 (vl_api_lisp_eid_table_map_details_t * mp)
2585 vat_main_t *vam = &vat_main;
2586 vat_json_node_t *node = NULL;
2588 if (VAT_JSON_ARRAY != vam->json_tree.type)
2590 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2591 vat_json_init_array (&vam->json_tree);
2593 node = vat_json_array_add (&vam->json_tree);
2594 vat_json_init_object (node);
2595 vat_json_object_add_uint (node, "dp_table",
2596 clib_net_to_host_u32 (mp->dp_table));
2597 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vl_api_lisp_eid_table_vni_details_t_handler
2602 (vl_api_lisp_eid_table_vni_details_t * mp)
2604 vat_main_t *vam = &vat_main;
2606 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2607 print (vam->ofp, "%v", line);
2612 vl_api_lisp_eid_table_vni_details_t_handler_json
2613 (vl_api_lisp_eid_table_vni_details_t * mp)
2615 vat_main_t *vam = &vat_main;
2616 vat_json_node_t *node = NULL;
2618 if (VAT_JSON_ARRAY != vam->json_tree.type)
2620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2621 vat_json_init_array (&vam->json_tree);
2623 node = vat_json_array_add (&vam->json_tree);
2624 vat_json_init_object (node);
2625 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2629 vl_api_show_lisp_map_register_state_reply_t_handler
2630 (vl_api_show_lisp_map_register_state_reply_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 int retval = clib_net_to_host_u32 (mp->retval);
2635 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2637 vam->retval = retval;
2638 vam->result_ready = 1;
2642 vl_api_show_lisp_map_register_state_reply_t_handler_json
2643 (vl_api_show_lisp_map_register_state_reply_t * mp)
2645 vat_main_t *vam = &vat_main;
2646 vat_json_node_t _node, *node = &_node;
2647 int retval = clib_net_to_host_u32 (mp->retval);
2649 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2651 vat_json_init_object (node);
2652 vat_json_object_add_string_copy (node, "state", s);
2654 vat_json_print (vam->ofp, node);
2655 vat_json_free (node);
2657 vam->retval = retval;
2658 vam->result_ready = 1;
2663 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2664 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2666 vat_main_t *vam = &vat_main;
2667 int retval = clib_net_to_host_u32 (mp->retval);
2672 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2674 vam->retval = retval;
2675 vam->result_ready = 1;
2679 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2680 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2682 vat_main_t *vam = &vat_main;
2683 vat_json_node_t _node, *node = &_node;
2684 int retval = clib_net_to_host_u32 (mp->retval);
2686 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2687 vat_json_init_object (node);
2688 vat_json_object_add_string_copy (node, "state", s);
2690 vat_json_print (vam->ofp, node);
2691 vat_json_free (node);
2693 vam->retval = retval;
2694 vam->result_ready = 1;
2699 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2701 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2702 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2706 gpe_fwd_entries_get_reply_t_net_to_host
2707 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2711 mp->count = clib_net_to_host_u32 (mp->count);
2712 for (i = 0; i < mp->count; i++)
2714 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2719 vl_api_gpe_fwd_entry_path_details_t_handler
2720 (vl_api_gpe_fwd_entry_path_details_t * mp)
2722 vat_main_t *vam = &vat_main;
2723 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2725 if (mp->lcl_loc.is_ip4)
2726 format_ip_address_fcn = format_ip4_address;
2728 format_ip_address_fcn = format_ip6_address;
2730 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2731 format_ip_address_fcn, &mp->lcl_loc,
2732 format_ip_address_fcn, &mp->rmt_loc);
2736 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2738 struct in6_addr ip6;
2743 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2744 vat_json_object_add_ip4 (n, "address", ip4);
2748 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2749 vat_json_object_add_ip6 (n, "address", ip6);
2751 vat_json_object_add_uint (n, "weight", loc->weight);
2755 vl_api_gpe_fwd_entry_path_details_t_handler_json
2756 (vl_api_gpe_fwd_entry_path_details_t * mp)
2758 vat_main_t *vam = &vat_main;
2759 vat_json_node_t *node = NULL;
2760 vat_json_node_t *loc_node;
2762 if (VAT_JSON_ARRAY != vam->json_tree.type)
2764 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2765 vat_json_init_array (&vam->json_tree);
2767 node = vat_json_array_add (&vam->json_tree);
2768 vat_json_init_object (node);
2770 loc_node = vat_json_object_add (node, "local_locator");
2771 vat_json_init_object (loc_node);
2772 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2774 loc_node = vat_json_object_add (node, "remote_locator");
2775 vat_json_init_object (loc_node);
2776 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2780 vl_api_gpe_fwd_entries_get_reply_t_handler
2781 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2783 vat_main_t *vam = &vat_main;
2785 int retval = clib_net_to_host_u32 (mp->retval);
2786 vl_api_gpe_fwd_entry_t *e;
2791 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2793 for (i = 0; i < mp->count; i++)
2795 e = &mp->entries[i];
2796 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2797 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2798 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2802 vam->retval = retval;
2803 vam->result_ready = 1;
2807 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2808 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2811 vat_main_t *vam = &vat_main;
2812 vat_json_node_t *e = 0, root;
2814 int retval = clib_net_to_host_u32 (mp->retval);
2815 vl_api_gpe_fwd_entry_t *fwd;
2820 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2821 vat_json_init_array (&root);
2823 for (i = 0; i < mp->count; i++)
2825 e = vat_json_array_add (&root);
2826 fwd = &mp->entries[i];
2828 vat_json_init_object (e);
2829 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2830 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2832 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2833 fwd->leid_prefix_len);
2835 vat_json_object_add_string_copy (e, "leid", s);
2838 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2839 fwd->reid_prefix_len);
2841 vat_json_object_add_string_copy (e, "reid", s);
2845 vat_json_print (vam->ofp, &root);
2846 vat_json_free (&root);
2849 vam->retval = retval;
2850 vam->result_ready = 1;
2854 vl_api_lisp_adjacencies_get_reply_t_handler
2855 (vl_api_lisp_adjacencies_get_reply_t * mp)
2857 vat_main_t *vam = &vat_main;
2859 int retval = clib_net_to_host_u32 (mp->retval);
2860 vl_api_lisp_adjacency_t *a;
2865 n = clib_net_to_host_u32 (mp->count);
2867 for (i = 0; i < n; i++)
2869 a = &mp->adjacencies[i];
2870 print (vam->ofp, "%U %40U",
2871 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2872 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2876 vam->retval = retval;
2877 vam->result_ready = 1;
2881 vl_api_lisp_adjacencies_get_reply_t_handler_json
2882 (vl_api_lisp_adjacencies_get_reply_t * mp)
2885 vat_main_t *vam = &vat_main;
2886 vat_json_node_t *e = 0, root;
2888 int retval = clib_net_to_host_u32 (mp->retval);
2889 vl_api_lisp_adjacency_t *a;
2894 n = clib_net_to_host_u32 (mp->count);
2895 vat_json_init_array (&root);
2897 for (i = 0; i < n; i++)
2899 e = vat_json_array_add (&root);
2900 a = &mp->adjacencies[i];
2902 vat_json_init_object (e);
2903 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2904 a->leid_prefix_len);
2906 vat_json_object_add_string_copy (e, "leid", s);
2909 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2910 a->reid_prefix_len);
2912 vat_json_object_add_string_copy (e, "reid", s);
2916 vat_json_print (vam->ofp, &root);
2917 vat_json_free (&root);
2920 vam->retval = retval;
2921 vam->result_ready = 1;
2925 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2928 vat_main_t *vam = &vat_main;
2930 print (vam->ofp, "%=20U",
2931 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2936 vl_api_lisp_map_server_details_t_handler_json
2937 (vl_api_lisp_map_server_details_t * mp)
2939 vat_main_t *vam = &vat_main;
2940 vat_json_node_t *node = NULL;
2941 struct in6_addr ip6;
2944 if (VAT_JSON_ARRAY != vam->json_tree.type)
2946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2947 vat_json_init_array (&vam->json_tree);
2949 node = vat_json_array_add (&vam->json_tree);
2951 vat_json_init_object (node);
2954 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2955 vat_json_object_add_ip6 (node, "map-server", ip6);
2959 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2960 vat_json_object_add_ip4 (node, "map-server", ip4);
2965 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2968 vat_main_t *vam = &vat_main;
2970 print (vam->ofp, "%=20U",
2971 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2976 vl_api_lisp_map_resolver_details_t_handler_json
2977 (vl_api_lisp_map_resolver_details_t * mp)
2979 vat_main_t *vam = &vat_main;
2980 vat_json_node_t *node = NULL;
2981 struct in6_addr ip6;
2984 if (VAT_JSON_ARRAY != vam->json_tree.type)
2986 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2987 vat_json_init_array (&vam->json_tree);
2989 node = vat_json_array_add (&vam->json_tree);
2991 vat_json_init_object (node);
2994 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2995 vat_json_object_add_ip6 (node, "map resolver", ip6);
2999 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3000 vat_json_object_add_ip4 (node, "map resolver", ip4);
3005 vl_api_show_lisp_status_reply_t_handler
3006 (vl_api_show_lisp_status_reply_t * mp)
3008 vat_main_t *vam = &vat_main;
3009 i32 retval = ntohl (mp->retval);
3013 print (vam->ofp, "feature: %s\ngpe: %s",
3014 mp->feature_status ? "enabled" : "disabled",
3015 mp->gpe_status ? "enabled" : "disabled");
3018 vam->retval = retval;
3019 vam->result_ready = 1;
3023 vl_api_show_lisp_status_reply_t_handler_json
3024 (vl_api_show_lisp_status_reply_t * mp)
3026 vat_main_t *vam = &vat_main;
3027 vat_json_node_t node;
3028 u8 *gpe_status = NULL;
3029 u8 *feature_status = NULL;
3031 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3032 feature_status = format (0, "%s",
3033 mp->feature_status ? "enabled" : "disabled");
3034 vec_add1 (gpe_status, 0);
3035 vec_add1 (feature_status, 0);
3037 vat_json_init_object (&node);
3038 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3039 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3041 vec_free (gpe_status);
3042 vec_free (feature_status);
3044 vat_json_print (vam->ofp, &node);
3045 vat_json_free (&node);
3047 vam->retval = ntohl (mp->retval);
3048 vam->result_ready = 1;
3052 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
3053 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
3055 vat_main_t *vam = &vat_main;
3056 i32 retval = ntohl (mp->retval);
3060 print (vam->ofp, "%=20s", mp->locator_set_name);
3063 vam->retval = retval;
3064 vam->result_ready = 1;
3068 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
3069 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
3071 vat_main_t *vam = &vat_main;
3072 vat_json_node_t *node = NULL;
3074 if (VAT_JSON_ARRAY != vam->json_tree.type)
3076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3077 vat_json_init_array (&vam->json_tree);
3079 node = vat_json_array_add (&vam->json_tree);
3081 vat_json_init_object (node);
3082 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3084 vat_json_print (vam->ofp, node);
3085 vat_json_free (node);
3087 vam->retval = ntohl (mp->retval);
3088 vam->result_ready = 1;
3092 format_lisp_map_request_mode (u8 * s, va_list * args)
3094 u32 mode = va_arg (*args, u32);
3099 return format (0, "dst-only");
3101 return format (0, "src-dst");
3107 vl_api_show_lisp_map_request_mode_reply_t_handler
3108 (vl_api_show_lisp_map_request_mode_reply_t * mp)
3110 vat_main_t *vam = &vat_main;
3111 i32 retval = ntohl (mp->retval);
3115 u32 mode = mp->mode;
3116 print (vam->ofp, "map_request_mode: %U",
3117 format_lisp_map_request_mode, mode);
3120 vam->retval = retval;
3121 vam->result_ready = 1;
3125 vl_api_show_lisp_map_request_mode_reply_t_handler_json
3126 (vl_api_show_lisp_map_request_mode_reply_t * mp)
3128 vat_main_t *vam = &vat_main;
3129 vat_json_node_t node;
3134 s = format (0, "%U", format_lisp_map_request_mode, mode);
3137 vat_json_init_object (&node);
3138 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3139 vat_json_print (vam->ofp, &node);
3140 vat_json_free (&node);
3143 vam->retval = ntohl (mp->retval);
3144 vam->result_ready = 1;
3148 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
3150 vat_main_t *vam = &vat_main;
3151 i32 retval = ntohl (mp->retval);
3155 print (vam->ofp, "%-20s%-16s",
3156 mp->status ? "enabled" : "disabled",
3157 mp->status ? (char *) mp->locator_set_name : "");
3160 vam->retval = retval;
3161 vam->result_ready = 1;
3165 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
3168 vat_main_t *vam = &vat_main;
3169 vat_json_node_t node;
3172 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3173 vec_add1 (status, 0);
3175 vat_json_init_object (&node);
3176 vat_json_object_add_string_copy (&node, "status", status);
3179 vat_json_object_add_string_copy (&node, "locator_set",
3180 mp->locator_set_name);
3185 vat_json_print (vam->ofp, &node);
3186 vat_json_free (&node);
3188 vam->retval = ntohl (mp->retval);
3189 vam->result_ready = 1;
3193 format_policer_type (u8 * s, va_list * va)
3195 u32 i = va_arg (*va, u32);
3197 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3198 s = format (s, "1r2c");
3199 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3200 s = format (s, "1r3c");
3201 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3202 s = format (s, "2r3c-2698");
3203 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3204 s = format (s, "2r3c-4115");
3205 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3206 s = format (s, "2r3c-mef5cf1");
3208 s = format (s, "ILLEGAL");
3213 format_policer_rate_type (u8 * s, va_list * va)
3215 u32 i = va_arg (*va, u32);
3217 if (i == SSE2_QOS_RATE_KBPS)
3218 s = format (s, "kbps");
3219 else if (i == SSE2_QOS_RATE_PPS)
3220 s = format (s, "pps");
3222 s = format (s, "ILLEGAL");
3227 format_policer_round_type (u8 * s, va_list * va)
3229 u32 i = va_arg (*va, u32);
3231 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3232 s = format (s, "closest");
3233 else if (i == SSE2_QOS_ROUND_TO_UP)
3234 s = format (s, "up");
3235 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3236 s = format (s, "down");
3238 s = format (s, "ILLEGAL");
3243 format_policer_action_type (u8 * s, va_list * va)
3245 u32 i = va_arg (*va, u32);
3247 if (i == SSE2_QOS_ACTION_DROP)
3248 s = format (s, "drop");
3249 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3250 s = format (s, "transmit");
3251 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3252 s = format (s, "mark-and-transmit");
3254 s = format (s, "ILLEGAL");
3259 format_dscp (u8 * s, va_list * va)
3261 u32 i = va_arg (*va, u32);
3266 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3270 return format (s, "ILLEGAL");
3272 s = format (s, "%s", t);
3277 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3279 vat_main_t *vam = &vat_main;
3280 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3282 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3283 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3285 conform_dscp_str = format (0, "");
3287 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3288 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3290 exceed_dscp_str = format (0, "");
3292 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3293 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3295 violate_dscp_str = format (0, "");
3297 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3298 "rate type %U, round type %U, %s rate, %s color-aware, "
3299 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3300 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3301 "conform action %U%s, exceed action %U%s, violate action %U%s",
3303 format_policer_type, mp->type,
3306 clib_net_to_host_u64 (mp->cb),
3307 clib_net_to_host_u64 (mp->eb),
3308 format_policer_rate_type, mp->rate_type,
3309 format_policer_round_type, mp->round_type,
3310 mp->single_rate ? "single" : "dual",
3311 mp->color_aware ? "is" : "not",
3312 ntohl (mp->cir_tokens_per_period),
3313 ntohl (mp->pir_tokens_per_period),
3315 ntohl (mp->current_limit),
3316 ntohl (mp->current_bucket),
3317 ntohl (mp->extended_limit),
3318 ntohl (mp->extended_bucket),
3319 clib_net_to_host_u64 (mp->last_update_time),
3320 format_policer_action_type, mp->conform_action_type,
3322 format_policer_action_type, mp->exceed_action_type,
3324 format_policer_action_type, mp->violate_action_type,
3327 vec_free (conform_dscp_str);
3328 vec_free (exceed_dscp_str);
3329 vec_free (violate_dscp_str);
3332 static void vl_api_policer_details_t_handler_json
3333 (vl_api_policer_details_t * mp)
3335 vat_main_t *vam = &vat_main;
3336 vat_json_node_t *node;
3337 u8 *rate_type_str, *round_type_str, *type_str;
3338 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3340 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3342 format (0, "%U", format_policer_round_type, mp->round_type);
3343 type_str = format (0, "%U", format_policer_type, mp->type);
3344 conform_action_str = format (0, "%U", format_policer_action_type,
3345 mp->conform_action_type);
3346 exceed_action_str = format (0, "%U", format_policer_action_type,
3347 mp->exceed_action_type);
3348 violate_action_str = format (0, "%U", format_policer_action_type,
3349 mp->violate_action_type);
3351 if (VAT_JSON_ARRAY != vam->json_tree.type)
3353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3354 vat_json_init_array (&vam->json_tree);
3356 node = vat_json_array_add (&vam->json_tree);
3358 vat_json_init_object (node);
3359 vat_json_object_add_string_copy (node, "name", mp->name);
3360 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3361 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3362 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3363 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3364 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3365 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3366 vat_json_object_add_string_copy (node, "type", type_str);
3367 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3368 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3369 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3370 vat_json_object_add_uint (node, "cir_tokens_per_period",
3371 ntohl (mp->cir_tokens_per_period));
3372 vat_json_object_add_uint (node, "eir_tokens_per_period",
3373 ntohl (mp->pir_tokens_per_period));
3374 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3375 vat_json_object_add_uint (node, "current_bucket",
3376 ntohl (mp->current_bucket));
3377 vat_json_object_add_uint (node, "extended_limit",
3378 ntohl (mp->extended_limit));
3379 vat_json_object_add_uint (node, "extended_bucket",
3380 ntohl (mp->extended_bucket));
3381 vat_json_object_add_uint (node, "last_update_time",
3382 ntohl (mp->last_update_time));
3383 vat_json_object_add_string_copy (node, "conform_action",
3384 conform_action_str);
3385 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3387 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3388 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3389 vec_free (dscp_str);
3391 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3392 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3394 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3395 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3396 vec_free (dscp_str);
3398 vat_json_object_add_string_copy (node, "violate_action",
3399 violate_action_str);
3400 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3402 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3403 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3404 vec_free (dscp_str);
3407 vec_free (rate_type_str);
3408 vec_free (round_type_str);
3409 vec_free (type_str);
3410 vec_free (conform_action_str);
3411 vec_free (exceed_action_str);
3412 vec_free (violate_action_str);
3416 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3419 vat_main_t *vam = &vat_main;
3420 int i, count = ntohl (mp->count);
3423 print (vam->ofp, "classify table ids (%d) : ", count);
3424 for (i = 0; i < count; i++)
3426 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3427 print (vam->ofp, (i < count - 1) ? "," : "");
3429 vam->retval = ntohl (mp->retval);
3430 vam->result_ready = 1;
3434 vl_api_classify_table_ids_reply_t_handler_json
3435 (vl_api_classify_table_ids_reply_t * mp)
3437 vat_main_t *vam = &vat_main;
3438 int i, count = ntohl (mp->count);
3442 vat_json_node_t node;
3444 vat_json_init_object (&node);
3445 for (i = 0; i < count; i++)
3447 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3449 vat_json_print (vam->ofp, &node);
3450 vat_json_free (&node);
3452 vam->retval = ntohl (mp->retval);
3453 vam->result_ready = 1;
3457 vl_api_classify_table_by_interface_reply_t_handler
3458 (vl_api_classify_table_by_interface_reply_t * mp)
3460 vat_main_t *vam = &vat_main;
3463 table_id = ntohl (mp->l2_table_id);
3465 print (vam->ofp, "l2 table id : %d", table_id);
3467 print (vam->ofp, "l2 table id : No input ACL tables configured");
3468 table_id = ntohl (mp->ip4_table_id);
3470 print (vam->ofp, "ip4 table id : %d", table_id);
3472 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3473 table_id = ntohl (mp->ip6_table_id);
3475 print (vam->ofp, "ip6 table id : %d", table_id);
3477 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3478 vam->retval = ntohl (mp->retval);
3479 vam->result_ready = 1;
3483 vl_api_classify_table_by_interface_reply_t_handler_json
3484 (vl_api_classify_table_by_interface_reply_t * mp)
3486 vat_main_t *vam = &vat_main;
3487 vat_json_node_t node;
3489 vat_json_init_object (&node);
3491 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3492 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3493 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3495 vat_json_print (vam->ofp, &node);
3496 vat_json_free (&node);
3498 vam->retval = ntohl (mp->retval);
3499 vam->result_ready = 1;
3502 static void vl_api_policer_add_del_reply_t_handler
3503 (vl_api_policer_add_del_reply_t * mp)
3505 vat_main_t *vam = &vat_main;
3506 i32 retval = ntohl (mp->retval);
3507 if (vam->async_mode)
3509 vam->async_errors += (retval < 0);
3513 vam->retval = retval;
3514 vam->result_ready = 1;
3515 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3517 * Note: this is just barely thread-safe, depends on
3518 * the main thread spinning waiting for an answer...
3520 errmsg ("policer index %d", ntohl (mp->policer_index));
3524 static void vl_api_policer_add_del_reply_t_handler_json
3525 (vl_api_policer_add_del_reply_t * mp)
3527 vat_main_t *vam = &vat_main;
3528 vat_json_node_t node;
3530 vat_json_init_object (&node);
3531 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3532 vat_json_object_add_uint (&node, "policer_index",
3533 ntohl (mp->policer_index));
3535 vat_json_print (vam->ofp, &node);
3536 vat_json_free (&node);
3538 vam->retval = ntohl (mp->retval);
3539 vam->result_ready = 1;
3542 /* Format hex dump. */
3544 format_hex_bytes (u8 * s, va_list * va)
3546 u8 *bytes = va_arg (*va, u8 *);
3547 int n_bytes = va_arg (*va, int);
3550 /* Print short or long form depending on byte count. */
3551 uword short_form = n_bytes <= 32;
3552 uword indent = format_get_indent (s);
3557 for (i = 0; i < n_bytes; i++)
3559 if (!short_form && (i % 32) == 0)
3560 s = format (s, "%08x: ", i);
3561 s = format (s, "%02x", bytes[i]);
3562 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3563 s = format (s, "\n%U", format_white_space, indent);
3570 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3573 vat_main_t *vam = &vat_main;
3574 i32 retval = ntohl (mp->retval);
3577 print (vam->ofp, "classify table info :");
3578 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3579 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3580 ntohl (mp->miss_next_index));
3581 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3582 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3583 ntohl (mp->match_n_vectors));
3584 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3585 ntohl (mp->mask_length));
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3592 vl_api_classify_table_info_reply_t_handler_json
3593 (vl_api_classify_table_info_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3596 vat_json_node_t node;
3598 i32 retval = ntohl (mp->retval);
3601 vat_json_init_object (&node);
3603 vat_json_object_add_int (&node, "sessions",
3604 ntohl (mp->active_sessions));
3605 vat_json_object_add_int (&node, "nexttbl",
3606 ntohl (mp->next_table_index));
3607 vat_json_object_add_int (&node, "nextnode",
3608 ntohl (mp->miss_next_index));
3609 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3610 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3611 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3612 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3613 ntohl (mp->mask_length), 0);
3614 vat_json_object_add_string_copy (&node, "mask", s);
3616 vat_json_print (vam->ofp, &node);
3617 vat_json_free (&node);
3619 vam->retval = ntohl (mp->retval);
3620 vam->result_ready = 1;
3624 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3627 vat_main_t *vam = &vat_main;
3629 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3630 ntohl (mp->hit_next_index), ntohl (mp->advance),
3631 ntohl (mp->opaque_index));
3632 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3633 ntohl (mp->match_length));
3637 vl_api_classify_session_details_t_handler_json
3638 (vl_api_classify_session_details_t * mp)
3640 vat_main_t *vam = &vat_main;
3641 vat_json_node_t *node = NULL;
3643 if (VAT_JSON_ARRAY != vam->json_tree.type)
3645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3646 vat_json_init_array (&vam->json_tree);
3648 node = vat_json_array_add (&vam->json_tree);
3650 vat_json_init_object (node);
3651 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3652 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3653 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3655 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3657 vat_json_object_add_string_copy (node, "match", s);
3660 static void vl_api_pg_create_interface_reply_t_handler
3661 (vl_api_pg_create_interface_reply_t * mp)
3663 vat_main_t *vam = &vat_main;
3665 vam->retval = ntohl (mp->retval);
3666 vam->result_ready = 1;
3669 static void vl_api_pg_create_interface_reply_t_handler_json
3670 (vl_api_pg_create_interface_reply_t * mp)
3672 vat_main_t *vam = &vat_main;
3673 vat_json_node_t node;
3675 i32 retval = ntohl (mp->retval);
3678 vat_json_init_object (&node);
3680 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3682 vat_json_print (vam->ofp, &node);
3683 vat_json_free (&node);
3685 vam->retval = ntohl (mp->retval);
3686 vam->result_ready = 1;
3689 static void vl_api_policer_classify_details_t_handler
3690 (vl_api_policer_classify_details_t * mp)
3692 vat_main_t *vam = &vat_main;
3694 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3695 ntohl (mp->table_index));
3698 static void vl_api_policer_classify_details_t_handler_json
3699 (vl_api_policer_classify_details_t * mp)
3701 vat_main_t *vam = &vat_main;
3702 vat_json_node_t *node;
3704 if (VAT_JSON_ARRAY != vam->json_tree.type)
3706 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3707 vat_json_init_array (&vam->json_tree);
3709 node = vat_json_array_add (&vam->json_tree);
3711 vat_json_init_object (node);
3712 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3713 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3716 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3717 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3719 vat_main_t *vam = &vat_main;
3720 i32 retval = ntohl (mp->retval);
3721 if (vam->async_mode)
3723 vam->async_errors += (retval < 0);
3727 vam->retval = retval;
3728 vam->sw_if_index = ntohl (mp->sw_if_index);
3729 vam->result_ready = 1;
3733 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3734 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3736 vat_main_t *vam = &vat_main;
3737 vat_json_node_t node;
3739 vat_json_init_object (&node);
3740 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3741 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3743 vat_json_print (vam->ofp, &node);
3744 vat_json_free (&node);
3746 vam->retval = ntohl (mp->retval);
3747 vam->result_ready = 1;
3750 static void vl_api_flow_classify_details_t_handler
3751 (vl_api_flow_classify_details_t * mp)
3753 vat_main_t *vam = &vat_main;
3755 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3756 ntohl (mp->table_index));
3759 static void vl_api_flow_classify_details_t_handler_json
3760 (vl_api_flow_classify_details_t * mp)
3762 vat_main_t *vam = &vat_main;
3763 vat_json_node_t *node;
3765 if (VAT_JSON_ARRAY != vam->json_tree.type)
3767 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3768 vat_json_init_array (&vam->json_tree);
3770 node = vat_json_array_add (&vam->json_tree);
3772 vat_json_init_object (node);
3773 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3774 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3779 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3780 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3781 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3782 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3783 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3784 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3785 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3786 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3787 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3788 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3791 * Generate boilerplate reply handlers, which
3792 * dig the return value out of the xxx_reply_t API message,
3793 * stick it into vam->retval, and set vam->result_ready
3795 * Could also do this by pointing N message decode slots at
3796 * a single function, but that could break in subtle ways.
3799 #define foreach_standard_reply_retval_handler \
3800 _(sw_interface_set_flags_reply) \
3801 _(sw_interface_add_del_address_reply) \
3802 _(sw_interface_set_table_reply) \
3803 _(sw_interface_set_mpls_enable_reply) \
3804 _(sw_interface_set_vpath_reply) \
3805 _(sw_interface_set_vxlan_bypass_reply) \
3806 _(sw_interface_set_l2_bridge_reply) \
3807 _(bridge_domain_add_del_reply) \
3808 _(sw_interface_set_l2_xconnect_reply) \
3809 _(l2fib_add_del_reply) \
3810 _(ip_add_del_route_reply) \
3811 _(ip_mroute_add_del_reply) \
3812 _(mpls_route_add_del_reply) \
3813 _(mpls_ip_bind_unbind_reply) \
3814 _(proxy_arp_add_del_reply) \
3815 _(proxy_arp_intfc_enable_disable_reply) \
3816 _(sw_interface_set_unnumbered_reply) \
3817 _(ip_neighbor_add_del_reply) \
3818 _(reset_vrf_reply) \
3819 _(oam_add_del_reply) \
3820 _(reset_fib_reply) \
3821 _(dhcp_proxy_config_reply) \
3822 _(dhcp_proxy_config_2_reply) \
3823 _(dhcp_proxy_set_vss_reply) \
3824 _(dhcp_client_config_reply) \
3825 _(set_ip_flow_hash_reply) \
3826 _(sw_interface_ip6_enable_disable_reply) \
3827 _(sw_interface_ip6_set_link_local_address_reply) \
3828 _(sw_interface_ip6nd_ra_prefix_reply) \
3829 _(sw_interface_ip6nd_ra_config_reply) \
3830 _(set_arp_neighbor_limit_reply) \
3831 _(l2_patch_add_del_reply) \
3832 _(sr_tunnel_add_del_reply) \
3833 _(sr_policy_add_del_reply) \
3834 _(sr_multicast_map_add_del_reply) \
3835 _(classify_add_del_session_reply) \
3836 _(classify_set_interface_ip_table_reply) \
3837 _(classify_set_interface_l2_tables_reply) \
3838 _(l2tpv3_set_tunnel_cookies_reply) \
3839 _(l2tpv3_interface_enable_disable_reply) \
3840 _(l2tpv3_set_lookup_key_reply) \
3841 _(l2_fib_clear_table_reply) \
3842 _(l2_interface_efp_filter_reply) \
3843 _(l2_interface_vlan_tag_rewrite_reply) \
3844 _(modify_vhost_user_if_reply) \
3845 _(delete_vhost_user_if_reply) \
3846 _(want_ip4_arp_events_reply) \
3847 _(want_ip6_nd_events_reply) \
3848 _(input_acl_set_interface_reply) \
3849 _(ipsec_spd_add_del_reply) \
3850 _(ipsec_interface_add_del_spd_reply) \
3851 _(ipsec_spd_add_del_entry_reply) \
3852 _(ipsec_sad_add_del_entry_reply) \
3853 _(ipsec_sa_set_key_reply) \
3854 _(ikev2_profile_add_del_reply) \
3855 _(ikev2_profile_set_auth_reply) \
3856 _(ikev2_profile_set_id_reply) \
3857 _(ikev2_profile_set_ts_reply) \
3858 _(ikev2_set_local_key_reply) \
3859 _(ikev2_set_responder_reply) \
3860 _(ikev2_set_ike_transforms_reply) \
3861 _(ikev2_set_esp_transforms_reply) \
3862 _(ikev2_set_sa_lifetime_reply) \
3863 _(ikev2_initiate_sa_init_reply) \
3864 _(ikev2_initiate_del_ike_sa_reply) \
3865 _(ikev2_initiate_del_child_sa_reply) \
3866 _(ikev2_initiate_rekey_child_sa_reply) \
3867 _(delete_loopback_reply) \
3868 _(bd_ip_mac_add_del_reply) \
3869 _(map_del_domain_reply) \
3870 _(map_add_del_rule_reply) \
3871 _(want_interface_events_reply) \
3872 _(want_stats_reply) \
3873 _(cop_interface_enable_disable_reply) \
3874 _(cop_whitelist_enable_disable_reply) \
3875 _(sw_interface_clear_stats_reply) \
3876 _(ioam_enable_reply) \
3877 _(ioam_disable_reply) \
3878 _(lisp_add_del_locator_reply) \
3879 _(lisp_add_del_local_eid_reply) \
3880 _(lisp_add_del_remote_mapping_reply) \
3881 _(lisp_add_del_adjacency_reply) \
3882 _(gpe_add_del_fwd_entry_reply) \
3883 _(lisp_add_del_map_resolver_reply) \
3884 _(lisp_add_del_map_server_reply) \
3885 _(gpe_enable_disable_reply) \
3886 _(gpe_add_del_iface_reply) \
3887 _(lisp_enable_disable_reply) \
3888 _(lisp_rloc_probe_enable_disable_reply) \
3889 _(lisp_map_register_enable_disable_reply) \
3890 _(lisp_pitr_set_locator_set_reply) \
3891 _(lisp_map_request_mode_reply) \
3892 _(lisp_add_del_map_request_itr_rlocs_reply) \
3893 _(lisp_eid_table_add_del_map_reply) \
3894 _(vxlan_gpe_add_del_tunnel_reply) \
3895 _(af_packet_delete_reply) \
3896 _(policer_classify_set_interface_reply) \
3897 _(netmap_create_reply) \
3898 _(netmap_delete_reply) \
3899 _(set_ipfix_exporter_reply) \
3900 _(set_ipfix_classify_stream_reply) \
3901 _(ipfix_classify_table_add_del_reply) \
3902 _(flow_classify_set_interface_reply) \
3903 _(sw_interface_span_enable_disable_reply) \
3904 _(pg_capture_reply) \
3905 _(pg_enable_disable_reply) \
3906 _(ip_source_and_port_range_check_add_del_reply) \
3907 _(ip_source_and_port_range_check_interface_add_del_reply)\
3908 _(delete_subif_reply) \
3909 _(l2_interface_pbb_tag_rewrite_reply) \
3911 _(feature_enable_disable_reply) \
3912 _(sw_interface_tag_add_del_reply) \
3913 _(sw_interface_set_mtu_reply)
3916 #define foreach_standard_dpdk_reply_retval_handler \
3917 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3918 _(sw_interface_set_dpdk_hqos_subport_reply) \
3919 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3923 static void vl_api_##n##_t_handler \
3924 (vl_api_##n##_t * mp) \
3926 vat_main_t * vam = &vat_main; \
3927 i32 retval = ntohl(mp->retval); \
3928 if (vam->async_mode) { \
3929 vam->async_errors += (retval < 0); \
3931 vam->retval = retval; \
3932 vam->result_ready = 1; \
3935 foreach_standard_reply_retval_handler;
3939 static void vl_api_##n##_t_handler_json \
3940 (vl_api_##n##_t * mp) \
3942 vat_main_t * vam = &vat_main; \
3943 vat_json_node_t node; \
3944 vat_json_init_object(&node); \
3945 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3946 vat_json_print(vam->ofp, &node); \
3947 vam->retval = ntohl(mp->retval); \
3948 vam->result_ready = 1; \
3950 foreach_standard_reply_retval_handler;
3955 static void vl_api_##n##_t_handler \
3956 (vl_api_##n##_t * mp) \
3958 vat_main_t * vam = &vat_main; \
3959 i32 retval = ntohl(mp->retval); \
3960 if (vam->async_mode) { \
3961 vam->async_errors += (retval < 0); \
3963 vam->retval = retval; \
3964 vam->result_ready = 1; \
3967 foreach_standard_dpdk_reply_retval_handler;
3971 static void vl_api_##n##_t_handler_json \
3972 (vl_api_##n##_t * mp) \
3974 vat_main_t * vam = &vat_main; \
3975 vat_json_node_t node; \
3976 vat_json_init_object(&node); \
3977 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3978 vat_json_print(vam->ofp, &node); \
3979 vam->retval = ntohl(mp->retval); \
3980 vam->result_ready = 1; \
3982 foreach_standard_dpdk_reply_retval_handler;
3987 * Table of message reply handlers, must include boilerplate handlers
3991 #define foreach_vpe_api_reply_msg \
3992 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3993 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3994 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3995 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3996 _(CONTROL_PING_REPLY, control_ping_reply) \
3997 _(CLI_REPLY, cli_reply) \
3998 _(CLI_INBAND_REPLY, cli_inband_reply) \
3999 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4000 sw_interface_add_del_address_reply) \
4001 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4002 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4003 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4004 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4005 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4006 sw_interface_set_l2_xconnect_reply) \
4007 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4008 sw_interface_set_l2_bridge_reply) \
4009 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4010 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4011 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4012 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4013 _(L2_FLAGS_REPLY, l2_flags_reply) \
4014 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4015 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4016 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4017 _(TAP_DELETE_REPLY, tap_delete_reply) \
4018 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4019 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4020 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4021 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4022 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4023 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4024 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4025 proxy_arp_intfc_enable_disable_reply) \
4026 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4027 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4028 sw_interface_set_unnumbered_reply) \
4029 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4030 _(RESET_VRF_REPLY, reset_vrf_reply) \
4031 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4032 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4033 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4034 _(RESET_FIB_REPLY, reset_fib_reply) \
4035 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4036 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
4037 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4038 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4039 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4040 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4041 sw_interface_ip6_enable_disable_reply) \
4042 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4043 sw_interface_ip6_set_link_local_address_reply) \
4044 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4045 sw_interface_ip6nd_ra_prefix_reply) \
4046 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4047 sw_interface_ip6nd_ra_config_reply) \
4048 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4049 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4050 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4051 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4052 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4053 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4054 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4055 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4056 classify_set_interface_ip_table_reply) \
4057 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4058 classify_set_interface_l2_tables_reply) \
4059 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4060 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4061 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4062 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4063 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4064 l2tpv3_interface_enable_disable_reply) \
4065 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4066 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4067 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4068 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4069 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4070 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4071 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4072 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4073 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4074 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4075 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4076 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4077 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4078 _(SHOW_VERSION_REPLY, show_version_reply) \
4079 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4080 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4081 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4082 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4083 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4084 _(IP4_ARP_EVENT, ip4_arp_event) \
4085 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4086 _(IP6_ND_EVENT, ip6_nd_event) \
4087 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4088 _(IP_ADDRESS_DETAILS, ip_address_details) \
4089 _(IP_DETAILS, ip_details) \
4090 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4091 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4092 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4093 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4094 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4095 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4096 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4097 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4098 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4099 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4100 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4101 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4102 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4103 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4104 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4105 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4106 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4107 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4108 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4109 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4110 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4111 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4112 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4113 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4114 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4115 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4116 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4117 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4118 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4119 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4120 _(MAP_RULE_DETAILS, map_rule_details) \
4121 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4122 _(WANT_STATS_REPLY, want_stats_reply) \
4123 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4124 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4125 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4126 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4127 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4128 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4129 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4130 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
4131 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
4132 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
4133 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
4134 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
4135 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4136 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
4137 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
4138 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4139 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
4140 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4141 lisp_map_register_enable_disable_reply) \
4142 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4143 lisp_rloc_probe_enable_disable_reply) \
4144 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
4145 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
4146 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
4147 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4148 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
4149 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
4150 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
4151 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
4152 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
4153 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
4154 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
4155 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
4156 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4157 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4158 gpe_fwd_entry_path_details) \
4159 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
4160 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4161 lisp_add_del_map_request_itr_rlocs_reply) \
4162 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4163 lisp_get_map_request_itr_rlocs_reply) \
4164 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
4165 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
4166 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
4167 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
4168 show_lisp_map_register_state_reply) \
4169 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4170 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4171 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4172 _(POLICER_DETAILS, policer_details) \
4173 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4174 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4175 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4176 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4177 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4178 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4179 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4180 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4181 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4182 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4183 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4184 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4185 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4186 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4187 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4188 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4189 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4190 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4191 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4192 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4193 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4194 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4195 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4196 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4197 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4198 ip_source_and_port_range_check_add_del_reply) \
4199 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4200 ip_source_and_port_range_check_interface_add_del_reply) \
4201 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4202 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4203 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4204 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4205 _(PUNT_REPLY, punt_reply) \
4206 _(IP_FIB_DETAILS, ip_fib_details) \
4207 _(IP6_FIB_DETAILS, ip6_fib_details) \
4208 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4209 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4210 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4211 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4212 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4213 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4216 #define foreach_vpe_dpdk_api_reply_msg \
4217 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4218 sw_interface_set_dpdk_hqos_pipe_reply) \
4219 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4220 sw_interface_set_dpdk_hqos_subport_reply) \
4221 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4222 sw_interface_set_dpdk_hqos_tctbl_reply)
4232 #define STR_VTR_OP_CASE(op) \
4233 case L2_VTR_ ## op: \
4237 str_vtr_op (u32 vtr_op)
4241 STR_VTR_OP_CASE (DISABLED);
4242 STR_VTR_OP_CASE (PUSH_1);
4243 STR_VTR_OP_CASE (PUSH_2);
4244 STR_VTR_OP_CASE (POP_1);
4245 STR_VTR_OP_CASE (POP_2);
4246 STR_VTR_OP_CASE (TRANSLATE_1_1);
4247 STR_VTR_OP_CASE (TRANSLATE_1_2);
4248 STR_VTR_OP_CASE (TRANSLATE_2_1);
4249 STR_VTR_OP_CASE (TRANSLATE_2_2);
4256 dump_sub_interface_table (vat_main_t * vam)
4258 const sw_interface_subif_t *sub = NULL;
4260 if (vam->json_output)
4263 ("JSON output supported only for VPE API calls and dump_stats_table");
4268 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4269 "Interface", "sw_if_index",
4270 "sub id", "dot1ad", "tags", "outer id",
4271 "inner id", "exact", "default", "outer any", "inner any");
4273 vec_foreach (sub, vam->sw_if_subif_table)
4276 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4277 sub->interface_name,
4279 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4280 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4281 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4282 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4283 if (sub->vtr_op != L2_VTR_DISABLED)
4286 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4287 "tag1: %d tag2: %d ]",
4288 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4289 sub->vtr_tag1, sub->vtr_tag2);
4297 name_sort_cmp (void *a1, void *a2)
4299 name_sort_t *n1 = a1;
4300 name_sort_t *n2 = a2;
4302 return strcmp ((char *) n1->name, (char *) n2->name);
4306 dump_interface_table (vat_main_t * vam)
4309 name_sort_t *nses = 0, *ns;
4311 if (vam->json_output)
4314 ("JSON output supported only for VPE API calls and dump_stats_table");
4319 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4321 vec_add2 (nses, ns, 1);
4322 ns->name = (u8 *)(p->key);
4323 ns->value = (u32) p->value[0];
4327 vec_sort_with_function (nses, name_sort_cmp);
4329 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4330 vec_foreach (ns, nses)
4332 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4339 dump_ip_table (vat_main_t * vam, int is_ipv6)
4341 const ip_details_t *det = NULL;
4342 const ip_address_details_t *address = NULL;
4345 print (vam->ofp, "%-12s", "sw_if_index");
4347 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4354 print (vam->ofp, "%-12d", i);
4355 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4360 vec_foreach (address, det->addr)
4364 is_ipv6 ? format_ip6_address : format_ip4_address,
4365 address->ip, address->prefix_length);
4373 dump_ipv4_table (vat_main_t * vam)
4375 if (vam->json_output)
4378 ("JSON output supported only for VPE API calls and dump_stats_table");
4382 return dump_ip_table (vam, 0);
4386 dump_ipv6_table (vat_main_t * vam)
4388 if (vam->json_output)
4391 ("JSON output supported only for VPE API calls and dump_stats_table");
4395 return dump_ip_table (vam, 1);
4399 counter_type_to_str (u8 counter_type, u8 is_combined)
4403 switch (counter_type)
4405 case VNET_INTERFACE_COUNTER_DROP:
4407 case VNET_INTERFACE_COUNTER_PUNT:
4409 case VNET_INTERFACE_COUNTER_IP4:
4411 case VNET_INTERFACE_COUNTER_IP6:
4413 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4415 case VNET_INTERFACE_COUNTER_RX_MISS:
4417 case VNET_INTERFACE_COUNTER_RX_ERROR:
4419 case VNET_INTERFACE_COUNTER_TX_ERROR:
4422 return "INVALID-COUNTER-TYPE";
4427 switch (counter_type)
4429 case VNET_INTERFACE_COUNTER_RX:
4431 case VNET_INTERFACE_COUNTER_TX:
4434 return "INVALID-COUNTER-TYPE";
4440 dump_stats_table (vat_main_t * vam)
4442 vat_json_node_t node;
4443 vat_json_node_t *msg_array;
4444 vat_json_node_t *msg;
4445 vat_json_node_t *counter_array;
4446 vat_json_node_t *counter;
4447 interface_counter_t c;
4449 ip4_fib_counter_t *c4;
4450 ip6_fib_counter_t *c6;
4451 ip4_nbr_counter_t *n4;
4452 ip6_nbr_counter_t *n6;
4455 if (!vam->json_output)
4457 clib_warning ("dump_stats_table supported only in JSON format");
4461 vat_json_init_object (&node);
4463 /* interface counters */
4464 msg_array = vat_json_object_add (&node, "interface_counters");
4465 vat_json_init_array (msg_array);
4466 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4468 msg = vat_json_array_add (msg_array);
4469 vat_json_init_object (msg);
4470 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4471 (u8 *) counter_type_to_str (i, 0));
4472 vat_json_object_add_int (msg, "is_combined", 0);
4473 counter_array = vat_json_object_add (msg, "data");
4474 vat_json_init_array (counter_array);
4475 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4477 packets = vam->simple_interface_counters[i][j];
4478 vat_json_array_add_uint (counter_array, packets);
4481 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4483 msg = vat_json_array_add (msg_array);
4484 vat_json_init_object (msg);
4485 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4486 (u8 *) counter_type_to_str (i, 1));
4487 vat_json_object_add_int (msg, "is_combined", 1);
4488 counter_array = vat_json_object_add (msg, "data");
4489 vat_json_init_array (counter_array);
4490 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4492 c = vam->combined_interface_counters[i][j];
4493 counter = vat_json_array_add (counter_array);
4494 vat_json_init_object (counter);
4495 vat_json_object_add_uint (counter, "packets", c.packets);
4496 vat_json_object_add_uint (counter, "bytes", c.bytes);
4500 /* ip4 fib counters */
4501 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4502 vat_json_init_array (msg_array);
4503 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4505 msg = vat_json_array_add (msg_array);
4506 vat_json_init_object (msg);
4507 vat_json_object_add_uint (msg, "vrf_id",
4508 vam->ip4_fib_counters_vrf_id_by_index[i]);
4509 counter_array = vat_json_object_add (msg, "c");
4510 vat_json_init_array (counter_array);
4511 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4513 counter = vat_json_array_add (counter_array);
4514 vat_json_init_object (counter);
4515 c4 = &vam->ip4_fib_counters[i][j];
4516 vat_json_object_add_ip4 (counter, "address", c4->address);
4517 vat_json_object_add_uint (counter, "address_length",
4518 c4->address_length);
4519 vat_json_object_add_uint (counter, "packets", c4->packets);
4520 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4524 /* ip6 fib counters */
4525 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4526 vat_json_init_array (msg_array);
4527 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4529 msg = vat_json_array_add (msg_array);
4530 vat_json_init_object (msg);
4531 vat_json_object_add_uint (msg, "vrf_id",
4532 vam->ip6_fib_counters_vrf_id_by_index[i]);
4533 counter_array = vat_json_object_add (msg, "c");
4534 vat_json_init_array (counter_array);
4535 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4537 counter = vat_json_array_add (counter_array);
4538 vat_json_init_object (counter);
4539 c6 = &vam->ip6_fib_counters[i][j];
4540 vat_json_object_add_ip6 (counter, "address", c6->address);
4541 vat_json_object_add_uint (counter, "address_length",
4542 c6->address_length);
4543 vat_json_object_add_uint (counter, "packets", c6->packets);
4544 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4548 /* ip4 nbr counters */
4549 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4550 vat_json_init_array (msg_array);
4551 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4553 msg = vat_json_array_add (msg_array);
4554 vat_json_init_object (msg);
4555 vat_json_object_add_uint (msg, "sw_if_index", i);
4556 counter_array = vat_json_object_add (msg, "c");
4557 vat_json_init_array (counter_array);
4558 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4560 counter = vat_json_array_add (counter_array);
4561 vat_json_init_object (counter);
4562 n4 = &vam->ip4_nbr_counters[i][j];
4563 vat_json_object_add_ip4 (counter, "address", n4->address);
4564 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4565 vat_json_object_add_uint (counter, "packets", n4->packets);
4566 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4570 /* ip6 nbr counters */
4571 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4572 vat_json_init_array (msg_array);
4573 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4575 msg = vat_json_array_add (msg_array);
4576 vat_json_init_object (msg);
4577 vat_json_object_add_uint (msg, "sw_if_index", i);
4578 counter_array = vat_json_object_add (msg, "c");
4579 vat_json_init_array (counter_array);
4580 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4582 counter = vat_json_array_add (counter_array);
4583 vat_json_init_object (counter);
4584 n6 = &vam->ip6_nbr_counters[i][j];
4585 vat_json_object_add_ip6 (counter, "address", n6->address);
4586 vat_json_object_add_uint (counter, "packets", n6->packets);
4587 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4591 vat_json_print (vam->ofp, &node);
4592 vat_json_free (&node);
4598 exec (vat_main_t * vam)
4600 api_main_t *am = &api_main;
4601 vl_api_cli_request_t *mp;
4605 unformat_input_t *i = vam->input;
4607 if (vec_len (i->buffer) == 0)
4610 if (vam->exec_mode == 0 && unformat (i, "mode"))
4615 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4622 M (CLI_REQUEST, mp);
4625 * Copy cmd into shared memory.
4626 * In order for the CLI command to work, it
4627 * must be a vector ending in \n, not a C-string ending
4630 pthread_mutex_lock (&am->vlib_rp->mutex);
4631 oldheap = svm_push_data_heap (am->vlib_rp);
4633 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4634 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4636 svm_pop_heap (oldheap);
4637 pthread_mutex_unlock (&am->vlib_rp->mutex);
4639 mp->cmd_in_shmem = (u64) cmd;
4641 timeout = vat_time_now (vam) + 10.0;
4643 while (vat_time_now (vam) < timeout)
4645 if (vam->result_ready == 1)
4648 if (vam->shmem_result != NULL)
4649 print (vam->ofp, "%s", vam->shmem_result);
4650 pthread_mutex_lock (&am->vlib_rp->mutex);
4651 oldheap = svm_push_data_heap (am->vlib_rp);
4653 free_me = (u8 *) vam->shmem_result;
4656 svm_pop_heap (oldheap);
4657 pthread_mutex_unlock (&am->vlib_rp->mutex);
4665 * Future replacement of exec() that passes CLI buffers directly in
4666 * the API messages instead of an additional shared memory area.
4669 exec_inband (vat_main_t * vam)
4671 vl_api_cli_inband_t *mp;
4672 unformat_input_t *i = vam->input;
4675 if (vec_len (i->buffer) == 0)
4678 if (vam->exec_mode == 0 && unformat (i, "mode"))
4683 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4690 * In order for the CLI command to work, it
4691 * must be a vector ending in \n, not a C-string ending
4694 u32 len = vec_len (vam->input->buffer);
4695 M2 (CLI_INBAND, mp, len);
4696 clib_memcpy (mp->cmd, vam->input->buffer, len);
4697 mp->length = htonl (len);
4700 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4705 api_create_loopback (vat_main_t * vam)
4707 unformat_input_t *i = vam->input;
4708 vl_api_create_loopback_t *mp;
4713 memset (mac_address, 0, sizeof (mac_address));
4715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4717 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4723 /* Construct the API message */
4724 M (CREATE_LOOPBACK, mp);
4726 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4734 api_delete_loopback (vat_main_t * vam)
4736 unformat_input_t *i = vam->input;
4737 vl_api_delete_loopback_t *mp;
4738 u32 sw_if_index = ~0;
4741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4743 if (unformat (i, "sw_if_index %d", &sw_if_index))
4749 if (sw_if_index == ~0)
4751 errmsg ("missing sw_if_index");
4755 /* Construct the API message */
4756 M (DELETE_LOOPBACK, mp);
4757 mp->sw_if_index = ntohl (sw_if_index);
4765 api_want_stats (vat_main_t * vam)
4767 unformat_input_t *i = vam->input;
4768 vl_api_want_stats_t *mp;
4772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4774 if (unformat (i, "enable"))
4776 else if (unformat (i, "disable"))
4784 errmsg ("missing enable|disable");
4789 mp->enable_disable = enable;
4797 api_want_interface_events (vat_main_t * vam)
4799 unformat_input_t *i = vam->input;
4800 vl_api_want_interface_events_t *mp;
4804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4806 if (unformat (i, "enable"))
4808 else if (unformat (i, "disable"))
4816 errmsg ("missing enable|disable");
4820 M (WANT_INTERFACE_EVENTS, mp);
4821 mp->enable_disable = enable;
4823 vam->interface_event_display = enable;
4831 /* Note: non-static, called once to set up the initial intfc table */
4833 api_sw_interface_dump (vat_main_t * vam)
4835 vl_api_sw_interface_dump_t *mp;
4836 vl_api_control_ping_t *mp_ping;
4838 name_sort_t *nses = 0, *ns;
4839 sw_interface_subif_t *sub = NULL;
4842 /* Toss the old name table */
4844 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4846 vec_add2 (nses, ns, 1);
4847 ns->name = (u8 *)(p->key);
4848 ns->value = (u32) p->value[0];
4852 hash_free (vam->sw_if_index_by_interface_name);
4854 vec_foreach (ns, nses) vec_free (ns->name);
4858 vec_foreach (sub, vam->sw_if_subif_table)
4860 vec_free (sub->interface_name);
4862 vec_free (vam->sw_if_subif_table);
4864 /* recreate the interface name hash table */
4865 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4867 /* Get list of ethernets */
4868 M (SW_INTERFACE_DUMP, mp);
4869 mp->name_filter_valid = 1;
4870 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4873 /* and local / loopback interfaces */
4874 M (SW_INTERFACE_DUMP, mp);
4875 mp->name_filter_valid = 1;
4876 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4879 /* and packet-generator interfaces */
4880 M (SW_INTERFACE_DUMP, mp);
4881 mp->name_filter_valid = 1;
4882 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4885 /* and vxlan-gpe tunnel interfaces */
4886 M (SW_INTERFACE_DUMP, mp);
4887 mp->name_filter_valid = 1;
4888 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4889 sizeof (mp->name_filter) - 1);
4892 /* and vxlan tunnel interfaces */
4893 M (SW_INTERFACE_DUMP, mp);
4894 mp->name_filter_valid = 1;
4895 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4898 /* and host (af_packet) interfaces */
4899 M (SW_INTERFACE_DUMP, mp);
4900 mp->name_filter_valid = 1;
4901 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4904 /* and l2tpv3 tunnel interfaces */
4905 M (SW_INTERFACE_DUMP, mp);
4906 mp->name_filter_valid = 1;
4907 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4908 sizeof (mp->name_filter) - 1);
4911 /* and GRE tunnel interfaces */
4912 M (SW_INTERFACE_DUMP, mp);
4913 mp->name_filter_valid = 1;
4914 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4917 /* and LISP-GPE interfaces */
4918 M (SW_INTERFACE_DUMP, mp);
4919 mp->name_filter_valid = 1;
4920 strncpy ((char *) mp->name_filter, "lisp_gpe",
4921 sizeof (mp->name_filter) - 1);
4924 /* and IPSEC tunnel interfaces */
4925 M (SW_INTERFACE_DUMP, mp);
4926 mp->name_filter_valid = 1;
4927 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4930 /* Use a control ping for synchronization */
4931 M (CONTROL_PING, mp_ping);
4939 api_sw_interface_set_flags (vat_main_t * vam)
4941 unformat_input_t *i = vam->input;
4942 vl_api_sw_interface_set_flags_t *mp;
4944 u8 sw_if_index_set = 0;
4945 u8 admin_up = 0, link_up = 0;
4948 /* Parse args required to build the message */
4949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4951 if (unformat (i, "admin-up"))
4953 else if (unformat (i, "admin-down"))
4955 else if (unformat (i, "link-up"))
4957 else if (unformat (i, "link-down"))
4960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4961 sw_if_index_set = 1;
4962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4963 sw_if_index_set = 1;
4968 if (sw_if_index_set == 0)
4970 errmsg ("missing interface name or sw_if_index");
4974 /* Construct the API message */
4975 M (SW_INTERFACE_SET_FLAGS, mp);
4976 mp->sw_if_index = ntohl (sw_if_index);
4977 mp->admin_up_down = admin_up;
4978 mp->link_up_down = link_up;
4983 /* Wait for a reply, return the good/bad news... */
4989 api_sw_interface_clear_stats (vat_main_t * vam)
4991 unformat_input_t *i = vam->input;
4992 vl_api_sw_interface_clear_stats_t *mp;
4994 u8 sw_if_index_set = 0;
4997 /* Parse args required to build the message */
4998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5001 sw_if_index_set = 1;
5002 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5003 sw_if_index_set = 1;
5008 /* Construct the API message */
5009 M (SW_INTERFACE_CLEAR_STATS, mp);
5011 if (sw_if_index_set == 1)
5012 mp->sw_if_index = ntohl (sw_if_index);
5014 mp->sw_if_index = ~0;
5019 /* Wait for a reply, return the good/bad news... */
5026 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
5028 unformat_input_t *i = vam->input;
5029 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
5031 u8 sw_if_index_set = 0;
5040 /* Parse args required to build the message */
5041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5043 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5044 sw_if_index_set = 1;
5045 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5046 sw_if_index_set = 1;
5047 else if (unformat (i, "subport %u", &subport))
5050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5051 sw_if_index_set = 1;
5052 else if (unformat (i, "pipe %u", &pipe))
5054 else if (unformat (i, "profile %u", &profile))
5060 if (sw_if_index_set == 0)
5062 errmsg ("missing interface name or sw_if_index");
5066 if (subport_set == 0)
5068 errmsg ("missing subport ");
5074 errmsg ("missing pipe");
5078 if (profile_set == 0)
5080 errmsg ("missing profile");
5084 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
5086 mp->sw_if_index = ntohl (sw_if_index);
5087 mp->subport = ntohl (subport);
5088 mp->pipe = ntohl (pipe);
5089 mp->profile = ntohl (profile);
5098 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
5100 unformat_input_t *i = vam->input;
5101 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
5103 u8 sw_if_index_set = 0;
5106 u32 tb_rate = 1250000000; /* 10GbE */
5107 u32 tb_size = 1000000;
5108 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
5112 /* Parse args required to build the message */
5113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5115 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5116 sw_if_index_set = 1;
5117 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5118 sw_if_index_set = 1;
5119 else if (unformat (i, "subport %u", &subport))
5122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5123 sw_if_index_set = 1;
5124 else if (unformat (i, "rate %u", &tb_rate))
5128 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
5130 tc_rate[tc_id] = tb_rate;
5132 else if (unformat (i, "bktsize %u", &tb_size))
5134 else if (unformat (i, "tc0 %u", &tc_rate[0]))
5136 else if (unformat (i, "tc1 %u", &tc_rate[1]))
5138 else if (unformat (i, "tc2 %u", &tc_rate[2]))
5140 else if (unformat (i, "tc3 %u", &tc_rate[3]))
5142 else if (unformat (i, "period %u", &tc_period))
5148 if (sw_if_index_set == 0)
5150 errmsg ("missing interface name or sw_if_index");
5154 if (subport_set == 0)
5156 errmsg ("missing subport ");
5160 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
5162 mp->sw_if_index = ntohl (sw_if_index);
5163 mp->subport = ntohl (subport);
5164 mp->tb_rate = ntohl (tb_rate);
5165 mp->tb_size = ntohl (tb_size);
5166 mp->tc_rate[0] = ntohl (tc_rate[0]);
5167 mp->tc_rate[1] = ntohl (tc_rate[1]);
5168 mp->tc_rate[2] = ntohl (tc_rate[2]);
5169 mp->tc_rate[3] = ntohl (tc_rate[3]);
5170 mp->tc_period = ntohl (tc_period);
5178 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
5180 unformat_input_t *i = vam->input;
5181 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
5183 u8 sw_if_index_set = 0;
5187 u32 entry, tc, queue;
5190 /* Parse args required to build the message */
5191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5193 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5194 sw_if_index_set = 1;
5195 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5196 sw_if_index_set = 1;
5197 else if (unformat (i, "entry %d", &entry))
5199 else if (unformat (i, "tc %d", &tc))
5201 else if (unformat (i, "queue %d", &queue))
5207 if (sw_if_index_set == 0)
5209 errmsg ("missing interface name or sw_if_index");
5215 errmsg ("missing entry ");
5221 errmsg ("missing traffic class ");
5227 errmsg ("missing queue ");
5231 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
5233 mp->sw_if_index = ntohl (sw_if_index);
5234 mp->entry = ntohl (entry);
5235 mp->tc = ntohl (tc);
5236 mp->queue = ntohl (queue);
5245 api_sw_interface_add_del_address (vat_main_t * vam)
5247 unformat_input_t *i = vam->input;
5248 vl_api_sw_interface_add_del_address_t *mp;
5250 u8 sw_if_index_set = 0;
5251 u8 is_add = 1, del_all = 0;
5252 u32 address_length = 0;
5253 u8 v4_address_set = 0;
5254 u8 v6_address_set = 0;
5255 ip4_address_t v4address;
5256 ip6_address_t v6address;
5259 /* Parse args required to build the message */
5260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5262 if (unformat (i, "del-all"))
5264 else if (unformat (i, "del"))
5267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5268 sw_if_index_set = 1;
5269 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5270 sw_if_index_set = 1;
5271 else if (unformat (i, "%U/%d",
5272 unformat_ip4_address, &v4address, &address_length))
5274 else if (unformat (i, "%U/%d",
5275 unformat_ip6_address, &v6address, &address_length))
5281 if (sw_if_index_set == 0)
5283 errmsg ("missing interface name or sw_if_index");
5286 if (v4_address_set && v6_address_set)
5288 errmsg ("both v4 and v6 addresses set");
5291 if (!v4_address_set && !v6_address_set && !del_all)
5293 errmsg ("no addresses set");
5297 /* Construct the API message */
5298 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5300 mp->sw_if_index = ntohl (sw_if_index);
5301 mp->is_add = is_add;
5302 mp->del_all = del_all;
5306 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5310 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5312 mp->address_length = address_length;
5317 /* Wait for a reply, return good/bad news */
5323 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5325 unformat_input_t *i = vam->input;
5326 vl_api_sw_interface_set_mpls_enable_t *mp;
5328 u8 sw_if_index_set = 0;
5332 /* Parse args required to build the message */
5333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5335 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5336 sw_if_index_set = 1;
5337 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5338 sw_if_index_set = 1;
5339 else if (unformat (i, "disable"))
5341 else if (unformat (i, "dis"))
5347 if (sw_if_index_set == 0)
5349 errmsg ("missing interface name or sw_if_index");
5353 /* Construct the API message */
5354 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5356 mp->sw_if_index = ntohl (sw_if_index);
5357 mp->enable = enable;
5362 /* Wait for a reply... */
5368 api_sw_interface_set_table (vat_main_t * vam)
5370 unformat_input_t *i = vam->input;
5371 vl_api_sw_interface_set_table_t *mp;
5372 u32 sw_if_index, vrf_id = 0;
5373 u8 sw_if_index_set = 0;
5377 /* Parse args required to build the message */
5378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5380 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5381 sw_if_index_set = 1;
5382 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5383 sw_if_index_set = 1;
5384 else if (unformat (i, "vrf %d", &vrf_id))
5386 else if (unformat (i, "ipv6"))
5392 if (sw_if_index_set == 0)
5394 errmsg ("missing interface name or sw_if_index");
5398 /* Construct the API message */
5399 M (SW_INTERFACE_SET_TABLE, mp);
5401 mp->sw_if_index = ntohl (sw_if_index);
5402 mp->is_ipv6 = is_ipv6;
5403 mp->vrf_id = ntohl (vrf_id);
5408 /* Wait for a reply... */
5413 static void vl_api_sw_interface_get_table_reply_t_handler
5414 (vl_api_sw_interface_get_table_reply_t * mp)
5416 vat_main_t *vam = &vat_main;
5418 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5420 vam->retval = ntohl (mp->retval);
5421 vam->result_ready = 1;
5425 static void vl_api_sw_interface_get_table_reply_t_handler_json
5426 (vl_api_sw_interface_get_table_reply_t * mp)
5428 vat_main_t *vam = &vat_main;
5429 vat_json_node_t node;
5431 vat_json_init_object (&node);
5432 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5433 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5435 vat_json_print (vam->ofp, &node);
5436 vat_json_free (&node);
5438 vam->retval = ntohl (mp->retval);
5439 vam->result_ready = 1;
5443 api_sw_interface_get_table (vat_main_t * vam)
5445 unformat_input_t *i = vam->input;
5446 vl_api_sw_interface_get_table_t *mp;
5448 u8 sw_if_index_set = 0;
5452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5455 sw_if_index_set = 1;
5456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5457 sw_if_index_set = 1;
5458 else if (unformat (i, "ipv6"))
5464 if (sw_if_index_set == 0)
5466 errmsg ("missing interface name or sw_if_index");
5470 M (SW_INTERFACE_GET_TABLE, mp);
5471 mp->sw_if_index = htonl (sw_if_index);
5472 mp->is_ipv6 = is_ipv6;
5480 api_sw_interface_set_vpath (vat_main_t * vam)
5482 unformat_input_t *i = vam->input;
5483 vl_api_sw_interface_set_vpath_t *mp;
5484 u32 sw_if_index = 0;
5485 u8 sw_if_index_set = 0;
5489 /* Parse args required to build the message */
5490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5492 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5493 sw_if_index_set = 1;
5494 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5495 sw_if_index_set = 1;
5496 else if (unformat (i, "enable"))
5498 else if (unformat (i, "disable"))
5504 if (sw_if_index_set == 0)
5506 errmsg ("missing interface name or sw_if_index");
5510 /* Construct the API message */
5511 M (SW_INTERFACE_SET_VPATH, mp);
5513 mp->sw_if_index = ntohl (sw_if_index);
5514 mp->enable = is_enable;
5519 /* Wait for a reply... */
5525 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5527 unformat_input_t *i = vam->input;
5528 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5529 u32 sw_if_index = 0;
5530 u8 sw_if_index_set = 0;
5535 /* Parse args required to build the message */
5536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5539 sw_if_index_set = 1;
5540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5541 sw_if_index_set = 1;
5542 else if (unformat (i, "enable"))
5544 else if (unformat (i, "disable"))
5546 else if (unformat (i, "ip4"))
5548 else if (unformat (i, "ip6"))
5554 if (sw_if_index_set == 0)
5556 errmsg ("missing interface name or sw_if_index");
5560 /* Construct the API message */
5561 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5563 mp->sw_if_index = ntohl (sw_if_index);
5564 mp->enable = is_enable;
5565 mp->is_ipv6 = is_ipv6;
5570 /* Wait for a reply... */
5576 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5578 unformat_input_t *i = vam->input;
5579 vl_api_sw_interface_set_l2_xconnect_t *mp;
5581 u8 rx_sw_if_index_set = 0;
5583 u8 tx_sw_if_index_set = 0;
5587 /* Parse args required to build the message */
5588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5590 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5591 rx_sw_if_index_set = 1;
5592 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5593 tx_sw_if_index_set = 1;
5594 else if (unformat (i, "rx"))
5596 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5598 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5600 rx_sw_if_index_set = 1;
5605 else if (unformat (i, "tx"))
5607 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5609 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5611 tx_sw_if_index_set = 1;
5616 else if (unformat (i, "enable"))
5618 else if (unformat (i, "disable"))
5624 if (rx_sw_if_index_set == 0)
5626 errmsg ("missing rx interface name or rx_sw_if_index");
5630 if (enable && (tx_sw_if_index_set == 0))
5632 errmsg ("missing tx interface name or tx_sw_if_index");
5636 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5638 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5639 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5640 mp->enable = enable;
5648 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5650 unformat_input_t *i = vam->input;
5651 vl_api_sw_interface_set_l2_bridge_t *mp;
5653 u8 rx_sw_if_index_set = 0;
5661 /* Parse args required to build the message */
5662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5664 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5665 rx_sw_if_index_set = 1;
5666 else if (unformat (i, "bd_id %d", &bd_id))
5670 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5671 rx_sw_if_index_set = 1;
5672 else if (unformat (i, "shg %d", &shg))
5674 else if (unformat (i, "bvi"))
5676 else if (unformat (i, "enable"))
5678 else if (unformat (i, "disable"))
5684 if (rx_sw_if_index_set == 0)
5686 errmsg ("missing rx interface name or sw_if_index");
5690 if (enable && (bd_id_set == 0))
5692 errmsg ("missing bridge domain");
5696 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5698 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5699 mp->bd_id = ntohl (bd_id);
5702 mp->enable = enable;
5710 api_bridge_domain_dump (vat_main_t * vam)
5712 unformat_input_t *i = vam->input;
5713 vl_api_bridge_domain_dump_t *mp;
5714 vl_api_control_ping_t *mp_ping;
5718 /* Parse args required to build the message */
5719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5721 if (unformat (i, "bd_id %d", &bd_id))
5727 M (BRIDGE_DOMAIN_DUMP, mp);
5728 mp->bd_id = ntohl (bd_id);
5731 /* Use a control ping for synchronization */
5732 M (CONTROL_PING, mp_ping);
5740 api_bridge_domain_add_del (vat_main_t * vam)
5742 unformat_input_t *i = vam->input;
5743 vl_api_bridge_domain_add_del_t *mp;
5746 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5750 /* Parse args required to build the message */
5751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5753 if (unformat (i, "bd_id %d", &bd_id))
5755 else if (unformat (i, "flood %d", &flood))
5757 else if (unformat (i, "uu-flood %d", &uu_flood))
5759 else if (unformat (i, "forward %d", &forward))
5761 else if (unformat (i, "learn %d", &learn))
5763 else if (unformat (i, "arp-term %d", &arp_term))
5765 else if (unformat (i, "mac-age %d", &mac_age))
5767 else if (unformat (i, "del"))
5770 flood = uu_flood = forward = learn = 0;
5778 errmsg ("missing bridge domain");
5784 errmsg ("mac age must be less than 256 ");
5788 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5790 mp->bd_id = ntohl (bd_id);
5792 mp->uu_flood = uu_flood;
5793 mp->forward = forward;
5795 mp->arp_term = arp_term;
5796 mp->is_add = is_add;
5797 mp->mac_age = (u8) mac_age;
5805 api_l2fib_add_del (vat_main_t * vam)
5807 unformat_input_t *i = vam->input;
5808 vl_api_l2fib_add_del_t *mp;
5814 u32 sw_if_index = ~0;
5815 u8 sw_if_index_set = 0;
5824 /* Parse args required to build the message */
5825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5827 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5829 else if (unformat (i, "bd_id %d", &bd_id))
5831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5832 sw_if_index_set = 1;
5833 else if (unformat (i, "sw_if"))
5835 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5838 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5839 sw_if_index_set = 1;
5844 else if (unformat (i, "static"))
5846 else if (unformat (i, "filter"))
5851 else if (unformat (i, "bvi"))
5856 else if (unformat (i, "del"))
5858 else if (unformat (i, "count %d", &count))
5866 errmsg ("missing mac address");
5872 errmsg ("missing bridge domain");
5876 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5878 errmsg ("missing interface name or sw_if_index");
5884 /* Turn on async mode */
5885 vam->async_mode = 1;
5886 vam->async_errors = 0;
5887 before = vat_time_now (vam);
5890 for (j = 0; j < count; j++)
5892 M (L2FIB_ADD_DEL, mp);
5895 mp->bd_id = ntohl (bd_id);
5896 mp->is_add = is_add;
5900 mp->sw_if_index = ntohl (sw_if_index);
5901 mp->static_mac = static_mac;
5902 mp->filter_mac = filter_mac;
5903 mp->bvi_mac = bvi_mac;
5905 increment_mac_address (&mac);
5912 vl_api_control_ping_t *mp_ping;
5915 /* Shut off async mode */
5916 vam->async_mode = 0;
5918 M (CONTROL_PING, mp_ping);
5921 timeout = vat_time_now (vam) + 1.0;
5922 while (vat_time_now (vam) < timeout)
5923 if (vam->result_ready == 1)
5928 if (vam->retval == -99)
5931 if (vam->async_errors > 0)
5933 errmsg ("%d asynchronous errors", vam->async_errors);
5936 vam->async_errors = 0;
5937 after = vat_time_now (vam);
5939 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5940 count, after - before, count / (after - before));
5946 /* Wait for a reply... */
5950 /* Return the good/bad news */
5951 return (vam->retval);
5955 api_l2_flags (vat_main_t * vam)
5957 unformat_input_t *i = vam->input;
5958 vl_api_l2_flags_t *mp;
5960 u32 feature_bitmap = 0;
5961 u8 sw_if_index_set = 0;
5964 /* Parse args required to build the message */
5965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5967 if (unformat (i, "sw_if_index %d", &sw_if_index))
5968 sw_if_index_set = 1;
5969 else if (unformat (i, "sw_if"))
5971 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5974 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5975 sw_if_index_set = 1;
5980 else if (unformat (i, "learn"))
5981 feature_bitmap |= L2INPUT_FEAT_LEARN;
5982 else if (unformat (i, "forward"))
5983 feature_bitmap |= L2INPUT_FEAT_FWD;
5984 else if (unformat (i, "flood"))
5985 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5986 else if (unformat (i, "uu-flood"))
5987 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5992 if (sw_if_index_set == 0)
5994 errmsg ("missing interface name or sw_if_index");
6000 mp->sw_if_index = ntohl (sw_if_index);
6001 mp->feature_bitmap = ntohl (feature_bitmap);
6009 api_bridge_flags (vat_main_t * vam)
6011 unformat_input_t *i = vam->input;
6012 vl_api_bridge_flags_t *mp;
6019 /* Parse args required to build the message */
6020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6022 if (unformat (i, "bd_id %d", &bd_id))
6024 else if (unformat (i, "learn"))
6026 else if (unformat (i, "forward"))
6028 else if (unformat (i, "flood"))
6030 else if (unformat (i, "uu-flood"))
6031 flags |= L2_UU_FLOOD;
6032 else if (unformat (i, "arp-term"))
6033 flags |= L2_ARP_TERM;
6034 else if (unformat (i, "off"))
6036 else if (unformat (i, "disable"))
6044 errmsg ("missing bridge domain");
6048 M (BRIDGE_FLAGS, mp);
6050 mp->bd_id = ntohl (bd_id);
6051 mp->feature_bitmap = ntohl (flags);
6052 mp->is_set = is_set;
6060 api_bd_ip_mac_add_del (vat_main_t * vam)
6062 unformat_input_t *i = vam->input;
6063 vl_api_bd_ip_mac_add_del_t *mp;
6070 ip4_address_t v4addr;
6071 ip6_address_t v6addr;
6076 /* Parse args required to build the message */
6077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6079 if (unformat (i, "bd_id %d", &bd_id))
6083 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6087 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6092 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6096 else if (unformat (i, "del"))
6104 errmsg ("missing bridge domain");
6107 else if (ip_set == 0)
6109 errmsg ("missing IP address");
6112 else if (mac_set == 0)
6114 errmsg ("missing MAC address");
6118 M (BD_IP_MAC_ADD_DEL, mp);
6120 mp->bd_id = ntohl (bd_id);
6121 mp->is_ipv6 = is_ipv6;
6122 mp->is_add = is_add;
6124 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6126 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6127 clib_memcpy (mp->mac_address, macaddr, 6);
6134 api_tap_connect (vat_main_t * vam)
6136 unformat_input_t *i = vam->input;
6137 vl_api_tap_connect_t *mp;
6143 ip4_address_t ip4_address;
6145 int ip4_address_set = 0;
6146 ip6_address_t ip6_address;
6148 int ip6_address_set = 0;
6151 memset (mac_address, 0, sizeof (mac_address));
6153 /* Parse args required to build the message */
6154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6156 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6160 else if (unformat (i, "random-mac"))
6162 else if (unformat (i, "tapname %s", &tap_name))
6164 else if (unformat (i, "tag %s", &tag))
6166 else if (unformat (i, "address %U/%d",
6167 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6168 ip4_address_set = 1;
6169 else if (unformat (i, "address %U/%d",
6170 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6171 ip6_address_set = 1;
6178 errmsg ("missing tap name");
6181 if (vec_len (tap_name) > 63)
6183 errmsg ("tap name too long");
6186 vec_add1 (tap_name, 0);
6188 if (vec_len (tag) > 63)
6190 errmsg ("tag too long");
6194 /* Construct the API message */
6195 M (TAP_CONNECT, mp);
6197 mp->use_random_mac = random_mac;
6198 clib_memcpy (mp->mac_address, mac_address, 6);
6199 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6201 clib_memcpy (mp->tag, tag, vec_len (tag));
6203 if (ip4_address_set)
6205 mp->ip4_address_set = 1;
6206 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6207 mp->ip4_mask_width = ip4_mask_width;
6209 if (ip6_address_set)
6211 mp->ip6_address_set = 1;
6212 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6213 mp->ip6_mask_width = ip6_mask_width;
6216 vec_free (tap_name);
6222 /* Wait for a reply... */
6228 api_tap_modify (vat_main_t * vam)
6230 unformat_input_t *i = vam->input;
6231 vl_api_tap_modify_t *mp;
6236 u32 sw_if_index = ~0;
6237 u8 sw_if_index_set = 0;
6240 memset (mac_address, 0, sizeof (mac_address));
6242 /* Parse args required to build the message */
6243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6246 sw_if_index_set = 1;
6247 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6248 sw_if_index_set = 1;
6249 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6253 else if (unformat (i, "random-mac"))
6255 else if (unformat (i, "tapname %s", &tap_name))
6261 if (sw_if_index_set == 0)
6263 errmsg ("missing vpp interface name");
6268 errmsg ("missing tap name");
6271 if (vec_len (tap_name) > 63)
6273 errmsg ("tap name too long");
6275 vec_add1 (tap_name, 0);
6277 /* Construct the API message */
6280 mp->use_random_mac = random_mac;
6281 mp->sw_if_index = ntohl (sw_if_index);
6282 clib_memcpy (mp->mac_address, mac_address, 6);
6283 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6284 vec_free (tap_name);
6289 /* Wait for a reply... */
6295 api_tap_delete (vat_main_t * vam)
6297 unformat_input_t *i = vam->input;
6298 vl_api_tap_delete_t *mp;
6299 u32 sw_if_index = ~0;
6300 u8 sw_if_index_set = 0;
6303 /* Parse args required to build the message */
6304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6306 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6307 sw_if_index_set = 1;
6308 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6309 sw_if_index_set = 1;
6314 if (sw_if_index_set == 0)
6316 errmsg ("missing vpp interface name");
6320 /* Construct the API message */
6323 mp->sw_if_index = ntohl (sw_if_index);
6328 /* Wait for a reply... */
6334 api_ip_add_del_route (vat_main_t * vam)
6336 unformat_input_t *i = vam->input;
6337 vl_api_ip_add_del_route_t *mp;
6338 u32 sw_if_index = ~0, vrf_id = 0;
6340 u8 is_local = 0, is_drop = 0;
6341 u8 is_unreach = 0, is_prohibit = 0;
6342 u8 create_vrf_if_needed = 0;
6344 u32 next_hop_weight = 1;
6346 u8 is_multipath = 0;
6348 u8 address_length_set = 0;
6349 u32 next_hop_table_id = 0;
6350 u32 resolve_attempts = 0;
6351 u32 dst_address_length = 0;
6352 u8 next_hop_set = 0;
6353 ip4_address_t v4_dst_address, v4_next_hop_address;
6354 ip6_address_t v6_dst_address, v6_next_hop_address;
6358 u32 random_add_del = 0;
6359 u32 *random_vector = 0;
6361 u32 random_seed = 0xdeaddabe;
6362 u32 classify_table_index = ~0;
6364 u8 resolve_host = 0, resolve_attached = 0;
6365 mpls_label_t *next_hop_out_label_stack = NULL;
6366 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6367 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6369 /* Parse args required to build the message */
6370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6376 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6381 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6386 else if (unformat (i, "/%d", &dst_address_length))
6388 address_length_set = 1;
6391 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6392 &v4_next_hop_address))
6396 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6397 &v6_next_hop_address))
6401 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6403 else if (unformat (i, "weight %d", &next_hop_weight))
6405 else if (unformat (i, "drop"))
6409 else if (unformat (i, "null-send-unreach"))
6413 else if (unformat (i, "null-send-prohibit"))
6417 else if (unformat (i, "local"))
6421 else if (unformat (i, "classify %d", &classify_table_index))
6425 else if (unformat (i, "del"))
6427 else if (unformat (i, "add"))
6429 else if (unformat (i, "not-last"))
6431 else if (unformat (i, "resolve-via-host"))
6433 else if (unformat (i, "resolve-via-attached"))
6434 resolve_attached = 1;
6435 else if (unformat (i, "multipath"))
6437 else if (unformat (i, "vrf %d", &vrf_id))
6439 else if (unformat (i, "create-vrf"))
6440 create_vrf_if_needed = 1;
6441 else if (unformat (i, "count %d", &count))
6443 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6445 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6447 else if (unformat (i, "out-label %d", &next_hop_out_label))
6448 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6449 else if (unformat (i, "via-label %d", &next_hop_via_label))
6451 else if (unformat (i, "random"))
6453 else if (unformat (i, "seed %d", &random_seed))
6457 clib_warning ("parse error '%U'", format_unformat_error, i);
6462 if (!next_hop_set && !is_drop && !is_local &&
6463 !is_classify && !is_unreach && !is_prohibit &&
6464 MPLS_LABEL_INVALID == next_hop_via_label)
6467 ("next hop / local / drop / unreach / prohibit / classify not set");
6471 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6473 errmsg ("next hop and next-hop via label set");
6476 if (address_set == 0)
6478 errmsg ("missing addresses");
6482 if (address_length_set == 0)
6484 errmsg ("missing address length");
6488 /* Generate a pile of unique, random routes */
6491 u32 this_random_address;
6492 random_hash = hash_create (count, sizeof (uword));
6494 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6495 for (j = 0; j <= count; j++)
6499 this_random_address = random_u32 (&random_seed);
6500 this_random_address =
6501 clib_host_to_net_u32 (this_random_address);
6503 while (hash_get (random_hash, this_random_address));
6504 vec_add1 (random_vector, this_random_address);
6505 hash_set (random_hash, this_random_address, 1);
6507 hash_free (random_hash);
6508 v4_dst_address.as_u32 = random_vector[0];
6513 /* Turn on async mode */
6514 vam->async_mode = 1;
6515 vam->async_errors = 0;
6516 before = vat_time_now (vam);
6519 for (j = 0; j < count; j++)
6521 /* Construct the API message */
6522 M2 (IP_ADD_DEL_ROUTE, mp,
6523 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6525 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6526 mp->table_id = ntohl (vrf_id);
6527 mp->create_vrf_if_needed = create_vrf_if_needed;
6529 mp->is_add = is_add;
6530 mp->is_drop = is_drop;
6531 mp->is_unreach = is_unreach;
6532 mp->is_prohibit = is_prohibit;
6533 mp->is_ipv6 = is_ipv6;
6534 mp->is_local = is_local;
6535 mp->is_classify = is_classify;
6536 mp->is_multipath = is_multipath;
6537 mp->is_resolve_host = resolve_host;
6538 mp->is_resolve_attached = resolve_attached;
6539 mp->not_last = not_last;
6540 mp->next_hop_weight = next_hop_weight;
6541 mp->dst_address_length = dst_address_length;
6542 mp->next_hop_table_id = ntohl (next_hop_table_id);
6543 mp->classify_table_index = ntohl (classify_table_index);
6544 mp->next_hop_via_label = ntohl (next_hop_via_label);
6545 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6546 if (0 != mp->next_hop_n_out_labels)
6548 memcpy (mp->next_hop_out_label_stack,
6549 next_hop_out_label_stack,
6550 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6551 vec_free (next_hop_out_label_stack);
6556 clib_memcpy (mp->dst_address, &v6_dst_address,
6557 sizeof (v6_dst_address));
6559 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6560 sizeof (v6_next_hop_address));
6561 increment_v6_address (&v6_dst_address);
6565 clib_memcpy (mp->dst_address, &v4_dst_address,
6566 sizeof (v4_dst_address));
6568 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6569 sizeof (v4_next_hop_address));
6571 v4_dst_address.as_u32 = random_vector[j + 1];
6573 increment_v4_address (&v4_dst_address);
6577 /* If we receive SIGTERM, stop now... */
6582 /* When testing multiple add/del ops, use a control-ping to sync */
6585 vl_api_control_ping_t *mp_ping;
6589 /* Shut off async mode */
6590 vam->async_mode = 0;
6592 M (CONTROL_PING, mp_ping);
6595 timeout = vat_time_now (vam) + 1.0;
6596 while (vat_time_now (vam) < timeout)
6597 if (vam->result_ready == 1)
6602 if (vam->retval == -99)
6605 if (vam->async_errors > 0)
6607 errmsg ("%d asynchronous errors", vam->async_errors);
6610 vam->async_errors = 0;
6611 after = vat_time_now (vam);
6613 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6617 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6618 count, after - before, count / (after - before));
6624 /* Wait for a reply... */
6629 /* Return the good/bad news */
6630 return (vam->retval);
6634 api_ip_mroute_add_del (vat_main_t * vam)
6636 unformat_input_t *i = vam->input;
6637 vl_api_ip_mroute_add_del_t *mp;
6638 u32 sw_if_index = ~0, vrf_id = 0;
6641 u8 create_vrf_if_needed = 0;
6644 u32 grp_address_length = 0;
6645 ip4_address_t v4_grp_address, v4_src_address;
6646 ip6_address_t v6_grp_address, v6_src_address;
6647 mfib_itf_flags_t iflags = 0;
6648 mfib_entry_flags_t eflags = 0;
6651 /* Parse args required to build the message */
6652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6654 if (unformat (i, "sw_if_index %d", &sw_if_index))
6656 else if (unformat (i, "%U %U",
6657 unformat_ip4_address, &v4_src_address,
6658 unformat_ip4_address, &v4_grp_address))
6660 grp_address_length = 64;
6664 else if (unformat (i, "%U %U",
6665 unformat_ip6_address, &v6_src_address,
6666 unformat_ip6_address, &v6_grp_address))
6668 grp_address_length = 256;
6672 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6674 memset (&v4_src_address, 0, sizeof (v4_src_address));
6675 grp_address_length = 32;
6679 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6681 memset (&v6_src_address, 0, sizeof (v6_src_address));
6682 grp_address_length = 128;
6686 else if (unformat (i, "/%d", &grp_address_length))
6688 else if (unformat (i, "local"))
6692 else if (unformat (i, "del"))
6694 else if (unformat (i, "add"))
6696 else if (unformat (i, "vrf %d", &vrf_id))
6698 else if (unformat (i, "create-vrf"))
6699 create_vrf_if_needed = 1;
6700 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6702 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6706 clib_warning ("parse error '%U'", format_unformat_error, i);
6711 if (address_set == 0)
6713 errmsg ("missing addresses\n");
6717 /* Construct the API message */
6718 M (IP_MROUTE_ADD_DEL, mp);
6720 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6721 mp->table_id = ntohl (vrf_id);
6722 mp->create_vrf_if_needed = create_vrf_if_needed;
6724 mp->is_add = is_add;
6725 mp->is_ipv6 = is_ipv6;
6726 mp->is_local = is_local;
6727 mp->itf_flags = ntohl (iflags);
6728 mp->entry_flags = ntohl (eflags);
6729 mp->grp_address_length = grp_address_length;
6730 mp->grp_address_length = ntohs (mp->grp_address_length);
6734 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6735 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6739 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6740 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6746 /* Wait for a reply... */
6752 api_mpls_route_add_del (vat_main_t * vam)
6754 unformat_input_t *i = vam->input;
6755 vl_api_mpls_route_add_del_t *mp;
6756 u32 sw_if_index = ~0, table_id = 0;
6757 u8 create_table_if_needed = 0;
6759 u32 next_hop_weight = 1;
6760 u8 is_multipath = 0;
6761 u32 next_hop_table_id = 0;
6762 u8 next_hop_set = 0;
6763 ip4_address_t v4_next_hop_address = {
6766 ip6_address_t v6_next_hop_address = { {0} };
6770 u32 classify_table_index = ~0;
6772 u8 resolve_host = 0, resolve_attached = 0;
6773 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6774 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6775 mpls_label_t *next_hop_out_label_stack = NULL;
6776 mpls_label_t local_label = MPLS_LABEL_INVALID;
6778 u8 next_hop_proto_is_ip4 = 1;
6780 /* Parse args required to build the message */
6781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6783 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6785 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6787 else if (unformat (i, "%d", &local_label))
6789 else if (unformat (i, "eos"))
6791 else if (unformat (i, "non-eos"))
6793 else if (unformat (i, "via %U", unformat_ip4_address,
6794 &v4_next_hop_address))
6797 next_hop_proto_is_ip4 = 1;
6799 else if (unformat (i, "via %U", unformat_ip6_address,
6800 &v6_next_hop_address))
6803 next_hop_proto_is_ip4 = 0;
6805 else if (unformat (i, "weight %d", &next_hop_weight))
6807 else if (unformat (i, "create-table"))
6808 create_table_if_needed = 1;
6809 else if (unformat (i, "classify %d", &classify_table_index))
6813 else if (unformat (i, "del"))
6815 else if (unformat (i, "add"))
6817 else if (unformat (i, "resolve-via-host"))
6819 else if (unformat (i, "resolve-via-attached"))
6820 resolve_attached = 1;
6821 else if (unformat (i, "multipath"))
6823 else if (unformat (i, "count %d", &count))
6825 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6828 next_hop_proto_is_ip4 = 1;
6830 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6833 next_hop_proto_is_ip4 = 0;
6835 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6837 else if (unformat (i, "via-label %d", &next_hop_via_label))
6839 else if (unformat (i, "out-label %d", &next_hop_out_label))
6840 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6843 clib_warning ("parse error '%U'", format_unformat_error, i);
6848 if (!next_hop_set && !is_classify)
6850 errmsg ("next hop / classify not set");
6854 if (MPLS_LABEL_INVALID == local_label)
6856 errmsg ("missing label");
6862 /* Turn on async mode */
6863 vam->async_mode = 1;
6864 vam->async_errors = 0;
6865 before = vat_time_now (vam);
6868 for (j = 0; j < count; j++)
6870 /* Construct the API message */
6871 M2 (MPLS_ROUTE_ADD_DEL, mp,
6872 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6874 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6875 mp->mr_table_id = ntohl (table_id);
6876 mp->mr_create_table_if_needed = create_table_if_needed;
6878 mp->mr_is_add = is_add;
6879 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6880 mp->mr_is_classify = is_classify;
6881 mp->mr_is_multipath = is_multipath;
6882 mp->mr_is_resolve_host = resolve_host;
6883 mp->mr_is_resolve_attached = resolve_attached;
6884 mp->mr_next_hop_weight = next_hop_weight;
6885 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6886 mp->mr_classify_table_index = ntohl (classify_table_index);
6887 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6888 mp->mr_label = ntohl (local_label);
6889 mp->mr_eos = is_eos;
6891 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6892 if (0 != mp->mr_next_hop_n_out_labels)
6894 memcpy (mp->mr_next_hop_out_label_stack,
6895 next_hop_out_label_stack,
6896 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6897 vec_free (next_hop_out_label_stack);
6902 if (next_hop_proto_is_ip4)
6904 clib_memcpy (mp->mr_next_hop,
6905 &v4_next_hop_address,
6906 sizeof (v4_next_hop_address));
6910 clib_memcpy (mp->mr_next_hop,
6911 &v6_next_hop_address,
6912 sizeof (v6_next_hop_address));
6919 /* If we receive SIGTERM, stop now... */
6924 /* When testing multiple add/del ops, use a control-ping to sync */
6927 vl_api_control_ping_t *mp_ping;
6931 /* Shut off async mode */
6932 vam->async_mode = 0;
6934 M (CONTROL_PING, mp_ping);
6937 timeout = vat_time_now (vam) + 1.0;
6938 while (vat_time_now (vam) < timeout)
6939 if (vam->result_ready == 1)
6944 if (vam->retval == -99)
6947 if (vam->async_errors > 0)
6949 errmsg ("%d asynchronous errors", vam->async_errors);
6952 vam->async_errors = 0;
6953 after = vat_time_now (vam);
6955 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6959 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6960 count, after - before, count / (after - before));
6966 /* Wait for a reply... */
6971 /* Return the good/bad news */
6972 return (vam->retval);
6976 api_mpls_ip_bind_unbind (vat_main_t * vam)
6978 unformat_input_t *i = vam->input;
6979 vl_api_mpls_ip_bind_unbind_t *mp;
6980 u32 ip_table_id = 0;
6981 u8 create_table_if_needed = 0;
6984 ip4_address_t v4_address;
6985 ip6_address_t v6_address;
6988 mpls_label_t local_label = MPLS_LABEL_INVALID;
6991 /* Parse args required to build the message */
6992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6994 if (unformat (i, "%U/%d", unformat_ip4_address,
6995 &v4_address, &address_length))
7000 else if (unformat (i, "%U/%d", unformat_ip6_address,
7001 &v6_address, &address_length))
7006 else if (unformat (i, "%d", &local_label))
7008 else if (unformat (i, "create-table"))
7009 create_table_if_needed = 1;
7010 else if (unformat (i, "table-id %d", &ip_table_id))
7012 else if (unformat (i, "unbind"))
7014 else if (unformat (i, "bind"))
7018 clib_warning ("parse error '%U'", format_unformat_error, i);
7025 errmsg ("IP addres not set");
7029 if (MPLS_LABEL_INVALID == local_label)
7031 errmsg ("missing label");
7035 /* Construct the API message */
7036 M (MPLS_IP_BIND_UNBIND, mp);
7038 mp->mb_create_table_if_needed = create_table_if_needed;
7039 mp->mb_is_bind = is_bind;
7040 mp->mb_is_ip4 = is_ip4;
7041 mp->mb_ip_table_id = ntohl (ip_table_id);
7042 mp->mb_mpls_table_id = 0;
7043 mp->mb_label = ntohl (local_label);
7044 mp->mb_address_length = address_length;
7047 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7049 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7054 /* Wait for a reply... */
7060 api_proxy_arp_add_del (vat_main_t * vam)
7062 unformat_input_t *i = vam->input;
7063 vl_api_proxy_arp_add_del_t *mp;
7066 ip4_address_t lo, hi;
7070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7072 if (unformat (i, "vrf %d", &vrf_id))
7074 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7075 unformat_ip4_address, &hi))
7077 else if (unformat (i, "del"))
7081 clib_warning ("parse error '%U'", format_unformat_error, i);
7088 errmsg ("address range not set");
7092 M (PROXY_ARP_ADD_DEL, mp);
7094 mp->vrf_id = ntohl (vrf_id);
7095 mp->is_add = is_add;
7096 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7097 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7105 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7107 unformat_input_t *i = vam->input;
7108 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7111 u8 sw_if_index_set = 0;
7114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7116 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7117 sw_if_index_set = 1;
7118 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7119 sw_if_index_set = 1;
7120 else if (unformat (i, "enable"))
7122 else if (unformat (i, "disable"))
7126 clib_warning ("parse error '%U'", format_unformat_error, i);
7131 if (sw_if_index_set == 0)
7133 errmsg ("missing interface name or sw_if_index");
7137 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7139 mp->sw_if_index = ntohl (sw_if_index);
7140 mp->enable_disable = enable;
7148 api_mpls_tunnel_add_del (vat_main_t * vam)
7150 unformat_input_t *i = vam->input;
7151 vl_api_mpls_tunnel_add_del_t *mp;
7155 u32 sw_if_index = ~0;
7156 u32 next_hop_sw_if_index = ~0;
7157 u32 next_hop_proto_is_ip4 = 1;
7159 u32 next_hop_table_id = 0;
7160 ip4_address_t v4_next_hop_address = {
7163 ip6_address_t v6_next_hop_address = { {0} };
7164 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7169 if (unformat (i, "add"))
7171 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7173 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7175 else if (unformat (i, "via %U",
7176 unformat_ip4_address, &v4_next_hop_address))
7178 next_hop_proto_is_ip4 = 1;
7180 else if (unformat (i, "via %U",
7181 unformat_ip6_address, &v6_next_hop_address))
7183 next_hop_proto_is_ip4 = 0;
7185 else if (unformat (i, "l2-only"))
7187 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7189 else if (unformat (i, "out-label %d", &next_hop_out_label))
7190 vec_add1 (labels, ntohl (next_hop_out_label));
7193 clib_warning ("parse error '%U'", format_unformat_error, i);
7198 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7200 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7201 mp->mt_sw_if_index = ntohl (sw_if_index);
7202 mp->mt_is_add = is_add;
7203 mp->mt_l2_only = l2_only;
7204 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7205 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7207 mp->mt_next_hop_n_out_labels = vec_len (labels);
7209 if (0 != mp->mt_next_hop_n_out_labels)
7211 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7212 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7216 if (next_hop_proto_is_ip4)
7218 clib_memcpy (mp->mt_next_hop,
7219 &v4_next_hop_address, sizeof (v4_next_hop_address));
7223 clib_memcpy (mp->mt_next_hop,
7224 &v6_next_hop_address, sizeof (v6_next_hop_address));
7233 api_sw_interface_set_unnumbered (vat_main_t * vam)
7235 unformat_input_t *i = vam->input;
7236 vl_api_sw_interface_set_unnumbered_t *mp;
7238 u32 unnum_sw_index = ~0;
7240 u8 sw_if_index_set = 0;
7243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7246 sw_if_index_set = 1;
7247 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7248 sw_if_index_set = 1;
7249 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7251 else if (unformat (i, "del"))
7255 clib_warning ("parse error '%U'", format_unformat_error, i);
7260 if (sw_if_index_set == 0)
7262 errmsg ("missing interface name or sw_if_index");
7266 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7268 mp->sw_if_index = ntohl (sw_if_index);
7269 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7270 mp->is_add = is_add;
7278 api_ip_neighbor_add_del (vat_main_t * vam)
7280 unformat_input_t *i = vam->input;
7281 vl_api_ip_neighbor_add_del_t *mp;
7283 u8 sw_if_index_set = 0;
7289 u8 v4_address_set = 0;
7290 u8 v6_address_set = 0;
7291 ip4_address_t v4address;
7292 ip6_address_t v6address;
7295 memset (mac_address, 0, sizeof (mac_address));
7297 /* Parse args required to build the message */
7298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7300 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7304 else if (unformat (i, "del"))
7307 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7308 sw_if_index_set = 1;
7309 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7310 sw_if_index_set = 1;
7311 else if (unformat (i, "is_static"))
7313 else if (unformat (i, "vrf %d", &vrf_id))
7315 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7317 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7321 clib_warning ("parse error '%U'", format_unformat_error, i);
7326 if (sw_if_index_set == 0)
7328 errmsg ("missing interface name or sw_if_index");
7331 if (v4_address_set && v6_address_set)
7333 errmsg ("both v4 and v6 addresses set");
7336 if (!v4_address_set && !v6_address_set)
7338 errmsg ("no address set");
7342 /* Construct the API message */
7343 M (IP_NEIGHBOR_ADD_DEL, mp);
7345 mp->sw_if_index = ntohl (sw_if_index);
7346 mp->is_add = is_add;
7347 mp->vrf_id = ntohl (vrf_id);
7348 mp->is_static = is_static;
7350 clib_memcpy (mp->mac_address, mac_address, 6);
7354 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7358 /* mp->is_ipv6 = 0; via memset in M macro above */
7359 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7365 /* Wait for a reply, return good/bad news */
7371 api_reset_vrf (vat_main_t * vam)
7373 unformat_input_t *i = vam->input;
7374 vl_api_reset_vrf_t *mp;
7380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7382 if (unformat (i, "vrf %d", &vrf_id))
7384 else if (unformat (i, "ipv6"))
7388 clib_warning ("parse error '%U'", format_unformat_error, i);
7393 if (vrf_id_set == 0)
7395 errmsg ("missing vrf id");
7401 mp->vrf_id = ntohl (vrf_id);
7402 mp->is_ipv6 = is_ipv6;
7410 api_create_vlan_subif (vat_main_t * vam)
7412 unformat_input_t *i = vam->input;
7413 vl_api_create_vlan_subif_t *mp;
7415 u8 sw_if_index_set = 0;
7420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7422 if (unformat (i, "sw_if_index %d", &sw_if_index))
7423 sw_if_index_set = 1;
7425 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7426 sw_if_index_set = 1;
7427 else if (unformat (i, "vlan %d", &vlan_id))
7431 clib_warning ("parse error '%U'", format_unformat_error, i);
7436 if (sw_if_index_set == 0)
7438 errmsg ("missing interface name or sw_if_index");
7442 if (vlan_id_set == 0)
7444 errmsg ("missing vlan_id");
7447 M (CREATE_VLAN_SUBIF, mp);
7449 mp->sw_if_index = ntohl (sw_if_index);
7450 mp->vlan_id = ntohl (vlan_id);
7457 #define foreach_create_subif_bit \
7464 _(outer_vlan_id_any) \
7465 _(inner_vlan_id_any)
7468 api_create_subif (vat_main_t * vam)
7470 unformat_input_t *i = vam->input;
7471 vl_api_create_subif_t *mp;
7473 u8 sw_if_index_set = 0;
7480 u32 exact_match = 0;
7481 u32 default_sub = 0;
7482 u32 outer_vlan_id_any = 0;
7483 u32 inner_vlan_id_any = 0;
7485 u16 outer_vlan_id = 0;
7486 u16 inner_vlan_id = 0;
7489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7491 if (unformat (i, "sw_if_index %d", &sw_if_index))
7492 sw_if_index_set = 1;
7494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7495 sw_if_index_set = 1;
7496 else if (unformat (i, "sub_id %d", &sub_id))
7498 else if (unformat (i, "outer_vlan_id %d", &tmp))
7499 outer_vlan_id = tmp;
7500 else if (unformat (i, "inner_vlan_id %d", &tmp))
7501 inner_vlan_id = tmp;
7503 #define _(a) else if (unformat (i, #a)) a = 1 ;
7504 foreach_create_subif_bit
7508 clib_warning ("parse error '%U'", format_unformat_error, i);
7513 if (sw_if_index_set == 0)
7515 errmsg ("missing interface name or sw_if_index");
7519 if (sub_id_set == 0)
7521 errmsg ("missing sub_id");
7524 M (CREATE_SUBIF, mp);
7526 mp->sw_if_index = ntohl (sw_if_index);
7527 mp->sub_id = ntohl (sub_id);
7529 #define _(a) mp->a = a;
7530 foreach_create_subif_bit;
7533 mp->outer_vlan_id = ntohs (outer_vlan_id);
7534 mp->inner_vlan_id = ntohs (inner_vlan_id);
7542 api_oam_add_del (vat_main_t * vam)
7544 unformat_input_t *i = vam->input;
7545 vl_api_oam_add_del_t *mp;
7548 ip4_address_t src, dst;
7553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7555 if (unformat (i, "vrf %d", &vrf_id))
7557 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7559 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7561 else if (unformat (i, "del"))
7565 clib_warning ("parse error '%U'", format_unformat_error, i);
7572 errmsg ("missing src addr");
7578 errmsg ("missing dst addr");
7582 M (OAM_ADD_DEL, mp);
7584 mp->vrf_id = ntohl (vrf_id);
7585 mp->is_add = is_add;
7586 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7587 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7595 api_reset_fib (vat_main_t * vam)
7597 unformat_input_t *i = vam->input;
7598 vl_api_reset_fib_t *mp;
7604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7606 if (unformat (i, "vrf %d", &vrf_id))
7608 else if (unformat (i, "ipv6"))
7612 clib_warning ("parse error '%U'", format_unformat_error, i);
7617 if (vrf_id_set == 0)
7619 errmsg ("missing vrf id");
7625 mp->vrf_id = ntohl (vrf_id);
7626 mp->is_ipv6 = is_ipv6;
7634 api_dhcp_proxy_config (vat_main_t * vam)
7636 unformat_input_t *i = vam->input;
7637 vl_api_dhcp_proxy_config_t *mp;
7641 u8 v4_address_set = 0;
7642 u8 v6_address_set = 0;
7643 ip4_address_t v4address;
7644 ip6_address_t v6address;
7645 u8 v4_src_address_set = 0;
7646 u8 v6_src_address_set = 0;
7647 ip4_address_t v4srcaddress;
7648 ip6_address_t v6srcaddress;
7651 /* Parse args required to build the message */
7652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7654 if (unformat (i, "del"))
7656 else if (unformat (i, "vrf %d", &vrf_id))
7658 else if (unformat (i, "insert-cid %d", &insert_cid))
7660 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7662 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7664 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7665 v4_src_address_set = 1;
7666 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7667 v6_src_address_set = 1;
7672 if (v4_address_set && v6_address_set)
7674 errmsg ("both v4 and v6 server addresses set");
7677 if (!v4_address_set && !v6_address_set)
7679 errmsg ("no server addresses set");
7683 if (v4_src_address_set && v6_src_address_set)
7685 errmsg ("both v4 and v6 src addresses set");
7688 if (!v4_src_address_set && !v6_src_address_set)
7690 errmsg ("no src addresses set");
7694 if (!(v4_src_address_set && v4_address_set) &&
7695 !(v6_src_address_set && v6_address_set))
7697 errmsg ("no matching server and src addresses set");
7701 /* Construct the API message */
7702 M (DHCP_PROXY_CONFIG, mp);
7704 mp->insert_circuit_id = insert_cid;
7705 mp->is_add = is_add;
7706 mp->vrf_id = ntohl (vrf_id);
7710 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7711 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7715 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7716 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7722 /* Wait for a reply, return good/bad news */
7728 api_dhcp_proxy_config_2 (vat_main_t * vam)
7730 unformat_input_t *i = vam->input;
7731 vl_api_dhcp_proxy_config_2_t *mp;
7733 u32 server_vrf_id = 0;
7736 u8 v4_address_set = 0;
7737 u8 v6_address_set = 0;
7738 ip4_address_t v4address;
7739 ip6_address_t v6address;
7740 u8 v4_src_address_set = 0;
7741 u8 v6_src_address_set = 0;
7742 ip4_address_t v4srcaddress;
7743 ip6_address_t v6srcaddress;
7746 /* Parse args required to build the message */
7747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7749 if (unformat (i, "del"))
7751 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7753 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7755 else if (unformat (i, "insert-cid %d", &insert_cid))
7757 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7759 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7761 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7762 v4_src_address_set = 1;
7763 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7764 v6_src_address_set = 1;
7769 if (v4_address_set && v6_address_set)
7771 errmsg ("both v4 and v6 server addresses set");
7774 if (!v4_address_set && !v6_address_set)
7776 errmsg ("no server addresses set");
7780 if (v4_src_address_set && v6_src_address_set)
7782 errmsg ("both v4 and v6 src addresses set");
7785 if (!v4_src_address_set && !v6_src_address_set)
7787 errmsg ("no src addresses set");
7791 if (!(v4_src_address_set && v4_address_set) &&
7792 !(v6_src_address_set && v6_address_set))
7794 errmsg ("no matching server and src addresses set");
7798 /* Construct the API message */
7799 M (DHCP_PROXY_CONFIG_2, mp);
7801 mp->insert_circuit_id = insert_cid;
7802 mp->is_add = is_add;
7803 mp->rx_vrf_id = ntohl (rx_vrf_id);
7804 mp->server_vrf_id = ntohl (server_vrf_id);
7808 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7809 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7813 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7814 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7820 /* Wait for a reply, return good/bad news */
7826 api_dhcp_proxy_set_vss (vat_main_t * vam)
7828 unformat_input_t *i = vam->input;
7829 vl_api_dhcp_proxy_set_vss_t *mp;
7840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7842 if (unformat (i, "tbl_id %d", &tbl_id))
7844 if (unformat (i, "fib_id %d", &fib_id))
7846 if (unformat (i, "oui %d", &oui))
7848 else if (unformat (i, "ipv6"))
7850 else if (unformat (i, "del"))
7854 clib_warning ("parse error '%U'", format_unformat_error, i);
7859 if (tbl_id_set == 0)
7861 errmsg ("missing tbl id");
7865 if (fib_id_set == 0)
7867 errmsg ("missing fib id");
7872 errmsg ("missing oui");
7876 M (DHCP_PROXY_SET_VSS, mp);
7877 mp->tbl_id = ntohl (tbl_id);
7878 mp->fib_id = ntohl (fib_id);
7879 mp->oui = ntohl (oui);
7880 mp->is_ipv6 = is_ipv6;
7881 mp->is_add = is_add;
7889 api_dhcp_client_config (vat_main_t * vam)
7891 unformat_input_t *i = vam->input;
7892 vl_api_dhcp_client_config_t *mp;
7894 u8 sw_if_index_set = 0;
7897 u8 disable_event = 0;
7900 /* Parse args required to build the message */
7901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7903 if (unformat (i, "del"))
7906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7907 sw_if_index_set = 1;
7908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7909 sw_if_index_set = 1;
7910 else if (unformat (i, "hostname %s", &hostname))
7912 else if (unformat (i, "disable_event"))
7918 if (sw_if_index_set == 0)
7920 errmsg ("missing interface name or sw_if_index");
7924 if (vec_len (hostname) > 63)
7926 errmsg ("hostname too long");
7928 vec_add1 (hostname, 0);
7930 /* Construct the API message */
7931 M (DHCP_CLIENT_CONFIG, mp);
7933 mp->sw_if_index = ntohl (sw_if_index);
7934 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7935 vec_free (hostname);
7936 mp->is_add = is_add;
7937 mp->want_dhcp_event = disable_event ? 0 : 1;
7938 mp->pid = getpid ();
7943 /* Wait for a reply, return good/bad news */
7949 api_set_ip_flow_hash (vat_main_t * vam)
7951 unformat_input_t *i = vam->input;
7952 vl_api_set_ip_flow_hash_t *mp;
7964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7966 if (unformat (i, "vrf %d", &vrf_id))
7968 else if (unformat (i, "ipv6"))
7970 else if (unformat (i, "src"))
7972 else if (unformat (i, "dst"))
7974 else if (unformat (i, "sport"))
7976 else if (unformat (i, "dport"))
7978 else if (unformat (i, "proto"))
7980 else if (unformat (i, "reverse"))
7985 clib_warning ("parse error '%U'", format_unformat_error, i);
7990 if (vrf_id_set == 0)
7992 errmsg ("missing vrf id");
7996 M (SET_IP_FLOW_HASH, mp);
8002 mp->reverse = reverse;
8003 mp->vrf_id = ntohl (vrf_id);
8004 mp->is_ipv6 = is_ipv6;
8012 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8014 unformat_input_t *i = vam->input;
8015 vl_api_sw_interface_ip6_enable_disable_t *mp;
8017 u8 sw_if_index_set = 0;
8021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8023 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8024 sw_if_index_set = 1;
8025 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8026 sw_if_index_set = 1;
8027 else if (unformat (i, "enable"))
8029 else if (unformat (i, "disable"))
8033 clib_warning ("parse error '%U'", format_unformat_error, i);
8038 if (sw_if_index_set == 0)
8040 errmsg ("missing interface name or sw_if_index");
8044 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8046 mp->sw_if_index = ntohl (sw_if_index);
8047 mp->enable = enable;
8055 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8057 unformat_input_t *i = vam->input;
8058 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8060 u8 sw_if_index_set = 0;
8061 u8 v6_address_set = 0;
8062 ip6_address_t v6address;
8065 /* Parse args required to build the message */
8066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8068 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8069 sw_if_index_set = 1;
8070 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8071 sw_if_index_set = 1;
8072 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8078 if (sw_if_index_set == 0)
8080 errmsg ("missing interface name or sw_if_index");
8083 if (!v6_address_set)
8085 errmsg ("no address set");
8089 /* Construct the API message */
8090 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8092 mp->sw_if_index = ntohl (sw_if_index);
8093 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8098 /* Wait for a reply, return good/bad news */
8105 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8107 unformat_input_t *i = vam->input;
8108 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8110 u8 sw_if_index_set = 0;
8111 u32 address_length = 0;
8112 u8 v6_address_set = 0;
8113 ip6_address_t v6address;
8115 u8 no_advertise = 0;
8117 u8 no_autoconfig = 0;
8120 u32 val_lifetime = 0;
8121 u32 pref_lifetime = 0;
8124 /* Parse args required to build the message */
8125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8127 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8128 sw_if_index_set = 1;
8129 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8130 sw_if_index_set = 1;
8131 else if (unformat (i, "%U/%d",
8132 unformat_ip6_address, &v6address, &address_length))
8134 else if (unformat (i, "val_life %d", &val_lifetime))
8136 else if (unformat (i, "pref_life %d", &pref_lifetime))
8138 else if (unformat (i, "def"))
8140 else if (unformat (i, "noadv"))
8142 else if (unformat (i, "offl"))
8144 else if (unformat (i, "noauto"))
8146 else if (unformat (i, "nolink"))
8148 else if (unformat (i, "isno"))
8152 clib_warning ("parse error '%U'", format_unformat_error, i);
8157 if (sw_if_index_set == 0)
8159 errmsg ("missing interface name or sw_if_index");
8162 if (!v6_address_set)
8164 errmsg ("no address set");
8168 /* Construct the API message */
8169 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8171 mp->sw_if_index = ntohl (sw_if_index);
8172 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8173 mp->address_length = address_length;
8174 mp->use_default = use_default;
8175 mp->no_advertise = no_advertise;
8176 mp->off_link = off_link;
8177 mp->no_autoconfig = no_autoconfig;
8178 mp->no_onlink = no_onlink;
8180 mp->val_lifetime = ntohl (val_lifetime);
8181 mp->pref_lifetime = ntohl (pref_lifetime);
8186 /* Wait for a reply, return good/bad news */
8192 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8194 unformat_input_t *i = vam->input;
8195 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8197 u8 sw_if_index_set = 0;
8202 u8 send_unicast = 0;
8205 u8 default_router = 0;
8206 u32 max_interval = 0;
8207 u32 min_interval = 0;
8209 u32 initial_count = 0;
8210 u32 initial_interval = 0;
8214 /* Parse args required to build the message */
8215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8217 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8218 sw_if_index_set = 1;
8219 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8220 sw_if_index_set = 1;
8221 else if (unformat (i, "maxint %d", &max_interval))
8223 else if (unformat (i, "minint %d", &min_interval))
8225 else if (unformat (i, "life %d", &lifetime))
8227 else if (unformat (i, "count %d", &initial_count))
8229 else if (unformat (i, "interval %d", &initial_interval))
8231 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8233 else if (unformat (i, "managed"))
8235 else if (unformat (i, "other"))
8237 else if (unformat (i, "ll"))
8239 else if (unformat (i, "send"))
8241 else if (unformat (i, "cease"))
8243 else if (unformat (i, "isno"))
8245 else if (unformat (i, "def"))
8249 clib_warning ("parse error '%U'", format_unformat_error, i);
8254 if (sw_if_index_set == 0)
8256 errmsg ("missing interface name or sw_if_index");
8260 /* Construct the API message */
8261 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8263 mp->sw_if_index = ntohl (sw_if_index);
8264 mp->max_interval = ntohl (max_interval);
8265 mp->min_interval = ntohl (min_interval);
8266 mp->lifetime = ntohl (lifetime);
8267 mp->initial_count = ntohl (initial_count);
8268 mp->initial_interval = ntohl (initial_interval);
8269 mp->suppress = suppress;
8270 mp->managed = managed;
8272 mp->ll_option = ll_option;
8273 mp->send_unicast = send_unicast;
8276 mp->default_router = default_router;
8281 /* Wait for a reply, return good/bad news */
8287 api_set_arp_neighbor_limit (vat_main_t * vam)
8289 unformat_input_t *i = vam->input;
8290 vl_api_set_arp_neighbor_limit_t *mp;
8296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8298 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8300 else if (unformat (i, "ipv6"))
8304 clib_warning ("parse error '%U'", format_unformat_error, i);
8311 errmsg ("missing limit value");
8315 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8317 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8318 mp->is_ipv6 = is_ipv6;
8326 api_l2_patch_add_del (vat_main_t * vam)
8328 unformat_input_t *i = vam->input;
8329 vl_api_l2_patch_add_del_t *mp;
8331 u8 rx_sw_if_index_set = 0;
8333 u8 tx_sw_if_index_set = 0;
8337 /* Parse args required to build the message */
8338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8340 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8341 rx_sw_if_index_set = 1;
8342 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8343 tx_sw_if_index_set = 1;
8344 else if (unformat (i, "rx"))
8346 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8348 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8350 rx_sw_if_index_set = 1;
8355 else if (unformat (i, "tx"))
8357 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8359 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8361 tx_sw_if_index_set = 1;
8366 else if (unformat (i, "del"))
8372 if (rx_sw_if_index_set == 0)
8374 errmsg ("missing rx interface name or rx_sw_if_index");
8378 if (tx_sw_if_index_set == 0)
8380 errmsg ("missing tx interface name or tx_sw_if_index");
8384 M (L2_PATCH_ADD_DEL, mp);
8386 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8387 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8388 mp->is_add = is_add;
8396 api_ioam_enable (vat_main_t * vam)
8398 unformat_input_t *input = vam->input;
8399 vl_api_ioam_enable_t *mp;
8401 int has_trace_option = 0;
8402 int has_pot_option = 0;
8403 int has_seqno_option = 0;
8404 int has_analyse_option = 0;
8407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8409 if (unformat (input, "trace"))
8410 has_trace_option = 1;
8411 else if (unformat (input, "pot"))
8413 else if (unformat (input, "seqno"))
8414 has_seqno_option = 1;
8415 else if (unformat (input, "analyse"))
8416 has_analyse_option = 1;
8420 M (IOAM_ENABLE, mp);
8421 mp->id = htons (id);
8422 mp->seqno = has_seqno_option;
8423 mp->analyse = has_analyse_option;
8424 mp->pot_enable = has_pot_option;
8425 mp->trace_enable = has_trace_option;
8434 api_ioam_disable (vat_main_t * vam)
8436 vl_api_ioam_disable_t *mp;
8439 M (IOAM_DISABLE, mp);
8446 api_sr_tunnel_add_del (vat_main_t * vam)
8448 unformat_input_t *i = vam->input;
8449 vl_api_sr_tunnel_add_del_t *mp;
8452 ip6_address_t src_address;
8453 int src_address_set = 0;
8454 ip6_address_t dst_address;
8456 int dst_address_set = 0;
8458 u32 rx_table_id = 0;
8459 u32 tx_table_id = 0;
8460 ip6_address_t *segments = 0;
8461 ip6_address_t *this_seg;
8462 ip6_address_t *tags = 0;
8463 ip6_address_t *this_tag;
8464 ip6_address_t next_address, tag;
8466 u8 *policy_name = 0;
8469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8471 if (unformat (i, "del"))
8473 else if (unformat (i, "name %s", &name))
8475 else if (unformat (i, "policy %s", &policy_name))
8477 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8479 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8481 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8482 src_address_set = 1;
8483 else if (unformat (i, "dst %U/%d",
8484 unformat_ip6_address, &dst_address, &dst_mask_width))
8485 dst_address_set = 1;
8486 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8488 vec_add2 (segments, this_seg, 1);
8489 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8490 sizeof (*this_seg));
8492 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8494 vec_add2 (tags, this_tag, 1);
8495 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8497 else if (unformat (i, "clean"))
8498 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8499 else if (unformat (i, "protected"))
8500 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8501 else if (unformat (i, "InPE %d", &pl_index))
8503 if (pl_index <= 0 || pl_index > 4)
8505 pl_index_range_error:
8506 errmsg ("pl index %d out of range", pl_index);
8510 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8512 else if (unformat (i, "EgPE %d", &pl_index))
8514 if (pl_index <= 0 || pl_index > 4)
8515 goto pl_index_range_error;
8517 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8519 else if (unformat (i, "OrgSrc %d", &pl_index))
8521 if (pl_index <= 0 || pl_index > 4)
8522 goto pl_index_range_error;
8524 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8530 if (!src_address_set)
8532 errmsg ("src address required");
8536 if (!dst_address_set)
8538 errmsg ("dst address required");
8544 errmsg ("at least one sr segment required");
8548 M2 (SR_TUNNEL_ADD_DEL, mp,
8549 vec_len (segments) * sizeof (ip6_address_t)
8550 + vec_len (tags) * sizeof (ip6_address_t));
8552 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8553 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8554 mp->dst_mask_width = dst_mask_width;
8555 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8556 mp->n_segments = vec_len (segments);
8557 mp->n_tags = vec_len (tags);
8558 mp->is_add = is_del == 0;
8559 clib_memcpy (mp->segs_and_tags, segments,
8560 vec_len (segments) * sizeof (ip6_address_t));
8561 clib_memcpy (mp->segs_and_tags +
8562 vec_len (segments) * sizeof (ip6_address_t), tags,
8563 vec_len (tags) * sizeof (ip6_address_t));
8565 mp->outer_vrf_id = ntohl (rx_table_id);
8566 mp->inner_vrf_id = ntohl (tx_table_id);
8567 memcpy (mp->name, name, vec_len (name));
8568 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8570 vec_free (segments);
8579 api_sr_policy_add_del (vat_main_t * vam)
8581 unformat_input_t *input = vam->input;
8582 vl_api_sr_policy_add_del_t *mp;
8585 u8 *tunnel_name = 0;
8586 u8 **tunnel_names = 0;
8591 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8592 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8597 if (unformat (input, "del"))
8599 else if (unformat (input, "name %s", &name))
8601 else if (unformat (input, "tunnel %s", &tunnel_name))
8605 vec_add1 (tunnel_names, tunnel_name);
8607 - length = #bytes to store in serial vector
8608 - +1 = byte to store that length
8610 tunnel_names_length += (vec_len (tunnel_name) + 1);
8621 errmsg ("policy name required");
8625 if ((!tunnel_set) && (!is_del))
8627 errmsg ("tunnel name required");
8631 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8635 mp->is_add = !is_del;
8637 memcpy (mp->name, name, vec_len (name));
8638 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8639 u8 *serial_orig = 0;
8640 vec_validate (serial_orig, tunnel_names_length);
8641 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8642 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8644 for (j = 0; j < vec_len (tunnel_names); j++)
8646 tun_name_len = vec_len (tunnel_names[j]);
8647 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8648 serial_orig += 1; // Move along one byte to store the actual tunnel name
8649 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8650 serial_orig += tun_name_len; // Advance past the copy
8652 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8654 vec_free (tunnel_names);
8655 vec_free (tunnel_name);
8663 api_sr_multicast_map_add_del (vat_main_t * vam)
8665 unformat_input_t *input = vam->input;
8666 vl_api_sr_multicast_map_add_del_t *mp;
8668 ip6_address_t multicast_address;
8669 u8 *policy_name = 0;
8670 int multicast_address_set = 0;
8673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8675 if (unformat (input, "del"))
8679 (input, "address %U", unformat_ip6_address, &multicast_address))
8680 multicast_address_set = 1;
8681 else if (unformat (input, "sr-policy %s", &policy_name))
8687 if (!is_del && !policy_name)
8689 errmsg ("sr-policy name required");
8694 if (!multicast_address_set)
8696 errmsg ("address required");
8700 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8702 mp->is_add = !is_del;
8703 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8704 clib_memcpy (mp->multicast_address, &multicast_address,
8705 sizeof (mp->multicast_address));
8708 vec_free (policy_name);
8716 #define foreach_tcp_proto_field \
8720 #define foreach_udp_proto_field \
8724 #define foreach_ip4_proto_field \
8735 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8737 u8 **maskp = va_arg (*args, u8 **);
8739 u8 found_something = 0;
8742 #define _(a) u8 a=0;
8743 foreach_tcp_proto_field;
8746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8749 #define _(a) else if (unformat (input, #a)) a=1;
8750 foreach_tcp_proto_field
8756 #define _(a) found_something += a;
8757 foreach_tcp_proto_field;
8760 if (found_something == 0)
8763 vec_validate (mask, sizeof (*tcp) - 1);
8765 tcp = (tcp_header_t *) mask;
8767 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8768 foreach_tcp_proto_field;
8776 unformat_udp_mask (unformat_input_t * input, va_list * args)
8778 u8 **maskp = va_arg (*args, u8 **);
8780 u8 found_something = 0;
8783 #define _(a) u8 a=0;
8784 foreach_udp_proto_field;
8787 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8790 #define _(a) else if (unformat (input, #a)) a=1;
8791 foreach_udp_proto_field
8797 #define _(a) found_something += a;
8798 foreach_udp_proto_field;
8801 if (found_something == 0)
8804 vec_validate (mask, sizeof (*udp) - 1);
8806 udp = (udp_header_t *) mask;
8808 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8809 foreach_udp_proto_field;
8818 u16 src_port, dst_port;
8822 unformat_l4_mask (unformat_input_t * input, va_list * args)
8824 u8 **maskp = va_arg (*args, u8 **);
8825 u16 src_port = 0, dst_port = 0;
8826 tcpudp_header_t *tcpudp;
8828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8830 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8832 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8834 else if (unformat (input, "src_port"))
8836 else if (unformat (input, "dst_port"))
8842 if (!src_port && !dst_port)
8846 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8848 tcpudp = (tcpudp_header_t *) mask;
8849 tcpudp->src_port = src_port;
8850 tcpudp->dst_port = dst_port;
8858 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8860 u8 **maskp = va_arg (*args, u8 **);
8862 u8 found_something = 0;
8865 #define _(a) u8 a=0;
8866 foreach_ip4_proto_field;
8872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8874 if (unformat (input, "version"))
8876 else if (unformat (input, "hdr_length"))
8878 else if (unformat (input, "src"))
8880 else if (unformat (input, "dst"))
8882 else if (unformat (input, "proto"))
8885 #define _(a) else if (unformat (input, #a)) a=1;
8886 foreach_ip4_proto_field
8892 #define _(a) found_something += a;
8893 foreach_ip4_proto_field;
8896 if (found_something == 0)
8899 vec_validate (mask, sizeof (*ip) - 1);
8901 ip = (ip4_header_t *) mask;
8903 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8904 foreach_ip4_proto_field;
8907 ip->ip_version_and_header_length = 0;
8910 ip->ip_version_and_header_length |= 0xF0;
8913 ip->ip_version_and_header_length |= 0x0F;
8919 #define foreach_ip6_proto_field \
8927 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8929 u8 **maskp = va_arg (*args, u8 **);
8931 u8 found_something = 0;
8933 u32 ip_version_traffic_class_and_flow_label;
8935 #define _(a) u8 a=0;
8936 foreach_ip6_proto_field;
8939 u8 traffic_class = 0;
8942 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8944 if (unformat (input, "version"))
8946 else if (unformat (input, "traffic-class"))
8948 else if (unformat (input, "flow-label"))
8950 else if (unformat (input, "src"))
8952 else if (unformat (input, "dst"))
8954 else if (unformat (input, "proto"))
8957 #define _(a) else if (unformat (input, #a)) a=1;
8958 foreach_ip6_proto_field
8964 #define _(a) found_something += a;
8965 foreach_ip6_proto_field;
8968 if (found_something == 0)
8971 vec_validate (mask, sizeof (*ip) - 1);
8973 ip = (ip6_header_t *) mask;
8975 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8976 foreach_ip6_proto_field;
8979 ip_version_traffic_class_and_flow_label = 0;
8982 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8985 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8988 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8990 ip->ip_version_traffic_class_and_flow_label =
8991 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8998 unformat_l3_mask (unformat_input_t * input, va_list * args)
9000 u8 **maskp = va_arg (*args, u8 **);
9002 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9004 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9006 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9015 unformat_l2_mask (unformat_input_t * input, va_list * args)
9017 u8 **maskp = va_arg (*args, u8 **);
9032 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9034 if (unformat (input, "src"))
9036 else if (unformat (input, "dst"))
9038 else if (unformat (input, "proto"))
9040 else if (unformat (input, "tag1"))
9042 else if (unformat (input, "tag2"))
9044 else if (unformat (input, "ignore-tag1"))
9046 else if (unformat (input, "ignore-tag2"))
9048 else if (unformat (input, "cos1"))
9050 else if (unformat (input, "cos2"))
9052 else if (unformat (input, "dot1q"))
9054 else if (unformat (input, "dot1ad"))
9059 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9060 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9063 if (tag1 || ignore_tag1 || cos1 || dot1q)
9065 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9068 vec_validate (mask, len - 1);
9071 memset (mask, 0xff, 6);
9074 memset (mask + 6, 0xff, 6);
9078 /* inner vlan tag */
9087 mask[21] = mask[20] = 0xff;
9108 mask[16] = mask[17] = 0xff;
9118 mask[12] = mask[13] = 0xff;
9125 unformat_classify_mask (unformat_input_t * input, va_list * args)
9127 u8 **maskp = va_arg (*args, u8 **);
9128 u32 *skipp = va_arg (*args, u32 *);
9129 u32 *matchp = va_arg (*args, u32 *);
9137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9139 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9141 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9143 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9145 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9159 if (mask || l2 || l3 || l4)
9163 /* "With a free Ethernet header in every package" */
9165 vec_validate (l2, 13);
9169 vec_append (mask, l3);
9174 vec_append (mask, l4);
9179 /* Scan forward looking for the first significant mask octet */
9180 for (i = 0; i < vec_len (mask); i++)
9184 /* compute (skip, match) params */
9185 *skipp = i / sizeof (u32x4);
9186 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9188 /* Pad mask to an even multiple of the vector size */
9189 while (vec_len (mask) % sizeof (u32x4))
9192 match = vec_len (mask) / sizeof (u32x4);
9194 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9196 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9197 if (*tmp || *(tmp + 1))
9202 clib_warning ("BUG: match 0");
9204 _vec_len (mask) = match * sizeof (u32x4);
9215 #define foreach_l2_next \
9217 _(ethernet, ETHERNET_INPUT) \
9222 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9224 u32 *miss_next_indexp = va_arg (*args, u32 *);
9229 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9233 if (unformat (input, "%d", &tmp))
9242 *miss_next_indexp = next_index;
9246 #define foreach_ip_next \
9252 unformat_ip_next_index (unformat_input_t * input, va_list * args)
9254 u32 *miss_next_indexp = va_arg (*args, u32 *);
9259 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9263 if (unformat (input, "%d", &tmp))
9272 *miss_next_indexp = next_index;
9276 #define foreach_acl_next \
9280 unformat_acl_next_index (unformat_input_t * input, va_list * args)
9282 u32 *miss_next_indexp = va_arg (*args, u32 *);
9287 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9291 if (unformat (input, "permit"))
9296 else if (unformat (input, "%d", &tmp))
9305 *miss_next_indexp = next_index;
9310 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9312 u32 *r = va_arg (*args, u32 *);
9314 if (unformat (input, "conform-color"))
9315 *r = POLICE_CONFORM;
9316 else if (unformat (input, "exceed-color"))
9325 api_classify_add_del_table (vat_main_t * vam)
9327 unformat_input_t *i = vam->input;
9328 vl_api_classify_add_del_table_t *mp;
9335 u32 table_index = ~0;
9336 u32 next_table_index = ~0;
9337 u32 miss_next_index = ~0;
9338 u32 memory_size = 32 << 20;
9340 u32 current_data_flag = 0;
9341 int current_data_offset = 0;
9344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9346 if (unformat (i, "del"))
9348 else if (unformat (i, "del-chain"))
9353 else if (unformat (i, "buckets %d", &nbuckets))
9355 else if (unformat (i, "memory_size %d", &memory_size))
9357 else if (unformat (i, "skip %d", &skip))
9359 else if (unformat (i, "match %d", &match))
9361 else if (unformat (i, "table %d", &table_index))
9363 else if (unformat (i, "mask %U", unformat_classify_mask,
9364 &mask, &skip, &match))
9366 else if (unformat (i, "next-table %d", &next_table_index))
9368 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
9371 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9374 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9377 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9379 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9385 if (is_add && mask == 0)
9387 errmsg ("Mask required");
9391 if (is_add && skip == ~0)
9393 errmsg ("skip count required");
9397 if (is_add && match == ~0)
9399 errmsg ("match count required");
9403 if (!is_add && table_index == ~0)
9405 errmsg ("table index required for delete");
9409 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9411 mp->is_add = is_add;
9412 mp->del_chain = del_chain;
9413 mp->table_index = ntohl (table_index);
9414 mp->nbuckets = ntohl (nbuckets);
9415 mp->memory_size = ntohl (memory_size);
9416 mp->skip_n_vectors = ntohl (skip);
9417 mp->match_n_vectors = ntohl (match);
9418 mp->next_table_index = ntohl (next_table_index);
9419 mp->miss_next_index = ntohl (miss_next_index);
9420 mp->current_data_flag = ntohl (current_data_flag);
9421 mp->current_data_offset = ntohl (current_data_offset);
9422 clib_memcpy (mp->mask, mask, vec_len (mask));
9432 unformat_l4_match (unformat_input_t * input, va_list * args)
9434 u8 **matchp = va_arg (*args, u8 **);
9436 u8 *proto_header = 0;
9442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9444 if (unformat (input, "src_port %d", &src_port))
9446 else if (unformat (input, "dst_port %d", &dst_port))
9452 h.src_port = clib_host_to_net_u16 (src_port);
9453 h.dst_port = clib_host_to_net_u16 (dst_port);
9454 vec_validate (proto_header, sizeof (h) - 1);
9455 memcpy (proto_header, &h, sizeof (h));
9457 *matchp = proto_header;
9463 unformat_ip4_match (unformat_input_t * input, va_list * args)
9465 u8 **matchp = va_arg (*args, u8 **);
9472 int src = 0, dst = 0;
9473 ip4_address_t src_val, dst_val;
9480 int fragment_id = 0;
9481 u32 fragment_id_val;
9487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9489 if (unformat (input, "version %d", &version_val))
9491 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9493 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9495 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9497 else if (unformat (input, "proto %d", &proto_val))
9499 else if (unformat (input, "tos %d", &tos_val))
9501 else if (unformat (input, "length %d", &length_val))
9503 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9505 else if (unformat (input, "ttl %d", &ttl_val))
9507 else if (unformat (input, "checksum %d", &checksum_val))
9513 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9514 + ttl + checksum == 0)
9518 * Aligned because we use the real comparison functions
9520 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9522 ip = (ip4_header_t *) match;
9524 /* These are realistically matched in practice */
9526 ip->src_address.as_u32 = src_val.as_u32;
9529 ip->dst_address.as_u32 = dst_val.as_u32;
9532 ip->protocol = proto_val;
9535 /* These are not, but they're included for completeness */
9537 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9540 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9546 ip->length = clib_host_to_net_u16 (length_val);
9552 ip->checksum = clib_host_to_net_u16 (checksum_val);
9559 unformat_ip6_match (unformat_input_t * input, va_list * args)
9561 u8 **matchp = va_arg (*args, u8 **);
9566 u8 traffic_class = 0;
9567 u32 traffic_class_val = 0;
9570 int src = 0, dst = 0;
9571 ip6_address_t src_val, dst_val;
9574 int payload_length = 0;
9575 u32 payload_length_val;
9578 u32 ip_version_traffic_class_and_flow_label;
9580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9582 if (unformat (input, "version %d", &version_val))
9584 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9586 else if (unformat (input, "flow_label %d", &flow_label_val))
9588 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9590 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9592 else if (unformat (input, "proto %d", &proto_val))
9594 else if (unformat (input, "payload_length %d", &payload_length_val))
9596 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9602 if (version + traffic_class + flow_label + src + dst + proto +
9603 payload_length + hop_limit == 0)
9607 * Aligned because we use the real comparison functions
9609 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9611 ip = (ip6_header_t *) match;
9614 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9617 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9620 ip->protocol = proto_val;
9622 ip_version_traffic_class_and_flow_label = 0;
9625 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9628 ip_version_traffic_class_and_flow_label |=
9629 (traffic_class_val & 0xFF) << 20;
9632 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9634 ip->ip_version_traffic_class_and_flow_label =
9635 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9638 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9641 ip->hop_limit = hop_limit_val;
9648 unformat_l3_match (unformat_input_t * input, va_list * args)
9650 u8 **matchp = va_arg (*args, u8 **);
9652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9654 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9656 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9665 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9667 u8 *tagp = va_arg (*args, u8 *);
9670 if (unformat (input, "%d", &tag))
9672 tagp[0] = (tag >> 8) & 0x0F;
9673 tagp[1] = tag & 0xFF;
9681 unformat_l2_match (unformat_input_t * input, va_list * args)
9683 u8 **matchp = va_arg (*args, u8 **);
9703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9705 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9708 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9710 else if (unformat (input, "proto %U",
9711 unformat_ethernet_type_host_byte_order, &proto_val))
9713 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9715 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9717 else if (unformat (input, "ignore-tag1"))
9719 else if (unformat (input, "ignore-tag2"))
9721 else if (unformat (input, "cos1 %d", &cos1_val))
9723 else if (unformat (input, "cos2 %d", &cos2_val))
9728 if ((src + dst + proto + tag1 + tag2 +
9729 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9732 if (tag1 || ignore_tag1 || cos1)
9734 if (tag2 || ignore_tag2 || cos2)
9737 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9740 clib_memcpy (match, dst_val, 6);
9743 clib_memcpy (match + 6, src_val, 6);
9747 /* inner vlan tag */
9748 match[19] = tag2_val[1];
9749 match[18] = tag2_val[0];
9751 match[18] |= (cos2_val & 0x7) << 5;
9754 match[21] = proto_val & 0xff;
9755 match[20] = proto_val >> 8;
9759 match[15] = tag1_val[1];
9760 match[14] = tag1_val[0];
9763 match[14] |= (cos1_val & 0x7) << 5;
9769 match[15] = tag1_val[1];
9770 match[14] = tag1_val[0];
9773 match[17] = proto_val & 0xff;
9774 match[16] = proto_val >> 8;
9777 match[14] |= (cos1_val & 0x7) << 5;
9783 match[18] |= (cos2_val & 0x7) << 5;
9785 match[14] |= (cos1_val & 0x7) << 5;
9788 match[13] = proto_val & 0xff;
9789 match[12] = proto_val >> 8;
9798 unformat_classify_match (unformat_input_t * input, va_list * args)
9800 u8 **matchp = va_arg (*args, u8 **);
9801 u32 skip_n_vectors = va_arg (*args, u32);
9802 u32 match_n_vectors = va_arg (*args, u32);
9809 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9811 if (unformat (input, "hex %U", unformat_hex_string, &match))
9813 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9815 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9817 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9831 if (match || l2 || l3 || l4)
9835 /* "Win a free Ethernet header in every packet" */
9837 vec_validate_aligned (l2, 13, sizeof (u32x4));
9841 vec_append_aligned (match, l3, sizeof (u32x4));
9846 vec_append_aligned (match, l4, sizeof (u32x4));
9851 /* Make sure the vector is big enough even if key is all 0's */
9852 vec_validate_aligned
9853 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9856 /* Set size, include skipped vectors */
9857 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9868 api_classify_add_del_session (vat_main_t * vam)
9870 unformat_input_t *i = vam->input;
9871 vl_api_classify_add_del_session_t *mp;
9873 u32 table_index = ~0;
9874 u32 hit_next_index = ~0;
9875 u32 opaque_index = ~0;
9878 u32 skip_n_vectors = 0;
9879 u32 match_n_vectors = 0;
9885 * Warning: you have to supply skip_n and match_n
9886 * because the API client cant simply look at the classify
9890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9892 if (unformat (i, "del"))
9894 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9897 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9900 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9903 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9905 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9907 else if (unformat (i, "opaque-index %d", &opaque_index))
9909 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9911 else if (unformat (i, "match_n %d", &match_n_vectors))
9913 else if (unformat (i, "match %U", unformat_classify_match,
9914 &match, skip_n_vectors, match_n_vectors))
9916 else if (unformat (i, "advance %d", &advance))
9918 else if (unformat (i, "table-index %d", &table_index))
9920 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9922 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9924 else if (unformat (i, "action %d", &action))
9926 else if (unformat (i, "metadata %d", &metadata))
9932 if (table_index == ~0)
9934 errmsg ("Table index required");
9938 if (is_add && match == 0)
9940 errmsg ("Match value required");
9944 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9946 mp->is_add = is_add;
9947 mp->table_index = ntohl (table_index);
9948 mp->hit_next_index = ntohl (hit_next_index);
9949 mp->opaque_index = ntohl (opaque_index);
9950 mp->advance = ntohl (advance);
9951 mp->action = action;
9952 mp->metadata = ntohl (metadata);
9953 clib_memcpy (mp->match, match, vec_len (match));
9962 api_classify_set_interface_ip_table (vat_main_t * vam)
9964 unformat_input_t *i = vam->input;
9965 vl_api_classify_set_interface_ip_table_t *mp;
9967 int sw_if_index_set;
9968 u32 table_index = ~0;
9972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9974 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9975 sw_if_index_set = 1;
9976 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9977 sw_if_index_set = 1;
9978 else if (unformat (i, "table %d", &table_index))
9982 clib_warning ("parse error '%U'", format_unformat_error, i);
9987 if (sw_if_index_set == 0)
9989 errmsg ("missing interface name or sw_if_index");
9994 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9996 mp->sw_if_index = ntohl (sw_if_index);
9997 mp->table_index = ntohl (table_index);
9998 mp->is_ipv6 = is_ipv6;
10006 api_classify_set_interface_l2_tables (vat_main_t * vam)
10008 unformat_input_t *i = vam->input;
10009 vl_api_classify_set_interface_l2_tables_t *mp;
10011 int sw_if_index_set;
10012 u32 ip4_table_index = ~0;
10013 u32 ip6_table_index = ~0;
10014 u32 other_table_index = ~0;
10018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10021 sw_if_index_set = 1;
10022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10023 sw_if_index_set = 1;
10024 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10026 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10028 else if (unformat (i, "other-table %d", &other_table_index))
10030 else if (unformat (i, "is-input %d", &is_input))
10034 clib_warning ("parse error '%U'", format_unformat_error, i);
10039 if (sw_if_index_set == 0)
10041 errmsg ("missing interface name or sw_if_index");
10046 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10048 mp->sw_if_index = ntohl (sw_if_index);
10049 mp->ip4_table_index = ntohl (ip4_table_index);
10050 mp->ip6_table_index = ntohl (ip6_table_index);
10051 mp->other_table_index = ntohl (other_table_index);
10052 mp->is_input = (u8) is_input;
10060 api_set_ipfix_exporter (vat_main_t * vam)
10062 unformat_input_t *i = vam->input;
10063 vl_api_set_ipfix_exporter_t *mp;
10064 ip4_address_t collector_address;
10065 u8 collector_address_set = 0;
10066 u32 collector_port = ~0;
10067 ip4_address_t src_address;
10068 u8 src_address_set = 0;
10071 u32 template_interval = ~0;
10072 u8 udp_checksum = 0;
10075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10077 if (unformat (i, "collector_address %U", unformat_ip4_address,
10078 &collector_address))
10079 collector_address_set = 1;
10080 else if (unformat (i, "collector_port %d", &collector_port))
10082 else if (unformat (i, "src_address %U", unformat_ip4_address,
10084 src_address_set = 1;
10085 else if (unformat (i, "vrf_id %d", &vrf_id))
10087 else if (unformat (i, "path_mtu %d", &path_mtu))
10089 else if (unformat (i, "template_interval %d", &template_interval))
10091 else if (unformat (i, "udp_checksum"))
10097 if (collector_address_set == 0)
10099 errmsg ("collector_address required");
10103 if (src_address_set == 0)
10105 errmsg ("src_address required");
10109 M (SET_IPFIX_EXPORTER, mp);
10111 memcpy (mp->collector_address, collector_address.data,
10112 sizeof (collector_address.data));
10113 mp->collector_port = htons ((u16) collector_port);
10114 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10115 mp->vrf_id = htonl (vrf_id);
10116 mp->path_mtu = htonl (path_mtu);
10117 mp->template_interval = htonl (template_interval);
10118 mp->udp_checksum = udp_checksum;
10126 api_set_ipfix_classify_stream (vat_main_t * vam)
10128 unformat_input_t *i = vam->input;
10129 vl_api_set_ipfix_classify_stream_t *mp;
10131 u32 src_port = UDP_DST_PORT_ipfix;
10134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10136 if (unformat (i, "domain %d", &domain_id))
10138 else if (unformat (i, "src_port %d", &src_port))
10142 errmsg ("unknown input `%U'", format_unformat_error, i);
10147 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10149 mp->domain_id = htonl (domain_id);
10150 mp->src_port = htons ((u16) src_port);
10158 api_ipfix_classify_table_add_del (vat_main_t * vam)
10160 unformat_input_t *i = vam->input;
10161 vl_api_ipfix_classify_table_add_del_t *mp;
10163 u32 classify_table_index = ~0;
10165 u8 transport_protocol = 255;
10168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10170 if (unformat (i, "add"))
10172 else if (unformat (i, "del"))
10174 else if (unformat (i, "table %d", &classify_table_index))
10176 else if (unformat (i, "ip4"))
10178 else if (unformat (i, "ip6"))
10180 else if (unformat (i, "tcp"))
10181 transport_protocol = 6;
10182 else if (unformat (i, "udp"))
10183 transport_protocol = 17;
10186 errmsg ("unknown input `%U'", format_unformat_error, i);
10193 errmsg ("expecting: add|del");
10196 if (classify_table_index == ~0)
10198 errmsg ("classifier table not specified");
10201 if (ip_version == 0)
10203 errmsg ("IP version not specified");
10207 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10209 mp->is_add = is_add;
10210 mp->table_id = htonl (classify_table_index);
10211 mp->ip_version = ip_version;
10212 mp->transport_protocol = transport_protocol;
10220 api_get_node_index (vat_main_t * vam)
10222 unformat_input_t *i = vam->input;
10223 vl_api_get_node_index_t *mp;
10227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10229 if (unformat (i, "node %s", &name))
10236 errmsg ("node name required");
10239 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10241 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10245 M (GET_NODE_INDEX, mp);
10246 clib_memcpy (mp->node_name, name, vec_len (name));
10255 api_get_next_index (vat_main_t * vam)
10257 unformat_input_t *i = vam->input;
10258 vl_api_get_next_index_t *mp;
10259 u8 *node_name = 0, *next_node_name = 0;
10262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10264 if (unformat (i, "node-name %s", &node_name))
10266 else if (unformat (i, "next-node-name %s", &next_node_name))
10270 if (node_name == 0)
10272 errmsg ("node name required");
10275 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10277 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10281 if (next_node_name == 0)
10283 errmsg ("next node name required");
10286 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10288 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10292 M (GET_NEXT_INDEX, mp);
10293 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10294 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10295 vec_free (node_name);
10296 vec_free (next_node_name);
10304 api_add_node_next (vat_main_t * vam)
10306 unformat_input_t *i = vam->input;
10307 vl_api_add_node_next_t *mp;
10312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10314 if (unformat (i, "node %s", &name))
10316 else if (unformat (i, "next %s", &next))
10323 errmsg ("node name required");
10326 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10328 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10333 errmsg ("next node required");
10336 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10338 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10342 M (ADD_NODE_NEXT, mp);
10343 clib_memcpy (mp->node_name, name, vec_len (name));
10344 clib_memcpy (mp->next_name, next, vec_len (next));
10354 api_l2tpv3_create_tunnel (vat_main_t * vam)
10356 unformat_input_t *i = vam->input;
10357 ip6_address_t client_address, our_address;
10358 int client_address_set = 0;
10359 int our_address_set = 0;
10360 u32 local_session_id = 0;
10361 u32 remote_session_id = 0;
10362 u64 local_cookie = 0;
10363 u64 remote_cookie = 0;
10364 u8 l2_sublayer_present = 0;
10365 vl_api_l2tpv3_create_tunnel_t *mp;
10368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10370 if (unformat (i, "client_address %U", unformat_ip6_address,
10372 client_address_set = 1;
10373 else if (unformat (i, "our_address %U", unformat_ip6_address,
10375 our_address_set = 1;
10376 else if (unformat (i, "local_session_id %d", &local_session_id))
10378 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10380 else if (unformat (i, "local_cookie %lld", &local_cookie))
10382 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10384 else if (unformat (i, "l2-sublayer-present"))
10385 l2_sublayer_present = 1;
10390 if (client_address_set == 0)
10392 errmsg ("client_address required");
10396 if (our_address_set == 0)
10398 errmsg ("our_address required");
10402 M (L2TPV3_CREATE_TUNNEL, mp);
10404 clib_memcpy (mp->client_address, client_address.as_u8,
10405 sizeof (mp->client_address));
10407 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10409 mp->local_session_id = ntohl (local_session_id);
10410 mp->remote_session_id = ntohl (remote_session_id);
10411 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10412 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10413 mp->l2_sublayer_present = l2_sublayer_present;
10422 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10424 unformat_input_t *i = vam->input;
10426 u8 sw_if_index_set = 0;
10427 u64 new_local_cookie = 0;
10428 u64 new_remote_cookie = 0;
10429 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10434 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10435 sw_if_index_set = 1;
10436 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10437 sw_if_index_set = 1;
10438 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10440 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10446 if (sw_if_index_set == 0)
10448 errmsg ("missing interface name or sw_if_index");
10452 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10454 mp->sw_if_index = ntohl (sw_if_index);
10455 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10456 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10464 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10466 unformat_input_t *i = vam->input;
10467 vl_api_l2tpv3_interface_enable_disable_t *mp;
10469 u8 sw_if_index_set = 0;
10470 u8 enable_disable = 1;
10473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10475 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10476 sw_if_index_set = 1;
10477 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10478 sw_if_index_set = 1;
10479 else if (unformat (i, "enable"))
10480 enable_disable = 1;
10481 else if (unformat (i, "disable"))
10482 enable_disable = 0;
10487 if (sw_if_index_set == 0)
10489 errmsg ("missing interface name or sw_if_index");
10493 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10495 mp->sw_if_index = ntohl (sw_if_index);
10496 mp->enable_disable = enable_disable;
10504 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10506 unformat_input_t *i = vam->input;
10507 vl_api_l2tpv3_set_lookup_key_t *mp;
10511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10513 if (unformat (i, "lookup_v6_src"))
10514 key = L2T_LOOKUP_SRC_ADDRESS;
10515 else if (unformat (i, "lookup_v6_dst"))
10516 key = L2T_LOOKUP_DST_ADDRESS;
10517 else if (unformat (i, "lookup_session_id"))
10518 key = L2T_LOOKUP_SESSION_ID;
10523 if (key == (u8) ~ 0)
10525 errmsg ("l2tp session lookup key unset");
10529 M (L2TPV3_SET_LOOKUP_KEY, mp);
10538 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10539 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10541 vat_main_t *vam = &vat_main;
10543 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10544 format_ip6_address, mp->our_address,
10545 format_ip6_address, mp->client_address,
10546 clib_net_to_host_u32 (mp->sw_if_index));
10549 " local cookies %016llx %016llx remote cookie %016llx",
10550 clib_net_to_host_u64 (mp->local_cookie[0]),
10551 clib_net_to_host_u64 (mp->local_cookie[1]),
10552 clib_net_to_host_u64 (mp->remote_cookie));
10554 print (vam->ofp, " local session-id %d remote session-id %d",
10555 clib_net_to_host_u32 (mp->local_session_id),
10556 clib_net_to_host_u32 (mp->remote_session_id));
10558 print (vam->ofp, " l2 specific sublayer %s\n",
10559 mp->l2_sublayer_present ? "preset" : "absent");
10563 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10564 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10566 vat_main_t *vam = &vat_main;
10567 vat_json_node_t *node = NULL;
10568 struct in6_addr addr;
10570 if (VAT_JSON_ARRAY != vam->json_tree.type)
10572 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10573 vat_json_init_array (&vam->json_tree);
10575 node = vat_json_array_add (&vam->json_tree);
10577 vat_json_init_object (node);
10579 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10580 vat_json_object_add_ip6 (node, "our_address", addr);
10581 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10582 vat_json_object_add_ip6 (node, "client_address", addr);
10584 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10585 vat_json_init_array (lc);
10586 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10587 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10588 vat_json_object_add_uint (node, "remote_cookie",
10589 clib_net_to_host_u64 (mp->remote_cookie));
10591 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10592 vat_json_object_add_uint (node, "local_session_id",
10593 clib_net_to_host_u32 (mp->local_session_id));
10594 vat_json_object_add_uint (node, "remote_session_id",
10595 clib_net_to_host_u32 (mp->remote_session_id));
10596 vat_json_object_add_string_copy (node, "l2_sublayer",
10597 mp->l2_sublayer_present ? (u8 *) "present"
10598 : (u8 *) "absent");
10602 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10604 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10605 vl_api_control_ping_t *mp_ping;
10608 /* Get list of l2tpv3-tunnel interfaces */
10609 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10612 /* Use a control ping for synchronization */
10613 M (CONTROL_PING, mp_ping);
10621 static void vl_api_sw_interface_tap_details_t_handler
10622 (vl_api_sw_interface_tap_details_t * mp)
10624 vat_main_t *vam = &vat_main;
10626 print (vam->ofp, "%-16s %d",
10627 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10630 static void vl_api_sw_interface_tap_details_t_handler_json
10631 (vl_api_sw_interface_tap_details_t * mp)
10633 vat_main_t *vam = &vat_main;
10634 vat_json_node_t *node = NULL;
10636 if (VAT_JSON_ARRAY != vam->json_tree.type)
10638 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10639 vat_json_init_array (&vam->json_tree);
10641 node = vat_json_array_add (&vam->json_tree);
10643 vat_json_init_object (node);
10644 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10645 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10649 api_sw_interface_tap_dump (vat_main_t * vam)
10651 vl_api_sw_interface_tap_dump_t *mp;
10652 vl_api_control_ping_t *mp_ping;
10655 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10656 /* Get list of tap interfaces */
10657 M (SW_INTERFACE_TAP_DUMP, mp);
10660 /* Use a control ping for synchronization */
10661 M (CONTROL_PING, mp_ping);
10668 static uword unformat_vxlan_decap_next
10669 (unformat_input_t * input, va_list * args)
10671 u32 *result = va_arg (*args, u32 *);
10674 if (unformat (input, "l2"))
10675 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10676 else if (unformat (input, "%d", &tmp))
10684 api_vxlan_add_del_tunnel (vat_main_t * vam)
10686 unformat_input_t *line_input = vam->input;
10687 vl_api_vxlan_add_del_tunnel_t *mp;
10688 ip46_address_t src, dst;
10690 u8 ipv4_set = 0, ipv6_set = 0;
10694 u32 mcast_sw_if_index = ~0;
10695 u32 encap_vrf_id = 0;
10696 u32 decap_next_index = ~0;
10700 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10701 memset (&src, 0, sizeof src);
10702 memset (&dst, 0, sizeof dst);
10704 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10706 if (unformat (line_input, "del"))
10709 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10715 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10721 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10727 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10732 else if (unformat (line_input, "group %U %U",
10733 unformat_ip4_address, &dst.ip4,
10734 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10736 grp_set = dst_set = 1;
10739 else if (unformat (line_input, "group %U",
10740 unformat_ip4_address, &dst.ip4))
10742 grp_set = dst_set = 1;
10745 else if (unformat (line_input, "group %U %U",
10746 unformat_ip6_address, &dst.ip6,
10747 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10749 grp_set = dst_set = 1;
10752 else if (unformat (line_input, "group %U",
10753 unformat_ip6_address, &dst.ip6))
10755 grp_set = dst_set = 1;
10759 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10761 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10763 else if (unformat (line_input, "decap-next %U",
10764 unformat_vxlan_decap_next, &decap_next_index))
10766 else if (unformat (line_input, "vni %d", &vni))
10770 errmsg ("parse error '%U'", format_unformat_error, line_input);
10777 errmsg ("tunnel src address not specified");
10782 errmsg ("tunnel dst address not specified");
10786 if (grp_set && !ip46_address_is_multicast (&dst))
10788 errmsg ("tunnel group address not multicast");
10791 if (grp_set && mcast_sw_if_index == ~0)
10793 errmsg ("tunnel nonexistent multicast device");
10796 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10798 errmsg ("tunnel dst address must be unicast");
10803 if (ipv4_set && ipv6_set)
10805 errmsg ("both IPv4 and IPv6 addresses specified");
10809 if ((vni == 0) || (vni >> 24))
10811 errmsg ("vni not specified or out of range");
10815 M (VXLAN_ADD_DEL_TUNNEL, mp);
10819 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10820 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10824 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10825 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10827 mp->encap_vrf_id = ntohl (encap_vrf_id);
10828 mp->decap_next_index = ntohl (decap_next_index);
10829 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10830 mp->vni = ntohl (vni);
10831 mp->is_add = is_add;
10832 mp->is_ipv6 = ipv6_set;
10839 static void vl_api_vxlan_tunnel_details_t_handler
10840 (vl_api_vxlan_tunnel_details_t * mp)
10842 vat_main_t *vam = &vat_main;
10843 ip46_address_t src, dst;
10845 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10846 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10848 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10849 ntohl (mp->sw_if_index),
10850 format_ip46_address, &src, IP46_TYPE_ANY,
10851 format_ip46_address, &dst, IP46_TYPE_ANY,
10852 ntohl (mp->encap_vrf_id),
10853 ntohl (mp->decap_next_index), ntohl (mp->vni),
10854 ntohl (mp->mcast_sw_if_index));
10857 static void vl_api_vxlan_tunnel_details_t_handler_json
10858 (vl_api_vxlan_tunnel_details_t * mp)
10860 vat_main_t *vam = &vat_main;
10861 vat_json_node_t *node = NULL;
10863 if (VAT_JSON_ARRAY != vam->json_tree.type)
10865 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10866 vat_json_init_array (&vam->json_tree);
10868 node = vat_json_array_add (&vam->json_tree);
10870 vat_json_init_object (node);
10871 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10874 struct in6_addr ip6;
10876 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10877 vat_json_object_add_ip6 (node, "src_address", ip6);
10878 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10879 vat_json_object_add_ip6 (node, "dst_address", ip6);
10883 struct in_addr ip4;
10885 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10886 vat_json_object_add_ip4 (node, "src_address", ip4);
10887 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10888 vat_json_object_add_ip4 (node, "dst_address", ip4);
10890 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10891 vat_json_object_add_uint (node, "decap_next_index",
10892 ntohl (mp->decap_next_index));
10893 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10894 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10895 vat_json_object_add_uint (node, "mcast_sw_if_index",
10896 ntohl (mp->mcast_sw_if_index));
10900 api_vxlan_tunnel_dump (vat_main_t * vam)
10902 unformat_input_t *i = vam->input;
10903 vl_api_vxlan_tunnel_dump_t *mp;
10904 vl_api_control_ping_t *mp_ping;
10906 u8 sw_if_index_set = 0;
10909 /* Parse args required to build the message */
10910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10912 if (unformat (i, "sw_if_index %d", &sw_if_index))
10913 sw_if_index_set = 1;
10918 if (sw_if_index_set == 0)
10923 if (!vam->json_output)
10925 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10926 "sw_if_index", "src_address", "dst_address",
10927 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10930 /* Get list of vxlan-tunnel interfaces */
10931 M (VXLAN_TUNNEL_DUMP, mp);
10933 mp->sw_if_index = htonl (sw_if_index);
10937 /* Use a control ping for synchronization */
10938 M (CONTROL_PING, mp_ping);
10946 api_gre_add_del_tunnel (vat_main_t * vam)
10948 unformat_input_t *line_input = vam->input;
10949 vl_api_gre_add_del_tunnel_t *mp;
10950 ip4_address_t src4, dst4;
10955 u32 outer_fib_id = 0;
10958 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (line_input, "del"))
10962 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10964 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10966 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10968 else if (unformat (line_input, "teb"))
10972 errmsg ("parse error '%U'", format_unformat_error, line_input);
10979 errmsg ("tunnel src address not specified");
10984 errmsg ("tunnel dst address not specified");
10989 M (GRE_ADD_DEL_TUNNEL, mp);
10991 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10992 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10993 mp->outer_fib_id = ntohl (outer_fib_id);
10994 mp->is_add = is_add;
11002 static void vl_api_gre_tunnel_details_t_handler
11003 (vl_api_gre_tunnel_details_t * mp)
11005 vat_main_t *vam = &vat_main;
11007 print (vam->ofp, "%11d%15U%15U%6d%14d",
11008 ntohl (mp->sw_if_index),
11009 format_ip4_address, &mp->src_address,
11010 format_ip4_address, &mp->dst_address,
11011 mp->teb, ntohl (mp->outer_fib_id));
11014 static void vl_api_gre_tunnel_details_t_handler_json
11015 (vl_api_gre_tunnel_details_t * mp)
11017 vat_main_t *vam = &vat_main;
11018 vat_json_node_t *node = NULL;
11019 struct in_addr ip4;
11021 if (VAT_JSON_ARRAY != vam->json_tree.type)
11023 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11024 vat_json_init_array (&vam->json_tree);
11026 node = vat_json_array_add (&vam->json_tree);
11028 vat_json_init_object (node);
11029 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11030 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11031 vat_json_object_add_ip4 (node, "src_address", ip4);
11032 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11033 vat_json_object_add_ip4 (node, "dst_address", ip4);
11034 vat_json_object_add_uint (node, "teb", mp->teb);
11035 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11039 api_gre_tunnel_dump (vat_main_t * vam)
11041 unformat_input_t *i = vam->input;
11042 vl_api_gre_tunnel_dump_t *mp;
11043 vl_api_control_ping_t *mp_ping;
11045 u8 sw_if_index_set = 0;
11048 /* Parse args required to build the message */
11049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11051 if (unformat (i, "sw_if_index %d", &sw_if_index))
11052 sw_if_index_set = 1;
11057 if (sw_if_index_set == 0)
11062 if (!vam->json_output)
11064 print (vam->ofp, "%11s%15s%15s%6s%14s",
11065 "sw_if_index", "src_address", "dst_address", "teb",
11069 /* Get list of gre-tunnel interfaces */
11070 M (GRE_TUNNEL_DUMP, mp);
11072 mp->sw_if_index = htonl (sw_if_index);
11076 /* Use a control ping for synchronization */
11077 M (CONTROL_PING, mp_ping);
11085 api_l2_fib_clear_table (vat_main_t * vam)
11087 // unformat_input_t * i = vam->input;
11088 vl_api_l2_fib_clear_table_t *mp;
11091 M (L2_FIB_CLEAR_TABLE, mp);
11099 api_l2_interface_efp_filter (vat_main_t * vam)
11101 unformat_input_t *i = vam->input;
11102 vl_api_l2_interface_efp_filter_t *mp;
11105 u8 sw_if_index_set = 0;
11108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11111 sw_if_index_set = 1;
11112 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11113 sw_if_index_set = 1;
11114 else if (unformat (i, "enable"))
11116 else if (unformat (i, "disable"))
11120 clib_warning ("parse error '%U'", format_unformat_error, i);
11125 if (sw_if_index_set == 0)
11127 errmsg ("missing sw_if_index");
11131 M (L2_INTERFACE_EFP_FILTER, mp);
11133 mp->sw_if_index = ntohl (sw_if_index);
11134 mp->enable_disable = enable;
11141 #define foreach_vtr_op \
11142 _("disable", L2_VTR_DISABLED) \
11143 _("push-1", L2_VTR_PUSH_1) \
11144 _("push-2", L2_VTR_PUSH_2) \
11145 _("pop-1", L2_VTR_POP_1) \
11146 _("pop-2", L2_VTR_POP_2) \
11147 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11148 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11149 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11150 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11153 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11155 unformat_input_t *i = vam->input;
11156 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11158 u8 sw_if_index_set = 0;
11161 u32 push_dot1q = 1;
11166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11168 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11169 sw_if_index_set = 1;
11170 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11171 sw_if_index_set = 1;
11172 else if (unformat (i, "vtr_op %d", &vtr_op))
11174 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11177 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11179 else if (unformat (i, "tag1 %d", &tag1))
11181 else if (unformat (i, "tag2 %d", &tag2))
11185 clib_warning ("parse error '%U'", format_unformat_error, i);
11190 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11192 errmsg ("missing vtr operation or sw_if_index");
11196 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11197 mp->sw_if_index = ntohl (sw_if_index);
11198 mp->vtr_op = ntohl (vtr_op);
11199 mp->push_dot1q = ntohl (push_dot1q);
11200 mp->tag1 = ntohl (tag1);
11201 mp->tag2 = ntohl (tag2);
11209 api_create_vhost_user_if (vat_main_t * vam)
11211 unformat_input_t *i = vam->input;
11212 vl_api_create_vhost_user_if_t *mp;
11215 u8 file_name_set = 0;
11216 u32 custom_dev_instance = ~0;
11218 u8 use_custom_mac = 0;
11222 /* Shut up coverity */
11223 memset (hwaddr, 0, sizeof (hwaddr));
11225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11227 if (unformat (i, "socket %s", &file_name))
11231 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11233 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11234 use_custom_mac = 1;
11235 else if (unformat (i, "server"))
11237 else if (unformat (i, "tag %s", &tag))
11243 if (file_name_set == 0)
11245 errmsg ("missing socket file name");
11249 if (vec_len (file_name) > 255)
11251 errmsg ("socket file name too long");
11254 vec_add1 (file_name, 0);
11256 M (CREATE_VHOST_USER_IF, mp);
11258 mp->is_server = is_server;
11259 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11260 vec_free (file_name);
11261 if (custom_dev_instance != ~0)
11264 mp->custom_dev_instance = ntohl (custom_dev_instance);
11266 mp->use_custom_mac = use_custom_mac;
11267 clib_memcpy (mp->mac_address, hwaddr, 6);
11269 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11278 api_modify_vhost_user_if (vat_main_t * vam)
11280 unformat_input_t *i = vam->input;
11281 vl_api_modify_vhost_user_if_t *mp;
11284 u8 file_name_set = 0;
11285 u32 custom_dev_instance = ~0;
11286 u8 sw_if_index_set = 0;
11287 u32 sw_if_index = (u32) ~ 0;
11290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11293 sw_if_index_set = 1;
11294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11295 sw_if_index_set = 1;
11296 else if (unformat (i, "socket %s", &file_name))
11300 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11302 else if (unformat (i, "server"))
11308 if (sw_if_index_set == 0)
11310 errmsg ("missing sw_if_index or interface name");
11314 if (file_name_set == 0)
11316 errmsg ("missing socket file name");
11320 if (vec_len (file_name) > 255)
11322 errmsg ("socket file name too long");
11325 vec_add1 (file_name, 0);
11327 M (MODIFY_VHOST_USER_IF, mp);
11329 mp->sw_if_index = ntohl (sw_if_index);
11330 mp->is_server = is_server;
11331 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11332 vec_free (file_name);
11333 if (custom_dev_instance != ~0)
11336 mp->custom_dev_instance = ntohl (custom_dev_instance);
11345 api_delete_vhost_user_if (vat_main_t * vam)
11347 unformat_input_t *i = vam->input;
11348 vl_api_delete_vhost_user_if_t *mp;
11349 u32 sw_if_index = ~0;
11350 u8 sw_if_index_set = 0;
11353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11356 sw_if_index_set = 1;
11357 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11358 sw_if_index_set = 1;
11363 if (sw_if_index_set == 0)
11365 errmsg ("missing sw_if_index or interface name");
11370 M (DELETE_VHOST_USER_IF, mp);
11372 mp->sw_if_index = ntohl (sw_if_index);
11379 static void vl_api_sw_interface_vhost_user_details_t_handler
11380 (vl_api_sw_interface_vhost_user_details_t * mp)
11382 vat_main_t *vam = &vat_main;
11384 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11385 (char *) mp->interface_name,
11386 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11387 clib_net_to_host_u64 (mp->features), mp->is_server,
11388 ntohl (mp->num_regions), (char *) mp->sock_filename);
11389 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11392 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11393 (vl_api_sw_interface_vhost_user_details_t * mp)
11395 vat_main_t *vam = &vat_main;
11396 vat_json_node_t *node = NULL;
11398 if (VAT_JSON_ARRAY != vam->json_tree.type)
11400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11401 vat_json_init_array (&vam->json_tree);
11403 node = vat_json_array_add (&vam->json_tree);
11405 vat_json_init_object (node);
11406 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11407 vat_json_object_add_string_copy (node, "interface_name",
11408 mp->interface_name);
11409 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11410 ntohl (mp->virtio_net_hdr_sz));
11411 vat_json_object_add_uint (node, "features",
11412 clib_net_to_host_u64 (mp->features));
11413 vat_json_object_add_uint (node, "is_server", mp->is_server);
11414 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11415 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11416 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11420 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11422 vl_api_sw_interface_vhost_user_dump_t *mp;
11423 vl_api_control_ping_t *mp_ping;
11426 "Interface name idx hdr_sz features server regions filename");
11428 /* Get list of vhost-user interfaces */
11429 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11432 /* Use a control ping for synchronization */
11433 M (CONTROL_PING, mp_ping);
11441 api_show_version (vat_main_t * vam)
11443 vl_api_show_version_t *mp;
11446 M (SHOW_VERSION, mp);
11455 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11457 unformat_input_t *line_input = vam->input;
11458 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11459 ip4_address_t local4, remote4;
11460 ip6_address_t local6, remote6;
11462 u8 ipv4_set = 0, ipv6_set = 0;
11465 u32 encap_vrf_id = 0;
11466 u32 decap_vrf_id = 0;
11472 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11474 if (unformat (line_input, "del"))
11476 else if (unformat (line_input, "local %U",
11477 unformat_ip4_address, &local4))
11482 else if (unformat (line_input, "remote %U",
11483 unformat_ip4_address, &remote4))
11488 else if (unformat (line_input, "local %U",
11489 unformat_ip6_address, &local6))
11494 else if (unformat (line_input, "remote %U",
11495 unformat_ip6_address, &remote6))
11500 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11502 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11504 else if (unformat (line_input, "vni %d", &vni))
11506 else if (unformat (line_input, "next-ip4"))
11508 else if (unformat (line_input, "next-ip6"))
11510 else if (unformat (line_input, "next-ethernet"))
11512 else if (unformat (line_input, "next-nsh"))
11516 errmsg ("parse error '%U'", format_unformat_error, line_input);
11521 if (local_set == 0)
11523 errmsg ("tunnel local address not specified");
11526 if (remote_set == 0)
11528 errmsg ("tunnel remote address not specified");
11531 if (ipv4_set && ipv6_set)
11533 errmsg ("both IPv4 and IPv6 addresses specified");
11539 errmsg ("vni not specified");
11543 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11548 clib_memcpy (&mp->local, &local6, sizeof (local6));
11549 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11553 clib_memcpy (&mp->local, &local4, sizeof (local4));
11554 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11557 mp->encap_vrf_id = ntohl (encap_vrf_id);
11558 mp->decap_vrf_id = ntohl (decap_vrf_id);
11559 mp->protocol = protocol;
11560 mp->vni = ntohl (vni);
11561 mp->is_add = is_add;
11562 mp->is_ipv6 = ipv6_set;
11569 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11570 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11572 vat_main_t *vam = &vat_main;
11574 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11575 ntohl (mp->sw_if_index),
11576 format_ip46_address, &(mp->local[0]),
11577 format_ip46_address, &(mp->remote[0]),
11579 ntohl (mp->protocol),
11580 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11583 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11584 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11586 vat_main_t *vam = &vat_main;
11587 vat_json_node_t *node = NULL;
11588 struct in_addr ip4;
11589 struct in6_addr ip6;
11591 if (VAT_JSON_ARRAY != vam->json_tree.type)
11593 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11594 vat_json_init_array (&vam->json_tree);
11596 node = vat_json_array_add (&vam->json_tree);
11598 vat_json_init_object (node);
11599 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11602 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11603 vat_json_object_add_ip6 (node, "local", ip6);
11604 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11605 vat_json_object_add_ip6 (node, "remote", ip6);
11609 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11610 vat_json_object_add_ip4 (node, "local", ip4);
11611 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11612 vat_json_object_add_ip4 (node, "remote", ip4);
11614 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11615 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11616 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11617 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11618 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11622 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11624 unformat_input_t *i = vam->input;
11625 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11626 vl_api_control_ping_t *mp_ping;
11628 u8 sw_if_index_set = 0;
11631 /* Parse args required to build the message */
11632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11634 if (unformat (i, "sw_if_index %d", &sw_if_index))
11635 sw_if_index_set = 1;
11640 if (sw_if_index_set == 0)
11645 if (!vam->json_output)
11647 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11648 "sw_if_index", "local", "remote", "vni",
11649 "protocol", "encap_vrf_id", "decap_vrf_id");
11652 /* Get list of vxlan-tunnel interfaces */
11653 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11655 mp->sw_if_index = htonl (sw_if_index);
11659 /* Use a control ping for synchronization */
11660 M (CONTROL_PING, mp_ping);
11668 format_l2_fib_mac_address (u8 * s, va_list * args)
11670 u8 *a = va_arg (*args, u8 *);
11672 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11673 a[2], a[3], a[4], a[5], a[6], a[7]);
11676 static void vl_api_l2_fib_table_entry_t_handler
11677 (vl_api_l2_fib_table_entry_t * mp)
11679 vat_main_t *vam = &vat_main;
11681 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11683 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11684 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11688 static void vl_api_l2_fib_table_entry_t_handler_json
11689 (vl_api_l2_fib_table_entry_t * mp)
11691 vat_main_t *vam = &vat_main;
11692 vat_json_node_t *node = NULL;
11694 if (VAT_JSON_ARRAY != vam->json_tree.type)
11696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11697 vat_json_init_array (&vam->json_tree);
11699 node = vat_json_array_add (&vam->json_tree);
11701 vat_json_init_object (node);
11702 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11703 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11704 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11705 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11706 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11707 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11711 api_l2_fib_table_dump (vat_main_t * vam)
11713 unformat_input_t *i = vam->input;
11714 vl_api_l2_fib_table_dump_t *mp;
11715 vl_api_control_ping_t *mp_ping;
11720 /* Parse args required to build the message */
11721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11723 if (unformat (i, "bd_id %d", &bd_id))
11729 if (bd_id_set == 0)
11731 errmsg ("missing bridge domain");
11735 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11737 /* Get list of l2 fib entries */
11738 M (L2_FIB_TABLE_DUMP, mp);
11740 mp->bd_id = ntohl (bd_id);
11743 /* Use a control ping for synchronization */
11744 M (CONTROL_PING, mp_ping);
11753 api_interface_name_renumber (vat_main_t * vam)
11755 unformat_input_t *line_input = vam->input;
11756 vl_api_interface_name_renumber_t *mp;
11757 u32 sw_if_index = ~0;
11758 u32 new_show_dev_instance = ~0;
11761 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11763 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11766 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11768 else if (unformat (line_input, "new_show_dev_instance %d",
11769 &new_show_dev_instance))
11775 if (sw_if_index == ~0)
11777 errmsg ("missing interface name or sw_if_index");
11781 if (new_show_dev_instance == ~0)
11783 errmsg ("missing new_show_dev_instance");
11787 M (INTERFACE_NAME_RENUMBER, mp);
11789 mp->sw_if_index = ntohl (sw_if_index);
11790 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11798 api_want_ip4_arp_events (vat_main_t * vam)
11800 unformat_input_t *line_input = vam->input;
11801 vl_api_want_ip4_arp_events_t *mp;
11802 ip4_address_t address;
11803 int address_set = 0;
11804 u32 enable_disable = 1;
11807 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11809 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11811 else if (unformat (line_input, "del"))
11812 enable_disable = 0;
11817 if (address_set == 0)
11819 errmsg ("missing addresses");
11823 M (WANT_IP4_ARP_EVENTS, mp);
11824 mp->enable_disable = enable_disable;
11825 mp->pid = getpid ();
11826 mp->address = address.as_u32;
11834 api_want_ip6_nd_events (vat_main_t * vam)
11836 unformat_input_t *line_input = vam->input;
11837 vl_api_want_ip6_nd_events_t *mp;
11838 ip6_address_t address;
11839 int address_set = 0;
11840 u32 enable_disable = 1;
11843 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11845 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11847 else if (unformat (line_input, "del"))
11848 enable_disable = 0;
11853 if (address_set == 0)
11855 errmsg ("missing addresses");
11859 M (WANT_IP6_ND_EVENTS, mp);
11860 mp->enable_disable = enable_disable;
11861 mp->pid = getpid ();
11862 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11870 api_input_acl_set_interface (vat_main_t * vam)
11872 unformat_input_t *i = vam->input;
11873 vl_api_input_acl_set_interface_t *mp;
11875 int sw_if_index_set;
11876 u32 ip4_table_index = ~0;
11877 u32 ip6_table_index = ~0;
11878 u32 l2_table_index = ~0;
11882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11885 sw_if_index_set = 1;
11886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11887 sw_if_index_set = 1;
11888 else if (unformat (i, "del"))
11890 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11892 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11894 else if (unformat (i, "l2-table %d", &l2_table_index))
11898 clib_warning ("parse error '%U'", format_unformat_error, i);
11903 if (sw_if_index_set == 0)
11905 errmsg ("missing interface name or sw_if_index");
11909 M (INPUT_ACL_SET_INTERFACE, mp);
11911 mp->sw_if_index = ntohl (sw_if_index);
11912 mp->ip4_table_index = ntohl (ip4_table_index);
11913 mp->ip6_table_index = ntohl (ip6_table_index);
11914 mp->l2_table_index = ntohl (l2_table_index);
11915 mp->is_add = is_add;
11923 api_ip_address_dump (vat_main_t * vam)
11925 unformat_input_t *i = vam->input;
11926 vl_api_ip_address_dump_t *mp;
11927 vl_api_control_ping_t *mp_ping;
11928 u32 sw_if_index = ~0;
11929 u8 sw_if_index_set = 0;
11934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11936 if (unformat (i, "sw_if_index %d", &sw_if_index))
11937 sw_if_index_set = 1;
11939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11940 sw_if_index_set = 1;
11941 else if (unformat (i, "ipv4"))
11943 else if (unformat (i, "ipv6"))
11949 if (ipv4_set && ipv6_set)
11951 errmsg ("ipv4 and ipv6 flags cannot be both set");
11955 if ((!ipv4_set) && (!ipv6_set))
11957 errmsg ("no ipv4 nor ipv6 flag set");
11961 if (sw_if_index_set == 0)
11963 errmsg ("missing interface name or sw_if_index");
11967 vam->current_sw_if_index = sw_if_index;
11968 vam->is_ipv6 = ipv6_set;
11970 M (IP_ADDRESS_DUMP, mp);
11971 mp->sw_if_index = ntohl (sw_if_index);
11972 mp->is_ipv6 = ipv6_set;
11975 /* Use a control ping for synchronization */
11976 M (CONTROL_PING, mp_ping);
11984 api_ip_dump (vat_main_t * vam)
11986 vl_api_ip_dump_t *mp;
11987 vl_api_control_ping_t *mp_ping;
11988 unformat_input_t *in = vam->input;
11995 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11997 if (unformat (in, "ipv4"))
11999 else if (unformat (in, "ipv6"))
12005 if (ipv4_set && ipv6_set)
12007 errmsg ("ipv4 and ipv6 flags cannot be both set");
12011 if ((!ipv4_set) && (!ipv6_set))
12013 errmsg ("no ipv4 nor ipv6 flag set");
12017 is_ipv6 = ipv6_set;
12018 vam->is_ipv6 = is_ipv6;
12020 /* free old data */
12021 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12023 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12025 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12028 mp->is_ipv6 = ipv6_set;
12031 /* Use a control ping for synchronization */
12032 M (CONTROL_PING, mp_ping);
12040 api_ipsec_spd_add_del (vat_main_t * vam)
12042 unformat_input_t *i = vam->input;
12043 vl_api_ipsec_spd_add_del_t *mp;
12048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12050 if (unformat (i, "spd_id %d", &spd_id))
12052 else if (unformat (i, "del"))
12056 clib_warning ("parse error '%U'", format_unformat_error, i);
12062 errmsg ("spd_id must be set");
12066 M (IPSEC_SPD_ADD_DEL, mp);
12068 mp->spd_id = ntohl (spd_id);
12069 mp->is_add = is_add;
12077 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12079 unformat_input_t *i = vam->input;
12080 vl_api_ipsec_interface_add_del_spd_t *mp;
12082 u8 sw_if_index_set = 0;
12083 u32 spd_id = (u32) ~ 0;
12087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12089 if (unformat (i, "del"))
12091 else if (unformat (i, "spd_id %d", &spd_id))
12094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12095 sw_if_index_set = 1;
12096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12097 sw_if_index_set = 1;
12100 clib_warning ("parse error '%U'", format_unformat_error, i);
12106 if (spd_id == (u32) ~ 0)
12108 errmsg ("spd_id must be set");
12112 if (sw_if_index_set == 0)
12114 errmsg ("missing interface name or sw_if_index");
12118 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12120 mp->spd_id = ntohl (spd_id);
12121 mp->sw_if_index = ntohl (sw_if_index);
12122 mp->is_add = is_add;
12130 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12132 unformat_input_t *i = vam->input;
12133 vl_api_ipsec_spd_add_del_entry_t *mp;
12134 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12135 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12137 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12138 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12139 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12140 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12143 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12144 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12145 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12146 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12147 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12148 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12152 if (unformat (i, "del"))
12154 if (unformat (i, "outbound"))
12156 if (unformat (i, "inbound"))
12158 else if (unformat (i, "spd_id %d", &spd_id))
12160 else if (unformat (i, "sa_id %d", &sa_id))
12162 else if (unformat (i, "priority %d", &priority))
12164 else if (unformat (i, "protocol %d", &protocol))
12166 else if (unformat (i, "lport_start %d", &lport_start))
12168 else if (unformat (i, "lport_stop %d", &lport_stop))
12170 else if (unformat (i, "rport_start %d", &rport_start))
12172 else if (unformat (i, "rport_stop %d", &rport_stop))
12176 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12182 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12189 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12195 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12202 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12208 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12215 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12221 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12227 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12229 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12231 clib_warning ("unsupported action: 'resolve'");
12237 clib_warning ("parse error '%U'", format_unformat_error, i);
12243 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12245 mp->spd_id = ntohl (spd_id);
12246 mp->priority = ntohl (priority);
12247 mp->is_outbound = is_outbound;
12249 mp->is_ipv6 = is_ipv6;
12250 if (is_ipv6 || is_ip_any)
12252 clib_memcpy (mp->remote_address_start, &raddr6_start,
12253 sizeof (ip6_address_t));
12254 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12255 sizeof (ip6_address_t));
12256 clib_memcpy (mp->local_address_start, &laddr6_start,
12257 sizeof (ip6_address_t));
12258 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12259 sizeof (ip6_address_t));
12263 clib_memcpy (mp->remote_address_start, &raddr4_start,
12264 sizeof (ip4_address_t));
12265 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12266 sizeof (ip4_address_t));
12267 clib_memcpy (mp->local_address_start, &laddr4_start,
12268 sizeof (ip4_address_t));
12269 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12270 sizeof (ip4_address_t));
12272 mp->protocol = (u8) protocol;
12273 mp->local_port_start = ntohs ((u16) lport_start);
12274 mp->local_port_stop = ntohs ((u16) lport_stop);
12275 mp->remote_port_start = ntohs ((u16) rport_start);
12276 mp->remote_port_stop = ntohs ((u16) rport_stop);
12277 mp->policy = (u8) policy;
12278 mp->sa_id = ntohl (sa_id);
12279 mp->is_add = is_add;
12280 mp->is_ip_any = is_ip_any;
12287 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12289 unformat_input_t *i = vam->input;
12290 vl_api_ipsec_sad_add_del_entry_t *mp;
12291 u32 sad_id = 0, spi = 0;
12292 u8 *ck = 0, *ik = 0;
12295 u8 protocol = IPSEC_PROTOCOL_AH;
12296 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12297 u32 crypto_alg = 0, integ_alg = 0;
12298 ip4_address_t tun_src4;
12299 ip4_address_t tun_dst4;
12300 ip6_address_t tun_src6;
12301 ip6_address_t tun_dst6;
12304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12306 if (unformat (i, "del"))
12308 else if (unformat (i, "sad_id %d", &sad_id))
12310 else if (unformat (i, "spi %d", &spi))
12312 else if (unformat (i, "esp"))
12313 protocol = IPSEC_PROTOCOL_ESP;
12314 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12317 is_tunnel_ipv6 = 0;
12319 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12322 is_tunnel_ipv6 = 0;
12324 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12327 is_tunnel_ipv6 = 1;
12329 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12332 is_tunnel_ipv6 = 1;
12336 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12338 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12339 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12341 clib_warning ("unsupported crypto-alg: '%U'",
12342 format_ipsec_crypto_alg, crypto_alg);
12346 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12350 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12352 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12353 integ_alg >= IPSEC_INTEG_N_ALG)
12355 clib_warning ("unsupported integ-alg: '%U'",
12356 format_ipsec_integ_alg, integ_alg);
12360 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12364 clib_warning ("parse error '%U'", format_unformat_error, i);
12370 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12372 mp->sad_id = ntohl (sad_id);
12373 mp->is_add = is_add;
12374 mp->protocol = protocol;
12375 mp->spi = ntohl (spi);
12376 mp->is_tunnel = is_tunnel;
12377 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12378 mp->crypto_algorithm = crypto_alg;
12379 mp->integrity_algorithm = integ_alg;
12380 mp->crypto_key_length = vec_len (ck);
12381 mp->integrity_key_length = vec_len (ik);
12383 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12384 mp->crypto_key_length = sizeof (mp->crypto_key);
12386 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12387 mp->integrity_key_length = sizeof (mp->integrity_key);
12390 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12392 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12396 if (is_tunnel_ipv6)
12398 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12399 sizeof (ip6_address_t));
12400 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12401 sizeof (ip6_address_t));
12405 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12406 sizeof (ip4_address_t));
12407 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12408 sizeof (ip4_address_t));
12418 api_ipsec_sa_set_key (vat_main_t * vam)
12420 unformat_input_t *i = vam->input;
12421 vl_api_ipsec_sa_set_key_t *mp;
12423 u8 *ck = 0, *ik = 0;
12426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12428 if (unformat (i, "sa_id %d", &sa_id))
12430 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12432 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12436 clib_warning ("parse error '%U'", format_unformat_error, i);
12441 M (IPSEC_SA_SET_KEY, mp);
12443 mp->sa_id = ntohl (sa_id);
12444 mp->crypto_key_length = vec_len (ck);
12445 mp->integrity_key_length = vec_len (ik);
12447 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12448 mp->crypto_key_length = sizeof (mp->crypto_key);
12450 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12451 mp->integrity_key_length = sizeof (mp->integrity_key);
12454 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12456 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12464 api_ikev2_profile_add_del (vat_main_t * vam)
12466 unformat_input_t *i = vam->input;
12467 vl_api_ikev2_profile_add_del_t *mp;
12472 const char *valid_chars = "a-zA-Z0-9_";
12474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12476 if (unformat (i, "del"))
12478 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12479 vec_add1 (name, 0);
12482 errmsg ("parse error '%U'", format_unformat_error, i);
12487 if (!vec_len (name))
12489 errmsg ("profile name must be specified");
12493 if (vec_len (name) > 64)
12495 errmsg ("profile name too long");
12499 M (IKEV2_PROFILE_ADD_DEL, mp);
12501 clib_memcpy (mp->name, name, vec_len (name));
12502 mp->is_add = is_add;
12511 api_ikev2_profile_set_auth (vat_main_t * vam)
12513 unformat_input_t *i = vam->input;
12514 vl_api_ikev2_profile_set_auth_t *mp;
12517 u32 auth_method = 0;
12521 const char *valid_chars = "a-zA-Z0-9_";
12523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12525 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12526 vec_add1 (name, 0);
12527 else if (unformat (i, "auth_method %U",
12528 unformat_ikev2_auth_method, &auth_method))
12530 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12532 else if (unformat (i, "auth_data %v", &data))
12536 errmsg ("parse error '%U'", format_unformat_error, i);
12541 if (!vec_len (name))
12543 errmsg ("profile name must be specified");
12547 if (vec_len (name) > 64)
12549 errmsg ("profile name too long");
12553 if (!vec_len (data))
12555 errmsg ("auth_data must be specified");
12561 errmsg ("auth_method must be specified");
12565 M (IKEV2_PROFILE_SET_AUTH, mp);
12567 mp->is_hex = is_hex;
12568 mp->auth_method = (u8) auth_method;
12569 mp->data_len = vec_len (data);
12570 clib_memcpy (mp->name, name, vec_len (name));
12571 clib_memcpy (mp->data, data, vec_len (data));
12581 api_ikev2_profile_set_id (vat_main_t * vam)
12583 unformat_input_t *i = vam->input;
12584 vl_api_ikev2_profile_set_id_t *mp;
12592 const char *valid_chars = "a-zA-Z0-9_";
12594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12596 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12597 vec_add1 (name, 0);
12598 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12600 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12602 data = vec_new (u8, 4);
12603 clib_memcpy (data, ip4.as_u8, 4);
12605 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12607 else if (unformat (i, "id_data %v", &data))
12609 else if (unformat (i, "local"))
12611 else if (unformat (i, "remote"))
12615 errmsg ("parse error '%U'", format_unformat_error, i);
12620 if (!vec_len (name))
12622 errmsg ("profile name must be specified");
12626 if (vec_len (name) > 64)
12628 errmsg ("profile name too long");
12632 if (!vec_len (data))
12634 errmsg ("id_data must be specified");
12640 errmsg ("id_type must be specified");
12644 M (IKEV2_PROFILE_SET_ID, mp);
12646 mp->is_local = is_local;
12647 mp->id_type = (u8) id_type;
12648 mp->data_len = vec_len (data);
12649 clib_memcpy (mp->name, name, vec_len (name));
12650 clib_memcpy (mp->data, data, vec_len (data));
12660 api_ikev2_profile_set_ts (vat_main_t * vam)
12662 unformat_input_t *i = vam->input;
12663 vl_api_ikev2_profile_set_ts_t *mp;
12666 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12667 ip4_address_t start_addr, end_addr;
12669 const char *valid_chars = "a-zA-Z0-9_";
12672 start_addr.as_u32 = 0;
12673 end_addr.as_u32 = (u32) ~ 0;
12675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12677 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12678 vec_add1 (name, 0);
12679 else if (unformat (i, "protocol %d", &proto))
12681 else if (unformat (i, "start_port %d", &start_port))
12683 else if (unformat (i, "end_port %d", &end_port))
12686 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12688 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12690 else if (unformat (i, "local"))
12692 else if (unformat (i, "remote"))
12696 errmsg ("parse error '%U'", format_unformat_error, i);
12701 if (!vec_len (name))
12703 errmsg ("profile name must be specified");
12707 if (vec_len (name) > 64)
12709 errmsg ("profile name too long");
12713 M (IKEV2_PROFILE_SET_TS, mp);
12715 mp->is_local = is_local;
12716 mp->proto = (u8) proto;
12717 mp->start_port = (u16) start_port;
12718 mp->end_port = (u16) end_port;
12719 mp->start_addr = start_addr.as_u32;
12720 mp->end_addr = end_addr.as_u32;
12721 clib_memcpy (mp->name, name, vec_len (name));
12730 api_ikev2_set_local_key (vat_main_t * vam)
12732 unformat_input_t *i = vam->input;
12733 vl_api_ikev2_set_local_key_t *mp;
12737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12739 if (unformat (i, "file %v", &file))
12740 vec_add1 (file, 0);
12743 errmsg ("parse error '%U'", format_unformat_error, i);
12748 if (!vec_len (file))
12750 errmsg ("RSA key file must be specified");
12754 if (vec_len (file) > 256)
12756 errmsg ("file name too long");
12760 M (IKEV2_SET_LOCAL_KEY, mp);
12762 clib_memcpy (mp->key_file, file, vec_len (file));
12771 api_ikev2_set_responder (vat_main_t * vam)
12773 unformat_input_t *i = vam->input;
12774 vl_api_ikev2_set_responder_t *mp;
12777 u32 sw_if_index = ~0;
12778 ip4_address_t address;
12780 const char *valid_chars = "a-zA-Z0-9_";
12782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12785 (i, "%U interface %d address %U", unformat_token, valid_chars,
12786 &name, &sw_if_index, unformat_ip4_address, &address))
12787 vec_add1 (name, 0);
12790 errmsg ("parse error '%U'", format_unformat_error, i);
12795 if (!vec_len (name))
12797 errmsg ("profile name must be specified");
12801 if (vec_len (name) > 64)
12803 errmsg ("profile name too long");
12807 M (IKEV2_SET_RESPONDER, mp);
12809 clib_memcpy (mp->name, name, vec_len (name));
12812 mp->sw_if_index = sw_if_index;
12813 clib_memcpy (mp->address, &address, sizeof (address));
12821 api_ikev2_set_ike_transforms (vat_main_t * vam)
12823 unformat_input_t *i = vam->input;
12824 vl_api_ikev2_set_ike_transforms_t *mp;
12827 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12829 const char *valid_chars = "a-zA-Z0-9_";
12831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12833 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12834 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12835 vec_add1 (name, 0);
12838 errmsg ("parse error '%U'", format_unformat_error, i);
12843 if (!vec_len (name))
12845 errmsg ("profile name must be specified");
12849 if (vec_len (name) > 64)
12851 errmsg ("profile name too long");
12855 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12857 clib_memcpy (mp->name, name, vec_len (name));
12859 mp->crypto_alg = crypto_alg;
12860 mp->crypto_key_size = crypto_key_size;
12861 mp->integ_alg = integ_alg;
12862 mp->dh_group = dh_group;
12871 api_ikev2_set_esp_transforms (vat_main_t * vam)
12873 unformat_input_t *i = vam->input;
12874 vl_api_ikev2_set_esp_transforms_t *mp;
12877 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12879 const char *valid_chars = "a-zA-Z0-9_";
12881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12883 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12884 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12885 vec_add1 (name, 0);
12888 errmsg ("parse error '%U'", format_unformat_error, i);
12893 if (!vec_len (name))
12895 errmsg ("profile name must be specified");
12899 if (vec_len (name) > 64)
12901 errmsg ("profile name too long");
12905 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12907 clib_memcpy (mp->name, name, vec_len (name));
12909 mp->crypto_alg = crypto_alg;
12910 mp->crypto_key_size = crypto_key_size;
12911 mp->integ_alg = integ_alg;
12912 mp->dh_group = dh_group;
12920 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12922 unformat_input_t *i = vam->input;
12923 vl_api_ikev2_set_sa_lifetime_t *mp;
12926 u64 lifetime, lifetime_maxdata;
12927 u32 lifetime_jitter, handover;
12929 const char *valid_chars = "a-zA-Z0-9_";
12931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12933 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12934 &lifetime, &lifetime_jitter, &handover,
12935 &lifetime_maxdata))
12936 vec_add1 (name, 0);
12939 errmsg ("parse error '%U'", format_unformat_error, i);
12944 if (!vec_len (name))
12946 errmsg ("profile name must be specified");
12950 if (vec_len (name) > 64)
12952 errmsg ("profile name too long");
12956 M (IKEV2_SET_SA_LIFETIME, mp);
12958 clib_memcpy (mp->name, name, vec_len (name));
12960 mp->lifetime = lifetime;
12961 mp->lifetime_jitter = lifetime_jitter;
12962 mp->handover = handover;
12963 mp->lifetime_maxdata = lifetime_maxdata;
12971 api_ikev2_initiate_sa_init (vat_main_t * vam)
12973 unformat_input_t *i = vam->input;
12974 vl_api_ikev2_initiate_sa_init_t *mp;
12978 const char *valid_chars = "a-zA-Z0-9_";
12980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12982 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12983 vec_add1 (name, 0);
12986 errmsg ("parse error '%U'", format_unformat_error, i);
12991 if (!vec_len (name))
12993 errmsg ("profile name must be specified");
12997 if (vec_len (name) > 64)
12999 errmsg ("profile name too long");
13003 M (IKEV2_INITIATE_SA_INIT, mp);
13005 clib_memcpy (mp->name, name, vec_len (name));
13014 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13016 unformat_input_t *i = vam->input;
13017 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13024 if (unformat (i, "%lx", &ispi))
13028 errmsg ("parse error '%U'", format_unformat_error, i);
13033 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13043 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13045 unformat_input_t *i = vam->input;
13046 vl_api_ikev2_initiate_del_child_sa_t *mp;
13051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13053 if (unformat (i, "%x", &ispi))
13057 errmsg ("parse error '%U'", format_unformat_error, i);
13062 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13072 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13074 unformat_input_t *i = vam->input;
13075 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13082 if (unformat (i, "%x", &ispi))
13086 errmsg ("parse error '%U'", format_unformat_error, i);
13091 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13104 api_map_add_domain (vat_main_t * vam)
13106 unformat_input_t *i = vam->input;
13107 vl_api_map_add_domain_t *mp;
13109 ip4_address_t ip4_prefix;
13110 ip6_address_t ip6_prefix;
13111 ip6_address_t ip6_src;
13112 u32 num_m_args = 0;
13113 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13114 0, psid_length = 0;
13115 u8 is_translation = 0;
13117 u32 ip6_src_len = 128;
13120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13122 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13123 &ip4_prefix, &ip4_prefix_len))
13125 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13126 &ip6_prefix, &ip6_prefix_len))
13130 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13133 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13135 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13137 else if (unformat (i, "psid-offset %d", &psid_offset))
13139 else if (unformat (i, "psid-len %d", &psid_length))
13141 else if (unformat (i, "mtu %d", &mtu))
13143 else if (unformat (i, "map-t"))
13144 is_translation = 1;
13147 clib_warning ("parse error '%U'", format_unformat_error, i);
13152 if (num_m_args < 3)
13154 errmsg ("mandatory argument(s) missing");
13158 /* Construct the API message */
13159 M (MAP_ADD_DOMAIN, mp);
13161 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13162 mp->ip4_prefix_len = ip4_prefix_len;
13164 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13165 mp->ip6_prefix_len = ip6_prefix_len;
13167 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13168 mp->ip6_src_prefix_len = ip6_src_len;
13170 mp->ea_bits_len = ea_bits_len;
13171 mp->psid_offset = psid_offset;
13172 mp->psid_length = psid_length;
13173 mp->is_translation = is_translation;
13174 mp->mtu = htons (mtu);
13179 /* Wait for a reply, return good/bad news */
13185 api_map_del_domain (vat_main_t * vam)
13187 unformat_input_t *i = vam->input;
13188 vl_api_map_del_domain_t *mp;
13190 u32 num_m_args = 0;
13194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13196 if (unformat (i, "index %d", &index))
13200 clib_warning ("parse error '%U'", format_unformat_error, i);
13205 if (num_m_args != 1)
13207 errmsg ("mandatory argument(s) missing");
13211 /* Construct the API message */
13212 M (MAP_DEL_DOMAIN, mp);
13214 mp->index = ntohl (index);
13219 /* Wait for a reply, return good/bad news */
13225 api_map_add_del_rule (vat_main_t * vam)
13227 unformat_input_t *i = vam->input;
13228 vl_api_map_add_del_rule_t *mp;
13230 ip6_address_t ip6_dst;
13231 u32 num_m_args = 0, index, psid = 0;
13234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13236 if (unformat (i, "index %d", &index))
13238 else if (unformat (i, "psid %d", &psid))
13240 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13242 else if (unformat (i, "del"))
13248 clib_warning ("parse error '%U'", format_unformat_error, i);
13253 /* Construct the API message */
13254 M (MAP_ADD_DEL_RULE, mp);
13256 mp->index = ntohl (index);
13257 mp->is_add = is_add;
13258 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13259 mp->psid = ntohs (psid);
13264 /* Wait for a reply, return good/bad news */
13270 api_map_domain_dump (vat_main_t * vam)
13272 vl_api_map_domain_dump_t *mp;
13273 vl_api_control_ping_t *mp_ping;
13276 /* Construct the API message */
13277 M (MAP_DOMAIN_DUMP, mp);
13282 /* Use a control ping for synchronization */
13283 M (CONTROL_PING, mp_ping);
13291 api_map_rule_dump (vat_main_t * vam)
13293 unformat_input_t *i = vam->input;
13294 vl_api_map_rule_dump_t *mp;
13295 vl_api_control_ping_t *mp_ping;
13296 u32 domain_index = ~0;
13299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13301 if (unformat (i, "index %u", &domain_index))
13307 if (domain_index == ~0)
13309 clib_warning ("parse error: domain index expected");
13313 /* Construct the API message */
13314 M (MAP_RULE_DUMP, mp);
13316 mp->domain_index = htonl (domain_index);
13321 /* Use a control ping for synchronization */
13322 M (CONTROL_PING, mp_ping);
13329 static void vl_api_map_add_domain_reply_t_handler
13330 (vl_api_map_add_domain_reply_t * mp)
13332 vat_main_t *vam = &vat_main;
13333 i32 retval = ntohl (mp->retval);
13335 if (vam->async_mode)
13337 vam->async_errors += (retval < 0);
13341 vam->retval = retval;
13342 vam->result_ready = 1;
13346 static void vl_api_map_add_domain_reply_t_handler_json
13347 (vl_api_map_add_domain_reply_t * mp)
13349 vat_main_t *vam = &vat_main;
13350 vat_json_node_t node;
13352 vat_json_init_object (&node);
13353 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13354 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13356 vat_json_print (vam->ofp, &node);
13357 vat_json_free (&node);
13359 vam->retval = ntohl (mp->retval);
13360 vam->result_ready = 1;
13364 api_get_first_msg_id (vat_main_t * vam)
13366 vl_api_get_first_msg_id_t *mp;
13367 unformat_input_t *i = vam->input;
13372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13374 if (unformat (i, "client %s", &name))
13382 errmsg ("missing client name");
13385 vec_add1 (name, 0);
13387 if (vec_len (name) > 63)
13389 errmsg ("client name too long");
13393 M (GET_FIRST_MSG_ID, mp);
13394 clib_memcpy (mp->name, name, vec_len (name));
13401 api_cop_interface_enable_disable (vat_main_t * vam)
13403 unformat_input_t *line_input = vam->input;
13404 vl_api_cop_interface_enable_disable_t *mp;
13405 u32 sw_if_index = ~0;
13406 u8 enable_disable = 1;
13409 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13411 if (unformat (line_input, "disable"))
13412 enable_disable = 0;
13413 if (unformat (line_input, "enable"))
13414 enable_disable = 1;
13415 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13416 vam, &sw_if_index))
13418 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13424 if (sw_if_index == ~0)
13426 errmsg ("missing interface name or sw_if_index");
13430 /* Construct the API message */
13431 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13432 mp->sw_if_index = ntohl (sw_if_index);
13433 mp->enable_disable = enable_disable;
13437 /* Wait for the reply */
13443 api_cop_whitelist_enable_disable (vat_main_t * vam)
13445 unformat_input_t *line_input = vam->input;
13446 vl_api_cop_whitelist_enable_disable_t *mp;
13447 u32 sw_if_index = ~0;
13448 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13452 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13454 if (unformat (line_input, "ip4"))
13456 else if (unformat (line_input, "ip6"))
13458 else if (unformat (line_input, "default"))
13460 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13461 vam, &sw_if_index))
13463 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13465 else if (unformat (line_input, "fib-id %d", &fib_id))
13471 if (sw_if_index == ~0)
13473 errmsg ("missing interface name or sw_if_index");
13477 /* Construct the API message */
13478 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13479 mp->sw_if_index = ntohl (sw_if_index);
13480 mp->fib_id = ntohl (fib_id);
13483 mp->default_cop = default_cop;
13487 /* Wait for the reply */
13493 api_get_node_graph (vat_main_t * vam)
13495 vl_api_get_node_graph_t *mp;
13498 M (GET_NODE_GRAPH, mp);
13502 /* Wait for the reply */
13508 /** Used for parsing LISP eids */
13509 typedef CLIB_PACKED(struct{
13510 u8 addr[16]; /**< eid address */
13511 u32 len; /**< prefix length if IP */
13512 u8 type; /**< type of eid */
13517 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13519 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13521 memset (a, 0, sizeof (a[0]));
13523 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13525 a->type = 0; /* ipv4 type */
13527 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13529 a->type = 1; /* ipv6 type */
13531 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13533 a->type = 2; /* mac type */
13540 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13549 lisp_eid_size_vat (u8 type)
13564 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13566 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13570 api_lisp_add_del_locator_set (vat_main_t * vam)
13572 unformat_input_t *input = vam->input;
13573 vl_api_lisp_add_del_locator_set_t *mp;
13575 u8 *locator_set_name = NULL;
13576 u8 locator_set_name_set = 0;
13577 vl_api_local_locator_t locator, *locators = 0;
13578 u32 sw_if_index, priority, weight;
13582 /* Parse args required to build the message */
13583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13585 if (unformat (input, "del"))
13589 else if (unformat (input, "locator-set %s", &locator_set_name))
13591 locator_set_name_set = 1;
13593 else if (unformat (input, "sw_if_index %u p %u w %u",
13594 &sw_if_index, &priority, &weight))
13596 locator.sw_if_index = htonl (sw_if_index);
13597 locator.priority = priority;
13598 locator.weight = weight;
13599 vec_add1 (locators, locator);
13603 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13604 &sw_if_index, &priority, &weight))
13606 locator.sw_if_index = htonl (sw_if_index);
13607 locator.priority = priority;
13608 locator.weight = weight;
13609 vec_add1 (locators, locator);
13615 if (locator_set_name_set == 0)
13617 errmsg ("missing locator-set name");
13618 vec_free (locators);
13622 if (vec_len (locator_set_name) > 64)
13624 errmsg ("locator-set name too long");
13625 vec_free (locator_set_name);
13626 vec_free (locators);
13629 vec_add1 (locator_set_name, 0);
13631 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13633 /* Construct the API message */
13634 M2 (LISP_ADD_DEL_LOCATOR_SET, mp, data_len);
13636 mp->is_add = is_add;
13637 clib_memcpy (mp->locator_set_name, locator_set_name,
13638 vec_len (locator_set_name));
13639 vec_free (locator_set_name);
13641 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13643 clib_memcpy (mp->locators, locators, data_len);
13644 vec_free (locators);
13649 /* Wait for a reply... */
13655 api_lisp_add_del_locator (vat_main_t * vam)
13657 unformat_input_t *input = vam->input;
13658 vl_api_lisp_add_del_locator_t *mp;
13659 u32 tmp_if_index = ~0;
13660 u32 sw_if_index = ~0;
13661 u8 sw_if_index_set = 0;
13662 u8 sw_if_index_if_name_set = 0;
13664 u8 priority_set = 0;
13668 u8 *locator_set_name = NULL;
13669 u8 locator_set_name_set = 0;
13672 /* Parse args required to build the message */
13673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13675 if (unformat (input, "del"))
13679 else if (unformat (input, "locator-set %s", &locator_set_name))
13681 locator_set_name_set = 1;
13683 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13686 sw_if_index_if_name_set = 1;
13687 sw_if_index = tmp_if_index;
13689 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13691 sw_if_index_set = 1;
13692 sw_if_index = tmp_if_index;
13694 else if (unformat (input, "p %d", &priority))
13698 else if (unformat (input, "w %d", &weight))
13706 if (locator_set_name_set == 0)
13708 errmsg ("missing locator-set name");
13712 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13714 errmsg ("missing sw_if_index");
13715 vec_free (locator_set_name);
13719 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13721 errmsg ("cannot use both params interface name and sw_if_index");
13722 vec_free (locator_set_name);
13726 if (priority_set == 0)
13728 errmsg ("missing locator-set priority");
13729 vec_free (locator_set_name);
13733 if (weight_set == 0)
13735 errmsg ("missing locator-set weight");
13736 vec_free (locator_set_name);
13740 if (vec_len (locator_set_name) > 64)
13742 errmsg ("locator-set name too long");
13743 vec_free (locator_set_name);
13746 vec_add1 (locator_set_name, 0);
13748 /* Construct the API message */
13749 M (LISP_ADD_DEL_LOCATOR, mp);
13751 mp->is_add = is_add;
13752 mp->sw_if_index = ntohl (sw_if_index);
13753 mp->priority = priority;
13754 mp->weight = weight;
13755 clib_memcpy (mp->locator_set_name, locator_set_name,
13756 vec_len (locator_set_name));
13757 vec_free (locator_set_name);
13762 /* Wait for a reply... */
13768 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13770 u32 *key_id = va_arg (*args, u32 *);
13773 if (unformat (input, "%s", &s))
13775 if (!strcmp ((char *) s, "sha1"))
13776 key_id[0] = HMAC_SHA_1_96;
13777 else if (!strcmp ((char *) s, "sha256"))
13778 key_id[0] = HMAC_SHA_256_128;
13781 clib_warning ("invalid key_id: '%s'", s);
13782 key_id[0] = HMAC_NO_KEY;
13793 api_lisp_add_del_local_eid (vat_main_t * vam)
13795 unformat_input_t *input = vam->input;
13796 vl_api_lisp_add_del_local_eid_t *mp;
13799 lisp_eid_vat_t _eid, *eid = &_eid;
13800 u8 *locator_set_name = 0;
13801 u8 locator_set_name_set = 0;
13807 /* Parse args required to build the message */
13808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13810 if (unformat (input, "del"))
13814 else if (unformat (input, "vni %d", &vni))
13818 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13822 else if (unformat (input, "locator-set %s", &locator_set_name))
13824 locator_set_name_set = 1;
13826 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13828 else if (unformat (input, "secret-key %_%v%_", &key))
13834 if (locator_set_name_set == 0)
13836 errmsg ("missing locator-set name");
13842 errmsg ("EID address not set!");
13843 vec_free (locator_set_name);
13847 if (key && (0 == key_id))
13849 errmsg ("invalid key_id!");
13853 if (vec_len (key) > 64)
13855 errmsg ("key too long");
13860 if (vec_len (locator_set_name) > 64)
13862 errmsg ("locator-set name too long");
13863 vec_free (locator_set_name);
13866 vec_add1 (locator_set_name, 0);
13868 /* Construct the API message */
13869 M (LISP_ADD_DEL_LOCAL_EID, mp);
13871 mp->is_add = is_add;
13872 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13873 mp->eid_type = eid->type;
13874 mp->prefix_len = eid->len;
13875 mp->vni = clib_host_to_net_u32 (vni);
13876 mp->key_id = clib_host_to_net_u16 (key_id);
13877 clib_memcpy (mp->locator_set_name, locator_set_name,
13878 vec_len (locator_set_name));
13879 clib_memcpy (mp->key, key, vec_len (key));
13881 vec_free (locator_set_name);
13887 /* Wait for a reply... */
13893 /** Used for transferring locators via VPP API */
13894 typedef CLIB_PACKED(struct
13896 u8 is_ip4; /**< is locator an IPv4 address? */
13897 u8 priority; /**< locator priority */
13898 u8 weight; /**< locator weight */
13899 u8 addr[16]; /**< IPv4/IPv6 address */
13904 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13906 u32 dp_table = 0, vni = 0;;
13907 unformat_input_t *input = vam->input;
13908 vl_api_gpe_add_del_fwd_entry_t *mp;
13910 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13911 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13912 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13913 u32 action = ~0, w;
13914 ip4_address_t rmt_rloc4, lcl_rloc4;
13915 ip6_address_t rmt_rloc6, lcl_rloc6;
13916 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13919 memset (&rloc, 0, sizeof (rloc));
13921 /* Parse args required to build the message */
13922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13924 if (unformat (input, "del"))
13926 else if (unformat (input, "add"))
13928 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13932 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13936 else if (unformat (input, "vrf %d", &dp_table))
13938 else if (unformat (input, "bd %d", &dp_table))
13940 else if (unformat (input, "vni %d", &vni))
13942 else if (unformat (input, "w %d", &w))
13946 errmsg ("No RLOC configured for setting priority/weight!");
13949 curr_rloc->weight = w;
13951 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13952 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13956 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13958 vec_add1 (lcl_locs, rloc);
13960 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13961 vec_add1 (rmt_locs, rloc);
13962 /* weight saved in rmt loc */
13963 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13965 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13966 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13969 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13971 vec_add1 (lcl_locs, rloc);
13973 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13974 vec_add1 (rmt_locs, rloc);
13975 /* weight saved in rmt loc */
13976 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13978 else if (unformat (input, "action %d", &action))
13984 clib_warning ("parse error '%U'", format_unformat_error, input);
13991 errmsg ("remote eid addresses not set");
13995 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13997 errmsg ("eid types don't match");
14001 if (0 == rmt_locs && (u32) ~ 0 == action)
14003 errmsg ("action not set for negative mapping");
14007 /* Construct the API message */
14008 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14009 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14011 mp->is_add = is_add;
14012 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14013 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14014 mp->eid_type = rmt_eid->type;
14015 mp->dp_table = clib_host_to_net_u32 (dp_table);
14016 mp->vni = clib_host_to_net_u32 (vni);
14017 mp->rmt_len = rmt_eid->len;
14018 mp->lcl_len = lcl_eid->len;
14019 mp->action = action;
14021 if (0 != rmt_locs && 0 != lcl_locs)
14023 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14024 clib_memcpy (mp->locs, lcl_locs,
14025 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14027 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14028 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14029 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14031 vec_free (lcl_locs);
14032 vec_free (rmt_locs);
14037 /* Wait for a reply... */
14043 api_lisp_add_del_map_server (vat_main_t * vam)
14045 unformat_input_t *input = vam->input;
14046 vl_api_lisp_add_del_map_server_t *mp;
14050 ip4_address_t ipv4;
14051 ip6_address_t ipv6;
14054 /* Parse args required to build the message */
14055 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14057 if (unformat (input, "del"))
14061 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14065 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14073 if (ipv4_set && ipv6_set)
14075 errmsg ("both eid v4 and v6 addresses set");
14079 if (!ipv4_set && !ipv6_set)
14081 errmsg ("eid addresses not set");
14085 /* Construct the API message */
14086 M (LISP_ADD_DEL_MAP_SERVER, mp);
14088 mp->is_add = is_add;
14092 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14097 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14103 /* Wait for a reply... */
14109 api_lisp_add_del_map_resolver (vat_main_t * vam)
14111 unformat_input_t *input = vam->input;
14112 vl_api_lisp_add_del_map_resolver_t *mp;
14116 ip4_address_t ipv4;
14117 ip6_address_t ipv6;
14120 /* Parse args required to build the message */
14121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14123 if (unformat (input, "del"))
14127 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14131 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14139 if (ipv4_set && ipv6_set)
14141 errmsg ("both eid v4 and v6 addresses set");
14145 if (!ipv4_set && !ipv6_set)
14147 errmsg ("eid addresses not set");
14151 /* Construct the API message */
14152 M (LISP_ADD_DEL_MAP_RESOLVER, mp);
14154 mp->is_add = is_add;
14158 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14163 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14169 /* Wait for a reply... */
14175 api_lisp_gpe_enable_disable (vat_main_t * vam)
14177 unformat_input_t *input = vam->input;
14178 vl_api_gpe_enable_disable_t *mp;
14183 /* Parse args required to build the message */
14184 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14186 if (unformat (input, "enable"))
14191 else if (unformat (input, "disable"))
14202 errmsg ("Value not set");
14206 /* Construct the API message */
14207 M (GPE_ENABLE_DISABLE, mp);
14214 /* Wait for a reply... */
14220 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
14222 unformat_input_t *input = vam->input;
14223 vl_api_lisp_rloc_probe_enable_disable_t *mp;
14228 /* Parse args required to build the message */
14229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14231 if (unformat (input, "enable"))
14236 else if (unformat (input, "disable"))
14244 errmsg ("Value not set");
14248 /* Construct the API message */
14249 M (LISP_RLOC_PROBE_ENABLE_DISABLE, mp);
14251 mp->is_enabled = is_en;
14256 /* Wait for a reply... */
14262 api_lisp_map_register_enable_disable (vat_main_t * vam)
14264 unformat_input_t *input = vam->input;
14265 vl_api_lisp_map_register_enable_disable_t *mp;
14270 /* Parse args required to build the message */
14271 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14273 if (unformat (input, "enable"))
14278 else if (unformat (input, "disable"))
14286 errmsg ("Value not set");
14290 /* Construct the API message */
14291 M (LISP_MAP_REGISTER_ENABLE_DISABLE, mp);
14293 mp->is_enabled = is_en;
14298 /* Wait for a reply... */
14304 api_lisp_enable_disable (vat_main_t * vam)
14306 unformat_input_t *input = vam->input;
14307 vl_api_lisp_enable_disable_t *mp;
14312 /* Parse args required to build the message */
14313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14315 if (unformat (input, "enable"))
14320 else if (unformat (input, "disable"))
14330 errmsg ("Value not set");
14334 /* Construct the API message */
14335 M (LISP_ENABLE_DISABLE, mp);
14342 /* Wait for a reply... */
14348 api_show_lisp_map_register_state (vat_main_t * vam)
14350 vl_api_show_lisp_map_register_state_t *mp;
14353 M (SHOW_LISP_MAP_REGISTER_STATE, mp);
14358 /* wait for reply */
14364 api_show_lisp_rloc_probe_state (vat_main_t * vam)
14366 vl_api_show_lisp_rloc_probe_state_t *mp;
14369 M (SHOW_LISP_RLOC_PROBE_STATE, mp);
14374 /* wait for reply */
14380 api_show_lisp_map_request_mode (vat_main_t * vam)
14382 vl_api_show_lisp_map_request_mode_t *mp;
14385 M (SHOW_LISP_MAP_REQUEST_MODE, mp);
14390 /* wait for reply */
14396 api_lisp_map_request_mode (vat_main_t * vam)
14398 unformat_input_t *input = vam->input;
14399 vl_api_lisp_map_request_mode_t *mp;
14403 /* Parse args required to build the message */
14404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14406 if (unformat (input, "dst-only"))
14408 else if (unformat (input, "src-dst"))
14412 errmsg ("parse error '%U'", format_unformat_error, input);
14417 M (LISP_MAP_REQUEST_MODE, mp);
14424 /* wait for reply */
14430 * Enable/disable LISP proxy ITR.
14432 * @param vam vpp API test context
14433 * @return return code
14436 api_lisp_pitr_set_locator_set (vat_main_t * vam)
14438 u8 ls_name_set = 0;
14439 unformat_input_t *input = vam->input;
14440 vl_api_lisp_pitr_set_locator_set_t *mp;
14445 /* Parse args required to build the message */
14446 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14448 if (unformat (input, "del"))
14450 else if (unformat (input, "locator-set %s", &ls_name))
14454 errmsg ("parse error '%U'", format_unformat_error, input);
14461 errmsg ("locator-set name not set!");
14465 M (LISP_PITR_SET_LOCATOR_SET, mp);
14467 mp->is_add = is_add;
14468 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14469 vec_free (ls_name);
14474 /* wait for reply */
14480 api_show_lisp_pitr (vat_main_t * vam)
14482 vl_api_show_lisp_pitr_t *mp;
14485 if (!vam->json_output)
14487 print (vam->ofp, "%=20s", "lisp status:");
14490 M (SHOW_LISP_PITR, mp);
14494 /* Wait for a reply... */
14500 * Add/delete mapping between vni and vrf
14503 api_lisp_eid_table_add_del_map (vat_main_t * vam)
14505 unformat_input_t *input = vam->input;
14506 vl_api_lisp_eid_table_add_del_map_t *mp;
14507 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14508 u32 vni, vrf, bd_index;
14511 /* Parse args required to build the message */
14512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14514 if (unformat (input, "del"))
14516 else if (unformat (input, "vrf %d", &vrf))
14518 else if (unformat (input, "bd_index %d", &bd_index))
14520 else if (unformat (input, "vni %d", &vni))
14526 if (!vni_set || (!vrf_set && !bd_index_set))
14528 errmsg ("missing arguments!");
14532 if (vrf_set && bd_index_set)
14534 errmsg ("error: both vrf and bd entered!");
14538 M (LISP_EID_TABLE_ADD_DEL_MAP, mp);
14540 mp->is_add = is_add;
14541 mp->vni = htonl (vni);
14542 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14543 mp->is_l2 = bd_index_set;
14548 /* wait for reply */
14554 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14556 u32 *action = va_arg (*args, u32 *);
14559 if (unformat (input, "%s", &s))
14561 if (!strcmp ((char *) s, "no-action"))
14563 else if (!strcmp ((char *) s, "natively-forward"))
14565 else if (!strcmp ((char *) s, "send-map-request"))
14567 else if (!strcmp ((char *) s, "drop"))
14571 clib_warning ("invalid action: '%s'", s);
14583 * Add/del remote mapping to/from LISP control plane
14585 * @param vam vpp API test context
14586 * @return return code
14589 api_lisp_add_del_remote_mapping (vat_main_t * vam)
14591 unformat_input_t *input = vam->input;
14592 vl_api_lisp_add_del_remote_mapping_t *mp;
14594 lisp_eid_vat_t _eid, *eid = &_eid;
14595 lisp_eid_vat_t _seid, *seid = &_seid;
14596 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14597 u32 action = ~0, p, w, data_len;
14598 ip4_address_t rloc4;
14599 ip6_address_t rloc6;
14600 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14603 memset (&rloc, 0, sizeof (rloc));
14605 /* Parse args required to build the message */
14606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14608 if (unformat (input, "del-all"))
14612 else if (unformat (input, "del"))
14616 else if (unformat (input, "add"))
14620 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14624 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14628 else if (unformat (input, "vni %d", &vni))
14632 else if (unformat (input, "p %d w %d", &p, &w))
14636 errmsg ("No RLOC configured for setting priority/weight!");
14639 curr_rloc->priority = p;
14640 curr_rloc->weight = w;
14642 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14645 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14646 vec_add1 (rlocs, rloc);
14647 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14649 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14652 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14653 vec_add1 (rlocs, rloc);
14654 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14656 else if (unformat (input, "action %U",
14657 unformat_negative_mapping_action, &action))
14663 clib_warning ("parse error '%U'", format_unformat_error, input);
14670 errmsg ("missing params!");
14674 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14676 errmsg ("no action set for negative map-reply!");
14680 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14682 M2 (LISP_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14683 mp->is_add = is_add;
14684 mp->vni = htonl (vni);
14685 mp->action = (u8) action;
14686 mp->is_src_dst = seid_set;
14687 mp->eid_len = eid->len;
14688 mp->seid_len = seid->len;
14689 mp->del_all = del_all;
14690 mp->eid_type = eid->type;
14691 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14692 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14694 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14695 clib_memcpy (mp->rlocs, rlocs, data_len);
14701 /* Wait for a reply... */
14707 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14708 * forwarding entries in data-plane accordingly.
14710 * @param vam vpp API test context
14711 * @return return code
14714 api_lisp_add_del_adjacency (vat_main_t * vam)
14716 unformat_input_t *input = vam->input;
14717 vl_api_lisp_add_del_adjacency_t *mp;
14719 ip4_address_t leid4, reid4;
14720 ip6_address_t leid6, reid6;
14721 u8 reid_mac[6] = { 0 };
14722 u8 leid_mac[6] = { 0 };
14723 u8 reid_type, leid_type;
14724 u32 leid_len = 0, reid_len = 0, len;
14728 leid_type = reid_type = (u8) ~ 0;
14730 /* Parse args required to build the message */
14731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14733 if (unformat (input, "del"))
14737 else if (unformat (input, "add"))
14741 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14744 reid_type = 0; /* ipv4 */
14747 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14750 reid_type = 1; /* ipv6 */
14753 else if (unformat (input, "reid %U", unformat_ethernet_address,
14756 reid_type = 2; /* mac */
14758 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14761 leid_type = 0; /* ipv4 */
14764 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14767 leid_type = 1; /* ipv6 */
14770 else if (unformat (input, "leid %U", unformat_ethernet_address,
14773 leid_type = 2; /* mac */
14775 else if (unformat (input, "vni %d", &vni))
14781 errmsg ("parse error '%U'", format_unformat_error, input);
14786 if ((u8) ~ 0 == reid_type)
14788 errmsg ("missing params!");
14792 if (leid_type != reid_type)
14794 errmsg ("remote and local EIDs are of different types!");
14798 M (LISP_ADD_DEL_ADJACENCY, mp);
14799 mp->is_add = is_add;
14800 mp->vni = htonl (vni);
14801 mp->leid_len = leid_len;
14802 mp->reid_len = reid_len;
14803 mp->eid_type = reid_type;
14805 switch (mp->eid_type)
14808 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14809 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14812 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14813 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14816 clib_memcpy (mp->leid, leid_mac, 6);
14817 clib_memcpy (mp->reid, reid_mac, 6);
14820 errmsg ("unknown EID type %d!", mp->eid_type);
14827 /* Wait for a reply... */
14833 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14835 unformat_input_t *input = vam->input;
14836 vl_api_gpe_add_del_iface_t *mp;
14837 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14838 u32 dp_table = 0, vni = 0;
14841 /* Parse args required to build the message */
14842 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14844 if (unformat (input, "up"))
14849 else if (unformat (input, "down"))
14854 else if (unformat (input, "table_id %d", &dp_table))
14858 else if (unformat (input, "bd_id %d", &dp_table))
14863 else if (unformat (input, "vni %d", &vni))
14871 if (action_set == 0)
14873 errmsg ("Action not set");
14876 if (dp_table_set == 0 || vni_set == 0)
14878 errmsg ("vni and dp_table must be set");
14882 /* Construct the API message */
14883 M (GPE_ADD_DEL_IFACE, mp);
14885 mp->is_add = is_add;
14886 mp->dp_table = dp_table;
14893 /* Wait for a reply... */
14899 * Add/del map request itr rlocs from LISP control plane and updates
14901 * @param vam vpp API test context
14902 * @return return code
14905 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14907 unformat_input_t *input = vam->input;
14908 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14909 u8 *locator_set_name = 0;
14910 u8 locator_set_name_set = 0;
14914 /* Parse args required to build the message */
14915 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14917 if (unformat (input, "del"))
14921 else if (unformat (input, "%_%v%_", &locator_set_name))
14923 locator_set_name_set = 1;
14927 clib_warning ("parse error '%U'", format_unformat_error, input);
14932 if (is_add && !locator_set_name_set)
14934 errmsg ("itr-rloc is not set!");
14938 if (is_add && vec_len (locator_set_name) > 64)
14940 errmsg ("itr-rloc locator-set name too long");
14941 vec_free (locator_set_name);
14945 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14946 mp->is_add = is_add;
14949 clib_memcpy (mp->locator_set_name, locator_set_name,
14950 vec_len (locator_set_name));
14954 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14956 vec_free (locator_set_name);
14961 /* Wait for a reply... */
14967 api_lisp_locator_dump (vat_main_t * vam)
14969 unformat_input_t *input = vam->input;
14970 vl_api_lisp_locator_dump_t *mp;
14971 vl_api_control_ping_t *mp_ping;
14972 u8 is_index_set = 0, is_name_set = 0;
14977 /* Parse args required to build the message */
14978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14980 if (unformat (input, "ls_name %_%v%_", &ls_name))
14984 else if (unformat (input, "ls_index %d", &ls_index))
14990 errmsg ("parse error '%U'", format_unformat_error, input);
14995 if (!is_index_set && !is_name_set)
14997 errmsg ("error: expected one of index or name!");
15001 if (is_index_set && is_name_set)
15003 errmsg ("error: only one param expected!");
15007 if (vec_len (ls_name) > 62)
15009 errmsg ("error: locator set name too long!");
15013 if (!vam->json_output)
15015 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15018 M (LISP_LOCATOR_DUMP, mp);
15019 mp->is_index_set = is_index_set;
15022 mp->ls_index = clib_host_to_net_u32 (ls_index);
15025 vec_add1 (ls_name, 0);
15026 strncpy ((char *) mp->ls_name, (char *) ls_name,
15027 sizeof (mp->ls_name) - 1);
15033 /* Use a control ping for synchronization */
15034 M (CONTROL_PING, mp_ping);
15037 /* Wait for a reply... */
15043 api_lisp_locator_set_dump (vat_main_t * vam)
15045 vl_api_lisp_locator_set_dump_t *mp;
15046 vl_api_control_ping_t *mp_ping;
15047 unformat_input_t *input = vam->input;
15051 /* Parse args required to build the message */
15052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15054 if (unformat (input, "local"))
15058 else if (unformat (input, "remote"))
15064 errmsg ("parse error '%U'", format_unformat_error, input);
15069 if (!vam->json_output)
15071 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15074 M (LISP_LOCATOR_SET_DUMP, mp);
15076 mp->filter = filter;
15081 /* Use a control ping for synchronization */
15082 M (CONTROL_PING, mp_ping);
15085 /* Wait for a reply... */
15091 api_lisp_eid_table_map_dump (vat_main_t * vam)
15095 unformat_input_t *input = vam->input;
15096 vl_api_lisp_eid_table_map_dump_t *mp;
15097 vl_api_control_ping_t *mp_ping;
15100 /* Parse args required to build the message */
15101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15103 if (unformat (input, "l2"))
15108 else if (unformat (input, "l3"))
15115 errmsg ("parse error '%U'", format_unformat_error, input);
15122 errmsg ("expected one of 'l2' or 'l3' parameter!");
15126 if (!vam->json_output)
15128 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15131 M (LISP_EID_TABLE_MAP_DUMP, mp);
15137 /* Use a control ping for synchronization */
15138 M (CONTROL_PING, mp_ping);
15141 /* Wait for a reply... */
15147 api_lisp_eid_table_vni_dump (vat_main_t * vam)
15149 vl_api_lisp_eid_table_vni_dump_t *mp;
15150 vl_api_control_ping_t *mp_ping;
15153 if (!vam->json_output)
15155 print (vam->ofp, "VNI");
15158 M (LISP_EID_TABLE_VNI_DUMP, mp);
15163 /* Use a control ping for synchronization */
15164 M (CONTROL_PING, mp_ping);
15167 /* Wait for a reply... */
15173 api_lisp_eid_table_dump (vat_main_t * vam)
15175 unformat_input_t *i = vam->input;
15176 vl_api_lisp_eid_table_dump_t *mp;
15177 vl_api_control_ping_t *mp_ping;
15178 struct in_addr ip4;
15179 struct in6_addr ip6;
15181 u8 eid_type = ~0, eid_set = 0;
15182 u32 prefix_length = ~0, t, vni = 0;
15186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15188 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15194 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15200 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15205 else if (unformat (i, "vni %d", &t))
15209 else if (unformat (i, "local"))
15213 else if (unformat (i, "remote"))
15219 errmsg ("parse error '%U'", format_unformat_error, i);
15224 if (!vam->json_output)
15226 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15227 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15230 M (LISP_EID_TABLE_DUMP, mp);
15232 mp->filter = filter;
15236 mp->vni = htonl (vni);
15237 mp->eid_type = eid_type;
15241 mp->prefix_length = prefix_length;
15242 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15245 mp->prefix_length = prefix_length;
15246 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15249 clib_memcpy (mp->eid, mac, sizeof (mac));
15252 errmsg ("unknown EID type %d!", eid_type);
15260 /* Use a control ping for synchronization */
15261 M (CONTROL_PING, mp_ping);
15264 /* Wait for a reply... */
15270 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15272 unformat_input_t *i = vam->input;
15273 vl_api_gpe_fwd_entries_get_t *mp;
15278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15280 if (unformat (i, "vni %d", &vni))
15286 errmsg ("parse error '%U'", format_unformat_error, i);
15293 errmsg ("vni not set!");
15297 if (!vam->json_output)
15299 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15303 M (GPE_FWD_ENTRIES_GET, mp);
15304 mp->vni = clib_host_to_net_u32 (vni);
15309 /* Wait for a reply... */
15314 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15315 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15316 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15317 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15320 api_lisp_adjacencies_get (vat_main_t * vam)
15322 unformat_input_t *i = vam->input;
15323 vl_api_lisp_adjacencies_get_t *mp;
15328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15330 if (unformat (i, "vni %d", &vni))
15336 errmsg ("parse error '%U'", format_unformat_error, i);
15343 errmsg ("vni not set!");
15347 if (!vam->json_output)
15349 print (vam->ofp, "%s %40s", "leid", "reid");
15352 M (LISP_ADJACENCIES_GET, mp);
15353 mp->vni = clib_host_to_net_u32 (vni);
15358 /* Wait for a reply... */
15364 api_lisp_map_server_dump (vat_main_t * vam)
15366 vl_api_lisp_map_server_dump_t *mp;
15367 vl_api_control_ping_t *mp_ping;
15370 if (!vam->json_output)
15372 print (vam->ofp, "%=20s", "Map server");
15375 M (LISP_MAP_SERVER_DUMP, mp);
15379 /* Use a control ping for synchronization */
15380 M (CONTROL_PING, mp_ping);
15383 /* Wait for a reply... */
15389 api_lisp_map_resolver_dump (vat_main_t * vam)
15391 vl_api_lisp_map_resolver_dump_t *mp;
15392 vl_api_control_ping_t *mp_ping;
15395 if (!vam->json_output)
15397 print (vam->ofp, "%=20s", "Map resolver");
15400 M (LISP_MAP_RESOLVER_DUMP, mp);
15404 /* Use a control ping for synchronization */
15405 M (CONTROL_PING, mp_ping);
15408 /* Wait for a reply... */
15414 api_show_lisp_status (vat_main_t * vam)
15416 vl_api_show_lisp_status_t *mp;
15419 if (!vam->json_output)
15421 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
15424 M (SHOW_LISP_STATUS, mp);
15427 /* Wait for a reply... */
15433 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15435 vl_api_gpe_fwd_entry_path_dump_t *mp;
15436 vl_api_control_ping_t *mp_ping;
15437 unformat_input_t *i = vam->input;
15438 u32 fwd_entry_index = ~0;
15441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15443 if (unformat (i, "index %d", &fwd_entry_index))
15449 if (~0 == fwd_entry_index)
15451 errmsg ("no index specified!");
15455 if (!vam->json_output)
15457 print (vam->ofp, "first line");
15460 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15464 /* Use a control ping for synchronization */
15465 M (CONTROL_PING, mp_ping);
15468 /* Wait for a reply... */
15474 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
15476 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
15479 if (!vam->json_output)
15481 print (vam->ofp, "%=20s", "itr-rlocs:");
15484 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, mp);
15487 /* Wait for a reply... */
15493 api_af_packet_create (vat_main_t * vam)
15495 unformat_input_t *i = vam->input;
15496 vl_api_af_packet_create_t *mp;
15497 u8 *host_if_name = 0;
15499 u8 random_hw_addr = 1;
15502 memset (hw_addr, 0, sizeof (hw_addr));
15504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15506 if (unformat (i, "name %s", &host_if_name))
15507 vec_add1 (host_if_name, 0);
15508 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15509 random_hw_addr = 0;
15514 if (!vec_len (host_if_name))
15516 errmsg ("host-interface name must be specified");
15520 if (vec_len (host_if_name) > 64)
15522 errmsg ("host-interface name too long");
15526 M (AF_PACKET_CREATE, mp);
15528 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15529 clib_memcpy (mp->hw_addr, hw_addr, 6);
15530 mp->use_random_hw_addr = random_hw_addr;
15531 vec_free (host_if_name);
15534 W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15539 api_af_packet_delete (vat_main_t * vam)
15541 unformat_input_t *i = vam->input;
15542 vl_api_af_packet_delete_t *mp;
15543 u8 *host_if_name = 0;
15546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15548 if (unformat (i, "name %s", &host_if_name))
15549 vec_add1 (host_if_name, 0);
15554 if (!vec_len (host_if_name))
15556 errmsg ("host-interface name must be specified");
15560 if (vec_len (host_if_name) > 64)
15562 errmsg ("host-interface name too long");
15566 M (AF_PACKET_DELETE, mp);
15568 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15569 vec_free (host_if_name);
15577 api_policer_add_del (vat_main_t * vam)
15579 unformat_input_t *i = vam->input;
15580 vl_api_policer_add_del_t *mp;
15590 u8 color_aware = 0;
15591 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15594 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15595 conform_action.dscp = 0;
15596 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15597 exceed_action.dscp = 0;
15598 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15599 violate_action.dscp = 0;
15601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15603 if (unformat (i, "del"))
15605 else if (unformat (i, "name %s", &name))
15606 vec_add1 (name, 0);
15607 else if (unformat (i, "cir %u", &cir))
15609 else if (unformat (i, "eir %u", &eir))
15611 else if (unformat (i, "cb %u", &cb))
15613 else if (unformat (i, "eb %u", &eb))
15615 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15618 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15621 else if (unformat (i, "type %U", unformat_policer_type, &type))
15623 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15626 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15629 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15632 else if (unformat (i, "color-aware"))
15638 if (!vec_len (name))
15640 errmsg ("policer name must be specified");
15644 if (vec_len (name) > 64)
15646 errmsg ("policer name too long");
15650 M (POLICER_ADD_DEL, mp);
15652 clib_memcpy (mp->name, name, vec_len (name));
15654 mp->is_add = is_add;
15659 mp->rate_type = rate_type;
15660 mp->round_type = round_type;
15662 mp->conform_action_type = conform_action.action_type;
15663 mp->conform_dscp = conform_action.dscp;
15664 mp->exceed_action_type = exceed_action.action_type;
15665 mp->exceed_dscp = exceed_action.dscp;
15666 mp->violate_action_type = violate_action.action_type;
15667 mp->violate_dscp = violate_action.dscp;
15668 mp->color_aware = color_aware;
15676 api_policer_dump (vat_main_t * vam)
15678 unformat_input_t *i = vam->input;
15679 vl_api_policer_dump_t *mp;
15680 vl_api_control_ping_t *mp_ping;
15681 u8 *match_name = 0;
15682 u8 match_name_valid = 0;
15685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15687 if (unformat (i, "name %s", &match_name))
15689 vec_add1 (match_name, 0);
15690 match_name_valid = 1;
15696 M (POLICER_DUMP, mp);
15697 mp->match_name_valid = match_name_valid;
15698 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15699 vec_free (match_name);
15703 /* Use a control ping for synchronization */
15704 M (CONTROL_PING, mp_ping);
15707 /* Wait for a reply... */
15713 api_policer_classify_set_interface (vat_main_t * vam)
15715 unformat_input_t *i = vam->input;
15716 vl_api_policer_classify_set_interface_t *mp;
15718 int sw_if_index_set;
15719 u32 ip4_table_index = ~0;
15720 u32 ip6_table_index = ~0;
15721 u32 l2_table_index = ~0;
15725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15727 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15728 sw_if_index_set = 1;
15729 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15730 sw_if_index_set = 1;
15731 else if (unformat (i, "del"))
15733 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15735 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15737 else if (unformat (i, "l2-table %d", &l2_table_index))
15741 clib_warning ("parse error '%U'", format_unformat_error, i);
15746 if (sw_if_index_set == 0)
15748 errmsg ("missing interface name or sw_if_index");
15752 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15754 mp->sw_if_index = ntohl (sw_if_index);
15755 mp->ip4_table_index = ntohl (ip4_table_index);
15756 mp->ip6_table_index = ntohl (ip6_table_index);
15757 mp->l2_table_index = ntohl (l2_table_index);
15758 mp->is_add = is_add;
15766 api_policer_classify_dump (vat_main_t * vam)
15768 unformat_input_t *i = vam->input;
15769 vl_api_policer_classify_dump_t *mp;
15770 vl_api_control_ping_t *mp_ping;
15771 u8 type = POLICER_CLASSIFY_N_TABLES;
15774 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15778 errmsg ("classify table type must be specified");
15782 if (!vam->json_output)
15784 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15787 M (POLICER_CLASSIFY_DUMP, mp);
15792 /* Use a control ping for synchronization */
15793 M (CONTROL_PING, mp_ping);
15796 /* Wait for a reply... */
15802 api_netmap_create (vat_main_t * vam)
15804 unformat_input_t *i = vam->input;
15805 vl_api_netmap_create_t *mp;
15808 u8 random_hw_addr = 1;
15813 memset (hw_addr, 0, sizeof (hw_addr));
15815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15817 if (unformat (i, "name %s", &if_name))
15818 vec_add1 (if_name, 0);
15819 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15820 random_hw_addr = 0;
15821 else if (unformat (i, "pipe"))
15823 else if (unformat (i, "master"))
15825 else if (unformat (i, "slave"))
15831 if (!vec_len (if_name))
15833 errmsg ("interface name must be specified");
15837 if (vec_len (if_name) > 64)
15839 errmsg ("interface name too long");
15843 M (NETMAP_CREATE, mp);
15845 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15846 clib_memcpy (mp->hw_addr, hw_addr, 6);
15847 mp->use_random_hw_addr = random_hw_addr;
15848 mp->is_pipe = is_pipe;
15849 mp->is_master = is_master;
15850 vec_free (if_name);
15858 api_netmap_delete (vat_main_t * vam)
15860 unformat_input_t *i = vam->input;
15861 vl_api_netmap_delete_t *mp;
15865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15867 if (unformat (i, "name %s", &if_name))
15868 vec_add1 (if_name, 0);
15873 if (!vec_len (if_name))
15875 errmsg ("interface name must be specified");
15879 if (vec_len (if_name) > 64)
15881 errmsg ("interface name too long");
15885 M (NETMAP_DELETE, mp);
15887 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15888 vec_free (if_name);
15895 static void vl_api_mpls_tunnel_details_t_handler
15896 (vl_api_mpls_tunnel_details_t * mp)
15898 vat_main_t *vam = &vat_main;
15899 i32 len = mp->mt_next_hop_n_labels;
15902 print (vam->ofp, "[%d]: via %U %d labels ",
15904 format_ip4_address, mp->mt_next_hop,
15905 ntohl (mp->mt_next_hop_sw_if_index));
15906 for (i = 0; i < len; i++)
15908 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15910 print (vam->ofp, "");
15913 static void vl_api_mpls_tunnel_details_t_handler_json
15914 (vl_api_mpls_tunnel_details_t * mp)
15916 vat_main_t *vam = &vat_main;
15917 vat_json_node_t *node = NULL;
15918 struct in_addr ip4;
15920 i32 len = mp->mt_next_hop_n_labels;
15922 if (VAT_JSON_ARRAY != vam->json_tree.type)
15924 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15925 vat_json_init_array (&vam->json_tree);
15927 node = vat_json_array_add (&vam->json_tree);
15929 vat_json_init_object (node);
15930 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15931 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15932 vat_json_object_add_ip4 (node, "next_hop", ip4);
15933 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15934 ntohl (mp->mt_next_hop_sw_if_index));
15935 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15936 vat_json_object_add_uint (node, "label_count", len);
15937 for (i = 0; i < len; i++)
15939 vat_json_object_add_uint (node, "label",
15940 ntohl (mp->mt_next_hop_out_labels[i]));
15945 api_mpls_tunnel_dump (vat_main_t * vam)
15947 vl_api_mpls_tunnel_dump_t *mp;
15948 vl_api_control_ping_t *mp_ping;
15952 /* Parse args required to build the message */
15953 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15955 if (!unformat (vam->input, "tunnel_index %d", &index))
15962 print (vam->ofp, " tunnel_index %d", index);
15964 M (MPLS_TUNNEL_DUMP, mp);
15965 mp->tunnel_index = htonl (index);
15968 /* Use a control ping for synchronization */
15969 M (CONTROL_PING, mp_ping);
15976 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15977 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15980 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15982 vat_main_t *vam = &vat_main;
15983 int count = ntohl (mp->count);
15984 vl_api_fib_path2_t *fp;
15988 "table-id %d, label %u, ess_bit %u",
15989 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15991 for (i = 0; i < count; i++)
15993 if (fp->afi == IP46_TYPE_IP6)
15995 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15996 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15997 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15998 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15999 format_ip6_address, fp->next_hop);
16000 else if (fp->afi == IP46_TYPE_IP4)
16002 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16003 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16004 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16005 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16006 format_ip4_address, fp->next_hop);
16011 static void vl_api_mpls_fib_details_t_handler_json
16012 (vl_api_mpls_fib_details_t * mp)
16014 vat_main_t *vam = &vat_main;
16015 int count = ntohl (mp->count);
16016 vat_json_node_t *node = NULL;
16017 struct in_addr ip4;
16018 struct in6_addr ip6;
16019 vl_api_fib_path2_t *fp;
16022 if (VAT_JSON_ARRAY != vam->json_tree.type)
16024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16025 vat_json_init_array (&vam->json_tree);
16027 node = vat_json_array_add (&vam->json_tree);
16029 vat_json_init_object (node);
16030 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16031 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16032 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16033 vat_json_object_add_uint (node, "path_count", count);
16035 for (i = 0; i < count; i++)
16037 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16038 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16039 vat_json_object_add_uint (node, "is_local", fp->is_local);
16040 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16041 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16042 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16043 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16044 if (fp->afi == IP46_TYPE_IP4)
16046 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16047 vat_json_object_add_ip4 (node, "next_hop", ip4);
16049 else if (fp->afi == IP46_TYPE_IP6)
16051 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16052 vat_json_object_add_ip6 (node, "next_hop", ip6);
16058 api_mpls_fib_dump (vat_main_t * vam)
16060 vl_api_mpls_fib_dump_t *mp;
16061 vl_api_control_ping_t *mp_ping;
16064 M (MPLS_FIB_DUMP, mp);
16067 /* Use a control ping for synchronization */
16068 M (CONTROL_PING, mp_ping);
16075 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16076 #define vl_api_ip_fib_details_t_print vl_noop_handler
16079 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16081 vat_main_t *vam = &vat_main;
16082 int count = ntohl (mp->count);
16083 vl_api_fib_path_t *fp;
16087 "table-id %d, prefix %U/%d",
16088 ntohl (mp->table_id), format_ip4_address, mp->address,
16089 mp->address_length);
16091 for (i = 0; i < count; i++)
16093 if (fp->afi == IP46_TYPE_IP6)
16095 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16096 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16097 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16098 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16099 format_ip6_address, fp->next_hop);
16100 else if (fp->afi == IP46_TYPE_IP4)
16102 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16103 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16104 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16105 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16106 format_ip4_address, fp->next_hop);
16111 static void vl_api_ip_fib_details_t_handler_json
16112 (vl_api_ip_fib_details_t * mp)
16114 vat_main_t *vam = &vat_main;
16115 int count = ntohl (mp->count);
16116 vat_json_node_t *node = NULL;
16117 struct in_addr ip4;
16118 struct in6_addr ip6;
16119 vl_api_fib_path_t *fp;
16122 if (VAT_JSON_ARRAY != vam->json_tree.type)
16124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16125 vat_json_init_array (&vam->json_tree);
16127 node = vat_json_array_add (&vam->json_tree);
16129 vat_json_init_object (node);
16130 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16131 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16132 vat_json_object_add_ip4 (node, "prefix", ip4);
16133 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16134 vat_json_object_add_uint (node, "path_count", count);
16136 for (i = 0; i < count; i++)
16138 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16139 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16140 vat_json_object_add_uint (node, "is_local", fp->is_local);
16141 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16142 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16143 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16144 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16145 if (fp->afi == IP46_TYPE_IP4)
16147 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16148 vat_json_object_add_ip4 (node, "next_hop", ip4);
16150 else if (fp->afi == IP46_TYPE_IP6)
16152 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16153 vat_json_object_add_ip6 (node, "next_hop", ip6);
16159 api_ip_fib_dump (vat_main_t * vam)
16161 vl_api_ip_fib_dump_t *mp;
16162 vl_api_control_ping_t *mp_ping;
16165 M (IP_FIB_DUMP, mp);
16168 /* Use a control ping for synchronization */
16169 M (CONTROL_PING, mp_ping);
16177 api_ip_mfib_dump (vat_main_t * vam)
16179 vl_api_ip_mfib_dump_t *mp;
16180 vl_api_control_ping_t *mp_ping;
16183 M (IP_MFIB_DUMP, mp);
16186 /* Use a control ping for synchronization */
16187 M (CONTROL_PING, mp_ping);
16194 static void vl_api_ip_neighbor_details_t_handler
16195 (vl_api_ip_neighbor_details_t * mp)
16197 vat_main_t *vam = &vat_main;
16199 print (vam->ofp, "%c %U %U",
16200 (mp->is_static) ? 'S' : 'D',
16201 format_ethernet_address, &mp->mac_address,
16202 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16206 static void vl_api_ip_neighbor_details_t_handler_json
16207 (vl_api_ip_neighbor_details_t * mp)
16210 vat_main_t *vam = &vat_main;
16211 vat_json_node_t *node;
16212 struct in_addr ip4;
16213 struct in6_addr ip6;
16215 if (VAT_JSON_ARRAY != vam->json_tree.type)
16217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16218 vat_json_init_array (&vam->json_tree);
16220 node = vat_json_array_add (&vam->json_tree);
16222 vat_json_init_object (node);
16223 vat_json_object_add_string_copy (node, "flag",
16224 (mp->is_static) ? (u8 *) "static" : (u8 *)
16227 vat_json_object_add_string_copy (node, "link_layer",
16228 format (0, "%U", format_ethernet_address,
16229 &mp->mac_address));
16233 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16234 vat_json_object_add_ip6 (node, "ip_address", ip6);
16238 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16239 vat_json_object_add_ip4 (node, "ip_address", ip4);
16244 api_ip_neighbor_dump (vat_main_t * vam)
16246 unformat_input_t *i = vam->input;
16247 vl_api_ip_neighbor_dump_t *mp;
16248 vl_api_control_ping_t *mp_ping;
16250 u32 sw_if_index = ~0;
16253 /* Parse args required to build the message */
16254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16256 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16258 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16260 else if (unformat (i, "ip6"))
16266 if (sw_if_index == ~0)
16268 errmsg ("missing interface name or sw_if_index");
16272 M (IP_NEIGHBOR_DUMP, mp);
16273 mp->is_ipv6 = (u8) is_ipv6;
16274 mp->sw_if_index = ntohl (sw_if_index);
16277 /* Use a control ping for synchronization */
16278 M (CONTROL_PING, mp_ping);
16285 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16286 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16289 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16291 vat_main_t *vam = &vat_main;
16292 int count = ntohl (mp->count);
16293 vl_api_fib_path_t *fp;
16297 "table-id %d, prefix %U/%d",
16298 ntohl (mp->table_id), format_ip6_address, mp->address,
16299 mp->address_length);
16301 for (i = 0; i < count; i++)
16303 if (fp->afi == IP46_TYPE_IP6)
16305 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16306 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16307 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16308 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16309 format_ip6_address, fp->next_hop);
16310 else if (fp->afi == IP46_TYPE_IP4)
16312 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16313 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16314 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16315 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16316 format_ip4_address, fp->next_hop);
16321 static void vl_api_ip6_fib_details_t_handler_json
16322 (vl_api_ip6_fib_details_t * mp)
16324 vat_main_t *vam = &vat_main;
16325 int count = ntohl (mp->count);
16326 vat_json_node_t *node = NULL;
16327 struct in_addr ip4;
16328 struct in6_addr ip6;
16329 vl_api_fib_path_t *fp;
16332 if (VAT_JSON_ARRAY != vam->json_tree.type)
16334 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16335 vat_json_init_array (&vam->json_tree);
16337 node = vat_json_array_add (&vam->json_tree);
16339 vat_json_init_object (node);
16340 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16341 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16342 vat_json_object_add_ip6 (node, "prefix", ip6);
16343 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16344 vat_json_object_add_uint (node, "path_count", count);
16346 for (i = 0; i < count; i++)
16348 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16349 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16350 vat_json_object_add_uint (node, "is_local", fp->is_local);
16351 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16352 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16353 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16354 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16355 if (fp->afi == IP46_TYPE_IP4)
16357 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16358 vat_json_object_add_ip4 (node, "next_hop", ip4);
16360 else if (fp->afi == IP46_TYPE_IP6)
16362 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16363 vat_json_object_add_ip6 (node, "next_hop", ip6);
16369 api_ip6_fib_dump (vat_main_t * vam)
16371 vl_api_ip6_fib_dump_t *mp;
16372 vl_api_control_ping_t *mp_ping;
16375 M (IP6_FIB_DUMP, mp);
16378 /* Use a control ping for synchronization */
16379 M (CONTROL_PING, mp_ping);
16387 api_ip6_mfib_dump (vat_main_t * vam)
16389 vl_api_ip6_mfib_dump_t *mp;
16390 vl_api_control_ping_t *mp_ping;
16393 M (IP6_MFIB_DUMP, mp);
16396 /* Use a control ping for synchronization */
16397 M (CONTROL_PING, mp_ping);
16405 api_classify_table_ids (vat_main_t * vam)
16407 vl_api_classify_table_ids_t *mp;
16410 /* Construct the API message */
16411 M (CLASSIFY_TABLE_IDS, mp);
16420 api_classify_table_by_interface (vat_main_t * vam)
16422 unformat_input_t *input = vam->input;
16423 vl_api_classify_table_by_interface_t *mp;
16425 u32 sw_if_index = ~0;
16427 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16429 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16431 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16436 if (sw_if_index == ~0)
16438 errmsg ("missing interface name or sw_if_index");
16442 /* Construct the API message */
16443 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16445 mp->sw_if_index = ntohl (sw_if_index);
16453 api_classify_table_info (vat_main_t * vam)
16455 unformat_input_t *input = vam->input;
16456 vl_api_classify_table_info_t *mp;
16460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16462 if (unformat (input, "table_id %d", &table_id))
16467 if (table_id == ~0)
16469 errmsg ("missing table id");
16473 /* Construct the API message */
16474 M (CLASSIFY_TABLE_INFO, mp);
16476 mp->table_id = ntohl (table_id);
16484 api_classify_session_dump (vat_main_t * vam)
16486 unformat_input_t *input = vam->input;
16487 vl_api_classify_session_dump_t *mp;
16488 vl_api_control_ping_t *mp_ping;
16492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16494 if (unformat (input, "table_id %d", &table_id))
16499 if (table_id == ~0)
16501 errmsg ("missing table id");
16505 /* Construct the API message */
16506 M (CLASSIFY_SESSION_DUMP, mp);
16508 mp->table_id = ntohl (table_id);
16511 /* Use a control ping for synchronization */
16512 M (CONTROL_PING, mp_ping);
16520 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16522 vat_main_t *vam = &vat_main;
16524 print (vam->ofp, "collector_address %U, collector_port %d, "
16525 "src_address %U, vrf_id %d, path_mtu %u, "
16526 "template_interval %u, udp_checksum %d",
16527 format_ip4_address, mp->collector_address,
16528 ntohs (mp->collector_port),
16529 format_ip4_address, mp->src_address,
16530 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16531 ntohl (mp->template_interval), mp->udp_checksum);
16534 vam->result_ready = 1;
16538 vl_api_ipfix_exporter_details_t_handler_json
16539 (vl_api_ipfix_exporter_details_t * mp)
16541 vat_main_t *vam = &vat_main;
16542 vat_json_node_t node;
16543 struct in_addr collector_address;
16544 struct in_addr src_address;
16546 vat_json_init_object (&node);
16547 clib_memcpy (&collector_address, &mp->collector_address,
16548 sizeof (collector_address));
16549 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16550 vat_json_object_add_uint (&node, "collector_port",
16551 ntohs (mp->collector_port));
16552 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16553 vat_json_object_add_ip4 (&node, "src_address", src_address);
16554 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16555 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16556 vat_json_object_add_uint (&node, "template_interval",
16557 ntohl (mp->template_interval));
16558 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16560 vat_json_print (vam->ofp, &node);
16561 vat_json_free (&node);
16563 vam->result_ready = 1;
16567 api_ipfix_exporter_dump (vat_main_t * vam)
16569 vl_api_ipfix_exporter_dump_t *mp;
16572 /* Construct the API message */
16573 M (IPFIX_EXPORTER_DUMP, mp);
16582 api_ipfix_classify_stream_dump (vat_main_t * vam)
16584 vl_api_ipfix_classify_stream_dump_t *mp;
16587 /* Construct the API message */
16588 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16599 vl_api_ipfix_classify_stream_details_t_handler
16600 (vl_api_ipfix_classify_stream_details_t * mp)
16602 vat_main_t *vam = &vat_main;
16603 print (vam->ofp, "domain_id %d, src_port %d",
16604 ntohl (mp->domain_id), ntohs (mp->src_port));
16606 vam->result_ready = 1;
16610 vl_api_ipfix_classify_stream_details_t_handler_json
16611 (vl_api_ipfix_classify_stream_details_t * mp)
16613 vat_main_t *vam = &vat_main;
16614 vat_json_node_t node;
16616 vat_json_init_object (&node);
16617 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16618 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16620 vat_json_print (vam->ofp, &node);
16621 vat_json_free (&node);
16623 vam->result_ready = 1;
16627 api_ipfix_classify_table_dump (vat_main_t * vam)
16629 vl_api_ipfix_classify_table_dump_t *mp;
16630 vl_api_control_ping_t *mp_ping;
16633 if (!vam->json_output)
16635 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16636 "transport_protocol");
16639 /* Construct the API message */
16640 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16645 /* Use a control ping for synchronization */
16646 M (CONTROL_PING, mp_ping);
16654 vl_api_ipfix_classify_table_details_t_handler
16655 (vl_api_ipfix_classify_table_details_t * mp)
16657 vat_main_t *vam = &vat_main;
16658 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16659 mp->transport_protocol);
16663 vl_api_ipfix_classify_table_details_t_handler_json
16664 (vl_api_ipfix_classify_table_details_t * mp)
16666 vat_json_node_t *node = NULL;
16667 vat_main_t *vam = &vat_main;
16669 if (VAT_JSON_ARRAY != vam->json_tree.type)
16671 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16672 vat_json_init_array (&vam->json_tree);
16675 node = vat_json_array_add (&vam->json_tree);
16676 vat_json_init_object (node);
16678 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16679 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16680 vat_json_object_add_uint (node, "transport_protocol",
16681 mp->transport_protocol);
16685 api_sw_interface_span_enable_disable (vat_main_t * vam)
16687 unformat_input_t *i = vam->input;
16688 vl_api_sw_interface_span_enable_disable_t *mp;
16689 u32 src_sw_if_index = ~0;
16690 u32 dst_sw_if_index = ~0;
16694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16697 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16699 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16703 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16705 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16707 else if (unformat (i, "disable"))
16709 else if (unformat (i, "rx"))
16711 else if (unformat (i, "tx"))
16713 else if (unformat (i, "both"))
16719 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16721 mp->sw_if_index_from = htonl (src_sw_if_index);
16722 mp->sw_if_index_to = htonl (dst_sw_if_index);
16731 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16734 vat_main_t *vam = &vat_main;
16735 u8 *sw_if_from_name = 0;
16736 u8 *sw_if_to_name = 0;
16737 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16738 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16739 char *states[] = { "none", "rx", "tx", "both" };
16743 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16745 if ((u32) p->value[0] == sw_if_index_from)
16747 sw_if_from_name = (u8 *)(p->key);
16751 if ((u32) p->value[0] == sw_if_index_to)
16753 sw_if_to_name = (u8 *)(p->key);
16754 if (sw_if_from_name)
16759 print (vam->ofp, "%20s => %20s (%s)",
16760 sw_if_from_name, sw_if_to_name, states[mp->state]);
16764 vl_api_sw_interface_span_details_t_handler_json
16765 (vl_api_sw_interface_span_details_t * mp)
16767 vat_main_t *vam = &vat_main;
16768 vat_json_node_t *node = NULL;
16769 u8 *sw_if_from_name = 0;
16770 u8 *sw_if_to_name = 0;
16771 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16772 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16776 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16778 if ((u32) p->value[0] == sw_if_index_from)
16780 sw_if_from_name = (u8 *)(p->key);
16784 if ((u32) p->value[0] == sw_if_index_to)
16786 sw_if_to_name = (u8 *)(p->key);
16787 if (sw_if_from_name)
16793 if (VAT_JSON_ARRAY != vam->json_tree.type)
16795 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16796 vat_json_init_array (&vam->json_tree);
16798 node = vat_json_array_add (&vam->json_tree);
16800 vat_json_init_object (node);
16801 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16802 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16803 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16804 if (0 != sw_if_to_name)
16806 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16808 vat_json_object_add_uint (node, "state", mp->state);
16812 api_sw_interface_span_dump (vat_main_t * vam)
16814 vl_api_sw_interface_span_dump_t *mp;
16815 vl_api_control_ping_t *mp_ping;
16818 M (SW_INTERFACE_SPAN_DUMP, mp);
16821 /* Use a control ping for synchronization */
16822 M (CONTROL_PING, mp_ping);
16830 api_pg_create_interface (vat_main_t * vam)
16832 unformat_input_t *input = vam->input;
16833 vl_api_pg_create_interface_t *mp;
16837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16839 if (unformat (input, "if_id %d", &if_id))
16846 errmsg ("missing pg interface index");
16850 /* Construct the API message */
16851 M (PG_CREATE_INTERFACE, mp);
16853 mp->interface_id = ntohl (if_id);
16861 api_pg_capture (vat_main_t * vam)
16863 unformat_input_t *input = vam->input;
16864 vl_api_pg_capture_t *mp;
16869 u8 pcap_file_set = 0;
16872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16874 if (unformat (input, "if_id %d", &if_id))
16876 else if (unformat (input, "pcap %s", &pcap_file))
16878 else if (unformat (input, "count %d", &count))
16880 else if (unformat (input, "disable"))
16887 errmsg ("missing pg interface index");
16890 if (pcap_file_set > 0)
16892 if (vec_len (pcap_file) > 255)
16894 errmsg ("pcap file name is too long");
16899 u32 name_len = vec_len (pcap_file);
16900 /* Construct the API message */
16901 M (PG_CAPTURE, mp);
16903 mp->interface_id = ntohl (if_id);
16904 mp->is_enabled = enable;
16905 mp->count = ntohl (count);
16906 mp->pcap_name_length = ntohl (name_len);
16907 if (pcap_file_set != 0)
16909 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16911 vec_free (pcap_file);
16919 api_pg_enable_disable (vat_main_t * vam)
16921 unformat_input_t *input = vam->input;
16922 vl_api_pg_enable_disable_t *mp;
16925 u8 stream_name_set = 0;
16926 u8 *stream_name = 0;
16928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16930 if (unformat (input, "stream %s", &stream_name))
16931 stream_name_set = 1;
16932 else if (unformat (input, "disable"))
16938 if (stream_name_set > 0)
16940 if (vec_len (stream_name) > 255)
16942 errmsg ("stream name too long");
16947 u32 name_len = vec_len (stream_name);
16948 /* Construct the API message */
16949 M (PG_ENABLE_DISABLE, mp);
16951 mp->is_enabled = enable;
16952 if (stream_name_set != 0)
16954 mp->stream_name_length = ntohl (name_len);
16955 clib_memcpy (mp->stream_name, stream_name, name_len);
16957 vec_free (stream_name);
16965 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16967 unformat_input_t *input = vam->input;
16968 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16970 u16 *low_ports = 0;
16971 u16 *high_ports = 0;
16974 ip4_address_t ip4_addr;
16975 ip6_address_t ip6_addr;
16984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16986 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16992 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16997 else if (unformat (input, "vrf %d", &vrf_id))
16999 else if (unformat (input, "del"))
17001 else if (unformat (input, "port %d", &tmp))
17003 if (tmp == 0 || tmp > 65535)
17005 errmsg ("port %d out of range", tmp);
17009 this_hi = this_low + 1;
17010 vec_add1 (low_ports, this_low);
17011 vec_add1 (high_ports, this_hi);
17013 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17015 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17017 errmsg ("incorrect range parameters");
17021 /* Note: in debug CLI +1 is added to high before
17022 passing to real fn that does "the work"
17023 (ip_source_and_port_range_check_add_del).
17024 This fn is a wrapper around the binary API fn a
17025 control plane will call, which expects this increment
17026 to have occurred. Hence letting the binary API control
17027 plane fn do the increment for consistency between VAT
17028 and other control planes.
17031 vec_add1 (low_ports, this_low);
17032 vec_add1 (high_ports, this_hi);
17038 if (prefix_set == 0)
17040 errmsg ("<address>/<mask> not specified");
17046 errmsg ("VRF ID required, not specified");
17053 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17057 if (vec_len (low_ports) == 0)
17059 errmsg ("At least one port or port range required");
17063 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17065 mp->is_add = is_add;
17070 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17075 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17078 mp->mask_length = length;
17079 mp->number_of_ranges = vec_len (low_ports);
17081 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17082 vec_free (low_ports);
17084 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17085 vec_free (high_ports);
17087 mp->vrf_id = ntohl (vrf_id);
17095 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17097 unformat_input_t *input = vam->input;
17098 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17099 u32 sw_if_index = ~0;
17101 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17102 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17108 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17110 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17112 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17114 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17116 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17118 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17120 else if (unformat (input, "del"))
17126 if (sw_if_index == ~0)
17128 errmsg ("Interface required but not specified");
17134 errmsg ("VRF ID required but not specified");
17138 if (tcp_out_vrf_id == 0
17139 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17142 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17146 /* Construct the API message */
17147 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17149 mp->sw_if_index = ntohl (sw_if_index);
17150 mp->is_add = is_add;
17151 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17152 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17153 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17154 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17159 /* Wait for a reply... */
17165 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17167 unformat_input_t *i = vam->input;
17168 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17169 u32 local_sa_id = 0;
17170 u32 remote_sa_id = 0;
17171 ip4_address_t src_address;
17172 ip4_address_t dst_address;
17176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17178 if (unformat (i, "local_sa %d", &local_sa_id))
17180 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17182 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17184 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17186 else if (unformat (i, "del"))
17190 clib_warning ("parse error '%U'", format_unformat_error, i);
17195 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17197 mp->local_sa_id = ntohl (local_sa_id);
17198 mp->remote_sa_id = ntohl (remote_sa_id);
17199 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17200 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17201 mp->is_add = is_add;
17209 api_punt (vat_main_t * vam)
17211 unformat_input_t *i = vam->input;
17219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17221 if (unformat (i, "ip %d", &ipv))
17223 else if (unformat (i, "protocol %d", &protocol))
17225 else if (unformat (i, "port %d", &port))
17227 else if (unformat (i, "del"))
17231 clib_warning ("parse error '%U'", format_unformat_error, i);
17238 mp->is_add = (u8) is_add;
17239 mp->ipv = (u8) ipv;
17240 mp->l4_protocol = (u8) protocol;
17241 mp->l4_port = htons ((u16) port);
17248 static void vl_api_ipsec_gre_tunnel_details_t_handler
17249 (vl_api_ipsec_gre_tunnel_details_t * mp)
17251 vat_main_t *vam = &vat_main;
17253 print (vam->ofp, "%11d%15U%15U%14d%14d",
17254 ntohl (mp->sw_if_index),
17255 format_ip4_address, &mp->src_address,
17256 format_ip4_address, &mp->dst_address,
17257 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17260 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17261 (vl_api_ipsec_gre_tunnel_details_t * mp)
17263 vat_main_t *vam = &vat_main;
17264 vat_json_node_t *node = NULL;
17265 struct in_addr ip4;
17267 if (VAT_JSON_ARRAY != vam->json_tree.type)
17269 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17270 vat_json_init_array (&vam->json_tree);
17272 node = vat_json_array_add (&vam->json_tree);
17274 vat_json_init_object (node);
17275 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17276 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17277 vat_json_object_add_ip4 (node, "src_address", ip4);
17278 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17279 vat_json_object_add_ip4 (node, "dst_address", ip4);
17280 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17281 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17285 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17287 unformat_input_t *i = vam->input;
17288 vl_api_ipsec_gre_tunnel_dump_t *mp;
17289 vl_api_control_ping_t *mp_ping;
17291 u8 sw_if_index_set = 0;
17294 /* Parse args required to build the message */
17295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17297 if (unformat (i, "sw_if_index %d", &sw_if_index))
17298 sw_if_index_set = 1;
17303 if (sw_if_index_set == 0)
17308 if (!vam->json_output)
17310 print (vam->ofp, "%11s%15s%15s%14s%14s",
17311 "sw_if_index", "src_address", "dst_address",
17312 "local_sa_id", "remote_sa_id");
17315 /* Get list of gre-tunnel interfaces */
17316 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17318 mp->sw_if_index = htonl (sw_if_index);
17322 /* Use a control ping for synchronization */
17323 M (CONTROL_PING, mp_ping);
17331 api_delete_subif (vat_main_t * vam)
17333 unformat_input_t *i = vam->input;
17334 vl_api_delete_subif_t *mp;
17335 u32 sw_if_index = ~0;
17338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17340 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17342 if (unformat (i, "sw_if_index %d", &sw_if_index))
17348 if (sw_if_index == ~0)
17350 errmsg ("missing sw_if_index");
17354 /* Construct the API message */
17355 M (DELETE_SUBIF, mp);
17356 mp->sw_if_index = ntohl (sw_if_index);
17363 #define foreach_pbb_vtr_op \
17364 _("disable", L2_VTR_DISABLED) \
17365 _("pop", L2_VTR_POP_2) \
17366 _("push", L2_VTR_PUSH_2)
17369 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17371 unformat_input_t *i = vam->input;
17372 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17373 u32 sw_if_index = ~0, vtr_op = ~0;
17374 u16 outer_tag = ~0;
17375 u8 dmac[6], smac[6];
17376 u8 dmac_set = 0, smac_set = 0;
17382 /* Shut up coverity */
17383 memset (dmac, 0, sizeof (dmac));
17384 memset (smac, 0, sizeof (smac));
17386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17392 else if (unformat (i, "vtr_op %d", &vtr_op))
17394 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17397 else if (unformat (i, "translate_pbb_stag"))
17399 if (unformat (i, "%d", &tmp))
17401 vtr_op = L2_VTR_TRANSLATE_2_1;
17407 ("translate_pbb_stag operation requires outer tag definition");
17411 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17413 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17415 else if (unformat (i, "sid %d", &sid))
17417 else if (unformat (i, "vlanid %d", &tmp))
17421 clib_warning ("parse error '%U'", format_unformat_error, i);
17426 if ((sw_if_index == ~0) || (vtr_op == ~0))
17428 errmsg ("missing sw_if_index or vtr operation");
17431 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17432 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17435 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17439 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17440 mp->sw_if_index = ntohl (sw_if_index);
17441 mp->vtr_op = ntohl (vtr_op);
17442 mp->outer_tag = ntohs (outer_tag);
17443 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17444 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17445 mp->b_vlanid = ntohs (vlanid);
17446 mp->i_sid = ntohl (sid);
17454 api_flow_classify_set_interface (vat_main_t * vam)
17456 unformat_input_t *i = vam->input;
17457 vl_api_flow_classify_set_interface_t *mp;
17459 int sw_if_index_set;
17460 u32 ip4_table_index = ~0;
17461 u32 ip6_table_index = ~0;
17465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17467 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17468 sw_if_index_set = 1;
17469 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17470 sw_if_index_set = 1;
17471 else if (unformat (i, "del"))
17473 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17475 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17479 clib_warning ("parse error '%U'", format_unformat_error, i);
17484 if (sw_if_index_set == 0)
17486 errmsg ("missing interface name or sw_if_index");
17490 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17492 mp->sw_if_index = ntohl (sw_if_index);
17493 mp->ip4_table_index = ntohl (ip4_table_index);
17494 mp->ip6_table_index = ntohl (ip6_table_index);
17495 mp->is_add = is_add;
17503 api_flow_classify_dump (vat_main_t * vam)
17505 unformat_input_t *i = vam->input;
17506 vl_api_flow_classify_dump_t *mp;
17507 vl_api_control_ping_t *mp_ping;
17508 u8 type = FLOW_CLASSIFY_N_TABLES;
17511 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17515 errmsg ("classify table type must be specified");
17519 if (!vam->json_output)
17521 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17524 M (FLOW_CLASSIFY_DUMP, mp);
17529 /* Use a control ping for synchronization */
17530 M (CONTROL_PING, mp_ping);
17533 /* Wait for a reply... */
17539 api_feature_enable_disable (vat_main_t * vam)
17541 unformat_input_t *i = vam->input;
17542 vl_api_feature_enable_disable_t *mp;
17544 u8 *feature_name = 0;
17545 u32 sw_if_index = ~0;
17549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17551 if (unformat (i, "arc_name %s", &arc_name))
17553 else if (unformat (i, "feature_name %s", &feature_name))
17556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17560 else if (unformat (i, "disable"))
17568 errmsg ("missing arc name");
17571 if (vec_len (arc_name) > 63)
17573 errmsg ("arc name too long");
17576 if (feature_name == 0)
17578 errmsg ("missing feature name");
17581 if (vec_len (feature_name) > 63)
17583 errmsg ("feature name too long");
17586 if (sw_if_index == ~0)
17588 errmsg ("missing interface name or sw_if_index");
17592 /* Construct the API message */
17593 M (FEATURE_ENABLE_DISABLE, mp);
17594 mp->sw_if_index = ntohl (sw_if_index);
17595 mp->enable = enable;
17596 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17597 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17598 vec_free (arc_name);
17599 vec_free (feature_name);
17607 api_sw_interface_tag_add_del (vat_main_t * vam)
17609 unformat_input_t *i = vam->input;
17610 vl_api_sw_interface_tag_add_del_t *mp;
17611 u32 sw_if_index = ~0;
17616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17618 if (unformat (i, "tag %s", &tag))
17620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17624 else if (unformat (i, "del"))
17630 if (sw_if_index == ~0)
17632 errmsg ("missing interface name or sw_if_index");
17636 if (enable && (tag == 0))
17638 errmsg ("no tag specified");
17642 /* Construct the API message */
17643 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17644 mp->sw_if_index = ntohl (sw_if_index);
17645 mp->is_add = enable;
17647 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17655 static void vl_api_l2_xconnect_details_t_handler
17656 (vl_api_l2_xconnect_details_t * mp)
17658 vat_main_t *vam = &vat_main;
17660 print (vam->ofp, "%15d%15d",
17661 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17664 static void vl_api_l2_xconnect_details_t_handler_json
17665 (vl_api_l2_xconnect_details_t * mp)
17667 vat_main_t *vam = &vat_main;
17668 vat_json_node_t *node = NULL;
17670 if (VAT_JSON_ARRAY != vam->json_tree.type)
17672 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17673 vat_json_init_array (&vam->json_tree);
17675 node = vat_json_array_add (&vam->json_tree);
17677 vat_json_init_object (node);
17678 vat_json_object_add_uint (node, "rx_sw_if_index",
17679 ntohl (mp->rx_sw_if_index));
17680 vat_json_object_add_uint (node, "tx_sw_if_index",
17681 ntohl (mp->tx_sw_if_index));
17685 api_l2_xconnect_dump (vat_main_t * vam)
17687 vl_api_l2_xconnect_dump_t *mp;
17688 vl_api_control_ping_t *mp_ping;
17691 if (!vam->json_output)
17693 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17696 M (L2_XCONNECT_DUMP, mp);
17700 /* Use a control ping for synchronization */
17701 M (CONTROL_PING, mp_ping);
17709 api_sw_interface_set_mtu (vat_main_t * vam)
17711 unformat_input_t *i = vam->input;
17712 vl_api_sw_interface_set_mtu_t *mp;
17713 u32 sw_if_index = ~0;
17717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17719 if (unformat (i, "mtu %d", &mtu))
17721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17723 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17729 if (sw_if_index == ~0)
17731 errmsg ("missing interface name or sw_if_index");
17737 errmsg ("no mtu specified");
17741 /* Construct the API message */
17742 M (SW_INTERFACE_SET_MTU, mp);
17743 mp->sw_if_index = ntohl (sw_if_index);
17744 mp->mtu = ntohs ((u16) mtu);
17753 q_or_quit (vat_main_t * vam)
17755 longjmp (vam->jump_buf, 1);
17756 return 0; /* not so much */
17760 q (vat_main_t * vam)
17762 return q_or_quit (vam);
17766 quit (vat_main_t * vam)
17768 return q_or_quit (vam);
17772 comment (vat_main_t * vam)
17778 cmd_cmp (void *a1, void *a2)
17783 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17787 help (vat_main_t * vam)
17792 unformat_input_t *i = vam->input;
17795 if (unformat (i, "%s", &name))
17799 vec_add1 (name, 0);
17801 hs = hash_get_mem (vam->help_by_name, name);
17803 print (vam->ofp, "usage: %s %s", name, hs[0]);
17805 print (vam->ofp, "No such msg / command '%s'", name);
17810 print (vam->ofp, "Help is available for the following:");
17813 hash_foreach_pair (p, vam->function_by_name,
17815 vec_add1 (cmds, (u8 *)(p->key));
17819 vec_sort_with_function (cmds, cmd_cmp);
17821 for (j = 0; j < vec_len (cmds); j++)
17822 print (vam->ofp, "%s", cmds[j]);
17829 set (vat_main_t * vam)
17831 u8 *name = 0, *value = 0;
17832 unformat_input_t *i = vam->input;
17834 if (unformat (i, "%s", &name))
17836 /* The input buffer is a vector, not a string. */
17837 value = vec_dup (i->buffer);
17838 vec_delete (value, i->index, 0);
17839 /* Almost certainly has a trailing newline */
17840 if (value[vec_len (value) - 1] == '\n')
17841 value[vec_len (value) - 1] = 0;
17842 /* Make sure it's a proper string, one way or the other */
17843 vec_add1 (value, 0);
17844 (void) clib_macro_set_value (&vam->macro_main,
17845 (char *) name, (char *) value);
17848 errmsg ("usage: set <name> <value>");
17856 unset (vat_main_t * vam)
17860 if (unformat (vam->input, "%s", &name))
17861 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17862 errmsg ("unset: %s wasn't set", name);
17875 macro_sort_cmp (void *a1, void *a2)
17877 macro_sort_t *s1 = a1;
17878 macro_sort_t *s2 = a2;
17880 return strcmp ((char *) (s1->name), (char *) (s2->name));
17884 dump_macro_table (vat_main_t * vam)
17886 macro_sort_t *sort_me = 0, *sm;
17891 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17893 vec_add2 (sort_me, sm, 1);
17894 sm->name = (u8 *)(p->key);
17895 sm->value = (u8 *) (p->value[0]);
17899 vec_sort_with_function (sort_me, macro_sort_cmp);
17901 if (vec_len (sort_me))
17902 print (vam->ofp, "%-15s%s", "Name", "Value");
17904 print (vam->ofp, "The macro table is empty...");
17906 for (i = 0; i < vec_len (sort_me); i++)
17907 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17912 dump_node_table (vat_main_t * vam)
17915 vlib_node_t *node, *next_node;
17917 if (vec_len (vam->graph_nodes) == 0)
17919 print (vam->ofp, "Node table empty, issue get_node_graph...");
17923 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17925 node = vam->graph_nodes[i];
17926 print (vam->ofp, "[%d] %s", i, node->name);
17927 for (j = 0; j < vec_len (node->next_nodes); j++)
17929 if (node->next_nodes[j] != ~0)
17931 next_node = vam->graph_nodes[node->next_nodes[j]];
17932 print (vam->ofp, " [%d] %s", j, next_node->name);
17940 value_sort_cmp (void *a1, void *a2)
17942 name_sort_t *n1 = a1;
17943 name_sort_t *n2 = a2;
17945 if (n1->value < n2->value)
17947 if (n1->value > n2->value)
17954 dump_msg_api_table (vat_main_t * vam)
17956 api_main_t *am = &api_main;
17957 name_sort_t *nses = 0, *ns;
17962 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17964 vec_add2 (nses, ns, 1);
17965 ns->name = (u8 *)(hp->key);
17966 ns->value = (u32) hp->value[0];
17970 vec_sort_with_function (nses, value_sort_cmp);
17972 for (i = 0; i < vec_len (nses); i++)
17973 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17979 get_msg_id (vat_main_t * vam)
17984 if (unformat (vam->input, "%s", &name_and_crc))
17986 message_index = vl_api_get_msg_index (name_and_crc);
17987 if (message_index == ~0)
17989 print (vam->ofp, " '%s' not found", name_and_crc);
17992 print (vam->ofp, " '%s' has message index %d",
17993 name_and_crc, message_index);
17996 errmsg ("name_and_crc required...");
18001 search_node_table (vat_main_t * vam)
18003 unformat_input_t *line_input = vam->input;
18006 vlib_node_t *node, *next_node;
18009 if (vam->graph_node_index_by_name == 0)
18011 print (vam->ofp, "Node table empty, issue get_node_graph...");
18015 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18017 if (unformat (line_input, "%s", &node_to_find))
18019 vec_add1 (node_to_find, 0);
18020 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18023 print (vam->ofp, "%s not found...", node_to_find);
18026 node = vam->graph_nodes[p[0]];
18027 print (vam->ofp, "[%d] %s", p[0], node->name);
18028 for (j = 0; j < vec_len (node->next_nodes); j++)
18030 if (node->next_nodes[j] != ~0)
18032 next_node = vam->graph_nodes[node->next_nodes[j]];
18033 print (vam->ofp, " [%d] %s", j, next_node->name);
18040 clib_warning ("parse error '%U'", format_unformat_error,
18046 vec_free (node_to_find);
18055 script (vat_main_t * vam)
18057 #if (VPP_API_TEST_BUILTIN==0)
18059 char *save_current_file;
18060 unformat_input_t save_input;
18061 jmp_buf save_jump_buf;
18062 u32 save_line_number;
18064 FILE *new_fp, *save_ifp;
18066 if (unformat (vam->input, "%s", &s))
18068 new_fp = fopen ((char *) s, "r");
18071 errmsg ("Couldn't open script file %s", s);
18078 errmsg ("Missing script name");
18082 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18083 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18084 save_ifp = vam->ifp;
18085 save_line_number = vam->input_line_number;
18086 save_current_file = (char *) vam->current_file;
18088 vam->input_line_number = 0;
18090 vam->current_file = s;
18093 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18094 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18095 vam->ifp = save_ifp;
18096 vam->input_line_number = save_line_number;
18097 vam->current_file = (u8 *) save_current_file;
18102 clib_warning ("use the exec command...");
18108 echo (vat_main_t * vam)
18110 print (vam->ofp, "%v", vam->input->buffer);
18114 /* List of API message constructors, CLI names map to api_xxx */
18115 #define foreach_vpe_api_msg \
18116 _(create_loopback,"[mac <mac-addr>]") \
18117 _(sw_interface_dump,"") \
18118 _(sw_interface_set_flags, \
18119 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18120 _(sw_interface_add_del_address, \
18121 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18122 _(sw_interface_set_table, \
18123 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18124 _(sw_interface_set_mpls_enable, \
18125 "<intfc> | sw_if_index [disable | dis]") \
18126 _(sw_interface_set_vpath, \
18127 "<intfc> | sw_if_index <id> enable | disable") \
18128 _(sw_interface_set_vxlan_bypass, \
18129 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18130 _(sw_interface_set_l2_xconnect, \
18131 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18132 "enable | disable") \
18133 _(sw_interface_set_l2_bridge, \
18134 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18135 "[shg <split-horizon-group>] [bvi]\n" \
18136 "enable | disable") \
18137 _(bridge_domain_add_del, \
18138 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18139 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18141 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18143 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18145 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18147 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18149 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18151 "<vpp-if-name> | sw_if_index <id>") \
18152 _(sw_interface_tap_dump, "") \
18153 _(ip_add_del_route, \
18154 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18155 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18156 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18157 "[multipath] [count <n>]") \
18158 _(ip_mroute_add_del, \
18159 "<src> <grp>/<mask> [table-id <n>]\n" \
18160 "[<intfc> | sw_if_index <id>] [local] [del]") \
18161 _(mpls_route_add_del, \
18162 "<label> <eos> via <addr> [table-id <n>]\n" \
18163 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18164 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18165 "[multipath] [count <n>]") \
18166 _(mpls_ip_bind_unbind, \
18167 "<label> <addr/len>") \
18168 _(mpls_tunnel_add_del, \
18169 " via <addr> [table-id <n>]\n" \
18170 "sw_if_index <id>] [l2] [del]") \
18171 _(proxy_arp_add_del, \
18172 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18173 _(proxy_arp_intfc_enable_disable, \
18174 "<intfc> | sw_if_index <id> enable | disable") \
18175 _(sw_interface_set_unnumbered, \
18176 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18177 _(ip_neighbor_add_del, \
18178 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18179 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18180 _(reset_vrf, "vrf <id> [ipv6]") \
18181 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18182 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18183 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18184 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18185 "[outer_vlan_id_any][inner_vlan_id_any]") \
18186 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18187 _(reset_fib, "vrf <n> [ipv6]") \
18188 _(dhcp_proxy_config, \
18189 "svr <v46-address> src <v46-address>\n" \
18190 "insert-cid <n> [del]") \
18191 _(dhcp_proxy_config_2, \
18192 "svr <v46-address> src <v46-address>\n" \
18193 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
18194 _(dhcp_proxy_set_vss, \
18195 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18196 _(dhcp_client_config, \
18197 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18198 _(set_ip_flow_hash, \
18199 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18200 _(sw_interface_ip6_enable_disable, \
18201 "<intfc> | sw_if_index <id> enable | disable") \
18202 _(sw_interface_ip6_set_link_local_address, \
18203 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18204 _(sw_interface_ip6nd_ra_prefix, \
18205 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18206 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18207 "[nolink] [isno]") \
18208 _(sw_interface_ip6nd_ra_config, \
18209 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18210 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18211 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18212 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18213 _(l2_patch_add_del, \
18214 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18215 "enable | disable") \
18216 _(sr_tunnel_add_del, \
18217 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
18218 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
18219 "[policy <policy_name>]") \
18220 _(sr_policy_add_del, \
18221 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
18222 _(sr_multicast_map_add_del, \
18223 "address [ip6 multicast address] sr-policy [policy name] [del]") \
18224 _(classify_add_del_table, \
18225 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18226 " [del] [del-chain] mask <mask-value>\n" \
18227 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18228 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18229 _(classify_add_del_session, \
18230 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18231 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18232 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18233 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18234 _(classify_set_interface_ip_table, \
18235 "<intfc> | sw_if_index <nn> table <nn>") \
18236 _(classify_set_interface_l2_tables, \
18237 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18238 " [other-table <nn>]") \
18239 _(get_node_index, "node <node-name") \
18240 _(add_node_next, "node <node-name> next <next-node-name>") \
18241 _(l2tpv3_create_tunnel, \
18242 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18243 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18244 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18245 _(l2tpv3_set_tunnel_cookies, \
18246 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18247 "[new_remote_cookie <nn>]\n") \
18248 _(l2tpv3_interface_enable_disable, \
18249 "<intfc> | sw_if_index <nn> enable | disable") \
18250 _(l2tpv3_set_lookup_key, \
18251 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18252 _(sw_if_l2tpv3_tunnel_dump, "") \
18253 _(vxlan_add_del_tunnel, \
18254 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18255 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18256 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18257 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18258 _(gre_add_del_tunnel, \
18259 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18260 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18261 _(l2_fib_clear_table, "") \
18262 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18263 _(l2_interface_vlan_tag_rewrite, \
18264 "<intfc> | sw_if_index <nn> \n" \
18265 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18266 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18267 _(create_vhost_user_if, \
18268 "socket <filename> [server] [renumber <dev_instance>] " \
18269 "[mac <mac_address>]") \
18270 _(modify_vhost_user_if, \
18271 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18272 "[server] [renumber <dev_instance>]") \
18273 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18274 _(sw_interface_vhost_user_dump, "") \
18275 _(show_version, "") \
18276 _(vxlan_gpe_add_del_tunnel, \
18277 "local <addr> remote <addr> vni <nn>\n" \
18278 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18279 "[next-ethernet] [next-nsh]\n") \
18280 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18281 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18282 _(interface_name_renumber, \
18283 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18284 _(input_acl_set_interface, \
18285 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18286 " [l2-table <nn>] [del]") \
18287 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18288 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18289 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18290 _(ip_dump, "ipv4 | ipv6") \
18291 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18292 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18294 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18295 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18296 " integ_alg <alg> integ_key <hex>") \
18297 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18298 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18299 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18300 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18301 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18302 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18303 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18304 "(auth_data 0x<data> | auth_data <data>)") \
18305 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18306 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18307 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18308 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18309 "(local|remote)") \
18310 _(ikev2_set_local_key, "file <absolute_file_path>") \
18311 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18312 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18313 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18314 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18315 _(ikev2_initiate_sa_init, "<profile_name>") \
18316 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18317 _(ikev2_initiate_del_child_sa, "<ispi>") \
18318 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18319 _(delete_loopback,"sw_if_index <nn>") \
18320 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18321 _(map_add_domain, \
18322 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18323 "ip6-src <ip6addr> " \
18324 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18325 _(map_del_domain, "index <n>") \
18326 _(map_add_del_rule, \
18327 "index <n> psid <n> dst <ip6addr> [del]") \
18328 _(map_domain_dump, "") \
18329 _(map_rule_dump, "index <map-domain>") \
18330 _(want_interface_events, "enable|disable") \
18331 _(want_stats,"enable|disable") \
18332 _(get_first_msg_id, "client <name>") \
18333 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18334 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18335 "fib-id <nn> [ip4][ip6][default]") \
18336 _(get_node_graph, " ") \
18337 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18338 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18339 _(ioam_disable, "") \
18340 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18341 " sw_if_index <sw_if_index> p <priority> " \
18342 "w <weight>] [del]") \
18343 _(lisp_add_del_locator, "locator-set <locator_name> " \
18344 "iface <intf> | sw_if_index <sw_if_index> " \
18345 "p <priority> w <weight> [del]") \
18346 _(lisp_add_del_local_eid,"vni <vni> eid " \
18347 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18348 "locator-set <locator_name> [del]" \
18349 "[key-id sha1|sha256 secret-key <secret-key>]") \
18350 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18351 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18352 _(lisp_enable_disable, "enable|disable") \
18353 _(lisp_map_register_enable_disable, "enable|disable") \
18354 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18355 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18357 "rloc <locator> p <prio> " \
18358 "w <weight> [rloc <loc> ... ] " \
18359 "action <action> [del-all]") \
18360 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18362 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18363 _(lisp_map_request_mode, "src-dst|dst-only") \
18364 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18365 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18366 _(lisp_locator_set_dump, "[local | remote]") \
18367 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18368 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18369 "[local] | [remote]") \
18370 _(lisp_eid_table_vni_dump, "") \
18371 _(lisp_eid_table_map_dump, "l2|l3") \
18372 _(lisp_map_resolver_dump, "") \
18373 _(lisp_map_server_dump, "") \
18374 _(lisp_adjacencies_get, "vni <vni>") \
18375 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18376 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18377 _(lisp_gpe_add_del_iface, "up|down") \
18378 _(lisp_gpe_enable_disable, "enable|disable") \
18379 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18380 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18381 _(show_lisp_rloc_probe_state, "") \
18382 _(show_lisp_map_register_state, "") \
18383 _(show_lisp_status, "") \
18384 _(lisp_get_map_request_itr_rlocs, "") \
18385 _(show_lisp_pitr, "") \
18386 _(show_lisp_map_request_mode, "") \
18387 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18388 _(af_packet_delete, "name <host interface name>") \
18389 _(policer_add_del, "name <policer name> <params> [del]") \
18390 _(policer_dump, "[name <policer name>]") \
18391 _(policer_classify_set_interface, \
18392 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18393 " [l2-table <nn>] [del]") \
18394 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18395 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18396 "[master|slave]") \
18397 _(netmap_delete, "name <interface name>") \
18398 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18399 _(mpls_fib_dump, "") \
18400 _(classify_table_ids, "") \
18401 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18402 _(classify_table_info, "table_id <nn>") \
18403 _(classify_session_dump, "table_id <nn>") \
18404 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18405 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18406 "[template_interval <nn>] [udp_checksum]") \
18407 _(ipfix_exporter_dump, "") \
18408 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18409 _(ipfix_classify_stream_dump, "") \
18410 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18411 _(ipfix_classify_table_dump, "") \
18412 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18413 _(sw_interface_span_dump, "") \
18414 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18415 _(pg_create_interface, "if_id <nn>") \
18416 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18417 _(pg_enable_disable, "[stream <id>] disable") \
18418 _(ip_source_and_port_range_check_add_del, \
18419 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18420 _(ip_source_and_port_range_check_interface_add_del, \
18421 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18422 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18423 _(ipsec_gre_add_del_tunnel, \
18424 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18425 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18426 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18427 _(l2_interface_pbb_tag_rewrite, \
18428 "<intfc> | sw_if_index <nn> \n" \
18429 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18430 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18431 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18432 _(flow_classify_set_interface, \
18433 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18434 _(flow_classify_dump, "type [ip4|ip6]") \
18435 _(ip_fib_dump, "") \
18436 _(ip_mfib_dump, "") \
18437 _(ip6_fib_dump, "") \
18438 _(ip6_mfib_dump, "") \
18439 _(feature_enable_disable, "arc_name <arc_name> " \
18440 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18441 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18443 _(l2_xconnect_dump, "") \
18444 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18445 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18446 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18449 #define foreach_vpe_dpdk_api_msg \
18450 _(sw_interface_set_dpdk_hqos_pipe, \
18451 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
18452 "profile <profile-id>\n") \
18453 _(sw_interface_set_dpdk_hqos_subport, \
18454 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
18455 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
18456 _(sw_interface_set_dpdk_hqos_tctbl, \
18457 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
18460 /* List of command functions, CLI names map directly to functions */
18461 #define foreach_cli_function \
18462 _(comment, "usage: comment <ignore-rest-of-line>") \
18463 _(dump_interface_table, "usage: dump_interface_table") \
18464 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18465 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18466 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18467 _(dump_stats_table, "usage: dump_stats_table") \
18468 _(dump_macro_table, "usage: dump_macro_table ") \
18469 _(dump_node_table, "usage: dump_node_table") \
18470 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18471 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18472 _(echo, "usage: echo <message>") \
18473 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18474 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18475 _(help, "usage: help") \
18476 _(q, "usage: quit") \
18477 _(quit, "usage: quit") \
18478 _(search_node_table, "usage: search_node_table <name>...") \
18479 _(set, "usage: set <variable-name> <value>") \
18480 _(script, "usage: script <file-name>") \
18481 _(unset, "usage: unset <variable-name>")
18484 static void vl_api_##n##_t_handler_uni \
18485 (vl_api_##n##_t * mp) \
18487 vat_main_t * vam = &vat_main; \
18488 if (vam->json_output) { \
18489 vl_api_##n##_t_handler_json(mp); \
18491 vl_api_##n##_t_handler(mp); \
18494 foreach_vpe_api_reply_msg;
18499 static void vl_api_##n##_t_handler_uni \
18500 (vl_api_##n##_t * mp) \
18502 vat_main_t * vam = &vat_main; \
18503 if (vam->json_output) { \
18504 vl_api_##n##_t_handler_json(mp); \
18506 vl_api_##n##_t_handler(mp); \
18509 foreach_vpe_dpdk_api_reply_msg;
18514 vat_api_hookup (vat_main_t * vam)
18517 vl_msg_api_set_handlers(VL_API_##N, #n, \
18518 vl_api_##n##_t_handler_uni, \
18520 vl_api_##n##_t_endian, \
18521 vl_api_##n##_t_print, \
18522 sizeof(vl_api_##n##_t), 1);
18523 foreach_vpe_api_reply_msg;
18528 vl_msg_api_set_handlers(VL_API_##N, #n, \
18529 vl_api_##n##_t_handler_uni, \
18531 vl_api_##n##_t_endian, \
18532 vl_api_##n##_t_print, \
18533 sizeof(vl_api_##n##_t), 1);
18534 foreach_vpe_dpdk_api_reply_msg;
18538 #if (VPP_API_TEST_BUILTIN==0)
18539 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18542 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18544 vam->function_by_name = hash_create_string (0, sizeof (uword));
18546 vam->help_by_name = hash_create_string (0, sizeof (uword));
18548 /* API messages we can send */
18549 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18550 foreach_vpe_api_msg;
18553 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18554 foreach_vpe_dpdk_api_msg;
18559 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18560 foreach_vpe_api_msg;
18563 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18564 foreach_vpe_dpdk_api_msg;
18568 /* CLI functions */
18569 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18570 foreach_cli_function;
18574 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18575 foreach_cli_function;
18580 * fd.io coding-style-patch-verification: ON
18583 * eval: (c-set-style "gnu")