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);
115 #if VPP_API_TEST_BUILTIN == 0
117 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
119 vat_main_t *vam = va_arg (*args, vat_main_t *);
120 u32 *result = va_arg (*args, u32 *);
124 if (!unformat (input, "%s", &if_name))
127 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
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 #else /* VPP_API_TEST_BUILTIN == 1 */
392 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
394 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
395 vnet_main_t *vnm = vnet_get_main ();
396 u32 *result = va_arg (*args, u32 *);
399 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
402 *result = sw_if_index;
405 #endif /* VPP_API_TEST_BUILTIN */
408 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
410 u8 *r = va_arg (*args, u8 *);
412 if (unformat (input, "kbps"))
413 *r = SSE2_QOS_RATE_KBPS;
414 else if (unformat (input, "pps"))
415 *r = SSE2_QOS_RATE_PPS;
422 unformat_policer_round_type (unformat_input_t * input, va_list * args)
424 u8 *r = va_arg (*args, u8 *);
426 if (unformat (input, "closest"))
427 *r = SSE2_QOS_ROUND_TO_CLOSEST;
428 else if (unformat (input, "up"))
429 *r = SSE2_QOS_ROUND_TO_UP;
430 else if (unformat (input, "down"))
431 *r = SSE2_QOS_ROUND_TO_DOWN;
438 unformat_policer_type (unformat_input_t * input, va_list * args)
440 u8 *r = va_arg (*args, u8 *);
442 if (unformat (input, "1r2c"))
443 *r = SSE2_QOS_POLICER_TYPE_1R2C;
444 else if (unformat (input, "1r3c"))
445 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
446 else if (unformat (input, "2r3c-2698"))
447 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
448 else if (unformat (input, "2r3c-4115"))
449 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
450 else if (unformat (input, "2r3c-mef5cf1"))
451 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
458 unformat_dscp (unformat_input_t * input, va_list * va)
460 u8 *r = va_arg (*va, u8 *);
463 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
472 unformat_policer_action_type (unformat_input_t * input, va_list * va)
474 sse2_qos_pol_action_params_st *a
475 = va_arg (*va, sse2_qos_pol_action_params_st *);
477 if (unformat (input, "drop"))
478 a->action_type = SSE2_QOS_ACTION_DROP;
479 else if (unformat (input, "transmit"))
480 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
481 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
482 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
489 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
491 u32 *r = va_arg (*va, u32 *);
494 if (unformat (input, "ip4"))
495 tid = POLICER_CLASSIFY_TABLE_IP4;
496 else if (unformat (input, "ip6"))
497 tid = POLICER_CLASSIFY_TABLE_IP6;
498 else if (unformat (input, "l2"))
499 tid = POLICER_CLASSIFY_TABLE_L2;
508 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
510 u32 *r = va_arg (*va, u32 *);
513 if (unformat (input, "ip4"))
514 tid = FLOW_CLASSIFY_TABLE_IP4;
515 else if (unformat (input, "ip6"))
516 tid = FLOW_CLASSIFY_TABLE_IP6;
524 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
525 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
526 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
527 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
529 #if (VPP_API_TEST_BUILTIN==0)
531 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
533 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
534 mfib_itf_attribute_t attr;
537 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
539 if (unformat (input, mfib_itf_flag_long_names[attr]))
540 *iflags |= (1 << attr);
542 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
544 if (unformat (input, mfib_itf_flag_names[attr]))
545 *iflags |= (1 << attr);
548 return (old == *iflags ? 0 : 1);
552 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
554 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
555 mfib_entry_attribute_t attr;
558 FOR_EACH_MFIB_ATTRIBUTE (attr)
560 if (unformat (input, mfib_flag_long_names[attr]))
561 *eflags |= (1 << attr);
563 FOR_EACH_MFIB_ATTRIBUTE (attr)
565 if (unformat (input, mfib_flag_names[attr]))
566 *eflags |= (1 << attr);
569 return (old == *eflags ? 0 : 1);
573 format_ip4_address (u8 * s, va_list * args)
575 u8 *a = va_arg (*args, u8 *);
576 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
580 format_ip6_address (u8 * s, va_list * args)
582 ip6_address_t *a = va_arg (*args, ip6_address_t *);
583 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
585 i_max_n_zero = ARRAY_LEN (a->as_u16);
587 i_first_zero = i_max_n_zero;
589 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
591 u32 is_zero = a->as_u16[i] == 0;
592 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
598 if ((!is_zero && n_zeros > max_n_zeros)
599 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
601 i_max_n_zero = i_first_zero;
602 max_n_zeros = n_zeros;
603 i_first_zero = ARRAY_LEN (a->as_u16);
608 last_double_colon = 0;
609 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
611 if (i == i_max_n_zero && max_n_zeros > 1)
613 s = format (s, "::");
614 i += max_n_zeros - 1;
615 last_double_colon = 1;
619 s = format (s, "%s%x",
620 (last_double_colon || i == 0) ? "" : ":",
621 clib_net_to_host_u16 (a->as_u16[i]));
622 last_double_colon = 0;
629 /* Format an IP46 address. */
631 format_ip46_address (u8 * s, va_list * args)
633 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
634 ip46_type_t type = va_arg (*args, ip46_type_t);
640 is_ip4 = ip46_address_is_ip4 (ip46);
651 format (s, "%U", format_ip4_address, &ip46->ip4) :
652 format (s, "%U", format_ip6_address, &ip46->ip6);
656 format_ethernet_address (u8 * s, va_list * args)
658 u8 *a = va_arg (*args, u8 *);
660 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
661 a[0], a[1], a[2], a[3], a[4], a[5]);
666 increment_v4_address (ip4_address_t * a)
670 v = ntohl (a->as_u32) + 1;
671 a->as_u32 = ntohl (v);
675 increment_v6_address (ip6_address_t * a)
679 v0 = clib_net_to_host_u64 (a->as_u64[0]);
680 v1 = clib_net_to_host_u64 (a->as_u64[1]);
685 a->as_u64[0] = clib_net_to_host_u64 (v0);
686 a->as_u64[1] = clib_net_to_host_u64 (v1);
690 increment_mac_address (u64 * mac)
694 tmp = clib_net_to_host_u64 (tmp);
695 tmp += 1 << 16; /* skip unused (least significant) octets */
696 tmp = clib_host_to_net_u64 (tmp);
700 static void vl_api_create_loopback_reply_t_handler
701 (vl_api_create_loopback_reply_t * mp)
703 vat_main_t *vam = &vat_main;
704 i32 retval = ntohl (mp->retval);
706 vam->retval = retval;
707 vam->regenerate_interface_table = 1;
708 vam->sw_if_index = ntohl (mp->sw_if_index);
709 vam->result_ready = 1;
712 static void vl_api_create_loopback_reply_t_handler_json
713 (vl_api_create_loopback_reply_t * mp)
715 vat_main_t *vam = &vat_main;
716 vat_json_node_t node;
718 vat_json_init_object (&node);
719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
720 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
722 vat_json_print (vam->ofp, &node);
723 vat_json_free (&node);
724 vam->retval = ntohl (mp->retval);
725 vam->result_ready = 1;
728 static void vl_api_af_packet_create_reply_t_handler
729 (vl_api_af_packet_create_reply_t * mp)
731 vat_main_t *vam = &vat_main;
732 i32 retval = ntohl (mp->retval);
734 vam->retval = retval;
735 vam->regenerate_interface_table = 1;
736 vam->sw_if_index = ntohl (mp->sw_if_index);
737 vam->result_ready = 1;
740 static void vl_api_af_packet_create_reply_t_handler_json
741 (vl_api_af_packet_create_reply_t * mp)
743 vat_main_t *vam = &vat_main;
744 vat_json_node_t node;
746 vat_json_init_object (&node);
747 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
748 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
750 vat_json_print (vam->ofp, &node);
751 vat_json_free (&node);
753 vam->retval = ntohl (mp->retval);
754 vam->result_ready = 1;
757 static void vl_api_create_vlan_subif_reply_t_handler
758 (vl_api_create_vlan_subif_reply_t * mp)
760 vat_main_t *vam = &vat_main;
761 i32 retval = ntohl (mp->retval);
763 vam->retval = retval;
764 vam->regenerate_interface_table = 1;
765 vam->sw_if_index = ntohl (mp->sw_if_index);
766 vam->result_ready = 1;
769 static void vl_api_create_vlan_subif_reply_t_handler_json
770 (vl_api_create_vlan_subif_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 vat_json_node_t node;
775 vat_json_init_object (&node);
776 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
777 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
779 vat_json_print (vam->ofp, &node);
780 vat_json_free (&node);
782 vam->retval = ntohl (mp->retval);
783 vam->result_ready = 1;
786 static void vl_api_create_subif_reply_t_handler
787 (vl_api_create_subif_reply_t * mp)
789 vat_main_t *vam = &vat_main;
790 i32 retval = ntohl (mp->retval);
792 vam->retval = retval;
793 vam->regenerate_interface_table = 1;
794 vam->sw_if_index = ntohl (mp->sw_if_index);
795 vam->result_ready = 1;
798 static void vl_api_create_subif_reply_t_handler_json
799 (vl_api_create_subif_reply_t * mp)
801 vat_main_t *vam = &vat_main;
802 vat_json_node_t node;
804 vat_json_init_object (&node);
805 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
806 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
808 vat_json_print (vam->ofp, &node);
809 vat_json_free (&node);
811 vam->retval = ntohl (mp->retval);
812 vam->result_ready = 1;
815 static void vl_api_interface_name_renumber_reply_t_handler
816 (vl_api_interface_name_renumber_reply_t * mp)
818 vat_main_t *vam = &vat_main;
819 i32 retval = ntohl (mp->retval);
821 vam->retval = retval;
822 vam->regenerate_interface_table = 1;
823 vam->result_ready = 1;
826 static void vl_api_interface_name_renumber_reply_t_handler_json
827 (vl_api_interface_name_renumber_reply_t * mp)
829 vat_main_t *vam = &vat_main;
830 vat_json_node_t node;
832 vat_json_init_object (&node);
833 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
843 * Special-case: build the interface table, maintain
844 * the next loopback sw_if_index vbl.
846 static void vl_api_sw_interface_details_t_handler
847 (vl_api_sw_interface_details_t * mp)
849 vat_main_t *vam = &vat_main;
850 u8 *s = format (0, "%s%c", mp->interface_name, 0);
852 hash_set_mem (vam->sw_if_index_by_interface_name, s,
853 ntohl (mp->sw_if_index));
855 /* In sub interface case, fill the sub interface table entry */
856 if (mp->sw_if_index != mp->sup_sw_if_index)
858 sw_interface_subif_t *sub = NULL;
860 vec_add2 (vam->sw_if_subif_table, sub, 1);
862 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
863 strncpy ((char *) sub->interface_name, (char *) s,
864 vec_len (sub->interface_name));
865 sub->sw_if_index = ntohl (mp->sw_if_index);
866 sub->sub_id = ntohl (mp->sub_id);
868 sub->sub_dot1ad = mp->sub_dot1ad;
869 sub->sub_number_of_tags = mp->sub_number_of_tags;
870 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
871 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
872 sub->sub_exact_match = mp->sub_exact_match;
873 sub->sub_default = mp->sub_default;
874 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
875 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
877 /* vlan tag rewrite */
878 sub->vtr_op = ntohl (mp->vtr_op);
879 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
880 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
881 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
885 static void vl_api_sw_interface_details_t_handler_json
886 (vl_api_sw_interface_details_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t *node = NULL;
891 if (VAT_JSON_ARRAY != vam->json_tree.type)
893 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
894 vat_json_init_array (&vam->json_tree);
896 node = vat_json_array_add (&vam->json_tree);
898 vat_json_init_object (node);
899 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
900 vat_json_object_add_uint (node, "sup_sw_if_index",
901 ntohl (mp->sup_sw_if_index));
902 vat_json_object_add_uint (node, "l2_address_length",
903 ntohl (mp->l2_address_length));
904 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
905 sizeof (mp->l2_address));
906 vat_json_object_add_string_copy (node, "interface_name",
908 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
909 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
910 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
911 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
912 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
913 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
914 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
915 vat_json_object_add_uint (node, "sub_number_of_tags",
916 mp->sub_number_of_tags);
917 vat_json_object_add_uint (node, "sub_outer_vlan_id",
918 ntohs (mp->sub_outer_vlan_id));
919 vat_json_object_add_uint (node, "sub_inner_vlan_id",
920 ntohs (mp->sub_inner_vlan_id));
921 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
922 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
923 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
924 mp->sub_outer_vlan_id_any);
925 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
926 mp->sub_inner_vlan_id_any);
927 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
928 vat_json_object_add_uint (node, "vtr_push_dot1q",
929 ntohl (mp->vtr_push_dot1q));
930 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
931 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
934 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
936 format_ethernet_address,
938 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
940 format_ethernet_address,
942 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
943 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
947 static void vl_api_sw_interface_set_flags_t_handler
948 (vl_api_sw_interface_set_flags_t * mp)
950 vat_main_t *vam = &vat_main;
951 if (vam->interface_event_display)
952 errmsg ("interface flags: sw_if_index %d %s %s",
953 ntohl (mp->sw_if_index),
954 mp->admin_up_down ? "admin-up" : "admin-down",
955 mp->link_up_down ? "link-up" : "link-down");
958 static void vl_api_sw_interface_set_flags_t_handler_json
959 (vl_api_sw_interface_set_flags_t * mp)
961 /* JSON output not supported */
965 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
967 vat_main_t *vam = &vat_main;
968 i32 retval = ntohl (mp->retval);
970 vam->retval = retval;
971 vam->shmem_result = (u8 *) mp->reply_in_shmem;
972 vam->result_ready = 1;
976 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
978 vat_main_t *vam = &vat_main;
979 vat_json_node_t node;
980 api_main_t *am = &api_main;
984 vat_json_init_object (&node);
985 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
986 vat_json_object_add_uint (&node, "reply_in_shmem",
987 ntohl (mp->reply_in_shmem));
988 /* Toss the shared-memory original... */
989 pthread_mutex_lock (&am->vlib_rp->mutex);
990 oldheap = svm_push_data_heap (am->vlib_rp);
992 reply = (u8 *) (mp->reply_in_shmem);
995 svm_pop_heap (oldheap);
996 pthread_mutex_unlock (&am->vlib_rp->mutex);
998 vat_json_print (vam->ofp, &node);
999 vat_json_free (&node);
1001 vam->retval = ntohl (mp->retval);
1002 vam->result_ready = 1;
1006 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1008 vat_main_t *vam = &vat_main;
1009 i32 retval = ntohl (mp->retval);
1011 vam->retval = retval;
1012 vam->cmd_reply = mp->reply;
1013 vam->result_ready = 1;
1017 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1019 vat_main_t *vam = &vat_main;
1020 vat_json_node_t node;
1022 vat_json_init_object (&node);
1023 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1024 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1026 vat_json_print (vam->ofp, &node);
1027 vat_json_free (&node);
1029 vam->retval = ntohl (mp->retval);
1030 vam->result_ready = 1;
1033 static void vl_api_classify_add_del_table_reply_t_handler
1034 (vl_api_classify_add_del_table_reply_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 i32 retval = ntohl (mp->retval);
1038 if (vam->async_mode)
1040 vam->async_errors += (retval < 0);
1044 vam->retval = retval;
1046 ((mp->new_table_index != 0xFFFFFFFF) ||
1047 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1048 (mp->match_n_vectors != 0xFFFFFFFF)))
1050 * Note: this is just barely thread-safe, depends on
1051 * the main thread spinning waiting for an answer...
1053 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1054 ntohl (mp->new_table_index),
1055 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1056 vam->result_ready = 1;
1060 static void vl_api_classify_add_del_table_reply_t_handler_json
1061 (vl_api_classify_add_del_table_reply_t * mp)
1063 vat_main_t *vam = &vat_main;
1064 vat_json_node_t node;
1066 vat_json_init_object (&node);
1067 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1068 vat_json_object_add_uint (&node, "new_table_index",
1069 ntohl (mp->new_table_index));
1070 vat_json_object_add_uint (&node, "skip_n_vectors",
1071 ntohl (mp->skip_n_vectors));
1072 vat_json_object_add_uint (&node, "match_n_vectors",
1073 ntohl (mp->match_n_vectors));
1075 vat_json_print (vam->ofp, &node);
1076 vat_json_free (&node);
1078 vam->retval = ntohl (mp->retval);
1079 vam->result_ready = 1;
1082 static void vl_api_get_node_index_reply_t_handler
1083 (vl_api_get_node_index_reply_t * mp)
1085 vat_main_t *vam = &vat_main;
1086 i32 retval = ntohl (mp->retval);
1087 if (vam->async_mode)
1089 vam->async_errors += (retval < 0);
1093 vam->retval = retval;
1095 errmsg ("node index %d", ntohl (mp->node_index));
1096 vam->result_ready = 1;
1100 static void vl_api_get_node_index_reply_t_handler_json
1101 (vl_api_get_node_index_reply_t * mp)
1103 vat_main_t *vam = &vat_main;
1104 vat_json_node_t node;
1106 vat_json_init_object (&node);
1107 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1108 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1110 vat_json_print (vam->ofp, &node);
1111 vat_json_free (&node);
1113 vam->retval = ntohl (mp->retval);
1114 vam->result_ready = 1;
1117 static void vl_api_get_next_index_reply_t_handler
1118 (vl_api_get_next_index_reply_t * mp)
1120 vat_main_t *vam = &vat_main;
1121 i32 retval = ntohl (mp->retval);
1122 if (vam->async_mode)
1124 vam->async_errors += (retval < 0);
1128 vam->retval = retval;
1130 errmsg ("next node index %d", ntohl (mp->next_index));
1131 vam->result_ready = 1;
1135 static void vl_api_get_next_index_reply_t_handler_json
1136 (vl_api_get_next_index_reply_t * mp)
1138 vat_main_t *vam = &vat_main;
1139 vat_json_node_t node;
1141 vat_json_init_object (&node);
1142 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1143 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1145 vat_json_print (vam->ofp, &node);
1146 vat_json_free (&node);
1148 vam->retval = ntohl (mp->retval);
1149 vam->result_ready = 1;
1152 static void vl_api_add_node_next_reply_t_handler
1153 (vl_api_add_node_next_reply_t * mp)
1155 vat_main_t *vam = &vat_main;
1156 i32 retval = ntohl (mp->retval);
1157 if (vam->async_mode)
1159 vam->async_errors += (retval < 0);
1163 vam->retval = retval;
1165 errmsg ("next index %d", ntohl (mp->next_index));
1166 vam->result_ready = 1;
1170 static void vl_api_add_node_next_reply_t_handler_json
1171 (vl_api_add_node_next_reply_t * mp)
1173 vat_main_t *vam = &vat_main;
1174 vat_json_node_t node;
1176 vat_json_init_object (&node);
1177 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1178 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1180 vat_json_print (vam->ofp, &node);
1181 vat_json_free (&node);
1183 vam->retval = ntohl (mp->retval);
1184 vam->result_ready = 1;
1187 static void vl_api_show_version_reply_t_handler
1188 (vl_api_show_version_reply_t * mp)
1190 vat_main_t *vam = &vat_main;
1191 i32 retval = ntohl (mp->retval);
1195 errmsg (" program: %s", mp->program);
1196 errmsg (" version: %s", mp->version);
1197 errmsg (" build date: %s", mp->build_date);
1198 errmsg ("build directory: %s", mp->build_directory);
1200 vam->retval = retval;
1201 vam->result_ready = 1;
1204 static void vl_api_show_version_reply_t_handler_json
1205 (vl_api_show_version_reply_t * mp)
1207 vat_main_t *vam = &vat_main;
1208 vat_json_node_t node;
1210 vat_json_init_object (&node);
1211 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1212 vat_json_object_add_string_copy (&node, "program", mp->program);
1213 vat_json_object_add_string_copy (&node, "version", mp->version);
1214 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1215 vat_json_object_add_string_copy (&node, "build_directory",
1216 mp->build_directory);
1218 vat_json_print (vam->ofp, &node);
1219 vat_json_free (&node);
1221 vam->retval = ntohl (mp->retval);
1222 vam->result_ready = 1;
1226 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1228 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1229 mp->mac_ip ? "mac/ip binding" : "address resolution",
1230 format_ip4_address, &mp->address,
1231 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1235 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1237 /* JSON output not supported */
1241 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1243 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1244 mp->mac_ip ? "mac/ip binding" : "address resolution",
1245 format_ip6_address, mp->address,
1246 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1250 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1252 /* JSON output not supported */
1256 * Special-case: build the bridge domain table, maintain
1257 * the next bd id vbl.
1259 static void vl_api_bridge_domain_details_t_handler
1260 (vl_api_bridge_domain_details_t * mp)
1262 vat_main_t *vam = &vat_main;
1263 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1265 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1266 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1268 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1269 ntohl (mp->bd_id), mp->learn, mp->forward,
1270 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1273 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1276 static void vl_api_bridge_domain_details_t_handler_json
1277 (vl_api_bridge_domain_details_t * mp)
1279 vat_main_t *vam = &vat_main;
1280 vat_json_node_t *node, *array = NULL;
1282 if (VAT_JSON_ARRAY != vam->json_tree.type)
1284 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1285 vat_json_init_array (&vam->json_tree);
1287 node = vat_json_array_add (&vam->json_tree);
1289 vat_json_init_object (node);
1290 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1291 vat_json_object_add_uint (node, "flood", mp->flood);
1292 vat_json_object_add_uint (node, "forward", mp->forward);
1293 vat_json_object_add_uint (node, "learn", mp->learn);
1294 vat_json_object_add_uint (node, "bvi_sw_if_index",
1295 ntohl (mp->bvi_sw_if_index));
1296 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1297 array = vat_json_object_add (node, "sw_if");
1298 vat_json_init_array (array);
1302 * Special-case: build the bridge domain sw if table.
1304 static void vl_api_bridge_domain_sw_if_details_t_handler
1305 (vl_api_bridge_domain_sw_if_details_t * mp)
1307 vat_main_t *vam = &vat_main;
1312 sw_if_index = ntohl (mp->sw_if_index);
1314 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1316 if ((u32) p->value[0] == sw_if_index)
1318 sw_if_name = (u8 *)(p->key);
1324 print (vam->ofp, "%7d %3d %s", sw_if_index,
1325 mp->shg, sw_if_name ? (char *) sw_if_name :
1326 "sw_if_index not found!");
1329 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1330 (vl_api_bridge_domain_sw_if_details_t * mp)
1332 vat_main_t *vam = &vat_main;
1333 vat_json_node_t *node = NULL;
1334 uword last_index = 0;
1336 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1337 ASSERT (vec_len (vam->json_tree.array) >= 1);
1338 last_index = vec_len (vam->json_tree.array) - 1;
1339 node = &vam->json_tree.array[last_index];
1340 node = vat_json_object_get_element (node, "sw_if");
1341 ASSERT (NULL != node);
1342 node = vat_json_array_add (node);
1344 vat_json_init_object (node);
1345 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1346 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1347 vat_json_object_add_uint (node, "shg", mp->shg);
1350 static void vl_api_control_ping_reply_t_handler
1351 (vl_api_control_ping_reply_t * mp)
1353 vat_main_t *vam = &vat_main;
1354 i32 retval = ntohl (mp->retval);
1355 if (vam->async_mode)
1357 vam->async_errors += (retval < 0);
1361 vam->retval = retval;
1362 vam->result_ready = 1;
1366 static void vl_api_control_ping_reply_t_handler_json
1367 (vl_api_control_ping_reply_t * mp)
1369 vat_main_t *vam = &vat_main;
1370 i32 retval = ntohl (mp->retval);
1372 if (VAT_JSON_NONE != vam->json_tree.type)
1374 vat_json_print (vam->ofp, &vam->json_tree);
1375 vat_json_free (&vam->json_tree);
1376 vam->json_tree.type = VAT_JSON_NONE;
1381 vat_json_init_array (&vam->json_tree);
1382 vat_json_print (vam->ofp, &vam->json_tree);
1383 vam->json_tree.type = VAT_JSON_NONE;
1386 vam->retval = retval;
1387 vam->result_ready = 1;
1391 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1393 vat_main_t *vam = &vat_main;
1394 i32 retval = ntohl (mp->retval);
1395 if (vam->async_mode)
1397 vam->async_errors += (retval < 0);
1401 vam->retval = retval;
1402 vam->result_ready = 1;
1406 static void vl_api_l2_flags_reply_t_handler_json
1407 (vl_api_l2_flags_reply_t * mp)
1409 vat_main_t *vam = &vat_main;
1410 vat_json_node_t node;
1412 vat_json_init_object (&node);
1413 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1414 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1415 ntohl (mp->resulting_feature_bitmap));
1417 vat_json_print (vam->ofp, &node);
1418 vat_json_free (&node);
1420 vam->retval = ntohl (mp->retval);
1421 vam->result_ready = 1;
1424 static void vl_api_bridge_flags_reply_t_handler
1425 (vl_api_bridge_flags_reply_t * mp)
1427 vat_main_t *vam = &vat_main;
1428 i32 retval = ntohl (mp->retval);
1429 if (vam->async_mode)
1431 vam->async_errors += (retval < 0);
1435 vam->retval = retval;
1436 vam->result_ready = 1;
1440 static void vl_api_bridge_flags_reply_t_handler_json
1441 (vl_api_bridge_flags_reply_t * mp)
1443 vat_main_t *vam = &vat_main;
1444 vat_json_node_t node;
1446 vat_json_init_object (&node);
1447 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1448 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1449 ntohl (mp->resulting_feature_bitmap));
1451 vat_json_print (vam->ofp, &node);
1452 vat_json_free (&node);
1454 vam->retval = ntohl (mp->retval);
1455 vam->result_ready = 1;
1458 static void vl_api_tap_connect_reply_t_handler
1459 (vl_api_tap_connect_reply_t * mp)
1461 vat_main_t *vam = &vat_main;
1462 i32 retval = ntohl (mp->retval);
1463 if (vam->async_mode)
1465 vam->async_errors += (retval < 0);
1469 vam->retval = retval;
1470 vam->sw_if_index = ntohl (mp->sw_if_index);
1471 vam->result_ready = 1;
1476 static void vl_api_tap_connect_reply_t_handler_json
1477 (vl_api_tap_connect_reply_t * mp)
1479 vat_main_t *vam = &vat_main;
1480 vat_json_node_t node;
1482 vat_json_init_object (&node);
1483 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1484 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1486 vat_json_print (vam->ofp, &node);
1487 vat_json_free (&node);
1489 vam->retval = ntohl (mp->retval);
1490 vam->result_ready = 1;
1495 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->sw_if_index = ntohl (mp->sw_if_index);
1507 vam->result_ready = 1;
1511 static void vl_api_tap_modify_reply_t_handler_json
1512 (vl_api_tap_modify_reply_t * mp)
1514 vat_main_t *vam = &vat_main;
1515 vat_json_node_t node;
1517 vat_json_init_object (&node);
1518 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1521 vat_json_print (vam->ofp, &node);
1522 vat_json_free (&node);
1524 vam->retval = ntohl (mp->retval);
1525 vam->result_ready = 1;
1529 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1531 vat_main_t *vam = &vat_main;
1532 i32 retval = ntohl (mp->retval);
1533 if (vam->async_mode)
1535 vam->async_errors += (retval < 0);
1539 vam->retval = retval;
1540 vam->result_ready = 1;
1544 static void vl_api_tap_delete_reply_t_handler_json
1545 (vl_api_tap_delete_reply_t * mp)
1547 vat_main_t *vam = &vat_main;
1548 vat_json_node_t node;
1550 vat_json_init_object (&node);
1551 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1561 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1577 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1585 ntohl (mp->sw_if_index));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1595 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1611 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1612 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1614 vat_main_t *vam = &vat_main;
1615 vat_json_node_t node;
1617 vat_json_init_object (&node);
1618 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1619 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1621 vat_json_print (vam->ofp, &node);
1622 vat_json_free (&node);
1624 vam->retval = ntohl (mp->retval);
1625 vam->result_ready = 1;
1629 static void vl_api_one_add_del_locator_set_reply_t_handler
1630 (vl_api_one_add_del_locator_set_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 i32 retval = ntohl (mp->retval);
1634 if (vam->async_mode)
1636 vam->async_errors += (retval < 0);
1640 vam->retval = retval;
1641 vam->result_ready = 1;
1645 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1646 (vl_api_one_add_del_locator_set_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 vat_json_node_t node;
1651 vat_json_init_object (&node);
1652 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1653 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1655 vat_json_print (vam->ofp, &node);
1656 vat_json_free (&node);
1658 vam->retval = ntohl (mp->retval);
1659 vam->result_ready = 1;
1662 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1663 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1665 vat_main_t *vam = &vat_main;
1666 i32 retval = ntohl (mp->retval);
1667 if (vam->async_mode)
1669 vam->async_errors += (retval < 0);
1673 vam->retval = retval;
1674 vam->sw_if_index = ntohl (mp->sw_if_index);
1675 vam->result_ready = 1;
1679 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1680 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1682 vat_main_t *vam = &vat_main;
1683 vat_json_node_t node;
1685 vat_json_init_object (&node);
1686 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1687 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_gre_add_del_tunnel_reply_t_handler
1697 (vl_api_gre_add_del_tunnel_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->sw_if_index = ntohl (mp->sw_if_index);
1709 vam->result_ready = 1;
1713 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1714 (vl_api_gre_add_del_tunnel_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 vat_json_node_t node;
1719 vat_json_init_object (&node);
1720 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1721 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_create_vhost_user_if_reply_t_handler
1731 (vl_api_create_vhost_user_if_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_create_vhost_user_if_reply_t_handler_json
1748 (vl_api_create_vhost_user_if_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_ip_address_details_t_handler
1765 (vl_api_ip_address_details_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 static ip_address_details_t empty_ip_address_details = { {0} };
1769 ip_address_details_t *address = NULL;
1770 ip_details_t *current_ip_details = NULL;
1771 ip_details_t *details = NULL;
1773 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1775 if (!details || vam->current_sw_if_index >= vec_len (details)
1776 || !details[vam->current_sw_if_index].present)
1778 errmsg ("ip address details arrived but not stored");
1779 errmsg ("ip_dump should be called first");
1783 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1785 #define addresses (current_ip_details->addr)
1787 vec_validate_init_empty (addresses, vec_len (addresses),
1788 empty_ip_address_details);
1790 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1792 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1793 address->prefix_length = mp->prefix_length;
1797 static void vl_api_ip_address_details_t_handler_json
1798 (vl_api_ip_address_details_t * mp)
1800 vat_main_t *vam = &vat_main;
1801 vat_json_node_t *node = NULL;
1802 struct in6_addr ip6;
1805 if (VAT_JSON_ARRAY != vam->json_tree.type)
1807 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1808 vat_json_init_array (&vam->json_tree);
1810 node = vat_json_array_add (&vam->json_tree);
1812 vat_json_init_object (node);
1815 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1816 vat_json_object_add_ip6 (node, "ip", ip6);
1820 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1821 vat_json_object_add_ip4 (node, "ip", ip4);
1823 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1827 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1829 vat_main_t *vam = &vat_main;
1830 static ip_details_t empty_ip_details = { 0 };
1831 ip_details_t *ip = NULL;
1832 u32 sw_if_index = ~0;
1834 sw_if_index = ntohl (mp->sw_if_index);
1836 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1837 sw_if_index, empty_ip_details);
1839 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1846 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1848 vat_main_t *vam = &vat_main;
1850 if (VAT_JSON_ARRAY != vam->json_tree.type)
1852 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1853 vat_json_init_array (&vam->json_tree);
1855 vat_json_array_add_uint (&vam->json_tree,
1856 clib_net_to_host_u32 (mp->sw_if_index));
1859 static void vl_api_map_domain_details_t_handler_json
1860 (vl_api_map_domain_details_t * mp)
1862 vat_json_node_t *node = NULL;
1863 vat_main_t *vam = &vat_main;
1864 struct in6_addr ip6;
1867 if (VAT_JSON_ARRAY != vam->json_tree.type)
1869 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1870 vat_json_init_array (&vam->json_tree);
1873 node = vat_json_array_add (&vam->json_tree);
1874 vat_json_init_object (node);
1876 vat_json_object_add_uint (node, "domain_index",
1877 clib_net_to_host_u32 (mp->domain_index));
1878 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1879 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1880 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1881 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1882 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1883 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1884 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1885 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1886 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1887 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1888 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1889 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1890 vat_json_object_add_uint (node, "flags", mp->flags);
1891 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1892 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1895 static void vl_api_map_domain_details_t_handler
1896 (vl_api_map_domain_details_t * mp)
1898 vat_main_t *vam = &vat_main;
1900 if (mp->is_translation)
1903 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1904 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1905 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1906 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1907 clib_net_to_host_u32 (mp->domain_index));
1912 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1913 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1914 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1915 format_ip6_address, mp->ip6_src,
1916 clib_net_to_host_u32 (mp->domain_index));
1918 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1919 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1920 mp->is_translation ? "map-t" : "");
1923 static void vl_api_map_rule_details_t_handler_json
1924 (vl_api_map_rule_details_t * mp)
1926 struct in6_addr ip6;
1927 vat_json_node_t *node = NULL;
1928 vat_main_t *vam = &vat_main;
1930 if (VAT_JSON_ARRAY != vam->json_tree.type)
1932 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1933 vat_json_init_array (&vam->json_tree);
1936 node = vat_json_array_add (&vam->json_tree);
1937 vat_json_init_object (node);
1939 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1940 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1941 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1945 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1947 vat_main_t *vam = &vat_main;
1948 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1949 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1953 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1955 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1956 "router_addr %U host_mac %U",
1957 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1958 format_ip4_address, &mp->host_address,
1959 format_ip4_address, &mp->router_address,
1960 format_ethernet_address, mp->host_mac);
1963 static void vl_api_dhcp_compl_event_t_handler_json
1964 (vl_api_dhcp_compl_event_t * mp)
1966 /* JSON output not supported */
1970 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1973 vat_main_t *vam = &vat_main;
1974 static u64 default_counter = 0;
1976 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1978 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1979 sw_if_index, default_counter);
1980 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1984 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1985 interface_counter_t counter)
1987 vat_main_t *vam = &vat_main;
1988 static interface_counter_t default_counter = { 0, };
1990 vec_validate_init_empty (vam->combined_interface_counters,
1991 vnet_counter_type, NULL);
1992 vec_validate_init_empty (vam->combined_interface_counters
1993 [vnet_counter_type], sw_if_index, default_counter);
1994 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1997 static void vl_api_vnet_interface_counters_t_handler
1998 (vl_api_vnet_interface_counters_t * mp)
2003 static void vl_api_vnet_interface_counters_t_handler_json
2004 (vl_api_vnet_interface_counters_t * mp)
2006 interface_counter_t counter;
2011 u32 first_sw_if_index;
2014 count = ntohl (mp->count);
2015 first_sw_if_index = ntohl (mp->first_sw_if_index);
2017 if (!mp->is_combined)
2019 v_packets = (u64 *) & mp->data;
2020 for (i = 0; i < count; i++)
2023 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2024 set_simple_interface_counter (mp->vnet_counter_type,
2025 first_sw_if_index + i, packets);
2031 v = (vlib_counter_t *) & mp->data;
2032 for (i = 0; i < count; i++)
2035 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2037 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2038 set_combined_interface_counter (mp->vnet_counter_type,
2039 first_sw_if_index + i, counter);
2046 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2048 vat_main_t *vam = &vat_main;
2051 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2053 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2062 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2064 vat_main_t *vam = &vat_main;
2067 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2069 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2077 static void vl_api_vnet_ip4_fib_counters_t_handler
2078 (vl_api_vnet_ip4_fib_counters_t * mp)
2083 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2084 (vl_api_vnet_ip4_fib_counters_t * mp)
2086 vat_main_t *vam = &vat_main;
2087 vl_api_ip4_fib_counter_t *v;
2088 ip4_fib_counter_t *counter;
2095 vrf_id = ntohl (mp->vrf_id);
2096 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2097 if (~0 == vrf_index)
2099 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2100 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2101 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2102 vec_validate (vam->ip4_fib_counters, vrf_index);
2103 vam->ip4_fib_counters[vrf_index] = NULL;
2106 vec_free (vam->ip4_fib_counters[vrf_index]);
2107 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2108 count = ntohl (mp->count);
2109 for (i = 0; i < count; i++)
2111 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2112 counter = &vam->ip4_fib_counters[vrf_index][i];
2113 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2114 counter->address = ip4;
2115 counter->address_length = v->address_length;
2116 counter->packets = clib_net_to_host_u64 (v->packets);
2117 counter->bytes = clib_net_to_host_u64 (v->bytes);
2122 static void vl_api_vnet_ip4_nbr_counters_t_handler
2123 (vl_api_vnet_ip4_nbr_counters_t * mp)
2128 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2129 (vl_api_vnet_ip4_nbr_counters_t * mp)
2131 vat_main_t *vam = &vat_main;
2132 vl_api_ip4_nbr_counter_t *v;
2133 ip4_nbr_counter_t *counter;
2138 sw_if_index = ntohl (mp->sw_if_index);
2139 count = ntohl (mp->count);
2140 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2143 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2145 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2146 for (i = 0; i < count; i++)
2148 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2149 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2150 counter->address.s_addr = v->address;
2151 counter->packets = clib_net_to_host_u64 (v->packets);
2152 counter->bytes = clib_net_to_host_u64 (v->bytes);
2153 counter->linkt = v->link_type;
2158 static void vl_api_vnet_ip6_fib_counters_t_handler
2159 (vl_api_vnet_ip6_fib_counters_t * mp)
2164 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2165 (vl_api_vnet_ip6_fib_counters_t * mp)
2167 vat_main_t *vam = &vat_main;
2168 vl_api_ip6_fib_counter_t *v;
2169 ip6_fib_counter_t *counter;
2170 struct in6_addr ip6;
2176 vrf_id = ntohl (mp->vrf_id);
2177 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2178 if (~0 == vrf_index)
2180 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2181 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2182 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2183 vec_validate (vam->ip6_fib_counters, vrf_index);
2184 vam->ip6_fib_counters[vrf_index] = NULL;
2187 vec_free (vam->ip6_fib_counters[vrf_index]);
2188 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2189 count = ntohl (mp->count);
2190 for (i = 0; i < count; i++)
2192 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2193 counter = &vam->ip6_fib_counters[vrf_index][i];
2194 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2195 counter->address = ip6;
2196 counter->address_length = v->address_length;
2197 counter->packets = clib_net_to_host_u64 (v->packets);
2198 counter->bytes = clib_net_to_host_u64 (v->bytes);
2203 static void vl_api_vnet_ip6_nbr_counters_t_handler
2204 (vl_api_vnet_ip6_nbr_counters_t * mp)
2209 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2210 (vl_api_vnet_ip6_nbr_counters_t * mp)
2212 vat_main_t *vam = &vat_main;
2213 vl_api_ip6_nbr_counter_t *v;
2214 ip6_nbr_counter_t *counter;
2215 struct in6_addr ip6;
2220 sw_if_index = ntohl (mp->sw_if_index);
2221 count = ntohl (mp->count);
2222 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2225 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2227 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2228 for (i = 0; i < count; i++)
2230 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2231 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2232 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2233 counter->address = ip6;
2234 counter->packets = clib_net_to_host_u64 (v->packets);
2235 counter->bytes = clib_net_to_host_u64 (v->bytes);
2240 static void vl_api_get_first_msg_id_reply_t_handler
2241 (vl_api_get_first_msg_id_reply_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 i32 retval = ntohl (mp->retval);
2246 if (vam->async_mode)
2248 vam->async_errors += (retval < 0);
2252 vam->retval = retval;
2253 vam->result_ready = 1;
2257 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2261 static void vl_api_get_first_msg_id_reply_t_handler_json
2262 (vl_api_get_first_msg_id_reply_t * mp)
2264 vat_main_t *vam = &vat_main;
2265 vat_json_node_t node;
2267 vat_json_init_object (&node);
2268 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2269 vat_json_object_add_uint (&node, "first_msg_id",
2270 (uint) ntohs (mp->first_msg_id));
2272 vat_json_print (vam->ofp, &node);
2273 vat_json_free (&node);
2275 vam->retval = ntohl (mp->retval);
2276 vam->result_ready = 1;
2279 static void vl_api_get_node_graph_reply_t_handler
2280 (vl_api_get_node_graph_reply_t * mp)
2282 vat_main_t *vam = &vat_main;
2283 api_main_t *am = &api_main;
2284 i32 retval = ntohl (mp->retval);
2285 u8 *pvt_copy, *reply;
2290 if (vam->async_mode)
2292 vam->async_errors += (retval < 0);
2296 vam->retval = retval;
2297 vam->result_ready = 1;
2300 /* "Should never happen..." */
2304 reply = (u8 *) (mp->reply_in_shmem);
2305 pvt_copy = vec_dup (reply);
2307 /* Toss the shared-memory original... */
2308 pthread_mutex_lock (&am->vlib_rp->mutex);
2309 oldheap = svm_push_data_heap (am->vlib_rp);
2313 svm_pop_heap (oldheap);
2314 pthread_mutex_unlock (&am->vlib_rp->mutex);
2316 if (vam->graph_nodes)
2318 hash_free (vam->graph_node_index_by_name);
2320 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2322 node = vam->graph_nodes[i];
2323 vec_free (node->name);
2324 vec_free (node->next_nodes);
2327 vec_free (vam->graph_nodes);
2330 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2331 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2332 vec_free (pvt_copy);
2334 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2336 node = vam->graph_nodes[i];
2337 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2341 static void vl_api_get_node_graph_reply_t_handler_json
2342 (vl_api_get_node_graph_reply_t * mp)
2344 vat_main_t *vam = &vat_main;
2345 api_main_t *am = &api_main;
2347 vat_json_node_t node;
2350 /* $$$$ make this real? */
2351 vat_json_init_object (&node);
2352 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2353 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2355 reply = (u8 *) (mp->reply_in_shmem);
2357 /* Toss the shared-memory original... */
2358 pthread_mutex_lock (&am->vlib_rp->mutex);
2359 oldheap = svm_push_data_heap (am->vlib_rp);
2363 svm_pop_heap (oldheap);
2364 pthread_mutex_unlock (&am->vlib_rp->mutex);
2366 vat_json_print (vam->ofp, &node);
2367 vat_json_free (&node);
2369 vam->retval = ntohl (mp->retval);
2370 vam->result_ready = 1;
2374 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2376 vat_main_t *vam = &vat_main;
2381 s = format (s, "%=16d%=16d%=16d",
2382 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2386 s = format (s, "%=16U%=16d%=16d",
2387 mp->is_ipv6 ? format_ip6_address :
2389 mp->ip_address, mp->priority, mp->weight);
2392 print (vam->ofp, "%v", s);
2397 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2399 vat_main_t *vam = &vat_main;
2400 vat_json_node_t *node = NULL;
2401 struct in6_addr ip6;
2404 if (VAT_JSON_ARRAY != vam->json_tree.type)
2406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2407 vat_json_init_array (&vam->json_tree);
2409 node = vat_json_array_add (&vam->json_tree);
2410 vat_json_init_object (node);
2412 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2413 vat_json_object_add_uint (node, "priority", mp->priority);
2414 vat_json_object_add_uint (node, "weight", mp->weight);
2417 vat_json_object_add_uint (node, "sw_if_index",
2418 clib_net_to_host_u32 (mp->sw_if_index));
2423 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2424 vat_json_object_add_ip6 (node, "address", ip6);
2428 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2429 vat_json_object_add_ip4 (node, "address", ip4);
2435 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2438 vat_main_t *vam = &vat_main;
2441 ls_name = format (0, "%s", mp->ls_name);
2443 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2449 vl_api_one_locator_set_details_t_handler_json
2450 (vl_api_one_locator_set_details_t * mp)
2452 vat_main_t *vam = &vat_main;
2453 vat_json_node_t *node = 0;
2456 ls_name = format (0, "%s", mp->ls_name);
2457 vec_add1 (ls_name, 0);
2459 if (VAT_JSON_ARRAY != vam->json_tree.type)
2461 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2462 vat_json_init_array (&vam->json_tree);
2464 node = vat_json_array_add (&vam->json_tree);
2466 vat_json_init_object (node);
2467 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2468 vat_json_object_add_uint (node, "ls_index",
2469 clib_net_to_host_u32 (mp->ls_index));
2474 format_lisp_flat_eid (u8 * s, va_list * args)
2476 u32 type = va_arg (*args, u32);
2477 u8 *eid = va_arg (*args, u8 *);
2478 u32 eid_len = va_arg (*args, u32);
2483 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2485 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2487 return format (s, "%U", format_ethernet_address, eid);
2493 format_lisp_eid_vat (u8 * s, va_list * args)
2495 u32 type = va_arg (*args, u32);
2496 u8 *eid = va_arg (*args, u8 *);
2497 u32 eid_len = va_arg (*args, u32);
2498 u8 *seid = va_arg (*args, u8 *);
2499 u32 seid_len = va_arg (*args, u32);
2500 u32 is_src_dst = va_arg (*args, u32);
2503 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2505 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2511 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2513 vat_main_t *vam = &vat_main;
2514 u8 *s = 0, *eid = 0;
2516 if (~0 == mp->locator_set_index)
2517 s = format (0, "action: %d", mp->action);
2519 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2521 eid = format (0, "%U", format_lisp_eid_vat,
2525 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2528 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2529 clib_net_to_host_u32 (mp->vni),
2531 mp->is_local ? "local" : "remote",
2532 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2533 clib_net_to_host_u16 (mp->key_id), mp->key);
2540 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2543 vat_main_t *vam = &vat_main;
2544 vat_json_node_t *node = 0;
2547 if (VAT_JSON_ARRAY != vam->json_tree.type)
2549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2550 vat_json_init_array (&vam->json_tree);
2552 node = vat_json_array_add (&vam->json_tree);
2554 vat_json_init_object (node);
2555 if (~0 == mp->locator_set_index)
2556 vat_json_object_add_uint (node, "action", mp->action);
2558 vat_json_object_add_uint (node, "locator_set_index",
2559 clib_net_to_host_u32 (mp->locator_set_index));
2561 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2562 eid = format (0, "%U", format_lisp_eid_vat,
2566 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2568 vat_json_object_add_string_copy (node, "eid", eid);
2569 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2570 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2571 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2575 vat_json_object_add_uint (node, "key_id",
2576 clib_net_to_host_u16 (mp->key_id));
2577 vat_json_object_add_string_copy (node, "key", mp->key);
2583 vl_api_one_eid_table_map_details_t_handler
2584 (vl_api_one_eid_table_map_details_t * mp)
2586 vat_main_t *vam = &vat_main;
2588 u8 *line = format (0, "%=10d%=10d",
2589 clib_net_to_host_u32 (mp->vni),
2590 clib_net_to_host_u32 (mp->dp_table));
2591 print (vam->ofp, "%v", line);
2596 vl_api_one_eid_table_map_details_t_handler_json
2597 (vl_api_one_eid_table_map_details_t * mp)
2599 vat_main_t *vam = &vat_main;
2600 vat_json_node_t *node = NULL;
2602 if (VAT_JSON_ARRAY != vam->json_tree.type)
2604 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2605 vat_json_init_array (&vam->json_tree);
2607 node = vat_json_array_add (&vam->json_tree);
2608 vat_json_init_object (node);
2609 vat_json_object_add_uint (node, "dp_table",
2610 clib_net_to_host_u32 (mp->dp_table));
2611 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2615 vl_api_one_eid_table_vni_details_t_handler
2616 (vl_api_one_eid_table_vni_details_t * mp)
2618 vat_main_t *vam = &vat_main;
2620 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2621 print (vam->ofp, "%v", line);
2626 vl_api_one_eid_table_vni_details_t_handler_json
2627 (vl_api_one_eid_table_vni_details_t * mp)
2629 vat_main_t *vam = &vat_main;
2630 vat_json_node_t *node = NULL;
2632 if (VAT_JSON_ARRAY != vam->json_tree.type)
2634 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2635 vat_json_init_array (&vam->json_tree);
2637 node = vat_json_array_add (&vam->json_tree);
2638 vat_json_init_object (node);
2639 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2643 vl_api_show_one_map_register_state_reply_t_handler
2644 (vl_api_show_one_map_register_state_reply_t * mp)
2646 vat_main_t *vam = &vat_main;
2647 int retval = clib_net_to_host_u32 (mp->retval);
2649 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2651 vam->retval = retval;
2652 vam->result_ready = 1;
2656 vl_api_show_one_map_register_state_reply_t_handler_json
2657 (vl_api_show_one_map_register_state_reply_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vat_json_node_t _node, *node = &_node;
2661 int retval = clib_net_to_host_u32 (mp->retval);
2663 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2665 vat_json_init_object (node);
2666 vat_json_object_add_string_copy (node, "state", s);
2668 vat_json_print (vam->ofp, node);
2669 vat_json_free (node);
2671 vam->retval = retval;
2672 vam->result_ready = 1;
2677 vl_api_show_one_rloc_probe_state_reply_t_handler
2678 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2680 vat_main_t *vam = &vat_main;
2681 int retval = clib_net_to_host_u32 (mp->retval);
2686 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2688 vam->retval = retval;
2689 vam->result_ready = 1;
2693 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2694 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2696 vat_main_t *vam = &vat_main;
2697 vat_json_node_t _node, *node = &_node;
2698 int retval = clib_net_to_host_u32 (mp->retval);
2700 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2701 vat_json_init_object (node);
2702 vat_json_object_add_string_copy (node, "state", s);
2704 vat_json_print (vam->ofp, node);
2705 vat_json_free (node);
2707 vam->retval = retval;
2708 vam->result_ready = 1;
2713 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2715 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2716 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2720 gpe_fwd_entries_get_reply_t_net_to_host
2721 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2725 mp->count = clib_net_to_host_u32 (mp->count);
2726 for (i = 0; i < mp->count; i++)
2728 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2733 vl_api_gpe_fwd_entry_path_details_t_handler
2734 (vl_api_gpe_fwd_entry_path_details_t * mp)
2736 vat_main_t *vam = &vat_main;
2737 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2739 if (mp->lcl_loc.is_ip4)
2740 format_ip_address_fcn = format_ip4_address;
2742 format_ip_address_fcn = format_ip6_address;
2744 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2745 format_ip_address_fcn, &mp->lcl_loc,
2746 format_ip_address_fcn, &mp->rmt_loc);
2750 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2752 struct in6_addr ip6;
2757 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2758 vat_json_object_add_ip4 (n, "address", ip4);
2762 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2763 vat_json_object_add_ip6 (n, "address", ip6);
2765 vat_json_object_add_uint (n, "weight", loc->weight);
2769 vl_api_gpe_fwd_entry_path_details_t_handler_json
2770 (vl_api_gpe_fwd_entry_path_details_t * mp)
2772 vat_main_t *vam = &vat_main;
2773 vat_json_node_t *node = NULL;
2774 vat_json_node_t *loc_node;
2776 if (VAT_JSON_ARRAY != vam->json_tree.type)
2778 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2779 vat_json_init_array (&vam->json_tree);
2781 node = vat_json_array_add (&vam->json_tree);
2782 vat_json_init_object (node);
2784 loc_node = vat_json_object_add (node, "local_locator");
2785 vat_json_init_object (loc_node);
2786 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2788 loc_node = vat_json_object_add (node, "remote_locator");
2789 vat_json_init_object (loc_node);
2790 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2794 vl_api_gpe_fwd_entries_get_reply_t_handler
2795 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2797 vat_main_t *vam = &vat_main;
2799 int retval = clib_net_to_host_u32 (mp->retval);
2800 vl_api_gpe_fwd_entry_t *e;
2805 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2807 for (i = 0; i < mp->count; i++)
2809 e = &mp->entries[i];
2810 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2811 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2812 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2816 vam->retval = retval;
2817 vam->result_ready = 1;
2821 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2822 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2825 vat_main_t *vam = &vat_main;
2826 vat_json_node_t *e = 0, root;
2828 int retval = clib_net_to_host_u32 (mp->retval);
2829 vl_api_gpe_fwd_entry_t *fwd;
2834 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2835 vat_json_init_array (&root);
2837 for (i = 0; i < mp->count; i++)
2839 e = vat_json_array_add (&root);
2840 fwd = &mp->entries[i];
2842 vat_json_init_object (e);
2843 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2844 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2846 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2847 fwd->leid_prefix_len);
2849 vat_json_object_add_string_copy (e, "leid", s);
2852 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2853 fwd->reid_prefix_len);
2855 vat_json_object_add_string_copy (e, "reid", s);
2859 vat_json_print (vam->ofp, &root);
2860 vat_json_free (&root);
2863 vam->retval = retval;
2864 vam->result_ready = 1;
2868 vl_api_one_adjacencies_get_reply_t_handler
2869 (vl_api_one_adjacencies_get_reply_t * mp)
2871 vat_main_t *vam = &vat_main;
2873 int retval = clib_net_to_host_u32 (mp->retval);
2874 vl_api_one_adjacency_t *a;
2879 n = clib_net_to_host_u32 (mp->count);
2881 for (i = 0; i < n; i++)
2883 a = &mp->adjacencies[i];
2884 print (vam->ofp, "%U %40U",
2885 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2886 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2890 vam->retval = retval;
2891 vam->result_ready = 1;
2895 vl_api_one_adjacencies_get_reply_t_handler_json
2896 (vl_api_one_adjacencies_get_reply_t * mp)
2899 vat_main_t *vam = &vat_main;
2900 vat_json_node_t *e = 0, root;
2902 int retval = clib_net_to_host_u32 (mp->retval);
2903 vl_api_one_adjacency_t *a;
2908 n = clib_net_to_host_u32 (mp->count);
2909 vat_json_init_array (&root);
2911 for (i = 0; i < n; i++)
2913 e = vat_json_array_add (&root);
2914 a = &mp->adjacencies[i];
2916 vat_json_init_object (e);
2917 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2918 a->leid_prefix_len);
2920 vat_json_object_add_string_copy (e, "leid", s);
2923 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2924 a->reid_prefix_len);
2926 vat_json_object_add_string_copy (e, "reid", s);
2930 vat_json_print (vam->ofp, &root);
2931 vat_json_free (&root);
2934 vam->retval = retval;
2935 vam->result_ready = 1;
2939 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
2941 vat_main_t *vam = &vat_main;
2943 print (vam->ofp, "%=20U",
2944 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2949 vl_api_one_map_server_details_t_handler_json
2950 (vl_api_one_map_server_details_t * mp)
2952 vat_main_t *vam = &vat_main;
2953 vat_json_node_t *node = NULL;
2954 struct in6_addr ip6;
2957 if (VAT_JSON_ARRAY != vam->json_tree.type)
2959 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2960 vat_json_init_array (&vam->json_tree);
2962 node = vat_json_array_add (&vam->json_tree);
2964 vat_json_init_object (node);
2967 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2968 vat_json_object_add_ip6 (node, "map-server", ip6);
2972 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2973 vat_json_object_add_ip4 (node, "map-server", ip4);
2978 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
2981 vat_main_t *vam = &vat_main;
2983 print (vam->ofp, "%=20U",
2984 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2989 vl_api_one_map_resolver_details_t_handler_json
2990 (vl_api_one_map_resolver_details_t * mp)
2992 vat_main_t *vam = &vat_main;
2993 vat_json_node_t *node = NULL;
2994 struct in6_addr ip6;
2997 if (VAT_JSON_ARRAY != vam->json_tree.type)
2999 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3000 vat_json_init_array (&vam->json_tree);
3002 node = vat_json_array_add (&vam->json_tree);
3004 vat_json_init_object (node);
3007 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3008 vat_json_object_add_ip6 (node, "map resolver", ip6);
3012 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3013 vat_json_object_add_ip4 (node, "map resolver", ip4);
3018 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3020 vat_main_t *vam = &vat_main;
3021 i32 retval = ntohl (mp->retval);
3025 print (vam->ofp, "feature: %s\ngpe: %s",
3026 mp->feature_status ? "enabled" : "disabled",
3027 mp->gpe_status ? "enabled" : "disabled");
3030 vam->retval = retval;
3031 vam->result_ready = 1;
3035 vl_api_show_one_status_reply_t_handler_json
3036 (vl_api_show_one_status_reply_t * mp)
3038 vat_main_t *vam = &vat_main;
3039 vat_json_node_t node;
3040 u8 *gpe_status = NULL;
3041 u8 *feature_status = NULL;
3043 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3044 feature_status = format (0, "%s",
3045 mp->feature_status ? "enabled" : "disabled");
3046 vec_add1 (gpe_status, 0);
3047 vec_add1 (feature_status, 0);
3049 vat_json_init_object (&node);
3050 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3051 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3053 vec_free (gpe_status);
3054 vec_free (feature_status);
3056 vat_json_print (vam->ofp, &node);
3057 vat_json_free (&node);
3059 vam->retval = ntohl (mp->retval);
3060 vam->result_ready = 1;
3064 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3065 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3067 vat_main_t *vam = &vat_main;
3068 i32 retval = ntohl (mp->retval);
3072 print (vam->ofp, "%=20s", mp->locator_set_name);
3075 vam->retval = retval;
3076 vam->result_ready = 1;
3080 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3081 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3083 vat_main_t *vam = &vat_main;
3084 vat_json_node_t *node = NULL;
3086 if (VAT_JSON_ARRAY != vam->json_tree.type)
3088 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3089 vat_json_init_array (&vam->json_tree);
3091 node = vat_json_array_add (&vam->json_tree);
3093 vat_json_init_object (node);
3094 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3096 vat_json_print (vam->ofp, node);
3097 vat_json_free (node);
3099 vam->retval = ntohl (mp->retval);
3100 vam->result_ready = 1;
3104 format_lisp_map_request_mode (u8 * s, va_list * args)
3106 u32 mode = va_arg (*args, u32);
3111 return format (0, "dst-only");
3113 return format (0, "src-dst");
3119 vl_api_show_one_map_request_mode_reply_t_handler
3120 (vl_api_show_one_map_request_mode_reply_t * mp)
3122 vat_main_t *vam = &vat_main;
3123 i32 retval = ntohl (mp->retval);
3127 u32 mode = mp->mode;
3128 print (vam->ofp, "map_request_mode: %U",
3129 format_lisp_map_request_mode, mode);
3132 vam->retval = retval;
3133 vam->result_ready = 1;
3137 vl_api_show_one_map_request_mode_reply_t_handler_json
3138 (vl_api_show_one_map_request_mode_reply_t * mp)
3140 vat_main_t *vam = &vat_main;
3141 vat_json_node_t node;
3146 s = format (0, "%U", format_lisp_map_request_mode, mode);
3149 vat_json_init_object (&node);
3150 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3151 vat_json_print (vam->ofp, &node);
3152 vat_json_free (&node);
3155 vam->retval = ntohl (mp->retval);
3156 vam->result_ready = 1;
3160 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3162 vat_main_t *vam = &vat_main;
3163 i32 retval = ntohl (mp->retval);
3167 print (vam->ofp, "%-20s%-16s",
3168 mp->status ? "enabled" : "disabled",
3169 mp->status ? (char *) mp->locator_set_name : "");
3172 vam->retval = retval;
3173 vam->result_ready = 1;
3177 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3179 vat_main_t *vam = &vat_main;
3180 vat_json_node_t node;
3183 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3184 vec_add1 (status, 0);
3186 vat_json_init_object (&node);
3187 vat_json_object_add_string_copy (&node, "status", status);
3190 vat_json_object_add_string_copy (&node, "locator_set",
3191 mp->locator_set_name);
3196 vat_json_print (vam->ofp, &node);
3197 vat_json_free (&node);
3199 vam->retval = ntohl (mp->retval);
3200 vam->result_ready = 1;
3204 format_policer_type (u8 * s, va_list * va)
3206 u32 i = va_arg (*va, u32);
3208 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3209 s = format (s, "1r2c");
3210 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3211 s = format (s, "1r3c");
3212 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3213 s = format (s, "2r3c-2698");
3214 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3215 s = format (s, "2r3c-4115");
3216 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3217 s = format (s, "2r3c-mef5cf1");
3219 s = format (s, "ILLEGAL");
3224 format_policer_rate_type (u8 * s, va_list * va)
3226 u32 i = va_arg (*va, u32);
3228 if (i == SSE2_QOS_RATE_KBPS)
3229 s = format (s, "kbps");
3230 else if (i == SSE2_QOS_RATE_PPS)
3231 s = format (s, "pps");
3233 s = format (s, "ILLEGAL");
3238 format_policer_round_type (u8 * s, va_list * va)
3240 u32 i = va_arg (*va, u32);
3242 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3243 s = format (s, "closest");
3244 else if (i == SSE2_QOS_ROUND_TO_UP)
3245 s = format (s, "up");
3246 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3247 s = format (s, "down");
3249 s = format (s, "ILLEGAL");
3254 format_policer_action_type (u8 * s, va_list * va)
3256 u32 i = va_arg (*va, u32);
3258 if (i == SSE2_QOS_ACTION_DROP)
3259 s = format (s, "drop");
3260 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3261 s = format (s, "transmit");
3262 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3263 s = format (s, "mark-and-transmit");
3265 s = format (s, "ILLEGAL");
3270 format_dscp (u8 * s, va_list * va)
3272 u32 i = va_arg (*va, u32);
3277 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3281 return format (s, "ILLEGAL");
3283 s = format (s, "%s", t);
3288 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3290 vat_main_t *vam = &vat_main;
3291 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3293 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3294 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3296 conform_dscp_str = format (0, "");
3298 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3299 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3301 exceed_dscp_str = format (0, "");
3303 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3304 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3306 violate_dscp_str = format (0, "");
3308 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3309 "rate type %U, round type %U, %s rate, %s color-aware, "
3310 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3311 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3312 "conform action %U%s, exceed action %U%s, violate action %U%s",
3314 format_policer_type, mp->type,
3317 clib_net_to_host_u64 (mp->cb),
3318 clib_net_to_host_u64 (mp->eb),
3319 format_policer_rate_type, mp->rate_type,
3320 format_policer_round_type, mp->round_type,
3321 mp->single_rate ? "single" : "dual",
3322 mp->color_aware ? "is" : "not",
3323 ntohl (mp->cir_tokens_per_period),
3324 ntohl (mp->pir_tokens_per_period),
3326 ntohl (mp->current_limit),
3327 ntohl (mp->current_bucket),
3328 ntohl (mp->extended_limit),
3329 ntohl (mp->extended_bucket),
3330 clib_net_to_host_u64 (mp->last_update_time),
3331 format_policer_action_type, mp->conform_action_type,
3333 format_policer_action_type, mp->exceed_action_type,
3335 format_policer_action_type, mp->violate_action_type,
3338 vec_free (conform_dscp_str);
3339 vec_free (exceed_dscp_str);
3340 vec_free (violate_dscp_str);
3343 static void vl_api_policer_details_t_handler_json
3344 (vl_api_policer_details_t * mp)
3346 vat_main_t *vam = &vat_main;
3347 vat_json_node_t *node;
3348 u8 *rate_type_str, *round_type_str, *type_str;
3349 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3351 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3353 format (0, "%U", format_policer_round_type, mp->round_type);
3354 type_str = format (0, "%U", format_policer_type, mp->type);
3355 conform_action_str = format (0, "%U", format_policer_action_type,
3356 mp->conform_action_type);
3357 exceed_action_str = format (0, "%U", format_policer_action_type,
3358 mp->exceed_action_type);
3359 violate_action_str = format (0, "%U", format_policer_action_type,
3360 mp->violate_action_type);
3362 if (VAT_JSON_ARRAY != vam->json_tree.type)
3364 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3365 vat_json_init_array (&vam->json_tree);
3367 node = vat_json_array_add (&vam->json_tree);
3369 vat_json_init_object (node);
3370 vat_json_object_add_string_copy (node, "name", mp->name);
3371 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3372 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3373 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3374 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3375 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3376 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3377 vat_json_object_add_string_copy (node, "type", type_str);
3378 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3379 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3380 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3381 vat_json_object_add_uint (node, "cir_tokens_per_period",
3382 ntohl (mp->cir_tokens_per_period));
3383 vat_json_object_add_uint (node, "eir_tokens_per_period",
3384 ntohl (mp->pir_tokens_per_period));
3385 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3386 vat_json_object_add_uint (node, "current_bucket",
3387 ntohl (mp->current_bucket));
3388 vat_json_object_add_uint (node, "extended_limit",
3389 ntohl (mp->extended_limit));
3390 vat_json_object_add_uint (node, "extended_bucket",
3391 ntohl (mp->extended_bucket));
3392 vat_json_object_add_uint (node, "last_update_time",
3393 ntohl (mp->last_update_time));
3394 vat_json_object_add_string_copy (node, "conform_action",
3395 conform_action_str);
3396 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3398 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3399 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3400 vec_free (dscp_str);
3402 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3403 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3405 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3406 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3407 vec_free (dscp_str);
3409 vat_json_object_add_string_copy (node, "violate_action",
3410 violate_action_str);
3411 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3413 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3414 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3415 vec_free (dscp_str);
3418 vec_free (rate_type_str);
3419 vec_free (round_type_str);
3420 vec_free (type_str);
3421 vec_free (conform_action_str);
3422 vec_free (exceed_action_str);
3423 vec_free (violate_action_str);
3427 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3430 vat_main_t *vam = &vat_main;
3431 int i, count = ntohl (mp->count);
3434 print (vam->ofp, "classify table ids (%d) : ", count);
3435 for (i = 0; i < count; i++)
3437 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3438 print (vam->ofp, (i < count - 1) ? "," : "");
3440 vam->retval = ntohl (mp->retval);
3441 vam->result_ready = 1;
3445 vl_api_classify_table_ids_reply_t_handler_json
3446 (vl_api_classify_table_ids_reply_t * mp)
3448 vat_main_t *vam = &vat_main;
3449 int i, count = ntohl (mp->count);
3453 vat_json_node_t node;
3455 vat_json_init_object (&node);
3456 for (i = 0; i < count; i++)
3458 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3460 vat_json_print (vam->ofp, &node);
3461 vat_json_free (&node);
3463 vam->retval = ntohl (mp->retval);
3464 vam->result_ready = 1;
3468 vl_api_classify_table_by_interface_reply_t_handler
3469 (vl_api_classify_table_by_interface_reply_t * mp)
3471 vat_main_t *vam = &vat_main;
3474 table_id = ntohl (mp->l2_table_id);
3476 print (vam->ofp, "l2 table id : %d", table_id);
3478 print (vam->ofp, "l2 table id : No input ACL tables configured");
3479 table_id = ntohl (mp->ip4_table_id);
3481 print (vam->ofp, "ip4 table id : %d", table_id);
3483 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3484 table_id = ntohl (mp->ip6_table_id);
3486 print (vam->ofp, "ip6 table id : %d", table_id);
3488 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3489 vam->retval = ntohl (mp->retval);
3490 vam->result_ready = 1;
3494 vl_api_classify_table_by_interface_reply_t_handler_json
3495 (vl_api_classify_table_by_interface_reply_t * mp)
3497 vat_main_t *vam = &vat_main;
3498 vat_json_node_t node;
3500 vat_json_init_object (&node);
3502 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3503 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3504 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3506 vat_json_print (vam->ofp, &node);
3507 vat_json_free (&node);
3509 vam->retval = ntohl (mp->retval);
3510 vam->result_ready = 1;
3513 static void vl_api_policer_add_del_reply_t_handler
3514 (vl_api_policer_add_del_reply_t * mp)
3516 vat_main_t *vam = &vat_main;
3517 i32 retval = ntohl (mp->retval);
3518 if (vam->async_mode)
3520 vam->async_errors += (retval < 0);
3524 vam->retval = retval;
3525 vam->result_ready = 1;
3526 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3528 * Note: this is just barely thread-safe, depends on
3529 * the main thread spinning waiting for an answer...
3531 errmsg ("policer index %d", ntohl (mp->policer_index));
3535 static void vl_api_policer_add_del_reply_t_handler_json
3536 (vl_api_policer_add_del_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 vat_json_node_t node;
3541 vat_json_init_object (&node);
3542 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3543 vat_json_object_add_uint (&node, "policer_index",
3544 ntohl (mp->policer_index));
3546 vat_json_print (vam->ofp, &node);
3547 vat_json_free (&node);
3549 vam->retval = ntohl (mp->retval);
3550 vam->result_ready = 1;
3553 /* Format hex dump. */
3555 format_hex_bytes (u8 * s, va_list * va)
3557 u8 *bytes = va_arg (*va, u8 *);
3558 int n_bytes = va_arg (*va, int);
3561 /* Print short or long form depending on byte count. */
3562 uword short_form = n_bytes <= 32;
3563 uword indent = format_get_indent (s);
3568 for (i = 0; i < n_bytes; i++)
3570 if (!short_form && (i % 32) == 0)
3571 s = format (s, "%08x: ", i);
3572 s = format (s, "%02x", bytes[i]);
3573 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3574 s = format (s, "\n%U", format_white_space, indent);
3581 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3584 vat_main_t *vam = &vat_main;
3585 i32 retval = ntohl (mp->retval);
3588 print (vam->ofp, "classify table info :");
3589 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3590 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3591 ntohl (mp->miss_next_index));
3592 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3593 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3594 ntohl (mp->match_n_vectors));
3595 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3596 ntohl (mp->mask_length));
3598 vam->retval = retval;
3599 vam->result_ready = 1;
3603 vl_api_classify_table_info_reply_t_handler_json
3604 (vl_api_classify_table_info_reply_t * mp)
3606 vat_main_t *vam = &vat_main;
3607 vat_json_node_t node;
3609 i32 retval = ntohl (mp->retval);
3612 vat_json_init_object (&node);
3614 vat_json_object_add_int (&node, "sessions",
3615 ntohl (mp->active_sessions));
3616 vat_json_object_add_int (&node, "nexttbl",
3617 ntohl (mp->next_table_index));
3618 vat_json_object_add_int (&node, "nextnode",
3619 ntohl (mp->miss_next_index));
3620 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3621 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3622 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3623 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3624 ntohl (mp->mask_length), 0);
3625 vat_json_object_add_string_copy (&node, "mask", s);
3627 vat_json_print (vam->ofp, &node);
3628 vat_json_free (&node);
3630 vam->retval = ntohl (mp->retval);
3631 vam->result_ready = 1;
3635 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3638 vat_main_t *vam = &vat_main;
3640 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3641 ntohl (mp->hit_next_index), ntohl (mp->advance),
3642 ntohl (mp->opaque_index));
3643 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3644 ntohl (mp->match_length));
3648 vl_api_classify_session_details_t_handler_json
3649 (vl_api_classify_session_details_t * mp)
3651 vat_main_t *vam = &vat_main;
3652 vat_json_node_t *node = NULL;
3654 if (VAT_JSON_ARRAY != vam->json_tree.type)
3656 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3657 vat_json_init_array (&vam->json_tree);
3659 node = vat_json_array_add (&vam->json_tree);
3661 vat_json_init_object (node);
3662 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3663 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3664 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3666 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3668 vat_json_object_add_string_copy (node, "match", s);
3671 static void vl_api_pg_create_interface_reply_t_handler
3672 (vl_api_pg_create_interface_reply_t * mp)
3674 vat_main_t *vam = &vat_main;
3676 vam->retval = ntohl (mp->retval);
3677 vam->result_ready = 1;
3680 static void vl_api_pg_create_interface_reply_t_handler_json
3681 (vl_api_pg_create_interface_reply_t * mp)
3683 vat_main_t *vam = &vat_main;
3684 vat_json_node_t node;
3686 i32 retval = ntohl (mp->retval);
3689 vat_json_init_object (&node);
3691 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3693 vat_json_print (vam->ofp, &node);
3694 vat_json_free (&node);
3696 vam->retval = ntohl (mp->retval);
3697 vam->result_ready = 1;
3700 static void vl_api_policer_classify_details_t_handler
3701 (vl_api_policer_classify_details_t * mp)
3703 vat_main_t *vam = &vat_main;
3705 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3706 ntohl (mp->table_index));
3709 static void vl_api_policer_classify_details_t_handler_json
3710 (vl_api_policer_classify_details_t * mp)
3712 vat_main_t *vam = &vat_main;
3713 vat_json_node_t *node;
3715 if (VAT_JSON_ARRAY != vam->json_tree.type)
3717 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3718 vat_json_init_array (&vam->json_tree);
3720 node = vat_json_array_add (&vam->json_tree);
3722 vat_json_init_object (node);
3723 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3724 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3727 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3728 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3730 vat_main_t *vam = &vat_main;
3731 i32 retval = ntohl (mp->retval);
3732 if (vam->async_mode)
3734 vam->async_errors += (retval < 0);
3738 vam->retval = retval;
3739 vam->sw_if_index = ntohl (mp->sw_if_index);
3740 vam->result_ready = 1;
3744 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3745 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3747 vat_main_t *vam = &vat_main;
3748 vat_json_node_t node;
3750 vat_json_init_object (&node);
3751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3754 vat_json_print (vam->ofp, &node);
3755 vat_json_free (&node);
3757 vam->retval = ntohl (mp->retval);
3758 vam->result_ready = 1;
3761 static void vl_api_flow_classify_details_t_handler
3762 (vl_api_flow_classify_details_t * mp)
3764 vat_main_t *vam = &vat_main;
3766 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3767 ntohl (mp->table_index));
3770 static void vl_api_flow_classify_details_t_handler_json
3771 (vl_api_flow_classify_details_t * mp)
3773 vat_main_t *vam = &vat_main;
3774 vat_json_node_t *node;
3776 if (VAT_JSON_ARRAY != vam->json_tree.type)
3778 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3779 vat_json_init_array (&vam->json_tree);
3781 node = vat_json_array_add (&vam->json_tree);
3783 vat_json_init_object (node);
3784 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3785 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3790 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3791 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3792 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3793 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3794 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3795 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3796 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3797 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3798 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3799 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3802 * Generate boilerplate reply handlers, which
3803 * dig the return value out of the xxx_reply_t API message,
3804 * stick it into vam->retval, and set vam->result_ready
3806 * Could also do this by pointing N message decode slots at
3807 * a single function, but that could break in subtle ways.
3810 #define foreach_standard_reply_retval_handler \
3811 _(sw_interface_set_flags_reply) \
3812 _(sw_interface_add_del_address_reply) \
3813 _(sw_interface_set_table_reply) \
3814 _(sw_interface_set_mpls_enable_reply) \
3815 _(sw_interface_set_vpath_reply) \
3816 _(sw_interface_set_vxlan_bypass_reply) \
3817 _(sw_interface_set_l2_bridge_reply) \
3818 _(bridge_domain_add_del_reply) \
3819 _(sw_interface_set_l2_xconnect_reply) \
3820 _(l2fib_add_del_reply) \
3821 _(ip_add_del_route_reply) \
3822 _(ip_mroute_add_del_reply) \
3823 _(mpls_route_add_del_reply) \
3824 _(mpls_ip_bind_unbind_reply) \
3825 _(proxy_arp_add_del_reply) \
3826 _(proxy_arp_intfc_enable_disable_reply) \
3827 _(sw_interface_set_unnumbered_reply) \
3828 _(ip_neighbor_add_del_reply) \
3829 _(reset_vrf_reply) \
3830 _(oam_add_del_reply) \
3831 _(reset_fib_reply) \
3832 _(dhcp_proxy_config_reply) \
3833 _(dhcp_proxy_set_vss_reply) \
3834 _(dhcp_client_config_reply) \
3835 _(set_ip_flow_hash_reply) \
3836 _(sw_interface_ip6_enable_disable_reply) \
3837 _(sw_interface_ip6_set_link_local_address_reply) \
3838 _(sw_interface_ip6nd_ra_prefix_reply) \
3839 _(sw_interface_ip6nd_ra_config_reply) \
3840 _(set_arp_neighbor_limit_reply) \
3841 _(l2_patch_add_del_reply) \
3842 _(sr_tunnel_add_del_reply) \
3843 _(sr_policy_add_del_reply) \
3844 _(sr_multicast_map_add_del_reply) \
3845 _(classify_add_del_session_reply) \
3846 _(classify_set_interface_ip_table_reply) \
3847 _(classify_set_interface_l2_tables_reply) \
3848 _(l2tpv3_set_tunnel_cookies_reply) \
3849 _(l2tpv3_interface_enable_disable_reply) \
3850 _(l2tpv3_set_lookup_key_reply) \
3851 _(l2_fib_clear_table_reply) \
3852 _(l2_interface_efp_filter_reply) \
3853 _(l2_interface_vlan_tag_rewrite_reply) \
3854 _(modify_vhost_user_if_reply) \
3855 _(delete_vhost_user_if_reply) \
3856 _(want_ip4_arp_events_reply) \
3857 _(want_ip6_nd_events_reply) \
3858 _(input_acl_set_interface_reply) \
3859 _(ipsec_spd_add_del_reply) \
3860 _(ipsec_interface_add_del_spd_reply) \
3861 _(ipsec_spd_add_del_entry_reply) \
3862 _(ipsec_sad_add_del_entry_reply) \
3863 _(ipsec_sa_set_key_reply) \
3864 _(ikev2_profile_add_del_reply) \
3865 _(ikev2_profile_set_auth_reply) \
3866 _(ikev2_profile_set_id_reply) \
3867 _(ikev2_profile_set_ts_reply) \
3868 _(ikev2_set_local_key_reply) \
3869 _(ikev2_set_responder_reply) \
3870 _(ikev2_set_ike_transforms_reply) \
3871 _(ikev2_set_esp_transforms_reply) \
3872 _(ikev2_set_sa_lifetime_reply) \
3873 _(ikev2_initiate_sa_init_reply) \
3874 _(ikev2_initiate_del_ike_sa_reply) \
3875 _(ikev2_initiate_del_child_sa_reply) \
3876 _(ikev2_initiate_rekey_child_sa_reply) \
3877 _(delete_loopback_reply) \
3878 _(bd_ip_mac_add_del_reply) \
3879 _(map_del_domain_reply) \
3880 _(map_add_del_rule_reply) \
3881 _(want_interface_events_reply) \
3882 _(want_stats_reply) \
3883 _(cop_interface_enable_disable_reply) \
3884 _(cop_whitelist_enable_disable_reply) \
3885 _(sw_interface_clear_stats_reply) \
3886 _(ioam_enable_reply) \
3887 _(ioam_disable_reply) \
3888 _(one_add_del_locator_reply) \
3889 _(one_add_del_local_eid_reply) \
3890 _(one_add_del_remote_mapping_reply) \
3891 _(one_add_del_adjacency_reply) \
3892 _(one_add_del_map_resolver_reply) \
3893 _(one_add_del_map_server_reply) \
3894 _(one_enable_disable_reply) \
3895 _(one_rloc_probe_enable_disable_reply) \
3896 _(one_map_register_enable_disable_reply) \
3897 _(one_pitr_set_locator_set_reply) \
3898 _(one_map_request_mode_reply) \
3899 _(one_add_del_map_request_itr_rlocs_reply) \
3900 _(one_eid_table_add_del_map_reply) \
3901 _(gpe_add_del_fwd_entry_reply) \
3902 _(gpe_enable_disable_reply) \
3903 _(gpe_add_del_iface_reply) \
3904 _(vxlan_gpe_add_del_tunnel_reply) \
3905 _(af_packet_delete_reply) \
3906 _(policer_classify_set_interface_reply) \
3907 _(netmap_create_reply) \
3908 _(netmap_delete_reply) \
3909 _(set_ipfix_exporter_reply) \
3910 _(set_ipfix_classify_stream_reply) \
3911 _(ipfix_classify_table_add_del_reply) \
3912 _(flow_classify_set_interface_reply) \
3913 _(sw_interface_span_enable_disable_reply) \
3914 _(pg_capture_reply) \
3915 _(pg_enable_disable_reply) \
3916 _(ip_source_and_port_range_check_add_del_reply) \
3917 _(ip_source_and_port_range_check_interface_add_del_reply)\
3918 _(delete_subif_reply) \
3919 _(l2_interface_pbb_tag_rewrite_reply) \
3921 _(feature_enable_disable_reply) \
3922 _(sw_interface_tag_add_del_reply) \
3923 _(sw_interface_set_mtu_reply)
3926 #define foreach_standard_dpdk_reply_retval_handler \
3927 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3928 _(sw_interface_set_dpdk_hqos_subport_reply) \
3929 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3933 static void vl_api_##n##_t_handler \
3934 (vl_api_##n##_t * mp) \
3936 vat_main_t * vam = &vat_main; \
3937 i32 retval = ntohl(mp->retval); \
3938 if (vam->async_mode) { \
3939 vam->async_errors += (retval < 0); \
3941 vam->retval = retval; \
3942 vam->result_ready = 1; \
3945 foreach_standard_reply_retval_handler;
3949 static void vl_api_##n##_t_handler_json \
3950 (vl_api_##n##_t * mp) \
3952 vat_main_t * vam = &vat_main; \
3953 vat_json_node_t node; \
3954 vat_json_init_object(&node); \
3955 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3956 vat_json_print(vam->ofp, &node); \
3957 vam->retval = ntohl(mp->retval); \
3958 vam->result_ready = 1; \
3960 foreach_standard_reply_retval_handler;
3965 static void vl_api_##n##_t_handler \
3966 (vl_api_##n##_t * mp) \
3968 vat_main_t * vam = &vat_main; \
3969 i32 retval = ntohl(mp->retval); \
3970 if (vam->async_mode) { \
3971 vam->async_errors += (retval < 0); \
3973 vam->retval = retval; \
3974 vam->result_ready = 1; \
3977 foreach_standard_dpdk_reply_retval_handler;
3981 static void vl_api_##n##_t_handler_json \
3982 (vl_api_##n##_t * mp) \
3984 vat_main_t * vam = &vat_main; \
3985 vat_json_node_t node; \
3986 vat_json_init_object(&node); \
3987 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3988 vat_json_print(vam->ofp, &node); \
3989 vam->retval = ntohl(mp->retval); \
3990 vam->result_ready = 1; \
3992 foreach_standard_dpdk_reply_retval_handler;
3997 * Table of message reply handlers, must include boilerplate handlers
4001 #define foreach_vpe_api_reply_msg \
4002 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4003 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4004 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4005 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4006 _(CONTROL_PING_REPLY, control_ping_reply) \
4007 _(CLI_REPLY, cli_reply) \
4008 _(CLI_INBAND_REPLY, cli_inband_reply) \
4009 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4010 sw_interface_add_del_address_reply) \
4011 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4012 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4013 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4014 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4015 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4016 sw_interface_set_l2_xconnect_reply) \
4017 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4018 sw_interface_set_l2_bridge_reply) \
4019 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4020 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4021 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4022 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4023 _(L2_FLAGS_REPLY, l2_flags_reply) \
4024 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4025 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4026 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4027 _(TAP_DELETE_REPLY, tap_delete_reply) \
4028 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4029 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4030 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4031 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4032 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4033 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4034 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4035 proxy_arp_intfc_enable_disable_reply) \
4036 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4037 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4038 sw_interface_set_unnumbered_reply) \
4039 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4040 _(RESET_VRF_REPLY, reset_vrf_reply) \
4041 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4042 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4043 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4044 _(RESET_FIB_REPLY, reset_fib_reply) \
4045 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4046 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4047 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4048 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4049 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4050 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4051 sw_interface_ip6_enable_disable_reply) \
4052 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4053 sw_interface_ip6_set_link_local_address_reply) \
4054 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4055 sw_interface_ip6nd_ra_prefix_reply) \
4056 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4057 sw_interface_ip6nd_ra_config_reply) \
4058 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4059 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4060 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4061 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4062 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4063 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4064 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4065 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4066 classify_set_interface_ip_table_reply) \
4067 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4068 classify_set_interface_l2_tables_reply) \
4069 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4070 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4071 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4072 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4073 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4074 l2tpv3_interface_enable_disable_reply) \
4075 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4076 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4077 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4078 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4079 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4080 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4081 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4082 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4083 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4084 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4085 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4086 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4087 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4088 _(SHOW_VERSION_REPLY, show_version_reply) \
4089 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4090 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4091 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4092 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4093 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4094 _(IP4_ARP_EVENT, ip4_arp_event) \
4095 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4096 _(IP6_ND_EVENT, ip6_nd_event) \
4097 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4098 _(IP_ADDRESS_DETAILS, ip_address_details) \
4099 _(IP_DETAILS, ip_details) \
4100 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4101 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4102 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4103 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4104 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4105 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4106 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4107 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4108 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4109 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4110 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4111 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4112 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4113 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4114 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4115 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4116 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4117 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4118 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4119 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4120 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4121 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4122 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4123 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4124 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4125 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4126 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4127 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4128 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4129 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4130 _(MAP_RULE_DETAILS, map_rule_details) \
4131 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4132 _(WANT_STATS_REPLY, want_stats_reply) \
4133 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4134 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4135 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4136 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4137 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4138 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4139 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4140 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4141 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4142 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4143 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4144 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4145 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4146 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4147 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4148 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4149 one_map_register_enable_disable_reply) \
4150 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4151 one_rloc_probe_enable_disable_reply) \
4152 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4153 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4154 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4155 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4156 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4157 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4158 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4159 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4160 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4161 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4162 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4163 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4164 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4165 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4166 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4167 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4168 gpe_fwd_entry_path_details) \
4169 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4170 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4171 one_add_del_map_request_itr_rlocs_reply) \
4172 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4173 one_get_map_request_itr_rlocs_reply) \
4174 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4175 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4176 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4177 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4178 show_one_map_register_state_reply) \
4179 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4180 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4181 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4182 _(POLICER_DETAILS, policer_details) \
4183 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4184 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4185 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4186 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4187 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4188 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4189 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4190 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4191 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4192 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4193 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4194 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4195 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4196 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4197 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4198 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4199 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4200 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4201 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4202 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4203 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4204 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4205 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4206 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4207 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4208 ip_source_and_port_range_check_add_del_reply) \
4209 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4210 ip_source_and_port_range_check_interface_add_del_reply) \
4211 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4212 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4213 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4214 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4215 _(PUNT_REPLY, punt_reply) \
4216 _(IP_FIB_DETAILS, ip_fib_details) \
4217 _(IP6_FIB_DETAILS, ip6_fib_details) \
4218 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4219 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4220 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4221 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4222 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4223 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4226 #define foreach_vpe_dpdk_api_reply_msg \
4227 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4228 sw_interface_set_dpdk_hqos_pipe_reply) \
4229 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4230 sw_interface_set_dpdk_hqos_subport_reply) \
4231 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4232 sw_interface_set_dpdk_hqos_tctbl_reply)
4242 #define STR_VTR_OP_CASE(op) \
4243 case L2_VTR_ ## op: \
4247 str_vtr_op (u32 vtr_op)
4251 STR_VTR_OP_CASE (DISABLED);
4252 STR_VTR_OP_CASE (PUSH_1);
4253 STR_VTR_OP_CASE (PUSH_2);
4254 STR_VTR_OP_CASE (POP_1);
4255 STR_VTR_OP_CASE (POP_2);
4256 STR_VTR_OP_CASE (TRANSLATE_1_1);
4257 STR_VTR_OP_CASE (TRANSLATE_1_2);
4258 STR_VTR_OP_CASE (TRANSLATE_2_1);
4259 STR_VTR_OP_CASE (TRANSLATE_2_2);
4266 dump_sub_interface_table (vat_main_t * vam)
4268 const sw_interface_subif_t *sub = NULL;
4270 if (vam->json_output)
4273 ("JSON output supported only for VPE API calls and dump_stats_table");
4278 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4279 "Interface", "sw_if_index",
4280 "sub id", "dot1ad", "tags", "outer id",
4281 "inner id", "exact", "default", "outer any", "inner any");
4283 vec_foreach (sub, vam->sw_if_subif_table)
4286 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4287 sub->interface_name,
4289 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4290 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4291 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4292 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4293 if (sub->vtr_op != L2_VTR_DISABLED)
4296 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4297 "tag1: %d tag2: %d ]",
4298 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4299 sub->vtr_tag1, sub->vtr_tag2);
4307 name_sort_cmp (void *a1, void *a2)
4309 name_sort_t *n1 = a1;
4310 name_sort_t *n2 = a2;
4312 return strcmp ((char *) n1->name, (char *) n2->name);
4316 dump_interface_table (vat_main_t * vam)
4319 name_sort_t *nses = 0, *ns;
4321 if (vam->json_output)
4324 ("JSON output supported only for VPE API calls and dump_stats_table");
4329 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4331 vec_add2 (nses, ns, 1);
4332 ns->name = (u8 *)(p->key);
4333 ns->value = (u32) p->value[0];
4337 vec_sort_with_function (nses, name_sort_cmp);
4339 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4340 vec_foreach (ns, nses)
4342 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4349 dump_ip_table (vat_main_t * vam, int is_ipv6)
4351 const ip_details_t *det = NULL;
4352 const ip_address_details_t *address = NULL;
4355 print (vam->ofp, "%-12s", "sw_if_index");
4357 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4364 print (vam->ofp, "%-12d", i);
4365 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4370 vec_foreach (address, det->addr)
4374 is_ipv6 ? format_ip6_address : format_ip4_address,
4375 address->ip, address->prefix_length);
4383 dump_ipv4_table (vat_main_t * vam)
4385 if (vam->json_output)
4388 ("JSON output supported only for VPE API calls and dump_stats_table");
4392 return dump_ip_table (vam, 0);
4396 dump_ipv6_table (vat_main_t * vam)
4398 if (vam->json_output)
4401 ("JSON output supported only for VPE API calls and dump_stats_table");
4405 return dump_ip_table (vam, 1);
4409 counter_type_to_str (u8 counter_type, u8 is_combined)
4413 switch (counter_type)
4415 case VNET_INTERFACE_COUNTER_DROP:
4417 case VNET_INTERFACE_COUNTER_PUNT:
4419 case VNET_INTERFACE_COUNTER_IP4:
4421 case VNET_INTERFACE_COUNTER_IP6:
4423 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4425 case VNET_INTERFACE_COUNTER_RX_MISS:
4427 case VNET_INTERFACE_COUNTER_RX_ERROR:
4429 case VNET_INTERFACE_COUNTER_TX_ERROR:
4432 return "INVALID-COUNTER-TYPE";
4437 switch (counter_type)
4439 case VNET_INTERFACE_COUNTER_RX:
4441 case VNET_INTERFACE_COUNTER_TX:
4444 return "INVALID-COUNTER-TYPE";
4450 dump_stats_table (vat_main_t * vam)
4452 vat_json_node_t node;
4453 vat_json_node_t *msg_array;
4454 vat_json_node_t *msg;
4455 vat_json_node_t *counter_array;
4456 vat_json_node_t *counter;
4457 interface_counter_t c;
4459 ip4_fib_counter_t *c4;
4460 ip6_fib_counter_t *c6;
4461 ip4_nbr_counter_t *n4;
4462 ip6_nbr_counter_t *n6;
4465 if (!vam->json_output)
4467 clib_warning ("dump_stats_table supported only in JSON format");
4471 vat_json_init_object (&node);
4473 /* interface counters */
4474 msg_array = vat_json_object_add (&node, "interface_counters");
4475 vat_json_init_array (msg_array);
4476 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4478 msg = vat_json_array_add (msg_array);
4479 vat_json_init_object (msg);
4480 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4481 (u8 *) counter_type_to_str (i, 0));
4482 vat_json_object_add_int (msg, "is_combined", 0);
4483 counter_array = vat_json_object_add (msg, "data");
4484 vat_json_init_array (counter_array);
4485 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4487 packets = vam->simple_interface_counters[i][j];
4488 vat_json_array_add_uint (counter_array, packets);
4491 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4493 msg = vat_json_array_add (msg_array);
4494 vat_json_init_object (msg);
4495 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4496 (u8 *) counter_type_to_str (i, 1));
4497 vat_json_object_add_int (msg, "is_combined", 1);
4498 counter_array = vat_json_object_add (msg, "data");
4499 vat_json_init_array (counter_array);
4500 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4502 c = vam->combined_interface_counters[i][j];
4503 counter = vat_json_array_add (counter_array);
4504 vat_json_init_object (counter);
4505 vat_json_object_add_uint (counter, "packets", c.packets);
4506 vat_json_object_add_uint (counter, "bytes", c.bytes);
4510 /* ip4 fib counters */
4511 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4512 vat_json_init_array (msg_array);
4513 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4515 msg = vat_json_array_add (msg_array);
4516 vat_json_init_object (msg);
4517 vat_json_object_add_uint (msg, "vrf_id",
4518 vam->ip4_fib_counters_vrf_id_by_index[i]);
4519 counter_array = vat_json_object_add (msg, "c");
4520 vat_json_init_array (counter_array);
4521 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4523 counter = vat_json_array_add (counter_array);
4524 vat_json_init_object (counter);
4525 c4 = &vam->ip4_fib_counters[i][j];
4526 vat_json_object_add_ip4 (counter, "address", c4->address);
4527 vat_json_object_add_uint (counter, "address_length",
4528 c4->address_length);
4529 vat_json_object_add_uint (counter, "packets", c4->packets);
4530 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4534 /* ip6 fib counters */
4535 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4536 vat_json_init_array (msg_array);
4537 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4539 msg = vat_json_array_add (msg_array);
4540 vat_json_init_object (msg);
4541 vat_json_object_add_uint (msg, "vrf_id",
4542 vam->ip6_fib_counters_vrf_id_by_index[i]);
4543 counter_array = vat_json_object_add (msg, "c");
4544 vat_json_init_array (counter_array);
4545 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4547 counter = vat_json_array_add (counter_array);
4548 vat_json_init_object (counter);
4549 c6 = &vam->ip6_fib_counters[i][j];
4550 vat_json_object_add_ip6 (counter, "address", c6->address);
4551 vat_json_object_add_uint (counter, "address_length",
4552 c6->address_length);
4553 vat_json_object_add_uint (counter, "packets", c6->packets);
4554 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4558 /* ip4 nbr counters */
4559 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4560 vat_json_init_array (msg_array);
4561 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4563 msg = vat_json_array_add (msg_array);
4564 vat_json_init_object (msg);
4565 vat_json_object_add_uint (msg, "sw_if_index", i);
4566 counter_array = vat_json_object_add (msg, "c");
4567 vat_json_init_array (counter_array);
4568 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4570 counter = vat_json_array_add (counter_array);
4571 vat_json_init_object (counter);
4572 n4 = &vam->ip4_nbr_counters[i][j];
4573 vat_json_object_add_ip4 (counter, "address", n4->address);
4574 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4575 vat_json_object_add_uint (counter, "packets", n4->packets);
4576 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4580 /* ip6 nbr counters */
4581 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4582 vat_json_init_array (msg_array);
4583 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4585 msg = vat_json_array_add (msg_array);
4586 vat_json_init_object (msg);
4587 vat_json_object_add_uint (msg, "sw_if_index", i);
4588 counter_array = vat_json_object_add (msg, "c");
4589 vat_json_init_array (counter_array);
4590 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4592 counter = vat_json_array_add (counter_array);
4593 vat_json_init_object (counter);
4594 n6 = &vam->ip6_nbr_counters[i][j];
4595 vat_json_object_add_ip6 (counter, "address", n6->address);
4596 vat_json_object_add_uint (counter, "packets", n6->packets);
4597 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4601 vat_json_print (vam->ofp, &node);
4602 vat_json_free (&node);
4608 exec (vat_main_t * vam)
4610 api_main_t *am = &api_main;
4611 vl_api_cli_request_t *mp;
4615 unformat_input_t *i = vam->input;
4617 if (vec_len (i->buffer) == 0)
4620 if (vam->exec_mode == 0 && unformat (i, "mode"))
4625 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4632 M (CLI_REQUEST, mp);
4635 * Copy cmd into shared memory.
4636 * In order for the CLI command to work, it
4637 * must be a vector ending in \n, not a C-string ending
4640 pthread_mutex_lock (&am->vlib_rp->mutex);
4641 oldheap = svm_push_data_heap (am->vlib_rp);
4643 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4644 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4646 svm_pop_heap (oldheap);
4647 pthread_mutex_unlock (&am->vlib_rp->mutex);
4649 mp->cmd_in_shmem = (u64) cmd;
4651 timeout = vat_time_now (vam) + 10.0;
4653 while (vat_time_now (vam) < timeout)
4655 if (vam->result_ready == 1)
4658 if (vam->shmem_result != NULL)
4659 print (vam->ofp, "%s", vam->shmem_result);
4660 pthread_mutex_lock (&am->vlib_rp->mutex);
4661 oldheap = svm_push_data_heap (am->vlib_rp);
4663 free_me = (u8 *) vam->shmem_result;
4666 svm_pop_heap (oldheap);
4667 pthread_mutex_unlock (&am->vlib_rp->mutex);
4675 * Future replacement of exec() that passes CLI buffers directly in
4676 * the API messages instead of an additional shared memory area.
4679 exec_inband (vat_main_t * vam)
4681 vl_api_cli_inband_t *mp;
4682 unformat_input_t *i = vam->input;
4685 if (vec_len (i->buffer) == 0)
4688 if (vam->exec_mode == 0 && unformat (i, "mode"))
4693 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4700 * In order for the CLI command to work, it
4701 * must be a vector ending in \n, not a C-string ending
4704 u32 len = vec_len (vam->input->buffer);
4705 M2 (CLI_INBAND, mp, len);
4706 clib_memcpy (mp->cmd, vam->input->buffer, len);
4707 mp->length = htonl (len);
4710 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4715 api_create_loopback (vat_main_t * vam)
4717 unformat_input_t *i = vam->input;
4718 vl_api_create_loopback_t *mp;
4723 memset (mac_address, 0, sizeof (mac_address));
4725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4727 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4733 /* Construct the API message */
4734 M (CREATE_LOOPBACK, mp);
4736 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4744 api_delete_loopback (vat_main_t * vam)
4746 unformat_input_t *i = vam->input;
4747 vl_api_delete_loopback_t *mp;
4748 u32 sw_if_index = ~0;
4751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4753 if (unformat (i, "sw_if_index %d", &sw_if_index))
4759 if (sw_if_index == ~0)
4761 errmsg ("missing sw_if_index");
4765 /* Construct the API message */
4766 M (DELETE_LOOPBACK, mp);
4767 mp->sw_if_index = ntohl (sw_if_index);
4775 api_want_stats (vat_main_t * vam)
4777 unformat_input_t *i = vam->input;
4778 vl_api_want_stats_t *mp;
4782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4784 if (unformat (i, "enable"))
4786 else if (unformat (i, "disable"))
4794 errmsg ("missing enable|disable");
4799 mp->enable_disable = enable;
4807 api_want_interface_events (vat_main_t * vam)
4809 unformat_input_t *i = vam->input;
4810 vl_api_want_interface_events_t *mp;
4814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4816 if (unformat (i, "enable"))
4818 else if (unformat (i, "disable"))
4826 errmsg ("missing enable|disable");
4830 M (WANT_INTERFACE_EVENTS, mp);
4831 mp->enable_disable = enable;
4833 vam->interface_event_display = enable;
4841 /* Note: non-static, called once to set up the initial intfc table */
4843 api_sw_interface_dump (vat_main_t * vam)
4845 vl_api_sw_interface_dump_t *mp;
4846 vl_api_control_ping_t *mp_ping;
4848 name_sort_t *nses = 0, *ns;
4849 sw_interface_subif_t *sub = NULL;
4852 /* Toss the old name table */
4854 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4856 vec_add2 (nses, ns, 1);
4857 ns->name = (u8 *)(p->key);
4858 ns->value = (u32) p->value[0];
4862 hash_free (vam->sw_if_index_by_interface_name);
4864 vec_foreach (ns, nses) vec_free (ns->name);
4868 vec_foreach (sub, vam->sw_if_subif_table)
4870 vec_free (sub->interface_name);
4872 vec_free (vam->sw_if_subif_table);
4874 /* recreate the interface name hash table */
4875 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4877 /* Get list of ethernets */
4878 M (SW_INTERFACE_DUMP, mp);
4879 mp->name_filter_valid = 1;
4880 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4883 /* and local / loopback interfaces */
4884 M (SW_INTERFACE_DUMP, mp);
4885 mp->name_filter_valid = 1;
4886 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4889 /* and packet-generator interfaces */
4890 M (SW_INTERFACE_DUMP, mp);
4891 mp->name_filter_valid = 1;
4892 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4895 /* and vxlan-gpe tunnel interfaces */
4896 M (SW_INTERFACE_DUMP, mp);
4897 mp->name_filter_valid = 1;
4898 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4899 sizeof (mp->name_filter) - 1);
4902 /* and vxlan tunnel interfaces */
4903 M (SW_INTERFACE_DUMP, mp);
4904 mp->name_filter_valid = 1;
4905 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4908 /* and host (af_packet) interfaces */
4909 M (SW_INTERFACE_DUMP, mp);
4910 mp->name_filter_valid = 1;
4911 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4914 /* and l2tpv3 tunnel interfaces */
4915 M (SW_INTERFACE_DUMP, mp);
4916 mp->name_filter_valid = 1;
4917 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4918 sizeof (mp->name_filter) - 1);
4921 /* and GRE tunnel interfaces */
4922 M (SW_INTERFACE_DUMP, mp);
4923 mp->name_filter_valid = 1;
4924 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4927 /* and LISP-GPE interfaces */
4928 M (SW_INTERFACE_DUMP, mp);
4929 mp->name_filter_valid = 1;
4930 strncpy ((char *) mp->name_filter, "lisp_gpe",
4931 sizeof (mp->name_filter) - 1);
4934 /* and IPSEC tunnel interfaces */
4935 M (SW_INTERFACE_DUMP, mp);
4936 mp->name_filter_valid = 1;
4937 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4940 /* Use a control ping for synchronization */
4941 M (CONTROL_PING, mp_ping);
4949 api_sw_interface_set_flags (vat_main_t * vam)
4951 unformat_input_t *i = vam->input;
4952 vl_api_sw_interface_set_flags_t *mp;
4954 u8 sw_if_index_set = 0;
4955 u8 admin_up = 0, link_up = 0;
4958 /* Parse args required to build the message */
4959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4961 if (unformat (i, "admin-up"))
4963 else if (unformat (i, "admin-down"))
4965 else if (unformat (i, "link-up"))
4967 else if (unformat (i, "link-down"))
4970 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4971 sw_if_index_set = 1;
4972 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4973 sw_if_index_set = 1;
4978 if (sw_if_index_set == 0)
4980 errmsg ("missing interface name or sw_if_index");
4984 /* Construct the API message */
4985 M (SW_INTERFACE_SET_FLAGS, mp);
4986 mp->sw_if_index = ntohl (sw_if_index);
4987 mp->admin_up_down = admin_up;
4988 mp->link_up_down = link_up;
4993 /* Wait for a reply, return the good/bad news... */
4999 api_sw_interface_clear_stats (vat_main_t * vam)
5001 unformat_input_t *i = vam->input;
5002 vl_api_sw_interface_clear_stats_t *mp;
5004 u8 sw_if_index_set = 0;
5007 /* Parse args required to build the message */
5008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5010 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5011 sw_if_index_set = 1;
5012 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5013 sw_if_index_set = 1;
5018 /* Construct the API message */
5019 M (SW_INTERFACE_CLEAR_STATS, mp);
5021 if (sw_if_index_set == 1)
5022 mp->sw_if_index = ntohl (sw_if_index);
5024 mp->sw_if_index = ~0;
5029 /* Wait for a reply, return the good/bad news... */
5036 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
5038 unformat_input_t *i = vam->input;
5039 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
5041 u8 sw_if_index_set = 0;
5050 /* Parse args required to build the message */
5051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5053 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5054 sw_if_index_set = 1;
5055 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5056 sw_if_index_set = 1;
5057 else if (unformat (i, "subport %u", &subport))
5060 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5061 sw_if_index_set = 1;
5062 else if (unformat (i, "pipe %u", &pipe))
5064 else if (unformat (i, "profile %u", &profile))
5070 if (sw_if_index_set == 0)
5072 errmsg ("missing interface name or sw_if_index");
5076 if (subport_set == 0)
5078 errmsg ("missing subport ");
5084 errmsg ("missing pipe");
5088 if (profile_set == 0)
5090 errmsg ("missing profile");
5094 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
5096 mp->sw_if_index = ntohl (sw_if_index);
5097 mp->subport = ntohl (subport);
5098 mp->pipe = ntohl (pipe);
5099 mp->profile = ntohl (profile);
5108 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
5110 unformat_input_t *i = vam->input;
5111 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
5113 u8 sw_if_index_set = 0;
5116 u32 tb_rate = 1250000000; /* 10GbE */
5117 u32 tb_size = 1000000;
5118 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
5122 /* Parse args required to build the message */
5123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5125 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5126 sw_if_index_set = 1;
5127 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5128 sw_if_index_set = 1;
5129 else if (unformat (i, "subport %u", &subport))
5132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5133 sw_if_index_set = 1;
5134 else if (unformat (i, "rate %u", &tb_rate))
5138 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
5140 tc_rate[tc_id] = tb_rate;
5142 else if (unformat (i, "bktsize %u", &tb_size))
5144 else if (unformat (i, "tc0 %u", &tc_rate[0]))
5146 else if (unformat (i, "tc1 %u", &tc_rate[1]))
5148 else if (unformat (i, "tc2 %u", &tc_rate[2]))
5150 else if (unformat (i, "tc3 %u", &tc_rate[3]))
5152 else if (unformat (i, "period %u", &tc_period))
5158 if (sw_if_index_set == 0)
5160 errmsg ("missing interface name or sw_if_index");
5164 if (subport_set == 0)
5166 errmsg ("missing subport ");
5170 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
5172 mp->sw_if_index = ntohl (sw_if_index);
5173 mp->subport = ntohl (subport);
5174 mp->tb_rate = ntohl (tb_rate);
5175 mp->tb_size = ntohl (tb_size);
5176 mp->tc_rate[0] = ntohl (tc_rate[0]);
5177 mp->tc_rate[1] = ntohl (tc_rate[1]);
5178 mp->tc_rate[2] = ntohl (tc_rate[2]);
5179 mp->tc_rate[3] = ntohl (tc_rate[3]);
5180 mp->tc_period = ntohl (tc_period);
5188 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
5190 unformat_input_t *i = vam->input;
5191 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
5193 u8 sw_if_index_set = 0;
5197 u32 entry, tc, queue;
5200 /* Parse args required to build the message */
5201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5203 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5204 sw_if_index_set = 1;
5205 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5206 sw_if_index_set = 1;
5207 else if (unformat (i, "entry %d", &entry))
5209 else if (unformat (i, "tc %d", &tc))
5211 else if (unformat (i, "queue %d", &queue))
5217 if (sw_if_index_set == 0)
5219 errmsg ("missing interface name or sw_if_index");
5225 errmsg ("missing entry ");
5231 errmsg ("missing traffic class ");
5237 errmsg ("missing queue ");
5241 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
5243 mp->sw_if_index = ntohl (sw_if_index);
5244 mp->entry = ntohl (entry);
5245 mp->tc = ntohl (tc);
5246 mp->queue = ntohl (queue);
5255 api_sw_interface_add_del_address (vat_main_t * vam)
5257 unformat_input_t *i = vam->input;
5258 vl_api_sw_interface_add_del_address_t *mp;
5260 u8 sw_if_index_set = 0;
5261 u8 is_add = 1, del_all = 0;
5262 u32 address_length = 0;
5263 u8 v4_address_set = 0;
5264 u8 v6_address_set = 0;
5265 ip4_address_t v4address;
5266 ip6_address_t v6address;
5269 /* Parse args required to build the message */
5270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5272 if (unformat (i, "del-all"))
5274 else if (unformat (i, "del"))
5277 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5278 sw_if_index_set = 1;
5279 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5280 sw_if_index_set = 1;
5281 else if (unformat (i, "%U/%d",
5282 unformat_ip4_address, &v4address, &address_length))
5284 else if (unformat (i, "%U/%d",
5285 unformat_ip6_address, &v6address, &address_length))
5291 if (sw_if_index_set == 0)
5293 errmsg ("missing interface name or sw_if_index");
5296 if (v4_address_set && v6_address_set)
5298 errmsg ("both v4 and v6 addresses set");
5301 if (!v4_address_set && !v6_address_set && !del_all)
5303 errmsg ("no addresses set");
5307 /* Construct the API message */
5308 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5310 mp->sw_if_index = ntohl (sw_if_index);
5311 mp->is_add = is_add;
5312 mp->del_all = del_all;
5316 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5320 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5322 mp->address_length = address_length;
5327 /* Wait for a reply, return good/bad news */
5333 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5335 unformat_input_t *i = vam->input;
5336 vl_api_sw_interface_set_mpls_enable_t *mp;
5338 u8 sw_if_index_set = 0;
5342 /* Parse args required to build the message */
5343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5345 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5346 sw_if_index_set = 1;
5347 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5348 sw_if_index_set = 1;
5349 else if (unformat (i, "disable"))
5351 else if (unformat (i, "dis"))
5357 if (sw_if_index_set == 0)
5359 errmsg ("missing interface name or sw_if_index");
5363 /* Construct the API message */
5364 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5366 mp->sw_if_index = ntohl (sw_if_index);
5367 mp->enable = enable;
5372 /* Wait for a reply... */
5378 api_sw_interface_set_table (vat_main_t * vam)
5380 unformat_input_t *i = vam->input;
5381 vl_api_sw_interface_set_table_t *mp;
5382 u32 sw_if_index, vrf_id = 0;
5383 u8 sw_if_index_set = 0;
5387 /* Parse args required to build the message */
5388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5390 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5391 sw_if_index_set = 1;
5392 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5393 sw_if_index_set = 1;
5394 else if (unformat (i, "vrf %d", &vrf_id))
5396 else if (unformat (i, "ipv6"))
5402 if (sw_if_index_set == 0)
5404 errmsg ("missing interface name or sw_if_index");
5408 /* Construct the API message */
5409 M (SW_INTERFACE_SET_TABLE, mp);
5411 mp->sw_if_index = ntohl (sw_if_index);
5412 mp->is_ipv6 = is_ipv6;
5413 mp->vrf_id = ntohl (vrf_id);
5418 /* Wait for a reply... */
5423 static void vl_api_sw_interface_get_table_reply_t_handler
5424 (vl_api_sw_interface_get_table_reply_t * mp)
5426 vat_main_t *vam = &vat_main;
5428 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5430 vam->retval = ntohl (mp->retval);
5431 vam->result_ready = 1;
5435 static void vl_api_sw_interface_get_table_reply_t_handler_json
5436 (vl_api_sw_interface_get_table_reply_t * mp)
5438 vat_main_t *vam = &vat_main;
5439 vat_json_node_t node;
5441 vat_json_init_object (&node);
5442 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5443 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5445 vat_json_print (vam->ofp, &node);
5446 vat_json_free (&node);
5448 vam->retval = ntohl (mp->retval);
5449 vam->result_ready = 1;
5453 api_sw_interface_get_table (vat_main_t * vam)
5455 unformat_input_t *i = vam->input;
5456 vl_api_sw_interface_get_table_t *mp;
5458 u8 sw_if_index_set = 0;
5462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5465 sw_if_index_set = 1;
5466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5467 sw_if_index_set = 1;
5468 else if (unformat (i, "ipv6"))
5474 if (sw_if_index_set == 0)
5476 errmsg ("missing interface name or sw_if_index");
5480 M (SW_INTERFACE_GET_TABLE, mp);
5481 mp->sw_if_index = htonl (sw_if_index);
5482 mp->is_ipv6 = is_ipv6;
5490 api_sw_interface_set_vpath (vat_main_t * vam)
5492 unformat_input_t *i = vam->input;
5493 vl_api_sw_interface_set_vpath_t *mp;
5494 u32 sw_if_index = 0;
5495 u8 sw_if_index_set = 0;
5499 /* Parse args required to build the message */
5500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5502 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5503 sw_if_index_set = 1;
5504 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5505 sw_if_index_set = 1;
5506 else if (unformat (i, "enable"))
5508 else if (unformat (i, "disable"))
5514 if (sw_if_index_set == 0)
5516 errmsg ("missing interface name or sw_if_index");
5520 /* Construct the API message */
5521 M (SW_INTERFACE_SET_VPATH, mp);
5523 mp->sw_if_index = ntohl (sw_if_index);
5524 mp->enable = is_enable;
5529 /* Wait for a reply... */
5535 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5537 unformat_input_t *i = vam->input;
5538 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5539 u32 sw_if_index = 0;
5540 u8 sw_if_index_set = 0;
5545 /* Parse args required to build the message */
5546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5548 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5549 sw_if_index_set = 1;
5550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5551 sw_if_index_set = 1;
5552 else if (unformat (i, "enable"))
5554 else if (unformat (i, "disable"))
5556 else if (unformat (i, "ip4"))
5558 else if (unformat (i, "ip6"))
5564 if (sw_if_index_set == 0)
5566 errmsg ("missing interface name or sw_if_index");
5570 /* Construct the API message */
5571 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5573 mp->sw_if_index = ntohl (sw_if_index);
5574 mp->enable = is_enable;
5575 mp->is_ipv6 = is_ipv6;
5580 /* Wait for a reply... */
5586 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5588 unformat_input_t *i = vam->input;
5589 vl_api_sw_interface_set_l2_xconnect_t *mp;
5591 u8 rx_sw_if_index_set = 0;
5593 u8 tx_sw_if_index_set = 0;
5597 /* Parse args required to build the message */
5598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5600 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5601 rx_sw_if_index_set = 1;
5602 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5603 tx_sw_if_index_set = 1;
5604 else if (unformat (i, "rx"))
5606 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5608 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5610 rx_sw_if_index_set = 1;
5615 else if (unformat (i, "tx"))
5617 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5619 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5621 tx_sw_if_index_set = 1;
5626 else if (unformat (i, "enable"))
5628 else if (unformat (i, "disable"))
5634 if (rx_sw_if_index_set == 0)
5636 errmsg ("missing rx interface name or rx_sw_if_index");
5640 if (enable && (tx_sw_if_index_set == 0))
5642 errmsg ("missing tx interface name or tx_sw_if_index");
5646 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5648 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5649 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5650 mp->enable = enable;
5658 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5660 unformat_input_t *i = vam->input;
5661 vl_api_sw_interface_set_l2_bridge_t *mp;
5663 u8 rx_sw_if_index_set = 0;
5671 /* Parse args required to build the message */
5672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5674 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5675 rx_sw_if_index_set = 1;
5676 else if (unformat (i, "bd_id %d", &bd_id))
5680 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5681 rx_sw_if_index_set = 1;
5682 else if (unformat (i, "shg %d", &shg))
5684 else if (unformat (i, "bvi"))
5686 else if (unformat (i, "enable"))
5688 else if (unformat (i, "disable"))
5694 if (rx_sw_if_index_set == 0)
5696 errmsg ("missing rx interface name or sw_if_index");
5700 if (enable && (bd_id_set == 0))
5702 errmsg ("missing bridge domain");
5706 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5708 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5709 mp->bd_id = ntohl (bd_id);
5712 mp->enable = enable;
5720 api_bridge_domain_dump (vat_main_t * vam)
5722 unformat_input_t *i = vam->input;
5723 vl_api_bridge_domain_dump_t *mp;
5724 vl_api_control_ping_t *mp_ping;
5728 /* Parse args required to build the message */
5729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5731 if (unformat (i, "bd_id %d", &bd_id))
5737 M (BRIDGE_DOMAIN_DUMP, mp);
5738 mp->bd_id = ntohl (bd_id);
5741 /* Use a control ping for synchronization */
5742 M (CONTROL_PING, mp_ping);
5750 api_bridge_domain_add_del (vat_main_t * vam)
5752 unformat_input_t *i = vam->input;
5753 vl_api_bridge_domain_add_del_t *mp;
5756 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5760 /* Parse args required to build the message */
5761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5763 if (unformat (i, "bd_id %d", &bd_id))
5765 else if (unformat (i, "flood %d", &flood))
5767 else if (unformat (i, "uu-flood %d", &uu_flood))
5769 else if (unformat (i, "forward %d", &forward))
5771 else if (unformat (i, "learn %d", &learn))
5773 else if (unformat (i, "arp-term %d", &arp_term))
5775 else if (unformat (i, "mac-age %d", &mac_age))
5777 else if (unformat (i, "del"))
5780 flood = uu_flood = forward = learn = 0;
5788 errmsg ("missing bridge domain");
5794 errmsg ("mac age must be less than 256 ");
5798 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5800 mp->bd_id = ntohl (bd_id);
5802 mp->uu_flood = uu_flood;
5803 mp->forward = forward;
5805 mp->arp_term = arp_term;
5806 mp->is_add = is_add;
5807 mp->mac_age = (u8) mac_age;
5815 api_l2fib_add_del (vat_main_t * vam)
5817 unformat_input_t *i = vam->input;
5818 vl_api_l2fib_add_del_t *mp;
5824 u32 sw_if_index = ~0;
5825 u8 sw_if_index_set = 0;
5834 /* Parse args required to build the message */
5835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5837 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5839 else if (unformat (i, "bd_id %d", &bd_id))
5841 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5842 sw_if_index_set = 1;
5843 else if (unformat (i, "sw_if"))
5845 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5848 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5849 sw_if_index_set = 1;
5854 else if (unformat (i, "static"))
5856 else if (unformat (i, "filter"))
5861 else if (unformat (i, "bvi"))
5866 else if (unformat (i, "del"))
5868 else if (unformat (i, "count %d", &count))
5876 errmsg ("missing mac address");
5882 errmsg ("missing bridge domain");
5886 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5888 errmsg ("missing interface name or sw_if_index");
5894 /* Turn on async mode */
5895 vam->async_mode = 1;
5896 vam->async_errors = 0;
5897 before = vat_time_now (vam);
5900 for (j = 0; j < count; j++)
5902 M (L2FIB_ADD_DEL, mp);
5905 mp->bd_id = ntohl (bd_id);
5906 mp->is_add = is_add;
5910 mp->sw_if_index = ntohl (sw_if_index);
5911 mp->static_mac = static_mac;
5912 mp->filter_mac = filter_mac;
5913 mp->bvi_mac = bvi_mac;
5915 increment_mac_address (&mac);
5922 vl_api_control_ping_t *mp_ping;
5925 /* Shut off async mode */
5926 vam->async_mode = 0;
5928 M (CONTROL_PING, mp_ping);
5931 timeout = vat_time_now (vam) + 1.0;
5932 while (vat_time_now (vam) < timeout)
5933 if (vam->result_ready == 1)
5938 if (vam->retval == -99)
5941 if (vam->async_errors > 0)
5943 errmsg ("%d asynchronous errors", vam->async_errors);
5946 vam->async_errors = 0;
5947 after = vat_time_now (vam);
5949 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5950 count, after - before, count / (after - before));
5956 /* Wait for a reply... */
5960 /* Return the good/bad news */
5961 return (vam->retval);
5965 api_l2_flags (vat_main_t * vam)
5967 unformat_input_t *i = vam->input;
5968 vl_api_l2_flags_t *mp;
5970 u32 feature_bitmap = 0;
5971 u8 sw_if_index_set = 0;
5974 /* Parse args required to build the message */
5975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5977 if (unformat (i, "sw_if_index %d", &sw_if_index))
5978 sw_if_index_set = 1;
5979 else if (unformat (i, "sw_if"))
5981 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5984 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5985 sw_if_index_set = 1;
5990 else if (unformat (i, "learn"))
5991 feature_bitmap |= L2INPUT_FEAT_LEARN;
5992 else if (unformat (i, "forward"))
5993 feature_bitmap |= L2INPUT_FEAT_FWD;
5994 else if (unformat (i, "flood"))
5995 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5996 else if (unformat (i, "uu-flood"))
5997 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6002 if (sw_if_index_set == 0)
6004 errmsg ("missing interface name or sw_if_index");
6010 mp->sw_if_index = ntohl (sw_if_index);
6011 mp->feature_bitmap = ntohl (feature_bitmap);
6019 api_bridge_flags (vat_main_t * vam)
6021 unformat_input_t *i = vam->input;
6022 vl_api_bridge_flags_t *mp;
6029 /* Parse args required to build the message */
6030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6032 if (unformat (i, "bd_id %d", &bd_id))
6034 else if (unformat (i, "learn"))
6036 else if (unformat (i, "forward"))
6038 else if (unformat (i, "flood"))
6040 else if (unformat (i, "uu-flood"))
6041 flags |= L2_UU_FLOOD;
6042 else if (unformat (i, "arp-term"))
6043 flags |= L2_ARP_TERM;
6044 else if (unformat (i, "off"))
6046 else if (unformat (i, "disable"))
6054 errmsg ("missing bridge domain");
6058 M (BRIDGE_FLAGS, mp);
6060 mp->bd_id = ntohl (bd_id);
6061 mp->feature_bitmap = ntohl (flags);
6062 mp->is_set = is_set;
6070 api_bd_ip_mac_add_del (vat_main_t * vam)
6072 unformat_input_t *i = vam->input;
6073 vl_api_bd_ip_mac_add_del_t *mp;
6080 ip4_address_t v4addr;
6081 ip6_address_t v6addr;
6086 /* Parse args required to build the message */
6087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6089 if (unformat (i, "bd_id %d", &bd_id))
6093 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6097 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6102 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6106 else if (unformat (i, "del"))
6114 errmsg ("missing bridge domain");
6117 else if (ip_set == 0)
6119 errmsg ("missing IP address");
6122 else if (mac_set == 0)
6124 errmsg ("missing MAC address");
6128 M (BD_IP_MAC_ADD_DEL, mp);
6130 mp->bd_id = ntohl (bd_id);
6131 mp->is_ipv6 = is_ipv6;
6132 mp->is_add = is_add;
6134 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6136 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6137 clib_memcpy (mp->mac_address, macaddr, 6);
6144 api_tap_connect (vat_main_t * vam)
6146 unformat_input_t *i = vam->input;
6147 vl_api_tap_connect_t *mp;
6153 ip4_address_t ip4_address;
6155 int ip4_address_set = 0;
6156 ip6_address_t ip6_address;
6158 int ip6_address_set = 0;
6161 memset (mac_address, 0, sizeof (mac_address));
6163 /* Parse args required to build the message */
6164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6166 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6170 else if (unformat (i, "random-mac"))
6172 else if (unformat (i, "tapname %s", &tap_name))
6174 else if (unformat (i, "tag %s", &tag))
6176 else if (unformat (i, "address %U/%d",
6177 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6178 ip4_address_set = 1;
6179 else if (unformat (i, "address %U/%d",
6180 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6181 ip6_address_set = 1;
6188 errmsg ("missing tap name");
6191 if (vec_len (tap_name) > 63)
6193 errmsg ("tap name too long");
6196 vec_add1 (tap_name, 0);
6198 if (vec_len (tag) > 63)
6200 errmsg ("tag too long");
6204 /* Construct the API message */
6205 M (TAP_CONNECT, mp);
6207 mp->use_random_mac = random_mac;
6208 clib_memcpy (mp->mac_address, mac_address, 6);
6209 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6211 clib_memcpy (mp->tag, tag, vec_len (tag));
6213 if (ip4_address_set)
6215 mp->ip4_address_set = 1;
6216 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6217 mp->ip4_mask_width = ip4_mask_width;
6219 if (ip6_address_set)
6221 mp->ip6_address_set = 1;
6222 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6223 mp->ip6_mask_width = ip6_mask_width;
6226 vec_free (tap_name);
6232 /* Wait for a reply... */
6238 api_tap_modify (vat_main_t * vam)
6240 unformat_input_t *i = vam->input;
6241 vl_api_tap_modify_t *mp;
6246 u32 sw_if_index = ~0;
6247 u8 sw_if_index_set = 0;
6250 memset (mac_address, 0, sizeof (mac_address));
6252 /* Parse args required to build the message */
6253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6255 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6256 sw_if_index_set = 1;
6257 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6258 sw_if_index_set = 1;
6259 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6263 else if (unformat (i, "random-mac"))
6265 else if (unformat (i, "tapname %s", &tap_name))
6271 if (sw_if_index_set == 0)
6273 errmsg ("missing vpp interface name");
6278 errmsg ("missing tap name");
6281 if (vec_len (tap_name) > 63)
6283 errmsg ("tap name too long");
6285 vec_add1 (tap_name, 0);
6287 /* Construct the API message */
6290 mp->use_random_mac = random_mac;
6291 mp->sw_if_index = ntohl (sw_if_index);
6292 clib_memcpy (mp->mac_address, mac_address, 6);
6293 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6294 vec_free (tap_name);
6299 /* Wait for a reply... */
6305 api_tap_delete (vat_main_t * vam)
6307 unformat_input_t *i = vam->input;
6308 vl_api_tap_delete_t *mp;
6309 u32 sw_if_index = ~0;
6310 u8 sw_if_index_set = 0;
6313 /* Parse args required to build the message */
6314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6316 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6317 sw_if_index_set = 1;
6318 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6319 sw_if_index_set = 1;
6324 if (sw_if_index_set == 0)
6326 errmsg ("missing vpp interface name");
6330 /* Construct the API message */
6333 mp->sw_if_index = ntohl (sw_if_index);
6338 /* Wait for a reply... */
6344 api_ip_add_del_route (vat_main_t * vam)
6346 unformat_input_t *i = vam->input;
6347 vl_api_ip_add_del_route_t *mp;
6348 u32 sw_if_index = ~0, vrf_id = 0;
6350 u8 is_local = 0, is_drop = 0;
6351 u8 is_unreach = 0, is_prohibit = 0;
6352 u8 create_vrf_if_needed = 0;
6354 u32 next_hop_weight = 1;
6356 u8 is_multipath = 0;
6358 u8 address_length_set = 0;
6359 u32 next_hop_table_id = 0;
6360 u32 resolve_attempts = 0;
6361 u32 dst_address_length = 0;
6362 u8 next_hop_set = 0;
6363 ip4_address_t v4_dst_address, v4_next_hop_address;
6364 ip6_address_t v6_dst_address, v6_next_hop_address;
6368 u32 random_add_del = 0;
6369 u32 *random_vector = 0;
6371 u32 random_seed = 0xdeaddabe;
6372 u32 classify_table_index = ~0;
6374 u8 resolve_host = 0, resolve_attached = 0;
6375 mpls_label_t *next_hop_out_label_stack = NULL;
6376 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6377 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6379 /* Parse args required to build the message */
6380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6386 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6391 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6396 else if (unformat (i, "/%d", &dst_address_length))
6398 address_length_set = 1;
6401 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6402 &v4_next_hop_address))
6406 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6407 &v6_next_hop_address))
6411 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6413 else if (unformat (i, "weight %d", &next_hop_weight))
6415 else if (unformat (i, "drop"))
6419 else if (unformat (i, "null-send-unreach"))
6423 else if (unformat (i, "null-send-prohibit"))
6427 else if (unformat (i, "local"))
6431 else if (unformat (i, "classify %d", &classify_table_index))
6435 else if (unformat (i, "del"))
6437 else if (unformat (i, "add"))
6439 else if (unformat (i, "not-last"))
6441 else if (unformat (i, "resolve-via-host"))
6443 else if (unformat (i, "resolve-via-attached"))
6444 resolve_attached = 1;
6445 else if (unformat (i, "multipath"))
6447 else if (unformat (i, "vrf %d", &vrf_id))
6449 else if (unformat (i, "create-vrf"))
6450 create_vrf_if_needed = 1;
6451 else if (unformat (i, "count %d", &count))
6453 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6455 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6457 else if (unformat (i, "out-label %d", &next_hop_out_label))
6458 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6459 else if (unformat (i, "via-label %d", &next_hop_via_label))
6461 else if (unformat (i, "random"))
6463 else if (unformat (i, "seed %d", &random_seed))
6467 clib_warning ("parse error '%U'", format_unformat_error, i);
6472 if (!next_hop_set && !is_drop && !is_local &&
6473 !is_classify && !is_unreach && !is_prohibit &&
6474 MPLS_LABEL_INVALID == next_hop_via_label)
6477 ("next hop / local / drop / unreach / prohibit / classify not set");
6481 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6483 errmsg ("next hop and next-hop via label set");
6486 if (address_set == 0)
6488 errmsg ("missing addresses");
6492 if (address_length_set == 0)
6494 errmsg ("missing address length");
6498 /* Generate a pile of unique, random routes */
6501 u32 this_random_address;
6502 random_hash = hash_create (count, sizeof (uword));
6504 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6505 for (j = 0; j <= count; j++)
6509 this_random_address = random_u32 (&random_seed);
6510 this_random_address =
6511 clib_host_to_net_u32 (this_random_address);
6513 while (hash_get (random_hash, this_random_address));
6514 vec_add1 (random_vector, this_random_address);
6515 hash_set (random_hash, this_random_address, 1);
6517 hash_free (random_hash);
6518 v4_dst_address.as_u32 = random_vector[0];
6523 /* Turn on async mode */
6524 vam->async_mode = 1;
6525 vam->async_errors = 0;
6526 before = vat_time_now (vam);
6529 for (j = 0; j < count; j++)
6531 /* Construct the API message */
6532 M2 (IP_ADD_DEL_ROUTE, mp,
6533 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6535 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6536 mp->table_id = ntohl (vrf_id);
6537 mp->create_vrf_if_needed = create_vrf_if_needed;
6539 mp->is_add = is_add;
6540 mp->is_drop = is_drop;
6541 mp->is_unreach = is_unreach;
6542 mp->is_prohibit = is_prohibit;
6543 mp->is_ipv6 = is_ipv6;
6544 mp->is_local = is_local;
6545 mp->is_classify = is_classify;
6546 mp->is_multipath = is_multipath;
6547 mp->is_resolve_host = resolve_host;
6548 mp->is_resolve_attached = resolve_attached;
6549 mp->not_last = not_last;
6550 mp->next_hop_weight = next_hop_weight;
6551 mp->dst_address_length = dst_address_length;
6552 mp->next_hop_table_id = ntohl (next_hop_table_id);
6553 mp->classify_table_index = ntohl (classify_table_index);
6554 mp->next_hop_via_label = ntohl (next_hop_via_label);
6555 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6556 if (0 != mp->next_hop_n_out_labels)
6558 memcpy (mp->next_hop_out_label_stack,
6559 next_hop_out_label_stack,
6560 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6561 vec_free (next_hop_out_label_stack);
6566 clib_memcpy (mp->dst_address, &v6_dst_address,
6567 sizeof (v6_dst_address));
6569 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6570 sizeof (v6_next_hop_address));
6571 increment_v6_address (&v6_dst_address);
6575 clib_memcpy (mp->dst_address, &v4_dst_address,
6576 sizeof (v4_dst_address));
6578 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6579 sizeof (v4_next_hop_address));
6581 v4_dst_address.as_u32 = random_vector[j + 1];
6583 increment_v4_address (&v4_dst_address);
6587 /* If we receive SIGTERM, stop now... */
6592 /* When testing multiple add/del ops, use a control-ping to sync */
6595 vl_api_control_ping_t *mp_ping;
6599 /* Shut off async mode */
6600 vam->async_mode = 0;
6602 M (CONTROL_PING, mp_ping);
6605 timeout = vat_time_now (vam) + 1.0;
6606 while (vat_time_now (vam) < timeout)
6607 if (vam->result_ready == 1)
6612 if (vam->retval == -99)
6615 if (vam->async_errors > 0)
6617 errmsg ("%d asynchronous errors", vam->async_errors);
6620 vam->async_errors = 0;
6621 after = vat_time_now (vam);
6623 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6627 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6628 count, after - before, count / (after - before));
6634 /* Wait for a reply... */
6639 /* Return the good/bad news */
6640 return (vam->retval);
6644 api_ip_mroute_add_del (vat_main_t * vam)
6646 unformat_input_t *i = vam->input;
6647 vl_api_ip_mroute_add_del_t *mp;
6648 u32 sw_if_index = ~0, vrf_id = 0;
6651 u8 create_vrf_if_needed = 0;
6654 u32 grp_address_length = 0;
6655 ip4_address_t v4_grp_address, v4_src_address;
6656 ip6_address_t v6_grp_address, v6_src_address;
6657 mfib_itf_flags_t iflags = 0;
6658 mfib_entry_flags_t eflags = 0;
6661 /* Parse args required to build the message */
6662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6664 if (unformat (i, "sw_if_index %d", &sw_if_index))
6666 else if (unformat (i, "%U %U",
6667 unformat_ip4_address, &v4_src_address,
6668 unformat_ip4_address, &v4_grp_address))
6670 grp_address_length = 64;
6674 else if (unformat (i, "%U %U",
6675 unformat_ip6_address, &v6_src_address,
6676 unformat_ip6_address, &v6_grp_address))
6678 grp_address_length = 256;
6682 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6684 memset (&v4_src_address, 0, sizeof (v4_src_address));
6685 grp_address_length = 32;
6689 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6691 memset (&v6_src_address, 0, sizeof (v6_src_address));
6692 grp_address_length = 128;
6696 else if (unformat (i, "/%d", &grp_address_length))
6698 else if (unformat (i, "local"))
6702 else if (unformat (i, "del"))
6704 else if (unformat (i, "add"))
6706 else if (unformat (i, "vrf %d", &vrf_id))
6708 else if (unformat (i, "create-vrf"))
6709 create_vrf_if_needed = 1;
6710 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6712 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6716 clib_warning ("parse error '%U'", format_unformat_error, i);
6721 if (address_set == 0)
6723 errmsg ("missing addresses\n");
6727 /* Construct the API message */
6728 M (IP_MROUTE_ADD_DEL, mp);
6730 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6731 mp->table_id = ntohl (vrf_id);
6732 mp->create_vrf_if_needed = create_vrf_if_needed;
6734 mp->is_add = is_add;
6735 mp->is_ipv6 = is_ipv6;
6736 mp->is_local = is_local;
6737 mp->itf_flags = ntohl (iflags);
6738 mp->entry_flags = ntohl (eflags);
6739 mp->grp_address_length = grp_address_length;
6740 mp->grp_address_length = ntohs (mp->grp_address_length);
6744 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6745 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6749 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6750 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6756 /* Wait for a reply... */
6762 api_mpls_route_add_del (vat_main_t * vam)
6764 unformat_input_t *i = vam->input;
6765 vl_api_mpls_route_add_del_t *mp;
6766 u32 sw_if_index = ~0, table_id = 0;
6767 u8 create_table_if_needed = 0;
6769 u32 next_hop_weight = 1;
6770 u8 is_multipath = 0;
6771 u32 next_hop_table_id = 0;
6772 u8 next_hop_set = 0;
6773 ip4_address_t v4_next_hop_address = {
6776 ip6_address_t v6_next_hop_address = { {0} };
6780 u32 classify_table_index = ~0;
6782 u8 resolve_host = 0, resolve_attached = 0;
6783 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6784 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6785 mpls_label_t *next_hop_out_label_stack = NULL;
6786 mpls_label_t local_label = MPLS_LABEL_INVALID;
6788 u8 next_hop_proto_is_ip4 = 1;
6790 /* Parse args required to build the message */
6791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6793 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6795 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6797 else if (unformat (i, "%d", &local_label))
6799 else if (unformat (i, "eos"))
6801 else if (unformat (i, "non-eos"))
6803 else if (unformat (i, "via %U", unformat_ip4_address,
6804 &v4_next_hop_address))
6807 next_hop_proto_is_ip4 = 1;
6809 else if (unformat (i, "via %U", unformat_ip6_address,
6810 &v6_next_hop_address))
6813 next_hop_proto_is_ip4 = 0;
6815 else if (unformat (i, "weight %d", &next_hop_weight))
6817 else if (unformat (i, "create-table"))
6818 create_table_if_needed = 1;
6819 else if (unformat (i, "classify %d", &classify_table_index))
6823 else if (unformat (i, "del"))
6825 else if (unformat (i, "add"))
6827 else if (unformat (i, "resolve-via-host"))
6829 else if (unformat (i, "resolve-via-attached"))
6830 resolve_attached = 1;
6831 else if (unformat (i, "multipath"))
6833 else if (unformat (i, "count %d", &count))
6835 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6838 next_hop_proto_is_ip4 = 1;
6840 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6843 next_hop_proto_is_ip4 = 0;
6845 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6847 else if (unformat (i, "via-label %d", &next_hop_via_label))
6849 else if (unformat (i, "out-label %d", &next_hop_out_label))
6850 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6853 clib_warning ("parse error '%U'", format_unformat_error, i);
6858 if (!next_hop_set && !is_classify)
6860 errmsg ("next hop / classify not set");
6864 if (MPLS_LABEL_INVALID == local_label)
6866 errmsg ("missing label");
6872 /* Turn on async mode */
6873 vam->async_mode = 1;
6874 vam->async_errors = 0;
6875 before = vat_time_now (vam);
6878 for (j = 0; j < count; j++)
6880 /* Construct the API message */
6881 M2 (MPLS_ROUTE_ADD_DEL, mp,
6882 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6884 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6885 mp->mr_table_id = ntohl (table_id);
6886 mp->mr_create_table_if_needed = create_table_if_needed;
6888 mp->mr_is_add = is_add;
6889 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6890 mp->mr_is_classify = is_classify;
6891 mp->mr_is_multipath = is_multipath;
6892 mp->mr_is_resolve_host = resolve_host;
6893 mp->mr_is_resolve_attached = resolve_attached;
6894 mp->mr_next_hop_weight = next_hop_weight;
6895 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6896 mp->mr_classify_table_index = ntohl (classify_table_index);
6897 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6898 mp->mr_label = ntohl (local_label);
6899 mp->mr_eos = is_eos;
6901 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6902 if (0 != mp->mr_next_hop_n_out_labels)
6904 memcpy (mp->mr_next_hop_out_label_stack,
6905 next_hop_out_label_stack,
6906 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6907 vec_free (next_hop_out_label_stack);
6912 if (next_hop_proto_is_ip4)
6914 clib_memcpy (mp->mr_next_hop,
6915 &v4_next_hop_address,
6916 sizeof (v4_next_hop_address));
6920 clib_memcpy (mp->mr_next_hop,
6921 &v6_next_hop_address,
6922 sizeof (v6_next_hop_address));
6929 /* If we receive SIGTERM, stop now... */
6934 /* When testing multiple add/del ops, use a control-ping to sync */
6937 vl_api_control_ping_t *mp_ping;
6941 /* Shut off async mode */
6942 vam->async_mode = 0;
6944 M (CONTROL_PING, mp_ping);
6947 timeout = vat_time_now (vam) + 1.0;
6948 while (vat_time_now (vam) < timeout)
6949 if (vam->result_ready == 1)
6954 if (vam->retval == -99)
6957 if (vam->async_errors > 0)
6959 errmsg ("%d asynchronous errors", vam->async_errors);
6962 vam->async_errors = 0;
6963 after = vat_time_now (vam);
6965 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6969 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6970 count, after - before, count / (after - before));
6976 /* Wait for a reply... */
6981 /* Return the good/bad news */
6982 return (vam->retval);
6986 api_mpls_ip_bind_unbind (vat_main_t * vam)
6988 unformat_input_t *i = vam->input;
6989 vl_api_mpls_ip_bind_unbind_t *mp;
6990 u32 ip_table_id = 0;
6991 u8 create_table_if_needed = 0;
6994 ip4_address_t v4_address;
6995 ip6_address_t v6_address;
6998 mpls_label_t local_label = MPLS_LABEL_INVALID;
7001 /* Parse args required to build the message */
7002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7004 if (unformat (i, "%U/%d", unformat_ip4_address,
7005 &v4_address, &address_length))
7010 else if (unformat (i, "%U/%d", unformat_ip6_address,
7011 &v6_address, &address_length))
7016 else if (unformat (i, "%d", &local_label))
7018 else if (unformat (i, "create-table"))
7019 create_table_if_needed = 1;
7020 else if (unformat (i, "table-id %d", &ip_table_id))
7022 else if (unformat (i, "unbind"))
7024 else if (unformat (i, "bind"))
7028 clib_warning ("parse error '%U'", format_unformat_error, i);
7035 errmsg ("IP addres not set");
7039 if (MPLS_LABEL_INVALID == local_label)
7041 errmsg ("missing label");
7045 /* Construct the API message */
7046 M (MPLS_IP_BIND_UNBIND, mp);
7048 mp->mb_create_table_if_needed = create_table_if_needed;
7049 mp->mb_is_bind = is_bind;
7050 mp->mb_is_ip4 = is_ip4;
7051 mp->mb_ip_table_id = ntohl (ip_table_id);
7052 mp->mb_mpls_table_id = 0;
7053 mp->mb_label = ntohl (local_label);
7054 mp->mb_address_length = address_length;
7057 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7059 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7064 /* Wait for a reply... */
7070 api_proxy_arp_add_del (vat_main_t * vam)
7072 unformat_input_t *i = vam->input;
7073 vl_api_proxy_arp_add_del_t *mp;
7076 ip4_address_t lo, hi;
7080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7082 if (unformat (i, "vrf %d", &vrf_id))
7084 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7085 unformat_ip4_address, &hi))
7087 else if (unformat (i, "del"))
7091 clib_warning ("parse error '%U'", format_unformat_error, i);
7098 errmsg ("address range not set");
7102 M (PROXY_ARP_ADD_DEL, mp);
7104 mp->vrf_id = ntohl (vrf_id);
7105 mp->is_add = is_add;
7106 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7107 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7115 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7117 unformat_input_t *i = vam->input;
7118 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7121 u8 sw_if_index_set = 0;
7124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7126 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7127 sw_if_index_set = 1;
7128 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7129 sw_if_index_set = 1;
7130 else if (unformat (i, "enable"))
7132 else if (unformat (i, "disable"))
7136 clib_warning ("parse error '%U'", format_unformat_error, i);
7141 if (sw_if_index_set == 0)
7143 errmsg ("missing interface name or sw_if_index");
7147 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7149 mp->sw_if_index = ntohl (sw_if_index);
7150 mp->enable_disable = enable;
7158 api_mpls_tunnel_add_del (vat_main_t * vam)
7160 unformat_input_t *i = vam->input;
7161 vl_api_mpls_tunnel_add_del_t *mp;
7165 u32 sw_if_index = ~0;
7166 u32 next_hop_sw_if_index = ~0;
7167 u32 next_hop_proto_is_ip4 = 1;
7169 u32 next_hop_table_id = 0;
7170 ip4_address_t v4_next_hop_address = {
7173 ip6_address_t v6_next_hop_address = { {0} };
7174 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7179 if (unformat (i, "add"))
7181 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7183 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7185 else if (unformat (i, "via %U",
7186 unformat_ip4_address, &v4_next_hop_address))
7188 next_hop_proto_is_ip4 = 1;
7190 else if (unformat (i, "via %U",
7191 unformat_ip6_address, &v6_next_hop_address))
7193 next_hop_proto_is_ip4 = 0;
7195 else if (unformat (i, "l2-only"))
7197 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7199 else if (unformat (i, "out-label %d", &next_hop_out_label))
7200 vec_add1 (labels, ntohl (next_hop_out_label));
7203 clib_warning ("parse error '%U'", format_unformat_error, i);
7208 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7210 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7211 mp->mt_sw_if_index = ntohl (sw_if_index);
7212 mp->mt_is_add = is_add;
7213 mp->mt_l2_only = l2_only;
7214 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7215 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7217 mp->mt_next_hop_n_out_labels = vec_len (labels);
7219 if (0 != mp->mt_next_hop_n_out_labels)
7221 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7222 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7226 if (next_hop_proto_is_ip4)
7228 clib_memcpy (mp->mt_next_hop,
7229 &v4_next_hop_address, sizeof (v4_next_hop_address));
7233 clib_memcpy (mp->mt_next_hop,
7234 &v6_next_hop_address, sizeof (v6_next_hop_address));
7243 api_sw_interface_set_unnumbered (vat_main_t * vam)
7245 unformat_input_t *i = vam->input;
7246 vl_api_sw_interface_set_unnumbered_t *mp;
7248 u32 unnum_sw_index = ~0;
7250 u8 sw_if_index_set = 0;
7253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7255 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7256 sw_if_index_set = 1;
7257 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7258 sw_if_index_set = 1;
7259 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7261 else if (unformat (i, "del"))
7265 clib_warning ("parse error '%U'", format_unformat_error, i);
7270 if (sw_if_index_set == 0)
7272 errmsg ("missing interface name or sw_if_index");
7276 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7278 mp->sw_if_index = ntohl (sw_if_index);
7279 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7280 mp->is_add = is_add;
7288 api_ip_neighbor_add_del (vat_main_t * vam)
7290 unformat_input_t *i = vam->input;
7291 vl_api_ip_neighbor_add_del_t *mp;
7293 u8 sw_if_index_set = 0;
7299 u8 v4_address_set = 0;
7300 u8 v6_address_set = 0;
7301 ip4_address_t v4address;
7302 ip6_address_t v6address;
7305 memset (mac_address, 0, sizeof (mac_address));
7307 /* Parse args required to build the message */
7308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7310 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7314 else if (unformat (i, "del"))
7317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7318 sw_if_index_set = 1;
7319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7320 sw_if_index_set = 1;
7321 else if (unformat (i, "is_static"))
7323 else if (unformat (i, "vrf %d", &vrf_id))
7325 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7327 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7331 clib_warning ("parse error '%U'", format_unformat_error, i);
7336 if (sw_if_index_set == 0)
7338 errmsg ("missing interface name or sw_if_index");
7341 if (v4_address_set && v6_address_set)
7343 errmsg ("both v4 and v6 addresses set");
7346 if (!v4_address_set && !v6_address_set)
7348 errmsg ("no address set");
7352 /* Construct the API message */
7353 M (IP_NEIGHBOR_ADD_DEL, mp);
7355 mp->sw_if_index = ntohl (sw_if_index);
7356 mp->is_add = is_add;
7357 mp->vrf_id = ntohl (vrf_id);
7358 mp->is_static = is_static;
7360 clib_memcpy (mp->mac_address, mac_address, 6);
7364 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7368 /* mp->is_ipv6 = 0; via memset in M macro above */
7369 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7375 /* Wait for a reply, return good/bad news */
7381 api_reset_vrf (vat_main_t * vam)
7383 unformat_input_t *i = vam->input;
7384 vl_api_reset_vrf_t *mp;
7390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7392 if (unformat (i, "vrf %d", &vrf_id))
7394 else if (unformat (i, "ipv6"))
7398 clib_warning ("parse error '%U'", format_unformat_error, i);
7403 if (vrf_id_set == 0)
7405 errmsg ("missing vrf id");
7411 mp->vrf_id = ntohl (vrf_id);
7412 mp->is_ipv6 = is_ipv6;
7420 api_create_vlan_subif (vat_main_t * vam)
7422 unformat_input_t *i = vam->input;
7423 vl_api_create_vlan_subif_t *mp;
7425 u8 sw_if_index_set = 0;
7430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7432 if (unformat (i, "sw_if_index %d", &sw_if_index))
7433 sw_if_index_set = 1;
7435 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7436 sw_if_index_set = 1;
7437 else if (unformat (i, "vlan %d", &vlan_id))
7441 clib_warning ("parse error '%U'", format_unformat_error, i);
7446 if (sw_if_index_set == 0)
7448 errmsg ("missing interface name or sw_if_index");
7452 if (vlan_id_set == 0)
7454 errmsg ("missing vlan_id");
7457 M (CREATE_VLAN_SUBIF, mp);
7459 mp->sw_if_index = ntohl (sw_if_index);
7460 mp->vlan_id = ntohl (vlan_id);
7467 #define foreach_create_subif_bit \
7474 _(outer_vlan_id_any) \
7475 _(inner_vlan_id_any)
7478 api_create_subif (vat_main_t * vam)
7480 unformat_input_t *i = vam->input;
7481 vl_api_create_subif_t *mp;
7483 u8 sw_if_index_set = 0;
7490 u32 exact_match = 0;
7491 u32 default_sub = 0;
7492 u32 outer_vlan_id_any = 0;
7493 u32 inner_vlan_id_any = 0;
7495 u16 outer_vlan_id = 0;
7496 u16 inner_vlan_id = 0;
7499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7501 if (unformat (i, "sw_if_index %d", &sw_if_index))
7502 sw_if_index_set = 1;
7504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7505 sw_if_index_set = 1;
7506 else if (unformat (i, "sub_id %d", &sub_id))
7508 else if (unformat (i, "outer_vlan_id %d", &tmp))
7509 outer_vlan_id = tmp;
7510 else if (unformat (i, "inner_vlan_id %d", &tmp))
7511 inner_vlan_id = tmp;
7513 #define _(a) else if (unformat (i, #a)) a = 1 ;
7514 foreach_create_subif_bit
7518 clib_warning ("parse error '%U'", format_unformat_error, i);
7523 if (sw_if_index_set == 0)
7525 errmsg ("missing interface name or sw_if_index");
7529 if (sub_id_set == 0)
7531 errmsg ("missing sub_id");
7534 M (CREATE_SUBIF, mp);
7536 mp->sw_if_index = ntohl (sw_if_index);
7537 mp->sub_id = ntohl (sub_id);
7539 #define _(a) mp->a = a;
7540 foreach_create_subif_bit;
7543 mp->outer_vlan_id = ntohs (outer_vlan_id);
7544 mp->inner_vlan_id = ntohs (inner_vlan_id);
7552 api_oam_add_del (vat_main_t * vam)
7554 unformat_input_t *i = vam->input;
7555 vl_api_oam_add_del_t *mp;
7558 ip4_address_t src, dst;
7563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7565 if (unformat (i, "vrf %d", &vrf_id))
7567 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7569 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7571 else if (unformat (i, "del"))
7575 clib_warning ("parse error '%U'", format_unformat_error, i);
7582 errmsg ("missing src addr");
7588 errmsg ("missing dst addr");
7592 M (OAM_ADD_DEL, mp);
7594 mp->vrf_id = ntohl (vrf_id);
7595 mp->is_add = is_add;
7596 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7597 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7605 api_reset_fib (vat_main_t * vam)
7607 unformat_input_t *i = vam->input;
7608 vl_api_reset_fib_t *mp;
7614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7616 if (unformat (i, "vrf %d", &vrf_id))
7618 else if (unformat (i, "ipv6"))
7622 clib_warning ("parse error '%U'", format_unformat_error, i);
7627 if (vrf_id_set == 0)
7629 errmsg ("missing vrf id");
7635 mp->vrf_id = ntohl (vrf_id);
7636 mp->is_ipv6 = is_ipv6;
7644 api_dhcp_proxy_config (vat_main_t * vam)
7646 unformat_input_t *i = vam->input;
7647 vl_api_dhcp_proxy_config_t *mp;
7649 u32 server_vrf_id = 0;
7651 u8 v4_address_set = 0;
7652 u8 v6_address_set = 0;
7653 ip4_address_t v4address;
7654 ip6_address_t v6address;
7655 u8 v4_src_address_set = 0;
7656 u8 v6_src_address_set = 0;
7657 ip4_address_t v4srcaddress;
7658 ip6_address_t v6srcaddress;
7661 /* Parse args required to build the message */
7662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7664 if (unformat (i, "del"))
7666 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7668 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7670 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7672 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7674 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7675 v4_src_address_set = 1;
7676 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7677 v6_src_address_set = 1;
7682 if (v4_address_set && v6_address_set)
7684 errmsg ("both v4 and v6 server addresses set");
7687 if (!v4_address_set && !v6_address_set)
7689 errmsg ("no server addresses set");
7693 if (v4_src_address_set && v6_src_address_set)
7695 errmsg ("both v4 and v6 src addresses set");
7698 if (!v4_src_address_set && !v6_src_address_set)
7700 errmsg ("no src addresses set");
7704 if (!(v4_src_address_set && v4_address_set) &&
7705 !(v6_src_address_set && v6_address_set))
7707 errmsg ("no matching server and src addresses set");
7711 /* Construct the API message */
7712 M (DHCP_PROXY_CONFIG, mp);
7714 mp->is_add = is_add;
7715 mp->rx_vrf_id = ntohl (rx_vrf_id);
7716 mp->server_vrf_id = ntohl (server_vrf_id);
7720 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7721 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7725 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7726 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7732 /* Wait for a reply, return good/bad news */
7737 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7738 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7741 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7743 vat_main_t *vam = &vat_main;
7747 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7748 ntohl (mp->rx_vrf_id),
7749 ntohl (mp->server_vrf_id),
7750 format_ip6_address, mp->dhcp_server,
7751 format_ip6_address, mp->dhcp_src_address,
7752 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7755 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7756 ntohl (mp->rx_vrf_id),
7757 ntohl (mp->server_vrf_id),
7758 format_ip4_address, mp->dhcp_server,
7759 format_ip4_address, mp->dhcp_src_address,
7760 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7763 static void vl_api_dhcp_proxy_details_t_handler_json
7764 (vl_api_dhcp_proxy_details_t * mp)
7766 vat_main_t *vam = &vat_main;
7767 vat_json_node_t *node = NULL;
7769 struct in6_addr ip6;
7771 if (VAT_JSON_ARRAY != vam->json_tree.type)
7773 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7774 vat_json_init_array (&vam->json_tree);
7776 node = vat_json_array_add (&vam->json_tree);
7778 vat_json_init_object (node);
7779 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7780 vat_json_object_add_uint (node, "server-table-id",
7781 ntohl (mp->server_vrf_id));
7784 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7785 vat_json_object_add_ip6 (node, "server_address", ip6);
7786 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7787 vat_json_object_add_ip6 (node, "src_address", ip6);
7791 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7792 vat_json_object_add_ip4 (node, "server_address", ip4);
7793 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7794 vat_json_object_add_ip4 (node, "src_address", ip4);
7796 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7797 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7801 api_dhcp_proxy_dump (vat_main_t * vam)
7803 unformat_input_t *i = vam->input;
7804 vl_api_control_ping_t *mp_ping;
7805 vl_api_dhcp_proxy_dump_t *mp;
7809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7811 if (unformat (i, "ipv6"))
7815 clib_warning ("parse error '%U'", format_unformat_error, i);
7820 M (DHCP_PROXY_DUMP, mp);
7822 mp->is_ip6 = is_ipv6;
7825 /* Use a control ping for synchronization */
7826 M (CONTROL_PING, mp_ping);
7834 api_dhcp_proxy_set_vss (vat_main_t * vam)
7836 unformat_input_t *i = vam->input;
7837 vl_api_dhcp_proxy_set_vss_t *mp;
7848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7850 if (unformat (i, "tbl_id %d", &tbl_id))
7852 if (unformat (i, "fib_id %d", &fib_id))
7854 if (unformat (i, "oui %d", &oui))
7856 else if (unformat (i, "ipv6"))
7858 else if (unformat (i, "del"))
7862 clib_warning ("parse error '%U'", format_unformat_error, i);
7867 if (tbl_id_set == 0)
7869 errmsg ("missing tbl id");
7873 if (fib_id_set == 0)
7875 errmsg ("missing fib id");
7880 errmsg ("missing oui");
7884 M (DHCP_PROXY_SET_VSS, mp);
7885 mp->tbl_id = ntohl (tbl_id);
7886 mp->fib_id = ntohl (fib_id);
7887 mp->oui = ntohl (oui);
7888 mp->is_ipv6 = is_ipv6;
7889 mp->is_add = is_add;
7897 api_dhcp_client_config (vat_main_t * vam)
7899 unformat_input_t *i = vam->input;
7900 vl_api_dhcp_client_config_t *mp;
7902 u8 sw_if_index_set = 0;
7905 u8 disable_event = 0;
7908 /* Parse args required to build the message */
7909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7911 if (unformat (i, "del"))
7914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7915 sw_if_index_set = 1;
7916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7917 sw_if_index_set = 1;
7918 else if (unformat (i, "hostname %s", &hostname))
7920 else if (unformat (i, "disable_event"))
7926 if (sw_if_index_set == 0)
7928 errmsg ("missing interface name or sw_if_index");
7932 if (vec_len (hostname) > 63)
7934 errmsg ("hostname too long");
7936 vec_add1 (hostname, 0);
7938 /* Construct the API message */
7939 M (DHCP_CLIENT_CONFIG, mp);
7941 mp->sw_if_index = ntohl (sw_if_index);
7942 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7943 vec_free (hostname);
7944 mp->is_add = is_add;
7945 mp->want_dhcp_event = disable_event ? 0 : 1;
7946 mp->pid = getpid ();
7951 /* Wait for a reply, return good/bad news */
7957 api_set_ip_flow_hash (vat_main_t * vam)
7959 unformat_input_t *i = vam->input;
7960 vl_api_set_ip_flow_hash_t *mp;
7972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7974 if (unformat (i, "vrf %d", &vrf_id))
7976 else if (unformat (i, "ipv6"))
7978 else if (unformat (i, "src"))
7980 else if (unformat (i, "dst"))
7982 else if (unformat (i, "sport"))
7984 else if (unformat (i, "dport"))
7986 else if (unformat (i, "proto"))
7988 else if (unformat (i, "reverse"))
7993 clib_warning ("parse error '%U'", format_unformat_error, i);
7998 if (vrf_id_set == 0)
8000 errmsg ("missing vrf id");
8004 M (SET_IP_FLOW_HASH, mp);
8010 mp->reverse = reverse;
8011 mp->vrf_id = ntohl (vrf_id);
8012 mp->is_ipv6 = is_ipv6;
8020 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8022 unformat_input_t *i = vam->input;
8023 vl_api_sw_interface_ip6_enable_disable_t *mp;
8025 u8 sw_if_index_set = 0;
8029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8032 sw_if_index_set = 1;
8033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8034 sw_if_index_set = 1;
8035 else if (unformat (i, "enable"))
8037 else if (unformat (i, "disable"))
8041 clib_warning ("parse error '%U'", format_unformat_error, i);
8046 if (sw_if_index_set == 0)
8048 errmsg ("missing interface name or sw_if_index");
8052 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8054 mp->sw_if_index = ntohl (sw_if_index);
8055 mp->enable = enable;
8063 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8065 unformat_input_t *i = vam->input;
8066 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8068 u8 sw_if_index_set = 0;
8069 u8 v6_address_set = 0;
8070 ip6_address_t v6address;
8073 /* Parse args required to build the message */
8074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8077 sw_if_index_set = 1;
8078 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8079 sw_if_index_set = 1;
8080 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8086 if (sw_if_index_set == 0)
8088 errmsg ("missing interface name or sw_if_index");
8091 if (!v6_address_set)
8093 errmsg ("no address set");
8097 /* Construct the API message */
8098 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8100 mp->sw_if_index = ntohl (sw_if_index);
8101 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8106 /* Wait for a reply, return good/bad news */
8113 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8115 unformat_input_t *i = vam->input;
8116 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8118 u8 sw_if_index_set = 0;
8119 u32 address_length = 0;
8120 u8 v6_address_set = 0;
8121 ip6_address_t v6address;
8123 u8 no_advertise = 0;
8125 u8 no_autoconfig = 0;
8128 u32 val_lifetime = 0;
8129 u32 pref_lifetime = 0;
8132 /* Parse args required to build the message */
8133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8136 sw_if_index_set = 1;
8137 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8138 sw_if_index_set = 1;
8139 else if (unformat (i, "%U/%d",
8140 unformat_ip6_address, &v6address, &address_length))
8142 else if (unformat (i, "val_life %d", &val_lifetime))
8144 else if (unformat (i, "pref_life %d", &pref_lifetime))
8146 else if (unformat (i, "def"))
8148 else if (unformat (i, "noadv"))
8150 else if (unformat (i, "offl"))
8152 else if (unformat (i, "noauto"))
8154 else if (unformat (i, "nolink"))
8156 else if (unformat (i, "isno"))
8160 clib_warning ("parse error '%U'", format_unformat_error, i);
8165 if (sw_if_index_set == 0)
8167 errmsg ("missing interface name or sw_if_index");
8170 if (!v6_address_set)
8172 errmsg ("no address set");
8176 /* Construct the API message */
8177 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8179 mp->sw_if_index = ntohl (sw_if_index);
8180 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8181 mp->address_length = address_length;
8182 mp->use_default = use_default;
8183 mp->no_advertise = no_advertise;
8184 mp->off_link = off_link;
8185 mp->no_autoconfig = no_autoconfig;
8186 mp->no_onlink = no_onlink;
8188 mp->val_lifetime = ntohl (val_lifetime);
8189 mp->pref_lifetime = ntohl (pref_lifetime);
8194 /* Wait for a reply, return good/bad news */
8200 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8202 unformat_input_t *i = vam->input;
8203 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8205 u8 sw_if_index_set = 0;
8210 u8 send_unicast = 0;
8213 u8 default_router = 0;
8214 u32 max_interval = 0;
8215 u32 min_interval = 0;
8217 u32 initial_count = 0;
8218 u32 initial_interval = 0;
8222 /* Parse args required to build the message */
8223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8225 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8226 sw_if_index_set = 1;
8227 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8228 sw_if_index_set = 1;
8229 else if (unformat (i, "maxint %d", &max_interval))
8231 else if (unformat (i, "minint %d", &min_interval))
8233 else if (unformat (i, "life %d", &lifetime))
8235 else if (unformat (i, "count %d", &initial_count))
8237 else if (unformat (i, "interval %d", &initial_interval))
8239 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8241 else if (unformat (i, "managed"))
8243 else if (unformat (i, "other"))
8245 else if (unformat (i, "ll"))
8247 else if (unformat (i, "send"))
8249 else if (unformat (i, "cease"))
8251 else if (unformat (i, "isno"))
8253 else if (unformat (i, "def"))
8257 clib_warning ("parse error '%U'", format_unformat_error, i);
8262 if (sw_if_index_set == 0)
8264 errmsg ("missing interface name or sw_if_index");
8268 /* Construct the API message */
8269 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8271 mp->sw_if_index = ntohl (sw_if_index);
8272 mp->max_interval = ntohl (max_interval);
8273 mp->min_interval = ntohl (min_interval);
8274 mp->lifetime = ntohl (lifetime);
8275 mp->initial_count = ntohl (initial_count);
8276 mp->initial_interval = ntohl (initial_interval);
8277 mp->suppress = suppress;
8278 mp->managed = managed;
8280 mp->ll_option = ll_option;
8281 mp->send_unicast = send_unicast;
8284 mp->default_router = default_router;
8289 /* Wait for a reply, return good/bad news */
8295 api_set_arp_neighbor_limit (vat_main_t * vam)
8297 unformat_input_t *i = vam->input;
8298 vl_api_set_arp_neighbor_limit_t *mp;
8304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8306 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8308 else if (unformat (i, "ipv6"))
8312 clib_warning ("parse error '%U'", format_unformat_error, i);
8319 errmsg ("missing limit value");
8323 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8325 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8326 mp->is_ipv6 = is_ipv6;
8334 api_l2_patch_add_del (vat_main_t * vam)
8336 unformat_input_t *i = vam->input;
8337 vl_api_l2_patch_add_del_t *mp;
8339 u8 rx_sw_if_index_set = 0;
8341 u8 tx_sw_if_index_set = 0;
8345 /* Parse args required to build the message */
8346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8348 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8349 rx_sw_if_index_set = 1;
8350 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8351 tx_sw_if_index_set = 1;
8352 else if (unformat (i, "rx"))
8354 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8356 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8358 rx_sw_if_index_set = 1;
8363 else if (unformat (i, "tx"))
8365 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8367 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8369 tx_sw_if_index_set = 1;
8374 else if (unformat (i, "del"))
8380 if (rx_sw_if_index_set == 0)
8382 errmsg ("missing rx interface name or rx_sw_if_index");
8386 if (tx_sw_if_index_set == 0)
8388 errmsg ("missing tx interface name or tx_sw_if_index");
8392 M (L2_PATCH_ADD_DEL, mp);
8394 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8395 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8396 mp->is_add = is_add;
8404 api_ioam_enable (vat_main_t * vam)
8406 unformat_input_t *input = vam->input;
8407 vl_api_ioam_enable_t *mp;
8409 int has_trace_option = 0;
8410 int has_pot_option = 0;
8411 int has_seqno_option = 0;
8412 int has_analyse_option = 0;
8415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8417 if (unformat (input, "trace"))
8418 has_trace_option = 1;
8419 else if (unformat (input, "pot"))
8421 else if (unformat (input, "seqno"))
8422 has_seqno_option = 1;
8423 else if (unformat (input, "analyse"))
8424 has_analyse_option = 1;
8428 M (IOAM_ENABLE, mp);
8429 mp->id = htons (id);
8430 mp->seqno = has_seqno_option;
8431 mp->analyse = has_analyse_option;
8432 mp->pot_enable = has_pot_option;
8433 mp->trace_enable = has_trace_option;
8442 api_ioam_disable (vat_main_t * vam)
8444 vl_api_ioam_disable_t *mp;
8447 M (IOAM_DISABLE, mp);
8454 api_sr_tunnel_add_del (vat_main_t * vam)
8456 unformat_input_t *i = vam->input;
8457 vl_api_sr_tunnel_add_del_t *mp;
8460 ip6_address_t src_address;
8461 int src_address_set = 0;
8462 ip6_address_t dst_address;
8464 int dst_address_set = 0;
8466 u32 rx_table_id = 0;
8467 u32 tx_table_id = 0;
8468 ip6_address_t *segments = 0;
8469 ip6_address_t *this_seg;
8470 ip6_address_t *tags = 0;
8471 ip6_address_t *this_tag;
8472 ip6_address_t next_address, tag;
8474 u8 *policy_name = 0;
8477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8479 if (unformat (i, "del"))
8481 else if (unformat (i, "name %s", &name))
8483 else if (unformat (i, "policy %s", &policy_name))
8485 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8487 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8489 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8490 src_address_set = 1;
8491 else if (unformat (i, "dst %U/%d",
8492 unformat_ip6_address, &dst_address, &dst_mask_width))
8493 dst_address_set = 1;
8494 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8496 vec_add2 (segments, this_seg, 1);
8497 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8498 sizeof (*this_seg));
8500 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8502 vec_add2 (tags, this_tag, 1);
8503 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8505 else if (unformat (i, "clean"))
8506 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8507 else if (unformat (i, "protected"))
8508 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8509 else if (unformat (i, "InPE %d", &pl_index))
8511 if (pl_index <= 0 || pl_index > 4)
8513 pl_index_range_error:
8514 errmsg ("pl index %d out of range", pl_index);
8518 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8520 else if (unformat (i, "EgPE %d", &pl_index))
8522 if (pl_index <= 0 || pl_index > 4)
8523 goto pl_index_range_error;
8525 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8527 else if (unformat (i, "OrgSrc %d", &pl_index))
8529 if (pl_index <= 0 || pl_index > 4)
8530 goto pl_index_range_error;
8532 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8538 if (!src_address_set)
8540 errmsg ("src address required");
8544 if (!dst_address_set)
8546 errmsg ("dst address required");
8552 errmsg ("at least one sr segment required");
8556 M2 (SR_TUNNEL_ADD_DEL, mp,
8557 vec_len (segments) * sizeof (ip6_address_t)
8558 + vec_len (tags) * sizeof (ip6_address_t));
8560 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8561 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8562 mp->dst_mask_width = dst_mask_width;
8563 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8564 mp->n_segments = vec_len (segments);
8565 mp->n_tags = vec_len (tags);
8566 mp->is_add = is_del == 0;
8567 clib_memcpy (mp->segs_and_tags, segments,
8568 vec_len (segments) * sizeof (ip6_address_t));
8569 clib_memcpy (mp->segs_and_tags +
8570 vec_len (segments) * sizeof (ip6_address_t), tags,
8571 vec_len (tags) * sizeof (ip6_address_t));
8573 mp->outer_vrf_id = ntohl (rx_table_id);
8574 mp->inner_vrf_id = ntohl (tx_table_id);
8575 memcpy (mp->name, name, vec_len (name));
8576 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8578 vec_free (segments);
8587 api_sr_policy_add_del (vat_main_t * vam)
8589 unformat_input_t *input = vam->input;
8590 vl_api_sr_policy_add_del_t *mp;
8593 u8 *tunnel_name = 0;
8594 u8 **tunnel_names = 0;
8599 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8600 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8605 if (unformat (input, "del"))
8607 else if (unformat (input, "name %s", &name))
8609 else if (unformat (input, "tunnel %s", &tunnel_name))
8613 vec_add1 (tunnel_names, tunnel_name);
8615 - length = #bytes to store in serial vector
8616 - +1 = byte to store that length
8618 tunnel_names_length += (vec_len (tunnel_name) + 1);
8629 errmsg ("policy name required");
8633 if ((!tunnel_set) && (!is_del))
8635 errmsg ("tunnel name required");
8639 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8643 mp->is_add = !is_del;
8645 memcpy (mp->name, name, vec_len (name));
8646 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8647 u8 *serial_orig = 0;
8648 vec_validate (serial_orig, tunnel_names_length);
8649 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8650 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8652 for (j = 0; j < vec_len (tunnel_names); j++)
8654 tun_name_len = vec_len (tunnel_names[j]);
8655 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8656 serial_orig += 1; // Move along one byte to store the actual tunnel name
8657 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8658 serial_orig += tun_name_len; // Advance past the copy
8660 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8662 vec_free (tunnel_names);
8663 vec_free (tunnel_name);
8671 api_sr_multicast_map_add_del (vat_main_t * vam)
8673 unformat_input_t *input = vam->input;
8674 vl_api_sr_multicast_map_add_del_t *mp;
8676 ip6_address_t multicast_address;
8677 u8 *policy_name = 0;
8678 int multicast_address_set = 0;
8681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8683 if (unformat (input, "del"))
8687 (input, "address %U", unformat_ip6_address, &multicast_address))
8688 multicast_address_set = 1;
8689 else if (unformat (input, "sr-policy %s", &policy_name))
8695 if (!is_del && !policy_name)
8697 errmsg ("sr-policy name required");
8702 if (!multicast_address_set)
8704 errmsg ("address required");
8708 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8710 mp->is_add = !is_del;
8711 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8712 clib_memcpy (mp->multicast_address, &multicast_address,
8713 sizeof (mp->multicast_address));
8716 vec_free (policy_name);
8724 #define foreach_tcp_proto_field \
8728 #define foreach_udp_proto_field \
8732 #define foreach_ip4_proto_field \
8744 u16 src_port, dst_port;
8747 #if VPP_API_TEST_BUILTIN == 0
8749 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8751 u8 **maskp = va_arg (*args, u8 **);
8753 u8 found_something = 0;
8756 #define _(a) u8 a=0;
8757 foreach_tcp_proto_field;
8760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8763 #define _(a) else if (unformat (input, #a)) a=1;
8764 foreach_tcp_proto_field
8770 #define _(a) found_something += a;
8771 foreach_tcp_proto_field;
8774 if (found_something == 0)
8777 vec_validate (mask, sizeof (*tcp) - 1);
8779 tcp = (tcp_header_t *) mask;
8781 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8782 foreach_tcp_proto_field;
8790 unformat_udp_mask (unformat_input_t * input, va_list * args)
8792 u8 **maskp = va_arg (*args, u8 **);
8794 u8 found_something = 0;
8797 #define _(a) u8 a=0;
8798 foreach_udp_proto_field;
8801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8804 #define _(a) else if (unformat (input, #a)) a=1;
8805 foreach_udp_proto_field
8811 #define _(a) found_something += a;
8812 foreach_udp_proto_field;
8815 if (found_something == 0)
8818 vec_validate (mask, sizeof (*udp) - 1);
8820 udp = (udp_header_t *) mask;
8822 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8823 foreach_udp_proto_field;
8831 unformat_l4_mask (unformat_input_t * input, va_list * args)
8833 u8 **maskp = va_arg (*args, u8 **);
8834 u16 src_port = 0, dst_port = 0;
8835 tcpudp_header_t *tcpudp;
8837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8839 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8841 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8843 else if (unformat (input, "src_port"))
8845 else if (unformat (input, "dst_port"))
8851 if (!src_port && !dst_port)
8855 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8857 tcpudp = (tcpudp_header_t *) mask;
8858 tcpudp->src_port = src_port;
8859 tcpudp->dst_port = dst_port;
8867 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8869 u8 **maskp = va_arg (*args, u8 **);
8871 u8 found_something = 0;
8874 #define _(a) u8 a=0;
8875 foreach_ip4_proto_field;
8881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8883 if (unformat (input, "version"))
8885 else if (unformat (input, "hdr_length"))
8887 else if (unformat (input, "src"))
8889 else if (unformat (input, "dst"))
8891 else if (unformat (input, "proto"))
8894 #define _(a) else if (unformat (input, #a)) a=1;
8895 foreach_ip4_proto_field
8901 #define _(a) found_something += a;
8902 foreach_ip4_proto_field;
8905 if (found_something == 0)
8908 vec_validate (mask, sizeof (*ip) - 1);
8910 ip = (ip4_header_t *) mask;
8912 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8913 foreach_ip4_proto_field;
8916 ip->ip_version_and_header_length = 0;
8919 ip->ip_version_and_header_length |= 0xF0;
8922 ip->ip_version_and_header_length |= 0x0F;
8928 #define foreach_ip6_proto_field \
8936 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8938 u8 **maskp = va_arg (*args, u8 **);
8940 u8 found_something = 0;
8942 u32 ip_version_traffic_class_and_flow_label;
8944 #define _(a) u8 a=0;
8945 foreach_ip6_proto_field;
8948 u8 traffic_class = 0;
8951 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8953 if (unformat (input, "version"))
8955 else if (unformat (input, "traffic-class"))
8957 else if (unformat (input, "flow-label"))
8959 else if (unformat (input, "src"))
8961 else if (unformat (input, "dst"))
8963 else if (unformat (input, "proto"))
8966 #define _(a) else if (unformat (input, #a)) a=1;
8967 foreach_ip6_proto_field
8973 #define _(a) found_something += a;
8974 foreach_ip6_proto_field;
8977 if (found_something == 0)
8980 vec_validate (mask, sizeof (*ip) - 1);
8982 ip = (ip6_header_t *) mask;
8984 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8985 foreach_ip6_proto_field;
8988 ip_version_traffic_class_and_flow_label = 0;
8991 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8994 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8997 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8999 ip->ip_version_traffic_class_and_flow_label =
9000 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9007 unformat_l3_mask (unformat_input_t * input, va_list * args)
9009 u8 **maskp = va_arg (*args, u8 **);
9011 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9013 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9015 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9024 unformat_l2_mask (unformat_input_t * input, va_list * args)
9026 u8 **maskp = va_arg (*args, u8 **);
9041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9043 if (unformat (input, "src"))
9045 else if (unformat (input, "dst"))
9047 else if (unformat (input, "proto"))
9049 else if (unformat (input, "tag1"))
9051 else if (unformat (input, "tag2"))
9053 else if (unformat (input, "ignore-tag1"))
9055 else if (unformat (input, "ignore-tag2"))
9057 else if (unformat (input, "cos1"))
9059 else if (unformat (input, "cos2"))
9061 else if (unformat (input, "dot1q"))
9063 else if (unformat (input, "dot1ad"))
9068 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9069 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9072 if (tag1 || ignore_tag1 || cos1 || dot1q)
9074 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9077 vec_validate (mask, len - 1);
9080 memset (mask, 0xff, 6);
9083 memset (mask + 6, 0xff, 6);
9087 /* inner vlan tag */
9096 mask[21] = mask[20] = 0xff;
9117 mask[16] = mask[17] = 0xff;
9127 mask[12] = mask[13] = 0xff;
9134 unformat_classify_mask (unformat_input_t * input, va_list * args)
9136 u8 **maskp = va_arg (*args, u8 **);
9137 u32 *skipp = va_arg (*args, u32 *);
9138 u32 *matchp = va_arg (*args, u32 *);
9146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9148 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9150 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9152 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9154 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9168 if (mask || l2 || l3 || l4)
9172 /* "With a free Ethernet header in every package" */
9174 vec_validate (l2, 13);
9178 vec_append (mask, l3);
9183 vec_append (mask, l4);
9188 /* Scan forward looking for the first significant mask octet */
9189 for (i = 0; i < vec_len (mask); i++)
9193 /* compute (skip, match) params */
9194 *skipp = i / sizeof (u32x4);
9195 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9197 /* Pad mask to an even multiple of the vector size */
9198 while (vec_len (mask) % sizeof (u32x4))
9201 match = vec_len (mask) / sizeof (u32x4);
9203 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9205 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9206 if (*tmp || *(tmp + 1))
9211 clib_warning ("BUG: match 0");
9213 _vec_len (mask) = match * sizeof (u32x4);
9223 #endif /* VPP_API_TEST_BUILTIN */
9225 #define foreach_l2_next \
9227 _(ethernet, ETHERNET_INPUT) \
9232 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9234 u32 *miss_next_indexp = va_arg (*args, u32 *);
9239 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9243 if (unformat (input, "%d", &tmp))
9252 *miss_next_indexp = next_index;
9256 #define foreach_ip_next \
9262 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9264 u32 *miss_next_indexp = va_arg (*args, u32 *);
9269 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9273 if (unformat (input, "%d", &tmp))
9282 *miss_next_indexp = next_index;
9286 #define foreach_acl_next \
9290 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9292 u32 *miss_next_indexp = va_arg (*args, u32 *);
9297 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9301 if (unformat (input, "permit"))
9306 else if (unformat (input, "%d", &tmp))
9315 *miss_next_indexp = next_index;
9320 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9322 u32 *r = va_arg (*args, u32 *);
9324 if (unformat (input, "conform-color"))
9325 *r = POLICE_CONFORM;
9326 else if (unformat (input, "exceed-color"))
9335 api_classify_add_del_table (vat_main_t * vam)
9337 unformat_input_t *i = vam->input;
9338 vl_api_classify_add_del_table_t *mp;
9345 u32 table_index = ~0;
9346 u32 next_table_index = ~0;
9347 u32 miss_next_index = ~0;
9348 u32 memory_size = 32 << 20;
9350 u32 current_data_flag = 0;
9351 int current_data_offset = 0;
9354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9356 if (unformat (i, "del"))
9358 else if (unformat (i, "del-chain"))
9363 else if (unformat (i, "buckets %d", &nbuckets))
9365 else if (unformat (i, "memory_size %d", &memory_size))
9367 else if (unformat (i, "skip %d", &skip))
9369 else if (unformat (i, "match %d", &match))
9371 else if (unformat (i, "table %d", &table_index))
9373 else if (unformat (i, "mask %U", unformat_classify_mask,
9374 &mask, &skip, &match))
9376 else if (unformat (i, "next-table %d", &next_table_index))
9378 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9381 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9384 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9387 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9389 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9395 if (is_add && mask == 0)
9397 errmsg ("Mask required");
9401 if (is_add && skip == ~0)
9403 errmsg ("skip count required");
9407 if (is_add && match == ~0)
9409 errmsg ("match count required");
9413 if (!is_add && table_index == ~0)
9415 errmsg ("table index required for delete");
9419 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9421 mp->is_add = is_add;
9422 mp->del_chain = del_chain;
9423 mp->table_index = ntohl (table_index);
9424 mp->nbuckets = ntohl (nbuckets);
9425 mp->memory_size = ntohl (memory_size);
9426 mp->skip_n_vectors = ntohl (skip);
9427 mp->match_n_vectors = ntohl (match);
9428 mp->next_table_index = ntohl (next_table_index);
9429 mp->miss_next_index = ntohl (miss_next_index);
9430 mp->current_data_flag = ntohl (current_data_flag);
9431 mp->current_data_offset = ntohl (current_data_offset);
9432 clib_memcpy (mp->mask, mask, vec_len (mask));
9441 #if VPP_API_TEST_BUILTIN == 0
9443 unformat_l4_match (unformat_input_t * input, va_list * args)
9445 u8 **matchp = va_arg (*args, u8 **);
9447 u8 *proto_header = 0;
9453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9455 if (unformat (input, "src_port %d", &src_port))
9457 else if (unformat (input, "dst_port %d", &dst_port))
9463 h.src_port = clib_host_to_net_u16 (src_port);
9464 h.dst_port = clib_host_to_net_u16 (dst_port);
9465 vec_validate (proto_header, sizeof (h) - 1);
9466 memcpy (proto_header, &h, sizeof (h));
9468 *matchp = proto_header;
9474 unformat_ip4_match (unformat_input_t * input, va_list * args)
9476 u8 **matchp = va_arg (*args, u8 **);
9483 int src = 0, dst = 0;
9484 ip4_address_t src_val, dst_val;
9491 int fragment_id = 0;
9492 u32 fragment_id_val;
9498 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9500 if (unformat (input, "version %d", &version_val))
9502 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9504 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9506 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9508 else if (unformat (input, "proto %d", &proto_val))
9510 else if (unformat (input, "tos %d", &tos_val))
9512 else if (unformat (input, "length %d", &length_val))
9514 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9516 else if (unformat (input, "ttl %d", &ttl_val))
9518 else if (unformat (input, "checksum %d", &checksum_val))
9524 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9525 + ttl + checksum == 0)
9529 * Aligned because we use the real comparison functions
9531 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9533 ip = (ip4_header_t *) match;
9535 /* These are realistically matched in practice */
9537 ip->src_address.as_u32 = src_val.as_u32;
9540 ip->dst_address.as_u32 = dst_val.as_u32;
9543 ip->protocol = proto_val;
9546 /* These are not, but they're included for completeness */
9548 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9551 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9557 ip->length = clib_host_to_net_u16 (length_val);
9563 ip->checksum = clib_host_to_net_u16 (checksum_val);
9570 unformat_ip6_match (unformat_input_t * input, va_list * args)
9572 u8 **matchp = va_arg (*args, u8 **);
9577 u8 traffic_class = 0;
9578 u32 traffic_class_val = 0;
9581 int src = 0, dst = 0;
9582 ip6_address_t src_val, dst_val;
9585 int payload_length = 0;
9586 u32 payload_length_val;
9589 u32 ip_version_traffic_class_and_flow_label;
9591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9593 if (unformat (input, "version %d", &version_val))
9595 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9597 else if (unformat (input, "flow_label %d", &flow_label_val))
9599 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9601 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9603 else if (unformat (input, "proto %d", &proto_val))
9605 else if (unformat (input, "payload_length %d", &payload_length_val))
9607 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9613 if (version + traffic_class + flow_label + src + dst + proto +
9614 payload_length + hop_limit == 0)
9618 * Aligned because we use the real comparison functions
9620 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9622 ip = (ip6_header_t *) match;
9625 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9628 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9631 ip->protocol = proto_val;
9633 ip_version_traffic_class_and_flow_label = 0;
9636 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9639 ip_version_traffic_class_and_flow_label |=
9640 (traffic_class_val & 0xFF) << 20;
9643 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9645 ip->ip_version_traffic_class_and_flow_label =
9646 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9649 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9652 ip->hop_limit = hop_limit_val;
9659 unformat_l3_match (unformat_input_t * input, va_list * args)
9661 u8 **matchp = va_arg (*args, u8 **);
9663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9665 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9667 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9676 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9678 u8 *tagp = va_arg (*args, u8 *);
9681 if (unformat (input, "%d", &tag))
9683 tagp[0] = (tag >> 8) & 0x0F;
9684 tagp[1] = tag & 0xFF;
9692 unformat_l2_match (unformat_input_t * input, va_list * args)
9694 u8 **matchp = va_arg (*args, u8 **);
9714 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9716 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9719 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9721 else if (unformat (input, "proto %U",
9722 unformat_ethernet_type_host_byte_order, &proto_val))
9724 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9726 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9728 else if (unformat (input, "ignore-tag1"))
9730 else if (unformat (input, "ignore-tag2"))
9732 else if (unformat (input, "cos1 %d", &cos1_val))
9734 else if (unformat (input, "cos2 %d", &cos2_val))
9739 if ((src + dst + proto + tag1 + tag2 +
9740 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9743 if (tag1 || ignore_tag1 || cos1)
9745 if (tag2 || ignore_tag2 || cos2)
9748 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9751 clib_memcpy (match, dst_val, 6);
9754 clib_memcpy (match + 6, src_val, 6);
9758 /* inner vlan tag */
9759 match[19] = tag2_val[1];
9760 match[18] = tag2_val[0];
9762 match[18] |= (cos2_val & 0x7) << 5;
9765 match[21] = proto_val & 0xff;
9766 match[20] = proto_val >> 8;
9770 match[15] = tag1_val[1];
9771 match[14] = tag1_val[0];
9774 match[14] |= (cos1_val & 0x7) << 5;
9780 match[15] = tag1_val[1];
9781 match[14] = tag1_val[0];
9784 match[17] = proto_val & 0xff;
9785 match[16] = proto_val >> 8;
9788 match[14] |= (cos1_val & 0x7) << 5;
9794 match[18] |= (cos2_val & 0x7) << 5;
9796 match[14] |= (cos1_val & 0x7) << 5;
9799 match[13] = proto_val & 0xff;
9800 match[12] = proto_val >> 8;
9809 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9811 u8 **matchp = va_arg (*args, u8 **);
9812 u32 skip_n_vectors = va_arg (*args, u32);
9813 u32 match_n_vectors = va_arg (*args, u32);
9820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9822 if (unformat (input, "hex %U", unformat_hex_string, &match))
9824 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9826 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9828 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9842 if (match || l2 || l3 || l4)
9846 /* "Win a free Ethernet header in every packet" */
9848 vec_validate_aligned (l2, 13, sizeof (u32x4));
9852 vec_append_aligned (match, l3, sizeof (u32x4));
9857 vec_append_aligned (match, l4, sizeof (u32x4));
9862 /* Make sure the vector is big enough even if key is all 0's */
9863 vec_validate_aligned
9864 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9867 /* Set size, include skipped vectors */
9868 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9879 api_classify_add_del_session (vat_main_t * vam)
9881 unformat_input_t *i = vam->input;
9882 vl_api_classify_add_del_session_t *mp;
9884 u32 table_index = ~0;
9885 u32 hit_next_index = ~0;
9886 u32 opaque_index = ~0;
9889 u32 skip_n_vectors = 0;
9890 u32 match_n_vectors = 0;
9896 * Warning: you have to supply skip_n and match_n
9897 * because the API client cant simply look at the classify
9901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9903 if (unformat (i, "del"))
9905 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9908 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9911 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9914 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9916 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9918 else if (unformat (i, "opaque-index %d", &opaque_index))
9920 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9922 else if (unformat (i, "match_n %d", &match_n_vectors))
9924 else if (unformat (i, "match %U", api_unformat_classify_match,
9925 &match, skip_n_vectors, match_n_vectors))
9927 else if (unformat (i, "advance %d", &advance))
9929 else if (unformat (i, "table-index %d", &table_index))
9931 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9933 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9935 else if (unformat (i, "action %d", &action))
9937 else if (unformat (i, "metadata %d", &metadata))
9943 if (table_index == ~0)
9945 errmsg ("Table index required");
9949 if (is_add && match == 0)
9951 errmsg ("Match value required");
9955 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9957 mp->is_add = is_add;
9958 mp->table_index = ntohl (table_index);
9959 mp->hit_next_index = ntohl (hit_next_index);
9960 mp->opaque_index = ntohl (opaque_index);
9961 mp->advance = ntohl (advance);
9962 mp->action = action;
9963 mp->metadata = ntohl (metadata);
9964 clib_memcpy (mp->match, match, vec_len (match));
9973 api_classify_set_interface_ip_table (vat_main_t * vam)
9975 unformat_input_t *i = vam->input;
9976 vl_api_classify_set_interface_ip_table_t *mp;
9978 int sw_if_index_set;
9979 u32 table_index = ~0;
9983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9986 sw_if_index_set = 1;
9987 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9988 sw_if_index_set = 1;
9989 else if (unformat (i, "table %d", &table_index))
9993 clib_warning ("parse error '%U'", format_unformat_error, i);
9998 if (sw_if_index_set == 0)
10000 errmsg ("missing interface name or sw_if_index");
10005 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10007 mp->sw_if_index = ntohl (sw_if_index);
10008 mp->table_index = ntohl (table_index);
10009 mp->is_ipv6 = is_ipv6;
10017 api_classify_set_interface_l2_tables (vat_main_t * vam)
10019 unformat_input_t *i = vam->input;
10020 vl_api_classify_set_interface_l2_tables_t *mp;
10022 int sw_if_index_set;
10023 u32 ip4_table_index = ~0;
10024 u32 ip6_table_index = ~0;
10025 u32 other_table_index = ~0;
10029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10032 sw_if_index_set = 1;
10033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10034 sw_if_index_set = 1;
10035 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10037 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10039 else if (unformat (i, "other-table %d", &other_table_index))
10041 else if (unformat (i, "is-input %d", &is_input))
10045 clib_warning ("parse error '%U'", format_unformat_error, i);
10050 if (sw_if_index_set == 0)
10052 errmsg ("missing interface name or sw_if_index");
10057 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10059 mp->sw_if_index = ntohl (sw_if_index);
10060 mp->ip4_table_index = ntohl (ip4_table_index);
10061 mp->ip6_table_index = ntohl (ip6_table_index);
10062 mp->other_table_index = ntohl (other_table_index);
10063 mp->is_input = (u8) is_input;
10071 api_set_ipfix_exporter (vat_main_t * vam)
10073 unformat_input_t *i = vam->input;
10074 vl_api_set_ipfix_exporter_t *mp;
10075 ip4_address_t collector_address;
10076 u8 collector_address_set = 0;
10077 u32 collector_port = ~0;
10078 ip4_address_t src_address;
10079 u8 src_address_set = 0;
10082 u32 template_interval = ~0;
10083 u8 udp_checksum = 0;
10086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10088 if (unformat (i, "collector_address %U", unformat_ip4_address,
10089 &collector_address))
10090 collector_address_set = 1;
10091 else if (unformat (i, "collector_port %d", &collector_port))
10093 else if (unformat (i, "src_address %U", unformat_ip4_address,
10095 src_address_set = 1;
10096 else if (unformat (i, "vrf_id %d", &vrf_id))
10098 else if (unformat (i, "path_mtu %d", &path_mtu))
10100 else if (unformat (i, "template_interval %d", &template_interval))
10102 else if (unformat (i, "udp_checksum"))
10108 if (collector_address_set == 0)
10110 errmsg ("collector_address required");
10114 if (src_address_set == 0)
10116 errmsg ("src_address required");
10120 M (SET_IPFIX_EXPORTER, mp);
10122 memcpy (mp->collector_address, collector_address.data,
10123 sizeof (collector_address.data));
10124 mp->collector_port = htons ((u16) collector_port);
10125 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10126 mp->vrf_id = htonl (vrf_id);
10127 mp->path_mtu = htonl (path_mtu);
10128 mp->template_interval = htonl (template_interval);
10129 mp->udp_checksum = udp_checksum;
10137 api_set_ipfix_classify_stream (vat_main_t * vam)
10139 unformat_input_t *i = vam->input;
10140 vl_api_set_ipfix_classify_stream_t *mp;
10142 u32 src_port = UDP_DST_PORT_ipfix;
10145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10147 if (unformat (i, "domain %d", &domain_id))
10149 else if (unformat (i, "src_port %d", &src_port))
10153 errmsg ("unknown input `%U'", format_unformat_error, i);
10158 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10160 mp->domain_id = htonl (domain_id);
10161 mp->src_port = htons ((u16) src_port);
10169 api_ipfix_classify_table_add_del (vat_main_t * vam)
10171 unformat_input_t *i = vam->input;
10172 vl_api_ipfix_classify_table_add_del_t *mp;
10174 u32 classify_table_index = ~0;
10176 u8 transport_protocol = 255;
10179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10181 if (unformat (i, "add"))
10183 else if (unformat (i, "del"))
10185 else if (unformat (i, "table %d", &classify_table_index))
10187 else if (unformat (i, "ip4"))
10189 else if (unformat (i, "ip6"))
10191 else if (unformat (i, "tcp"))
10192 transport_protocol = 6;
10193 else if (unformat (i, "udp"))
10194 transport_protocol = 17;
10197 errmsg ("unknown input `%U'", format_unformat_error, i);
10204 errmsg ("expecting: add|del");
10207 if (classify_table_index == ~0)
10209 errmsg ("classifier table not specified");
10212 if (ip_version == 0)
10214 errmsg ("IP version not specified");
10218 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10220 mp->is_add = is_add;
10221 mp->table_id = htonl (classify_table_index);
10222 mp->ip_version = ip_version;
10223 mp->transport_protocol = transport_protocol;
10231 api_get_node_index (vat_main_t * vam)
10233 unformat_input_t *i = vam->input;
10234 vl_api_get_node_index_t *mp;
10238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10240 if (unformat (i, "node %s", &name))
10247 errmsg ("node name required");
10250 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10252 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10256 M (GET_NODE_INDEX, mp);
10257 clib_memcpy (mp->node_name, name, vec_len (name));
10266 api_get_next_index (vat_main_t * vam)
10268 unformat_input_t *i = vam->input;
10269 vl_api_get_next_index_t *mp;
10270 u8 *node_name = 0, *next_node_name = 0;
10273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10275 if (unformat (i, "node-name %s", &node_name))
10277 else if (unformat (i, "next-node-name %s", &next_node_name))
10281 if (node_name == 0)
10283 errmsg ("node name required");
10286 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10288 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10292 if (next_node_name == 0)
10294 errmsg ("next node name required");
10297 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10299 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10303 M (GET_NEXT_INDEX, mp);
10304 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10305 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10306 vec_free (node_name);
10307 vec_free (next_node_name);
10315 api_add_node_next (vat_main_t * vam)
10317 unformat_input_t *i = vam->input;
10318 vl_api_add_node_next_t *mp;
10323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10325 if (unformat (i, "node %s", &name))
10327 else if (unformat (i, "next %s", &next))
10334 errmsg ("node name required");
10337 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10339 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10344 errmsg ("next node required");
10347 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10349 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10353 M (ADD_NODE_NEXT, mp);
10354 clib_memcpy (mp->node_name, name, vec_len (name));
10355 clib_memcpy (mp->next_name, next, vec_len (next));
10365 api_l2tpv3_create_tunnel (vat_main_t * vam)
10367 unformat_input_t *i = vam->input;
10368 ip6_address_t client_address, our_address;
10369 int client_address_set = 0;
10370 int our_address_set = 0;
10371 u32 local_session_id = 0;
10372 u32 remote_session_id = 0;
10373 u64 local_cookie = 0;
10374 u64 remote_cookie = 0;
10375 u8 l2_sublayer_present = 0;
10376 vl_api_l2tpv3_create_tunnel_t *mp;
10379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10381 if (unformat (i, "client_address %U", unformat_ip6_address,
10383 client_address_set = 1;
10384 else if (unformat (i, "our_address %U", unformat_ip6_address,
10386 our_address_set = 1;
10387 else if (unformat (i, "local_session_id %d", &local_session_id))
10389 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10391 else if (unformat (i, "local_cookie %lld", &local_cookie))
10393 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10395 else if (unformat (i, "l2-sublayer-present"))
10396 l2_sublayer_present = 1;
10401 if (client_address_set == 0)
10403 errmsg ("client_address required");
10407 if (our_address_set == 0)
10409 errmsg ("our_address required");
10413 M (L2TPV3_CREATE_TUNNEL, mp);
10415 clib_memcpy (mp->client_address, client_address.as_u8,
10416 sizeof (mp->client_address));
10418 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10420 mp->local_session_id = ntohl (local_session_id);
10421 mp->remote_session_id = ntohl (remote_session_id);
10422 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10423 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10424 mp->l2_sublayer_present = l2_sublayer_present;
10433 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10435 unformat_input_t *i = vam->input;
10437 u8 sw_if_index_set = 0;
10438 u64 new_local_cookie = 0;
10439 u64 new_remote_cookie = 0;
10440 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10445 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10446 sw_if_index_set = 1;
10447 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10448 sw_if_index_set = 1;
10449 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10451 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10457 if (sw_if_index_set == 0)
10459 errmsg ("missing interface name or sw_if_index");
10463 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10465 mp->sw_if_index = ntohl (sw_if_index);
10466 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10467 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10475 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10477 unformat_input_t *i = vam->input;
10478 vl_api_l2tpv3_interface_enable_disable_t *mp;
10480 u8 sw_if_index_set = 0;
10481 u8 enable_disable = 1;
10484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10487 sw_if_index_set = 1;
10488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10489 sw_if_index_set = 1;
10490 else if (unformat (i, "enable"))
10491 enable_disable = 1;
10492 else if (unformat (i, "disable"))
10493 enable_disable = 0;
10498 if (sw_if_index_set == 0)
10500 errmsg ("missing interface name or sw_if_index");
10504 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10506 mp->sw_if_index = ntohl (sw_if_index);
10507 mp->enable_disable = enable_disable;
10515 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10517 unformat_input_t *i = vam->input;
10518 vl_api_l2tpv3_set_lookup_key_t *mp;
10522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10524 if (unformat (i, "lookup_v6_src"))
10525 key = L2T_LOOKUP_SRC_ADDRESS;
10526 else if (unformat (i, "lookup_v6_dst"))
10527 key = L2T_LOOKUP_DST_ADDRESS;
10528 else if (unformat (i, "lookup_session_id"))
10529 key = L2T_LOOKUP_SESSION_ID;
10534 if (key == (u8) ~ 0)
10536 errmsg ("l2tp session lookup key unset");
10540 M (L2TPV3_SET_LOOKUP_KEY, mp);
10549 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10550 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10552 vat_main_t *vam = &vat_main;
10554 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10555 format_ip6_address, mp->our_address,
10556 format_ip6_address, mp->client_address,
10557 clib_net_to_host_u32 (mp->sw_if_index));
10560 " local cookies %016llx %016llx remote cookie %016llx",
10561 clib_net_to_host_u64 (mp->local_cookie[0]),
10562 clib_net_to_host_u64 (mp->local_cookie[1]),
10563 clib_net_to_host_u64 (mp->remote_cookie));
10565 print (vam->ofp, " local session-id %d remote session-id %d",
10566 clib_net_to_host_u32 (mp->local_session_id),
10567 clib_net_to_host_u32 (mp->remote_session_id));
10569 print (vam->ofp, " l2 specific sublayer %s\n",
10570 mp->l2_sublayer_present ? "preset" : "absent");
10574 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10575 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10577 vat_main_t *vam = &vat_main;
10578 vat_json_node_t *node = NULL;
10579 struct in6_addr addr;
10581 if (VAT_JSON_ARRAY != vam->json_tree.type)
10583 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10584 vat_json_init_array (&vam->json_tree);
10586 node = vat_json_array_add (&vam->json_tree);
10588 vat_json_init_object (node);
10590 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10591 vat_json_object_add_ip6 (node, "our_address", addr);
10592 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10593 vat_json_object_add_ip6 (node, "client_address", addr);
10595 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10596 vat_json_init_array (lc);
10597 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10598 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10599 vat_json_object_add_uint (node, "remote_cookie",
10600 clib_net_to_host_u64 (mp->remote_cookie));
10602 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10603 vat_json_object_add_uint (node, "local_session_id",
10604 clib_net_to_host_u32 (mp->local_session_id));
10605 vat_json_object_add_uint (node, "remote_session_id",
10606 clib_net_to_host_u32 (mp->remote_session_id));
10607 vat_json_object_add_string_copy (node, "l2_sublayer",
10608 mp->l2_sublayer_present ? (u8 *) "present"
10609 : (u8 *) "absent");
10613 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10615 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10616 vl_api_control_ping_t *mp_ping;
10619 /* Get list of l2tpv3-tunnel interfaces */
10620 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10623 /* Use a control ping for synchronization */
10624 M (CONTROL_PING, mp_ping);
10632 static void vl_api_sw_interface_tap_details_t_handler
10633 (vl_api_sw_interface_tap_details_t * mp)
10635 vat_main_t *vam = &vat_main;
10637 print (vam->ofp, "%-16s %d",
10638 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10641 static void vl_api_sw_interface_tap_details_t_handler_json
10642 (vl_api_sw_interface_tap_details_t * mp)
10644 vat_main_t *vam = &vat_main;
10645 vat_json_node_t *node = NULL;
10647 if (VAT_JSON_ARRAY != vam->json_tree.type)
10649 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10650 vat_json_init_array (&vam->json_tree);
10652 node = vat_json_array_add (&vam->json_tree);
10654 vat_json_init_object (node);
10655 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10656 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10660 api_sw_interface_tap_dump (vat_main_t * vam)
10662 vl_api_sw_interface_tap_dump_t *mp;
10663 vl_api_control_ping_t *mp_ping;
10666 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10667 /* Get list of tap interfaces */
10668 M (SW_INTERFACE_TAP_DUMP, mp);
10671 /* Use a control ping for synchronization */
10672 M (CONTROL_PING, mp_ping);
10679 static uword unformat_vxlan_decap_next
10680 (unformat_input_t * input, va_list * args)
10682 u32 *result = va_arg (*args, u32 *);
10685 if (unformat (input, "l2"))
10686 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10687 else if (unformat (input, "%d", &tmp))
10695 api_vxlan_add_del_tunnel (vat_main_t * vam)
10697 unformat_input_t *line_input = vam->input;
10698 vl_api_vxlan_add_del_tunnel_t *mp;
10699 ip46_address_t src, dst;
10701 u8 ipv4_set = 0, ipv6_set = 0;
10705 u32 mcast_sw_if_index = ~0;
10706 u32 encap_vrf_id = 0;
10707 u32 decap_next_index = ~0;
10711 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10712 memset (&src, 0, sizeof src);
10713 memset (&dst, 0, sizeof dst);
10715 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10717 if (unformat (line_input, "del"))
10720 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10726 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10732 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10738 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10743 else if (unformat (line_input, "group %U %U",
10744 unformat_ip4_address, &dst.ip4,
10745 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10747 grp_set = dst_set = 1;
10750 else if (unformat (line_input, "group %U",
10751 unformat_ip4_address, &dst.ip4))
10753 grp_set = dst_set = 1;
10756 else if (unformat (line_input, "group %U %U",
10757 unformat_ip6_address, &dst.ip6,
10758 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10760 grp_set = dst_set = 1;
10763 else if (unformat (line_input, "group %U",
10764 unformat_ip6_address, &dst.ip6))
10766 grp_set = dst_set = 1;
10770 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10772 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10774 else if (unformat (line_input, "decap-next %U",
10775 unformat_vxlan_decap_next, &decap_next_index))
10777 else if (unformat (line_input, "vni %d", &vni))
10781 errmsg ("parse error '%U'", format_unformat_error, line_input);
10788 errmsg ("tunnel src address not specified");
10793 errmsg ("tunnel dst address not specified");
10797 if (grp_set && !ip46_address_is_multicast (&dst))
10799 errmsg ("tunnel group address not multicast");
10802 if (grp_set && mcast_sw_if_index == ~0)
10804 errmsg ("tunnel nonexistent multicast device");
10807 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10809 errmsg ("tunnel dst address must be unicast");
10814 if (ipv4_set && ipv6_set)
10816 errmsg ("both IPv4 and IPv6 addresses specified");
10820 if ((vni == 0) || (vni >> 24))
10822 errmsg ("vni not specified or out of range");
10826 M (VXLAN_ADD_DEL_TUNNEL, mp);
10830 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10831 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10835 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10836 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10838 mp->encap_vrf_id = ntohl (encap_vrf_id);
10839 mp->decap_next_index = ntohl (decap_next_index);
10840 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10841 mp->vni = ntohl (vni);
10842 mp->is_add = is_add;
10843 mp->is_ipv6 = ipv6_set;
10850 static void vl_api_vxlan_tunnel_details_t_handler
10851 (vl_api_vxlan_tunnel_details_t * mp)
10853 vat_main_t *vam = &vat_main;
10854 ip46_address_t src, dst;
10856 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10857 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10859 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10860 ntohl (mp->sw_if_index),
10861 format_ip46_address, &src, IP46_TYPE_ANY,
10862 format_ip46_address, &dst, IP46_TYPE_ANY,
10863 ntohl (mp->encap_vrf_id),
10864 ntohl (mp->decap_next_index), ntohl (mp->vni),
10865 ntohl (mp->mcast_sw_if_index));
10868 static void vl_api_vxlan_tunnel_details_t_handler_json
10869 (vl_api_vxlan_tunnel_details_t * mp)
10871 vat_main_t *vam = &vat_main;
10872 vat_json_node_t *node = NULL;
10874 if (VAT_JSON_ARRAY != vam->json_tree.type)
10876 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10877 vat_json_init_array (&vam->json_tree);
10879 node = vat_json_array_add (&vam->json_tree);
10881 vat_json_init_object (node);
10882 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10885 struct in6_addr ip6;
10887 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10888 vat_json_object_add_ip6 (node, "src_address", ip6);
10889 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10890 vat_json_object_add_ip6 (node, "dst_address", ip6);
10894 struct in_addr ip4;
10896 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10897 vat_json_object_add_ip4 (node, "src_address", ip4);
10898 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10899 vat_json_object_add_ip4 (node, "dst_address", ip4);
10901 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10902 vat_json_object_add_uint (node, "decap_next_index",
10903 ntohl (mp->decap_next_index));
10904 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10905 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10906 vat_json_object_add_uint (node, "mcast_sw_if_index",
10907 ntohl (mp->mcast_sw_if_index));
10911 api_vxlan_tunnel_dump (vat_main_t * vam)
10913 unformat_input_t *i = vam->input;
10914 vl_api_vxlan_tunnel_dump_t *mp;
10915 vl_api_control_ping_t *mp_ping;
10917 u8 sw_if_index_set = 0;
10920 /* Parse args required to build the message */
10921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10923 if (unformat (i, "sw_if_index %d", &sw_if_index))
10924 sw_if_index_set = 1;
10929 if (sw_if_index_set == 0)
10934 if (!vam->json_output)
10936 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10937 "sw_if_index", "src_address", "dst_address",
10938 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10941 /* Get list of vxlan-tunnel interfaces */
10942 M (VXLAN_TUNNEL_DUMP, mp);
10944 mp->sw_if_index = htonl (sw_if_index);
10948 /* Use a control ping for synchronization */
10949 M (CONTROL_PING, mp_ping);
10957 api_gre_add_del_tunnel (vat_main_t * vam)
10959 unformat_input_t *line_input = vam->input;
10960 vl_api_gre_add_del_tunnel_t *mp;
10961 ip4_address_t src4, dst4;
10966 u32 outer_fib_id = 0;
10969 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10971 if (unformat (line_input, "del"))
10973 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10975 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10977 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10979 else if (unformat (line_input, "teb"))
10983 errmsg ("parse error '%U'", format_unformat_error, line_input);
10990 errmsg ("tunnel src address not specified");
10995 errmsg ("tunnel dst address not specified");
11000 M (GRE_ADD_DEL_TUNNEL, mp);
11002 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
11003 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
11004 mp->outer_fib_id = ntohl (outer_fib_id);
11005 mp->is_add = is_add;
11013 static void vl_api_gre_tunnel_details_t_handler
11014 (vl_api_gre_tunnel_details_t * mp)
11016 vat_main_t *vam = &vat_main;
11018 print (vam->ofp, "%11d%15U%15U%6d%14d",
11019 ntohl (mp->sw_if_index),
11020 format_ip4_address, &mp->src_address,
11021 format_ip4_address, &mp->dst_address,
11022 mp->teb, ntohl (mp->outer_fib_id));
11025 static void vl_api_gre_tunnel_details_t_handler_json
11026 (vl_api_gre_tunnel_details_t * mp)
11028 vat_main_t *vam = &vat_main;
11029 vat_json_node_t *node = NULL;
11030 struct in_addr ip4;
11032 if (VAT_JSON_ARRAY != vam->json_tree.type)
11034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11035 vat_json_init_array (&vam->json_tree);
11037 node = vat_json_array_add (&vam->json_tree);
11039 vat_json_init_object (node);
11040 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11041 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11042 vat_json_object_add_ip4 (node, "src_address", ip4);
11043 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11044 vat_json_object_add_ip4 (node, "dst_address", ip4);
11045 vat_json_object_add_uint (node, "teb", mp->teb);
11046 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11050 api_gre_tunnel_dump (vat_main_t * vam)
11052 unformat_input_t *i = vam->input;
11053 vl_api_gre_tunnel_dump_t *mp;
11054 vl_api_control_ping_t *mp_ping;
11056 u8 sw_if_index_set = 0;
11059 /* Parse args required to build the message */
11060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11062 if (unformat (i, "sw_if_index %d", &sw_if_index))
11063 sw_if_index_set = 1;
11068 if (sw_if_index_set == 0)
11073 if (!vam->json_output)
11075 print (vam->ofp, "%11s%15s%15s%6s%14s",
11076 "sw_if_index", "src_address", "dst_address", "teb",
11080 /* Get list of gre-tunnel interfaces */
11081 M (GRE_TUNNEL_DUMP, mp);
11083 mp->sw_if_index = htonl (sw_if_index);
11087 /* Use a control ping for synchronization */
11088 M (CONTROL_PING, mp_ping);
11096 api_l2_fib_clear_table (vat_main_t * vam)
11098 // unformat_input_t * i = vam->input;
11099 vl_api_l2_fib_clear_table_t *mp;
11102 M (L2_FIB_CLEAR_TABLE, mp);
11110 api_l2_interface_efp_filter (vat_main_t * vam)
11112 unformat_input_t *i = vam->input;
11113 vl_api_l2_interface_efp_filter_t *mp;
11116 u8 sw_if_index_set = 0;
11119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11121 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11122 sw_if_index_set = 1;
11123 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11124 sw_if_index_set = 1;
11125 else if (unformat (i, "enable"))
11127 else if (unformat (i, "disable"))
11131 clib_warning ("parse error '%U'", format_unformat_error, i);
11136 if (sw_if_index_set == 0)
11138 errmsg ("missing sw_if_index");
11142 M (L2_INTERFACE_EFP_FILTER, mp);
11144 mp->sw_if_index = ntohl (sw_if_index);
11145 mp->enable_disable = enable;
11152 #define foreach_vtr_op \
11153 _("disable", L2_VTR_DISABLED) \
11154 _("push-1", L2_VTR_PUSH_1) \
11155 _("push-2", L2_VTR_PUSH_2) \
11156 _("pop-1", L2_VTR_POP_1) \
11157 _("pop-2", L2_VTR_POP_2) \
11158 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11159 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11160 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11161 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11164 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11166 unformat_input_t *i = vam->input;
11167 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11169 u8 sw_if_index_set = 0;
11172 u32 push_dot1q = 1;
11177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11180 sw_if_index_set = 1;
11181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11182 sw_if_index_set = 1;
11183 else if (unformat (i, "vtr_op %d", &vtr_op))
11185 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11188 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11190 else if (unformat (i, "tag1 %d", &tag1))
11192 else if (unformat (i, "tag2 %d", &tag2))
11196 clib_warning ("parse error '%U'", format_unformat_error, i);
11201 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11203 errmsg ("missing vtr operation or sw_if_index");
11207 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11208 mp->sw_if_index = ntohl (sw_if_index);
11209 mp->vtr_op = ntohl (vtr_op);
11210 mp->push_dot1q = ntohl (push_dot1q);
11211 mp->tag1 = ntohl (tag1);
11212 mp->tag2 = ntohl (tag2);
11220 api_create_vhost_user_if (vat_main_t * vam)
11222 unformat_input_t *i = vam->input;
11223 vl_api_create_vhost_user_if_t *mp;
11226 u8 file_name_set = 0;
11227 u32 custom_dev_instance = ~0;
11229 u8 use_custom_mac = 0;
11233 /* Shut up coverity */
11234 memset (hwaddr, 0, sizeof (hwaddr));
11236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11238 if (unformat (i, "socket %s", &file_name))
11242 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11244 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11245 use_custom_mac = 1;
11246 else if (unformat (i, "server"))
11248 else if (unformat (i, "tag %s", &tag))
11254 if (file_name_set == 0)
11256 errmsg ("missing socket file name");
11260 if (vec_len (file_name) > 255)
11262 errmsg ("socket file name too long");
11265 vec_add1 (file_name, 0);
11267 M (CREATE_VHOST_USER_IF, mp);
11269 mp->is_server = is_server;
11270 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11271 vec_free (file_name);
11272 if (custom_dev_instance != ~0)
11275 mp->custom_dev_instance = ntohl (custom_dev_instance);
11277 mp->use_custom_mac = use_custom_mac;
11278 clib_memcpy (mp->mac_address, hwaddr, 6);
11280 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11289 api_modify_vhost_user_if (vat_main_t * vam)
11291 unformat_input_t *i = vam->input;
11292 vl_api_modify_vhost_user_if_t *mp;
11295 u8 file_name_set = 0;
11296 u32 custom_dev_instance = ~0;
11297 u8 sw_if_index_set = 0;
11298 u32 sw_if_index = (u32) ~ 0;
11301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11304 sw_if_index_set = 1;
11305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11306 sw_if_index_set = 1;
11307 else if (unformat (i, "socket %s", &file_name))
11311 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11313 else if (unformat (i, "server"))
11319 if (sw_if_index_set == 0)
11321 errmsg ("missing sw_if_index or interface name");
11325 if (file_name_set == 0)
11327 errmsg ("missing socket file name");
11331 if (vec_len (file_name) > 255)
11333 errmsg ("socket file name too long");
11336 vec_add1 (file_name, 0);
11338 M (MODIFY_VHOST_USER_IF, mp);
11340 mp->sw_if_index = ntohl (sw_if_index);
11341 mp->is_server = is_server;
11342 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11343 vec_free (file_name);
11344 if (custom_dev_instance != ~0)
11347 mp->custom_dev_instance = ntohl (custom_dev_instance);
11356 api_delete_vhost_user_if (vat_main_t * vam)
11358 unformat_input_t *i = vam->input;
11359 vl_api_delete_vhost_user_if_t *mp;
11360 u32 sw_if_index = ~0;
11361 u8 sw_if_index_set = 0;
11364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11367 sw_if_index_set = 1;
11368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11369 sw_if_index_set = 1;
11374 if (sw_if_index_set == 0)
11376 errmsg ("missing sw_if_index or interface name");
11381 M (DELETE_VHOST_USER_IF, mp);
11383 mp->sw_if_index = ntohl (sw_if_index);
11390 static void vl_api_sw_interface_vhost_user_details_t_handler
11391 (vl_api_sw_interface_vhost_user_details_t * mp)
11393 vat_main_t *vam = &vat_main;
11395 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11396 (char *) mp->interface_name,
11397 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11398 clib_net_to_host_u64 (mp->features), mp->is_server,
11399 ntohl (mp->num_regions), (char *) mp->sock_filename);
11400 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11403 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11404 (vl_api_sw_interface_vhost_user_details_t * mp)
11406 vat_main_t *vam = &vat_main;
11407 vat_json_node_t *node = NULL;
11409 if (VAT_JSON_ARRAY != vam->json_tree.type)
11411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11412 vat_json_init_array (&vam->json_tree);
11414 node = vat_json_array_add (&vam->json_tree);
11416 vat_json_init_object (node);
11417 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11418 vat_json_object_add_string_copy (node, "interface_name",
11419 mp->interface_name);
11420 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11421 ntohl (mp->virtio_net_hdr_sz));
11422 vat_json_object_add_uint (node, "features",
11423 clib_net_to_host_u64 (mp->features));
11424 vat_json_object_add_uint (node, "is_server", mp->is_server);
11425 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11426 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11427 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11431 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11433 vl_api_sw_interface_vhost_user_dump_t *mp;
11434 vl_api_control_ping_t *mp_ping;
11437 "Interface name idx hdr_sz features server regions filename");
11439 /* Get list of vhost-user interfaces */
11440 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11443 /* Use a control ping for synchronization */
11444 M (CONTROL_PING, mp_ping);
11452 api_show_version (vat_main_t * vam)
11454 vl_api_show_version_t *mp;
11457 M (SHOW_VERSION, mp);
11466 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11468 unformat_input_t *line_input = vam->input;
11469 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11470 ip4_address_t local4, remote4;
11471 ip6_address_t local6, remote6;
11473 u8 ipv4_set = 0, ipv6_set = 0;
11476 u32 encap_vrf_id = 0;
11477 u32 decap_vrf_id = 0;
11483 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (line_input, "del"))
11487 else if (unformat (line_input, "local %U",
11488 unformat_ip4_address, &local4))
11493 else if (unformat (line_input, "remote %U",
11494 unformat_ip4_address, &remote4))
11499 else if (unformat (line_input, "local %U",
11500 unformat_ip6_address, &local6))
11505 else if (unformat (line_input, "remote %U",
11506 unformat_ip6_address, &remote6))
11511 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11513 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11515 else if (unformat (line_input, "vni %d", &vni))
11517 else if (unformat (line_input, "next-ip4"))
11519 else if (unformat (line_input, "next-ip6"))
11521 else if (unformat (line_input, "next-ethernet"))
11523 else if (unformat (line_input, "next-nsh"))
11527 errmsg ("parse error '%U'", format_unformat_error, line_input);
11532 if (local_set == 0)
11534 errmsg ("tunnel local address not specified");
11537 if (remote_set == 0)
11539 errmsg ("tunnel remote address not specified");
11542 if (ipv4_set && ipv6_set)
11544 errmsg ("both IPv4 and IPv6 addresses specified");
11550 errmsg ("vni not specified");
11554 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11559 clib_memcpy (&mp->local, &local6, sizeof (local6));
11560 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11564 clib_memcpy (&mp->local, &local4, sizeof (local4));
11565 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11568 mp->encap_vrf_id = ntohl (encap_vrf_id);
11569 mp->decap_vrf_id = ntohl (decap_vrf_id);
11570 mp->protocol = protocol;
11571 mp->vni = ntohl (vni);
11572 mp->is_add = is_add;
11573 mp->is_ipv6 = ipv6_set;
11580 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11581 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11583 vat_main_t *vam = &vat_main;
11585 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11586 ntohl (mp->sw_if_index),
11587 format_ip46_address, &(mp->local[0]),
11588 format_ip46_address, &(mp->remote[0]),
11590 ntohl (mp->protocol),
11591 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11594 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11595 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11597 vat_main_t *vam = &vat_main;
11598 vat_json_node_t *node = NULL;
11599 struct in_addr ip4;
11600 struct in6_addr ip6;
11602 if (VAT_JSON_ARRAY != vam->json_tree.type)
11604 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11605 vat_json_init_array (&vam->json_tree);
11607 node = vat_json_array_add (&vam->json_tree);
11609 vat_json_init_object (node);
11610 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11613 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11614 vat_json_object_add_ip6 (node, "local", ip6);
11615 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11616 vat_json_object_add_ip6 (node, "remote", ip6);
11620 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11621 vat_json_object_add_ip4 (node, "local", ip4);
11622 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11623 vat_json_object_add_ip4 (node, "remote", ip4);
11625 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11626 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11627 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11628 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11629 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11633 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11635 unformat_input_t *i = vam->input;
11636 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11637 vl_api_control_ping_t *mp_ping;
11639 u8 sw_if_index_set = 0;
11642 /* Parse args required to build the message */
11643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11645 if (unformat (i, "sw_if_index %d", &sw_if_index))
11646 sw_if_index_set = 1;
11651 if (sw_if_index_set == 0)
11656 if (!vam->json_output)
11658 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11659 "sw_if_index", "local", "remote", "vni",
11660 "protocol", "encap_vrf_id", "decap_vrf_id");
11663 /* Get list of vxlan-tunnel interfaces */
11664 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11666 mp->sw_if_index = htonl (sw_if_index);
11670 /* Use a control ping for synchronization */
11671 M (CONTROL_PING, mp_ping);
11679 format_l2_fib_mac_address (u8 * s, va_list * args)
11681 u8 *a = va_arg (*args, u8 *);
11683 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11684 a[2], a[3], a[4], a[5], a[6], a[7]);
11687 static void vl_api_l2_fib_table_entry_t_handler
11688 (vl_api_l2_fib_table_entry_t * mp)
11690 vat_main_t *vam = &vat_main;
11692 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11694 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11695 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11699 static void vl_api_l2_fib_table_entry_t_handler_json
11700 (vl_api_l2_fib_table_entry_t * mp)
11702 vat_main_t *vam = &vat_main;
11703 vat_json_node_t *node = NULL;
11705 if (VAT_JSON_ARRAY != vam->json_tree.type)
11707 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11708 vat_json_init_array (&vam->json_tree);
11710 node = vat_json_array_add (&vam->json_tree);
11712 vat_json_init_object (node);
11713 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11714 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11715 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11716 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11717 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11718 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11722 api_l2_fib_table_dump (vat_main_t * vam)
11724 unformat_input_t *i = vam->input;
11725 vl_api_l2_fib_table_dump_t *mp;
11726 vl_api_control_ping_t *mp_ping;
11731 /* Parse args required to build the message */
11732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11734 if (unformat (i, "bd_id %d", &bd_id))
11740 if (bd_id_set == 0)
11742 errmsg ("missing bridge domain");
11746 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11748 /* Get list of l2 fib entries */
11749 M (L2_FIB_TABLE_DUMP, mp);
11751 mp->bd_id = ntohl (bd_id);
11754 /* Use a control ping for synchronization */
11755 M (CONTROL_PING, mp_ping);
11764 api_interface_name_renumber (vat_main_t * vam)
11766 unformat_input_t *line_input = vam->input;
11767 vl_api_interface_name_renumber_t *mp;
11768 u32 sw_if_index = ~0;
11769 u32 new_show_dev_instance = ~0;
11772 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11774 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11777 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11779 else if (unformat (line_input, "new_show_dev_instance %d",
11780 &new_show_dev_instance))
11786 if (sw_if_index == ~0)
11788 errmsg ("missing interface name or sw_if_index");
11792 if (new_show_dev_instance == ~0)
11794 errmsg ("missing new_show_dev_instance");
11798 M (INTERFACE_NAME_RENUMBER, mp);
11800 mp->sw_if_index = ntohl (sw_if_index);
11801 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11809 api_want_ip4_arp_events (vat_main_t * vam)
11811 unformat_input_t *line_input = vam->input;
11812 vl_api_want_ip4_arp_events_t *mp;
11813 ip4_address_t address;
11814 int address_set = 0;
11815 u32 enable_disable = 1;
11818 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11820 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11822 else if (unformat (line_input, "del"))
11823 enable_disable = 0;
11828 if (address_set == 0)
11830 errmsg ("missing addresses");
11834 M (WANT_IP4_ARP_EVENTS, mp);
11835 mp->enable_disable = enable_disable;
11836 mp->pid = getpid ();
11837 mp->address = address.as_u32;
11845 api_want_ip6_nd_events (vat_main_t * vam)
11847 unformat_input_t *line_input = vam->input;
11848 vl_api_want_ip6_nd_events_t *mp;
11849 ip6_address_t address;
11850 int address_set = 0;
11851 u32 enable_disable = 1;
11854 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11856 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11858 else if (unformat (line_input, "del"))
11859 enable_disable = 0;
11864 if (address_set == 0)
11866 errmsg ("missing addresses");
11870 M (WANT_IP6_ND_EVENTS, mp);
11871 mp->enable_disable = enable_disable;
11872 mp->pid = getpid ();
11873 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11881 api_input_acl_set_interface (vat_main_t * vam)
11883 unformat_input_t *i = vam->input;
11884 vl_api_input_acl_set_interface_t *mp;
11886 int sw_if_index_set;
11887 u32 ip4_table_index = ~0;
11888 u32 ip6_table_index = ~0;
11889 u32 l2_table_index = ~0;
11893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11896 sw_if_index_set = 1;
11897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11898 sw_if_index_set = 1;
11899 else if (unformat (i, "del"))
11901 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11903 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11905 else if (unformat (i, "l2-table %d", &l2_table_index))
11909 clib_warning ("parse error '%U'", format_unformat_error, i);
11914 if (sw_if_index_set == 0)
11916 errmsg ("missing interface name or sw_if_index");
11920 M (INPUT_ACL_SET_INTERFACE, mp);
11922 mp->sw_if_index = ntohl (sw_if_index);
11923 mp->ip4_table_index = ntohl (ip4_table_index);
11924 mp->ip6_table_index = ntohl (ip6_table_index);
11925 mp->l2_table_index = ntohl (l2_table_index);
11926 mp->is_add = is_add;
11934 api_ip_address_dump (vat_main_t * vam)
11936 unformat_input_t *i = vam->input;
11937 vl_api_ip_address_dump_t *mp;
11938 vl_api_control_ping_t *mp_ping;
11939 u32 sw_if_index = ~0;
11940 u8 sw_if_index_set = 0;
11945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11947 if (unformat (i, "sw_if_index %d", &sw_if_index))
11948 sw_if_index_set = 1;
11950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11951 sw_if_index_set = 1;
11952 else if (unformat (i, "ipv4"))
11954 else if (unformat (i, "ipv6"))
11960 if (ipv4_set && ipv6_set)
11962 errmsg ("ipv4 and ipv6 flags cannot be both set");
11966 if ((!ipv4_set) && (!ipv6_set))
11968 errmsg ("no ipv4 nor ipv6 flag set");
11972 if (sw_if_index_set == 0)
11974 errmsg ("missing interface name or sw_if_index");
11978 vam->current_sw_if_index = sw_if_index;
11979 vam->is_ipv6 = ipv6_set;
11981 M (IP_ADDRESS_DUMP, mp);
11982 mp->sw_if_index = ntohl (sw_if_index);
11983 mp->is_ipv6 = ipv6_set;
11986 /* Use a control ping for synchronization */
11987 M (CONTROL_PING, mp_ping);
11995 api_ip_dump (vat_main_t * vam)
11997 vl_api_ip_dump_t *mp;
11998 vl_api_control_ping_t *mp_ping;
11999 unformat_input_t *in = vam->input;
12006 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12008 if (unformat (in, "ipv4"))
12010 else if (unformat (in, "ipv6"))
12016 if (ipv4_set && ipv6_set)
12018 errmsg ("ipv4 and ipv6 flags cannot be both set");
12022 if ((!ipv4_set) && (!ipv6_set))
12024 errmsg ("no ipv4 nor ipv6 flag set");
12028 is_ipv6 = ipv6_set;
12029 vam->is_ipv6 = is_ipv6;
12031 /* free old data */
12032 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12034 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12036 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12039 mp->is_ipv6 = ipv6_set;
12042 /* Use a control ping for synchronization */
12043 M (CONTROL_PING, mp_ping);
12051 api_ipsec_spd_add_del (vat_main_t * vam)
12053 unformat_input_t *i = vam->input;
12054 vl_api_ipsec_spd_add_del_t *mp;
12059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12061 if (unformat (i, "spd_id %d", &spd_id))
12063 else if (unformat (i, "del"))
12067 clib_warning ("parse error '%U'", format_unformat_error, i);
12073 errmsg ("spd_id must be set");
12077 M (IPSEC_SPD_ADD_DEL, mp);
12079 mp->spd_id = ntohl (spd_id);
12080 mp->is_add = is_add;
12088 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12090 unformat_input_t *i = vam->input;
12091 vl_api_ipsec_interface_add_del_spd_t *mp;
12093 u8 sw_if_index_set = 0;
12094 u32 spd_id = (u32) ~ 0;
12098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12100 if (unformat (i, "del"))
12102 else if (unformat (i, "spd_id %d", &spd_id))
12105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12106 sw_if_index_set = 1;
12107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12108 sw_if_index_set = 1;
12111 clib_warning ("parse error '%U'", format_unformat_error, i);
12117 if (spd_id == (u32) ~ 0)
12119 errmsg ("spd_id must be set");
12123 if (sw_if_index_set == 0)
12125 errmsg ("missing interface name or sw_if_index");
12129 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12131 mp->spd_id = ntohl (spd_id);
12132 mp->sw_if_index = ntohl (sw_if_index);
12133 mp->is_add = is_add;
12141 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12143 unformat_input_t *i = vam->input;
12144 vl_api_ipsec_spd_add_del_entry_t *mp;
12145 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12146 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12148 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12149 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12150 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12151 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12154 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12155 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12156 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12157 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12158 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12159 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12163 if (unformat (i, "del"))
12165 if (unformat (i, "outbound"))
12167 if (unformat (i, "inbound"))
12169 else if (unformat (i, "spd_id %d", &spd_id))
12171 else if (unformat (i, "sa_id %d", &sa_id))
12173 else if (unformat (i, "priority %d", &priority))
12175 else if (unformat (i, "protocol %d", &protocol))
12177 else if (unformat (i, "lport_start %d", &lport_start))
12179 else if (unformat (i, "lport_stop %d", &lport_stop))
12181 else if (unformat (i, "rport_start %d", &rport_start))
12183 else if (unformat (i, "rport_stop %d", &rport_stop))
12187 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12193 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12200 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12206 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12213 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12219 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12226 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12232 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12238 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12240 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12242 clib_warning ("unsupported action: 'resolve'");
12248 clib_warning ("parse error '%U'", format_unformat_error, i);
12254 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12256 mp->spd_id = ntohl (spd_id);
12257 mp->priority = ntohl (priority);
12258 mp->is_outbound = is_outbound;
12260 mp->is_ipv6 = is_ipv6;
12261 if (is_ipv6 || is_ip_any)
12263 clib_memcpy (mp->remote_address_start, &raddr6_start,
12264 sizeof (ip6_address_t));
12265 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12266 sizeof (ip6_address_t));
12267 clib_memcpy (mp->local_address_start, &laddr6_start,
12268 sizeof (ip6_address_t));
12269 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12270 sizeof (ip6_address_t));
12274 clib_memcpy (mp->remote_address_start, &raddr4_start,
12275 sizeof (ip4_address_t));
12276 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12277 sizeof (ip4_address_t));
12278 clib_memcpy (mp->local_address_start, &laddr4_start,
12279 sizeof (ip4_address_t));
12280 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12281 sizeof (ip4_address_t));
12283 mp->protocol = (u8) protocol;
12284 mp->local_port_start = ntohs ((u16) lport_start);
12285 mp->local_port_stop = ntohs ((u16) lport_stop);
12286 mp->remote_port_start = ntohs ((u16) rport_start);
12287 mp->remote_port_stop = ntohs ((u16) rport_stop);
12288 mp->policy = (u8) policy;
12289 mp->sa_id = ntohl (sa_id);
12290 mp->is_add = is_add;
12291 mp->is_ip_any = is_ip_any;
12298 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12300 unformat_input_t *i = vam->input;
12301 vl_api_ipsec_sad_add_del_entry_t *mp;
12302 u32 sad_id = 0, spi = 0;
12303 u8 *ck = 0, *ik = 0;
12306 u8 protocol = IPSEC_PROTOCOL_AH;
12307 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12308 u32 crypto_alg = 0, integ_alg = 0;
12309 ip4_address_t tun_src4;
12310 ip4_address_t tun_dst4;
12311 ip6_address_t tun_src6;
12312 ip6_address_t tun_dst6;
12315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12317 if (unformat (i, "del"))
12319 else if (unformat (i, "sad_id %d", &sad_id))
12321 else if (unformat (i, "spi %d", &spi))
12323 else if (unformat (i, "esp"))
12324 protocol = IPSEC_PROTOCOL_ESP;
12325 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12328 is_tunnel_ipv6 = 0;
12330 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12333 is_tunnel_ipv6 = 0;
12335 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12338 is_tunnel_ipv6 = 1;
12340 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12343 is_tunnel_ipv6 = 1;
12347 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12349 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12350 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12352 clib_warning ("unsupported crypto-alg: '%U'",
12353 format_ipsec_crypto_alg, crypto_alg);
12357 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12361 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12363 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12364 integ_alg >= IPSEC_INTEG_N_ALG)
12366 clib_warning ("unsupported integ-alg: '%U'",
12367 format_ipsec_integ_alg, integ_alg);
12371 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12375 clib_warning ("parse error '%U'", format_unformat_error, i);
12381 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12383 mp->sad_id = ntohl (sad_id);
12384 mp->is_add = is_add;
12385 mp->protocol = protocol;
12386 mp->spi = ntohl (spi);
12387 mp->is_tunnel = is_tunnel;
12388 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12389 mp->crypto_algorithm = crypto_alg;
12390 mp->integrity_algorithm = integ_alg;
12391 mp->crypto_key_length = vec_len (ck);
12392 mp->integrity_key_length = vec_len (ik);
12394 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12395 mp->crypto_key_length = sizeof (mp->crypto_key);
12397 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12398 mp->integrity_key_length = sizeof (mp->integrity_key);
12401 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12403 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12407 if (is_tunnel_ipv6)
12409 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12410 sizeof (ip6_address_t));
12411 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12412 sizeof (ip6_address_t));
12416 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12417 sizeof (ip4_address_t));
12418 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12419 sizeof (ip4_address_t));
12429 api_ipsec_sa_set_key (vat_main_t * vam)
12431 unformat_input_t *i = vam->input;
12432 vl_api_ipsec_sa_set_key_t *mp;
12434 u8 *ck = 0, *ik = 0;
12437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12439 if (unformat (i, "sa_id %d", &sa_id))
12441 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12443 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12447 clib_warning ("parse error '%U'", format_unformat_error, i);
12452 M (IPSEC_SA_SET_KEY, mp);
12454 mp->sa_id = ntohl (sa_id);
12455 mp->crypto_key_length = vec_len (ck);
12456 mp->integrity_key_length = vec_len (ik);
12458 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12459 mp->crypto_key_length = sizeof (mp->crypto_key);
12461 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12462 mp->integrity_key_length = sizeof (mp->integrity_key);
12465 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12467 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12475 api_ikev2_profile_add_del (vat_main_t * vam)
12477 unformat_input_t *i = vam->input;
12478 vl_api_ikev2_profile_add_del_t *mp;
12483 const char *valid_chars = "a-zA-Z0-9_";
12485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12487 if (unformat (i, "del"))
12489 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12490 vec_add1 (name, 0);
12493 errmsg ("parse error '%U'", format_unformat_error, i);
12498 if (!vec_len (name))
12500 errmsg ("profile name must be specified");
12504 if (vec_len (name) > 64)
12506 errmsg ("profile name too long");
12510 M (IKEV2_PROFILE_ADD_DEL, mp);
12512 clib_memcpy (mp->name, name, vec_len (name));
12513 mp->is_add = is_add;
12522 api_ikev2_profile_set_auth (vat_main_t * vam)
12524 unformat_input_t *i = vam->input;
12525 vl_api_ikev2_profile_set_auth_t *mp;
12528 u32 auth_method = 0;
12532 const char *valid_chars = "a-zA-Z0-9_";
12534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12536 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12537 vec_add1 (name, 0);
12538 else if (unformat (i, "auth_method %U",
12539 unformat_ikev2_auth_method, &auth_method))
12541 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12543 else if (unformat (i, "auth_data %v", &data))
12547 errmsg ("parse error '%U'", format_unformat_error, i);
12552 if (!vec_len (name))
12554 errmsg ("profile name must be specified");
12558 if (vec_len (name) > 64)
12560 errmsg ("profile name too long");
12564 if (!vec_len (data))
12566 errmsg ("auth_data must be specified");
12572 errmsg ("auth_method must be specified");
12576 M (IKEV2_PROFILE_SET_AUTH, mp);
12578 mp->is_hex = is_hex;
12579 mp->auth_method = (u8) auth_method;
12580 mp->data_len = vec_len (data);
12581 clib_memcpy (mp->name, name, vec_len (name));
12582 clib_memcpy (mp->data, data, vec_len (data));
12592 api_ikev2_profile_set_id (vat_main_t * vam)
12594 unformat_input_t *i = vam->input;
12595 vl_api_ikev2_profile_set_id_t *mp;
12603 const char *valid_chars = "a-zA-Z0-9_";
12605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12607 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12608 vec_add1 (name, 0);
12609 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12611 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12613 data = vec_new (u8, 4);
12614 clib_memcpy (data, ip4.as_u8, 4);
12616 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12618 else if (unformat (i, "id_data %v", &data))
12620 else if (unformat (i, "local"))
12622 else if (unformat (i, "remote"))
12626 errmsg ("parse error '%U'", format_unformat_error, i);
12631 if (!vec_len (name))
12633 errmsg ("profile name must be specified");
12637 if (vec_len (name) > 64)
12639 errmsg ("profile name too long");
12643 if (!vec_len (data))
12645 errmsg ("id_data must be specified");
12651 errmsg ("id_type must be specified");
12655 M (IKEV2_PROFILE_SET_ID, mp);
12657 mp->is_local = is_local;
12658 mp->id_type = (u8) id_type;
12659 mp->data_len = vec_len (data);
12660 clib_memcpy (mp->name, name, vec_len (name));
12661 clib_memcpy (mp->data, data, vec_len (data));
12671 api_ikev2_profile_set_ts (vat_main_t * vam)
12673 unformat_input_t *i = vam->input;
12674 vl_api_ikev2_profile_set_ts_t *mp;
12677 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12678 ip4_address_t start_addr, end_addr;
12680 const char *valid_chars = "a-zA-Z0-9_";
12683 start_addr.as_u32 = 0;
12684 end_addr.as_u32 = (u32) ~ 0;
12686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12688 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12689 vec_add1 (name, 0);
12690 else if (unformat (i, "protocol %d", &proto))
12692 else if (unformat (i, "start_port %d", &start_port))
12694 else if (unformat (i, "end_port %d", &end_port))
12697 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12699 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12701 else if (unformat (i, "local"))
12703 else if (unformat (i, "remote"))
12707 errmsg ("parse error '%U'", format_unformat_error, i);
12712 if (!vec_len (name))
12714 errmsg ("profile name must be specified");
12718 if (vec_len (name) > 64)
12720 errmsg ("profile name too long");
12724 M (IKEV2_PROFILE_SET_TS, mp);
12726 mp->is_local = is_local;
12727 mp->proto = (u8) proto;
12728 mp->start_port = (u16) start_port;
12729 mp->end_port = (u16) end_port;
12730 mp->start_addr = start_addr.as_u32;
12731 mp->end_addr = end_addr.as_u32;
12732 clib_memcpy (mp->name, name, vec_len (name));
12741 api_ikev2_set_local_key (vat_main_t * vam)
12743 unformat_input_t *i = vam->input;
12744 vl_api_ikev2_set_local_key_t *mp;
12748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12750 if (unformat (i, "file %v", &file))
12751 vec_add1 (file, 0);
12754 errmsg ("parse error '%U'", format_unformat_error, i);
12759 if (!vec_len (file))
12761 errmsg ("RSA key file must be specified");
12765 if (vec_len (file) > 256)
12767 errmsg ("file name too long");
12771 M (IKEV2_SET_LOCAL_KEY, mp);
12773 clib_memcpy (mp->key_file, file, vec_len (file));
12782 api_ikev2_set_responder (vat_main_t * vam)
12784 unformat_input_t *i = vam->input;
12785 vl_api_ikev2_set_responder_t *mp;
12788 u32 sw_if_index = ~0;
12789 ip4_address_t address;
12791 const char *valid_chars = "a-zA-Z0-9_";
12793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12796 (i, "%U interface %d address %U", unformat_token, valid_chars,
12797 &name, &sw_if_index, unformat_ip4_address, &address))
12798 vec_add1 (name, 0);
12801 errmsg ("parse error '%U'", format_unformat_error, i);
12806 if (!vec_len (name))
12808 errmsg ("profile name must be specified");
12812 if (vec_len (name) > 64)
12814 errmsg ("profile name too long");
12818 M (IKEV2_SET_RESPONDER, mp);
12820 clib_memcpy (mp->name, name, vec_len (name));
12823 mp->sw_if_index = sw_if_index;
12824 clib_memcpy (mp->address, &address, sizeof (address));
12832 api_ikev2_set_ike_transforms (vat_main_t * vam)
12834 unformat_input_t *i = vam->input;
12835 vl_api_ikev2_set_ike_transforms_t *mp;
12838 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12840 const char *valid_chars = "a-zA-Z0-9_";
12842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12844 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12845 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12846 vec_add1 (name, 0);
12849 errmsg ("parse error '%U'", format_unformat_error, i);
12854 if (!vec_len (name))
12856 errmsg ("profile name must be specified");
12860 if (vec_len (name) > 64)
12862 errmsg ("profile name too long");
12866 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12868 clib_memcpy (mp->name, name, vec_len (name));
12870 mp->crypto_alg = crypto_alg;
12871 mp->crypto_key_size = crypto_key_size;
12872 mp->integ_alg = integ_alg;
12873 mp->dh_group = dh_group;
12882 api_ikev2_set_esp_transforms (vat_main_t * vam)
12884 unformat_input_t *i = vam->input;
12885 vl_api_ikev2_set_esp_transforms_t *mp;
12888 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12890 const char *valid_chars = "a-zA-Z0-9_";
12892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12894 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12895 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12896 vec_add1 (name, 0);
12899 errmsg ("parse error '%U'", format_unformat_error, i);
12904 if (!vec_len (name))
12906 errmsg ("profile name must be specified");
12910 if (vec_len (name) > 64)
12912 errmsg ("profile name too long");
12916 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12918 clib_memcpy (mp->name, name, vec_len (name));
12920 mp->crypto_alg = crypto_alg;
12921 mp->crypto_key_size = crypto_key_size;
12922 mp->integ_alg = integ_alg;
12923 mp->dh_group = dh_group;
12931 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12933 unformat_input_t *i = vam->input;
12934 vl_api_ikev2_set_sa_lifetime_t *mp;
12937 u64 lifetime, lifetime_maxdata;
12938 u32 lifetime_jitter, handover;
12940 const char *valid_chars = "a-zA-Z0-9_";
12942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12944 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12945 &lifetime, &lifetime_jitter, &handover,
12946 &lifetime_maxdata))
12947 vec_add1 (name, 0);
12950 errmsg ("parse error '%U'", format_unformat_error, i);
12955 if (!vec_len (name))
12957 errmsg ("profile name must be specified");
12961 if (vec_len (name) > 64)
12963 errmsg ("profile name too long");
12967 M (IKEV2_SET_SA_LIFETIME, mp);
12969 clib_memcpy (mp->name, name, vec_len (name));
12971 mp->lifetime = lifetime;
12972 mp->lifetime_jitter = lifetime_jitter;
12973 mp->handover = handover;
12974 mp->lifetime_maxdata = lifetime_maxdata;
12982 api_ikev2_initiate_sa_init (vat_main_t * vam)
12984 unformat_input_t *i = vam->input;
12985 vl_api_ikev2_initiate_sa_init_t *mp;
12989 const char *valid_chars = "a-zA-Z0-9_";
12991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12993 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12994 vec_add1 (name, 0);
12997 errmsg ("parse error '%U'", format_unformat_error, i);
13002 if (!vec_len (name))
13004 errmsg ("profile name must be specified");
13008 if (vec_len (name) > 64)
13010 errmsg ("profile name too long");
13014 M (IKEV2_INITIATE_SA_INIT, mp);
13016 clib_memcpy (mp->name, name, vec_len (name));
13025 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13027 unformat_input_t *i = vam->input;
13028 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13035 if (unformat (i, "%lx", &ispi))
13039 errmsg ("parse error '%U'", format_unformat_error, i);
13044 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13054 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13056 unformat_input_t *i = vam->input;
13057 vl_api_ikev2_initiate_del_child_sa_t *mp;
13062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13064 if (unformat (i, "%x", &ispi))
13068 errmsg ("parse error '%U'", format_unformat_error, i);
13073 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13083 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13085 unformat_input_t *i = vam->input;
13086 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13093 if (unformat (i, "%x", &ispi))
13097 errmsg ("parse error '%U'", format_unformat_error, i);
13102 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13115 api_map_add_domain (vat_main_t * vam)
13117 unformat_input_t *i = vam->input;
13118 vl_api_map_add_domain_t *mp;
13120 ip4_address_t ip4_prefix;
13121 ip6_address_t ip6_prefix;
13122 ip6_address_t ip6_src;
13123 u32 num_m_args = 0;
13124 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13125 0, psid_length = 0;
13126 u8 is_translation = 0;
13128 u32 ip6_src_len = 128;
13131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13133 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13134 &ip4_prefix, &ip4_prefix_len))
13136 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13137 &ip6_prefix, &ip6_prefix_len))
13141 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13144 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13146 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13148 else if (unformat (i, "psid-offset %d", &psid_offset))
13150 else if (unformat (i, "psid-len %d", &psid_length))
13152 else if (unformat (i, "mtu %d", &mtu))
13154 else if (unformat (i, "map-t"))
13155 is_translation = 1;
13158 clib_warning ("parse error '%U'", format_unformat_error, i);
13163 if (num_m_args < 3)
13165 errmsg ("mandatory argument(s) missing");
13169 /* Construct the API message */
13170 M (MAP_ADD_DOMAIN, mp);
13172 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13173 mp->ip4_prefix_len = ip4_prefix_len;
13175 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13176 mp->ip6_prefix_len = ip6_prefix_len;
13178 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13179 mp->ip6_src_prefix_len = ip6_src_len;
13181 mp->ea_bits_len = ea_bits_len;
13182 mp->psid_offset = psid_offset;
13183 mp->psid_length = psid_length;
13184 mp->is_translation = is_translation;
13185 mp->mtu = htons (mtu);
13190 /* Wait for a reply, return good/bad news */
13196 api_map_del_domain (vat_main_t * vam)
13198 unformat_input_t *i = vam->input;
13199 vl_api_map_del_domain_t *mp;
13201 u32 num_m_args = 0;
13205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13207 if (unformat (i, "index %d", &index))
13211 clib_warning ("parse error '%U'", format_unformat_error, i);
13216 if (num_m_args != 1)
13218 errmsg ("mandatory argument(s) missing");
13222 /* Construct the API message */
13223 M (MAP_DEL_DOMAIN, mp);
13225 mp->index = ntohl (index);
13230 /* Wait for a reply, return good/bad news */
13236 api_map_add_del_rule (vat_main_t * vam)
13238 unformat_input_t *i = vam->input;
13239 vl_api_map_add_del_rule_t *mp;
13241 ip6_address_t ip6_dst;
13242 u32 num_m_args = 0, index, psid = 0;
13245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13247 if (unformat (i, "index %d", &index))
13249 else if (unformat (i, "psid %d", &psid))
13251 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13253 else if (unformat (i, "del"))
13259 clib_warning ("parse error '%U'", format_unformat_error, i);
13264 /* Construct the API message */
13265 M (MAP_ADD_DEL_RULE, mp);
13267 mp->index = ntohl (index);
13268 mp->is_add = is_add;
13269 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13270 mp->psid = ntohs (psid);
13275 /* Wait for a reply, return good/bad news */
13281 api_map_domain_dump (vat_main_t * vam)
13283 vl_api_map_domain_dump_t *mp;
13284 vl_api_control_ping_t *mp_ping;
13287 /* Construct the API message */
13288 M (MAP_DOMAIN_DUMP, mp);
13293 /* Use a control ping for synchronization */
13294 M (CONTROL_PING, mp_ping);
13302 api_map_rule_dump (vat_main_t * vam)
13304 unformat_input_t *i = vam->input;
13305 vl_api_map_rule_dump_t *mp;
13306 vl_api_control_ping_t *mp_ping;
13307 u32 domain_index = ~0;
13310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13312 if (unformat (i, "index %u", &domain_index))
13318 if (domain_index == ~0)
13320 clib_warning ("parse error: domain index expected");
13324 /* Construct the API message */
13325 M (MAP_RULE_DUMP, mp);
13327 mp->domain_index = htonl (domain_index);
13332 /* Use a control ping for synchronization */
13333 M (CONTROL_PING, mp_ping);
13340 static void vl_api_map_add_domain_reply_t_handler
13341 (vl_api_map_add_domain_reply_t * mp)
13343 vat_main_t *vam = &vat_main;
13344 i32 retval = ntohl (mp->retval);
13346 if (vam->async_mode)
13348 vam->async_errors += (retval < 0);
13352 vam->retval = retval;
13353 vam->result_ready = 1;
13357 static void vl_api_map_add_domain_reply_t_handler_json
13358 (vl_api_map_add_domain_reply_t * mp)
13360 vat_main_t *vam = &vat_main;
13361 vat_json_node_t node;
13363 vat_json_init_object (&node);
13364 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13365 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13367 vat_json_print (vam->ofp, &node);
13368 vat_json_free (&node);
13370 vam->retval = ntohl (mp->retval);
13371 vam->result_ready = 1;
13375 api_get_first_msg_id (vat_main_t * vam)
13377 vl_api_get_first_msg_id_t *mp;
13378 unformat_input_t *i = vam->input;
13383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13385 if (unformat (i, "client %s", &name))
13393 errmsg ("missing client name");
13396 vec_add1 (name, 0);
13398 if (vec_len (name) > 63)
13400 errmsg ("client name too long");
13404 M (GET_FIRST_MSG_ID, mp);
13405 clib_memcpy (mp->name, name, vec_len (name));
13412 api_cop_interface_enable_disable (vat_main_t * vam)
13414 unformat_input_t *line_input = vam->input;
13415 vl_api_cop_interface_enable_disable_t *mp;
13416 u32 sw_if_index = ~0;
13417 u8 enable_disable = 1;
13420 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13422 if (unformat (line_input, "disable"))
13423 enable_disable = 0;
13424 if (unformat (line_input, "enable"))
13425 enable_disable = 1;
13426 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13427 vam, &sw_if_index))
13429 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13435 if (sw_if_index == ~0)
13437 errmsg ("missing interface name or sw_if_index");
13441 /* Construct the API message */
13442 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13443 mp->sw_if_index = ntohl (sw_if_index);
13444 mp->enable_disable = enable_disable;
13448 /* Wait for the reply */
13454 api_cop_whitelist_enable_disable (vat_main_t * vam)
13456 unformat_input_t *line_input = vam->input;
13457 vl_api_cop_whitelist_enable_disable_t *mp;
13458 u32 sw_if_index = ~0;
13459 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13463 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13465 if (unformat (line_input, "ip4"))
13467 else if (unformat (line_input, "ip6"))
13469 else if (unformat (line_input, "default"))
13471 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13472 vam, &sw_if_index))
13474 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13476 else if (unformat (line_input, "fib-id %d", &fib_id))
13482 if (sw_if_index == ~0)
13484 errmsg ("missing interface name or sw_if_index");
13488 /* Construct the API message */
13489 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13490 mp->sw_if_index = ntohl (sw_if_index);
13491 mp->fib_id = ntohl (fib_id);
13494 mp->default_cop = default_cop;
13498 /* Wait for the reply */
13504 api_get_node_graph (vat_main_t * vam)
13506 vl_api_get_node_graph_t *mp;
13509 M (GET_NODE_GRAPH, mp);
13513 /* Wait for the reply */
13519 /** Used for parsing LISP eids */
13520 typedef CLIB_PACKED(struct{
13521 u8 addr[16]; /**< eid address */
13522 u32 len; /**< prefix length if IP */
13523 u8 type; /**< type of eid */
13528 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13530 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13532 memset (a, 0, sizeof (a[0]));
13534 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13536 a->type = 0; /* ipv4 type */
13538 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13540 a->type = 1; /* ipv6 type */
13542 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13544 a->type = 2; /* mac type */
13551 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13560 lisp_eid_size_vat (u8 type)
13575 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13577 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13581 api_one_add_del_locator_set (vat_main_t * vam)
13583 unformat_input_t *input = vam->input;
13584 vl_api_one_add_del_locator_set_t *mp;
13586 u8 *locator_set_name = NULL;
13587 u8 locator_set_name_set = 0;
13588 vl_api_local_locator_t locator, *locators = 0;
13589 u32 sw_if_index, priority, weight;
13593 /* Parse args required to build the message */
13594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13596 if (unformat (input, "del"))
13600 else if (unformat (input, "locator-set %s", &locator_set_name))
13602 locator_set_name_set = 1;
13604 else if (unformat (input, "sw_if_index %u p %u w %u",
13605 &sw_if_index, &priority, &weight))
13607 locator.sw_if_index = htonl (sw_if_index);
13608 locator.priority = priority;
13609 locator.weight = weight;
13610 vec_add1 (locators, locator);
13614 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13615 &sw_if_index, &priority, &weight))
13617 locator.sw_if_index = htonl (sw_if_index);
13618 locator.priority = priority;
13619 locator.weight = weight;
13620 vec_add1 (locators, locator);
13626 if (locator_set_name_set == 0)
13628 errmsg ("missing locator-set name");
13629 vec_free (locators);
13633 if (vec_len (locator_set_name) > 64)
13635 errmsg ("locator-set name too long");
13636 vec_free (locator_set_name);
13637 vec_free (locators);
13640 vec_add1 (locator_set_name, 0);
13642 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13644 /* Construct the API message */
13645 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13647 mp->is_add = is_add;
13648 clib_memcpy (mp->locator_set_name, locator_set_name,
13649 vec_len (locator_set_name));
13650 vec_free (locator_set_name);
13652 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13654 clib_memcpy (mp->locators, locators, data_len);
13655 vec_free (locators);
13660 /* Wait for a reply... */
13665 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13668 api_one_add_del_locator (vat_main_t * vam)
13670 unformat_input_t *input = vam->input;
13671 vl_api_one_add_del_locator_t *mp;
13672 u32 tmp_if_index = ~0;
13673 u32 sw_if_index = ~0;
13674 u8 sw_if_index_set = 0;
13675 u8 sw_if_index_if_name_set = 0;
13677 u8 priority_set = 0;
13681 u8 *locator_set_name = NULL;
13682 u8 locator_set_name_set = 0;
13685 /* Parse args required to build the message */
13686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13688 if (unformat (input, "del"))
13692 else if (unformat (input, "locator-set %s", &locator_set_name))
13694 locator_set_name_set = 1;
13696 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13699 sw_if_index_if_name_set = 1;
13700 sw_if_index = tmp_if_index;
13702 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13704 sw_if_index_set = 1;
13705 sw_if_index = tmp_if_index;
13707 else if (unformat (input, "p %d", &priority))
13711 else if (unformat (input, "w %d", &weight))
13719 if (locator_set_name_set == 0)
13721 errmsg ("missing locator-set name");
13725 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13727 errmsg ("missing sw_if_index");
13728 vec_free (locator_set_name);
13732 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13734 errmsg ("cannot use both params interface name and sw_if_index");
13735 vec_free (locator_set_name);
13739 if (priority_set == 0)
13741 errmsg ("missing locator-set priority");
13742 vec_free (locator_set_name);
13746 if (weight_set == 0)
13748 errmsg ("missing locator-set weight");
13749 vec_free (locator_set_name);
13753 if (vec_len (locator_set_name) > 64)
13755 errmsg ("locator-set name too long");
13756 vec_free (locator_set_name);
13759 vec_add1 (locator_set_name, 0);
13761 /* Construct the API message */
13762 M (ONE_ADD_DEL_LOCATOR, mp);
13764 mp->is_add = is_add;
13765 mp->sw_if_index = ntohl (sw_if_index);
13766 mp->priority = priority;
13767 mp->weight = weight;
13768 clib_memcpy (mp->locator_set_name, locator_set_name,
13769 vec_len (locator_set_name));
13770 vec_free (locator_set_name);
13775 /* Wait for a reply... */
13780 #define api_lisp_add_del_locator api_one_add_del_locator
13783 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13785 u32 *key_id = va_arg (*args, u32 *);
13788 if (unformat (input, "%s", &s))
13790 if (!strcmp ((char *) s, "sha1"))
13791 key_id[0] = HMAC_SHA_1_96;
13792 else if (!strcmp ((char *) s, "sha256"))
13793 key_id[0] = HMAC_SHA_256_128;
13796 clib_warning ("invalid key_id: '%s'", s);
13797 key_id[0] = HMAC_NO_KEY;
13808 api_one_add_del_local_eid (vat_main_t * vam)
13810 unformat_input_t *input = vam->input;
13811 vl_api_one_add_del_local_eid_t *mp;
13814 lisp_eid_vat_t _eid, *eid = &_eid;
13815 u8 *locator_set_name = 0;
13816 u8 locator_set_name_set = 0;
13822 /* Parse args required to build the message */
13823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13825 if (unformat (input, "del"))
13829 else if (unformat (input, "vni %d", &vni))
13833 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13837 else if (unformat (input, "locator-set %s", &locator_set_name))
13839 locator_set_name_set = 1;
13841 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13843 else if (unformat (input, "secret-key %_%v%_", &key))
13849 if (locator_set_name_set == 0)
13851 errmsg ("missing locator-set name");
13857 errmsg ("EID address not set!");
13858 vec_free (locator_set_name);
13862 if (key && (0 == key_id))
13864 errmsg ("invalid key_id!");
13868 if (vec_len (key) > 64)
13870 errmsg ("key too long");
13875 if (vec_len (locator_set_name) > 64)
13877 errmsg ("locator-set name too long");
13878 vec_free (locator_set_name);
13881 vec_add1 (locator_set_name, 0);
13883 /* Construct the API message */
13884 M (ONE_ADD_DEL_LOCAL_EID, mp);
13886 mp->is_add = is_add;
13887 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13888 mp->eid_type = eid->type;
13889 mp->prefix_len = eid->len;
13890 mp->vni = clib_host_to_net_u32 (vni);
13891 mp->key_id = clib_host_to_net_u16 (key_id);
13892 clib_memcpy (mp->locator_set_name, locator_set_name,
13893 vec_len (locator_set_name));
13894 clib_memcpy (mp->key, key, vec_len (key));
13896 vec_free (locator_set_name);
13902 /* Wait for a reply... */
13907 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13910 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13912 u32 dp_table = 0, vni = 0;;
13913 unformat_input_t *input = vam->input;
13914 vl_api_gpe_add_del_fwd_entry_t *mp;
13916 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13917 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13918 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13919 u32 action = ~0, w;
13920 ip4_address_t rmt_rloc4, lcl_rloc4;
13921 ip6_address_t rmt_rloc6, lcl_rloc6;
13922 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13925 memset (&rloc, 0, sizeof (rloc));
13927 /* Parse args required to build the message */
13928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13930 if (unformat (input, "del"))
13932 else if (unformat (input, "add"))
13934 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13938 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13942 else if (unformat (input, "vrf %d", &dp_table))
13944 else if (unformat (input, "bd %d", &dp_table))
13946 else if (unformat (input, "vni %d", &vni))
13948 else if (unformat (input, "w %d", &w))
13952 errmsg ("No RLOC configured for setting priority/weight!");
13955 curr_rloc->weight = w;
13957 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13958 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13962 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13964 vec_add1 (lcl_locs, rloc);
13966 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13967 vec_add1 (rmt_locs, rloc);
13968 /* weight saved in rmt loc */
13969 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13971 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13972 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13975 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13977 vec_add1 (lcl_locs, rloc);
13979 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13980 vec_add1 (rmt_locs, rloc);
13981 /* weight saved in rmt loc */
13982 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13984 else if (unformat (input, "action %d", &action))
13990 clib_warning ("parse error '%U'", format_unformat_error, input);
13997 errmsg ("remote eid addresses not set");
14001 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14003 errmsg ("eid types don't match");
14007 if (0 == rmt_locs && (u32) ~ 0 == action)
14009 errmsg ("action not set for negative mapping");
14013 /* Construct the API message */
14014 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14015 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14017 mp->is_add = is_add;
14018 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14019 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14020 mp->eid_type = rmt_eid->type;
14021 mp->dp_table = clib_host_to_net_u32 (dp_table);
14022 mp->vni = clib_host_to_net_u32 (vni);
14023 mp->rmt_len = rmt_eid->len;
14024 mp->lcl_len = lcl_eid->len;
14025 mp->action = action;
14027 if (0 != rmt_locs && 0 != lcl_locs)
14029 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14030 clib_memcpy (mp->locs, lcl_locs,
14031 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14033 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14034 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14035 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14037 vec_free (lcl_locs);
14038 vec_free (rmt_locs);
14043 /* Wait for a reply... */
14049 api_one_add_del_map_server (vat_main_t * vam)
14051 unformat_input_t *input = vam->input;
14052 vl_api_one_add_del_map_server_t *mp;
14056 ip4_address_t ipv4;
14057 ip6_address_t ipv6;
14060 /* Parse args required to build the message */
14061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14063 if (unformat (input, "del"))
14067 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14071 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14079 if (ipv4_set && ipv6_set)
14081 errmsg ("both eid v4 and v6 addresses set");
14085 if (!ipv4_set && !ipv6_set)
14087 errmsg ("eid addresses not set");
14091 /* Construct the API message */
14092 M (ONE_ADD_DEL_MAP_SERVER, mp);
14094 mp->is_add = is_add;
14098 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14103 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14109 /* Wait for a reply... */
14114 #define api_lisp_add_del_map_server api_one_add_del_map_server
14117 api_one_add_del_map_resolver (vat_main_t * vam)
14119 unformat_input_t *input = vam->input;
14120 vl_api_one_add_del_map_resolver_t *mp;
14124 ip4_address_t ipv4;
14125 ip6_address_t ipv6;
14128 /* Parse args required to build the message */
14129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14131 if (unformat (input, "del"))
14135 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14139 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14147 if (ipv4_set && ipv6_set)
14149 errmsg ("both eid v4 and v6 addresses set");
14153 if (!ipv4_set && !ipv6_set)
14155 errmsg ("eid addresses not set");
14159 /* Construct the API message */
14160 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14162 mp->is_add = is_add;
14166 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14171 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14177 /* Wait for a reply... */
14182 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14185 api_lisp_gpe_enable_disable (vat_main_t * vam)
14187 unformat_input_t *input = vam->input;
14188 vl_api_gpe_enable_disable_t *mp;
14193 /* Parse args required to build the message */
14194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14196 if (unformat (input, "enable"))
14201 else if (unformat (input, "disable"))
14212 errmsg ("Value not set");
14216 /* Construct the API message */
14217 M (GPE_ENABLE_DISABLE, mp);
14224 /* Wait for a reply... */
14230 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14232 unformat_input_t *input = vam->input;
14233 vl_api_one_rloc_probe_enable_disable_t *mp;
14238 /* Parse args required to build the message */
14239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14241 if (unformat (input, "enable"))
14246 else if (unformat (input, "disable"))
14254 errmsg ("Value not set");
14258 /* Construct the API message */
14259 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14261 mp->is_enabled = is_en;
14266 /* Wait for a reply... */
14271 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14274 api_one_map_register_enable_disable (vat_main_t * vam)
14276 unformat_input_t *input = vam->input;
14277 vl_api_one_map_register_enable_disable_t *mp;
14282 /* Parse args required to build the message */
14283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14285 if (unformat (input, "enable"))
14290 else if (unformat (input, "disable"))
14298 errmsg ("Value not set");
14302 /* Construct the API message */
14303 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14305 mp->is_enabled = is_en;
14310 /* Wait for a reply... */
14315 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14318 api_one_enable_disable (vat_main_t * vam)
14320 unformat_input_t *input = vam->input;
14321 vl_api_one_enable_disable_t *mp;
14326 /* Parse args required to build the message */
14327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14329 if (unformat (input, "enable"))
14334 else if (unformat (input, "disable"))
14344 errmsg ("Value not set");
14348 /* Construct the API message */
14349 M (ONE_ENABLE_DISABLE, mp);
14356 /* Wait for a reply... */
14361 #define api_lisp_enable_disable api_one_enable_disable
14364 api_show_one_map_register_state (vat_main_t * vam)
14366 vl_api_show_one_map_register_state_t *mp;
14369 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14374 /* wait for reply */
14379 #define api_show_lisp_map_register_state api_show_one_map_register_state
14382 api_show_one_rloc_probe_state (vat_main_t * vam)
14384 vl_api_show_one_rloc_probe_state_t *mp;
14387 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14392 /* wait for reply */
14397 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14400 api_show_one_map_request_mode (vat_main_t * vam)
14402 vl_api_show_one_map_request_mode_t *mp;
14405 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14410 /* wait for reply */
14415 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14418 api_one_map_request_mode (vat_main_t * vam)
14420 unformat_input_t *input = vam->input;
14421 vl_api_one_map_request_mode_t *mp;
14425 /* Parse args required to build the message */
14426 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14428 if (unformat (input, "dst-only"))
14430 else if (unformat (input, "src-dst"))
14434 errmsg ("parse error '%U'", format_unformat_error, input);
14439 M (ONE_MAP_REQUEST_MODE, mp);
14446 /* wait for reply */
14451 #define api_lisp_map_request_mode api_one_map_request_mode
14454 * Enable/disable ONE proxy ITR.
14456 * @param vam vpp API test context
14457 * @return return code
14460 api_one_pitr_set_locator_set (vat_main_t * vam)
14462 u8 ls_name_set = 0;
14463 unformat_input_t *input = vam->input;
14464 vl_api_one_pitr_set_locator_set_t *mp;
14469 /* Parse args required to build the message */
14470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14472 if (unformat (input, "del"))
14474 else if (unformat (input, "locator-set %s", &ls_name))
14478 errmsg ("parse error '%U'", format_unformat_error, input);
14485 errmsg ("locator-set name not set!");
14489 M (ONE_PITR_SET_LOCATOR_SET, mp);
14491 mp->is_add = is_add;
14492 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14493 vec_free (ls_name);
14498 /* wait for reply */
14503 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14506 api_show_one_pitr (vat_main_t * vam)
14508 vl_api_show_one_pitr_t *mp;
14511 if (!vam->json_output)
14513 print (vam->ofp, "%=20s", "lisp status:");
14516 M (SHOW_ONE_PITR, mp);
14520 /* Wait for a reply... */
14525 #define api_show_lisp_pitr api_show_one_pitr
14528 * Add/delete mapping between vni and vrf
14531 api_one_eid_table_add_del_map (vat_main_t * vam)
14533 unformat_input_t *input = vam->input;
14534 vl_api_one_eid_table_add_del_map_t *mp;
14535 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14536 u32 vni, vrf, bd_index;
14539 /* Parse args required to build the message */
14540 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14542 if (unformat (input, "del"))
14544 else if (unformat (input, "vrf %d", &vrf))
14546 else if (unformat (input, "bd_index %d", &bd_index))
14548 else if (unformat (input, "vni %d", &vni))
14554 if (!vni_set || (!vrf_set && !bd_index_set))
14556 errmsg ("missing arguments!");
14560 if (vrf_set && bd_index_set)
14562 errmsg ("error: both vrf and bd entered!");
14566 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14568 mp->is_add = is_add;
14569 mp->vni = htonl (vni);
14570 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14571 mp->is_l2 = bd_index_set;
14576 /* wait for reply */
14581 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14584 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14586 u32 *action = va_arg (*args, u32 *);
14589 if (unformat (input, "%s", &s))
14591 if (!strcmp ((char *) s, "no-action"))
14593 else if (!strcmp ((char *) s, "natively-forward"))
14595 else if (!strcmp ((char *) s, "send-map-request"))
14597 else if (!strcmp ((char *) s, "drop"))
14601 clib_warning ("invalid action: '%s'", s);
14613 * Add/del remote mapping to/from ONE control plane
14615 * @param vam vpp API test context
14616 * @return return code
14619 api_one_add_del_remote_mapping (vat_main_t * vam)
14621 unformat_input_t *input = vam->input;
14622 vl_api_one_add_del_remote_mapping_t *mp;
14624 lisp_eid_vat_t _eid, *eid = &_eid;
14625 lisp_eid_vat_t _seid, *seid = &_seid;
14626 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14627 u32 action = ~0, p, w, data_len;
14628 ip4_address_t rloc4;
14629 ip6_address_t rloc6;
14630 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14633 memset (&rloc, 0, sizeof (rloc));
14635 /* Parse args required to build the message */
14636 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14638 if (unformat (input, "del-all"))
14642 else if (unformat (input, "del"))
14646 else if (unformat (input, "add"))
14650 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14654 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14658 else if (unformat (input, "vni %d", &vni))
14662 else if (unformat (input, "p %d w %d", &p, &w))
14666 errmsg ("No RLOC configured for setting priority/weight!");
14669 curr_rloc->priority = p;
14670 curr_rloc->weight = w;
14672 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14675 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14676 vec_add1 (rlocs, rloc);
14677 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14679 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14682 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14683 vec_add1 (rlocs, rloc);
14684 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14686 else if (unformat (input, "action %U",
14687 unformat_negative_mapping_action, &action))
14693 clib_warning ("parse error '%U'", format_unformat_error, input);
14700 errmsg ("missing params!");
14704 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14706 errmsg ("no action set for negative map-reply!");
14710 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14712 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14713 mp->is_add = is_add;
14714 mp->vni = htonl (vni);
14715 mp->action = (u8) action;
14716 mp->is_src_dst = seid_set;
14717 mp->eid_len = eid->len;
14718 mp->seid_len = seid->len;
14719 mp->del_all = del_all;
14720 mp->eid_type = eid->type;
14721 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14722 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14724 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14725 clib_memcpy (mp->rlocs, rlocs, data_len);
14731 /* Wait for a reply... */
14736 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14739 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14740 * forwarding entries in data-plane accordingly.
14742 * @param vam vpp API test context
14743 * @return return code
14746 api_one_add_del_adjacency (vat_main_t * vam)
14748 unformat_input_t *input = vam->input;
14749 vl_api_one_add_del_adjacency_t *mp;
14751 ip4_address_t leid4, reid4;
14752 ip6_address_t leid6, reid6;
14753 u8 reid_mac[6] = { 0 };
14754 u8 leid_mac[6] = { 0 };
14755 u8 reid_type, leid_type;
14756 u32 leid_len = 0, reid_len = 0, len;
14760 leid_type = reid_type = (u8) ~ 0;
14762 /* Parse args required to build the message */
14763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14765 if (unformat (input, "del"))
14769 else if (unformat (input, "add"))
14773 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14776 reid_type = 0; /* ipv4 */
14779 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14782 reid_type = 1; /* ipv6 */
14785 else if (unformat (input, "reid %U", unformat_ethernet_address,
14788 reid_type = 2; /* mac */
14790 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14793 leid_type = 0; /* ipv4 */
14796 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14799 leid_type = 1; /* ipv6 */
14802 else if (unformat (input, "leid %U", unformat_ethernet_address,
14805 leid_type = 2; /* mac */
14807 else if (unformat (input, "vni %d", &vni))
14813 errmsg ("parse error '%U'", format_unformat_error, input);
14818 if ((u8) ~ 0 == reid_type)
14820 errmsg ("missing params!");
14824 if (leid_type != reid_type)
14826 errmsg ("remote and local EIDs are of different types!");
14830 M (ONE_ADD_DEL_ADJACENCY, mp);
14831 mp->is_add = is_add;
14832 mp->vni = htonl (vni);
14833 mp->leid_len = leid_len;
14834 mp->reid_len = reid_len;
14835 mp->eid_type = reid_type;
14837 switch (mp->eid_type)
14840 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14841 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14844 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14845 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14848 clib_memcpy (mp->leid, leid_mac, 6);
14849 clib_memcpy (mp->reid, reid_mac, 6);
14852 errmsg ("unknown EID type %d!", mp->eid_type);
14859 /* Wait for a reply... */
14864 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14867 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14869 unformat_input_t *input = vam->input;
14870 vl_api_gpe_add_del_iface_t *mp;
14871 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14872 u32 dp_table = 0, vni = 0;
14875 /* Parse args required to build the message */
14876 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14878 if (unformat (input, "up"))
14883 else if (unformat (input, "down"))
14888 else if (unformat (input, "table_id %d", &dp_table))
14892 else if (unformat (input, "bd_id %d", &dp_table))
14897 else if (unformat (input, "vni %d", &vni))
14905 if (action_set == 0)
14907 errmsg ("Action not set");
14910 if (dp_table_set == 0 || vni_set == 0)
14912 errmsg ("vni and dp_table must be set");
14916 /* Construct the API message */
14917 M (GPE_ADD_DEL_IFACE, mp);
14919 mp->is_add = is_add;
14920 mp->dp_table = dp_table;
14927 /* Wait for a reply... */
14933 * Add/del map request itr rlocs from ONE control plane and updates
14935 * @param vam vpp API test context
14936 * @return return code
14939 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14941 unformat_input_t *input = vam->input;
14942 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14943 u8 *locator_set_name = 0;
14944 u8 locator_set_name_set = 0;
14948 /* Parse args required to build the message */
14949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14951 if (unformat (input, "del"))
14955 else if (unformat (input, "%_%v%_", &locator_set_name))
14957 locator_set_name_set = 1;
14961 clib_warning ("parse error '%U'", format_unformat_error, input);
14966 if (is_add && !locator_set_name_set)
14968 errmsg ("itr-rloc is not set!");
14972 if (is_add && vec_len (locator_set_name) > 64)
14974 errmsg ("itr-rloc locator-set name too long");
14975 vec_free (locator_set_name);
14979 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14980 mp->is_add = is_add;
14983 clib_memcpy (mp->locator_set_name, locator_set_name,
14984 vec_len (locator_set_name));
14988 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14990 vec_free (locator_set_name);
14995 /* Wait for a reply... */
15000 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15003 api_one_locator_dump (vat_main_t * vam)
15005 unformat_input_t *input = vam->input;
15006 vl_api_one_locator_dump_t *mp;
15007 vl_api_control_ping_t *mp_ping;
15008 u8 is_index_set = 0, is_name_set = 0;
15013 /* Parse args required to build the message */
15014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15016 if (unformat (input, "ls_name %_%v%_", &ls_name))
15020 else if (unformat (input, "ls_index %d", &ls_index))
15026 errmsg ("parse error '%U'", format_unformat_error, input);
15031 if (!is_index_set && !is_name_set)
15033 errmsg ("error: expected one of index or name!");
15037 if (is_index_set && is_name_set)
15039 errmsg ("error: only one param expected!");
15043 if (vec_len (ls_name) > 62)
15045 errmsg ("error: locator set name too long!");
15049 if (!vam->json_output)
15051 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15054 M (ONE_LOCATOR_DUMP, mp);
15055 mp->is_index_set = is_index_set;
15058 mp->ls_index = clib_host_to_net_u32 (ls_index);
15061 vec_add1 (ls_name, 0);
15062 strncpy ((char *) mp->ls_name, (char *) ls_name,
15063 sizeof (mp->ls_name) - 1);
15069 /* Use a control ping for synchronization */
15070 M (CONTROL_PING, mp_ping);
15073 /* Wait for a reply... */
15078 #define api_lisp_locator_dump api_one_locator_dump
15081 api_one_locator_set_dump (vat_main_t * vam)
15083 vl_api_one_locator_set_dump_t *mp;
15084 vl_api_control_ping_t *mp_ping;
15085 unformat_input_t *input = vam->input;
15089 /* Parse args required to build the message */
15090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15092 if (unformat (input, "local"))
15096 else if (unformat (input, "remote"))
15102 errmsg ("parse error '%U'", format_unformat_error, input);
15107 if (!vam->json_output)
15109 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15112 M (ONE_LOCATOR_SET_DUMP, mp);
15114 mp->filter = filter;
15119 /* Use a control ping for synchronization */
15120 M (CONTROL_PING, mp_ping);
15123 /* Wait for a reply... */
15128 #define api_lisp_locator_set_dump api_one_locator_set_dump
15131 api_one_eid_table_map_dump (vat_main_t * vam)
15135 unformat_input_t *input = vam->input;
15136 vl_api_one_eid_table_map_dump_t *mp;
15137 vl_api_control_ping_t *mp_ping;
15140 /* Parse args required to build the message */
15141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15143 if (unformat (input, "l2"))
15148 else if (unformat (input, "l3"))
15155 errmsg ("parse error '%U'", format_unformat_error, input);
15162 errmsg ("expected one of 'l2' or 'l3' parameter!");
15166 if (!vam->json_output)
15168 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15171 M (ONE_EID_TABLE_MAP_DUMP, mp);
15177 /* Use a control ping for synchronization */
15178 M (CONTROL_PING, mp_ping);
15181 /* Wait for a reply... */
15186 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15189 api_one_eid_table_vni_dump (vat_main_t * vam)
15191 vl_api_one_eid_table_vni_dump_t *mp;
15192 vl_api_control_ping_t *mp_ping;
15195 if (!vam->json_output)
15197 print (vam->ofp, "VNI");
15200 M (ONE_EID_TABLE_VNI_DUMP, mp);
15205 /* Use a control ping for synchronization */
15206 M (CONTROL_PING, mp_ping);
15209 /* Wait for a reply... */
15214 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15217 api_one_eid_table_dump (vat_main_t * vam)
15219 unformat_input_t *i = vam->input;
15220 vl_api_one_eid_table_dump_t *mp;
15221 vl_api_control_ping_t *mp_ping;
15222 struct in_addr ip4;
15223 struct in6_addr ip6;
15225 u8 eid_type = ~0, eid_set = 0;
15226 u32 prefix_length = ~0, t, vni = 0;
15230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15232 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15238 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15244 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15249 else if (unformat (i, "vni %d", &t))
15253 else if (unformat (i, "local"))
15257 else if (unformat (i, "remote"))
15263 errmsg ("parse error '%U'", format_unformat_error, i);
15268 if (!vam->json_output)
15270 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15271 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15274 M (ONE_EID_TABLE_DUMP, mp);
15276 mp->filter = filter;
15280 mp->vni = htonl (vni);
15281 mp->eid_type = eid_type;
15285 mp->prefix_length = prefix_length;
15286 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15289 mp->prefix_length = prefix_length;
15290 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15293 clib_memcpy (mp->eid, mac, sizeof (mac));
15296 errmsg ("unknown EID type %d!", eid_type);
15304 /* Use a control ping for synchronization */
15305 M (CONTROL_PING, mp_ping);
15308 /* Wait for a reply... */
15313 #define api_lisp_eid_table_dump api_one_eid_table_dump
15316 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15318 unformat_input_t *i = vam->input;
15319 vl_api_gpe_fwd_entries_get_t *mp;
15324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15326 if (unformat (i, "vni %d", &vni))
15332 errmsg ("parse error '%U'", format_unformat_error, i);
15339 errmsg ("vni not set!");
15343 if (!vam->json_output)
15345 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15349 M (GPE_FWD_ENTRIES_GET, mp);
15350 mp->vni = clib_host_to_net_u32 (vni);
15355 /* Wait for a reply... */
15360 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15361 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15362 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15363 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15366 api_one_adjacencies_get (vat_main_t * vam)
15368 unformat_input_t *i = vam->input;
15369 vl_api_one_adjacencies_get_t *mp;
15374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15376 if (unformat (i, "vni %d", &vni))
15382 errmsg ("parse error '%U'", format_unformat_error, i);
15389 errmsg ("vni not set!");
15393 if (!vam->json_output)
15395 print (vam->ofp, "%s %40s", "leid", "reid");
15398 M (ONE_ADJACENCIES_GET, mp);
15399 mp->vni = clib_host_to_net_u32 (vni);
15404 /* Wait for a reply... */
15409 #define api_lisp_adjacencies_get api_one_adjacencies_get
15412 api_one_map_server_dump (vat_main_t * vam)
15414 vl_api_one_map_server_dump_t *mp;
15415 vl_api_control_ping_t *mp_ping;
15418 if (!vam->json_output)
15420 print (vam->ofp, "%=20s", "Map server");
15423 M (ONE_MAP_SERVER_DUMP, mp);
15427 /* Use a control ping for synchronization */
15428 M (CONTROL_PING, mp_ping);
15431 /* Wait for a reply... */
15436 #define api_lisp_map_server_dump api_one_map_server_dump
15439 api_one_map_resolver_dump (vat_main_t * vam)
15441 vl_api_one_map_resolver_dump_t *mp;
15442 vl_api_control_ping_t *mp_ping;
15445 if (!vam->json_output)
15447 print (vam->ofp, "%=20s", "Map resolver");
15450 M (ONE_MAP_RESOLVER_DUMP, mp);
15454 /* Use a control ping for synchronization */
15455 M (CONTROL_PING, mp_ping);
15458 /* Wait for a reply... */
15463 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15466 api_show_one_status (vat_main_t * vam)
15468 vl_api_show_one_status_t *mp;
15471 if (!vam->json_output)
15473 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15476 M (SHOW_ONE_STATUS, mp);
15479 /* Wait for a reply... */
15484 #define api_show_lisp_status api_show_one_status
15487 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15489 vl_api_gpe_fwd_entry_path_dump_t *mp;
15490 vl_api_control_ping_t *mp_ping;
15491 unformat_input_t *i = vam->input;
15492 u32 fwd_entry_index = ~0;
15495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15497 if (unformat (i, "index %d", &fwd_entry_index))
15503 if (~0 == fwd_entry_index)
15505 errmsg ("no index specified!");
15509 if (!vam->json_output)
15511 print (vam->ofp, "first line");
15514 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15518 /* Use a control ping for synchronization */
15519 M (CONTROL_PING, mp_ping);
15522 /* Wait for a reply... */
15528 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15530 vl_api_one_get_map_request_itr_rlocs_t *mp;
15533 if (!vam->json_output)
15535 print (vam->ofp, "%=20s", "itr-rlocs:");
15538 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15541 /* Wait for a reply... */
15546 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15549 api_af_packet_create (vat_main_t * vam)
15551 unformat_input_t *i = vam->input;
15552 vl_api_af_packet_create_t *mp;
15553 u8 *host_if_name = 0;
15555 u8 random_hw_addr = 1;
15558 memset (hw_addr, 0, sizeof (hw_addr));
15560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15562 if (unformat (i, "name %s", &host_if_name))
15563 vec_add1 (host_if_name, 0);
15564 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15565 random_hw_addr = 0;
15570 if (!vec_len (host_if_name))
15572 errmsg ("host-interface name must be specified");
15576 if (vec_len (host_if_name) > 64)
15578 errmsg ("host-interface name too long");
15582 M (AF_PACKET_CREATE, mp);
15584 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15585 clib_memcpy (mp->hw_addr, hw_addr, 6);
15586 mp->use_random_hw_addr = random_hw_addr;
15587 vec_free (host_if_name);
15590 W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15595 api_af_packet_delete (vat_main_t * vam)
15597 unformat_input_t *i = vam->input;
15598 vl_api_af_packet_delete_t *mp;
15599 u8 *host_if_name = 0;
15602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15604 if (unformat (i, "name %s", &host_if_name))
15605 vec_add1 (host_if_name, 0);
15610 if (!vec_len (host_if_name))
15612 errmsg ("host-interface name must be specified");
15616 if (vec_len (host_if_name) > 64)
15618 errmsg ("host-interface name too long");
15622 M (AF_PACKET_DELETE, mp);
15624 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15625 vec_free (host_if_name);
15633 api_policer_add_del (vat_main_t * vam)
15635 unformat_input_t *i = vam->input;
15636 vl_api_policer_add_del_t *mp;
15646 u8 color_aware = 0;
15647 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15650 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15651 conform_action.dscp = 0;
15652 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15653 exceed_action.dscp = 0;
15654 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15655 violate_action.dscp = 0;
15657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15659 if (unformat (i, "del"))
15661 else if (unformat (i, "name %s", &name))
15662 vec_add1 (name, 0);
15663 else if (unformat (i, "cir %u", &cir))
15665 else if (unformat (i, "eir %u", &eir))
15667 else if (unformat (i, "cb %u", &cb))
15669 else if (unformat (i, "eb %u", &eb))
15671 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15674 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15677 else if (unformat (i, "type %U", unformat_policer_type, &type))
15679 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15682 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15685 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15688 else if (unformat (i, "color-aware"))
15694 if (!vec_len (name))
15696 errmsg ("policer name must be specified");
15700 if (vec_len (name) > 64)
15702 errmsg ("policer name too long");
15706 M (POLICER_ADD_DEL, mp);
15708 clib_memcpy (mp->name, name, vec_len (name));
15710 mp->is_add = is_add;
15715 mp->rate_type = rate_type;
15716 mp->round_type = round_type;
15718 mp->conform_action_type = conform_action.action_type;
15719 mp->conform_dscp = conform_action.dscp;
15720 mp->exceed_action_type = exceed_action.action_type;
15721 mp->exceed_dscp = exceed_action.dscp;
15722 mp->violate_action_type = violate_action.action_type;
15723 mp->violate_dscp = violate_action.dscp;
15724 mp->color_aware = color_aware;
15732 api_policer_dump (vat_main_t * vam)
15734 unformat_input_t *i = vam->input;
15735 vl_api_policer_dump_t *mp;
15736 vl_api_control_ping_t *mp_ping;
15737 u8 *match_name = 0;
15738 u8 match_name_valid = 0;
15741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15743 if (unformat (i, "name %s", &match_name))
15745 vec_add1 (match_name, 0);
15746 match_name_valid = 1;
15752 M (POLICER_DUMP, mp);
15753 mp->match_name_valid = match_name_valid;
15754 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15755 vec_free (match_name);
15759 /* Use a control ping for synchronization */
15760 M (CONTROL_PING, mp_ping);
15763 /* Wait for a reply... */
15769 api_policer_classify_set_interface (vat_main_t * vam)
15771 unformat_input_t *i = vam->input;
15772 vl_api_policer_classify_set_interface_t *mp;
15774 int sw_if_index_set;
15775 u32 ip4_table_index = ~0;
15776 u32 ip6_table_index = ~0;
15777 u32 l2_table_index = ~0;
15781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15783 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15784 sw_if_index_set = 1;
15785 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15786 sw_if_index_set = 1;
15787 else if (unformat (i, "del"))
15789 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15791 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15793 else if (unformat (i, "l2-table %d", &l2_table_index))
15797 clib_warning ("parse error '%U'", format_unformat_error, i);
15802 if (sw_if_index_set == 0)
15804 errmsg ("missing interface name or sw_if_index");
15808 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15810 mp->sw_if_index = ntohl (sw_if_index);
15811 mp->ip4_table_index = ntohl (ip4_table_index);
15812 mp->ip6_table_index = ntohl (ip6_table_index);
15813 mp->l2_table_index = ntohl (l2_table_index);
15814 mp->is_add = is_add;
15822 api_policer_classify_dump (vat_main_t * vam)
15824 unformat_input_t *i = vam->input;
15825 vl_api_policer_classify_dump_t *mp;
15826 vl_api_control_ping_t *mp_ping;
15827 u8 type = POLICER_CLASSIFY_N_TABLES;
15830 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15834 errmsg ("classify table type must be specified");
15838 if (!vam->json_output)
15840 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15843 M (POLICER_CLASSIFY_DUMP, mp);
15848 /* Use a control ping for synchronization */
15849 M (CONTROL_PING, mp_ping);
15852 /* Wait for a reply... */
15858 api_netmap_create (vat_main_t * vam)
15860 unformat_input_t *i = vam->input;
15861 vl_api_netmap_create_t *mp;
15864 u8 random_hw_addr = 1;
15869 memset (hw_addr, 0, sizeof (hw_addr));
15871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15873 if (unformat (i, "name %s", &if_name))
15874 vec_add1 (if_name, 0);
15875 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15876 random_hw_addr = 0;
15877 else if (unformat (i, "pipe"))
15879 else if (unformat (i, "master"))
15881 else if (unformat (i, "slave"))
15887 if (!vec_len (if_name))
15889 errmsg ("interface name must be specified");
15893 if (vec_len (if_name) > 64)
15895 errmsg ("interface name too long");
15899 M (NETMAP_CREATE, mp);
15901 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15902 clib_memcpy (mp->hw_addr, hw_addr, 6);
15903 mp->use_random_hw_addr = random_hw_addr;
15904 mp->is_pipe = is_pipe;
15905 mp->is_master = is_master;
15906 vec_free (if_name);
15914 api_netmap_delete (vat_main_t * vam)
15916 unformat_input_t *i = vam->input;
15917 vl_api_netmap_delete_t *mp;
15921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15923 if (unformat (i, "name %s", &if_name))
15924 vec_add1 (if_name, 0);
15929 if (!vec_len (if_name))
15931 errmsg ("interface name must be specified");
15935 if (vec_len (if_name) > 64)
15937 errmsg ("interface name too long");
15941 M (NETMAP_DELETE, mp);
15943 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15944 vec_free (if_name);
15951 static void vl_api_mpls_tunnel_details_t_handler
15952 (vl_api_mpls_tunnel_details_t * mp)
15954 vat_main_t *vam = &vat_main;
15955 i32 len = mp->mt_next_hop_n_labels;
15958 print (vam->ofp, "[%d]: via %U %d labels ",
15960 format_ip4_address, mp->mt_next_hop,
15961 ntohl (mp->mt_next_hop_sw_if_index));
15962 for (i = 0; i < len; i++)
15964 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15966 print (vam->ofp, "");
15969 static void vl_api_mpls_tunnel_details_t_handler_json
15970 (vl_api_mpls_tunnel_details_t * mp)
15972 vat_main_t *vam = &vat_main;
15973 vat_json_node_t *node = NULL;
15974 struct in_addr ip4;
15976 i32 len = mp->mt_next_hop_n_labels;
15978 if (VAT_JSON_ARRAY != vam->json_tree.type)
15980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15981 vat_json_init_array (&vam->json_tree);
15983 node = vat_json_array_add (&vam->json_tree);
15985 vat_json_init_object (node);
15986 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15987 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15988 vat_json_object_add_ip4 (node, "next_hop", ip4);
15989 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15990 ntohl (mp->mt_next_hop_sw_if_index));
15991 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15992 vat_json_object_add_uint (node, "label_count", len);
15993 for (i = 0; i < len; i++)
15995 vat_json_object_add_uint (node, "label",
15996 ntohl (mp->mt_next_hop_out_labels[i]));
16001 api_mpls_tunnel_dump (vat_main_t * vam)
16003 vl_api_mpls_tunnel_dump_t *mp;
16004 vl_api_control_ping_t *mp_ping;
16008 /* Parse args required to build the message */
16009 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16011 if (!unformat (vam->input, "tunnel_index %d", &index))
16018 print (vam->ofp, " tunnel_index %d", index);
16020 M (MPLS_TUNNEL_DUMP, mp);
16021 mp->tunnel_index = htonl (index);
16024 /* Use a control ping for synchronization */
16025 M (CONTROL_PING, mp_ping);
16032 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16033 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16036 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16038 vat_main_t *vam = &vat_main;
16039 int count = ntohl (mp->count);
16040 vl_api_fib_path2_t *fp;
16044 "table-id %d, label %u, ess_bit %u",
16045 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16047 for (i = 0; i < count; i++)
16049 if (fp->afi == IP46_TYPE_IP6)
16051 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16052 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16053 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16054 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16055 format_ip6_address, fp->next_hop);
16056 else if (fp->afi == IP46_TYPE_IP4)
16058 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16059 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16060 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16061 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16062 format_ip4_address, fp->next_hop);
16067 static void vl_api_mpls_fib_details_t_handler_json
16068 (vl_api_mpls_fib_details_t * mp)
16070 vat_main_t *vam = &vat_main;
16071 int count = ntohl (mp->count);
16072 vat_json_node_t *node = NULL;
16073 struct in_addr ip4;
16074 struct in6_addr ip6;
16075 vl_api_fib_path2_t *fp;
16078 if (VAT_JSON_ARRAY != vam->json_tree.type)
16080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16081 vat_json_init_array (&vam->json_tree);
16083 node = vat_json_array_add (&vam->json_tree);
16085 vat_json_init_object (node);
16086 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16087 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16088 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16089 vat_json_object_add_uint (node, "path_count", count);
16091 for (i = 0; i < count; i++)
16093 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16094 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16095 vat_json_object_add_uint (node, "is_local", fp->is_local);
16096 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16097 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16098 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16099 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16100 if (fp->afi == IP46_TYPE_IP4)
16102 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16103 vat_json_object_add_ip4 (node, "next_hop", ip4);
16105 else if (fp->afi == IP46_TYPE_IP6)
16107 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16108 vat_json_object_add_ip6 (node, "next_hop", ip6);
16114 api_mpls_fib_dump (vat_main_t * vam)
16116 vl_api_mpls_fib_dump_t *mp;
16117 vl_api_control_ping_t *mp_ping;
16120 M (MPLS_FIB_DUMP, mp);
16123 /* Use a control ping for synchronization */
16124 M (CONTROL_PING, mp_ping);
16131 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16132 #define vl_api_ip_fib_details_t_print vl_noop_handler
16135 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16137 vat_main_t *vam = &vat_main;
16138 int count = ntohl (mp->count);
16139 vl_api_fib_path_t *fp;
16143 "table-id %d, prefix %U/%d",
16144 ntohl (mp->table_id), format_ip4_address, mp->address,
16145 mp->address_length);
16147 for (i = 0; i < count; i++)
16149 if (fp->afi == IP46_TYPE_IP6)
16151 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16152 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16153 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16154 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16155 format_ip6_address, fp->next_hop);
16156 else if (fp->afi == IP46_TYPE_IP4)
16158 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16159 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16160 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16161 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16162 format_ip4_address, fp->next_hop);
16167 static void vl_api_ip_fib_details_t_handler_json
16168 (vl_api_ip_fib_details_t * mp)
16170 vat_main_t *vam = &vat_main;
16171 int count = ntohl (mp->count);
16172 vat_json_node_t *node = NULL;
16173 struct in_addr ip4;
16174 struct in6_addr ip6;
16175 vl_api_fib_path_t *fp;
16178 if (VAT_JSON_ARRAY != vam->json_tree.type)
16180 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16181 vat_json_init_array (&vam->json_tree);
16183 node = vat_json_array_add (&vam->json_tree);
16185 vat_json_init_object (node);
16186 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16187 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16188 vat_json_object_add_ip4 (node, "prefix", ip4);
16189 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16190 vat_json_object_add_uint (node, "path_count", count);
16192 for (i = 0; i < count; i++)
16194 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16195 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16196 vat_json_object_add_uint (node, "is_local", fp->is_local);
16197 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16198 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16199 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16200 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16201 if (fp->afi == IP46_TYPE_IP4)
16203 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16204 vat_json_object_add_ip4 (node, "next_hop", ip4);
16206 else if (fp->afi == IP46_TYPE_IP6)
16208 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16209 vat_json_object_add_ip6 (node, "next_hop", ip6);
16215 api_ip_fib_dump (vat_main_t * vam)
16217 vl_api_ip_fib_dump_t *mp;
16218 vl_api_control_ping_t *mp_ping;
16221 M (IP_FIB_DUMP, mp);
16224 /* Use a control ping for synchronization */
16225 M (CONTROL_PING, mp_ping);
16233 api_ip_mfib_dump (vat_main_t * vam)
16235 vl_api_ip_mfib_dump_t *mp;
16236 vl_api_control_ping_t *mp_ping;
16239 M (IP_MFIB_DUMP, mp);
16242 /* Use a control ping for synchronization */
16243 M (CONTROL_PING, mp_ping);
16250 static void vl_api_ip_neighbor_details_t_handler
16251 (vl_api_ip_neighbor_details_t * mp)
16253 vat_main_t *vam = &vat_main;
16255 print (vam->ofp, "%c %U %U",
16256 (mp->is_static) ? 'S' : 'D',
16257 format_ethernet_address, &mp->mac_address,
16258 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16262 static void vl_api_ip_neighbor_details_t_handler_json
16263 (vl_api_ip_neighbor_details_t * mp)
16266 vat_main_t *vam = &vat_main;
16267 vat_json_node_t *node;
16268 struct in_addr ip4;
16269 struct in6_addr ip6;
16271 if (VAT_JSON_ARRAY != vam->json_tree.type)
16273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16274 vat_json_init_array (&vam->json_tree);
16276 node = vat_json_array_add (&vam->json_tree);
16278 vat_json_init_object (node);
16279 vat_json_object_add_string_copy (node, "flag",
16280 (mp->is_static) ? (u8 *) "static" : (u8 *)
16283 vat_json_object_add_string_copy (node, "link_layer",
16284 format (0, "%U", format_ethernet_address,
16285 &mp->mac_address));
16289 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16290 vat_json_object_add_ip6 (node, "ip_address", ip6);
16294 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16295 vat_json_object_add_ip4 (node, "ip_address", ip4);
16300 api_ip_neighbor_dump (vat_main_t * vam)
16302 unformat_input_t *i = vam->input;
16303 vl_api_ip_neighbor_dump_t *mp;
16304 vl_api_control_ping_t *mp_ping;
16306 u32 sw_if_index = ~0;
16309 /* Parse args required to build the message */
16310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16312 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16314 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16316 else if (unformat (i, "ip6"))
16322 if (sw_if_index == ~0)
16324 errmsg ("missing interface name or sw_if_index");
16328 M (IP_NEIGHBOR_DUMP, mp);
16329 mp->is_ipv6 = (u8) is_ipv6;
16330 mp->sw_if_index = ntohl (sw_if_index);
16333 /* Use a control ping for synchronization */
16334 M (CONTROL_PING, mp_ping);
16341 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16342 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16345 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16347 vat_main_t *vam = &vat_main;
16348 int count = ntohl (mp->count);
16349 vl_api_fib_path_t *fp;
16353 "table-id %d, prefix %U/%d",
16354 ntohl (mp->table_id), format_ip6_address, mp->address,
16355 mp->address_length);
16357 for (i = 0; i < count; i++)
16359 if (fp->afi == IP46_TYPE_IP6)
16361 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16362 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16363 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16364 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16365 format_ip6_address, fp->next_hop);
16366 else if (fp->afi == IP46_TYPE_IP4)
16368 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16369 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16370 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16371 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16372 format_ip4_address, fp->next_hop);
16377 static void vl_api_ip6_fib_details_t_handler_json
16378 (vl_api_ip6_fib_details_t * mp)
16380 vat_main_t *vam = &vat_main;
16381 int count = ntohl (mp->count);
16382 vat_json_node_t *node = NULL;
16383 struct in_addr ip4;
16384 struct in6_addr ip6;
16385 vl_api_fib_path_t *fp;
16388 if (VAT_JSON_ARRAY != vam->json_tree.type)
16390 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16391 vat_json_init_array (&vam->json_tree);
16393 node = vat_json_array_add (&vam->json_tree);
16395 vat_json_init_object (node);
16396 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16397 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16398 vat_json_object_add_ip6 (node, "prefix", ip6);
16399 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16400 vat_json_object_add_uint (node, "path_count", count);
16402 for (i = 0; i < count; i++)
16404 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16405 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16406 vat_json_object_add_uint (node, "is_local", fp->is_local);
16407 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16408 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16409 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16410 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16411 if (fp->afi == IP46_TYPE_IP4)
16413 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16414 vat_json_object_add_ip4 (node, "next_hop", ip4);
16416 else if (fp->afi == IP46_TYPE_IP6)
16418 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16419 vat_json_object_add_ip6 (node, "next_hop", ip6);
16425 api_ip6_fib_dump (vat_main_t * vam)
16427 vl_api_ip6_fib_dump_t *mp;
16428 vl_api_control_ping_t *mp_ping;
16431 M (IP6_FIB_DUMP, mp);
16434 /* Use a control ping for synchronization */
16435 M (CONTROL_PING, mp_ping);
16443 api_ip6_mfib_dump (vat_main_t * vam)
16445 vl_api_ip6_mfib_dump_t *mp;
16446 vl_api_control_ping_t *mp_ping;
16449 M (IP6_MFIB_DUMP, mp);
16452 /* Use a control ping for synchronization */
16453 M (CONTROL_PING, mp_ping);
16461 api_classify_table_ids (vat_main_t * vam)
16463 vl_api_classify_table_ids_t *mp;
16466 /* Construct the API message */
16467 M (CLASSIFY_TABLE_IDS, mp);
16476 api_classify_table_by_interface (vat_main_t * vam)
16478 unformat_input_t *input = vam->input;
16479 vl_api_classify_table_by_interface_t *mp;
16481 u32 sw_if_index = ~0;
16483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16485 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16487 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16492 if (sw_if_index == ~0)
16494 errmsg ("missing interface name or sw_if_index");
16498 /* Construct the API message */
16499 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16501 mp->sw_if_index = ntohl (sw_if_index);
16509 api_classify_table_info (vat_main_t * vam)
16511 unformat_input_t *input = vam->input;
16512 vl_api_classify_table_info_t *mp;
16516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16518 if (unformat (input, "table_id %d", &table_id))
16523 if (table_id == ~0)
16525 errmsg ("missing table id");
16529 /* Construct the API message */
16530 M (CLASSIFY_TABLE_INFO, mp);
16532 mp->table_id = ntohl (table_id);
16540 api_classify_session_dump (vat_main_t * vam)
16542 unformat_input_t *input = vam->input;
16543 vl_api_classify_session_dump_t *mp;
16544 vl_api_control_ping_t *mp_ping;
16548 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16550 if (unformat (input, "table_id %d", &table_id))
16555 if (table_id == ~0)
16557 errmsg ("missing table id");
16561 /* Construct the API message */
16562 M (CLASSIFY_SESSION_DUMP, mp);
16564 mp->table_id = ntohl (table_id);
16567 /* Use a control ping for synchronization */
16568 M (CONTROL_PING, mp_ping);
16576 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16578 vat_main_t *vam = &vat_main;
16580 print (vam->ofp, "collector_address %U, collector_port %d, "
16581 "src_address %U, vrf_id %d, path_mtu %u, "
16582 "template_interval %u, udp_checksum %d",
16583 format_ip4_address, mp->collector_address,
16584 ntohs (mp->collector_port),
16585 format_ip4_address, mp->src_address,
16586 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16587 ntohl (mp->template_interval), mp->udp_checksum);
16590 vam->result_ready = 1;
16594 vl_api_ipfix_exporter_details_t_handler_json
16595 (vl_api_ipfix_exporter_details_t * mp)
16597 vat_main_t *vam = &vat_main;
16598 vat_json_node_t node;
16599 struct in_addr collector_address;
16600 struct in_addr src_address;
16602 vat_json_init_object (&node);
16603 clib_memcpy (&collector_address, &mp->collector_address,
16604 sizeof (collector_address));
16605 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16606 vat_json_object_add_uint (&node, "collector_port",
16607 ntohs (mp->collector_port));
16608 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16609 vat_json_object_add_ip4 (&node, "src_address", src_address);
16610 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16611 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16612 vat_json_object_add_uint (&node, "template_interval",
16613 ntohl (mp->template_interval));
16614 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16616 vat_json_print (vam->ofp, &node);
16617 vat_json_free (&node);
16619 vam->result_ready = 1;
16623 api_ipfix_exporter_dump (vat_main_t * vam)
16625 vl_api_ipfix_exporter_dump_t *mp;
16628 /* Construct the API message */
16629 M (IPFIX_EXPORTER_DUMP, mp);
16638 api_ipfix_classify_stream_dump (vat_main_t * vam)
16640 vl_api_ipfix_classify_stream_dump_t *mp;
16643 /* Construct the API message */
16644 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16655 vl_api_ipfix_classify_stream_details_t_handler
16656 (vl_api_ipfix_classify_stream_details_t * mp)
16658 vat_main_t *vam = &vat_main;
16659 print (vam->ofp, "domain_id %d, src_port %d",
16660 ntohl (mp->domain_id), ntohs (mp->src_port));
16662 vam->result_ready = 1;
16666 vl_api_ipfix_classify_stream_details_t_handler_json
16667 (vl_api_ipfix_classify_stream_details_t * mp)
16669 vat_main_t *vam = &vat_main;
16670 vat_json_node_t node;
16672 vat_json_init_object (&node);
16673 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16674 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16676 vat_json_print (vam->ofp, &node);
16677 vat_json_free (&node);
16679 vam->result_ready = 1;
16683 api_ipfix_classify_table_dump (vat_main_t * vam)
16685 vl_api_ipfix_classify_table_dump_t *mp;
16686 vl_api_control_ping_t *mp_ping;
16689 if (!vam->json_output)
16691 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16692 "transport_protocol");
16695 /* Construct the API message */
16696 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16701 /* Use a control ping for synchronization */
16702 M (CONTROL_PING, mp_ping);
16710 vl_api_ipfix_classify_table_details_t_handler
16711 (vl_api_ipfix_classify_table_details_t * mp)
16713 vat_main_t *vam = &vat_main;
16714 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16715 mp->transport_protocol);
16719 vl_api_ipfix_classify_table_details_t_handler_json
16720 (vl_api_ipfix_classify_table_details_t * mp)
16722 vat_json_node_t *node = NULL;
16723 vat_main_t *vam = &vat_main;
16725 if (VAT_JSON_ARRAY != vam->json_tree.type)
16727 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16728 vat_json_init_array (&vam->json_tree);
16731 node = vat_json_array_add (&vam->json_tree);
16732 vat_json_init_object (node);
16734 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16735 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16736 vat_json_object_add_uint (node, "transport_protocol",
16737 mp->transport_protocol);
16741 api_sw_interface_span_enable_disable (vat_main_t * vam)
16743 unformat_input_t *i = vam->input;
16744 vl_api_sw_interface_span_enable_disable_t *mp;
16745 u32 src_sw_if_index = ~0;
16746 u32 dst_sw_if_index = ~0;
16750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16753 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16755 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16759 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16761 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16763 else if (unformat (i, "disable"))
16765 else if (unformat (i, "rx"))
16767 else if (unformat (i, "tx"))
16769 else if (unformat (i, "both"))
16775 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16777 mp->sw_if_index_from = htonl (src_sw_if_index);
16778 mp->sw_if_index_to = htonl (dst_sw_if_index);
16787 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16790 vat_main_t *vam = &vat_main;
16791 u8 *sw_if_from_name = 0;
16792 u8 *sw_if_to_name = 0;
16793 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16794 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16795 char *states[] = { "none", "rx", "tx", "both" };
16799 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16801 if ((u32) p->value[0] == sw_if_index_from)
16803 sw_if_from_name = (u8 *)(p->key);
16807 if ((u32) p->value[0] == sw_if_index_to)
16809 sw_if_to_name = (u8 *)(p->key);
16810 if (sw_if_from_name)
16815 print (vam->ofp, "%20s => %20s (%s)",
16816 sw_if_from_name, sw_if_to_name, states[mp->state]);
16820 vl_api_sw_interface_span_details_t_handler_json
16821 (vl_api_sw_interface_span_details_t * mp)
16823 vat_main_t *vam = &vat_main;
16824 vat_json_node_t *node = NULL;
16825 u8 *sw_if_from_name = 0;
16826 u8 *sw_if_to_name = 0;
16827 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16828 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16832 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16834 if ((u32) p->value[0] == sw_if_index_from)
16836 sw_if_from_name = (u8 *)(p->key);
16840 if ((u32) p->value[0] == sw_if_index_to)
16842 sw_if_to_name = (u8 *)(p->key);
16843 if (sw_if_from_name)
16849 if (VAT_JSON_ARRAY != vam->json_tree.type)
16851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16852 vat_json_init_array (&vam->json_tree);
16854 node = vat_json_array_add (&vam->json_tree);
16856 vat_json_init_object (node);
16857 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16858 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16859 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16860 if (0 != sw_if_to_name)
16862 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16864 vat_json_object_add_uint (node, "state", mp->state);
16868 api_sw_interface_span_dump (vat_main_t * vam)
16870 vl_api_sw_interface_span_dump_t *mp;
16871 vl_api_control_ping_t *mp_ping;
16874 M (SW_INTERFACE_SPAN_DUMP, mp);
16877 /* Use a control ping for synchronization */
16878 M (CONTROL_PING, mp_ping);
16886 api_pg_create_interface (vat_main_t * vam)
16888 unformat_input_t *input = vam->input;
16889 vl_api_pg_create_interface_t *mp;
16893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16895 if (unformat (input, "if_id %d", &if_id))
16902 errmsg ("missing pg interface index");
16906 /* Construct the API message */
16907 M (PG_CREATE_INTERFACE, mp);
16909 mp->interface_id = ntohl (if_id);
16917 api_pg_capture (vat_main_t * vam)
16919 unformat_input_t *input = vam->input;
16920 vl_api_pg_capture_t *mp;
16925 u8 pcap_file_set = 0;
16928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16930 if (unformat (input, "if_id %d", &if_id))
16932 else if (unformat (input, "pcap %s", &pcap_file))
16934 else if (unformat (input, "count %d", &count))
16936 else if (unformat (input, "disable"))
16943 errmsg ("missing pg interface index");
16946 if (pcap_file_set > 0)
16948 if (vec_len (pcap_file) > 255)
16950 errmsg ("pcap file name is too long");
16955 u32 name_len = vec_len (pcap_file);
16956 /* Construct the API message */
16957 M (PG_CAPTURE, mp);
16959 mp->interface_id = ntohl (if_id);
16960 mp->is_enabled = enable;
16961 mp->count = ntohl (count);
16962 mp->pcap_name_length = ntohl (name_len);
16963 if (pcap_file_set != 0)
16965 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16967 vec_free (pcap_file);
16975 api_pg_enable_disable (vat_main_t * vam)
16977 unformat_input_t *input = vam->input;
16978 vl_api_pg_enable_disable_t *mp;
16981 u8 stream_name_set = 0;
16982 u8 *stream_name = 0;
16984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16986 if (unformat (input, "stream %s", &stream_name))
16987 stream_name_set = 1;
16988 else if (unformat (input, "disable"))
16994 if (stream_name_set > 0)
16996 if (vec_len (stream_name) > 255)
16998 errmsg ("stream name too long");
17003 u32 name_len = vec_len (stream_name);
17004 /* Construct the API message */
17005 M (PG_ENABLE_DISABLE, mp);
17007 mp->is_enabled = enable;
17008 if (stream_name_set != 0)
17010 mp->stream_name_length = ntohl (name_len);
17011 clib_memcpy (mp->stream_name, stream_name, name_len);
17013 vec_free (stream_name);
17021 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17023 unformat_input_t *input = vam->input;
17024 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17026 u16 *low_ports = 0;
17027 u16 *high_ports = 0;
17030 ip4_address_t ip4_addr;
17031 ip6_address_t ip6_addr;
17040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17042 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17048 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17053 else if (unformat (input, "vrf %d", &vrf_id))
17055 else if (unformat (input, "del"))
17057 else if (unformat (input, "port %d", &tmp))
17059 if (tmp == 0 || tmp > 65535)
17061 errmsg ("port %d out of range", tmp);
17065 this_hi = this_low + 1;
17066 vec_add1 (low_ports, this_low);
17067 vec_add1 (high_ports, this_hi);
17069 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17071 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17073 errmsg ("incorrect range parameters");
17077 /* Note: in debug CLI +1 is added to high before
17078 passing to real fn that does "the work"
17079 (ip_source_and_port_range_check_add_del).
17080 This fn is a wrapper around the binary API fn a
17081 control plane will call, which expects this increment
17082 to have occurred. Hence letting the binary API control
17083 plane fn do the increment for consistency between VAT
17084 and other control planes.
17087 vec_add1 (low_ports, this_low);
17088 vec_add1 (high_ports, this_hi);
17094 if (prefix_set == 0)
17096 errmsg ("<address>/<mask> not specified");
17102 errmsg ("VRF ID required, not specified");
17109 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17113 if (vec_len (low_ports) == 0)
17115 errmsg ("At least one port or port range required");
17119 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17121 mp->is_add = is_add;
17126 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17131 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17134 mp->mask_length = length;
17135 mp->number_of_ranges = vec_len (low_ports);
17137 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17138 vec_free (low_ports);
17140 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17141 vec_free (high_ports);
17143 mp->vrf_id = ntohl (vrf_id);
17151 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17153 unformat_input_t *input = vam->input;
17154 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17155 u32 sw_if_index = ~0;
17157 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17158 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17162 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17164 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17166 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17168 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17170 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17172 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17174 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17176 else if (unformat (input, "del"))
17182 if (sw_if_index == ~0)
17184 errmsg ("Interface required but not specified");
17190 errmsg ("VRF ID required but not specified");
17194 if (tcp_out_vrf_id == 0
17195 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17198 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17202 /* Construct the API message */
17203 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17205 mp->sw_if_index = ntohl (sw_if_index);
17206 mp->is_add = is_add;
17207 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17208 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17209 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17210 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17215 /* Wait for a reply... */
17221 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17223 unformat_input_t *i = vam->input;
17224 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17225 u32 local_sa_id = 0;
17226 u32 remote_sa_id = 0;
17227 ip4_address_t src_address;
17228 ip4_address_t dst_address;
17232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17234 if (unformat (i, "local_sa %d", &local_sa_id))
17236 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17238 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17240 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17242 else if (unformat (i, "del"))
17246 clib_warning ("parse error '%U'", format_unformat_error, i);
17251 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17253 mp->local_sa_id = ntohl (local_sa_id);
17254 mp->remote_sa_id = ntohl (remote_sa_id);
17255 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17256 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17257 mp->is_add = is_add;
17265 api_punt (vat_main_t * vam)
17267 unformat_input_t *i = vam->input;
17275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17277 if (unformat (i, "ip %d", &ipv))
17279 else if (unformat (i, "protocol %d", &protocol))
17281 else if (unformat (i, "port %d", &port))
17283 else if (unformat (i, "del"))
17287 clib_warning ("parse error '%U'", format_unformat_error, i);
17294 mp->is_add = (u8) is_add;
17295 mp->ipv = (u8) ipv;
17296 mp->l4_protocol = (u8) protocol;
17297 mp->l4_port = htons ((u16) port);
17304 static void vl_api_ipsec_gre_tunnel_details_t_handler
17305 (vl_api_ipsec_gre_tunnel_details_t * mp)
17307 vat_main_t *vam = &vat_main;
17309 print (vam->ofp, "%11d%15U%15U%14d%14d",
17310 ntohl (mp->sw_if_index),
17311 format_ip4_address, &mp->src_address,
17312 format_ip4_address, &mp->dst_address,
17313 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17316 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17317 (vl_api_ipsec_gre_tunnel_details_t * mp)
17319 vat_main_t *vam = &vat_main;
17320 vat_json_node_t *node = NULL;
17321 struct in_addr ip4;
17323 if (VAT_JSON_ARRAY != vam->json_tree.type)
17325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17326 vat_json_init_array (&vam->json_tree);
17328 node = vat_json_array_add (&vam->json_tree);
17330 vat_json_init_object (node);
17331 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17332 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17333 vat_json_object_add_ip4 (node, "src_address", ip4);
17334 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17335 vat_json_object_add_ip4 (node, "dst_address", ip4);
17336 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17337 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17341 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17343 unformat_input_t *i = vam->input;
17344 vl_api_ipsec_gre_tunnel_dump_t *mp;
17345 vl_api_control_ping_t *mp_ping;
17347 u8 sw_if_index_set = 0;
17350 /* Parse args required to build the message */
17351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17353 if (unformat (i, "sw_if_index %d", &sw_if_index))
17354 sw_if_index_set = 1;
17359 if (sw_if_index_set == 0)
17364 if (!vam->json_output)
17366 print (vam->ofp, "%11s%15s%15s%14s%14s",
17367 "sw_if_index", "src_address", "dst_address",
17368 "local_sa_id", "remote_sa_id");
17371 /* Get list of gre-tunnel interfaces */
17372 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17374 mp->sw_if_index = htonl (sw_if_index);
17378 /* Use a control ping for synchronization */
17379 M (CONTROL_PING, mp_ping);
17387 api_delete_subif (vat_main_t * vam)
17389 unformat_input_t *i = vam->input;
17390 vl_api_delete_subif_t *mp;
17391 u32 sw_if_index = ~0;
17394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17396 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17398 if (unformat (i, "sw_if_index %d", &sw_if_index))
17404 if (sw_if_index == ~0)
17406 errmsg ("missing sw_if_index");
17410 /* Construct the API message */
17411 M (DELETE_SUBIF, mp);
17412 mp->sw_if_index = ntohl (sw_if_index);
17419 #define foreach_pbb_vtr_op \
17420 _("disable", L2_VTR_DISABLED) \
17421 _("pop", L2_VTR_POP_2) \
17422 _("push", L2_VTR_PUSH_2)
17425 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17427 unformat_input_t *i = vam->input;
17428 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17429 u32 sw_if_index = ~0, vtr_op = ~0;
17430 u16 outer_tag = ~0;
17431 u8 dmac[6], smac[6];
17432 u8 dmac_set = 0, smac_set = 0;
17438 /* Shut up coverity */
17439 memset (dmac, 0, sizeof (dmac));
17440 memset (smac, 0, sizeof (smac));
17442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17444 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17446 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17448 else if (unformat (i, "vtr_op %d", &vtr_op))
17450 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17453 else if (unformat (i, "translate_pbb_stag"))
17455 if (unformat (i, "%d", &tmp))
17457 vtr_op = L2_VTR_TRANSLATE_2_1;
17463 ("translate_pbb_stag operation requires outer tag definition");
17467 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17469 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17471 else if (unformat (i, "sid %d", &sid))
17473 else if (unformat (i, "vlanid %d", &tmp))
17477 clib_warning ("parse error '%U'", format_unformat_error, i);
17482 if ((sw_if_index == ~0) || (vtr_op == ~0))
17484 errmsg ("missing sw_if_index or vtr operation");
17487 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17488 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17491 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17495 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17496 mp->sw_if_index = ntohl (sw_if_index);
17497 mp->vtr_op = ntohl (vtr_op);
17498 mp->outer_tag = ntohs (outer_tag);
17499 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17500 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17501 mp->b_vlanid = ntohs (vlanid);
17502 mp->i_sid = ntohl (sid);
17510 api_flow_classify_set_interface (vat_main_t * vam)
17512 unformat_input_t *i = vam->input;
17513 vl_api_flow_classify_set_interface_t *mp;
17515 int sw_if_index_set;
17516 u32 ip4_table_index = ~0;
17517 u32 ip6_table_index = ~0;
17521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17523 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17524 sw_if_index_set = 1;
17525 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17526 sw_if_index_set = 1;
17527 else if (unformat (i, "del"))
17529 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17531 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17535 clib_warning ("parse error '%U'", format_unformat_error, i);
17540 if (sw_if_index_set == 0)
17542 errmsg ("missing interface name or sw_if_index");
17546 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17548 mp->sw_if_index = ntohl (sw_if_index);
17549 mp->ip4_table_index = ntohl (ip4_table_index);
17550 mp->ip6_table_index = ntohl (ip6_table_index);
17551 mp->is_add = is_add;
17559 api_flow_classify_dump (vat_main_t * vam)
17561 unformat_input_t *i = vam->input;
17562 vl_api_flow_classify_dump_t *mp;
17563 vl_api_control_ping_t *mp_ping;
17564 u8 type = FLOW_CLASSIFY_N_TABLES;
17567 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17571 errmsg ("classify table type must be specified");
17575 if (!vam->json_output)
17577 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17580 M (FLOW_CLASSIFY_DUMP, mp);
17585 /* Use a control ping for synchronization */
17586 M (CONTROL_PING, mp_ping);
17589 /* Wait for a reply... */
17595 api_feature_enable_disable (vat_main_t * vam)
17597 unformat_input_t *i = vam->input;
17598 vl_api_feature_enable_disable_t *mp;
17600 u8 *feature_name = 0;
17601 u32 sw_if_index = ~0;
17605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17607 if (unformat (i, "arc_name %s", &arc_name))
17609 else if (unformat (i, "feature_name %s", &feature_name))
17612 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17614 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17616 else if (unformat (i, "disable"))
17624 errmsg ("missing arc name");
17627 if (vec_len (arc_name) > 63)
17629 errmsg ("arc name too long");
17632 if (feature_name == 0)
17634 errmsg ("missing feature name");
17637 if (vec_len (feature_name) > 63)
17639 errmsg ("feature name too long");
17642 if (sw_if_index == ~0)
17644 errmsg ("missing interface name or sw_if_index");
17648 /* Construct the API message */
17649 M (FEATURE_ENABLE_DISABLE, mp);
17650 mp->sw_if_index = ntohl (sw_if_index);
17651 mp->enable = enable;
17652 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17653 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17654 vec_free (arc_name);
17655 vec_free (feature_name);
17663 api_sw_interface_tag_add_del (vat_main_t * vam)
17665 unformat_input_t *i = vam->input;
17666 vl_api_sw_interface_tag_add_del_t *mp;
17667 u32 sw_if_index = ~0;
17672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17674 if (unformat (i, "tag %s", &tag))
17676 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17678 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17680 else if (unformat (i, "del"))
17686 if (sw_if_index == ~0)
17688 errmsg ("missing interface name or sw_if_index");
17692 if (enable && (tag == 0))
17694 errmsg ("no tag specified");
17698 /* Construct the API message */
17699 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17700 mp->sw_if_index = ntohl (sw_if_index);
17701 mp->is_add = enable;
17703 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17711 static void vl_api_l2_xconnect_details_t_handler
17712 (vl_api_l2_xconnect_details_t * mp)
17714 vat_main_t *vam = &vat_main;
17716 print (vam->ofp, "%15d%15d",
17717 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17720 static void vl_api_l2_xconnect_details_t_handler_json
17721 (vl_api_l2_xconnect_details_t * mp)
17723 vat_main_t *vam = &vat_main;
17724 vat_json_node_t *node = NULL;
17726 if (VAT_JSON_ARRAY != vam->json_tree.type)
17728 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17729 vat_json_init_array (&vam->json_tree);
17731 node = vat_json_array_add (&vam->json_tree);
17733 vat_json_init_object (node);
17734 vat_json_object_add_uint (node, "rx_sw_if_index",
17735 ntohl (mp->rx_sw_if_index));
17736 vat_json_object_add_uint (node, "tx_sw_if_index",
17737 ntohl (mp->tx_sw_if_index));
17741 api_l2_xconnect_dump (vat_main_t * vam)
17743 vl_api_l2_xconnect_dump_t *mp;
17744 vl_api_control_ping_t *mp_ping;
17747 if (!vam->json_output)
17749 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17752 M (L2_XCONNECT_DUMP, mp);
17756 /* Use a control ping for synchronization */
17757 M (CONTROL_PING, mp_ping);
17765 api_sw_interface_set_mtu (vat_main_t * vam)
17767 unformat_input_t *i = vam->input;
17768 vl_api_sw_interface_set_mtu_t *mp;
17769 u32 sw_if_index = ~0;
17773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17775 if (unformat (i, "mtu %d", &mtu))
17777 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17779 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17785 if (sw_if_index == ~0)
17787 errmsg ("missing interface name or sw_if_index");
17793 errmsg ("no mtu specified");
17797 /* Construct the API message */
17798 M (SW_INTERFACE_SET_MTU, mp);
17799 mp->sw_if_index = ntohl (sw_if_index);
17800 mp->mtu = ntohs ((u16) mtu);
17809 q_or_quit (vat_main_t * vam)
17811 #if VPP_API_TEST_BUILTIN == 0
17812 longjmp (vam->jump_buf, 1);
17814 return 0; /* not so much */
17818 q (vat_main_t * vam)
17820 return q_or_quit (vam);
17824 quit (vat_main_t * vam)
17826 return q_or_quit (vam);
17830 comment (vat_main_t * vam)
17836 cmd_cmp (void *a1, void *a2)
17841 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17845 help (vat_main_t * vam)
17850 unformat_input_t *i = vam->input;
17853 if (unformat (i, "%s", &name))
17857 vec_add1 (name, 0);
17859 hs = hash_get_mem (vam->help_by_name, name);
17861 print (vam->ofp, "usage: %s %s", name, hs[0]);
17863 print (vam->ofp, "No such msg / command '%s'", name);
17868 print (vam->ofp, "Help is available for the following:");
17871 hash_foreach_pair (p, vam->function_by_name,
17873 vec_add1 (cmds, (u8 *)(p->key));
17877 vec_sort_with_function (cmds, cmd_cmp);
17879 for (j = 0; j < vec_len (cmds); j++)
17880 print (vam->ofp, "%s", cmds[j]);
17887 set (vat_main_t * vam)
17889 u8 *name = 0, *value = 0;
17890 unformat_input_t *i = vam->input;
17892 if (unformat (i, "%s", &name))
17894 /* The input buffer is a vector, not a string. */
17895 value = vec_dup (i->buffer);
17896 vec_delete (value, i->index, 0);
17897 /* Almost certainly has a trailing newline */
17898 if (value[vec_len (value) - 1] == '\n')
17899 value[vec_len (value) - 1] = 0;
17900 /* Make sure it's a proper string, one way or the other */
17901 vec_add1 (value, 0);
17902 (void) clib_macro_set_value (&vam->macro_main,
17903 (char *) name, (char *) value);
17906 errmsg ("usage: set <name> <value>");
17914 unset (vat_main_t * vam)
17918 if (unformat (vam->input, "%s", &name))
17919 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17920 errmsg ("unset: %s wasn't set", name);
17933 macro_sort_cmp (void *a1, void *a2)
17935 macro_sort_t *s1 = a1;
17936 macro_sort_t *s2 = a2;
17938 return strcmp ((char *) (s1->name), (char *) (s2->name));
17942 dump_macro_table (vat_main_t * vam)
17944 macro_sort_t *sort_me = 0, *sm;
17949 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17951 vec_add2 (sort_me, sm, 1);
17952 sm->name = (u8 *)(p->key);
17953 sm->value = (u8 *) (p->value[0]);
17957 vec_sort_with_function (sort_me, macro_sort_cmp);
17959 if (vec_len (sort_me))
17960 print (vam->ofp, "%-15s%s", "Name", "Value");
17962 print (vam->ofp, "The macro table is empty...");
17964 for (i = 0; i < vec_len (sort_me); i++)
17965 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17970 dump_node_table (vat_main_t * vam)
17973 vlib_node_t *node, *next_node;
17975 if (vec_len (vam->graph_nodes) == 0)
17977 print (vam->ofp, "Node table empty, issue get_node_graph...");
17981 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17983 node = vam->graph_nodes[i];
17984 print (vam->ofp, "[%d] %s", i, node->name);
17985 for (j = 0; j < vec_len (node->next_nodes); j++)
17987 if (node->next_nodes[j] != ~0)
17989 next_node = vam->graph_nodes[node->next_nodes[j]];
17990 print (vam->ofp, " [%d] %s", j, next_node->name);
17998 value_sort_cmp (void *a1, void *a2)
18000 name_sort_t *n1 = a1;
18001 name_sort_t *n2 = a2;
18003 if (n1->value < n2->value)
18005 if (n1->value > n2->value)
18012 dump_msg_api_table (vat_main_t * vam)
18014 api_main_t *am = &api_main;
18015 name_sort_t *nses = 0, *ns;
18020 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18022 vec_add2 (nses, ns, 1);
18023 ns->name = (u8 *)(hp->key);
18024 ns->value = (u32) hp->value[0];
18028 vec_sort_with_function (nses, value_sort_cmp);
18030 for (i = 0; i < vec_len (nses); i++)
18031 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18037 get_msg_id (vat_main_t * vam)
18042 if (unformat (vam->input, "%s", &name_and_crc))
18044 message_index = vl_api_get_msg_index (name_and_crc);
18045 if (message_index == ~0)
18047 print (vam->ofp, " '%s' not found", name_and_crc);
18050 print (vam->ofp, " '%s' has message index %d",
18051 name_and_crc, message_index);
18054 errmsg ("name_and_crc required...");
18059 search_node_table (vat_main_t * vam)
18061 unformat_input_t *line_input = vam->input;
18064 vlib_node_t *node, *next_node;
18067 if (vam->graph_node_index_by_name == 0)
18069 print (vam->ofp, "Node table empty, issue get_node_graph...");
18073 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18075 if (unformat (line_input, "%s", &node_to_find))
18077 vec_add1 (node_to_find, 0);
18078 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18081 print (vam->ofp, "%s not found...", node_to_find);
18084 node = vam->graph_nodes[p[0]];
18085 print (vam->ofp, "[%d] %s", p[0], node->name);
18086 for (j = 0; j < vec_len (node->next_nodes); j++)
18088 if (node->next_nodes[j] != ~0)
18090 next_node = vam->graph_nodes[node->next_nodes[j]];
18091 print (vam->ofp, " [%d] %s", j, next_node->name);
18098 clib_warning ("parse error '%U'", format_unformat_error,
18104 vec_free (node_to_find);
18113 script (vat_main_t * vam)
18115 #if (VPP_API_TEST_BUILTIN==0)
18117 char *save_current_file;
18118 unformat_input_t save_input;
18119 jmp_buf save_jump_buf;
18120 u32 save_line_number;
18122 FILE *new_fp, *save_ifp;
18124 if (unformat (vam->input, "%s", &s))
18126 new_fp = fopen ((char *) s, "r");
18129 errmsg ("Couldn't open script file %s", s);
18136 errmsg ("Missing script name");
18140 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18141 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18142 save_ifp = vam->ifp;
18143 save_line_number = vam->input_line_number;
18144 save_current_file = (char *) vam->current_file;
18146 vam->input_line_number = 0;
18148 vam->current_file = s;
18151 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18152 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18153 vam->ifp = save_ifp;
18154 vam->input_line_number = save_line_number;
18155 vam->current_file = (u8 *) save_current_file;
18160 clib_warning ("use the exec command...");
18166 echo (vat_main_t * vam)
18168 print (vam->ofp, "%v", vam->input->buffer);
18172 /* List of API message constructors, CLI names map to api_xxx */
18173 #define foreach_vpe_api_msg \
18174 _(create_loopback,"[mac <mac-addr>]") \
18175 _(sw_interface_dump,"") \
18176 _(sw_interface_set_flags, \
18177 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18178 _(sw_interface_add_del_address, \
18179 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18180 _(sw_interface_set_table, \
18181 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18182 _(sw_interface_set_mpls_enable, \
18183 "<intfc> | sw_if_index [disable | dis]") \
18184 _(sw_interface_set_vpath, \
18185 "<intfc> | sw_if_index <id> enable | disable") \
18186 _(sw_interface_set_vxlan_bypass, \
18187 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18188 _(sw_interface_set_l2_xconnect, \
18189 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18190 "enable | disable") \
18191 _(sw_interface_set_l2_bridge, \
18192 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18193 "[shg <split-horizon-group>] [bvi]\n" \
18194 "enable | disable") \
18195 _(bridge_domain_add_del, \
18196 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18197 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18199 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18201 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18203 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18205 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18207 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18209 "<vpp-if-name> | sw_if_index <id>") \
18210 _(sw_interface_tap_dump, "") \
18211 _(ip_add_del_route, \
18212 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18213 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18214 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18215 "[multipath] [count <n>]") \
18216 _(ip_mroute_add_del, \
18217 "<src> <grp>/<mask> [table-id <n>]\n" \
18218 "[<intfc> | sw_if_index <id>] [local] [del]") \
18219 _(mpls_route_add_del, \
18220 "<label> <eos> via <addr> [table-id <n>]\n" \
18221 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18222 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18223 "[multipath] [count <n>]") \
18224 _(mpls_ip_bind_unbind, \
18225 "<label> <addr/len>") \
18226 _(mpls_tunnel_add_del, \
18227 " via <addr> [table-id <n>]\n" \
18228 "sw_if_index <id>] [l2] [del]") \
18229 _(proxy_arp_add_del, \
18230 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18231 _(proxy_arp_intfc_enable_disable, \
18232 "<intfc> | sw_if_index <id> enable | disable") \
18233 _(sw_interface_set_unnumbered, \
18234 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18235 _(ip_neighbor_add_del, \
18236 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18237 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18238 _(reset_vrf, "vrf <id> [ipv6]") \
18239 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18240 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18241 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18242 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18243 "[outer_vlan_id_any][inner_vlan_id_any]") \
18244 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18245 _(reset_fib, "vrf <n> [ipv6]") \
18246 _(dhcp_proxy_config, \
18247 "svr <v46-address> src <v46-address>\n" \
18248 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18249 _(dhcp_proxy_set_vss, \
18250 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18251 _(dhcp_proxy_dump, "ip6") \
18252 _(dhcp_client_config, \
18253 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18254 _(set_ip_flow_hash, \
18255 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18256 _(sw_interface_ip6_enable_disable, \
18257 "<intfc> | sw_if_index <id> enable | disable") \
18258 _(sw_interface_ip6_set_link_local_address, \
18259 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18260 _(sw_interface_ip6nd_ra_prefix, \
18261 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18262 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18263 "[nolink] [isno]") \
18264 _(sw_interface_ip6nd_ra_config, \
18265 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18266 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18267 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18268 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18269 _(l2_patch_add_del, \
18270 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18271 "enable | disable") \
18272 _(sr_tunnel_add_del, \
18273 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
18274 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
18275 "[policy <policy_name>]") \
18276 _(sr_policy_add_del, \
18277 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
18278 _(sr_multicast_map_add_del, \
18279 "address [ip6 multicast address] sr-policy [policy name] [del]") \
18280 _(classify_add_del_table, \
18281 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18282 " [del] [del-chain] mask <mask-value>\n" \
18283 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18284 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18285 _(classify_add_del_session, \
18286 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18287 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18288 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18289 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18290 _(classify_set_interface_ip_table, \
18291 "<intfc> | sw_if_index <nn> table <nn>") \
18292 _(classify_set_interface_l2_tables, \
18293 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18294 " [other-table <nn>]") \
18295 _(get_node_index, "node <node-name") \
18296 _(add_node_next, "node <node-name> next <next-node-name>") \
18297 _(l2tpv3_create_tunnel, \
18298 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18299 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18300 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18301 _(l2tpv3_set_tunnel_cookies, \
18302 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18303 "[new_remote_cookie <nn>]\n") \
18304 _(l2tpv3_interface_enable_disable, \
18305 "<intfc> | sw_if_index <nn> enable | disable") \
18306 _(l2tpv3_set_lookup_key, \
18307 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18308 _(sw_if_l2tpv3_tunnel_dump, "") \
18309 _(vxlan_add_del_tunnel, \
18310 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18311 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18312 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18313 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18314 _(gre_add_del_tunnel, \
18315 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18316 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18317 _(l2_fib_clear_table, "") \
18318 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18319 _(l2_interface_vlan_tag_rewrite, \
18320 "<intfc> | sw_if_index <nn> \n" \
18321 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18322 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18323 _(create_vhost_user_if, \
18324 "socket <filename> [server] [renumber <dev_instance>] " \
18325 "[mac <mac_address>]") \
18326 _(modify_vhost_user_if, \
18327 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18328 "[server] [renumber <dev_instance>]") \
18329 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18330 _(sw_interface_vhost_user_dump, "") \
18331 _(show_version, "") \
18332 _(vxlan_gpe_add_del_tunnel, \
18333 "local <addr> remote <addr> vni <nn>\n" \
18334 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18335 "[next-ethernet] [next-nsh]\n") \
18336 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18337 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18338 _(interface_name_renumber, \
18339 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18340 _(input_acl_set_interface, \
18341 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18342 " [l2-table <nn>] [del]") \
18343 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18344 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18345 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18346 _(ip_dump, "ipv4 | ipv6") \
18347 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18348 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18350 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18351 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18352 " integ_alg <alg> integ_key <hex>") \
18353 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18354 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18355 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18356 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18357 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18358 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18359 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18360 "(auth_data 0x<data> | auth_data <data>)") \
18361 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18362 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18363 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18364 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18365 "(local|remote)") \
18366 _(ikev2_set_local_key, "file <absolute_file_path>") \
18367 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18368 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18369 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18370 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18371 _(ikev2_initiate_sa_init, "<profile_name>") \
18372 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18373 _(ikev2_initiate_del_child_sa, "<ispi>") \
18374 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18375 _(delete_loopback,"sw_if_index <nn>") \
18376 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18377 _(map_add_domain, \
18378 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18379 "ip6-src <ip6addr> " \
18380 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18381 _(map_del_domain, "index <n>") \
18382 _(map_add_del_rule, \
18383 "index <n> psid <n> dst <ip6addr> [del]") \
18384 _(map_domain_dump, "") \
18385 _(map_rule_dump, "index <map-domain>") \
18386 _(want_interface_events, "enable|disable") \
18387 _(want_stats,"enable|disable") \
18388 _(get_first_msg_id, "client <name>") \
18389 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18390 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18391 "fib-id <nn> [ip4][ip6][default]") \
18392 _(get_node_graph, " ") \
18393 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18394 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18395 _(ioam_disable, "") \
18396 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18397 " sw_if_index <sw_if_index> p <priority> " \
18398 "w <weight>] [del]") \
18399 _(one_add_del_locator, "locator-set <locator_name> " \
18400 "iface <intf> | sw_if_index <sw_if_index> " \
18401 "p <priority> w <weight> [del]") \
18402 _(one_add_del_local_eid,"vni <vni> eid " \
18403 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18404 "locator-set <locator_name> [del]" \
18405 "[key-id sha1|sha256 secret-key <secret-key>]")\
18406 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18407 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18408 _(one_enable_disable, "enable|disable") \
18409 _(one_map_register_enable_disable, "enable|disable") \
18410 _(one_rloc_probe_enable_disable, "enable|disable") \
18411 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18413 "rloc <locator> p <prio> " \
18414 "w <weight> [rloc <loc> ... ] " \
18415 "action <action> [del-all]") \
18416 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18418 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18419 _(one_map_request_mode, "src-dst|dst-only") \
18420 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18421 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18422 _(one_locator_set_dump, "[local | remote]") \
18423 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18424 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18425 "[local] | [remote]") \
18426 _(one_eid_table_vni_dump, "") \
18427 _(one_eid_table_map_dump, "l2|l3") \
18428 _(one_map_resolver_dump, "") \
18429 _(one_map_server_dump, "") \
18430 _(one_adjacencies_get, "vni <vni>") \
18431 _(show_one_rloc_probe_state, "") \
18432 _(show_one_map_register_state, "") \
18433 _(show_one_status, "") \
18434 _(one_get_map_request_itr_rlocs, "") \
18435 _(show_one_pitr, "") \
18436 _(show_one_map_request_mode, "") \
18437 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18438 " sw_if_index <sw_if_index> p <priority> " \
18439 "w <weight>] [del]") \
18440 _(lisp_add_del_locator, "locator-set <locator_name> " \
18441 "iface <intf> | sw_if_index <sw_if_index> " \
18442 "p <priority> w <weight> [del]") \
18443 _(lisp_add_del_local_eid,"vni <vni> eid " \
18444 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18445 "locator-set <locator_name> [del]" \
18446 "[key-id sha1|sha256 secret-key <secret-key>]") \
18447 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18448 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18449 _(lisp_enable_disable, "enable|disable") \
18450 _(lisp_map_register_enable_disable, "enable|disable") \
18451 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18452 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18454 "rloc <locator> p <prio> " \
18455 "w <weight> [rloc <loc> ... ] " \
18456 "action <action> [del-all]") \
18457 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18459 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18460 _(lisp_map_request_mode, "src-dst|dst-only") \
18461 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18462 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18463 _(lisp_locator_set_dump, "[local | remote]") \
18464 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18465 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18466 "[local] | [remote]") \
18467 _(lisp_eid_table_vni_dump, "") \
18468 _(lisp_eid_table_map_dump, "l2|l3") \
18469 _(lisp_map_resolver_dump, "") \
18470 _(lisp_map_server_dump, "") \
18471 _(lisp_adjacencies_get, "vni <vni>") \
18472 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18473 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18474 _(lisp_gpe_add_del_iface, "up|down") \
18475 _(lisp_gpe_enable_disable, "enable|disable") \
18476 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18477 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18478 _(show_lisp_rloc_probe_state, "") \
18479 _(show_lisp_map_register_state, "") \
18480 _(show_lisp_status, "") \
18481 _(lisp_get_map_request_itr_rlocs, "") \
18482 _(show_lisp_pitr, "") \
18483 _(show_lisp_map_request_mode, "") \
18484 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18485 _(af_packet_delete, "name <host interface name>") \
18486 _(policer_add_del, "name <policer name> <params> [del]") \
18487 _(policer_dump, "[name <policer name>]") \
18488 _(policer_classify_set_interface, \
18489 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18490 " [l2-table <nn>] [del]") \
18491 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18492 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18493 "[master|slave]") \
18494 _(netmap_delete, "name <interface name>") \
18495 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18496 _(mpls_fib_dump, "") \
18497 _(classify_table_ids, "") \
18498 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18499 _(classify_table_info, "table_id <nn>") \
18500 _(classify_session_dump, "table_id <nn>") \
18501 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18502 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18503 "[template_interval <nn>] [udp_checksum]") \
18504 _(ipfix_exporter_dump, "") \
18505 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18506 _(ipfix_classify_stream_dump, "") \
18507 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18508 _(ipfix_classify_table_dump, "") \
18509 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18510 _(sw_interface_span_dump, "") \
18511 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18512 _(pg_create_interface, "if_id <nn>") \
18513 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18514 _(pg_enable_disable, "[stream <id>] disable") \
18515 _(ip_source_and_port_range_check_add_del, \
18516 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18517 _(ip_source_and_port_range_check_interface_add_del, \
18518 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18519 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18520 _(ipsec_gre_add_del_tunnel, \
18521 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18522 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18523 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18524 _(l2_interface_pbb_tag_rewrite, \
18525 "<intfc> | sw_if_index <nn> \n" \
18526 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18527 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18528 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18529 _(flow_classify_set_interface, \
18530 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18531 _(flow_classify_dump, "type [ip4|ip6]") \
18532 _(ip_fib_dump, "") \
18533 _(ip_mfib_dump, "") \
18534 _(ip6_fib_dump, "") \
18535 _(ip6_mfib_dump, "") \
18536 _(feature_enable_disable, "arc_name <arc_name> " \
18537 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18538 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18540 _(l2_xconnect_dump, "") \
18541 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18542 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18543 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18546 #define foreach_vpe_dpdk_api_msg \
18547 _(sw_interface_set_dpdk_hqos_pipe, \
18548 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
18549 "profile <profile-id>\n") \
18550 _(sw_interface_set_dpdk_hqos_subport, \
18551 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
18552 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
18553 _(sw_interface_set_dpdk_hqos_tctbl, \
18554 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
18557 /* List of command functions, CLI names map directly to functions */
18558 #define foreach_cli_function \
18559 _(comment, "usage: comment <ignore-rest-of-line>") \
18560 _(dump_interface_table, "usage: dump_interface_table") \
18561 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18562 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18563 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18564 _(dump_stats_table, "usage: dump_stats_table") \
18565 _(dump_macro_table, "usage: dump_macro_table ") \
18566 _(dump_node_table, "usage: dump_node_table") \
18567 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18568 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18569 _(echo, "usage: echo <message>") \
18570 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18571 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18572 _(help, "usage: help") \
18573 _(q, "usage: quit") \
18574 _(quit, "usage: quit") \
18575 _(search_node_table, "usage: search_node_table <name>...") \
18576 _(set, "usage: set <variable-name> <value>") \
18577 _(script, "usage: script <file-name>") \
18578 _(unset, "usage: unset <variable-name>")
18581 static void vl_api_##n##_t_handler_uni \
18582 (vl_api_##n##_t * mp) \
18584 vat_main_t * vam = &vat_main; \
18585 if (vam->json_output) { \
18586 vl_api_##n##_t_handler_json(mp); \
18588 vl_api_##n##_t_handler(mp); \
18591 foreach_vpe_api_reply_msg;
18596 static void vl_api_##n##_t_handler_uni \
18597 (vl_api_##n##_t * mp) \
18599 vat_main_t * vam = &vat_main; \
18600 if (vam->json_output) { \
18601 vl_api_##n##_t_handler_json(mp); \
18603 vl_api_##n##_t_handler(mp); \
18606 foreach_vpe_dpdk_api_reply_msg;
18611 vat_api_hookup (vat_main_t * vam)
18614 vl_msg_api_set_handlers(VL_API_##N, #n, \
18615 vl_api_##n##_t_handler_uni, \
18617 vl_api_##n##_t_endian, \
18618 vl_api_##n##_t_print, \
18619 sizeof(vl_api_##n##_t), 1);
18620 foreach_vpe_api_reply_msg;
18625 vl_msg_api_set_handlers(VL_API_##N, #n, \
18626 vl_api_##n##_t_handler_uni, \
18628 vl_api_##n##_t_endian, \
18629 vl_api_##n##_t_print, \
18630 sizeof(vl_api_##n##_t), 1);
18631 foreach_vpe_dpdk_api_reply_msg;
18635 #if (VPP_API_TEST_BUILTIN==0)
18636 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18639 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18641 vam->function_by_name = hash_create_string (0, sizeof (uword));
18643 vam->help_by_name = hash_create_string (0, sizeof (uword));
18645 /* API messages we can send */
18646 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18647 foreach_vpe_api_msg;
18650 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18651 foreach_vpe_dpdk_api_msg;
18656 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18657 foreach_vpe_api_msg;
18660 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18661 foreach_vpe_dpdk_api_msg;
18665 /* CLI functions */
18666 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18667 foreach_cli_function;
18671 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18672 foreach_cli_function;
18677 * fd.io coding-style-patch-verification: ON
18680 * eval: (c-set-style "gnu")