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 format_gpe_encap_mode (u8 * s, va_list * args)
2735 u32 mode = va_arg (*args, u32);
2740 return format (s, "lisp");
2742 return format (s, "vxlan");
2748 vl_api_gpe_get_encap_mode_reply_t_handler
2749 (vl_api_gpe_get_encap_mode_reply_t * mp)
2751 vat_main_t *vam = &vat_main;
2753 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2754 vam->retval = ntohl (mp->retval);
2755 vam->result_ready = 1;
2759 vl_api_gpe_get_encap_mode_reply_t_handler_json
2760 (vl_api_gpe_get_encap_mode_reply_t * mp)
2762 vat_main_t *vam = &vat_main;
2763 vat_json_node_t node;
2765 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2766 vec_add1 (encap_mode, 0);
2768 vat_json_init_object (&node);
2769 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2771 vec_free (encap_mode);
2772 vat_json_print (vam->ofp, &node);
2773 vat_json_free (&node);
2775 vam->retval = ntohl (mp->retval);
2776 vam->result_ready = 1;
2780 vl_api_gpe_fwd_entry_path_details_t_handler
2781 (vl_api_gpe_fwd_entry_path_details_t * mp)
2783 vat_main_t *vam = &vat_main;
2784 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2786 if (mp->lcl_loc.is_ip4)
2787 format_ip_address_fcn = format_ip4_address;
2789 format_ip_address_fcn = format_ip6_address;
2791 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2792 format_ip_address_fcn, &mp->lcl_loc,
2793 format_ip_address_fcn, &mp->rmt_loc);
2797 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2799 struct in6_addr ip6;
2804 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2805 vat_json_object_add_ip4 (n, "address", ip4);
2809 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2810 vat_json_object_add_ip6 (n, "address", ip6);
2812 vat_json_object_add_uint (n, "weight", loc->weight);
2816 vl_api_gpe_fwd_entry_path_details_t_handler_json
2817 (vl_api_gpe_fwd_entry_path_details_t * mp)
2819 vat_main_t *vam = &vat_main;
2820 vat_json_node_t *node = NULL;
2821 vat_json_node_t *loc_node;
2823 if (VAT_JSON_ARRAY != vam->json_tree.type)
2825 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2826 vat_json_init_array (&vam->json_tree);
2828 node = vat_json_array_add (&vam->json_tree);
2829 vat_json_init_object (node);
2831 loc_node = vat_json_object_add (node, "local_locator");
2832 vat_json_init_object (loc_node);
2833 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2835 loc_node = vat_json_object_add (node, "remote_locator");
2836 vat_json_init_object (loc_node);
2837 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2841 vl_api_gpe_fwd_entries_get_reply_t_handler
2842 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2844 vat_main_t *vam = &vat_main;
2846 int retval = clib_net_to_host_u32 (mp->retval);
2847 vl_api_gpe_fwd_entry_t *e;
2852 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2854 for (i = 0; i < mp->count; i++)
2856 e = &mp->entries[i];
2857 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2858 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2859 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2863 vam->retval = retval;
2864 vam->result_ready = 1;
2868 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2869 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2872 vat_main_t *vam = &vat_main;
2873 vat_json_node_t *e = 0, root;
2875 int retval = clib_net_to_host_u32 (mp->retval);
2876 vl_api_gpe_fwd_entry_t *fwd;
2881 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2882 vat_json_init_array (&root);
2884 for (i = 0; i < mp->count; i++)
2886 e = vat_json_array_add (&root);
2887 fwd = &mp->entries[i];
2889 vat_json_init_object (e);
2890 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2891 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2893 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2894 fwd->leid_prefix_len);
2896 vat_json_object_add_string_copy (e, "leid", s);
2899 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2900 fwd->reid_prefix_len);
2902 vat_json_object_add_string_copy (e, "reid", s);
2906 vat_json_print (vam->ofp, &root);
2907 vat_json_free (&root);
2910 vam->retval = retval;
2911 vam->result_ready = 1;
2915 vl_api_one_adjacencies_get_reply_t_handler
2916 (vl_api_one_adjacencies_get_reply_t * mp)
2918 vat_main_t *vam = &vat_main;
2920 int retval = clib_net_to_host_u32 (mp->retval);
2921 vl_api_one_adjacency_t *a;
2926 n = clib_net_to_host_u32 (mp->count);
2928 for (i = 0; i < n; i++)
2930 a = &mp->adjacencies[i];
2931 print (vam->ofp, "%U %40U",
2932 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2933 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2937 vam->retval = retval;
2938 vam->result_ready = 1;
2942 vl_api_one_adjacencies_get_reply_t_handler_json
2943 (vl_api_one_adjacencies_get_reply_t * mp)
2946 vat_main_t *vam = &vat_main;
2947 vat_json_node_t *e = 0, root;
2949 int retval = clib_net_to_host_u32 (mp->retval);
2950 vl_api_one_adjacency_t *a;
2955 n = clib_net_to_host_u32 (mp->count);
2956 vat_json_init_array (&root);
2958 for (i = 0; i < n; i++)
2960 e = vat_json_array_add (&root);
2961 a = &mp->adjacencies[i];
2963 vat_json_init_object (e);
2964 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2965 a->leid_prefix_len);
2967 vat_json_object_add_string_copy (e, "leid", s);
2970 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2971 a->reid_prefix_len);
2973 vat_json_object_add_string_copy (e, "reid", s);
2977 vat_json_print (vam->ofp, &root);
2978 vat_json_free (&root);
2981 vam->retval = retval;
2982 vam->result_ready = 1;
2986 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
2988 vat_main_t *vam = &vat_main;
2990 print (vam->ofp, "%=20U",
2991 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2996 vl_api_one_map_server_details_t_handler_json
2997 (vl_api_one_map_server_details_t * mp)
2999 vat_main_t *vam = &vat_main;
3000 vat_json_node_t *node = NULL;
3001 struct in6_addr ip6;
3004 if (VAT_JSON_ARRAY != vam->json_tree.type)
3006 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3007 vat_json_init_array (&vam->json_tree);
3009 node = vat_json_array_add (&vam->json_tree);
3011 vat_json_init_object (node);
3014 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3015 vat_json_object_add_ip6 (node, "map-server", ip6);
3019 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3020 vat_json_object_add_ip4 (node, "map-server", ip4);
3025 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3028 vat_main_t *vam = &vat_main;
3030 print (vam->ofp, "%=20U",
3031 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3036 vl_api_one_map_resolver_details_t_handler_json
3037 (vl_api_one_map_resolver_details_t * mp)
3039 vat_main_t *vam = &vat_main;
3040 vat_json_node_t *node = NULL;
3041 struct in6_addr ip6;
3044 if (VAT_JSON_ARRAY != vam->json_tree.type)
3046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3047 vat_json_init_array (&vam->json_tree);
3049 node = vat_json_array_add (&vam->json_tree);
3051 vat_json_init_object (node);
3054 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3055 vat_json_object_add_ip6 (node, "map resolver", ip6);
3059 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3060 vat_json_object_add_ip4 (node, "map resolver", ip4);
3065 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3067 vat_main_t *vam = &vat_main;
3068 i32 retval = ntohl (mp->retval);
3072 print (vam->ofp, "feature: %s\ngpe: %s",
3073 mp->feature_status ? "enabled" : "disabled",
3074 mp->gpe_status ? "enabled" : "disabled");
3077 vam->retval = retval;
3078 vam->result_ready = 1;
3082 vl_api_show_one_status_reply_t_handler_json
3083 (vl_api_show_one_status_reply_t * mp)
3085 vat_main_t *vam = &vat_main;
3086 vat_json_node_t node;
3087 u8 *gpe_status = NULL;
3088 u8 *feature_status = NULL;
3090 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3091 feature_status = format (0, "%s",
3092 mp->feature_status ? "enabled" : "disabled");
3093 vec_add1 (gpe_status, 0);
3094 vec_add1 (feature_status, 0);
3096 vat_json_init_object (&node);
3097 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3098 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3100 vec_free (gpe_status);
3101 vec_free (feature_status);
3103 vat_json_print (vam->ofp, &node);
3104 vat_json_free (&node);
3106 vam->retval = ntohl (mp->retval);
3107 vam->result_ready = 1;
3111 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3112 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3114 vat_main_t *vam = &vat_main;
3115 i32 retval = ntohl (mp->retval);
3119 print (vam->ofp, "%=20s", mp->locator_set_name);
3122 vam->retval = retval;
3123 vam->result_ready = 1;
3127 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3128 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3130 vat_main_t *vam = &vat_main;
3131 vat_json_node_t *node = NULL;
3133 if (VAT_JSON_ARRAY != vam->json_tree.type)
3135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3136 vat_json_init_array (&vam->json_tree);
3138 node = vat_json_array_add (&vam->json_tree);
3140 vat_json_init_object (node);
3141 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3143 vat_json_print (vam->ofp, node);
3144 vat_json_free (node);
3146 vam->retval = ntohl (mp->retval);
3147 vam->result_ready = 1;
3151 format_lisp_map_request_mode (u8 * s, va_list * args)
3153 u32 mode = va_arg (*args, u32);
3158 return format (0, "dst-only");
3160 return format (0, "src-dst");
3166 vl_api_show_one_map_request_mode_reply_t_handler
3167 (vl_api_show_one_map_request_mode_reply_t * mp)
3169 vat_main_t *vam = &vat_main;
3170 i32 retval = ntohl (mp->retval);
3174 u32 mode = mp->mode;
3175 print (vam->ofp, "map_request_mode: %U",
3176 format_lisp_map_request_mode, mode);
3179 vam->retval = retval;
3180 vam->result_ready = 1;
3184 vl_api_show_one_map_request_mode_reply_t_handler_json
3185 (vl_api_show_one_map_request_mode_reply_t * mp)
3187 vat_main_t *vam = &vat_main;
3188 vat_json_node_t node;
3193 s = format (0, "%U", format_lisp_map_request_mode, mode);
3196 vat_json_init_object (&node);
3197 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3198 vat_json_print (vam->ofp, &node);
3199 vat_json_free (&node);
3202 vam->retval = ntohl (mp->retval);
3203 vam->result_ready = 1;
3207 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3209 vat_main_t *vam = &vat_main;
3210 i32 retval = ntohl (mp->retval);
3214 print (vam->ofp, "%-20s%-16s",
3215 mp->status ? "enabled" : "disabled",
3216 mp->status ? (char *) mp->locator_set_name : "");
3219 vam->retval = retval;
3220 vam->result_ready = 1;
3224 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3226 vat_main_t *vam = &vat_main;
3227 vat_json_node_t node;
3230 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3231 vec_add1 (status, 0);
3233 vat_json_init_object (&node);
3234 vat_json_object_add_string_copy (&node, "status", status);
3237 vat_json_object_add_string_copy (&node, "locator_set",
3238 mp->locator_set_name);
3243 vat_json_print (vam->ofp, &node);
3244 vat_json_free (&node);
3246 vam->retval = ntohl (mp->retval);
3247 vam->result_ready = 1;
3251 format_policer_type (u8 * s, va_list * va)
3253 u32 i = va_arg (*va, u32);
3255 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3256 s = format (s, "1r2c");
3257 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3258 s = format (s, "1r3c");
3259 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3260 s = format (s, "2r3c-2698");
3261 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3262 s = format (s, "2r3c-4115");
3263 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3264 s = format (s, "2r3c-mef5cf1");
3266 s = format (s, "ILLEGAL");
3271 format_policer_rate_type (u8 * s, va_list * va)
3273 u32 i = va_arg (*va, u32);
3275 if (i == SSE2_QOS_RATE_KBPS)
3276 s = format (s, "kbps");
3277 else if (i == SSE2_QOS_RATE_PPS)
3278 s = format (s, "pps");
3280 s = format (s, "ILLEGAL");
3285 format_policer_round_type (u8 * s, va_list * va)
3287 u32 i = va_arg (*va, u32);
3289 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3290 s = format (s, "closest");
3291 else if (i == SSE2_QOS_ROUND_TO_UP)
3292 s = format (s, "up");
3293 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3294 s = format (s, "down");
3296 s = format (s, "ILLEGAL");
3301 format_policer_action_type (u8 * s, va_list * va)
3303 u32 i = va_arg (*va, u32);
3305 if (i == SSE2_QOS_ACTION_DROP)
3306 s = format (s, "drop");
3307 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3308 s = format (s, "transmit");
3309 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3310 s = format (s, "mark-and-transmit");
3312 s = format (s, "ILLEGAL");
3317 format_dscp (u8 * s, va_list * va)
3319 u32 i = va_arg (*va, u32);
3324 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3328 return format (s, "ILLEGAL");
3330 s = format (s, "%s", t);
3335 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3337 vat_main_t *vam = &vat_main;
3338 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3340 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3341 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3343 conform_dscp_str = format (0, "");
3345 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3346 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3348 exceed_dscp_str = format (0, "");
3350 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3351 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3353 violate_dscp_str = format (0, "");
3355 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3356 "rate type %U, round type %U, %s rate, %s color-aware, "
3357 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3358 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3359 "conform action %U%s, exceed action %U%s, violate action %U%s",
3361 format_policer_type, mp->type,
3364 clib_net_to_host_u64 (mp->cb),
3365 clib_net_to_host_u64 (mp->eb),
3366 format_policer_rate_type, mp->rate_type,
3367 format_policer_round_type, mp->round_type,
3368 mp->single_rate ? "single" : "dual",
3369 mp->color_aware ? "is" : "not",
3370 ntohl (mp->cir_tokens_per_period),
3371 ntohl (mp->pir_tokens_per_period),
3373 ntohl (mp->current_limit),
3374 ntohl (mp->current_bucket),
3375 ntohl (mp->extended_limit),
3376 ntohl (mp->extended_bucket),
3377 clib_net_to_host_u64 (mp->last_update_time),
3378 format_policer_action_type, mp->conform_action_type,
3380 format_policer_action_type, mp->exceed_action_type,
3382 format_policer_action_type, mp->violate_action_type,
3385 vec_free (conform_dscp_str);
3386 vec_free (exceed_dscp_str);
3387 vec_free (violate_dscp_str);
3390 static void vl_api_policer_details_t_handler_json
3391 (vl_api_policer_details_t * mp)
3393 vat_main_t *vam = &vat_main;
3394 vat_json_node_t *node;
3395 u8 *rate_type_str, *round_type_str, *type_str;
3396 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3398 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3400 format (0, "%U", format_policer_round_type, mp->round_type);
3401 type_str = format (0, "%U", format_policer_type, mp->type);
3402 conform_action_str = format (0, "%U", format_policer_action_type,
3403 mp->conform_action_type);
3404 exceed_action_str = format (0, "%U", format_policer_action_type,
3405 mp->exceed_action_type);
3406 violate_action_str = format (0, "%U", format_policer_action_type,
3407 mp->violate_action_type);
3409 if (VAT_JSON_ARRAY != vam->json_tree.type)
3411 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3412 vat_json_init_array (&vam->json_tree);
3414 node = vat_json_array_add (&vam->json_tree);
3416 vat_json_init_object (node);
3417 vat_json_object_add_string_copy (node, "name", mp->name);
3418 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3419 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3420 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3421 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3422 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3423 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3424 vat_json_object_add_string_copy (node, "type", type_str);
3425 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3426 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3427 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3428 vat_json_object_add_uint (node, "cir_tokens_per_period",
3429 ntohl (mp->cir_tokens_per_period));
3430 vat_json_object_add_uint (node, "eir_tokens_per_period",
3431 ntohl (mp->pir_tokens_per_period));
3432 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3433 vat_json_object_add_uint (node, "current_bucket",
3434 ntohl (mp->current_bucket));
3435 vat_json_object_add_uint (node, "extended_limit",
3436 ntohl (mp->extended_limit));
3437 vat_json_object_add_uint (node, "extended_bucket",
3438 ntohl (mp->extended_bucket));
3439 vat_json_object_add_uint (node, "last_update_time",
3440 ntohl (mp->last_update_time));
3441 vat_json_object_add_string_copy (node, "conform_action",
3442 conform_action_str);
3443 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3445 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3446 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3447 vec_free (dscp_str);
3449 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3450 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3452 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3453 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3454 vec_free (dscp_str);
3456 vat_json_object_add_string_copy (node, "violate_action",
3457 violate_action_str);
3458 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3460 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3461 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3462 vec_free (dscp_str);
3465 vec_free (rate_type_str);
3466 vec_free (round_type_str);
3467 vec_free (type_str);
3468 vec_free (conform_action_str);
3469 vec_free (exceed_action_str);
3470 vec_free (violate_action_str);
3474 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3477 vat_main_t *vam = &vat_main;
3478 int i, count = ntohl (mp->count);
3481 print (vam->ofp, "classify table ids (%d) : ", count);
3482 for (i = 0; i < count; i++)
3484 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3485 print (vam->ofp, (i < count - 1) ? "," : "");
3487 vam->retval = ntohl (mp->retval);
3488 vam->result_ready = 1;
3492 vl_api_classify_table_ids_reply_t_handler_json
3493 (vl_api_classify_table_ids_reply_t * mp)
3495 vat_main_t *vam = &vat_main;
3496 int i, count = ntohl (mp->count);
3500 vat_json_node_t node;
3502 vat_json_init_object (&node);
3503 for (i = 0; i < count; i++)
3505 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3507 vat_json_print (vam->ofp, &node);
3508 vat_json_free (&node);
3510 vam->retval = ntohl (mp->retval);
3511 vam->result_ready = 1;
3515 vl_api_classify_table_by_interface_reply_t_handler
3516 (vl_api_classify_table_by_interface_reply_t * mp)
3518 vat_main_t *vam = &vat_main;
3521 table_id = ntohl (mp->l2_table_id);
3523 print (vam->ofp, "l2 table id : %d", table_id);
3525 print (vam->ofp, "l2 table id : No input ACL tables configured");
3526 table_id = ntohl (mp->ip4_table_id);
3528 print (vam->ofp, "ip4 table id : %d", table_id);
3530 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3531 table_id = ntohl (mp->ip6_table_id);
3533 print (vam->ofp, "ip6 table id : %d", table_id);
3535 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3536 vam->retval = ntohl (mp->retval);
3537 vam->result_ready = 1;
3541 vl_api_classify_table_by_interface_reply_t_handler_json
3542 (vl_api_classify_table_by_interface_reply_t * mp)
3544 vat_main_t *vam = &vat_main;
3545 vat_json_node_t node;
3547 vat_json_init_object (&node);
3549 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3550 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3551 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3553 vat_json_print (vam->ofp, &node);
3554 vat_json_free (&node);
3556 vam->retval = ntohl (mp->retval);
3557 vam->result_ready = 1;
3560 static void vl_api_policer_add_del_reply_t_handler
3561 (vl_api_policer_add_del_reply_t * mp)
3563 vat_main_t *vam = &vat_main;
3564 i32 retval = ntohl (mp->retval);
3565 if (vam->async_mode)
3567 vam->async_errors += (retval < 0);
3571 vam->retval = retval;
3572 vam->result_ready = 1;
3573 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3575 * Note: this is just barely thread-safe, depends on
3576 * the main thread spinning waiting for an answer...
3578 errmsg ("policer index %d", ntohl (mp->policer_index));
3582 static void vl_api_policer_add_del_reply_t_handler_json
3583 (vl_api_policer_add_del_reply_t * mp)
3585 vat_main_t *vam = &vat_main;
3586 vat_json_node_t node;
3588 vat_json_init_object (&node);
3589 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3590 vat_json_object_add_uint (&node, "policer_index",
3591 ntohl (mp->policer_index));
3593 vat_json_print (vam->ofp, &node);
3594 vat_json_free (&node);
3596 vam->retval = ntohl (mp->retval);
3597 vam->result_ready = 1;
3600 /* Format hex dump. */
3602 format_hex_bytes (u8 * s, va_list * va)
3604 u8 *bytes = va_arg (*va, u8 *);
3605 int n_bytes = va_arg (*va, int);
3608 /* Print short or long form depending on byte count. */
3609 uword short_form = n_bytes <= 32;
3610 uword indent = format_get_indent (s);
3615 for (i = 0; i < n_bytes; i++)
3617 if (!short_form && (i % 32) == 0)
3618 s = format (s, "%08x: ", i);
3619 s = format (s, "%02x", bytes[i]);
3620 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3621 s = format (s, "\n%U", format_white_space, indent);
3628 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3631 vat_main_t *vam = &vat_main;
3632 i32 retval = ntohl (mp->retval);
3635 print (vam->ofp, "classify table info :");
3636 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3637 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3638 ntohl (mp->miss_next_index));
3639 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3640 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3641 ntohl (mp->match_n_vectors));
3642 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3643 ntohl (mp->mask_length));
3645 vam->retval = retval;
3646 vam->result_ready = 1;
3650 vl_api_classify_table_info_reply_t_handler_json
3651 (vl_api_classify_table_info_reply_t * mp)
3653 vat_main_t *vam = &vat_main;
3654 vat_json_node_t node;
3656 i32 retval = ntohl (mp->retval);
3659 vat_json_init_object (&node);
3661 vat_json_object_add_int (&node, "sessions",
3662 ntohl (mp->active_sessions));
3663 vat_json_object_add_int (&node, "nexttbl",
3664 ntohl (mp->next_table_index));
3665 vat_json_object_add_int (&node, "nextnode",
3666 ntohl (mp->miss_next_index));
3667 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3668 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3669 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3670 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3671 ntohl (mp->mask_length), 0);
3672 vat_json_object_add_string_copy (&node, "mask", s);
3674 vat_json_print (vam->ofp, &node);
3675 vat_json_free (&node);
3677 vam->retval = ntohl (mp->retval);
3678 vam->result_ready = 1;
3682 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3685 vat_main_t *vam = &vat_main;
3687 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3688 ntohl (mp->hit_next_index), ntohl (mp->advance),
3689 ntohl (mp->opaque_index));
3690 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3691 ntohl (mp->match_length));
3695 vl_api_classify_session_details_t_handler_json
3696 (vl_api_classify_session_details_t * mp)
3698 vat_main_t *vam = &vat_main;
3699 vat_json_node_t *node = NULL;
3701 if (VAT_JSON_ARRAY != vam->json_tree.type)
3703 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3704 vat_json_init_array (&vam->json_tree);
3706 node = vat_json_array_add (&vam->json_tree);
3708 vat_json_init_object (node);
3709 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3710 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3711 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3713 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3715 vat_json_object_add_string_copy (node, "match", s);
3718 static void vl_api_pg_create_interface_reply_t_handler
3719 (vl_api_pg_create_interface_reply_t * mp)
3721 vat_main_t *vam = &vat_main;
3723 vam->retval = ntohl (mp->retval);
3724 vam->result_ready = 1;
3727 static void vl_api_pg_create_interface_reply_t_handler_json
3728 (vl_api_pg_create_interface_reply_t * mp)
3730 vat_main_t *vam = &vat_main;
3731 vat_json_node_t node;
3733 i32 retval = ntohl (mp->retval);
3736 vat_json_init_object (&node);
3738 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3740 vat_json_print (vam->ofp, &node);
3741 vat_json_free (&node);
3743 vam->retval = ntohl (mp->retval);
3744 vam->result_ready = 1;
3747 static void vl_api_policer_classify_details_t_handler
3748 (vl_api_policer_classify_details_t * mp)
3750 vat_main_t *vam = &vat_main;
3752 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3753 ntohl (mp->table_index));
3756 static void vl_api_policer_classify_details_t_handler_json
3757 (vl_api_policer_classify_details_t * mp)
3759 vat_main_t *vam = &vat_main;
3760 vat_json_node_t *node;
3762 if (VAT_JSON_ARRAY != vam->json_tree.type)
3764 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3765 vat_json_init_array (&vam->json_tree);
3767 node = vat_json_array_add (&vam->json_tree);
3769 vat_json_init_object (node);
3770 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3771 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3774 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3775 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3777 vat_main_t *vam = &vat_main;
3778 i32 retval = ntohl (mp->retval);
3779 if (vam->async_mode)
3781 vam->async_errors += (retval < 0);
3785 vam->retval = retval;
3786 vam->sw_if_index = ntohl (mp->sw_if_index);
3787 vam->result_ready = 1;
3791 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3792 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3794 vat_main_t *vam = &vat_main;
3795 vat_json_node_t node;
3797 vat_json_init_object (&node);
3798 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3799 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3801 vat_json_print (vam->ofp, &node);
3802 vat_json_free (&node);
3804 vam->retval = ntohl (mp->retval);
3805 vam->result_ready = 1;
3808 static void vl_api_flow_classify_details_t_handler
3809 (vl_api_flow_classify_details_t * mp)
3811 vat_main_t *vam = &vat_main;
3813 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3814 ntohl (mp->table_index));
3817 static void vl_api_flow_classify_details_t_handler_json
3818 (vl_api_flow_classify_details_t * mp)
3820 vat_main_t *vam = &vat_main;
3821 vat_json_node_t *node;
3823 if (VAT_JSON_ARRAY != vam->json_tree.type)
3825 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3826 vat_json_init_array (&vam->json_tree);
3828 node = vat_json_array_add (&vam->json_tree);
3830 vat_json_init_object (node);
3831 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3832 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3837 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3838 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3839 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3840 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3841 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3842 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3843 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3844 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3845 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3846 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3849 * Generate boilerplate reply handlers, which
3850 * dig the return value out of the xxx_reply_t API message,
3851 * stick it into vam->retval, and set vam->result_ready
3853 * Could also do this by pointing N message decode slots at
3854 * a single function, but that could break in subtle ways.
3857 #define foreach_standard_reply_retval_handler \
3858 _(sw_interface_set_flags_reply) \
3859 _(sw_interface_add_del_address_reply) \
3860 _(sw_interface_set_table_reply) \
3861 _(sw_interface_set_mpls_enable_reply) \
3862 _(sw_interface_set_vpath_reply) \
3863 _(sw_interface_set_vxlan_bypass_reply) \
3864 _(sw_interface_set_l2_bridge_reply) \
3865 _(bridge_domain_add_del_reply) \
3866 _(sw_interface_set_l2_xconnect_reply) \
3867 _(l2fib_add_del_reply) \
3868 _(ip_add_del_route_reply) \
3869 _(ip_mroute_add_del_reply) \
3870 _(mpls_route_add_del_reply) \
3871 _(mpls_ip_bind_unbind_reply) \
3872 _(proxy_arp_add_del_reply) \
3873 _(proxy_arp_intfc_enable_disable_reply) \
3874 _(sw_interface_set_unnumbered_reply) \
3875 _(ip_neighbor_add_del_reply) \
3876 _(reset_vrf_reply) \
3877 _(oam_add_del_reply) \
3878 _(reset_fib_reply) \
3879 _(dhcp_proxy_config_reply) \
3880 _(dhcp_proxy_set_vss_reply) \
3881 _(dhcp_client_config_reply) \
3882 _(set_ip_flow_hash_reply) \
3883 _(sw_interface_ip6_enable_disable_reply) \
3884 _(sw_interface_ip6_set_link_local_address_reply) \
3885 _(sw_interface_ip6nd_ra_prefix_reply) \
3886 _(sw_interface_ip6nd_ra_config_reply) \
3887 _(set_arp_neighbor_limit_reply) \
3888 _(l2_patch_add_del_reply) \
3889 _(sr_tunnel_add_del_reply) \
3890 _(sr_policy_add_del_reply) \
3891 _(sr_multicast_map_add_del_reply) \
3892 _(classify_add_del_session_reply) \
3893 _(classify_set_interface_ip_table_reply) \
3894 _(classify_set_interface_l2_tables_reply) \
3895 _(l2tpv3_set_tunnel_cookies_reply) \
3896 _(l2tpv3_interface_enable_disable_reply) \
3897 _(l2tpv3_set_lookup_key_reply) \
3898 _(l2_fib_clear_table_reply) \
3899 _(l2_interface_efp_filter_reply) \
3900 _(l2_interface_vlan_tag_rewrite_reply) \
3901 _(modify_vhost_user_if_reply) \
3902 _(delete_vhost_user_if_reply) \
3903 _(want_ip4_arp_events_reply) \
3904 _(want_ip6_nd_events_reply) \
3905 _(input_acl_set_interface_reply) \
3906 _(ipsec_spd_add_del_reply) \
3907 _(ipsec_interface_add_del_spd_reply) \
3908 _(ipsec_spd_add_del_entry_reply) \
3909 _(ipsec_sad_add_del_entry_reply) \
3910 _(ipsec_sa_set_key_reply) \
3911 _(ikev2_profile_add_del_reply) \
3912 _(ikev2_profile_set_auth_reply) \
3913 _(ikev2_profile_set_id_reply) \
3914 _(ikev2_profile_set_ts_reply) \
3915 _(ikev2_set_local_key_reply) \
3916 _(ikev2_set_responder_reply) \
3917 _(ikev2_set_ike_transforms_reply) \
3918 _(ikev2_set_esp_transforms_reply) \
3919 _(ikev2_set_sa_lifetime_reply) \
3920 _(ikev2_initiate_sa_init_reply) \
3921 _(ikev2_initiate_del_ike_sa_reply) \
3922 _(ikev2_initiate_del_child_sa_reply) \
3923 _(ikev2_initiate_rekey_child_sa_reply) \
3924 _(delete_loopback_reply) \
3925 _(bd_ip_mac_add_del_reply) \
3926 _(map_del_domain_reply) \
3927 _(map_add_del_rule_reply) \
3928 _(want_interface_events_reply) \
3929 _(want_stats_reply) \
3930 _(cop_interface_enable_disable_reply) \
3931 _(cop_whitelist_enable_disable_reply) \
3932 _(sw_interface_clear_stats_reply) \
3933 _(ioam_enable_reply) \
3934 _(ioam_disable_reply) \
3935 _(one_add_del_locator_reply) \
3936 _(one_add_del_local_eid_reply) \
3937 _(one_add_del_remote_mapping_reply) \
3938 _(one_add_del_adjacency_reply) \
3939 _(one_add_del_map_resolver_reply) \
3940 _(one_add_del_map_server_reply) \
3941 _(one_enable_disable_reply) \
3942 _(one_rloc_probe_enable_disable_reply) \
3943 _(one_map_register_enable_disable_reply) \
3944 _(one_pitr_set_locator_set_reply) \
3945 _(one_map_request_mode_reply) \
3946 _(one_add_del_map_request_itr_rlocs_reply) \
3947 _(one_eid_table_add_del_map_reply) \
3948 _(gpe_add_del_fwd_entry_reply) \
3949 _(gpe_enable_disable_reply) \
3950 _(gpe_set_encap_mode_reply) \
3951 _(gpe_add_del_iface_reply) \
3952 _(vxlan_gpe_add_del_tunnel_reply) \
3953 _(af_packet_delete_reply) \
3954 _(policer_classify_set_interface_reply) \
3955 _(netmap_create_reply) \
3956 _(netmap_delete_reply) \
3957 _(set_ipfix_exporter_reply) \
3958 _(set_ipfix_classify_stream_reply) \
3959 _(ipfix_classify_table_add_del_reply) \
3960 _(flow_classify_set_interface_reply) \
3961 _(sw_interface_span_enable_disable_reply) \
3962 _(pg_capture_reply) \
3963 _(pg_enable_disable_reply) \
3964 _(ip_source_and_port_range_check_add_del_reply) \
3965 _(ip_source_and_port_range_check_interface_add_del_reply)\
3966 _(delete_subif_reply) \
3967 _(l2_interface_pbb_tag_rewrite_reply) \
3969 _(feature_enable_disable_reply) \
3970 _(sw_interface_tag_add_del_reply) \
3971 _(sw_interface_set_mtu_reply)
3974 #define foreach_standard_dpdk_reply_retval_handler \
3975 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3976 _(sw_interface_set_dpdk_hqos_subport_reply) \
3977 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3981 static void vl_api_##n##_t_handler \
3982 (vl_api_##n##_t * mp) \
3984 vat_main_t * vam = &vat_main; \
3985 i32 retval = ntohl(mp->retval); \
3986 if (vam->async_mode) { \
3987 vam->async_errors += (retval < 0); \
3989 vam->retval = retval; \
3990 vam->result_ready = 1; \
3993 foreach_standard_reply_retval_handler;
3997 static void vl_api_##n##_t_handler_json \
3998 (vl_api_##n##_t * mp) \
4000 vat_main_t * vam = &vat_main; \
4001 vat_json_node_t node; \
4002 vat_json_init_object(&node); \
4003 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4004 vat_json_print(vam->ofp, &node); \
4005 vam->retval = ntohl(mp->retval); \
4006 vam->result_ready = 1; \
4008 foreach_standard_reply_retval_handler;
4013 static void vl_api_##n##_t_handler \
4014 (vl_api_##n##_t * mp) \
4016 vat_main_t * vam = &vat_main; \
4017 i32 retval = ntohl(mp->retval); \
4018 if (vam->async_mode) { \
4019 vam->async_errors += (retval < 0); \
4021 vam->retval = retval; \
4022 vam->result_ready = 1; \
4025 foreach_standard_dpdk_reply_retval_handler;
4029 static void vl_api_##n##_t_handler_json \
4030 (vl_api_##n##_t * mp) \
4032 vat_main_t * vam = &vat_main; \
4033 vat_json_node_t node; \
4034 vat_json_init_object(&node); \
4035 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4036 vat_json_print(vam->ofp, &node); \
4037 vam->retval = ntohl(mp->retval); \
4038 vam->result_ready = 1; \
4040 foreach_standard_dpdk_reply_retval_handler;
4045 * Table of message reply handlers, must include boilerplate handlers
4049 #define foreach_vpe_api_reply_msg \
4050 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4051 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4052 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4053 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4054 _(CONTROL_PING_REPLY, control_ping_reply) \
4055 _(CLI_REPLY, cli_reply) \
4056 _(CLI_INBAND_REPLY, cli_inband_reply) \
4057 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4058 sw_interface_add_del_address_reply) \
4059 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4060 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4061 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4062 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4063 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4064 sw_interface_set_l2_xconnect_reply) \
4065 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4066 sw_interface_set_l2_bridge_reply) \
4067 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4068 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4069 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4070 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4071 _(L2_FLAGS_REPLY, l2_flags_reply) \
4072 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4073 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4074 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4075 _(TAP_DELETE_REPLY, tap_delete_reply) \
4076 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4077 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4078 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4079 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4080 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4081 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4082 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4083 proxy_arp_intfc_enable_disable_reply) \
4084 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4085 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4086 sw_interface_set_unnumbered_reply) \
4087 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4088 _(RESET_VRF_REPLY, reset_vrf_reply) \
4089 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4090 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4091 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4092 _(RESET_FIB_REPLY, reset_fib_reply) \
4093 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4094 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4095 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4096 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4097 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4098 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4099 sw_interface_ip6_enable_disable_reply) \
4100 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4101 sw_interface_ip6_set_link_local_address_reply) \
4102 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4103 sw_interface_ip6nd_ra_prefix_reply) \
4104 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4105 sw_interface_ip6nd_ra_config_reply) \
4106 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4107 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4108 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4109 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4110 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4111 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4112 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4113 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4114 classify_set_interface_ip_table_reply) \
4115 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4116 classify_set_interface_l2_tables_reply) \
4117 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4118 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4119 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4120 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4121 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4122 l2tpv3_interface_enable_disable_reply) \
4123 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4124 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4125 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4126 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4127 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4128 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4129 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4130 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4131 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4132 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4133 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4134 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4135 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4136 _(SHOW_VERSION_REPLY, show_version_reply) \
4137 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4138 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4139 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4140 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4141 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4142 _(IP4_ARP_EVENT, ip4_arp_event) \
4143 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4144 _(IP6_ND_EVENT, ip6_nd_event) \
4145 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4146 _(IP_ADDRESS_DETAILS, ip_address_details) \
4147 _(IP_DETAILS, ip_details) \
4148 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4149 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4150 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4151 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4152 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4153 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4154 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4155 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4156 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4157 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4158 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4159 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4160 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4161 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4162 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4163 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4164 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4165 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4166 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4167 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4168 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4169 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4170 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4171 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4172 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4173 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4174 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4175 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4176 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4177 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4178 _(MAP_RULE_DETAILS, map_rule_details) \
4179 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4180 _(WANT_STATS_REPLY, want_stats_reply) \
4181 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4182 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4183 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4184 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4185 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4186 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4187 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4188 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4189 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4190 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4191 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4192 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4193 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4194 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4195 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4196 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4197 one_map_register_enable_disable_reply) \
4198 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4199 one_rloc_probe_enable_disable_reply) \
4200 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4201 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4202 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4203 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4204 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4205 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4206 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4207 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4208 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4209 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4210 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4211 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4212 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4213 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4214 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4215 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4216 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4217 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4218 gpe_fwd_entry_path_details) \
4219 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4220 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4221 one_add_del_map_request_itr_rlocs_reply) \
4222 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4223 one_get_map_request_itr_rlocs_reply) \
4224 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4225 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4226 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4227 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4228 show_one_map_register_state_reply) \
4229 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4230 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4231 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4232 _(POLICER_DETAILS, policer_details) \
4233 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4234 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4235 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4236 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4237 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4238 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4239 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4240 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4241 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4242 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4243 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4244 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4245 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4246 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4247 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4248 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4249 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4250 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4251 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4252 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4253 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4254 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4255 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4256 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4257 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4258 ip_source_and_port_range_check_add_del_reply) \
4259 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4260 ip_source_and_port_range_check_interface_add_del_reply) \
4261 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4262 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4263 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4264 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4265 _(PUNT_REPLY, punt_reply) \
4266 _(IP_FIB_DETAILS, ip_fib_details) \
4267 _(IP6_FIB_DETAILS, ip6_fib_details) \
4268 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4269 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4270 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4271 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4272 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4273 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4276 #define foreach_vpe_dpdk_api_reply_msg \
4277 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
4278 sw_interface_set_dpdk_hqos_pipe_reply) \
4279 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
4280 sw_interface_set_dpdk_hqos_subport_reply) \
4281 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
4282 sw_interface_set_dpdk_hqos_tctbl_reply)
4292 #define STR_VTR_OP_CASE(op) \
4293 case L2_VTR_ ## op: \
4297 str_vtr_op (u32 vtr_op)
4301 STR_VTR_OP_CASE (DISABLED);
4302 STR_VTR_OP_CASE (PUSH_1);
4303 STR_VTR_OP_CASE (PUSH_2);
4304 STR_VTR_OP_CASE (POP_1);
4305 STR_VTR_OP_CASE (POP_2);
4306 STR_VTR_OP_CASE (TRANSLATE_1_1);
4307 STR_VTR_OP_CASE (TRANSLATE_1_2);
4308 STR_VTR_OP_CASE (TRANSLATE_2_1);
4309 STR_VTR_OP_CASE (TRANSLATE_2_2);
4316 dump_sub_interface_table (vat_main_t * vam)
4318 const sw_interface_subif_t *sub = NULL;
4320 if (vam->json_output)
4323 ("JSON output supported only for VPE API calls and dump_stats_table");
4328 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4329 "Interface", "sw_if_index",
4330 "sub id", "dot1ad", "tags", "outer id",
4331 "inner id", "exact", "default", "outer any", "inner any");
4333 vec_foreach (sub, vam->sw_if_subif_table)
4336 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4337 sub->interface_name,
4339 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4340 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4341 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4342 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4343 if (sub->vtr_op != L2_VTR_DISABLED)
4346 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4347 "tag1: %d tag2: %d ]",
4348 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4349 sub->vtr_tag1, sub->vtr_tag2);
4357 name_sort_cmp (void *a1, void *a2)
4359 name_sort_t *n1 = a1;
4360 name_sort_t *n2 = a2;
4362 return strcmp ((char *) n1->name, (char *) n2->name);
4366 dump_interface_table (vat_main_t * vam)
4369 name_sort_t *nses = 0, *ns;
4371 if (vam->json_output)
4374 ("JSON output supported only for VPE API calls and dump_stats_table");
4379 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4381 vec_add2 (nses, ns, 1);
4382 ns->name = (u8 *)(p->key);
4383 ns->value = (u32) p->value[0];
4387 vec_sort_with_function (nses, name_sort_cmp);
4389 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4390 vec_foreach (ns, nses)
4392 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4399 dump_ip_table (vat_main_t * vam, int is_ipv6)
4401 const ip_details_t *det = NULL;
4402 const ip_address_details_t *address = NULL;
4405 print (vam->ofp, "%-12s", "sw_if_index");
4407 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4414 print (vam->ofp, "%-12d", i);
4415 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4420 vec_foreach (address, det->addr)
4424 is_ipv6 ? format_ip6_address : format_ip4_address,
4425 address->ip, address->prefix_length);
4433 dump_ipv4_table (vat_main_t * vam)
4435 if (vam->json_output)
4438 ("JSON output supported only for VPE API calls and dump_stats_table");
4442 return dump_ip_table (vam, 0);
4446 dump_ipv6_table (vat_main_t * vam)
4448 if (vam->json_output)
4451 ("JSON output supported only for VPE API calls and dump_stats_table");
4455 return dump_ip_table (vam, 1);
4459 counter_type_to_str (u8 counter_type, u8 is_combined)
4463 switch (counter_type)
4465 case VNET_INTERFACE_COUNTER_DROP:
4467 case VNET_INTERFACE_COUNTER_PUNT:
4469 case VNET_INTERFACE_COUNTER_IP4:
4471 case VNET_INTERFACE_COUNTER_IP6:
4473 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4475 case VNET_INTERFACE_COUNTER_RX_MISS:
4477 case VNET_INTERFACE_COUNTER_RX_ERROR:
4479 case VNET_INTERFACE_COUNTER_TX_ERROR:
4482 return "INVALID-COUNTER-TYPE";
4487 switch (counter_type)
4489 case VNET_INTERFACE_COUNTER_RX:
4491 case VNET_INTERFACE_COUNTER_TX:
4494 return "INVALID-COUNTER-TYPE";
4500 dump_stats_table (vat_main_t * vam)
4502 vat_json_node_t node;
4503 vat_json_node_t *msg_array;
4504 vat_json_node_t *msg;
4505 vat_json_node_t *counter_array;
4506 vat_json_node_t *counter;
4507 interface_counter_t c;
4509 ip4_fib_counter_t *c4;
4510 ip6_fib_counter_t *c6;
4511 ip4_nbr_counter_t *n4;
4512 ip6_nbr_counter_t *n6;
4515 if (!vam->json_output)
4517 clib_warning ("dump_stats_table supported only in JSON format");
4521 vat_json_init_object (&node);
4523 /* interface counters */
4524 msg_array = vat_json_object_add (&node, "interface_counters");
4525 vat_json_init_array (msg_array);
4526 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4528 msg = vat_json_array_add (msg_array);
4529 vat_json_init_object (msg);
4530 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4531 (u8 *) counter_type_to_str (i, 0));
4532 vat_json_object_add_int (msg, "is_combined", 0);
4533 counter_array = vat_json_object_add (msg, "data");
4534 vat_json_init_array (counter_array);
4535 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4537 packets = vam->simple_interface_counters[i][j];
4538 vat_json_array_add_uint (counter_array, packets);
4541 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4543 msg = vat_json_array_add (msg_array);
4544 vat_json_init_object (msg);
4545 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4546 (u8 *) counter_type_to_str (i, 1));
4547 vat_json_object_add_int (msg, "is_combined", 1);
4548 counter_array = vat_json_object_add (msg, "data");
4549 vat_json_init_array (counter_array);
4550 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4552 c = vam->combined_interface_counters[i][j];
4553 counter = vat_json_array_add (counter_array);
4554 vat_json_init_object (counter);
4555 vat_json_object_add_uint (counter, "packets", c.packets);
4556 vat_json_object_add_uint (counter, "bytes", c.bytes);
4560 /* ip4 fib counters */
4561 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4562 vat_json_init_array (msg_array);
4563 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4565 msg = vat_json_array_add (msg_array);
4566 vat_json_init_object (msg);
4567 vat_json_object_add_uint (msg, "vrf_id",
4568 vam->ip4_fib_counters_vrf_id_by_index[i]);
4569 counter_array = vat_json_object_add (msg, "c");
4570 vat_json_init_array (counter_array);
4571 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4573 counter = vat_json_array_add (counter_array);
4574 vat_json_init_object (counter);
4575 c4 = &vam->ip4_fib_counters[i][j];
4576 vat_json_object_add_ip4 (counter, "address", c4->address);
4577 vat_json_object_add_uint (counter, "address_length",
4578 c4->address_length);
4579 vat_json_object_add_uint (counter, "packets", c4->packets);
4580 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4584 /* ip6 fib counters */
4585 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4586 vat_json_init_array (msg_array);
4587 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4589 msg = vat_json_array_add (msg_array);
4590 vat_json_init_object (msg);
4591 vat_json_object_add_uint (msg, "vrf_id",
4592 vam->ip6_fib_counters_vrf_id_by_index[i]);
4593 counter_array = vat_json_object_add (msg, "c");
4594 vat_json_init_array (counter_array);
4595 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4597 counter = vat_json_array_add (counter_array);
4598 vat_json_init_object (counter);
4599 c6 = &vam->ip6_fib_counters[i][j];
4600 vat_json_object_add_ip6 (counter, "address", c6->address);
4601 vat_json_object_add_uint (counter, "address_length",
4602 c6->address_length);
4603 vat_json_object_add_uint (counter, "packets", c6->packets);
4604 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4608 /* ip4 nbr counters */
4609 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4610 vat_json_init_array (msg_array);
4611 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4613 msg = vat_json_array_add (msg_array);
4614 vat_json_init_object (msg);
4615 vat_json_object_add_uint (msg, "sw_if_index", i);
4616 counter_array = vat_json_object_add (msg, "c");
4617 vat_json_init_array (counter_array);
4618 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4620 counter = vat_json_array_add (counter_array);
4621 vat_json_init_object (counter);
4622 n4 = &vam->ip4_nbr_counters[i][j];
4623 vat_json_object_add_ip4 (counter, "address", n4->address);
4624 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4625 vat_json_object_add_uint (counter, "packets", n4->packets);
4626 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4630 /* ip6 nbr counters */
4631 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4632 vat_json_init_array (msg_array);
4633 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4635 msg = vat_json_array_add (msg_array);
4636 vat_json_init_object (msg);
4637 vat_json_object_add_uint (msg, "sw_if_index", i);
4638 counter_array = vat_json_object_add (msg, "c");
4639 vat_json_init_array (counter_array);
4640 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4642 counter = vat_json_array_add (counter_array);
4643 vat_json_init_object (counter);
4644 n6 = &vam->ip6_nbr_counters[i][j];
4645 vat_json_object_add_ip6 (counter, "address", n6->address);
4646 vat_json_object_add_uint (counter, "packets", n6->packets);
4647 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4651 vat_json_print (vam->ofp, &node);
4652 vat_json_free (&node);
4658 exec (vat_main_t * vam)
4660 api_main_t *am = &api_main;
4661 vl_api_cli_request_t *mp;
4665 unformat_input_t *i = vam->input;
4667 if (vec_len (i->buffer) == 0)
4670 if (vam->exec_mode == 0 && unformat (i, "mode"))
4675 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4682 M (CLI_REQUEST, mp);
4685 * Copy cmd into shared memory.
4686 * In order for the CLI command to work, it
4687 * must be a vector ending in \n, not a C-string ending
4690 pthread_mutex_lock (&am->vlib_rp->mutex);
4691 oldheap = svm_push_data_heap (am->vlib_rp);
4693 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4694 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4696 svm_pop_heap (oldheap);
4697 pthread_mutex_unlock (&am->vlib_rp->mutex);
4699 mp->cmd_in_shmem = (u64) cmd;
4701 timeout = vat_time_now (vam) + 10.0;
4703 while (vat_time_now (vam) < timeout)
4705 if (vam->result_ready == 1)
4708 if (vam->shmem_result != NULL)
4709 print (vam->ofp, "%s", vam->shmem_result);
4710 pthread_mutex_lock (&am->vlib_rp->mutex);
4711 oldheap = svm_push_data_heap (am->vlib_rp);
4713 free_me = (u8 *) vam->shmem_result;
4716 svm_pop_heap (oldheap);
4717 pthread_mutex_unlock (&am->vlib_rp->mutex);
4725 * Future replacement of exec() that passes CLI buffers directly in
4726 * the API messages instead of an additional shared memory area.
4729 exec_inband (vat_main_t * vam)
4731 vl_api_cli_inband_t *mp;
4732 unformat_input_t *i = vam->input;
4735 if (vec_len (i->buffer) == 0)
4738 if (vam->exec_mode == 0 && unformat (i, "mode"))
4743 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4750 * In order for the CLI command to work, it
4751 * must be a vector ending in \n, not a C-string ending
4754 u32 len = vec_len (vam->input->buffer);
4755 M2 (CLI_INBAND, mp, len);
4756 clib_memcpy (mp->cmd, vam->input->buffer, len);
4757 mp->length = htonl (len);
4760 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4765 api_create_loopback (vat_main_t * vam)
4767 unformat_input_t *i = vam->input;
4768 vl_api_create_loopback_t *mp;
4773 memset (mac_address, 0, sizeof (mac_address));
4775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4777 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4783 /* Construct the API message */
4784 M (CREATE_LOOPBACK, mp);
4786 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4794 api_delete_loopback (vat_main_t * vam)
4796 unformat_input_t *i = vam->input;
4797 vl_api_delete_loopback_t *mp;
4798 u32 sw_if_index = ~0;
4801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4803 if (unformat (i, "sw_if_index %d", &sw_if_index))
4809 if (sw_if_index == ~0)
4811 errmsg ("missing sw_if_index");
4815 /* Construct the API message */
4816 M (DELETE_LOOPBACK, mp);
4817 mp->sw_if_index = ntohl (sw_if_index);
4825 api_want_stats (vat_main_t * vam)
4827 unformat_input_t *i = vam->input;
4828 vl_api_want_stats_t *mp;
4832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4834 if (unformat (i, "enable"))
4836 else if (unformat (i, "disable"))
4844 errmsg ("missing enable|disable");
4849 mp->enable_disable = enable;
4857 api_want_interface_events (vat_main_t * vam)
4859 unformat_input_t *i = vam->input;
4860 vl_api_want_interface_events_t *mp;
4864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4866 if (unformat (i, "enable"))
4868 else if (unformat (i, "disable"))
4876 errmsg ("missing enable|disable");
4880 M (WANT_INTERFACE_EVENTS, mp);
4881 mp->enable_disable = enable;
4883 vam->interface_event_display = enable;
4891 /* Note: non-static, called once to set up the initial intfc table */
4893 api_sw_interface_dump (vat_main_t * vam)
4895 vl_api_sw_interface_dump_t *mp;
4896 vl_api_control_ping_t *mp_ping;
4898 name_sort_t *nses = 0, *ns;
4899 sw_interface_subif_t *sub = NULL;
4902 /* Toss the old name table */
4904 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4906 vec_add2 (nses, ns, 1);
4907 ns->name = (u8 *)(p->key);
4908 ns->value = (u32) p->value[0];
4912 hash_free (vam->sw_if_index_by_interface_name);
4914 vec_foreach (ns, nses) vec_free (ns->name);
4918 vec_foreach (sub, vam->sw_if_subif_table)
4920 vec_free (sub->interface_name);
4922 vec_free (vam->sw_if_subif_table);
4924 /* recreate the interface name hash table */
4925 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4927 /* Get list of ethernets */
4928 M (SW_INTERFACE_DUMP, mp);
4929 mp->name_filter_valid = 1;
4930 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4933 /* and local / loopback interfaces */
4934 M (SW_INTERFACE_DUMP, mp);
4935 mp->name_filter_valid = 1;
4936 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4939 /* and packet-generator interfaces */
4940 M (SW_INTERFACE_DUMP, mp);
4941 mp->name_filter_valid = 1;
4942 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4945 /* and vxlan-gpe tunnel interfaces */
4946 M (SW_INTERFACE_DUMP, mp);
4947 mp->name_filter_valid = 1;
4948 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4949 sizeof (mp->name_filter) - 1);
4952 /* and vxlan tunnel interfaces */
4953 M (SW_INTERFACE_DUMP, mp);
4954 mp->name_filter_valid = 1;
4955 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4958 /* and host (af_packet) interfaces */
4959 M (SW_INTERFACE_DUMP, mp);
4960 mp->name_filter_valid = 1;
4961 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4964 /* and l2tpv3 tunnel interfaces */
4965 M (SW_INTERFACE_DUMP, mp);
4966 mp->name_filter_valid = 1;
4967 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4968 sizeof (mp->name_filter) - 1);
4971 /* and GRE tunnel interfaces */
4972 M (SW_INTERFACE_DUMP, mp);
4973 mp->name_filter_valid = 1;
4974 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4977 /* and LISP-GPE interfaces */
4978 M (SW_INTERFACE_DUMP, mp);
4979 mp->name_filter_valid = 1;
4980 strncpy ((char *) mp->name_filter, "lisp_gpe",
4981 sizeof (mp->name_filter) - 1);
4984 /* and IPSEC tunnel interfaces */
4985 M (SW_INTERFACE_DUMP, mp);
4986 mp->name_filter_valid = 1;
4987 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4990 /* Use a control ping for synchronization */
4991 M (CONTROL_PING, mp_ping);
4999 api_sw_interface_set_flags (vat_main_t * vam)
5001 unformat_input_t *i = vam->input;
5002 vl_api_sw_interface_set_flags_t *mp;
5004 u8 sw_if_index_set = 0;
5005 u8 admin_up = 0, link_up = 0;
5008 /* Parse args required to build the message */
5009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5011 if (unformat (i, "admin-up"))
5013 else if (unformat (i, "admin-down"))
5015 else if (unformat (i, "link-up"))
5017 else if (unformat (i, "link-down"))
5020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5021 sw_if_index_set = 1;
5022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5023 sw_if_index_set = 1;
5028 if (sw_if_index_set == 0)
5030 errmsg ("missing interface name or sw_if_index");
5034 /* Construct the API message */
5035 M (SW_INTERFACE_SET_FLAGS, mp);
5036 mp->sw_if_index = ntohl (sw_if_index);
5037 mp->admin_up_down = admin_up;
5038 mp->link_up_down = link_up;
5043 /* Wait for a reply, return the good/bad news... */
5049 api_sw_interface_clear_stats (vat_main_t * vam)
5051 unformat_input_t *i = vam->input;
5052 vl_api_sw_interface_clear_stats_t *mp;
5054 u8 sw_if_index_set = 0;
5057 /* Parse args required to build the message */
5058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
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, "sw_if_index %d", &sw_if_index))
5063 sw_if_index_set = 1;
5068 /* Construct the API message */
5069 M (SW_INTERFACE_CLEAR_STATS, mp);
5071 if (sw_if_index_set == 1)
5072 mp->sw_if_index = ntohl (sw_if_index);
5074 mp->sw_if_index = ~0;
5079 /* Wait for a reply, return the good/bad news... */
5086 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
5088 unformat_input_t *i = vam->input;
5089 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
5091 u8 sw_if_index_set = 0;
5100 /* Parse args required to build the message */
5101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5103 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5104 sw_if_index_set = 1;
5105 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5106 sw_if_index_set = 1;
5107 else if (unformat (i, "subport %u", &subport))
5110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5111 sw_if_index_set = 1;
5112 else if (unformat (i, "pipe %u", &pipe))
5114 else if (unformat (i, "profile %u", &profile))
5120 if (sw_if_index_set == 0)
5122 errmsg ("missing interface name or sw_if_index");
5126 if (subport_set == 0)
5128 errmsg ("missing subport ");
5134 errmsg ("missing pipe");
5138 if (profile_set == 0)
5140 errmsg ("missing profile");
5144 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
5146 mp->sw_if_index = ntohl (sw_if_index);
5147 mp->subport = ntohl (subport);
5148 mp->pipe = ntohl (pipe);
5149 mp->profile = ntohl (profile);
5158 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
5160 unformat_input_t *i = vam->input;
5161 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
5163 u8 sw_if_index_set = 0;
5166 u32 tb_rate = 1250000000; /* 10GbE */
5167 u32 tb_size = 1000000;
5168 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
5172 /* Parse args required to build the message */
5173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5175 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5176 sw_if_index_set = 1;
5177 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5178 sw_if_index_set = 1;
5179 else if (unformat (i, "subport %u", &subport))
5182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5183 sw_if_index_set = 1;
5184 else if (unformat (i, "rate %u", &tb_rate))
5188 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
5190 tc_rate[tc_id] = tb_rate;
5192 else if (unformat (i, "bktsize %u", &tb_size))
5194 else if (unformat (i, "tc0 %u", &tc_rate[0]))
5196 else if (unformat (i, "tc1 %u", &tc_rate[1]))
5198 else if (unformat (i, "tc2 %u", &tc_rate[2]))
5200 else if (unformat (i, "tc3 %u", &tc_rate[3]))
5202 else if (unformat (i, "period %u", &tc_period))
5208 if (sw_if_index_set == 0)
5210 errmsg ("missing interface name or sw_if_index");
5214 if (subport_set == 0)
5216 errmsg ("missing subport ");
5220 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
5222 mp->sw_if_index = ntohl (sw_if_index);
5223 mp->subport = ntohl (subport);
5224 mp->tb_rate = ntohl (tb_rate);
5225 mp->tb_size = ntohl (tb_size);
5226 mp->tc_rate[0] = ntohl (tc_rate[0]);
5227 mp->tc_rate[1] = ntohl (tc_rate[1]);
5228 mp->tc_rate[2] = ntohl (tc_rate[2]);
5229 mp->tc_rate[3] = ntohl (tc_rate[3]);
5230 mp->tc_period = ntohl (tc_period);
5238 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
5240 unformat_input_t *i = vam->input;
5241 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
5243 u8 sw_if_index_set = 0;
5247 u32 entry, tc, queue;
5250 /* Parse args required to build the message */
5251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5253 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
5254 sw_if_index_set = 1;
5255 else if (unformat (i, "sw_if_index %u", &sw_if_index))
5256 sw_if_index_set = 1;
5257 else if (unformat (i, "entry %d", &entry))
5259 else if (unformat (i, "tc %d", &tc))
5261 else if (unformat (i, "queue %d", &queue))
5267 if (sw_if_index_set == 0)
5269 errmsg ("missing interface name or sw_if_index");
5275 errmsg ("missing entry ");
5281 errmsg ("missing traffic class ");
5287 errmsg ("missing queue ");
5291 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
5293 mp->sw_if_index = ntohl (sw_if_index);
5294 mp->entry = ntohl (entry);
5295 mp->tc = ntohl (tc);
5296 mp->queue = ntohl (queue);
5305 api_sw_interface_add_del_address (vat_main_t * vam)
5307 unformat_input_t *i = vam->input;
5308 vl_api_sw_interface_add_del_address_t *mp;
5310 u8 sw_if_index_set = 0;
5311 u8 is_add = 1, del_all = 0;
5312 u32 address_length = 0;
5313 u8 v4_address_set = 0;
5314 u8 v6_address_set = 0;
5315 ip4_address_t v4address;
5316 ip6_address_t v6address;
5319 /* Parse args required to build the message */
5320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5322 if (unformat (i, "del-all"))
5324 else if (unformat (i, "del"))
5327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5328 sw_if_index_set = 1;
5329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5330 sw_if_index_set = 1;
5331 else if (unformat (i, "%U/%d",
5332 unformat_ip4_address, &v4address, &address_length))
5334 else if (unformat (i, "%U/%d",
5335 unformat_ip6_address, &v6address, &address_length))
5341 if (sw_if_index_set == 0)
5343 errmsg ("missing interface name or sw_if_index");
5346 if (v4_address_set && v6_address_set)
5348 errmsg ("both v4 and v6 addresses set");
5351 if (!v4_address_set && !v6_address_set && !del_all)
5353 errmsg ("no addresses set");
5357 /* Construct the API message */
5358 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5360 mp->sw_if_index = ntohl (sw_if_index);
5361 mp->is_add = is_add;
5362 mp->del_all = del_all;
5366 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5370 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5372 mp->address_length = address_length;
5377 /* Wait for a reply, return good/bad news */
5383 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5385 unformat_input_t *i = vam->input;
5386 vl_api_sw_interface_set_mpls_enable_t *mp;
5388 u8 sw_if_index_set = 0;
5392 /* Parse args required to build the message */
5393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5395 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5396 sw_if_index_set = 1;
5397 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5398 sw_if_index_set = 1;
5399 else if (unformat (i, "disable"))
5401 else if (unformat (i, "dis"))
5407 if (sw_if_index_set == 0)
5409 errmsg ("missing interface name or sw_if_index");
5413 /* Construct the API message */
5414 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5416 mp->sw_if_index = ntohl (sw_if_index);
5417 mp->enable = enable;
5422 /* Wait for a reply... */
5428 api_sw_interface_set_table (vat_main_t * vam)
5430 unformat_input_t *i = vam->input;
5431 vl_api_sw_interface_set_table_t *mp;
5432 u32 sw_if_index, vrf_id = 0;
5433 u8 sw_if_index_set = 0;
5437 /* Parse args required to build the message */
5438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5441 sw_if_index_set = 1;
5442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5443 sw_if_index_set = 1;
5444 else if (unformat (i, "vrf %d", &vrf_id))
5446 else if (unformat (i, "ipv6"))
5452 if (sw_if_index_set == 0)
5454 errmsg ("missing interface name or sw_if_index");
5458 /* Construct the API message */
5459 M (SW_INTERFACE_SET_TABLE, mp);
5461 mp->sw_if_index = ntohl (sw_if_index);
5462 mp->is_ipv6 = is_ipv6;
5463 mp->vrf_id = ntohl (vrf_id);
5468 /* Wait for a reply... */
5473 static void vl_api_sw_interface_get_table_reply_t_handler
5474 (vl_api_sw_interface_get_table_reply_t * mp)
5476 vat_main_t *vam = &vat_main;
5478 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5480 vam->retval = ntohl (mp->retval);
5481 vam->result_ready = 1;
5485 static void vl_api_sw_interface_get_table_reply_t_handler_json
5486 (vl_api_sw_interface_get_table_reply_t * mp)
5488 vat_main_t *vam = &vat_main;
5489 vat_json_node_t node;
5491 vat_json_init_object (&node);
5492 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5493 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5495 vat_json_print (vam->ofp, &node);
5496 vat_json_free (&node);
5498 vam->retval = ntohl (mp->retval);
5499 vam->result_ready = 1;
5503 api_sw_interface_get_table (vat_main_t * vam)
5505 unformat_input_t *i = vam->input;
5506 vl_api_sw_interface_get_table_t *mp;
5508 u8 sw_if_index_set = 0;
5512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5514 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5515 sw_if_index_set = 1;
5516 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5517 sw_if_index_set = 1;
5518 else if (unformat (i, "ipv6"))
5524 if (sw_if_index_set == 0)
5526 errmsg ("missing interface name or sw_if_index");
5530 M (SW_INTERFACE_GET_TABLE, mp);
5531 mp->sw_if_index = htonl (sw_if_index);
5532 mp->is_ipv6 = is_ipv6;
5540 api_sw_interface_set_vpath (vat_main_t * vam)
5542 unformat_input_t *i = vam->input;
5543 vl_api_sw_interface_set_vpath_t *mp;
5544 u32 sw_if_index = 0;
5545 u8 sw_if_index_set = 0;
5549 /* Parse args required to build the message */
5550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5553 sw_if_index_set = 1;
5554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5555 sw_if_index_set = 1;
5556 else if (unformat (i, "enable"))
5558 else if (unformat (i, "disable"))
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_VPATH, mp);
5573 mp->sw_if_index = ntohl (sw_if_index);
5574 mp->enable = is_enable;
5579 /* Wait for a reply... */
5585 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5587 unformat_input_t *i = vam->input;
5588 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5589 u32 sw_if_index = 0;
5590 u8 sw_if_index_set = 0;
5595 /* Parse args required to build the message */
5596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5598 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5599 sw_if_index_set = 1;
5600 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5601 sw_if_index_set = 1;
5602 else if (unformat (i, "enable"))
5604 else if (unformat (i, "disable"))
5606 else if (unformat (i, "ip4"))
5608 else if (unformat (i, "ip6"))
5614 if (sw_if_index_set == 0)
5616 errmsg ("missing interface name or sw_if_index");
5620 /* Construct the API message */
5621 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5623 mp->sw_if_index = ntohl (sw_if_index);
5624 mp->enable = is_enable;
5625 mp->is_ipv6 = is_ipv6;
5630 /* Wait for a reply... */
5636 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5638 unformat_input_t *i = vam->input;
5639 vl_api_sw_interface_set_l2_xconnect_t *mp;
5641 u8 rx_sw_if_index_set = 0;
5643 u8 tx_sw_if_index_set = 0;
5647 /* Parse args required to build the message */
5648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5650 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5651 rx_sw_if_index_set = 1;
5652 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5653 tx_sw_if_index_set = 1;
5654 else if (unformat (i, "rx"))
5656 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5658 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5660 rx_sw_if_index_set = 1;
5665 else if (unformat (i, "tx"))
5667 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5669 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5671 tx_sw_if_index_set = 1;
5676 else if (unformat (i, "enable"))
5678 else if (unformat (i, "disable"))
5684 if (rx_sw_if_index_set == 0)
5686 errmsg ("missing rx interface name or rx_sw_if_index");
5690 if (enable && (tx_sw_if_index_set == 0))
5692 errmsg ("missing tx interface name or tx_sw_if_index");
5696 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5698 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5699 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5700 mp->enable = enable;
5708 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5710 unformat_input_t *i = vam->input;
5711 vl_api_sw_interface_set_l2_bridge_t *mp;
5713 u8 rx_sw_if_index_set = 0;
5721 /* Parse args required to build the message */
5722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5724 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5725 rx_sw_if_index_set = 1;
5726 else if (unformat (i, "bd_id %d", &bd_id))
5730 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5731 rx_sw_if_index_set = 1;
5732 else if (unformat (i, "shg %d", &shg))
5734 else if (unformat (i, "bvi"))
5736 else if (unformat (i, "enable"))
5738 else if (unformat (i, "disable"))
5744 if (rx_sw_if_index_set == 0)
5746 errmsg ("missing rx interface name or sw_if_index");
5750 if (enable && (bd_id_set == 0))
5752 errmsg ("missing bridge domain");
5756 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5758 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5759 mp->bd_id = ntohl (bd_id);
5762 mp->enable = enable;
5770 api_bridge_domain_dump (vat_main_t * vam)
5772 unformat_input_t *i = vam->input;
5773 vl_api_bridge_domain_dump_t *mp;
5774 vl_api_control_ping_t *mp_ping;
5778 /* Parse args required to build the message */
5779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5781 if (unformat (i, "bd_id %d", &bd_id))
5787 M (BRIDGE_DOMAIN_DUMP, mp);
5788 mp->bd_id = ntohl (bd_id);
5791 /* Use a control ping for synchronization */
5792 M (CONTROL_PING, mp_ping);
5800 api_bridge_domain_add_del (vat_main_t * vam)
5802 unformat_input_t *i = vam->input;
5803 vl_api_bridge_domain_add_del_t *mp;
5806 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5810 /* Parse args required to build the message */
5811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5813 if (unformat (i, "bd_id %d", &bd_id))
5815 else if (unformat (i, "flood %d", &flood))
5817 else if (unformat (i, "uu-flood %d", &uu_flood))
5819 else if (unformat (i, "forward %d", &forward))
5821 else if (unformat (i, "learn %d", &learn))
5823 else if (unformat (i, "arp-term %d", &arp_term))
5825 else if (unformat (i, "mac-age %d", &mac_age))
5827 else if (unformat (i, "del"))
5830 flood = uu_flood = forward = learn = 0;
5838 errmsg ("missing bridge domain");
5844 errmsg ("mac age must be less than 256 ");
5848 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5850 mp->bd_id = ntohl (bd_id);
5852 mp->uu_flood = uu_flood;
5853 mp->forward = forward;
5855 mp->arp_term = arp_term;
5856 mp->is_add = is_add;
5857 mp->mac_age = (u8) mac_age;
5865 api_l2fib_add_del (vat_main_t * vam)
5867 unformat_input_t *i = vam->input;
5868 vl_api_l2fib_add_del_t *mp;
5874 u32 sw_if_index = ~0;
5875 u8 sw_if_index_set = 0;
5884 /* Parse args required to build the message */
5885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5887 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5889 else if (unformat (i, "bd_id %d", &bd_id))
5891 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5892 sw_if_index_set = 1;
5893 else if (unformat (i, "sw_if"))
5895 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5898 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5899 sw_if_index_set = 1;
5904 else if (unformat (i, "static"))
5906 else if (unformat (i, "filter"))
5911 else if (unformat (i, "bvi"))
5916 else if (unformat (i, "del"))
5918 else if (unformat (i, "count %d", &count))
5926 errmsg ("missing mac address");
5932 errmsg ("missing bridge domain");
5936 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5938 errmsg ("missing interface name or sw_if_index");
5944 /* Turn on async mode */
5945 vam->async_mode = 1;
5946 vam->async_errors = 0;
5947 before = vat_time_now (vam);
5950 for (j = 0; j < count; j++)
5952 M (L2FIB_ADD_DEL, mp);
5955 mp->bd_id = ntohl (bd_id);
5956 mp->is_add = is_add;
5960 mp->sw_if_index = ntohl (sw_if_index);
5961 mp->static_mac = static_mac;
5962 mp->filter_mac = filter_mac;
5963 mp->bvi_mac = bvi_mac;
5965 increment_mac_address (&mac);
5972 vl_api_control_ping_t *mp_ping;
5975 /* Shut off async mode */
5976 vam->async_mode = 0;
5978 M (CONTROL_PING, mp_ping);
5981 timeout = vat_time_now (vam) + 1.0;
5982 while (vat_time_now (vam) < timeout)
5983 if (vam->result_ready == 1)
5988 if (vam->retval == -99)
5991 if (vam->async_errors > 0)
5993 errmsg ("%d asynchronous errors", vam->async_errors);
5996 vam->async_errors = 0;
5997 after = vat_time_now (vam);
5999 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6000 count, after - before, count / (after - before));
6006 /* Wait for a reply... */
6010 /* Return the good/bad news */
6011 return (vam->retval);
6015 api_l2_flags (vat_main_t * vam)
6017 unformat_input_t *i = vam->input;
6018 vl_api_l2_flags_t *mp;
6020 u32 feature_bitmap = 0;
6021 u8 sw_if_index_set = 0;
6024 /* Parse args required to build the message */
6025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6027 if (unformat (i, "sw_if_index %d", &sw_if_index))
6028 sw_if_index_set = 1;
6029 else if (unformat (i, "sw_if"))
6031 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6034 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6035 sw_if_index_set = 1;
6040 else if (unformat (i, "learn"))
6041 feature_bitmap |= L2INPUT_FEAT_LEARN;
6042 else if (unformat (i, "forward"))
6043 feature_bitmap |= L2INPUT_FEAT_FWD;
6044 else if (unformat (i, "flood"))
6045 feature_bitmap |= L2INPUT_FEAT_FLOOD;
6046 else if (unformat (i, "uu-flood"))
6047 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
6052 if (sw_if_index_set == 0)
6054 errmsg ("missing interface name or sw_if_index");
6060 mp->sw_if_index = ntohl (sw_if_index);
6061 mp->feature_bitmap = ntohl (feature_bitmap);
6069 api_bridge_flags (vat_main_t * vam)
6071 unformat_input_t *i = vam->input;
6072 vl_api_bridge_flags_t *mp;
6079 /* Parse args required to build the message */
6080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6082 if (unformat (i, "bd_id %d", &bd_id))
6084 else if (unformat (i, "learn"))
6086 else if (unformat (i, "forward"))
6088 else if (unformat (i, "flood"))
6090 else if (unformat (i, "uu-flood"))
6091 flags |= L2_UU_FLOOD;
6092 else if (unformat (i, "arp-term"))
6093 flags |= L2_ARP_TERM;
6094 else if (unformat (i, "off"))
6096 else if (unformat (i, "disable"))
6104 errmsg ("missing bridge domain");
6108 M (BRIDGE_FLAGS, mp);
6110 mp->bd_id = ntohl (bd_id);
6111 mp->feature_bitmap = ntohl (flags);
6112 mp->is_set = is_set;
6120 api_bd_ip_mac_add_del (vat_main_t * vam)
6122 unformat_input_t *i = vam->input;
6123 vl_api_bd_ip_mac_add_del_t *mp;
6130 ip4_address_t v4addr;
6131 ip6_address_t v6addr;
6136 /* Parse args required to build the message */
6137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6139 if (unformat (i, "bd_id %d", &bd_id))
6143 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6147 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6152 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6156 else if (unformat (i, "del"))
6164 errmsg ("missing bridge domain");
6167 else if (ip_set == 0)
6169 errmsg ("missing IP address");
6172 else if (mac_set == 0)
6174 errmsg ("missing MAC address");
6178 M (BD_IP_MAC_ADD_DEL, mp);
6180 mp->bd_id = ntohl (bd_id);
6181 mp->is_ipv6 = is_ipv6;
6182 mp->is_add = is_add;
6184 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6186 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6187 clib_memcpy (mp->mac_address, macaddr, 6);
6194 api_tap_connect (vat_main_t * vam)
6196 unformat_input_t *i = vam->input;
6197 vl_api_tap_connect_t *mp;
6203 ip4_address_t ip4_address;
6205 int ip4_address_set = 0;
6206 ip6_address_t ip6_address;
6208 int ip6_address_set = 0;
6211 memset (mac_address, 0, sizeof (mac_address));
6213 /* Parse args required to build the message */
6214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6216 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6220 else if (unformat (i, "random-mac"))
6222 else if (unformat (i, "tapname %s", &tap_name))
6224 else if (unformat (i, "tag %s", &tag))
6226 else if (unformat (i, "address %U/%d",
6227 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6228 ip4_address_set = 1;
6229 else if (unformat (i, "address %U/%d",
6230 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6231 ip6_address_set = 1;
6238 errmsg ("missing tap name");
6241 if (vec_len (tap_name) > 63)
6243 errmsg ("tap name too long");
6246 vec_add1 (tap_name, 0);
6248 if (vec_len (tag) > 63)
6250 errmsg ("tag too long");
6254 /* Construct the API message */
6255 M (TAP_CONNECT, mp);
6257 mp->use_random_mac = random_mac;
6258 clib_memcpy (mp->mac_address, mac_address, 6);
6259 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6261 clib_memcpy (mp->tag, tag, vec_len (tag));
6263 if (ip4_address_set)
6265 mp->ip4_address_set = 1;
6266 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6267 mp->ip4_mask_width = ip4_mask_width;
6269 if (ip6_address_set)
6271 mp->ip6_address_set = 1;
6272 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6273 mp->ip6_mask_width = ip6_mask_width;
6276 vec_free (tap_name);
6282 /* Wait for a reply... */
6288 api_tap_modify (vat_main_t * vam)
6290 unformat_input_t *i = vam->input;
6291 vl_api_tap_modify_t *mp;
6296 u32 sw_if_index = ~0;
6297 u8 sw_if_index_set = 0;
6300 memset (mac_address, 0, sizeof (mac_address));
6302 /* Parse args required to build the message */
6303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6305 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6306 sw_if_index_set = 1;
6307 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6308 sw_if_index_set = 1;
6309 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6313 else if (unformat (i, "random-mac"))
6315 else if (unformat (i, "tapname %s", &tap_name))
6321 if (sw_if_index_set == 0)
6323 errmsg ("missing vpp interface name");
6328 errmsg ("missing tap name");
6331 if (vec_len (tap_name) > 63)
6333 errmsg ("tap name too long");
6335 vec_add1 (tap_name, 0);
6337 /* Construct the API message */
6340 mp->use_random_mac = random_mac;
6341 mp->sw_if_index = ntohl (sw_if_index);
6342 clib_memcpy (mp->mac_address, mac_address, 6);
6343 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6344 vec_free (tap_name);
6349 /* Wait for a reply... */
6355 api_tap_delete (vat_main_t * vam)
6357 unformat_input_t *i = vam->input;
6358 vl_api_tap_delete_t *mp;
6359 u32 sw_if_index = ~0;
6360 u8 sw_if_index_set = 0;
6363 /* Parse args required to build the message */
6364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6366 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6367 sw_if_index_set = 1;
6368 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6369 sw_if_index_set = 1;
6374 if (sw_if_index_set == 0)
6376 errmsg ("missing vpp interface name");
6380 /* Construct the API message */
6383 mp->sw_if_index = ntohl (sw_if_index);
6388 /* Wait for a reply... */
6394 api_ip_add_del_route (vat_main_t * vam)
6396 unformat_input_t *i = vam->input;
6397 vl_api_ip_add_del_route_t *mp;
6398 u32 sw_if_index = ~0, vrf_id = 0;
6400 u8 is_local = 0, is_drop = 0;
6401 u8 is_unreach = 0, is_prohibit = 0;
6402 u8 create_vrf_if_needed = 0;
6404 u32 next_hop_weight = 1;
6406 u8 is_multipath = 0;
6408 u8 address_length_set = 0;
6409 u32 next_hop_table_id = 0;
6410 u32 resolve_attempts = 0;
6411 u32 dst_address_length = 0;
6412 u8 next_hop_set = 0;
6413 ip4_address_t v4_dst_address, v4_next_hop_address;
6414 ip6_address_t v6_dst_address, v6_next_hop_address;
6418 u32 random_add_del = 0;
6419 u32 *random_vector = 0;
6421 u32 random_seed = 0xdeaddabe;
6422 u32 classify_table_index = ~0;
6424 u8 resolve_host = 0, resolve_attached = 0;
6425 mpls_label_t *next_hop_out_label_stack = NULL;
6426 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6427 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6429 /* Parse args required to build the message */
6430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6432 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6434 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6436 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6441 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6446 else if (unformat (i, "/%d", &dst_address_length))
6448 address_length_set = 1;
6451 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6452 &v4_next_hop_address))
6456 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6457 &v6_next_hop_address))
6461 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6463 else if (unformat (i, "weight %d", &next_hop_weight))
6465 else if (unformat (i, "drop"))
6469 else if (unformat (i, "null-send-unreach"))
6473 else if (unformat (i, "null-send-prohibit"))
6477 else if (unformat (i, "local"))
6481 else if (unformat (i, "classify %d", &classify_table_index))
6485 else if (unformat (i, "del"))
6487 else if (unformat (i, "add"))
6489 else if (unformat (i, "not-last"))
6491 else if (unformat (i, "resolve-via-host"))
6493 else if (unformat (i, "resolve-via-attached"))
6494 resolve_attached = 1;
6495 else if (unformat (i, "multipath"))
6497 else if (unformat (i, "vrf %d", &vrf_id))
6499 else if (unformat (i, "create-vrf"))
6500 create_vrf_if_needed = 1;
6501 else if (unformat (i, "count %d", &count))
6503 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6505 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6507 else if (unformat (i, "out-label %d", &next_hop_out_label))
6508 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6509 else if (unformat (i, "via-label %d", &next_hop_via_label))
6511 else if (unformat (i, "random"))
6513 else if (unformat (i, "seed %d", &random_seed))
6517 clib_warning ("parse error '%U'", format_unformat_error, i);
6522 if (!next_hop_set && !is_drop && !is_local &&
6523 !is_classify && !is_unreach && !is_prohibit &&
6524 MPLS_LABEL_INVALID == next_hop_via_label)
6527 ("next hop / local / drop / unreach / prohibit / classify not set");
6531 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6533 errmsg ("next hop and next-hop via label set");
6536 if (address_set == 0)
6538 errmsg ("missing addresses");
6542 if (address_length_set == 0)
6544 errmsg ("missing address length");
6548 /* Generate a pile of unique, random routes */
6551 u32 this_random_address;
6552 random_hash = hash_create (count, sizeof (uword));
6554 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6555 for (j = 0; j <= count; j++)
6559 this_random_address = random_u32 (&random_seed);
6560 this_random_address =
6561 clib_host_to_net_u32 (this_random_address);
6563 while (hash_get (random_hash, this_random_address));
6564 vec_add1 (random_vector, this_random_address);
6565 hash_set (random_hash, this_random_address, 1);
6567 hash_free (random_hash);
6568 v4_dst_address.as_u32 = random_vector[0];
6573 /* Turn on async mode */
6574 vam->async_mode = 1;
6575 vam->async_errors = 0;
6576 before = vat_time_now (vam);
6579 for (j = 0; j < count; j++)
6581 /* Construct the API message */
6582 M2 (IP_ADD_DEL_ROUTE, mp,
6583 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6585 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6586 mp->table_id = ntohl (vrf_id);
6587 mp->create_vrf_if_needed = create_vrf_if_needed;
6589 mp->is_add = is_add;
6590 mp->is_drop = is_drop;
6591 mp->is_unreach = is_unreach;
6592 mp->is_prohibit = is_prohibit;
6593 mp->is_ipv6 = is_ipv6;
6594 mp->is_local = is_local;
6595 mp->is_classify = is_classify;
6596 mp->is_multipath = is_multipath;
6597 mp->is_resolve_host = resolve_host;
6598 mp->is_resolve_attached = resolve_attached;
6599 mp->not_last = not_last;
6600 mp->next_hop_weight = next_hop_weight;
6601 mp->dst_address_length = dst_address_length;
6602 mp->next_hop_table_id = ntohl (next_hop_table_id);
6603 mp->classify_table_index = ntohl (classify_table_index);
6604 mp->next_hop_via_label = ntohl (next_hop_via_label);
6605 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6606 if (0 != mp->next_hop_n_out_labels)
6608 memcpy (mp->next_hop_out_label_stack,
6609 next_hop_out_label_stack,
6610 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6611 vec_free (next_hop_out_label_stack);
6616 clib_memcpy (mp->dst_address, &v6_dst_address,
6617 sizeof (v6_dst_address));
6619 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6620 sizeof (v6_next_hop_address));
6621 increment_v6_address (&v6_dst_address);
6625 clib_memcpy (mp->dst_address, &v4_dst_address,
6626 sizeof (v4_dst_address));
6628 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6629 sizeof (v4_next_hop_address));
6631 v4_dst_address.as_u32 = random_vector[j + 1];
6633 increment_v4_address (&v4_dst_address);
6637 /* If we receive SIGTERM, stop now... */
6642 /* When testing multiple add/del ops, use a control-ping to sync */
6645 vl_api_control_ping_t *mp_ping;
6649 /* Shut off async mode */
6650 vam->async_mode = 0;
6652 M (CONTROL_PING, mp_ping);
6655 timeout = vat_time_now (vam) + 1.0;
6656 while (vat_time_now (vam) < timeout)
6657 if (vam->result_ready == 1)
6662 if (vam->retval == -99)
6665 if (vam->async_errors > 0)
6667 errmsg ("%d asynchronous errors", vam->async_errors);
6670 vam->async_errors = 0;
6671 after = vat_time_now (vam);
6673 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6677 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6678 count, after - before, count / (after - before));
6684 /* Wait for a reply... */
6689 /* Return the good/bad news */
6690 return (vam->retval);
6694 api_ip_mroute_add_del (vat_main_t * vam)
6696 unformat_input_t *i = vam->input;
6697 vl_api_ip_mroute_add_del_t *mp;
6698 u32 sw_if_index = ~0, vrf_id = 0;
6701 u8 create_vrf_if_needed = 0;
6704 u32 grp_address_length = 0;
6705 ip4_address_t v4_grp_address, v4_src_address;
6706 ip6_address_t v6_grp_address, v6_src_address;
6707 mfib_itf_flags_t iflags = 0;
6708 mfib_entry_flags_t eflags = 0;
6711 /* Parse args required to build the message */
6712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6714 if (unformat (i, "sw_if_index %d", &sw_if_index))
6716 else if (unformat (i, "%U %U",
6717 unformat_ip4_address, &v4_src_address,
6718 unformat_ip4_address, &v4_grp_address))
6720 grp_address_length = 64;
6724 else if (unformat (i, "%U %U",
6725 unformat_ip6_address, &v6_src_address,
6726 unformat_ip6_address, &v6_grp_address))
6728 grp_address_length = 256;
6732 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6734 memset (&v4_src_address, 0, sizeof (v4_src_address));
6735 grp_address_length = 32;
6739 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6741 memset (&v6_src_address, 0, sizeof (v6_src_address));
6742 grp_address_length = 128;
6746 else if (unformat (i, "/%d", &grp_address_length))
6748 else if (unformat (i, "local"))
6752 else if (unformat (i, "del"))
6754 else if (unformat (i, "add"))
6756 else if (unformat (i, "vrf %d", &vrf_id))
6758 else if (unformat (i, "create-vrf"))
6759 create_vrf_if_needed = 1;
6760 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6762 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6766 clib_warning ("parse error '%U'", format_unformat_error, i);
6771 if (address_set == 0)
6773 errmsg ("missing addresses\n");
6777 /* Construct the API message */
6778 M (IP_MROUTE_ADD_DEL, mp);
6780 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6781 mp->table_id = ntohl (vrf_id);
6782 mp->create_vrf_if_needed = create_vrf_if_needed;
6784 mp->is_add = is_add;
6785 mp->is_ipv6 = is_ipv6;
6786 mp->is_local = is_local;
6787 mp->itf_flags = ntohl (iflags);
6788 mp->entry_flags = ntohl (eflags);
6789 mp->grp_address_length = grp_address_length;
6790 mp->grp_address_length = ntohs (mp->grp_address_length);
6794 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6795 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6799 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6800 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6806 /* Wait for a reply... */
6812 api_mpls_route_add_del (vat_main_t * vam)
6814 unformat_input_t *i = vam->input;
6815 vl_api_mpls_route_add_del_t *mp;
6816 u32 sw_if_index = ~0, table_id = 0;
6817 u8 create_table_if_needed = 0;
6819 u32 next_hop_weight = 1;
6820 u8 is_multipath = 0;
6821 u32 next_hop_table_id = 0;
6822 u8 next_hop_set = 0;
6823 ip4_address_t v4_next_hop_address = {
6826 ip6_address_t v6_next_hop_address = { {0} };
6830 u32 classify_table_index = ~0;
6832 u8 resolve_host = 0, resolve_attached = 0;
6833 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6834 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6835 mpls_label_t *next_hop_out_label_stack = NULL;
6836 mpls_label_t local_label = MPLS_LABEL_INVALID;
6838 u8 next_hop_proto_is_ip4 = 1;
6840 /* Parse args required to build the message */
6841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6845 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6847 else if (unformat (i, "%d", &local_label))
6849 else if (unformat (i, "eos"))
6851 else if (unformat (i, "non-eos"))
6853 else if (unformat (i, "via %U", unformat_ip4_address,
6854 &v4_next_hop_address))
6857 next_hop_proto_is_ip4 = 1;
6859 else if (unformat (i, "via %U", unformat_ip6_address,
6860 &v6_next_hop_address))
6863 next_hop_proto_is_ip4 = 0;
6865 else if (unformat (i, "weight %d", &next_hop_weight))
6867 else if (unformat (i, "create-table"))
6868 create_table_if_needed = 1;
6869 else if (unformat (i, "classify %d", &classify_table_index))
6873 else if (unformat (i, "del"))
6875 else if (unformat (i, "add"))
6877 else if (unformat (i, "resolve-via-host"))
6879 else if (unformat (i, "resolve-via-attached"))
6880 resolve_attached = 1;
6881 else if (unformat (i, "multipath"))
6883 else if (unformat (i, "count %d", &count))
6885 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6888 next_hop_proto_is_ip4 = 1;
6890 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6893 next_hop_proto_is_ip4 = 0;
6895 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6897 else if (unformat (i, "via-label %d", &next_hop_via_label))
6899 else if (unformat (i, "out-label %d", &next_hop_out_label))
6900 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6903 clib_warning ("parse error '%U'", format_unformat_error, i);
6908 if (!next_hop_set && !is_classify)
6910 errmsg ("next hop / classify not set");
6914 if (MPLS_LABEL_INVALID == local_label)
6916 errmsg ("missing label");
6922 /* Turn on async mode */
6923 vam->async_mode = 1;
6924 vam->async_errors = 0;
6925 before = vat_time_now (vam);
6928 for (j = 0; j < count; j++)
6930 /* Construct the API message */
6931 M2 (MPLS_ROUTE_ADD_DEL, mp,
6932 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6934 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6935 mp->mr_table_id = ntohl (table_id);
6936 mp->mr_create_table_if_needed = create_table_if_needed;
6938 mp->mr_is_add = is_add;
6939 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6940 mp->mr_is_classify = is_classify;
6941 mp->mr_is_multipath = is_multipath;
6942 mp->mr_is_resolve_host = resolve_host;
6943 mp->mr_is_resolve_attached = resolve_attached;
6944 mp->mr_next_hop_weight = next_hop_weight;
6945 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6946 mp->mr_classify_table_index = ntohl (classify_table_index);
6947 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6948 mp->mr_label = ntohl (local_label);
6949 mp->mr_eos = is_eos;
6951 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6952 if (0 != mp->mr_next_hop_n_out_labels)
6954 memcpy (mp->mr_next_hop_out_label_stack,
6955 next_hop_out_label_stack,
6956 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6957 vec_free (next_hop_out_label_stack);
6962 if (next_hop_proto_is_ip4)
6964 clib_memcpy (mp->mr_next_hop,
6965 &v4_next_hop_address,
6966 sizeof (v4_next_hop_address));
6970 clib_memcpy (mp->mr_next_hop,
6971 &v6_next_hop_address,
6972 sizeof (v6_next_hop_address));
6979 /* If we receive SIGTERM, stop now... */
6984 /* When testing multiple add/del ops, use a control-ping to sync */
6987 vl_api_control_ping_t *mp_ping;
6991 /* Shut off async mode */
6992 vam->async_mode = 0;
6994 M (CONTROL_PING, mp_ping);
6997 timeout = vat_time_now (vam) + 1.0;
6998 while (vat_time_now (vam) < timeout)
6999 if (vam->result_ready == 1)
7004 if (vam->retval == -99)
7007 if (vam->async_errors > 0)
7009 errmsg ("%d asynchronous errors", vam->async_errors);
7012 vam->async_errors = 0;
7013 after = vat_time_now (vam);
7015 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7019 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7020 count, after - before, count / (after - before));
7026 /* Wait for a reply... */
7031 /* Return the good/bad news */
7032 return (vam->retval);
7036 api_mpls_ip_bind_unbind (vat_main_t * vam)
7038 unformat_input_t *i = vam->input;
7039 vl_api_mpls_ip_bind_unbind_t *mp;
7040 u32 ip_table_id = 0;
7041 u8 create_table_if_needed = 0;
7044 ip4_address_t v4_address;
7045 ip6_address_t v6_address;
7048 mpls_label_t local_label = MPLS_LABEL_INVALID;
7051 /* Parse args required to build the message */
7052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7054 if (unformat (i, "%U/%d", unformat_ip4_address,
7055 &v4_address, &address_length))
7060 else if (unformat (i, "%U/%d", unformat_ip6_address,
7061 &v6_address, &address_length))
7066 else if (unformat (i, "%d", &local_label))
7068 else if (unformat (i, "create-table"))
7069 create_table_if_needed = 1;
7070 else if (unformat (i, "table-id %d", &ip_table_id))
7072 else if (unformat (i, "unbind"))
7074 else if (unformat (i, "bind"))
7078 clib_warning ("parse error '%U'", format_unformat_error, i);
7085 errmsg ("IP addres not set");
7089 if (MPLS_LABEL_INVALID == local_label)
7091 errmsg ("missing label");
7095 /* Construct the API message */
7096 M (MPLS_IP_BIND_UNBIND, mp);
7098 mp->mb_create_table_if_needed = create_table_if_needed;
7099 mp->mb_is_bind = is_bind;
7100 mp->mb_is_ip4 = is_ip4;
7101 mp->mb_ip_table_id = ntohl (ip_table_id);
7102 mp->mb_mpls_table_id = 0;
7103 mp->mb_label = ntohl (local_label);
7104 mp->mb_address_length = address_length;
7107 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7109 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7114 /* Wait for a reply... */
7120 api_proxy_arp_add_del (vat_main_t * vam)
7122 unformat_input_t *i = vam->input;
7123 vl_api_proxy_arp_add_del_t *mp;
7126 ip4_address_t lo, hi;
7130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7132 if (unformat (i, "vrf %d", &vrf_id))
7134 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7135 unformat_ip4_address, &hi))
7137 else if (unformat (i, "del"))
7141 clib_warning ("parse error '%U'", format_unformat_error, i);
7148 errmsg ("address range not set");
7152 M (PROXY_ARP_ADD_DEL, mp);
7154 mp->vrf_id = ntohl (vrf_id);
7155 mp->is_add = is_add;
7156 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7157 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7165 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7167 unformat_input_t *i = vam->input;
7168 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7171 u8 sw_if_index_set = 0;
7174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7176 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7177 sw_if_index_set = 1;
7178 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7179 sw_if_index_set = 1;
7180 else if (unformat (i, "enable"))
7182 else if (unformat (i, "disable"))
7186 clib_warning ("parse error '%U'", format_unformat_error, i);
7191 if (sw_if_index_set == 0)
7193 errmsg ("missing interface name or sw_if_index");
7197 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7199 mp->sw_if_index = ntohl (sw_if_index);
7200 mp->enable_disable = enable;
7208 api_mpls_tunnel_add_del (vat_main_t * vam)
7210 unformat_input_t *i = vam->input;
7211 vl_api_mpls_tunnel_add_del_t *mp;
7215 u32 sw_if_index = ~0;
7216 u32 next_hop_sw_if_index = ~0;
7217 u32 next_hop_proto_is_ip4 = 1;
7219 u32 next_hop_table_id = 0;
7220 ip4_address_t v4_next_hop_address = {
7223 ip6_address_t v6_next_hop_address = { {0} };
7224 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7229 if (unformat (i, "add"))
7231 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7233 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7235 else if (unformat (i, "via %U",
7236 unformat_ip4_address, &v4_next_hop_address))
7238 next_hop_proto_is_ip4 = 1;
7240 else if (unformat (i, "via %U",
7241 unformat_ip6_address, &v6_next_hop_address))
7243 next_hop_proto_is_ip4 = 0;
7245 else if (unformat (i, "l2-only"))
7247 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7249 else if (unformat (i, "out-label %d", &next_hop_out_label))
7250 vec_add1 (labels, ntohl (next_hop_out_label));
7253 clib_warning ("parse error '%U'", format_unformat_error, i);
7258 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7260 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7261 mp->mt_sw_if_index = ntohl (sw_if_index);
7262 mp->mt_is_add = is_add;
7263 mp->mt_l2_only = l2_only;
7264 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7265 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7267 mp->mt_next_hop_n_out_labels = vec_len (labels);
7269 if (0 != mp->mt_next_hop_n_out_labels)
7271 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7272 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7276 if (next_hop_proto_is_ip4)
7278 clib_memcpy (mp->mt_next_hop,
7279 &v4_next_hop_address, sizeof (v4_next_hop_address));
7283 clib_memcpy (mp->mt_next_hop,
7284 &v6_next_hop_address, sizeof (v6_next_hop_address));
7293 api_sw_interface_set_unnumbered (vat_main_t * vam)
7295 unformat_input_t *i = vam->input;
7296 vl_api_sw_interface_set_unnumbered_t *mp;
7298 u32 unnum_sw_index = ~0;
7300 u8 sw_if_index_set = 0;
7303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7305 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7306 sw_if_index_set = 1;
7307 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7308 sw_if_index_set = 1;
7309 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7311 else if (unformat (i, "del"))
7315 clib_warning ("parse error '%U'", format_unformat_error, i);
7320 if (sw_if_index_set == 0)
7322 errmsg ("missing interface name or sw_if_index");
7326 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7328 mp->sw_if_index = ntohl (sw_if_index);
7329 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7330 mp->is_add = is_add;
7338 api_ip_neighbor_add_del (vat_main_t * vam)
7340 unformat_input_t *i = vam->input;
7341 vl_api_ip_neighbor_add_del_t *mp;
7343 u8 sw_if_index_set = 0;
7349 u8 v4_address_set = 0;
7350 u8 v6_address_set = 0;
7351 ip4_address_t v4address;
7352 ip6_address_t v6address;
7355 memset (mac_address, 0, sizeof (mac_address));
7357 /* Parse args required to build the message */
7358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7360 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7364 else if (unformat (i, "del"))
7367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7368 sw_if_index_set = 1;
7369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7370 sw_if_index_set = 1;
7371 else if (unformat (i, "is_static"))
7373 else if (unformat (i, "vrf %d", &vrf_id))
7375 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7377 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7381 clib_warning ("parse error '%U'", format_unformat_error, i);
7386 if (sw_if_index_set == 0)
7388 errmsg ("missing interface name or sw_if_index");
7391 if (v4_address_set && v6_address_set)
7393 errmsg ("both v4 and v6 addresses set");
7396 if (!v4_address_set && !v6_address_set)
7398 errmsg ("no address set");
7402 /* Construct the API message */
7403 M (IP_NEIGHBOR_ADD_DEL, mp);
7405 mp->sw_if_index = ntohl (sw_if_index);
7406 mp->is_add = is_add;
7407 mp->vrf_id = ntohl (vrf_id);
7408 mp->is_static = is_static;
7410 clib_memcpy (mp->mac_address, mac_address, 6);
7414 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7418 /* mp->is_ipv6 = 0; via memset in M macro above */
7419 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7425 /* Wait for a reply, return good/bad news */
7431 api_reset_vrf (vat_main_t * vam)
7433 unformat_input_t *i = vam->input;
7434 vl_api_reset_vrf_t *mp;
7440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7442 if (unformat (i, "vrf %d", &vrf_id))
7444 else if (unformat (i, "ipv6"))
7448 clib_warning ("parse error '%U'", format_unformat_error, i);
7453 if (vrf_id_set == 0)
7455 errmsg ("missing vrf id");
7461 mp->vrf_id = ntohl (vrf_id);
7462 mp->is_ipv6 = is_ipv6;
7470 api_create_vlan_subif (vat_main_t * vam)
7472 unformat_input_t *i = vam->input;
7473 vl_api_create_vlan_subif_t *mp;
7475 u8 sw_if_index_set = 0;
7480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7482 if (unformat (i, "sw_if_index %d", &sw_if_index))
7483 sw_if_index_set = 1;
7485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7486 sw_if_index_set = 1;
7487 else if (unformat (i, "vlan %d", &vlan_id))
7491 clib_warning ("parse error '%U'", format_unformat_error, i);
7496 if (sw_if_index_set == 0)
7498 errmsg ("missing interface name or sw_if_index");
7502 if (vlan_id_set == 0)
7504 errmsg ("missing vlan_id");
7507 M (CREATE_VLAN_SUBIF, mp);
7509 mp->sw_if_index = ntohl (sw_if_index);
7510 mp->vlan_id = ntohl (vlan_id);
7517 #define foreach_create_subif_bit \
7524 _(outer_vlan_id_any) \
7525 _(inner_vlan_id_any)
7528 api_create_subif (vat_main_t * vam)
7530 unformat_input_t *i = vam->input;
7531 vl_api_create_subif_t *mp;
7533 u8 sw_if_index_set = 0;
7540 u32 exact_match = 0;
7541 u32 default_sub = 0;
7542 u32 outer_vlan_id_any = 0;
7543 u32 inner_vlan_id_any = 0;
7545 u16 outer_vlan_id = 0;
7546 u16 inner_vlan_id = 0;
7549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7551 if (unformat (i, "sw_if_index %d", &sw_if_index))
7552 sw_if_index_set = 1;
7554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7555 sw_if_index_set = 1;
7556 else if (unformat (i, "sub_id %d", &sub_id))
7558 else if (unformat (i, "outer_vlan_id %d", &tmp))
7559 outer_vlan_id = tmp;
7560 else if (unformat (i, "inner_vlan_id %d", &tmp))
7561 inner_vlan_id = tmp;
7563 #define _(a) else if (unformat (i, #a)) a = 1 ;
7564 foreach_create_subif_bit
7568 clib_warning ("parse error '%U'", format_unformat_error, i);
7573 if (sw_if_index_set == 0)
7575 errmsg ("missing interface name or sw_if_index");
7579 if (sub_id_set == 0)
7581 errmsg ("missing sub_id");
7584 M (CREATE_SUBIF, mp);
7586 mp->sw_if_index = ntohl (sw_if_index);
7587 mp->sub_id = ntohl (sub_id);
7589 #define _(a) mp->a = a;
7590 foreach_create_subif_bit;
7593 mp->outer_vlan_id = ntohs (outer_vlan_id);
7594 mp->inner_vlan_id = ntohs (inner_vlan_id);
7602 api_oam_add_del (vat_main_t * vam)
7604 unformat_input_t *i = vam->input;
7605 vl_api_oam_add_del_t *mp;
7608 ip4_address_t src, dst;
7613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7615 if (unformat (i, "vrf %d", &vrf_id))
7617 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7619 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7621 else if (unformat (i, "del"))
7625 clib_warning ("parse error '%U'", format_unformat_error, i);
7632 errmsg ("missing src addr");
7638 errmsg ("missing dst addr");
7642 M (OAM_ADD_DEL, mp);
7644 mp->vrf_id = ntohl (vrf_id);
7645 mp->is_add = is_add;
7646 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7647 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7655 api_reset_fib (vat_main_t * vam)
7657 unformat_input_t *i = vam->input;
7658 vl_api_reset_fib_t *mp;
7664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7666 if (unformat (i, "vrf %d", &vrf_id))
7668 else if (unformat (i, "ipv6"))
7672 clib_warning ("parse error '%U'", format_unformat_error, i);
7677 if (vrf_id_set == 0)
7679 errmsg ("missing vrf id");
7685 mp->vrf_id = ntohl (vrf_id);
7686 mp->is_ipv6 = is_ipv6;
7694 api_dhcp_proxy_config (vat_main_t * vam)
7696 unformat_input_t *i = vam->input;
7697 vl_api_dhcp_proxy_config_t *mp;
7699 u32 server_vrf_id = 0;
7701 u8 v4_address_set = 0;
7702 u8 v6_address_set = 0;
7703 ip4_address_t v4address;
7704 ip6_address_t v6address;
7705 u8 v4_src_address_set = 0;
7706 u8 v6_src_address_set = 0;
7707 ip4_address_t v4srcaddress;
7708 ip6_address_t v6srcaddress;
7711 /* Parse args required to build the message */
7712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7714 if (unformat (i, "del"))
7716 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7718 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7720 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7722 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7724 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7725 v4_src_address_set = 1;
7726 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7727 v6_src_address_set = 1;
7732 if (v4_address_set && v6_address_set)
7734 errmsg ("both v4 and v6 server addresses set");
7737 if (!v4_address_set && !v6_address_set)
7739 errmsg ("no server addresses set");
7743 if (v4_src_address_set && v6_src_address_set)
7745 errmsg ("both v4 and v6 src addresses set");
7748 if (!v4_src_address_set && !v6_src_address_set)
7750 errmsg ("no src addresses set");
7754 if (!(v4_src_address_set && v4_address_set) &&
7755 !(v6_src_address_set && v6_address_set))
7757 errmsg ("no matching server and src addresses set");
7761 /* Construct the API message */
7762 M (DHCP_PROXY_CONFIG, mp);
7764 mp->is_add = is_add;
7765 mp->rx_vrf_id = ntohl (rx_vrf_id);
7766 mp->server_vrf_id = ntohl (server_vrf_id);
7770 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7771 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7775 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7776 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7782 /* Wait for a reply, return good/bad news */
7787 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7788 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7791 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7793 vat_main_t *vam = &vat_main;
7797 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7798 ntohl (mp->rx_vrf_id),
7799 ntohl (mp->server_vrf_id),
7800 format_ip6_address, mp->dhcp_server,
7801 format_ip6_address, mp->dhcp_src_address,
7802 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7805 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7806 ntohl (mp->rx_vrf_id),
7807 ntohl (mp->server_vrf_id),
7808 format_ip4_address, mp->dhcp_server,
7809 format_ip4_address, mp->dhcp_src_address,
7810 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7813 static void vl_api_dhcp_proxy_details_t_handler_json
7814 (vl_api_dhcp_proxy_details_t * mp)
7816 vat_main_t *vam = &vat_main;
7817 vat_json_node_t *node = NULL;
7819 struct in6_addr ip6;
7821 if (VAT_JSON_ARRAY != vam->json_tree.type)
7823 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7824 vat_json_init_array (&vam->json_tree);
7826 node = vat_json_array_add (&vam->json_tree);
7828 vat_json_init_object (node);
7829 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7830 vat_json_object_add_uint (node, "server-table-id",
7831 ntohl (mp->server_vrf_id));
7834 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7835 vat_json_object_add_ip6 (node, "server_address", ip6);
7836 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7837 vat_json_object_add_ip6 (node, "src_address", ip6);
7841 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7842 vat_json_object_add_ip4 (node, "server_address", ip4);
7843 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7844 vat_json_object_add_ip4 (node, "src_address", ip4);
7846 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7847 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7851 api_dhcp_proxy_dump (vat_main_t * vam)
7853 unformat_input_t *i = vam->input;
7854 vl_api_control_ping_t *mp_ping;
7855 vl_api_dhcp_proxy_dump_t *mp;
7859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7861 if (unformat (i, "ipv6"))
7865 clib_warning ("parse error '%U'", format_unformat_error, i);
7870 M (DHCP_PROXY_DUMP, mp);
7872 mp->is_ip6 = is_ipv6;
7875 /* Use a control ping for synchronization */
7876 M (CONTROL_PING, mp_ping);
7884 api_dhcp_proxy_set_vss (vat_main_t * vam)
7886 unformat_input_t *i = vam->input;
7887 vl_api_dhcp_proxy_set_vss_t *mp;
7898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7900 if (unformat (i, "tbl_id %d", &tbl_id))
7902 if (unformat (i, "fib_id %d", &fib_id))
7904 if (unformat (i, "oui %d", &oui))
7906 else if (unformat (i, "ipv6"))
7908 else if (unformat (i, "del"))
7912 clib_warning ("parse error '%U'", format_unformat_error, i);
7917 if (tbl_id_set == 0)
7919 errmsg ("missing tbl id");
7923 if (fib_id_set == 0)
7925 errmsg ("missing fib id");
7930 errmsg ("missing oui");
7934 M (DHCP_PROXY_SET_VSS, mp);
7935 mp->tbl_id = ntohl (tbl_id);
7936 mp->fib_id = ntohl (fib_id);
7937 mp->oui = ntohl (oui);
7938 mp->is_ipv6 = is_ipv6;
7939 mp->is_add = is_add;
7947 api_dhcp_client_config (vat_main_t * vam)
7949 unformat_input_t *i = vam->input;
7950 vl_api_dhcp_client_config_t *mp;
7952 u8 sw_if_index_set = 0;
7955 u8 disable_event = 0;
7958 /* Parse args required to build the message */
7959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7961 if (unformat (i, "del"))
7964 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7965 sw_if_index_set = 1;
7966 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7967 sw_if_index_set = 1;
7968 else if (unformat (i, "hostname %s", &hostname))
7970 else if (unformat (i, "disable_event"))
7976 if (sw_if_index_set == 0)
7978 errmsg ("missing interface name or sw_if_index");
7982 if (vec_len (hostname) > 63)
7984 errmsg ("hostname too long");
7986 vec_add1 (hostname, 0);
7988 /* Construct the API message */
7989 M (DHCP_CLIENT_CONFIG, mp);
7991 mp->sw_if_index = ntohl (sw_if_index);
7992 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7993 vec_free (hostname);
7994 mp->is_add = is_add;
7995 mp->want_dhcp_event = disable_event ? 0 : 1;
7996 mp->pid = getpid ();
8001 /* Wait for a reply, return good/bad news */
8007 api_set_ip_flow_hash (vat_main_t * vam)
8009 unformat_input_t *i = vam->input;
8010 vl_api_set_ip_flow_hash_t *mp;
8022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8024 if (unformat (i, "vrf %d", &vrf_id))
8026 else if (unformat (i, "ipv6"))
8028 else if (unformat (i, "src"))
8030 else if (unformat (i, "dst"))
8032 else if (unformat (i, "sport"))
8034 else if (unformat (i, "dport"))
8036 else if (unformat (i, "proto"))
8038 else if (unformat (i, "reverse"))
8043 clib_warning ("parse error '%U'", format_unformat_error, i);
8048 if (vrf_id_set == 0)
8050 errmsg ("missing vrf id");
8054 M (SET_IP_FLOW_HASH, mp);
8060 mp->reverse = reverse;
8061 mp->vrf_id = ntohl (vrf_id);
8062 mp->is_ipv6 = is_ipv6;
8070 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8072 unformat_input_t *i = vam->input;
8073 vl_api_sw_interface_ip6_enable_disable_t *mp;
8075 u8 sw_if_index_set = 0;
8079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8082 sw_if_index_set = 1;
8083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8084 sw_if_index_set = 1;
8085 else if (unformat (i, "enable"))
8087 else if (unformat (i, "disable"))
8091 clib_warning ("parse error '%U'", format_unformat_error, i);
8096 if (sw_if_index_set == 0)
8098 errmsg ("missing interface name or sw_if_index");
8102 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8104 mp->sw_if_index = ntohl (sw_if_index);
8105 mp->enable = enable;
8113 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8115 unformat_input_t *i = vam->input;
8116 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8118 u8 sw_if_index_set = 0;
8119 u8 v6_address_set = 0;
8120 ip6_address_t v6address;
8123 /* Parse args required to build the message */
8124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8126 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8127 sw_if_index_set = 1;
8128 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8129 sw_if_index_set = 1;
8130 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8136 if (sw_if_index_set == 0)
8138 errmsg ("missing interface name or sw_if_index");
8141 if (!v6_address_set)
8143 errmsg ("no address set");
8147 /* Construct the API message */
8148 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8150 mp->sw_if_index = ntohl (sw_if_index);
8151 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8156 /* Wait for a reply, return good/bad news */
8163 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
8165 unformat_input_t *i = vam->input;
8166 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
8168 u8 sw_if_index_set = 0;
8169 u32 address_length = 0;
8170 u8 v6_address_set = 0;
8171 ip6_address_t v6address;
8173 u8 no_advertise = 0;
8175 u8 no_autoconfig = 0;
8178 u32 val_lifetime = 0;
8179 u32 pref_lifetime = 0;
8182 /* Parse args required to build the message */
8183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8185 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8186 sw_if_index_set = 1;
8187 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8188 sw_if_index_set = 1;
8189 else if (unformat (i, "%U/%d",
8190 unformat_ip6_address, &v6address, &address_length))
8192 else if (unformat (i, "val_life %d", &val_lifetime))
8194 else if (unformat (i, "pref_life %d", &pref_lifetime))
8196 else if (unformat (i, "def"))
8198 else if (unformat (i, "noadv"))
8200 else if (unformat (i, "offl"))
8202 else if (unformat (i, "noauto"))
8204 else if (unformat (i, "nolink"))
8206 else if (unformat (i, "isno"))
8210 clib_warning ("parse error '%U'", format_unformat_error, i);
8215 if (sw_if_index_set == 0)
8217 errmsg ("missing interface name or sw_if_index");
8220 if (!v6_address_set)
8222 errmsg ("no address set");
8226 /* Construct the API message */
8227 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8229 mp->sw_if_index = ntohl (sw_if_index);
8230 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8231 mp->address_length = address_length;
8232 mp->use_default = use_default;
8233 mp->no_advertise = no_advertise;
8234 mp->off_link = off_link;
8235 mp->no_autoconfig = no_autoconfig;
8236 mp->no_onlink = no_onlink;
8238 mp->val_lifetime = ntohl (val_lifetime);
8239 mp->pref_lifetime = ntohl (pref_lifetime);
8244 /* Wait for a reply, return good/bad news */
8250 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8252 unformat_input_t *i = vam->input;
8253 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8255 u8 sw_if_index_set = 0;
8260 u8 send_unicast = 0;
8263 u8 default_router = 0;
8264 u32 max_interval = 0;
8265 u32 min_interval = 0;
8267 u32 initial_count = 0;
8268 u32 initial_interval = 0;
8272 /* Parse args required to build the message */
8273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8275 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8276 sw_if_index_set = 1;
8277 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8278 sw_if_index_set = 1;
8279 else if (unformat (i, "maxint %d", &max_interval))
8281 else if (unformat (i, "minint %d", &min_interval))
8283 else if (unformat (i, "life %d", &lifetime))
8285 else if (unformat (i, "count %d", &initial_count))
8287 else if (unformat (i, "interval %d", &initial_interval))
8289 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8291 else if (unformat (i, "managed"))
8293 else if (unformat (i, "other"))
8295 else if (unformat (i, "ll"))
8297 else if (unformat (i, "send"))
8299 else if (unformat (i, "cease"))
8301 else if (unformat (i, "isno"))
8303 else if (unformat (i, "def"))
8307 clib_warning ("parse error '%U'", format_unformat_error, i);
8312 if (sw_if_index_set == 0)
8314 errmsg ("missing interface name or sw_if_index");
8318 /* Construct the API message */
8319 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8321 mp->sw_if_index = ntohl (sw_if_index);
8322 mp->max_interval = ntohl (max_interval);
8323 mp->min_interval = ntohl (min_interval);
8324 mp->lifetime = ntohl (lifetime);
8325 mp->initial_count = ntohl (initial_count);
8326 mp->initial_interval = ntohl (initial_interval);
8327 mp->suppress = suppress;
8328 mp->managed = managed;
8330 mp->ll_option = ll_option;
8331 mp->send_unicast = send_unicast;
8334 mp->default_router = default_router;
8339 /* Wait for a reply, return good/bad news */
8345 api_set_arp_neighbor_limit (vat_main_t * vam)
8347 unformat_input_t *i = vam->input;
8348 vl_api_set_arp_neighbor_limit_t *mp;
8354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8356 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8358 else if (unformat (i, "ipv6"))
8362 clib_warning ("parse error '%U'", format_unformat_error, i);
8369 errmsg ("missing limit value");
8373 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8375 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8376 mp->is_ipv6 = is_ipv6;
8384 api_l2_patch_add_del (vat_main_t * vam)
8386 unformat_input_t *i = vam->input;
8387 vl_api_l2_patch_add_del_t *mp;
8389 u8 rx_sw_if_index_set = 0;
8391 u8 tx_sw_if_index_set = 0;
8395 /* Parse args required to build the message */
8396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8398 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8399 rx_sw_if_index_set = 1;
8400 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8401 tx_sw_if_index_set = 1;
8402 else if (unformat (i, "rx"))
8404 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8406 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8408 rx_sw_if_index_set = 1;
8413 else if (unformat (i, "tx"))
8415 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8417 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8419 tx_sw_if_index_set = 1;
8424 else if (unformat (i, "del"))
8430 if (rx_sw_if_index_set == 0)
8432 errmsg ("missing rx interface name or rx_sw_if_index");
8436 if (tx_sw_if_index_set == 0)
8438 errmsg ("missing tx interface name or tx_sw_if_index");
8442 M (L2_PATCH_ADD_DEL, mp);
8444 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8445 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8446 mp->is_add = is_add;
8454 api_ioam_enable (vat_main_t * vam)
8456 unformat_input_t *input = vam->input;
8457 vl_api_ioam_enable_t *mp;
8459 int has_trace_option = 0;
8460 int has_pot_option = 0;
8461 int has_seqno_option = 0;
8462 int has_analyse_option = 0;
8465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8467 if (unformat (input, "trace"))
8468 has_trace_option = 1;
8469 else if (unformat (input, "pot"))
8471 else if (unformat (input, "seqno"))
8472 has_seqno_option = 1;
8473 else if (unformat (input, "analyse"))
8474 has_analyse_option = 1;
8478 M (IOAM_ENABLE, mp);
8479 mp->id = htons (id);
8480 mp->seqno = has_seqno_option;
8481 mp->analyse = has_analyse_option;
8482 mp->pot_enable = has_pot_option;
8483 mp->trace_enable = has_trace_option;
8492 api_ioam_disable (vat_main_t * vam)
8494 vl_api_ioam_disable_t *mp;
8497 M (IOAM_DISABLE, mp);
8504 api_sr_tunnel_add_del (vat_main_t * vam)
8506 unformat_input_t *i = vam->input;
8507 vl_api_sr_tunnel_add_del_t *mp;
8510 ip6_address_t src_address;
8511 int src_address_set = 0;
8512 ip6_address_t dst_address;
8514 int dst_address_set = 0;
8516 u32 rx_table_id = 0;
8517 u32 tx_table_id = 0;
8518 ip6_address_t *segments = 0;
8519 ip6_address_t *this_seg;
8520 ip6_address_t *tags = 0;
8521 ip6_address_t *this_tag;
8522 ip6_address_t next_address, tag;
8524 u8 *policy_name = 0;
8527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8529 if (unformat (i, "del"))
8531 else if (unformat (i, "name %s", &name))
8533 else if (unformat (i, "policy %s", &policy_name))
8535 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8537 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8539 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8540 src_address_set = 1;
8541 else if (unformat (i, "dst %U/%d",
8542 unformat_ip6_address, &dst_address, &dst_mask_width))
8543 dst_address_set = 1;
8544 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8546 vec_add2 (segments, this_seg, 1);
8547 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8548 sizeof (*this_seg));
8550 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8552 vec_add2 (tags, this_tag, 1);
8553 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8555 else if (unformat (i, "clean"))
8556 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8557 else if (unformat (i, "protected"))
8558 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8559 else if (unformat (i, "InPE %d", &pl_index))
8561 if (pl_index <= 0 || pl_index > 4)
8563 pl_index_range_error:
8564 errmsg ("pl index %d out of range", pl_index);
8568 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8570 else if (unformat (i, "EgPE %d", &pl_index))
8572 if (pl_index <= 0 || pl_index > 4)
8573 goto pl_index_range_error;
8575 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8577 else if (unformat (i, "OrgSrc %d", &pl_index))
8579 if (pl_index <= 0 || pl_index > 4)
8580 goto pl_index_range_error;
8582 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8588 if (!src_address_set)
8590 errmsg ("src address required");
8594 if (!dst_address_set)
8596 errmsg ("dst address required");
8602 errmsg ("at least one sr segment required");
8606 M2 (SR_TUNNEL_ADD_DEL, mp,
8607 vec_len (segments) * sizeof (ip6_address_t)
8608 + vec_len (tags) * sizeof (ip6_address_t));
8610 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8611 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8612 mp->dst_mask_width = dst_mask_width;
8613 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8614 mp->n_segments = vec_len (segments);
8615 mp->n_tags = vec_len (tags);
8616 mp->is_add = is_del == 0;
8617 clib_memcpy (mp->segs_and_tags, segments,
8618 vec_len (segments) * sizeof (ip6_address_t));
8619 clib_memcpy (mp->segs_and_tags +
8620 vec_len (segments) * sizeof (ip6_address_t), tags,
8621 vec_len (tags) * sizeof (ip6_address_t));
8623 mp->outer_vrf_id = ntohl (rx_table_id);
8624 mp->inner_vrf_id = ntohl (tx_table_id);
8625 memcpy (mp->name, name, vec_len (name));
8626 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8628 vec_free (segments);
8637 api_sr_policy_add_del (vat_main_t * vam)
8639 unformat_input_t *input = vam->input;
8640 vl_api_sr_policy_add_del_t *mp;
8643 u8 *tunnel_name = 0;
8644 u8 **tunnel_names = 0;
8649 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8650 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8653 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8655 if (unformat (input, "del"))
8657 else if (unformat (input, "name %s", &name))
8659 else if (unformat (input, "tunnel %s", &tunnel_name))
8663 vec_add1 (tunnel_names, tunnel_name);
8665 - length = #bytes to store in serial vector
8666 - +1 = byte to store that length
8668 tunnel_names_length += (vec_len (tunnel_name) + 1);
8679 errmsg ("policy name required");
8683 if ((!tunnel_set) && (!is_del))
8685 errmsg ("tunnel name required");
8689 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8693 mp->is_add = !is_del;
8695 memcpy (mp->name, name, vec_len (name));
8696 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8697 u8 *serial_orig = 0;
8698 vec_validate (serial_orig, tunnel_names_length);
8699 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8700 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8702 for (j = 0; j < vec_len (tunnel_names); j++)
8704 tun_name_len = vec_len (tunnel_names[j]);
8705 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8706 serial_orig += 1; // Move along one byte to store the actual tunnel name
8707 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8708 serial_orig += tun_name_len; // Advance past the copy
8710 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8712 vec_free (tunnel_names);
8713 vec_free (tunnel_name);
8721 api_sr_multicast_map_add_del (vat_main_t * vam)
8723 unformat_input_t *input = vam->input;
8724 vl_api_sr_multicast_map_add_del_t *mp;
8726 ip6_address_t multicast_address;
8727 u8 *policy_name = 0;
8728 int multicast_address_set = 0;
8731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8733 if (unformat (input, "del"))
8737 (input, "address %U", unformat_ip6_address, &multicast_address))
8738 multicast_address_set = 1;
8739 else if (unformat (input, "sr-policy %s", &policy_name))
8745 if (!is_del && !policy_name)
8747 errmsg ("sr-policy name required");
8752 if (!multicast_address_set)
8754 errmsg ("address required");
8758 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8760 mp->is_add = !is_del;
8761 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8762 clib_memcpy (mp->multicast_address, &multicast_address,
8763 sizeof (mp->multicast_address));
8766 vec_free (policy_name);
8774 #define foreach_tcp_proto_field \
8778 #define foreach_udp_proto_field \
8782 #define foreach_ip4_proto_field \
8794 u16 src_port, dst_port;
8797 #if VPP_API_TEST_BUILTIN == 0
8799 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8801 u8 **maskp = va_arg (*args, u8 **);
8803 u8 found_something = 0;
8806 #define _(a) u8 a=0;
8807 foreach_tcp_proto_field;
8810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8813 #define _(a) else if (unformat (input, #a)) a=1;
8814 foreach_tcp_proto_field
8820 #define _(a) found_something += a;
8821 foreach_tcp_proto_field;
8824 if (found_something == 0)
8827 vec_validate (mask, sizeof (*tcp) - 1);
8829 tcp = (tcp_header_t *) mask;
8831 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8832 foreach_tcp_proto_field;
8840 unformat_udp_mask (unformat_input_t * input, va_list * args)
8842 u8 **maskp = va_arg (*args, u8 **);
8844 u8 found_something = 0;
8847 #define _(a) u8 a=0;
8848 foreach_udp_proto_field;
8851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8854 #define _(a) else if (unformat (input, #a)) a=1;
8855 foreach_udp_proto_field
8861 #define _(a) found_something += a;
8862 foreach_udp_proto_field;
8865 if (found_something == 0)
8868 vec_validate (mask, sizeof (*udp) - 1);
8870 udp = (udp_header_t *) mask;
8872 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8873 foreach_udp_proto_field;
8881 unformat_l4_mask (unformat_input_t * input, va_list * args)
8883 u8 **maskp = va_arg (*args, u8 **);
8884 u16 src_port = 0, dst_port = 0;
8885 tcpudp_header_t *tcpudp;
8887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8889 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8891 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8893 else if (unformat (input, "src_port"))
8895 else if (unformat (input, "dst_port"))
8901 if (!src_port && !dst_port)
8905 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8907 tcpudp = (tcpudp_header_t *) mask;
8908 tcpudp->src_port = src_port;
8909 tcpudp->dst_port = dst_port;
8917 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8919 u8 **maskp = va_arg (*args, u8 **);
8921 u8 found_something = 0;
8924 #define _(a) u8 a=0;
8925 foreach_ip4_proto_field;
8931 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8933 if (unformat (input, "version"))
8935 else if (unformat (input, "hdr_length"))
8937 else if (unformat (input, "src"))
8939 else if (unformat (input, "dst"))
8941 else if (unformat (input, "proto"))
8944 #define _(a) else if (unformat (input, #a)) a=1;
8945 foreach_ip4_proto_field
8951 #define _(a) found_something += a;
8952 foreach_ip4_proto_field;
8955 if (found_something == 0)
8958 vec_validate (mask, sizeof (*ip) - 1);
8960 ip = (ip4_header_t *) mask;
8962 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8963 foreach_ip4_proto_field;
8966 ip->ip_version_and_header_length = 0;
8969 ip->ip_version_and_header_length |= 0xF0;
8972 ip->ip_version_and_header_length |= 0x0F;
8978 #define foreach_ip6_proto_field \
8986 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8988 u8 **maskp = va_arg (*args, u8 **);
8990 u8 found_something = 0;
8992 u32 ip_version_traffic_class_and_flow_label;
8994 #define _(a) u8 a=0;
8995 foreach_ip6_proto_field;
8998 u8 traffic_class = 0;
9001 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9003 if (unformat (input, "version"))
9005 else if (unformat (input, "traffic-class"))
9007 else if (unformat (input, "flow-label"))
9009 else if (unformat (input, "src"))
9011 else if (unformat (input, "dst"))
9013 else if (unformat (input, "proto"))
9016 #define _(a) else if (unformat (input, #a)) a=1;
9017 foreach_ip6_proto_field
9023 #define _(a) found_something += a;
9024 foreach_ip6_proto_field;
9027 if (found_something == 0)
9030 vec_validate (mask, sizeof (*ip) - 1);
9032 ip = (ip6_header_t *) mask;
9034 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9035 foreach_ip6_proto_field;
9038 ip_version_traffic_class_and_flow_label = 0;
9041 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9044 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9047 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9049 ip->ip_version_traffic_class_and_flow_label =
9050 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9057 unformat_l3_mask (unformat_input_t * input, va_list * args)
9059 u8 **maskp = va_arg (*args, u8 **);
9061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9063 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9065 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9074 unformat_l2_mask (unformat_input_t * input, va_list * args)
9076 u8 **maskp = va_arg (*args, u8 **);
9091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9093 if (unformat (input, "src"))
9095 else if (unformat (input, "dst"))
9097 else if (unformat (input, "proto"))
9099 else if (unformat (input, "tag1"))
9101 else if (unformat (input, "tag2"))
9103 else if (unformat (input, "ignore-tag1"))
9105 else if (unformat (input, "ignore-tag2"))
9107 else if (unformat (input, "cos1"))
9109 else if (unformat (input, "cos2"))
9111 else if (unformat (input, "dot1q"))
9113 else if (unformat (input, "dot1ad"))
9118 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9119 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9122 if (tag1 || ignore_tag1 || cos1 || dot1q)
9124 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9127 vec_validate (mask, len - 1);
9130 memset (mask, 0xff, 6);
9133 memset (mask + 6, 0xff, 6);
9137 /* inner vlan tag */
9146 mask[21] = mask[20] = 0xff;
9167 mask[16] = mask[17] = 0xff;
9177 mask[12] = mask[13] = 0xff;
9184 unformat_classify_mask (unformat_input_t * input, va_list * args)
9186 u8 **maskp = va_arg (*args, u8 **);
9187 u32 *skipp = va_arg (*args, u32 *);
9188 u32 *matchp = va_arg (*args, u32 *);
9196 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9198 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9200 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9202 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9204 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9218 if (mask || l2 || l3 || l4)
9222 /* "With a free Ethernet header in every package" */
9224 vec_validate (l2, 13);
9228 vec_append (mask, l3);
9233 vec_append (mask, l4);
9238 /* Scan forward looking for the first significant mask octet */
9239 for (i = 0; i < vec_len (mask); i++)
9243 /* compute (skip, match) params */
9244 *skipp = i / sizeof (u32x4);
9245 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9247 /* Pad mask to an even multiple of the vector size */
9248 while (vec_len (mask) % sizeof (u32x4))
9251 match = vec_len (mask) / sizeof (u32x4);
9253 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9255 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9256 if (*tmp || *(tmp + 1))
9261 clib_warning ("BUG: match 0");
9263 _vec_len (mask) = match * sizeof (u32x4);
9273 #endif /* VPP_API_TEST_BUILTIN */
9275 #define foreach_l2_next \
9277 _(ethernet, ETHERNET_INPUT) \
9282 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9284 u32 *miss_next_indexp = va_arg (*args, u32 *);
9289 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9293 if (unformat (input, "%d", &tmp))
9302 *miss_next_indexp = next_index;
9306 #define foreach_ip_next \
9312 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9314 u32 *miss_next_indexp = va_arg (*args, u32 *);
9319 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9323 if (unformat (input, "%d", &tmp))
9332 *miss_next_indexp = next_index;
9336 #define foreach_acl_next \
9340 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9342 u32 *miss_next_indexp = va_arg (*args, u32 *);
9347 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9351 if (unformat (input, "permit"))
9356 else if (unformat (input, "%d", &tmp))
9365 *miss_next_indexp = next_index;
9370 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9372 u32 *r = va_arg (*args, u32 *);
9374 if (unformat (input, "conform-color"))
9375 *r = POLICE_CONFORM;
9376 else if (unformat (input, "exceed-color"))
9385 api_classify_add_del_table (vat_main_t * vam)
9387 unformat_input_t *i = vam->input;
9388 vl_api_classify_add_del_table_t *mp;
9395 u32 table_index = ~0;
9396 u32 next_table_index = ~0;
9397 u32 miss_next_index = ~0;
9398 u32 memory_size = 32 << 20;
9400 u32 current_data_flag = 0;
9401 int current_data_offset = 0;
9404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9406 if (unformat (i, "del"))
9408 else if (unformat (i, "del-chain"))
9413 else if (unformat (i, "buckets %d", &nbuckets))
9415 else if (unformat (i, "memory_size %d", &memory_size))
9417 else if (unformat (i, "skip %d", &skip))
9419 else if (unformat (i, "match %d", &match))
9421 else if (unformat (i, "table %d", &table_index))
9423 else if (unformat (i, "mask %U", unformat_classify_mask,
9424 &mask, &skip, &match))
9426 else if (unformat (i, "next-table %d", &next_table_index))
9428 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9431 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9434 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9437 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9439 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9445 if (is_add && mask == 0)
9447 errmsg ("Mask required");
9451 if (is_add && skip == ~0)
9453 errmsg ("skip count required");
9457 if (is_add && match == ~0)
9459 errmsg ("match count required");
9463 if (!is_add && table_index == ~0)
9465 errmsg ("table index required for delete");
9469 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9471 mp->is_add = is_add;
9472 mp->del_chain = del_chain;
9473 mp->table_index = ntohl (table_index);
9474 mp->nbuckets = ntohl (nbuckets);
9475 mp->memory_size = ntohl (memory_size);
9476 mp->skip_n_vectors = ntohl (skip);
9477 mp->match_n_vectors = ntohl (match);
9478 mp->next_table_index = ntohl (next_table_index);
9479 mp->miss_next_index = ntohl (miss_next_index);
9480 mp->current_data_flag = ntohl (current_data_flag);
9481 mp->current_data_offset = ntohl (current_data_offset);
9482 clib_memcpy (mp->mask, mask, vec_len (mask));
9491 #if VPP_API_TEST_BUILTIN == 0
9493 unformat_l4_match (unformat_input_t * input, va_list * args)
9495 u8 **matchp = va_arg (*args, u8 **);
9497 u8 *proto_header = 0;
9503 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9505 if (unformat (input, "src_port %d", &src_port))
9507 else if (unformat (input, "dst_port %d", &dst_port))
9513 h.src_port = clib_host_to_net_u16 (src_port);
9514 h.dst_port = clib_host_to_net_u16 (dst_port);
9515 vec_validate (proto_header, sizeof (h) - 1);
9516 memcpy (proto_header, &h, sizeof (h));
9518 *matchp = proto_header;
9524 unformat_ip4_match (unformat_input_t * input, va_list * args)
9526 u8 **matchp = va_arg (*args, u8 **);
9533 int src = 0, dst = 0;
9534 ip4_address_t src_val, dst_val;
9541 int fragment_id = 0;
9542 u32 fragment_id_val;
9548 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9550 if (unformat (input, "version %d", &version_val))
9552 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9554 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9556 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9558 else if (unformat (input, "proto %d", &proto_val))
9560 else if (unformat (input, "tos %d", &tos_val))
9562 else if (unformat (input, "length %d", &length_val))
9564 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9566 else if (unformat (input, "ttl %d", &ttl_val))
9568 else if (unformat (input, "checksum %d", &checksum_val))
9574 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9575 + ttl + checksum == 0)
9579 * Aligned because we use the real comparison functions
9581 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9583 ip = (ip4_header_t *) match;
9585 /* These are realistically matched in practice */
9587 ip->src_address.as_u32 = src_val.as_u32;
9590 ip->dst_address.as_u32 = dst_val.as_u32;
9593 ip->protocol = proto_val;
9596 /* These are not, but they're included for completeness */
9598 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9601 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9607 ip->length = clib_host_to_net_u16 (length_val);
9613 ip->checksum = clib_host_to_net_u16 (checksum_val);
9620 unformat_ip6_match (unformat_input_t * input, va_list * args)
9622 u8 **matchp = va_arg (*args, u8 **);
9627 u8 traffic_class = 0;
9628 u32 traffic_class_val = 0;
9631 int src = 0, dst = 0;
9632 ip6_address_t src_val, dst_val;
9635 int payload_length = 0;
9636 u32 payload_length_val;
9639 u32 ip_version_traffic_class_and_flow_label;
9641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9643 if (unformat (input, "version %d", &version_val))
9645 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9647 else if (unformat (input, "flow_label %d", &flow_label_val))
9649 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9651 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9653 else if (unformat (input, "proto %d", &proto_val))
9655 else if (unformat (input, "payload_length %d", &payload_length_val))
9657 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9663 if (version + traffic_class + flow_label + src + dst + proto +
9664 payload_length + hop_limit == 0)
9668 * Aligned because we use the real comparison functions
9670 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9672 ip = (ip6_header_t *) match;
9675 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9678 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9681 ip->protocol = proto_val;
9683 ip_version_traffic_class_and_flow_label = 0;
9686 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9689 ip_version_traffic_class_and_flow_label |=
9690 (traffic_class_val & 0xFF) << 20;
9693 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9695 ip->ip_version_traffic_class_and_flow_label =
9696 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9699 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9702 ip->hop_limit = hop_limit_val;
9709 unformat_l3_match (unformat_input_t * input, va_list * args)
9711 u8 **matchp = va_arg (*args, u8 **);
9713 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9715 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9717 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9726 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9728 u8 *tagp = va_arg (*args, u8 *);
9731 if (unformat (input, "%d", &tag))
9733 tagp[0] = (tag >> 8) & 0x0F;
9734 tagp[1] = tag & 0xFF;
9742 unformat_l2_match (unformat_input_t * input, va_list * args)
9744 u8 **matchp = va_arg (*args, u8 **);
9764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9766 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9769 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9771 else if (unformat (input, "proto %U",
9772 unformat_ethernet_type_host_byte_order, &proto_val))
9774 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9776 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9778 else if (unformat (input, "ignore-tag1"))
9780 else if (unformat (input, "ignore-tag2"))
9782 else if (unformat (input, "cos1 %d", &cos1_val))
9784 else if (unformat (input, "cos2 %d", &cos2_val))
9789 if ((src + dst + proto + tag1 + tag2 +
9790 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9793 if (tag1 || ignore_tag1 || cos1)
9795 if (tag2 || ignore_tag2 || cos2)
9798 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9801 clib_memcpy (match, dst_val, 6);
9804 clib_memcpy (match + 6, src_val, 6);
9808 /* inner vlan tag */
9809 match[19] = tag2_val[1];
9810 match[18] = tag2_val[0];
9812 match[18] |= (cos2_val & 0x7) << 5;
9815 match[21] = proto_val & 0xff;
9816 match[20] = proto_val >> 8;
9820 match[15] = tag1_val[1];
9821 match[14] = tag1_val[0];
9824 match[14] |= (cos1_val & 0x7) << 5;
9830 match[15] = tag1_val[1];
9831 match[14] = tag1_val[0];
9834 match[17] = proto_val & 0xff;
9835 match[16] = proto_val >> 8;
9838 match[14] |= (cos1_val & 0x7) << 5;
9844 match[18] |= (cos2_val & 0x7) << 5;
9846 match[14] |= (cos1_val & 0x7) << 5;
9849 match[13] = proto_val & 0xff;
9850 match[12] = proto_val >> 8;
9859 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9861 u8 **matchp = va_arg (*args, u8 **);
9862 u32 skip_n_vectors = va_arg (*args, u32);
9863 u32 match_n_vectors = va_arg (*args, u32);
9870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9872 if (unformat (input, "hex %U", unformat_hex_string, &match))
9874 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9876 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9878 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9892 if (match || l2 || l3 || l4)
9896 /* "Win a free Ethernet header in every packet" */
9898 vec_validate_aligned (l2, 13, sizeof (u32x4));
9902 vec_append_aligned (match, l3, sizeof (u32x4));
9907 vec_append_aligned (match, l4, sizeof (u32x4));
9912 /* Make sure the vector is big enough even if key is all 0's */
9913 vec_validate_aligned
9914 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9917 /* Set size, include skipped vectors */
9918 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9929 api_classify_add_del_session (vat_main_t * vam)
9931 unformat_input_t *i = vam->input;
9932 vl_api_classify_add_del_session_t *mp;
9934 u32 table_index = ~0;
9935 u32 hit_next_index = ~0;
9936 u32 opaque_index = ~0;
9939 u32 skip_n_vectors = 0;
9940 u32 match_n_vectors = 0;
9946 * Warning: you have to supply skip_n and match_n
9947 * because the API client cant simply look at the classify
9951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9953 if (unformat (i, "del"))
9955 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9958 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9961 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9964 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9966 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9968 else if (unformat (i, "opaque-index %d", &opaque_index))
9970 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9972 else if (unformat (i, "match_n %d", &match_n_vectors))
9974 else if (unformat (i, "match %U", api_unformat_classify_match,
9975 &match, skip_n_vectors, match_n_vectors))
9977 else if (unformat (i, "advance %d", &advance))
9979 else if (unformat (i, "table-index %d", &table_index))
9981 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9983 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9985 else if (unformat (i, "action %d", &action))
9987 else if (unformat (i, "metadata %d", &metadata))
9993 if (table_index == ~0)
9995 errmsg ("Table index required");
9999 if (is_add && match == 0)
10001 errmsg ("Match value required");
10005 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10007 mp->is_add = is_add;
10008 mp->table_index = ntohl (table_index);
10009 mp->hit_next_index = ntohl (hit_next_index);
10010 mp->opaque_index = ntohl (opaque_index);
10011 mp->advance = ntohl (advance);
10012 mp->action = action;
10013 mp->metadata = ntohl (metadata);
10014 clib_memcpy (mp->match, match, vec_len (match));
10023 api_classify_set_interface_ip_table (vat_main_t * vam)
10025 unformat_input_t *i = vam->input;
10026 vl_api_classify_set_interface_ip_table_t *mp;
10028 int sw_if_index_set;
10029 u32 table_index = ~0;
10033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10036 sw_if_index_set = 1;
10037 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10038 sw_if_index_set = 1;
10039 else if (unformat (i, "table %d", &table_index))
10043 clib_warning ("parse error '%U'", format_unformat_error, i);
10048 if (sw_if_index_set == 0)
10050 errmsg ("missing interface name or sw_if_index");
10055 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10057 mp->sw_if_index = ntohl (sw_if_index);
10058 mp->table_index = ntohl (table_index);
10059 mp->is_ipv6 = is_ipv6;
10067 api_classify_set_interface_l2_tables (vat_main_t * vam)
10069 unformat_input_t *i = vam->input;
10070 vl_api_classify_set_interface_l2_tables_t *mp;
10072 int sw_if_index_set;
10073 u32 ip4_table_index = ~0;
10074 u32 ip6_table_index = ~0;
10075 u32 other_table_index = ~0;
10079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10082 sw_if_index_set = 1;
10083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10084 sw_if_index_set = 1;
10085 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10087 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10089 else if (unformat (i, "other-table %d", &other_table_index))
10091 else if (unformat (i, "is-input %d", &is_input))
10095 clib_warning ("parse error '%U'", format_unformat_error, i);
10100 if (sw_if_index_set == 0)
10102 errmsg ("missing interface name or sw_if_index");
10107 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10109 mp->sw_if_index = ntohl (sw_if_index);
10110 mp->ip4_table_index = ntohl (ip4_table_index);
10111 mp->ip6_table_index = ntohl (ip6_table_index);
10112 mp->other_table_index = ntohl (other_table_index);
10113 mp->is_input = (u8) is_input;
10121 api_set_ipfix_exporter (vat_main_t * vam)
10123 unformat_input_t *i = vam->input;
10124 vl_api_set_ipfix_exporter_t *mp;
10125 ip4_address_t collector_address;
10126 u8 collector_address_set = 0;
10127 u32 collector_port = ~0;
10128 ip4_address_t src_address;
10129 u8 src_address_set = 0;
10132 u32 template_interval = ~0;
10133 u8 udp_checksum = 0;
10136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10138 if (unformat (i, "collector_address %U", unformat_ip4_address,
10139 &collector_address))
10140 collector_address_set = 1;
10141 else if (unformat (i, "collector_port %d", &collector_port))
10143 else if (unformat (i, "src_address %U", unformat_ip4_address,
10145 src_address_set = 1;
10146 else if (unformat (i, "vrf_id %d", &vrf_id))
10148 else if (unformat (i, "path_mtu %d", &path_mtu))
10150 else if (unformat (i, "template_interval %d", &template_interval))
10152 else if (unformat (i, "udp_checksum"))
10158 if (collector_address_set == 0)
10160 errmsg ("collector_address required");
10164 if (src_address_set == 0)
10166 errmsg ("src_address required");
10170 M (SET_IPFIX_EXPORTER, mp);
10172 memcpy (mp->collector_address, collector_address.data,
10173 sizeof (collector_address.data));
10174 mp->collector_port = htons ((u16) collector_port);
10175 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10176 mp->vrf_id = htonl (vrf_id);
10177 mp->path_mtu = htonl (path_mtu);
10178 mp->template_interval = htonl (template_interval);
10179 mp->udp_checksum = udp_checksum;
10187 api_set_ipfix_classify_stream (vat_main_t * vam)
10189 unformat_input_t *i = vam->input;
10190 vl_api_set_ipfix_classify_stream_t *mp;
10192 u32 src_port = UDP_DST_PORT_ipfix;
10195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10197 if (unformat (i, "domain %d", &domain_id))
10199 else if (unformat (i, "src_port %d", &src_port))
10203 errmsg ("unknown input `%U'", format_unformat_error, i);
10208 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10210 mp->domain_id = htonl (domain_id);
10211 mp->src_port = htons ((u16) src_port);
10219 api_ipfix_classify_table_add_del (vat_main_t * vam)
10221 unformat_input_t *i = vam->input;
10222 vl_api_ipfix_classify_table_add_del_t *mp;
10224 u32 classify_table_index = ~0;
10226 u8 transport_protocol = 255;
10229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10231 if (unformat (i, "add"))
10233 else if (unformat (i, "del"))
10235 else if (unformat (i, "table %d", &classify_table_index))
10237 else if (unformat (i, "ip4"))
10239 else if (unformat (i, "ip6"))
10241 else if (unformat (i, "tcp"))
10242 transport_protocol = 6;
10243 else if (unformat (i, "udp"))
10244 transport_protocol = 17;
10247 errmsg ("unknown input `%U'", format_unformat_error, i);
10254 errmsg ("expecting: add|del");
10257 if (classify_table_index == ~0)
10259 errmsg ("classifier table not specified");
10262 if (ip_version == 0)
10264 errmsg ("IP version not specified");
10268 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10270 mp->is_add = is_add;
10271 mp->table_id = htonl (classify_table_index);
10272 mp->ip_version = ip_version;
10273 mp->transport_protocol = transport_protocol;
10281 api_get_node_index (vat_main_t * vam)
10283 unformat_input_t *i = vam->input;
10284 vl_api_get_node_index_t *mp;
10288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10290 if (unformat (i, "node %s", &name))
10297 errmsg ("node name required");
10300 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10302 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10306 M (GET_NODE_INDEX, mp);
10307 clib_memcpy (mp->node_name, name, vec_len (name));
10316 api_get_next_index (vat_main_t * vam)
10318 unformat_input_t *i = vam->input;
10319 vl_api_get_next_index_t *mp;
10320 u8 *node_name = 0, *next_node_name = 0;
10323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10325 if (unformat (i, "node-name %s", &node_name))
10327 else if (unformat (i, "next-node-name %s", &next_node_name))
10331 if (node_name == 0)
10333 errmsg ("node name required");
10336 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10338 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10342 if (next_node_name == 0)
10344 errmsg ("next node name required");
10347 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10349 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10353 M (GET_NEXT_INDEX, mp);
10354 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10355 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10356 vec_free (node_name);
10357 vec_free (next_node_name);
10365 api_add_node_next (vat_main_t * vam)
10367 unformat_input_t *i = vam->input;
10368 vl_api_add_node_next_t *mp;
10373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10375 if (unformat (i, "node %s", &name))
10377 else if (unformat (i, "next %s", &next))
10384 errmsg ("node name required");
10387 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10389 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10394 errmsg ("next node required");
10397 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10399 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10403 M (ADD_NODE_NEXT, mp);
10404 clib_memcpy (mp->node_name, name, vec_len (name));
10405 clib_memcpy (mp->next_name, next, vec_len (next));
10415 api_l2tpv3_create_tunnel (vat_main_t * vam)
10417 unformat_input_t *i = vam->input;
10418 ip6_address_t client_address, our_address;
10419 int client_address_set = 0;
10420 int our_address_set = 0;
10421 u32 local_session_id = 0;
10422 u32 remote_session_id = 0;
10423 u64 local_cookie = 0;
10424 u64 remote_cookie = 0;
10425 u8 l2_sublayer_present = 0;
10426 vl_api_l2tpv3_create_tunnel_t *mp;
10429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10431 if (unformat (i, "client_address %U", unformat_ip6_address,
10433 client_address_set = 1;
10434 else if (unformat (i, "our_address %U", unformat_ip6_address,
10436 our_address_set = 1;
10437 else if (unformat (i, "local_session_id %d", &local_session_id))
10439 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10441 else if (unformat (i, "local_cookie %lld", &local_cookie))
10443 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10445 else if (unformat (i, "l2-sublayer-present"))
10446 l2_sublayer_present = 1;
10451 if (client_address_set == 0)
10453 errmsg ("client_address required");
10457 if (our_address_set == 0)
10459 errmsg ("our_address required");
10463 M (L2TPV3_CREATE_TUNNEL, mp);
10465 clib_memcpy (mp->client_address, client_address.as_u8,
10466 sizeof (mp->client_address));
10468 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10470 mp->local_session_id = ntohl (local_session_id);
10471 mp->remote_session_id = ntohl (remote_session_id);
10472 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10473 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10474 mp->l2_sublayer_present = l2_sublayer_present;
10483 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10485 unformat_input_t *i = vam->input;
10487 u8 sw_if_index_set = 0;
10488 u64 new_local_cookie = 0;
10489 u64 new_remote_cookie = 0;
10490 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10496 sw_if_index_set = 1;
10497 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10498 sw_if_index_set = 1;
10499 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10501 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10507 if (sw_if_index_set == 0)
10509 errmsg ("missing interface name or sw_if_index");
10513 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10515 mp->sw_if_index = ntohl (sw_if_index);
10516 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10517 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10525 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10527 unformat_input_t *i = vam->input;
10528 vl_api_l2tpv3_interface_enable_disable_t *mp;
10530 u8 sw_if_index_set = 0;
10531 u8 enable_disable = 1;
10534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10537 sw_if_index_set = 1;
10538 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10539 sw_if_index_set = 1;
10540 else if (unformat (i, "enable"))
10541 enable_disable = 1;
10542 else if (unformat (i, "disable"))
10543 enable_disable = 0;
10548 if (sw_if_index_set == 0)
10550 errmsg ("missing interface name or sw_if_index");
10554 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10556 mp->sw_if_index = ntohl (sw_if_index);
10557 mp->enable_disable = enable_disable;
10565 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10567 unformat_input_t *i = vam->input;
10568 vl_api_l2tpv3_set_lookup_key_t *mp;
10572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10574 if (unformat (i, "lookup_v6_src"))
10575 key = L2T_LOOKUP_SRC_ADDRESS;
10576 else if (unformat (i, "lookup_v6_dst"))
10577 key = L2T_LOOKUP_DST_ADDRESS;
10578 else if (unformat (i, "lookup_session_id"))
10579 key = L2T_LOOKUP_SESSION_ID;
10584 if (key == (u8) ~ 0)
10586 errmsg ("l2tp session lookup key unset");
10590 M (L2TPV3_SET_LOOKUP_KEY, mp);
10599 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10600 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10602 vat_main_t *vam = &vat_main;
10604 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10605 format_ip6_address, mp->our_address,
10606 format_ip6_address, mp->client_address,
10607 clib_net_to_host_u32 (mp->sw_if_index));
10610 " local cookies %016llx %016llx remote cookie %016llx",
10611 clib_net_to_host_u64 (mp->local_cookie[0]),
10612 clib_net_to_host_u64 (mp->local_cookie[1]),
10613 clib_net_to_host_u64 (mp->remote_cookie));
10615 print (vam->ofp, " local session-id %d remote session-id %d",
10616 clib_net_to_host_u32 (mp->local_session_id),
10617 clib_net_to_host_u32 (mp->remote_session_id));
10619 print (vam->ofp, " l2 specific sublayer %s\n",
10620 mp->l2_sublayer_present ? "preset" : "absent");
10624 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10625 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10627 vat_main_t *vam = &vat_main;
10628 vat_json_node_t *node = NULL;
10629 struct in6_addr addr;
10631 if (VAT_JSON_ARRAY != vam->json_tree.type)
10633 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10634 vat_json_init_array (&vam->json_tree);
10636 node = vat_json_array_add (&vam->json_tree);
10638 vat_json_init_object (node);
10640 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10641 vat_json_object_add_ip6 (node, "our_address", addr);
10642 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10643 vat_json_object_add_ip6 (node, "client_address", addr);
10645 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10646 vat_json_init_array (lc);
10647 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10648 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10649 vat_json_object_add_uint (node, "remote_cookie",
10650 clib_net_to_host_u64 (mp->remote_cookie));
10652 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10653 vat_json_object_add_uint (node, "local_session_id",
10654 clib_net_to_host_u32 (mp->local_session_id));
10655 vat_json_object_add_uint (node, "remote_session_id",
10656 clib_net_to_host_u32 (mp->remote_session_id));
10657 vat_json_object_add_string_copy (node, "l2_sublayer",
10658 mp->l2_sublayer_present ? (u8 *) "present"
10659 : (u8 *) "absent");
10663 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10665 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10666 vl_api_control_ping_t *mp_ping;
10669 /* Get list of l2tpv3-tunnel interfaces */
10670 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10673 /* Use a control ping for synchronization */
10674 M (CONTROL_PING, mp_ping);
10682 static void vl_api_sw_interface_tap_details_t_handler
10683 (vl_api_sw_interface_tap_details_t * mp)
10685 vat_main_t *vam = &vat_main;
10687 print (vam->ofp, "%-16s %d",
10688 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10691 static void vl_api_sw_interface_tap_details_t_handler_json
10692 (vl_api_sw_interface_tap_details_t * mp)
10694 vat_main_t *vam = &vat_main;
10695 vat_json_node_t *node = NULL;
10697 if (VAT_JSON_ARRAY != vam->json_tree.type)
10699 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10700 vat_json_init_array (&vam->json_tree);
10702 node = vat_json_array_add (&vam->json_tree);
10704 vat_json_init_object (node);
10705 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10706 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10710 api_sw_interface_tap_dump (vat_main_t * vam)
10712 vl_api_sw_interface_tap_dump_t *mp;
10713 vl_api_control_ping_t *mp_ping;
10716 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10717 /* Get list of tap interfaces */
10718 M (SW_INTERFACE_TAP_DUMP, mp);
10721 /* Use a control ping for synchronization */
10722 M (CONTROL_PING, mp_ping);
10729 static uword unformat_vxlan_decap_next
10730 (unformat_input_t * input, va_list * args)
10732 u32 *result = va_arg (*args, u32 *);
10735 if (unformat (input, "l2"))
10736 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10737 else if (unformat (input, "%d", &tmp))
10745 api_vxlan_add_del_tunnel (vat_main_t * vam)
10747 unformat_input_t *line_input = vam->input;
10748 vl_api_vxlan_add_del_tunnel_t *mp;
10749 ip46_address_t src, dst;
10751 u8 ipv4_set = 0, ipv6_set = 0;
10755 u32 mcast_sw_if_index = ~0;
10756 u32 encap_vrf_id = 0;
10757 u32 decap_next_index = ~0;
10761 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10762 memset (&src, 0, sizeof src);
10763 memset (&dst, 0, sizeof dst);
10765 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10767 if (unformat (line_input, "del"))
10770 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10776 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10782 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10788 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10793 else if (unformat (line_input, "group %U %U",
10794 unformat_ip4_address, &dst.ip4,
10795 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10797 grp_set = dst_set = 1;
10800 else if (unformat (line_input, "group %U",
10801 unformat_ip4_address, &dst.ip4))
10803 grp_set = dst_set = 1;
10806 else if (unformat (line_input, "group %U %U",
10807 unformat_ip6_address, &dst.ip6,
10808 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10810 grp_set = dst_set = 1;
10813 else if (unformat (line_input, "group %U",
10814 unformat_ip6_address, &dst.ip6))
10816 grp_set = dst_set = 1;
10820 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10822 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10824 else if (unformat (line_input, "decap-next %U",
10825 unformat_vxlan_decap_next, &decap_next_index))
10827 else if (unformat (line_input, "vni %d", &vni))
10831 errmsg ("parse error '%U'", format_unformat_error, line_input);
10838 errmsg ("tunnel src address not specified");
10843 errmsg ("tunnel dst address not specified");
10847 if (grp_set && !ip46_address_is_multicast (&dst))
10849 errmsg ("tunnel group address not multicast");
10852 if (grp_set && mcast_sw_if_index == ~0)
10854 errmsg ("tunnel nonexistent multicast device");
10857 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10859 errmsg ("tunnel dst address must be unicast");
10864 if (ipv4_set && ipv6_set)
10866 errmsg ("both IPv4 and IPv6 addresses specified");
10870 if ((vni == 0) || (vni >> 24))
10872 errmsg ("vni not specified or out of range");
10876 M (VXLAN_ADD_DEL_TUNNEL, mp);
10880 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10881 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10885 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10886 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10888 mp->encap_vrf_id = ntohl (encap_vrf_id);
10889 mp->decap_next_index = ntohl (decap_next_index);
10890 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10891 mp->vni = ntohl (vni);
10892 mp->is_add = is_add;
10893 mp->is_ipv6 = ipv6_set;
10900 static void vl_api_vxlan_tunnel_details_t_handler
10901 (vl_api_vxlan_tunnel_details_t * mp)
10903 vat_main_t *vam = &vat_main;
10904 ip46_address_t src, dst;
10906 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10907 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10909 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10910 ntohl (mp->sw_if_index),
10911 format_ip46_address, &src, IP46_TYPE_ANY,
10912 format_ip46_address, &dst, IP46_TYPE_ANY,
10913 ntohl (mp->encap_vrf_id),
10914 ntohl (mp->decap_next_index), ntohl (mp->vni),
10915 ntohl (mp->mcast_sw_if_index));
10918 static void vl_api_vxlan_tunnel_details_t_handler_json
10919 (vl_api_vxlan_tunnel_details_t * mp)
10921 vat_main_t *vam = &vat_main;
10922 vat_json_node_t *node = NULL;
10924 if (VAT_JSON_ARRAY != vam->json_tree.type)
10926 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10927 vat_json_init_array (&vam->json_tree);
10929 node = vat_json_array_add (&vam->json_tree);
10931 vat_json_init_object (node);
10932 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10935 struct in6_addr ip6;
10937 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10938 vat_json_object_add_ip6 (node, "src_address", ip6);
10939 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10940 vat_json_object_add_ip6 (node, "dst_address", ip6);
10944 struct in_addr ip4;
10946 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10947 vat_json_object_add_ip4 (node, "src_address", ip4);
10948 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10949 vat_json_object_add_ip4 (node, "dst_address", ip4);
10951 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10952 vat_json_object_add_uint (node, "decap_next_index",
10953 ntohl (mp->decap_next_index));
10954 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10955 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10956 vat_json_object_add_uint (node, "mcast_sw_if_index",
10957 ntohl (mp->mcast_sw_if_index));
10961 api_vxlan_tunnel_dump (vat_main_t * vam)
10963 unformat_input_t *i = vam->input;
10964 vl_api_vxlan_tunnel_dump_t *mp;
10965 vl_api_control_ping_t *mp_ping;
10967 u8 sw_if_index_set = 0;
10970 /* Parse args required to build the message */
10971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10973 if (unformat (i, "sw_if_index %d", &sw_if_index))
10974 sw_if_index_set = 1;
10979 if (sw_if_index_set == 0)
10984 if (!vam->json_output)
10986 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10987 "sw_if_index", "src_address", "dst_address",
10988 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10991 /* Get list of vxlan-tunnel interfaces */
10992 M (VXLAN_TUNNEL_DUMP, mp);
10994 mp->sw_if_index = htonl (sw_if_index);
10998 /* Use a control ping for synchronization */
10999 M (CONTROL_PING, mp_ping);
11007 api_gre_add_del_tunnel (vat_main_t * vam)
11009 unformat_input_t *line_input = vam->input;
11010 vl_api_gre_add_del_tunnel_t *mp;
11011 ip4_address_t src4, dst4;
11016 u32 outer_fib_id = 0;
11019 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11021 if (unformat (line_input, "del"))
11023 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11025 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11027 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11029 else if (unformat (line_input, "teb"))
11033 errmsg ("parse error '%U'", format_unformat_error, line_input);
11040 errmsg ("tunnel src address not specified");
11045 errmsg ("tunnel dst address not specified");
11050 M (GRE_ADD_DEL_TUNNEL, mp);
11052 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
11053 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
11054 mp->outer_fib_id = ntohl (outer_fib_id);
11055 mp->is_add = is_add;
11063 static void vl_api_gre_tunnel_details_t_handler
11064 (vl_api_gre_tunnel_details_t * mp)
11066 vat_main_t *vam = &vat_main;
11068 print (vam->ofp, "%11d%15U%15U%6d%14d",
11069 ntohl (mp->sw_if_index),
11070 format_ip4_address, &mp->src_address,
11071 format_ip4_address, &mp->dst_address,
11072 mp->teb, ntohl (mp->outer_fib_id));
11075 static void vl_api_gre_tunnel_details_t_handler_json
11076 (vl_api_gre_tunnel_details_t * mp)
11078 vat_main_t *vam = &vat_main;
11079 vat_json_node_t *node = NULL;
11080 struct in_addr ip4;
11082 if (VAT_JSON_ARRAY != vam->json_tree.type)
11084 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11085 vat_json_init_array (&vam->json_tree);
11087 node = vat_json_array_add (&vam->json_tree);
11089 vat_json_init_object (node);
11090 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11091 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11092 vat_json_object_add_ip4 (node, "src_address", ip4);
11093 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11094 vat_json_object_add_ip4 (node, "dst_address", ip4);
11095 vat_json_object_add_uint (node, "teb", mp->teb);
11096 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11100 api_gre_tunnel_dump (vat_main_t * vam)
11102 unformat_input_t *i = vam->input;
11103 vl_api_gre_tunnel_dump_t *mp;
11104 vl_api_control_ping_t *mp_ping;
11106 u8 sw_if_index_set = 0;
11109 /* Parse args required to build the message */
11110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11112 if (unformat (i, "sw_if_index %d", &sw_if_index))
11113 sw_if_index_set = 1;
11118 if (sw_if_index_set == 0)
11123 if (!vam->json_output)
11125 print (vam->ofp, "%11s%15s%15s%6s%14s",
11126 "sw_if_index", "src_address", "dst_address", "teb",
11130 /* Get list of gre-tunnel interfaces */
11131 M (GRE_TUNNEL_DUMP, mp);
11133 mp->sw_if_index = htonl (sw_if_index);
11137 /* Use a control ping for synchronization */
11138 M (CONTROL_PING, mp_ping);
11146 api_l2_fib_clear_table (vat_main_t * vam)
11148 // unformat_input_t * i = vam->input;
11149 vl_api_l2_fib_clear_table_t *mp;
11152 M (L2_FIB_CLEAR_TABLE, mp);
11160 api_l2_interface_efp_filter (vat_main_t * vam)
11162 unformat_input_t *i = vam->input;
11163 vl_api_l2_interface_efp_filter_t *mp;
11166 u8 sw_if_index_set = 0;
11169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11172 sw_if_index_set = 1;
11173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11174 sw_if_index_set = 1;
11175 else if (unformat (i, "enable"))
11177 else if (unformat (i, "disable"))
11181 clib_warning ("parse error '%U'", format_unformat_error, i);
11186 if (sw_if_index_set == 0)
11188 errmsg ("missing sw_if_index");
11192 M (L2_INTERFACE_EFP_FILTER, mp);
11194 mp->sw_if_index = ntohl (sw_if_index);
11195 mp->enable_disable = enable;
11202 #define foreach_vtr_op \
11203 _("disable", L2_VTR_DISABLED) \
11204 _("push-1", L2_VTR_PUSH_1) \
11205 _("push-2", L2_VTR_PUSH_2) \
11206 _("pop-1", L2_VTR_POP_1) \
11207 _("pop-2", L2_VTR_POP_2) \
11208 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11209 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11210 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11211 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11214 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11216 unformat_input_t *i = vam->input;
11217 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11219 u8 sw_if_index_set = 0;
11222 u32 push_dot1q = 1;
11227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11229 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11230 sw_if_index_set = 1;
11231 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11232 sw_if_index_set = 1;
11233 else if (unformat (i, "vtr_op %d", &vtr_op))
11235 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11238 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11240 else if (unformat (i, "tag1 %d", &tag1))
11242 else if (unformat (i, "tag2 %d", &tag2))
11246 clib_warning ("parse error '%U'", format_unformat_error, i);
11251 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11253 errmsg ("missing vtr operation or sw_if_index");
11257 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
11258 mp->sw_if_index = ntohl (sw_if_index);
11259 mp->vtr_op = ntohl (vtr_op);
11260 mp->push_dot1q = ntohl (push_dot1q);
11261 mp->tag1 = ntohl (tag1);
11262 mp->tag2 = ntohl (tag2);
11270 api_create_vhost_user_if (vat_main_t * vam)
11272 unformat_input_t *i = vam->input;
11273 vl_api_create_vhost_user_if_t *mp;
11276 u8 file_name_set = 0;
11277 u32 custom_dev_instance = ~0;
11279 u8 use_custom_mac = 0;
11283 /* Shut up coverity */
11284 memset (hwaddr, 0, sizeof (hwaddr));
11286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11288 if (unformat (i, "socket %s", &file_name))
11292 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11294 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11295 use_custom_mac = 1;
11296 else if (unformat (i, "server"))
11298 else if (unformat (i, "tag %s", &tag))
11304 if (file_name_set == 0)
11306 errmsg ("missing socket file name");
11310 if (vec_len (file_name) > 255)
11312 errmsg ("socket file name too long");
11315 vec_add1 (file_name, 0);
11317 M (CREATE_VHOST_USER_IF, mp);
11319 mp->is_server = is_server;
11320 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11321 vec_free (file_name);
11322 if (custom_dev_instance != ~0)
11325 mp->custom_dev_instance = ntohl (custom_dev_instance);
11327 mp->use_custom_mac = use_custom_mac;
11328 clib_memcpy (mp->mac_address, hwaddr, 6);
11330 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11339 api_modify_vhost_user_if (vat_main_t * vam)
11341 unformat_input_t *i = vam->input;
11342 vl_api_modify_vhost_user_if_t *mp;
11345 u8 file_name_set = 0;
11346 u32 custom_dev_instance = ~0;
11347 u8 sw_if_index_set = 0;
11348 u32 sw_if_index = (u32) ~ 0;
11351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11353 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11354 sw_if_index_set = 1;
11355 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11356 sw_if_index_set = 1;
11357 else if (unformat (i, "socket %s", &file_name))
11361 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11363 else if (unformat (i, "server"))
11369 if (sw_if_index_set == 0)
11371 errmsg ("missing sw_if_index or interface name");
11375 if (file_name_set == 0)
11377 errmsg ("missing socket file name");
11381 if (vec_len (file_name) > 255)
11383 errmsg ("socket file name too long");
11386 vec_add1 (file_name, 0);
11388 M (MODIFY_VHOST_USER_IF, mp);
11390 mp->sw_if_index = ntohl (sw_if_index);
11391 mp->is_server = is_server;
11392 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11393 vec_free (file_name);
11394 if (custom_dev_instance != ~0)
11397 mp->custom_dev_instance = ntohl (custom_dev_instance);
11406 api_delete_vhost_user_if (vat_main_t * vam)
11408 unformat_input_t *i = vam->input;
11409 vl_api_delete_vhost_user_if_t *mp;
11410 u32 sw_if_index = ~0;
11411 u8 sw_if_index_set = 0;
11414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11416 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11417 sw_if_index_set = 1;
11418 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11419 sw_if_index_set = 1;
11424 if (sw_if_index_set == 0)
11426 errmsg ("missing sw_if_index or interface name");
11431 M (DELETE_VHOST_USER_IF, mp);
11433 mp->sw_if_index = ntohl (sw_if_index);
11440 static void vl_api_sw_interface_vhost_user_details_t_handler
11441 (vl_api_sw_interface_vhost_user_details_t * mp)
11443 vat_main_t *vam = &vat_main;
11445 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11446 (char *) mp->interface_name,
11447 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11448 clib_net_to_host_u64 (mp->features), mp->is_server,
11449 ntohl (mp->num_regions), (char *) mp->sock_filename);
11450 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11453 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11454 (vl_api_sw_interface_vhost_user_details_t * mp)
11456 vat_main_t *vam = &vat_main;
11457 vat_json_node_t *node = NULL;
11459 if (VAT_JSON_ARRAY != vam->json_tree.type)
11461 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11462 vat_json_init_array (&vam->json_tree);
11464 node = vat_json_array_add (&vam->json_tree);
11466 vat_json_init_object (node);
11467 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11468 vat_json_object_add_string_copy (node, "interface_name",
11469 mp->interface_name);
11470 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11471 ntohl (mp->virtio_net_hdr_sz));
11472 vat_json_object_add_uint (node, "features",
11473 clib_net_to_host_u64 (mp->features));
11474 vat_json_object_add_uint (node, "is_server", mp->is_server);
11475 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11476 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11477 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11481 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11483 vl_api_sw_interface_vhost_user_dump_t *mp;
11484 vl_api_control_ping_t *mp_ping;
11487 "Interface name idx hdr_sz features server regions filename");
11489 /* Get list of vhost-user interfaces */
11490 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11493 /* Use a control ping for synchronization */
11494 M (CONTROL_PING, mp_ping);
11502 api_show_version (vat_main_t * vam)
11504 vl_api_show_version_t *mp;
11507 M (SHOW_VERSION, mp);
11516 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11518 unformat_input_t *line_input = vam->input;
11519 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11520 ip4_address_t local4, remote4;
11521 ip6_address_t local6, remote6;
11523 u8 ipv4_set = 0, ipv6_set = 0;
11526 u32 encap_vrf_id = 0;
11527 u32 decap_vrf_id = 0;
11533 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (line_input, "del"))
11537 else if (unformat (line_input, "local %U",
11538 unformat_ip4_address, &local4))
11543 else if (unformat (line_input, "remote %U",
11544 unformat_ip4_address, &remote4))
11549 else if (unformat (line_input, "local %U",
11550 unformat_ip6_address, &local6))
11555 else if (unformat (line_input, "remote %U",
11556 unformat_ip6_address, &remote6))
11561 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11563 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11565 else if (unformat (line_input, "vni %d", &vni))
11567 else if (unformat (line_input, "next-ip4"))
11569 else if (unformat (line_input, "next-ip6"))
11571 else if (unformat (line_input, "next-ethernet"))
11573 else if (unformat (line_input, "next-nsh"))
11577 errmsg ("parse error '%U'", format_unformat_error, line_input);
11582 if (local_set == 0)
11584 errmsg ("tunnel local address not specified");
11587 if (remote_set == 0)
11589 errmsg ("tunnel remote address not specified");
11592 if (ipv4_set && ipv6_set)
11594 errmsg ("both IPv4 and IPv6 addresses specified");
11600 errmsg ("vni not specified");
11604 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11609 clib_memcpy (&mp->local, &local6, sizeof (local6));
11610 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11614 clib_memcpy (&mp->local, &local4, sizeof (local4));
11615 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11618 mp->encap_vrf_id = ntohl (encap_vrf_id);
11619 mp->decap_vrf_id = ntohl (decap_vrf_id);
11620 mp->protocol = protocol;
11621 mp->vni = ntohl (vni);
11622 mp->is_add = is_add;
11623 mp->is_ipv6 = ipv6_set;
11630 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11631 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11633 vat_main_t *vam = &vat_main;
11635 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11636 ntohl (mp->sw_if_index),
11637 format_ip46_address, &(mp->local[0]),
11638 format_ip46_address, &(mp->remote[0]),
11640 ntohl (mp->protocol),
11641 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11644 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11645 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11647 vat_main_t *vam = &vat_main;
11648 vat_json_node_t *node = NULL;
11649 struct in_addr ip4;
11650 struct in6_addr ip6;
11652 if (VAT_JSON_ARRAY != vam->json_tree.type)
11654 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11655 vat_json_init_array (&vam->json_tree);
11657 node = vat_json_array_add (&vam->json_tree);
11659 vat_json_init_object (node);
11660 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11663 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11664 vat_json_object_add_ip6 (node, "local", ip6);
11665 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11666 vat_json_object_add_ip6 (node, "remote", ip6);
11670 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11671 vat_json_object_add_ip4 (node, "local", ip4);
11672 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11673 vat_json_object_add_ip4 (node, "remote", ip4);
11675 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11676 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11677 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11678 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11679 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11683 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11685 unformat_input_t *i = vam->input;
11686 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11687 vl_api_control_ping_t *mp_ping;
11689 u8 sw_if_index_set = 0;
11692 /* Parse args required to build the message */
11693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11695 if (unformat (i, "sw_if_index %d", &sw_if_index))
11696 sw_if_index_set = 1;
11701 if (sw_if_index_set == 0)
11706 if (!vam->json_output)
11708 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11709 "sw_if_index", "local", "remote", "vni",
11710 "protocol", "encap_vrf_id", "decap_vrf_id");
11713 /* Get list of vxlan-tunnel interfaces */
11714 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11716 mp->sw_if_index = htonl (sw_if_index);
11720 /* Use a control ping for synchronization */
11721 M (CONTROL_PING, mp_ping);
11729 format_l2_fib_mac_address (u8 * s, va_list * args)
11731 u8 *a = va_arg (*args, u8 *);
11733 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11734 a[2], a[3], a[4], a[5], a[6], a[7]);
11737 static void vl_api_l2_fib_table_entry_t_handler
11738 (vl_api_l2_fib_table_entry_t * mp)
11740 vat_main_t *vam = &vat_main;
11742 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11744 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11745 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11749 static void vl_api_l2_fib_table_entry_t_handler_json
11750 (vl_api_l2_fib_table_entry_t * mp)
11752 vat_main_t *vam = &vat_main;
11753 vat_json_node_t *node = NULL;
11755 if (VAT_JSON_ARRAY != vam->json_tree.type)
11757 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11758 vat_json_init_array (&vam->json_tree);
11760 node = vat_json_array_add (&vam->json_tree);
11762 vat_json_init_object (node);
11763 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11764 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11765 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11766 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11767 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11768 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11772 api_l2_fib_table_dump (vat_main_t * vam)
11774 unformat_input_t *i = vam->input;
11775 vl_api_l2_fib_table_dump_t *mp;
11776 vl_api_control_ping_t *mp_ping;
11781 /* Parse args required to build the message */
11782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11784 if (unformat (i, "bd_id %d", &bd_id))
11790 if (bd_id_set == 0)
11792 errmsg ("missing bridge domain");
11796 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11798 /* Get list of l2 fib entries */
11799 M (L2_FIB_TABLE_DUMP, mp);
11801 mp->bd_id = ntohl (bd_id);
11804 /* Use a control ping for synchronization */
11805 M (CONTROL_PING, mp_ping);
11814 api_interface_name_renumber (vat_main_t * vam)
11816 unformat_input_t *line_input = vam->input;
11817 vl_api_interface_name_renumber_t *mp;
11818 u32 sw_if_index = ~0;
11819 u32 new_show_dev_instance = ~0;
11822 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11824 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11827 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11829 else if (unformat (line_input, "new_show_dev_instance %d",
11830 &new_show_dev_instance))
11836 if (sw_if_index == ~0)
11838 errmsg ("missing interface name or sw_if_index");
11842 if (new_show_dev_instance == ~0)
11844 errmsg ("missing new_show_dev_instance");
11848 M (INTERFACE_NAME_RENUMBER, mp);
11850 mp->sw_if_index = ntohl (sw_if_index);
11851 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11859 api_want_ip4_arp_events (vat_main_t * vam)
11861 unformat_input_t *line_input = vam->input;
11862 vl_api_want_ip4_arp_events_t *mp;
11863 ip4_address_t address;
11864 int address_set = 0;
11865 u32 enable_disable = 1;
11868 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11870 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11872 else if (unformat (line_input, "del"))
11873 enable_disable = 0;
11878 if (address_set == 0)
11880 errmsg ("missing addresses");
11884 M (WANT_IP4_ARP_EVENTS, mp);
11885 mp->enable_disable = enable_disable;
11886 mp->pid = getpid ();
11887 mp->address = address.as_u32;
11895 api_want_ip6_nd_events (vat_main_t * vam)
11897 unformat_input_t *line_input = vam->input;
11898 vl_api_want_ip6_nd_events_t *mp;
11899 ip6_address_t address;
11900 int address_set = 0;
11901 u32 enable_disable = 1;
11904 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11906 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11908 else if (unformat (line_input, "del"))
11909 enable_disable = 0;
11914 if (address_set == 0)
11916 errmsg ("missing addresses");
11920 M (WANT_IP6_ND_EVENTS, mp);
11921 mp->enable_disable = enable_disable;
11922 mp->pid = getpid ();
11923 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11931 api_input_acl_set_interface (vat_main_t * vam)
11933 unformat_input_t *i = vam->input;
11934 vl_api_input_acl_set_interface_t *mp;
11936 int sw_if_index_set;
11937 u32 ip4_table_index = ~0;
11938 u32 ip6_table_index = ~0;
11939 u32 l2_table_index = ~0;
11943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11946 sw_if_index_set = 1;
11947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11948 sw_if_index_set = 1;
11949 else if (unformat (i, "del"))
11951 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11953 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11955 else if (unformat (i, "l2-table %d", &l2_table_index))
11959 clib_warning ("parse error '%U'", format_unformat_error, i);
11964 if (sw_if_index_set == 0)
11966 errmsg ("missing interface name or sw_if_index");
11970 M (INPUT_ACL_SET_INTERFACE, mp);
11972 mp->sw_if_index = ntohl (sw_if_index);
11973 mp->ip4_table_index = ntohl (ip4_table_index);
11974 mp->ip6_table_index = ntohl (ip6_table_index);
11975 mp->l2_table_index = ntohl (l2_table_index);
11976 mp->is_add = is_add;
11984 api_ip_address_dump (vat_main_t * vam)
11986 unformat_input_t *i = vam->input;
11987 vl_api_ip_address_dump_t *mp;
11988 vl_api_control_ping_t *mp_ping;
11989 u32 sw_if_index = ~0;
11990 u8 sw_if_index_set = 0;
11995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11997 if (unformat (i, "sw_if_index %d", &sw_if_index))
11998 sw_if_index_set = 1;
12000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12001 sw_if_index_set = 1;
12002 else if (unformat (i, "ipv4"))
12004 else if (unformat (i, "ipv6"))
12010 if (ipv4_set && ipv6_set)
12012 errmsg ("ipv4 and ipv6 flags cannot be both set");
12016 if ((!ipv4_set) && (!ipv6_set))
12018 errmsg ("no ipv4 nor ipv6 flag set");
12022 if (sw_if_index_set == 0)
12024 errmsg ("missing interface name or sw_if_index");
12028 vam->current_sw_if_index = sw_if_index;
12029 vam->is_ipv6 = ipv6_set;
12031 M (IP_ADDRESS_DUMP, mp);
12032 mp->sw_if_index = ntohl (sw_if_index);
12033 mp->is_ipv6 = ipv6_set;
12036 /* Use a control ping for synchronization */
12037 M (CONTROL_PING, mp_ping);
12045 api_ip_dump (vat_main_t * vam)
12047 vl_api_ip_dump_t *mp;
12048 vl_api_control_ping_t *mp_ping;
12049 unformat_input_t *in = vam->input;
12056 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12058 if (unformat (in, "ipv4"))
12060 else if (unformat (in, "ipv6"))
12066 if (ipv4_set && ipv6_set)
12068 errmsg ("ipv4 and ipv6 flags cannot be both set");
12072 if ((!ipv4_set) && (!ipv6_set))
12074 errmsg ("no ipv4 nor ipv6 flag set");
12078 is_ipv6 = ipv6_set;
12079 vam->is_ipv6 = is_ipv6;
12081 /* free old data */
12082 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12084 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12086 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12089 mp->is_ipv6 = ipv6_set;
12092 /* Use a control ping for synchronization */
12093 M (CONTROL_PING, mp_ping);
12101 api_ipsec_spd_add_del (vat_main_t * vam)
12103 unformat_input_t *i = vam->input;
12104 vl_api_ipsec_spd_add_del_t *mp;
12109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12111 if (unformat (i, "spd_id %d", &spd_id))
12113 else if (unformat (i, "del"))
12117 clib_warning ("parse error '%U'", format_unformat_error, i);
12123 errmsg ("spd_id must be set");
12127 M (IPSEC_SPD_ADD_DEL, mp);
12129 mp->spd_id = ntohl (spd_id);
12130 mp->is_add = is_add;
12138 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12140 unformat_input_t *i = vam->input;
12141 vl_api_ipsec_interface_add_del_spd_t *mp;
12143 u8 sw_if_index_set = 0;
12144 u32 spd_id = (u32) ~ 0;
12148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12150 if (unformat (i, "del"))
12152 else if (unformat (i, "spd_id %d", &spd_id))
12155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12156 sw_if_index_set = 1;
12157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12158 sw_if_index_set = 1;
12161 clib_warning ("parse error '%U'", format_unformat_error, i);
12167 if (spd_id == (u32) ~ 0)
12169 errmsg ("spd_id must be set");
12173 if (sw_if_index_set == 0)
12175 errmsg ("missing interface name or sw_if_index");
12179 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
12181 mp->spd_id = ntohl (spd_id);
12182 mp->sw_if_index = ntohl (sw_if_index);
12183 mp->is_add = is_add;
12191 api_ipsec_spd_add_del_entry (vat_main_t * vam)
12193 unformat_input_t *i = vam->input;
12194 vl_api_ipsec_spd_add_del_entry_t *mp;
12195 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
12196 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
12198 u32 rport_start = 0, rport_stop = (u32) ~ 0;
12199 u32 lport_start = 0, lport_stop = (u32) ~ 0;
12200 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
12201 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
12204 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
12205 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
12206 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
12207 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
12208 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
12209 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
12211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12213 if (unformat (i, "del"))
12215 if (unformat (i, "outbound"))
12217 if (unformat (i, "inbound"))
12219 else if (unformat (i, "spd_id %d", &spd_id))
12221 else if (unformat (i, "sa_id %d", &sa_id))
12223 else if (unformat (i, "priority %d", &priority))
12225 else if (unformat (i, "protocol %d", &protocol))
12227 else if (unformat (i, "lport_start %d", &lport_start))
12229 else if (unformat (i, "lport_stop %d", &lport_stop))
12231 else if (unformat (i, "rport_start %d", &rport_start))
12233 else if (unformat (i, "rport_stop %d", &rport_stop))
12237 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
12243 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
12250 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
12256 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
12263 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
12269 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12276 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12282 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12288 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12290 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12292 clib_warning ("unsupported action: 'resolve'");
12298 clib_warning ("parse error '%U'", format_unformat_error, i);
12304 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12306 mp->spd_id = ntohl (spd_id);
12307 mp->priority = ntohl (priority);
12308 mp->is_outbound = is_outbound;
12310 mp->is_ipv6 = is_ipv6;
12311 if (is_ipv6 || is_ip_any)
12313 clib_memcpy (mp->remote_address_start, &raddr6_start,
12314 sizeof (ip6_address_t));
12315 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12316 sizeof (ip6_address_t));
12317 clib_memcpy (mp->local_address_start, &laddr6_start,
12318 sizeof (ip6_address_t));
12319 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12320 sizeof (ip6_address_t));
12324 clib_memcpy (mp->remote_address_start, &raddr4_start,
12325 sizeof (ip4_address_t));
12326 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12327 sizeof (ip4_address_t));
12328 clib_memcpy (mp->local_address_start, &laddr4_start,
12329 sizeof (ip4_address_t));
12330 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12331 sizeof (ip4_address_t));
12333 mp->protocol = (u8) protocol;
12334 mp->local_port_start = ntohs ((u16) lport_start);
12335 mp->local_port_stop = ntohs ((u16) lport_stop);
12336 mp->remote_port_start = ntohs ((u16) rport_start);
12337 mp->remote_port_stop = ntohs ((u16) rport_stop);
12338 mp->policy = (u8) policy;
12339 mp->sa_id = ntohl (sa_id);
12340 mp->is_add = is_add;
12341 mp->is_ip_any = is_ip_any;
12348 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12350 unformat_input_t *i = vam->input;
12351 vl_api_ipsec_sad_add_del_entry_t *mp;
12352 u32 sad_id = 0, spi = 0;
12353 u8 *ck = 0, *ik = 0;
12356 u8 protocol = IPSEC_PROTOCOL_AH;
12357 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12358 u32 crypto_alg = 0, integ_alg = 0;
12359 ip4_address_t tun_src4;
12360 ip4_address_t tun_dst4;
12361 ip6_address_t tun_src6;
12362 ip6_address_t tun_dst6;
12365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12367 if (unformat (i, "del"))
12369 else if (unformat (i, "sad_id %d", &sad_id))
12371 else if (unformat (i, "spi %d", &spi))
12373 else if (unformat (i, "esp"))
12374 protocol = IPSEC_PROTOCOL_ESP;
12375 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12378 is_tunnel_ipv6 = 0;
12380 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12383 is_tunnel_ipv6 = 0;
12385 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12388 is_tunnel_ipv6 = 1;
12390 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12393 is_tunnel_ipv6 = 1;
12397 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12399 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12400 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12402 clib_warning ("unsupported crypto-alg: '%U'",
12403 format_ipsec_crypto_alg, crypto_alg);
12407 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12411 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12413 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12414 integ_alg >= IPSEC_INTEG_N_ALG)
12416 clib_warning ("unsupported integ-alg: '%U'",
12417 format_ipsec_integ_alg, integ_alg);
12421 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12425 clib_warning ("parse error '%U'", format_unformat_error, i);
12431 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12433 mp->sad_id = ntohl (sad_id);
12434 mp->is_add = is_add;
12435 mp->protocol = protocol;
12436 mp->spi = ntohl (spi);
12437 mp->is_tunnel = is_tunnel;
12438 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12439 mp->crypto_algorithm = crypto_alg;
12440 mp->integrity_algorithm = integ_alg;
12441 mp->crypto_key_length = vec_len (ck);
12442 mp->integrity_key_length = vec_len (ik);
12444 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12445 mp->crypto_key_length = sizeof (mp->crypto_key);
12447 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12448 mp->integrity_key_length = sizeof (mp->integrity_key);
12451 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12453 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12457 if (is_tunnel_ipv6)
12459 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12460 sizeof (ip6_address_t));
12461 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12462 sizeof (ip6_address_t));
12466 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12467 sizeof (ip4_address_t));
12468 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12469 sizeof (ip4_address_t));
12479 api_ipsec_sa_set_key (vat_main_t * vam)
12481 unformat_input_t *i = vam->input;
12482 vl_api_ipsec_sa_set_key_t *mp;
12484 u8 *ck = 0, *ik = 0;
12487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12489 if (unformat (i, "sa_id %d", &sa_id))
12491 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12493 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12497 clib_warning ("parse error '%U'", format_unformat_error, i);
12502 M (IPSEC_SA_SET_KEY, mp);
12504 mp->sa_id = ntohl (sa_id);
12505 mp->crypto_key_length = vec_len (ck);
12506 mp->integrity_key_length = vec_len (ik);
12508 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12509 mp->crypto_key_length = sizeof (mp->crypto_key);
12511 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12512 mp->integrity_key_length = sizeof (mp->integrity_key);
12515 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12517 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12525 api_ikev2_profile_add_del (vat_main_t * vam)
12527 unformat_input_t *i = vam->input;
12528 vl_api_ikev2_profile_add_del_t *mp;
12533 const char *valid_chars = "a-zA-Z0-9_";
12535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12537 if (unformat (i, "del"))
12539 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12540 vec_add1 (name, 0);
12543 errmsg ("parse error '%U'", format_unformat_error, i);
12548 if (!vec_len (name))
12550 errmsg ("profile name must be specified");
12554 if (vec_len (name) > 64)
12556 errmsg ("profile name too long");
12560 M (IKEV2_PROFILE_ADD_DEL, mp);
12562 clib_memcpy (mp->name, name, vec_len (name));
12563 mp->is_add = is_add;
12572 api_ikev2_profile_set_auth (vat_main_t * vam)
12574 unformat_input_t *i = vam->input;
12575 vl_api_ikev2_profile_set_auth_t *mp;
12578 u32 auth_method = 0;
12582 const char *valid_chars = "a-zA-Z0-9_";
12584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12586 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12587 vec_add1 (name, 0);
12588 else if (unformat (i, "auth_method %U",
12589 unformat_ikev2_auth_method, &auth_method))
12591 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12593 else if (unformat (i, "auth_data %v", &data))
12597 errmsg ("parse error '%U'", format_unformat_error, i);
12602 if (!vec_len (name))
12604 errmsg ("profile name must be specified");
12608 if (vec_len (name) > 64)
12610 errmsg ("profile name too long");
12614 if (!vec_len (data))
12616 errmsg ("auth_data must be specified");
12622 errmsg ("auth_method must be specified");
12626 M (IKEV2_PROFILE_SET_AUTH, mp);
12628 mp->is_hex = is_hex;
12629 mp->auth_method = (u8) auth_method;
12630 mp->data_len = vec_len (data);
12631 clib_memcpy (mp->name, name, vec_len (name));
12632 clib_memcpy (mp->data, data, vec_len (data));
12642 api_ikev2_profile_set_id (vat_main_t * vam)
12644 unformat_input_t *i = vam->input;
12645 vl_api_ikev2_profile_set_id_t *mp;
12653 const char *valid_chars = "a-zA-Z0-9_";
12655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12657 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12658 vec_add1 (name, 0);
12659 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12661 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12663 data = vec_new (u8, 4);
12664 clib_memcpy (data, ip4.as_u8, 4);
12666 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12668 else if (unformat (i, "id_data %v", &data))
12670 else if (unformat (i, "local"))
12672 else if (unformat (i, "remote"))
12676 errmsg ("parse error '%U'", format_unformat_error, i);
12681 if (!vec_len (name))
12683 errmsg ("profile name must be specified");
12687 if (vec_len (name) > 64)
12689 errmsg ("profile name too long");
12693 if (!vec_len (data))
12695 errmsg ("id_data must be specified");
12701 errmsg ("id_type must be specified");
12705 M (IKEV2_PROFILE_SET_ID, mp);
12707 mp->is_local = is_local;
12708 mp->id_type = (u8) id_type;
12709 mp->data_len = vec_len (data);
12710 clib_memcpy (mp->name, name, vec_len (name));
12711 clib_memcpy (mp->data, data, vec_len (data));
12721 api_ikev2_profile_set_ts (vat_main_t * vam)
12723 unformat_input_t *i = vam->input;
12724 vl_api_ikev2_profile_set_ts_t *mp;
12727 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12728 ip4_address_t start_addr, end_addr;
12730 const char *valid_chars = "a-zA-Z0-9_";
12733 start_addr.as_u32 = 0;
12734 end_addr.as_u32 = (u32) ~ 0;
12736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12738 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12739 vec_add1 (name, 0);
12740 else if (unformat (i, "protocol %d", &proto))
12742 else if (unformat (i, "start_port %d", &start_port))
12744 else if (unformat (i, "end_port %d", &end_port))
12747 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12749 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12751 else if (unformat (i, "local"))
12753 else if (unformat (i, "remote"))
12757 errmsg ("parse error '%U'", format_unformat_error, i);
12762 if (!vec_len (name))
12764 errmsg ("profile name must be specified");
12768 if (vec_len (name) > 64)
12770 errmsg ("profile name too long");
12774 M (IKEV2_PROFILE_SET_TS, mp);
12776 mp->is_local = is_local;
12777 mp->proto = (u8) proto;
12778 mp->start_port = (u16) start_port;
12779 mp->end_port = (u16) end_port;
12780 mp->start_addr = start_addr.as_u32;
12781 mp->end_addr = end_addr.as_u32;
12782 clib_memcpy (mp->name, name, vec_len (name));
12791 api_ikev2_set_local_key (vat_main_t * vam)
12793 unformat_input_t *i = vam->input;
12794 vl_api_ikev2_set_local_key_t *mp;
12798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12800 if (unformat (i, "file %v", &file))
12801 vec_add1 (file, 0);
12804 errmsg ("parse error '%U'", format_unformat_error, i);
12809 if (!vec_len (file))
12811 errmsg ("RSA key file must be specified");
12815 if (vec_len (file) > 256)
12817 errmsg ("file name too long");
12821 M (IKEV2_SET_LOCAL_KEY, mp);
12823 clib_memcpy (mp->key_file, file, vec_len (file));
12832 api_ikev2_set_responder (vat_main_t * vam)
12834 unformat_input_t *i = vam->input;
12835 vl_api_ikev2_set_responder_t *mp;
12838 u32 sw_if_index = ~0;
12839 ip4_address_t address;
12841 const char *valid_chars = "a-zA-Z0-9_";
12843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12846 (i, "%U interface %d address %U", unformat_token, valid_chars,
12847 &name, &sw_if_index, unformat_ip4_address, &address))
12848 vec_add1 (name, 0);
12851 errmsg ("parse error '%U'", format_unformat_error, i);
12856 if (!vec_len (name))
12858 errmsg ("profile name must be specified");
12862 if (vec_len (name) > 64)
12864 errmsg ("profile name too long");
12868 M (IKEV2_SET_RESPONDER, mp);
12870 clib_memcpy (mp->name, name, vec_len (name));
12873 mp->sw_if_index = sw_if_index;
12874 clib_memcpy (mp->address, &address, sizeof (address));
12882 api_ikev2_set_ike_transforms (vat_main_t * vam)
12884 unformat_input_t *i = vam->input;
12885 vl_api_ikev2_set_ike_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_IKE_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;
12932 api_ikev2_set_esp_transforms (vat_main_t * vam)
12934 unformat_input_t *i = vam->input;
12935 vl_api_ikev2_set_esp_transforms_t *mp;
12938 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12940 const char *valid_chars = "a-zA-Z0-9_";
12942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12944 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12945 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12946 vec_add1 (name, 0);
12949 errmsg ("parse error '%U'", format_unformat_error, i);
12954 if (!vec_len (name))
12956 errmsg ("profile name must be specified");
12960 if (vec_len (name) > 64)
12962 errmsg ("profile name too long");
12966 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12968 clib_memcpy (mp->name, name, vec_len (name));
12970 mp->crypto_alg = crypto_alg;
12971 mp->crypto_key_size = crypto_key_size;
12972 mp->integ_alg = integ_alg;
12973 mp->dh_group = dh_group;
12981 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12983 unformat_input_t *i = vam->input;
12984 vl_api_ikev2_set_sa_lifetime_t *mp;
12987 u64 lifetime, lifetime_maxdata;
12988 u32 lifetime_jitter, handover;
12990 const char *valid_chars = "a-zA-Z0-9_";
12992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12994 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12995 &lifetime, &lifetime_jitter, &handover,
12996 &lifetime_maxdata))
12997 vec_add1 (name, 0);
13000 errmsg ("parse error '%U'", format_unformat_error, i);
13005 if (!vec_len (name))
13007 errmsg ("profile name must be specified");
13011 if (vec_len (name) > 64)
13013 errmsg ("profile name too long");
13017 M (IKEV2_SET_SA_LIFETIME, mp);
13019 clib_memcpy (mp->name, name, vec_len (name));
13021 mp->lifetime = lifetime;
13022 mp->lifetime_jitter = lifetime_jitter;
13023 mp->handover = handover;
13024 mp->lifetime_maxdata = lifetime_maxdata;
13032 api_ikev2_initiate_sa_init (vat_main_t * vam)
13034 unformat_input_t *i = vam->input;
13035 vl_api_ikev2_initiate_sa_init_t *mp;
13039 const char *valid_chars = "a-zA-Z0-9_";
13041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13043 if (unformat (i, "%U", unformat_token, valid_chars, &name))
13044 vec_add1 (name, 0);
13047 errmsg ("parse error '%U'", format_unformat_error, i);
13052 if (!vec_len (name))
13054 errmsg ("profile name must be specified");
13058 if (vec_len (name) > 64)
13060 errmsg ("profile name too long");
13064 M (IKEV2_INITIATE_SA_INIT, mp);
13066 clib_memcpy (mp->name, name, vec_len (name));
13075 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
13077 unformat_input_t *i = vam->input;
13078 vl_api_ikev2_initiate_del_ike_sa_t *mp;
13083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13085 if (unformat (i, "%lx", &ispi))
13089 errmsg ("parse error '%U'", format_unformat_error, i);
13094 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
13104 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
13106 unformat_input_t *i = vam->input;
13107 vl_api_ikev2_initiate_del_child_sa_t *mp;
13112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13114 if (unformat (i, "%x", &ispi))
13118 errmsg ("parse error '%U'", format_unformat_error, i);
13123 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
13133 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
13135 unformat_input_t *i = vam->input;
13136 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
13141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13143 if (unformat (i, "%x", &ispi))
13147 errmsg ("parse error '%U'", format_unformat_error, i);
13152 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
13165 api_map_add_domain (vat_main_t * vam)
13167 unformat_input_t *i = vam->input;
13168 vl_api_map_add_domain_t *mp;
13170 ip4_address_t ip4_prefix;
13171 ip6_address_t ip6_prefix;
13172 ip6_address_t ip6_src;
13173 u32 num_m_args = 0;
13174 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
13175 0, psid_length = 0;
13176 u8 is_translation = 0;
13178 u32 ip6_src_len = 128;
13181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13183 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
13184 &ip4_prefix, &ip4_prefix_len))
13186 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
13187 &ip6_prefix, &ip6_prefix_len))
13191 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
13194 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
13196 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
13198 else if (unformat (i, "psid-offset %d", &psid_offset))
13200 else if (unformat (i, "psid-len %d", &psid_length))
13202 else if (unformat (i, "mtu %d", &mtu))
13204 else if (unformat (i, "map-t"))
13205 is_translation = 1;
13208 clib_warning ("parse error '%U'", format_unformat_error, i);
13213 if (num_m_args < 3)
13215 errmsg ("mandatory argument(s) missing");
13219 /* Construct the API message */
13220 M (MAP_ADD_DOMAIN, mp);
13222 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
13223 mp->ip4_prefix_len = ip4_prefix_len;
13225 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
13226 mp->ip6_prefix_len = ip6_prefix_len;
13228 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
13229 mp->ip6_src_prefix_len = ip6_src_len;
13231 mp->ea_bits_len = ea_bits_len;
13232 mp->psid_offset = psid_offset;
13233 mp->psid_length = psid_length;
13234 mp->is_translation = is_translation;
13235 mp->mtu = htons (mtu);
13240 /* Wait for a reply, return good/bad news */
13246 api_map_del_domain (vat_main_t * vam)
13248 unformat_input_t *i = vam->input;
13249 vl_api_map_del_domain_t *mp;
13251 u32 num_m_args = 0;
13255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13257 if (unformat (i, "index %d", &index))
13261 clib_warning ("parse error '%U'", format_unformat_error, i);
13266 if (num_m_args != 1)
13268 errmsg ("mandatory argument(s) missing");
13272 /* Construct the API message */
13273 M (MAP_DEL_DOMAIN, mp);
13275 mp->index = ntohl (index);
13280 /* Wait for a reply, return good/bad news */
13286 api_map_add_del_rule (vat_main_t * vam)
13288 unformat_input_t *i = vam->input;
13289 vl_api_map_add_del_rule_t *mp;
13291 ip6_address_t ip6_dst;
13292 u32 num_m_args = 0, index, psid = 0;
13295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13297 if (unformat (i, "index %d", &index))
13299 else if (unformat (i, "psid %d", &psid))
13301 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13303 else if (unformat (i, "del"))
13309 clib_warning ("parse error '%U'", format_unformat_error, i);
13314 /* Construct the API message */
13315 M (MAP_ADD_DEL_RULE, mp);
13317 mp->index = ntohl (index);
13318 mp->is_add = is_add;
13319 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13320 mp->psid = ntohs (psid);
13325 /* Wait for a reply, return good/bad news */
13331 api_map_domain_dump (vat_main_t * vam)
13333 vl_api_map_domain_dump_t *mp;
13334 vl_api_control_ping_t *mp_ping;
13337 /* Construct the API message */
13338 M (MAP_DOMAIN_DUMP, mp);
13343 /* Use a control ping for synchronization */
13344 M (CONTROL_PING, mp_ping);
13352 api_map_rule_dump (vat_main_t * vam)
13354 unformat_input_t *i = vam->input;
13355 vl_api_map_rule_dump_t *mp;
13356 vl_api_control_ping_t *mp_ping;
13357 u32 domain_index = ~0;
13360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13362 if (unformat (i, "index %u", &domain_index))
13368 if (domain_index == ~0)
13370 clib_warning ("parse error: domain index expected");
13374 /* Construct the API message */
13375 M (MAP_RULE_DUMP, mp);
13377 mp->domain_index = htonl (domain_index);
13382 /* Use a control ping for synchronization */
13383 M (CONTROL_PING, mp_ping);
13390 static void vl_api_map_add_domain_reply_t_handler
13391 (vl_api_map_add_domain_reply_t * mp)
13393 vat_main_t *vam = &vat_main;
13394 i32 retval = ntohl (mp->retval);
13396 if (vam->async_mode)
13398 vam->async_errors += (retval < 0);
13402 vam->retval = retval;
13403 vam->result_ready = 1;
13407 static void vl_api_map_add_domain_reply_t_handler_json
13408 (vl_api_map_add_domain_reply_t * mp)
13410 vat_main_t *vam = &vat_main;
13411 vat_json_node_t node;
13413 vat_json_init_object (&node);
13414 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13415 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13417 vat_json_print (vam->ofp, &node);
13418 vat_json_free (&node);
13420 vam->retval = ntohl (mp->retval);
13421 vam->result_ready = 1;
13425 api_get_first_msg_id (vat_main_t * vam)
13427 vl_api_get_first_msg_id_t *mp;
13428 unformat_input_t *i = vam->input;
13433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13435 if (unformat (i, "client %s", &name))
13443 errmsg ("missing client name");
13446 vec_add1 (name, 0);
13448 if (vec_len (name) > 63)
13450 errmsg ("client name too long");
13454 M (GET_FIRST_MSG_ID, mp);
13455 clib_memcpy (mp->name, name, vec_len (name));
13462 api_cop_interface_enable_disable (vat_main_t * vam)
13464 unformat_input_t *line_input = vam->input;
13465 vl_api_cop_interface_enable_disable_t *mp;
13466 u32 sw_if_index = ~0;
13467 u8 enable_disable = 1;
13470 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13472 if (unformat (line_input, "disable"))
13473 enable_disable = 0;
13474 if (unformat (line_input, "enable"))
13475 enable_disable = 1;
13476 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13477 vam, &sw_if_index))
13479 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13485 if (sw_if_index == ~0)
13487 errmsg ("missing interface name or sw_if_index");
13491 /* Construct the API message */
13492 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13493 mp->sw_if_index = ntohl (sw_if_index);
13494 mp->enable_disable = enable_disable;
13498 /* Wait for the reply */
13504 api_cop_whitelist_enable_disable (vat_main_t * vam)
13506 unformat_input_t *line_input = vam->input;
13507 vl_api_cop_whitelist_enable_disable_t *mp;
13508 u32 sw_if_index = ~0;
13509 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13513 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13515 if (unformat (line_input, "ip4"))
13517 else if (unformat (line_input, "ip6"))
13519 else if (unformat (line_input, "default"))
13521 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13522 vam, &sw_if_index))
13524 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13526 else if (unformat (line_input, "fib-id %d", &fib_id))
13532 if (sw_if_index == ~0)
13534 errmsg ("missing interface name or sw_if_index");
13538 /* Construct the API message */
13539 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13540 mp->sw_if_index = ntohl (sw_if_index);
13541 mp->fib_id = ntohl (fib_id);
13544 mp->default_cop = default_cop;
13548 /* Wait for the reply */
13554 api_get_node_graph (vat_main_t * vam)
13556 vl_api_get_node_graph_t *mp;
13559 M (GET_NODE_GRAPH, mp);
13563 /* Wait for the reply */
13569 /** Used for parsing LISP eids */
13570 typedef CLIB_PACKED(struct{
13571 u8 addr[16]; /**< eid address */
13572 u32 len; /**< prefix length if IP */
13573 u8 type; /**< type of eid */
13578 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13580 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13582 memset (a, 0, sizeof (a[0]));
13584 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13586 a->type = 0; /* ipv4 type */
13588 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13590 a->type = 1; /* ipv6 type */
13592 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13594 a->type = 2; /* mac type */
13601 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13610 lisp_eid_size_vat (u8 type)
13625 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13627 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13631 api_one_add_del_locator_set (vat_main_t * vam)
13633 unformat_input_t *input = vam->input;
13634 vl_api_one_add_del_locator_set_t *mp;
13636 u8 *locator_set_name = NULL;
13637 u8 locator_set_name_set = 0;
13638 vl_api_local_locator_t locator, *locators = 0;
13639 u32 sw_if_index, priority, weight;
13643 /* Parse args required to build the message */
13644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13646 if (unformat (input, "del"))
13650 else if (unformat (input, "locator-set %s", &locator_set_name))
13652 locator_set_name_set = 1;
13654 else if (unformat (input, "sw_if_index %u p %u w %u",
13655 &sw_if_index, &priority, &weight))
13657 locator.sw_if_index = htonl (sw_if_index);
13658 locator.priority = priority;
13659 locator.weight = weight;
13660 vec_add1 (locators, locator);
13664 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13665 &sw_if_index, &priority, &weight))
13667 locator.sw_if_index = htonl (sw_if_index);
13668 locator.priority = priority;
13669 locator.weight = weight;
13670 vec_add1 (locators, locator);
13676 if (locator_set_name_set == 0)
13678 errmsg ("missing locator-set name");
13679 vec_free (locators);
13683 if (vec_len (locator_set_name) > 64)
13685 errmsg ("locator-set name too long");
13686 vec_free (locator_set_name);
13687 vec_free (locators);
13690 vec_add1 (locator_set_name, 0);
13692 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13694 /* Construct the API message */
13695 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13697 mp->is_add = is_add;
13698 clib_memcpy (mp->locator_set_name, locator_set_name,
13699 vec_len (locator_set_name));
13700 vec_free (locator_set_name);
13702 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13704 clib_memcpy (mp->locators, locators, data_len);
13705 vec_free (locators);
13710 /* Wait for a reply... */
13715 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13718 api_one_add_del_locator (vat_main_t * vam)
13720 unformat_input_t *input = vam->input;
13721 vl_api_one_add_del_locator_t *mp;
13722 u32 tmp_if_index = ~0;
13723 u32 sw_if_index = ~0;
13724 u8 sw_if_index_set = 0;
13725 u8 sw_if_index_if_name_set = 0;
13727 u8 priority_set = 0;
13731 u8 *locator_set_name = NULL;
13732 u8 locator_set_name_set = 0;
13735 /* Parse args required to build the message */
13736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13738 if (unformat (input, "del"))
13742 else if (unformat (input, "locator-set %s", &locator_set_name))
13744 locator_set_name_set = 1;
13746 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13749 sw_if_index_if_name_set = 1;
13750 sw_if_index = tmp_if_index;
13752 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13754 sw_if_index_set = 1;
13755 sw_if_index = tmp_if_index;
13757 else if (unformat (input, "p %d", &priority))
13761 else if (unformat (input, "w %d", &weight))
13769 if (locator_set_name_set == 0)
13771 errmsg ("missing locator-set name");
13775 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13777 errmsg ("missing sw_if_index");
13778 vec_free (locator_set_name);
13782 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13784 errmsg ("cannot use both params interface name and sw_if_index");
13785 vec_free (locator_set_name);
13789 if (priority_set == 0)
13791 errmsg ("missing locator-set priority");
13792 vec_free (locator_set_name);
13796 if (weight_set == 0)
13798 errmsg ("missing locator-set weight");
13799 vec_free (locator_set_name);
13803 if (vec_len (locator_set_name) > 64)
13805 errmsg ("locator-set name too long");
13806 vec_free (locator_set_name);
13809 vec_add1 (locator_set_name, 0);
13811 /* Construct the API message */
13812 M (ONE_ADD_DEL_LOCATOR, mp);
13814 mp->is_add = is_add;
13815 mp->sw_if_index = ntohl (sw_if_index);
13816 mp->priority = priority;
13817 mp->weight = weight;
13818 clib_memcpy (mp->locator_set_name, locator_set_name,
13819 vec_len (locator_set_name));
13820 vec_free (locator_set_name);
13825 /* Wait for a reply... */
13830 #define api_lisp_add_del_locator api_one_add_del_locator
13833 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13835 u32 *key_id = va_arg (*args, u32 *);
13838 if (unformat (input, "%s", &s))
13840 if (!strcmp ((char *) s, "sha1"))
13841 key_id[0] = HMAC_SHA_1_96;
13842 else if (!strcmp ((char *) s, "sha256"))
13843 key_id[0] = HMAC_SHA_256_128;
13846 clib_warning ("invalid key_id: '%s'", s);
13847 key_id[0] = HMAC_NO_KEY;
13858 api_one_add_del_local_eid (vat_main_t * vam)
13860 unformat_input_t *input = vam->input;
13861 vl_api_one_add_del_local_eid_t *mp;
13864 lisp_eid_vat_t _eid, *eid = &_eid;
13865 u8 *locator_set_name = 0;
13866 u8 locator_set_name_set = 0;
13872 /* Parse args required to build the message */
13873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13875 if (unformat (input, "del"))
13879 else if (unformat (input, "vni %d", &vni))
13883 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13887 else if (unformat (input, "locator-set %s", &locator_set_name))
13889 locator_set_name_set = 1;
13891 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13893 else if (unformat (input, "secret-key %_%v%_", &key))
13899 if (locator_set_name_set == 0)
13901 errmsg ("missing locator-set name");
13907 errmsg ("EID address not set!");
13908 vec_free (locator_set_name);
13912 if (key && (0 == key_id))
13914 errmsg ("invalid key_id!");
13918 if (vec_len (key) > 64)
13920 errmsg ("key too long");
13925 if (vec_len (locator_set_name) > 64)
13927 errmsg ("locator-set name too long");
13928 vec_free (locator_set_name);
13931 vec_add1 (locator_set_name, 0);
13933 /* Construct the API message */
13934 M (ONE_ADD_DEL_LOCAL_EID, mp);
13936 mp->is_add = is_add;
13937 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13938 mp->eid_type = eid->type;
13939 mp->prefix_len = eid->len;
13940 mp->vni = clib_host_to_net_u32 (vni);
13941 mp->key_id = clib_host_to_net_u16 (key_id);
13942 clib_memcpy (mp->locator_set_name, locator_set_name,
13943 vec_len (locator_set_name));
13944 clib_memcpy (mp->key, key, vec_len (key));
13946 vec_free (locator_set_name);
13952 /* Wait for a reply... */
13957 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13960 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13962 u32 dp_table = 0, vni = 0;;
13963 unformat_input_t *input = vam->input;
13964 vl_api_gpe_add_del_fwd_entry_t *mp;
13966 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13967 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13968 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13969 u32 action = ~0, w;
13970 ip4_address_t rmt_rloc4, lcl_rloc4;
13971 ip6_address_t rmt_rloc6, lcl_rloc6;
13972 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13975 memset (&rloc, 0, sizeof (rloc));
13977 /* Parse args required to build the message */
13978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13980 if (unformat (input, "del"))
13982 else if (unformat (input, "add"))
13984 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13988 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13992 else if (unformat (input, "vrf %d", &dp_table))
13994 else if (unformat (input, "bd %d", &dp_table))
13996 else if (unformat (input, "vni %d", &vni))
13998 else if (unformat (input, "w %d", &w))
14002 errmsg ("No RLOC configured for setting priority/weight!");
14005 curr_rloc->weight = w;
14007 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14008 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14012 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14014 vec_add1 (lcl_locs, rloc);
14016 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14017 vec_add1 (rmt_locs, rloc);
14018 /* weight saved in rmt loc */
14019 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14021 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14022 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14025 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14027 vec_add1 (lcl_locs, rloc);
14029 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14030 vec_add1 (rmt_locs, rloc);
14031 /* weight saved in rmt loc */
14032 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14034 else if (unformat (input, "action %d", &action))
14040 clib_warning ("parse error '%U'", format_unformat_error, input);
14047 errmsg ("remote eid addresses not set");
14051 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14053 errmsg ("eid types don't match");
14057 if (0 == rmt_locs && (u32) ~ 0 == action)
14059 errmsg ("action not set for negative mapping");
14063 /* Construct the API message */
14064 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14065 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14067 mp->is_add = is_add;
14068 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
14069 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
14070 mp->eid_type = rmt_eid->type;
14071 mp->dp_table = clib_host_to_net_u32 (dp_table);
14072 mp->vni = clib_host_to_net_u32 (vni);
14073 mp->rmt_len = rmt_eid->len;
14074 mp->lcl_len = lcl_eid->len;
14075 mp->action = action;
14077 if (0 != rmt_locs && 0 != lcl_locs)
14079 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14080 clib_memcpy (mp->locs, lcl_locs,
14081 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14083 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14084 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14085 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14087 vec_free (lcl_locs);
14088 vec_free (rmt_locs);
14093 /* Wait for a reply... */
14099 api_one_add_del_map_server (vat_main_t * vam)
14101 unformat_input_t *input = vam->input;
14102 vl_api_one_add_del_map_server_t *mp;
14106 ip4_address_t ipv4;
14107 ip6_address_t ipv6;
14110 /* Parse args required to build the message */
14111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14113 if (unformat (input, "del"))
14117 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14121 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14129 if (ipv4_set && ipv6_set)
14131 errmsg ("both eid v4 and v6 addresses set");
14135 if (!ipv4_set && !ipv6_set)
14137 errmsg ("eid addresses not set");
14141 /* Construct the API message */
14142 M (ONE_ADD_DEL_MAP_SERVER, mp);
14144 mp->is_add = is_add;
14148 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14153 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14159 /* Wait for a reply... */
14164 #define api_lisp_add_del_map_server api_one_add_del_map_server
14167 api_one_add_del_map_resolver (vat_main_t * vam)
14169 unformat_input_t *input = vam->input;
14170 vl_api_one_add_del_map_resolver_t *mp;
14174 ip4_address_t ipv4;
14175 ip6_address_t ipv6;
14178 /* Parse args required to build the message */
14179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14181 if (unformat (input, "del"))
14185 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14189 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14197 if (ipv4_set && ipv6_set)
14199 errmsg ("both eid v4 and v6 addresses set");
14203 if (!ipv4_set && !ipv6_set)
14205 errmsg ("eid addresses not set");
14209 /* Construct the API message */
14210 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14212 mp->is_add = is_add;
14216 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
14221 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
14227 /* Wait for a reply... */
14232 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14235 api_lisp_gpe_enable_disable (vat_main_t * vam)
14237 unformat_input_t *input = vam->input;
14238 vl_api_gpe_enable_disable_t *mp;
14243 /* Parse args required to build the message */
14244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14246 if (unformat (input, "enable"))
14251 else if (unformat (input, "disable"))
14262 errmsg ("Value not set");
14266 /* Construct the API message */
14267 M (GPE_ENABLE_DISABLE, mp);
14274 /* Wait for a reply... */
14280 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14282 unformat_input_t *input = vam->input;
14283 vl_api_one_rloc_probe_enable_disable_t *mp;
14288 /* Parse args required to build the message */
14289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14291 if (unformat (input, "enable"))
14296 else if (unformat (input, "disable"))
14304 errmsg ("Value not set");
14308 /* Construct the API message */
14309 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14311 mp->is_enabled = is_en;
14316 /* Wait for a reply... */
14321 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14324 api_one_map_register_enable_disable (vat_main_t * vam)
14326 unformat_input_t *input = vam->input;
14327 vl_api_one_map_register_enable_disable_t *mp;
14332 /* Parse args required to build the message */
14333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14335 if (unformat (input, "enable"))
14340 else if (unformat (input, "disable"))
14348 errmsg ("Value not set");
14352 /* Construct the API message */
14353 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14355 mp->is_enabled = is_en;
14360 /* Wait for a reply... */
14365 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14368 api_one_enable_disable (vat_main_t * vam)
14370 unformat_input_t *input = vam->input;
14371 vl_api_one_enable_disable_t *mp;
14376 /* Parse args required to build the message */
14377 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14379 if (unformat (input, "enable"))
14384 else if (unformat (input, "disable"))
14394 errmsg ("Value not set");
14398 /* Construct the API message */
14399 M (ONE_ENABLE_DISABLE, mp);
14406 /* Wait for a reply... */
14411 #define api_lisp_enable_disable api_one_enable_disable
14414 api_show_one_map_register_state (vat_main_t * vam)
14416 vl_api_show_one_map_register_state_t *mp;
14419 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14424 /* wait for reply */
14429 #define api_show_lisp_map_register_state api_show_one_map_register_state
14432 api_show_one_rloc_probe_state (vat_main_t * vam)
14434 vl_api_show_one_rloc_probe_state_t *mp;
14437 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14442 /* wait for reply */
14447 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14450 api_show_one_map_request_mode (vat_main_t * vam)
14452 vl_api_show_one_map_request_mode_t *mp;
14455 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14460 /* wait for reply */
14465 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14468 api_one_map_request_mode (vat_main_t * vam)
14470 unformat_input_t *input = vam->input;
14471 vl_api_one_map_request_mode_t *mp;
14475 /* Parse args required to build the message */
14476 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14478 if (unformat (input, "dst-only"))
14480 else if (unformat (input, "src-dst"))
14484 errmsg ("parse error '%U'", format_unformat_error, input);
14489 M (ONE_MAP_REQUEST_MODE, mp);
14496 /* wait for reply */
14501 #define api_lisp_map_request_mode api_one_map_request_mode
14504 * Enable/disable ONE proxy ITR.
14506 * @param vam vpp API test context
14507 * @return return code
14510 api_one_pitr_set_locator_set (vat_main_t * vam)
14512 u8 ls_name_set = 0;
14513 unformat_input_t *input = vam->input;
14514 vl_api_one_pitr_set_locator_set_t *mp;
14519 /* Parse args required to build the message */
14520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14522 if (unformat (input, "del"))
14524 else if (unformat (input, "locator-set %s", &ls_name))
14528 errmsg ("parse error '%U'", format_unformat_error, input);
14535 errmsg ("locator-set name not set!");
14539 M (ONE_PITR_SET_LOCATOR_SET, mp);
14541 mp->is_add = is_add;
14542 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14543 vec_free (ls_name);
14548 /* wait for reply */
14553 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14556 api_show_one_pitr (vat_main_t * vam)
14558 vl_api_show_one_pitr_t *mp;
14561 if (!vam->json_output)
14563 print (vam->ofp, "%=20s", "lisp status:");
14566 M (SHOW_ONE_PITR, mp);
14570 /* Wait for a reply... */
14575 #define api_show_lisp_pitr api_show_one_pitr
14578 * Add/delete mapping between vni and vrf
14581 api_one_eid_table_add_del_map (vat_main_t * vam)
14583 unformat_input_t *input = vam->input;
14584 vl_api_one_eid_table_add_del_map_t *mp;
14585 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14586 u32 vni, vrf, bd_index;
14589 /* Parse args required to build the message */
14590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14592 if (unformat (input, "del"))
14594 else if (unformat (input, "vrf %d", &vrf))
14596 else if (unformat (input, "bd_index %d", &bd_index))
14598 else if (unformat (input, "vni %d", &vni))
14604 if (!vni_set || (!vrf_set && !bd_index_set))
14606 errmsg ("missing arguments!");
14610 if (vrf_set && bd_index_set)
14612 errmsg ("error: both vrf and bd entered!");
14616 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14618 mp->is_add = is_add;
14619 mp->vni = htonl (vni);
14620 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14621 mp->is_l2 = bd_index_set;
14626 /* wait for reply */
14631 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14634 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14636 u32 *action = va_arg (*args, u32 *);
14639 if (unformat (input, "%s", &s))
14641 if (!strcmp ((char *) s, "no-action"))
14643 else if (!strcmp ((char *) s, "natively-forward"))
14645 else if (!strcmp ((char *) s, "send-map-request"))
14647 else if (!strcmp ((char *) s, "drop"))
14651 clib_warning ("invalid action: '%s'", s);
14663 * Add/del remote mapping to/from ONE control plane
14665 * @param vam vpp API test context
14666 * @return return code
14669 api_one_add_del_remote_mapping (vat_main_t * vam)
14671 unformat_input_t *input = vam->input;
14672 vl_api_one_add_del_remote_mapping_t *mp;
14674 lisp_eid_vat_t _eid, *eid = &_eid;
14675 lisp_eid_vat_t _seid, *seid = &_seid;
14676 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14677 u32 action = ~0, p, w, data_len;
14678 ip4_address_t rloc4;
14679 ip6_address_t rloc6;
14680 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14683 memset (&rloc, 0, sizeof (rloc));
14685 /* Parse args required to build the message */
14686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14688 if (unformat (input, "del-all"))
14692 else if (unformat (input, "del"))
14696 else if (unformat (input, "add"))
14700 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14704 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14708 else if (unformat (input, "vni %d", &vni))
14712 else if (unformat (input, "p %d w %d", &p, &w))
14716 errmsg ("No RLOC configured for setting priority/weight!");
14719 curr_rloc->priority = p;
14720 curr_rloc->weight = w;
14722 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14725 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14726 vec_add1 (rlocs, rloc);
14727 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14729 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14732 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14733 vec_add1 (rlocs, rloc);
14734 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14736 else if (unformat (input, "action %U",
14737 unformat_negative_mapping_action, &action))
14743 clib_warning ("parse error '%U'", format_unformat_error, input);
14750 errmsg ("missing params!");
14754 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14756 errmsg ("no action set for negative map-reply!");
14760 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14762 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14763 mp->is_add = is_add;
14764 mp->vni = htonl (vni);
14765 mp->action = (u8) action;
14766 mp->is_src_dst = seid_set;
14767 mp->eid_len = eid->len;
14768 mp->seid_len = seid->len;
14769 mp->del_all = del_all;
14770 mp->eid_type = eid->type;
14771 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14772 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14774 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14775 clib_memcpy (mp->rlocs, rlocs, data_len);
14781 /* Wait for a reply... */
14786 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14789 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14790 * forwarding entries in data-plane accordingly.
14792 * @param vam vpp API test context
14793 * @return return code
14796 api_one_add_del_adjacency (vat_main_t * vam)
14798 unformat_input_t *input = vam->input;
14799 vl_api_one_add_del_adjacency_t *mp;
14801 ip4_address_t leid4, reid4;
14802 ip6_address_t leid6, reid6;
14803 u8 reid_mac[6] = { 0 };
14804 u8 leid_mac[6] = { 0 };
14805 u8 reid_type, leid_type;
14806 u32 leid_len = 0, reid_len = 0, len;
14810 leid_type = reid_type = (u8) ~ 0;
14812 /* Parse args required to build the message */
14813 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14815 if (unformat (input, "del"))
14819 else if (unformat (input, "add"))
14823 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14826 reid_type = 0; /* ipv4 */
14829 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14832 reid_type = 1; /* ipv6 */
14835 else if (unformat (input, "reid %U", unformat_ethernet_address,
14838 reid_type = 2; /* mac */
14840 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14843 leid_type = 0; /* ipv4 */
14846 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14849 leid_type = 1; /* ipv6 */
14852 else if (unformat (input, "leid %U", unformat_ethernet_address,
14855 leid_type = 2; /* mac */
14857 else if (unformat (input, "vni %d", &vni))
14863 errmsg ("parse error '%U'", format_unformat_error, input);
14868 if ((u8) ~ 0 == reid_type)
14870 errmsg ("missing params!");
14874 if (leid_type != reid_type)
14876 errmsg ("remote and local EIDs are of different types!");
14880 M (ONE_ADD_DEL_ADJACENCY, mp);
14881 mp->is_add = is_add;
14882 mp->vni = htonl (vni);
14883 mp->leid_len = leid_len;
14884 mp->reid_len = reid_len;
14885 mp->eid_type = reid_type;
14887 switch (mp->eid_type)
14890 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14891 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14894 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14895 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14898 clib_memcpy (mp->leid, leid_mac, 6);
14899 clib_memcpy (mp->reid, reid_mac, 6);
14902 errmsg ("unknown EID type %d!", mp->eid_type);
14909 /* Wait for a reply... */
14914 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14917 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14919 u32 *mode = va_arg (*args, u32 *);
14921 if (unformat (input, "lisp"))
14923 else if (unformat (input, "vxlan"))
14932 api_gpe_get_encap_mode (vat_main_t * vam)
14934 vl_api_gpe_get_encap_mode_t *mp;
14937 /* Construct the API message */
14938 M (GPE_GET_ENCAP_MODE, mp);
14943 /* Wait for a reply... */
14949 api_gpe_set_encap_mode (vat_main_t * vam)
14951 unformat_input_t *input = vam->input;
14952 vl_api_gpe_set_encap_mode_t *mp;
14956 /* Parse args required to build the message */
14957 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14959 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14965 /* Construct the API message */
14966 M (GPE_SET_ENCAP_MODE, mp);
14973 /* Wait for a reply... */
14979 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14981 unformat_input_t *input = vam->input;
14982 vl_api_gpe_add_del_iface_t *mp;
14983 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14984 u32 dp_table = 0, vni = 0;
14987 /* Parse args required to build the message */
14988 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14990 if (unformat (input, "up"))
14995 else if (unformat (input, "down"))
15000 else if (unformat (input, "table_id %d", &dp_table))
15004 else if (unformat (input, "bd_id %d", &dp_table))
15009 else if (unformat (input, "vni %d", &vni))
15017 if (action_set == 0)
15019 errmsg ("Action not set");
15022 if (dp_table_set == 0 || vni_set == 0)
15024 errmsg ("vni and dp_table must be set");
15028 /* Construct the API message */
15029 M (GPE_ADD_DEL_IFACE, mp);
15031 mp->is_add = is_add;
15032 mp->dp_table = dp_table;
15039 /* Wait for a reply... */
15045 * Add/del map request itr rlocs from ONE control plane and updates
15047 * @param vam vpp API test context
15048 * @return return code
15051 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
15053 unformat_input_t *input = vam->input;
15054 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
15055 u8 *locator_set_name = 0;
15056 u8 locator_set_name_set = 0;
15060 /* Parse args required to build the message */
15061 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15063 if (unformat (input, "del"))
15067 else if (unformat (input, "%_%v%_", &locator_set_name))
15069 locator_set_name_set = 1;
15073 clib_warning ("parse error '%U'", format_unformat_error, input);
15078 if (is_add && !locator_set_name_set)
15080 errmsg ("itr-rloc is not set!");
15084 if (is_add && vec_len (locator_set_name) > 64)
15086 errmsg ("itr-rloc locator-set name too long");
15087 vec_free (locator_set_name);
15091 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
15092 mp->is_add = is_add;
15095 clib_memcpy (mp->locator_set_name, locator_set_name,
15096 vec_len (locator_set_name));
15100 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
15102 vec_free (locator_set_name);
15107 /* Wait for a reply... */
15112 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
15115 api_one_locator_dump (vat_main_t * vam)
15117 unformat_input_t *input = vam->input;
15118 vl_api_one_locator_dump_t *mp;
15119 vl_api_control_ping_t *mp_ping;
15120 u8 is_index_set = 0, is_name_set = 0;
15125 /* Parse args required to build the message */
15126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15128 if (unformat (input, "ls_name %_%v%_", &ls_name))
15132 else if (unformat (input, "ls_index %d", &ls_index))
15138 errmsg ("parse error '%U'", format_unformat_error, input);
15143 if (!is_index_set && !is_name_set)
15145 errmsg ("error: expected one of index or name!");
15149 if (is_index_set && is_name_set)
15151 errmsg ("error: only one param expected!");
15155 if (vec_len (ls_name) > 62)
15157 errmsg ("error: locator set name too long!");
15161 if (!vam->json_output)
15163 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
15166 M (ONE_LOCATOR_DUMP, mp);
15167 mp->is_index_set = is_index_set;
15170 mp->ls_index = clib_host_to_net_u32 (ls_index);
15173 vec_add1 (ls_name, 0);
15174 strncpy ((char *) mp->ls_name, (char *) ls_name,
15175 sizeof (mp->ls_name) - 1);
15181 /* Use a control ping for synchronization */
15182 M (CONTROL_PING, mp_ping);
15185 /* Wait for a reply... */
15190 #define api_lisp_locator_dump api_one_locator_dump
15193 api_one_locator_set_dump (vat_main_t * vam)
15195 vl_api_one_locator_set_dump_t *mp;
15196 vl_api_control_ping_t *mp_ping;
15197 unformat_input_t *input = vam->input;
15201 /* Parse args required to build the message */
15202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15204 if (unformat (input, "local"))
15208 else if (unformat (input, "remote"))
15214 errmsg ("parse error '%U'", format_unformat_error, input);
15219 if (!vam->json_output)
15221 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
15224 M (ONE_LOCATOR_SET_DUMP, mp);
15226 mp->filter = filter;
15231 /* Use a control ping for synchronization */
15232 M (CONTROL_PING, mp_ping);
15235 /* Wait for a reply... */
15240 #define api_lisp_locator_set_dump api_one_locator_set_dump
15243 api_one_eid_table_map_dump (vat_main_t * vam)
15247 unformat_input_t *input = vam->input;
15248 vl_api_one_eid_table_map_dump_t *mp;
15249 vl_api_control_ping_t *mp_ping;
15252 /* Parse args required to build the message */
15253 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15255 if (unformat (input, "l2"))
15260 else if (unformat (input, "l3"))
15267 errmsg ("parse error '%U'", format_unformat_error, input);
15274 errmsg ("expected one of 'l2' or 'l3' parameter!");
15278 if (!vam->json_output)
15280 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15283 M (ONE_EID_TABLE_MAP_DUMP, mp);
15289 /* Use a control ping for synchronization */
15290 M (CONTROL_PING, mp_ping);
15293 /* Wait for a reply... */
15298 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15301 api_one_eid_table_vni_dump (vat_main_t * vam)
15303 vl_api_one_eid_table_vni_dump_t *mp;
15304 vl_api_control_ping_t *mp_ping;
15307 if (!vam->json_output)
15309 print (vam->ofp, "VNI");
15312 M (ONE_EID_TABLE_VNI_DUMP, mp);
15317 /* Use a control ping for synchronization */
15318 M (CONTROL_PING, mp_ping);
15321 /* Wait for a reply... */
15326 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15329 api_one_eid_table_dump (vat_main_t * vam)
15331 unformat_input_t *i = vam->input;
15332 vl_api_one_eid_table_dump_t *mp;
15333 vl_api_control_ping_t *mp_ping;
15334 struct in_addr ip4;
15335 struct in6_addr ip6;
15337 u8 eid_type = ~0, eid_set = 0;
15338 u32 prefix_length = ~0, t, vni = 0;
15342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15344 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15350 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15356 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15361 else if (unformat (i, "vni %d", &t))
15365 else if (unformat (i, "local"))
15369 else if (unformat (i, "remote"))
15375 errmsg ("parse error '%U'", format_unformat_error, i);
15380 if (!vam->json_output)
15382 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15383 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15386 M (ONE_EID_TABLE_DUMP, mp);
15388 mp->filter = filter;
15392 mp->vni = htonl (vni);
15393 mp->eid_type = eid_type;
15397 mp->prefix_length = prefix_length;
15398 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15401 mp->prefix_length = prefix_length;
15402 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15405 clib_memcpy (mp->eid, mac, sizeof (mac));
15408 errmsg ("unknown EID type %d!", eid_type);
15416 /* Use a control ping for synchronization */
15417 M (CONTROL_PING, mp_ping);
15420 /* Wait for a reply... */
15425 #define api_lisp_eid_table_dump api_one_eid_table_dump
15428 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15430 unformat_input_t *i = vam->input;
15431 vl_api_gpe_fwd_entries_get_t *mp;
15436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15438 if (unformat (i, "vni %d", &vni))
15444 errmsg ("parse error '%U'", format_unformat_error, i);
15451 errmsg ("vni not set!");
15455 if (!vam->json_output)
15457 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15461 M (GPE_FWD_ENTRIES_GET, mp);
15462 mp->vni = clib_host_to_net_u32 (vni);
15467 /* Wait for a reply... */
15472 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15473 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15474 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15475 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15478 api_one_adjacencies_get (vat_main_t * vam)
15480 unformat_input_t *i = vam->input;
15481 vl_api_one_adjacencies_get_t *mp;
15486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15488 if (unformat (i, "vni %d", &vni))
15494 errmsg ("parse error '%U'", format_unformat_error, i);
15501 errmsg ("vni not set!");
15505 if (!vam->json_output)
15507 print (vam->ofp, "%s %40s", "leid", "reid");
15510 M (ONE_ADJACENCIES_GET, mp);
15511 mp->vni = clib_host_to_net_u32 (vni);
15516 /* Wait for a reply... */
15521 #define api_lisp_adjacencies_get api_one_adjacencies_get
15524 api_one_map_server_dump (vat_main_t * vam)
15526 vl_api_one_map_server_dump_t *mp;
15527 vl_api_control_ping_t *mp_ping;
15530 if (!vam->json_output)
15532 print (vam->ofp, "%=20s", "Map server");
15535 M (ONE_MAP_SERVER_DUMP, mp);
15539 /* Use a control ping for synchronization */
15540 M (CONTROL_PING, mp_ping);
15543 /* Wait for a reply... */
15548 #define api_lisp_map_server_dump api_one_map_server_dump
15551 api_one_map_resolver_dump (vat_main_t * vam)
15553 vl_api_one_map_resolver_dump_t *mp;
15554 vl_api_control_ping_t *mp_ping;
15557 if (!vam->json_output)
15559 print (vam->ofp, "%=20s", "Map resolver");
15562 M (ONE_MAP_RESOLVER_DUMP, mp);
15566 /* Use a control ping for synchronization */
15567 M (CONTROL_PING, mp_ping);
15570 /* Wait for a reply... */
15575 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15578 api_show_one_status (vat_main_t * vam)
15580 vl_api_show_one_status_t *mp;
15583 if (!vam->json_output)
15585 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15588 M (SHOW_ONE_STATUS, mp);
15591 /* Wait for a reply... */
15596 #define api_show_lisp_status api_show_one_status
15599 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15601 vl_api_gpe_fwd_entry_path_dump_t *mp;
15602 vl_api_control_ping_t *mp_ping;
15603 unformat_input_t *i = vam->input;
15604 u32 fwd_entry_index = ~0;
15607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15609 if (unformat (i, "index %d", &fwd_entry_index))
15615 if (~0 == fwd_entry_index)
15617 errmsg ("no index specified!");
15621 if (!vam->json_output)
15623 print (vam->ofp, "first line");
15626 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15630 /* Use a control ping for synchronization */
15631 M (CONTROL_PING, mp_ping);
15634 /* Wait for a reply... */
15640 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15642 vl_api_one_get_map_request_itr_rlocs_t *mp;
15645 if (!vam->json_output)
15647 print (vam->ofp, "%=20s", "itr-rlocs:");
15650 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15653 /* Wait for a reply... */
15658 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15661 api_af_packet_create (vat_main_t * vam)
15663 unformat_input_t *i = vam->input;
15664 vl_api_af_packet_create_t *mp;
15665 u8 *host_if_name = 0;
15667 u8 random_hw_addr = 1;
15670 memset (hw_addr, 0, sizeof (hw_addr));
15672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15674 if (unformat (i, "name %s", &host_if_name))
15675 vec_add1 (host_if_name, 0);
15676 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15677 random_hw_addr = 0;
15682 if (!vec_len (host_if_name))
15684 errmsg ("host-interface name must be specified");
15688 if (vec_len (host_if_name) > 64)
15690 errmsg ("host-interface name too long");
15694 M (AF_PACKET_CREATE, mp);
15696 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15697 clib_memcpy (mp->hw_addr, hw_addr, 6);
15698 mp->use_random_hw_addr = random_hw_addr;
15699 vec_free (host_if_name);
15702 W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15707 api_af_packet_delete (vat_main_t * vam)
15709 unformat_input_t *i = vam->input;
15710 vl_api_af_packet_delete_t *mp;
15711 u8 *host_if_name = 0;
15714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15716 if (unformat (i, "name %s", &host_if_name))
15717 vec_add1 (host_if_name, 0);
15722 if (!vec_len (host_if_name))
15724 errmsg ("host-interface name must be specified");
15728 if (vec_len (host_if_name) > 64)
15730 errmsg ("host-interface name too long");
15734 M (AF_PACKET_DELETE, mp);
15736 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15737 vec_free (host_if_name);
15745 api_policer_add_del (vat_main_t * vam)
15747 unformat_input_t *i = vam->input;
15748 vl_api_policer_add_del_t *mp;
15758 u8 color_aware = 0;
15759 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15762 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15763 conform_action.dscp = 0;
15764 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15765 exceed_action.dscp = 0;
15766 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15767 violate_action.dscp = 0;
15769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15771 if (unformat (i, "del"))
15773 else if (unformat (i, "name %s", &name))
15774 vec_add1 (name, 0);
15775 else if (unformat (i, "cir %u", &cir))
15777 else if (unformat (i, "eir %u", &eir))
15779 else if (unformat (i, "cb %u", &cb))
15781 else if (unformat (i, "eb %u", &eb))
15783 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15786 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15789 else if (unformat (i, "type %U", unformat_policer_type, &type))
15791 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15794 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15797 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15800 else if (unformat (i, "color-aware"))
15806 if (!vec_len (name))
15808 errmsg ("policer name must be specified");
15812 if (vec_len (name) > 64)
15814 errmsg ("policer name too long");
15818 M (POLICER_ADD_DEL, mp);
15820 clib_memcpy (mp->name, name, vec_len (name));
15822 mp->is_add = is_add;
15827 mp->rate_type = rate_type;
15828 mp->round_type = round_type;
15830 mp->conform_action_type = conform_action.action_type;
15831 mp->conform_dscp = conform_action.dscp;
15832 mp->exceed_action_type = exceed_action.action_type;
15833 mp->exceed_dscp = exceed_action.dscp;
15834 mp->violate_action_type = violate_action.action_type;
15835 mp->violate_dscp = violate_action.dscp;
15836 mp->color_aware = color_aware;
15844 api_policer_dump (vat_main_t * vam)
15846 unformat_input_t *i = vam->input;
15847 vl_api_policer_dump_t *mp;
15848 vl_api_control_ping_t *mp_ping;
15849 u8 *match_name = 0;
15850 u8 match_name_valid = 0;
15853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15855 if (unformat (i, "name %s", &match_name))
15857 vec_add1 (match_name, 0);
15858 match_name_valid = 1;
15864 M (POLICER_DUMP, mp);
15865 mp->match_name_valid = match_name_valid;
15866 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15867 vec_free (match_name);
15871 /* Use a control ping for synchronization */
15872 M (CONTROL_PING, mp_ping);
15875 /* Wait for a reply... */
15881 api_policer_classify_set_interface (vat_main_t * vam)
15883 unformat_input_t *i = vam->input;
15884 vl_api_policer_classify_set_interface_t *mp;
15886 int sw_if_index_set;
15887 u32 ip4_table_index = ~0;
15888 u32 ip6_table_index = ~0;
15889 u32 l2_table_index = ~0;
15893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15896 sw_if_index_set = 1;
15897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15898 sw_if_index_set = 1;
15899 else if (unformat (i, "del"))
15901 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15903 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15905 else if (unformat (i, "l2-table %d", &l2_table_index))
15909 clib_warning ("parse error '%U'", format_unformat_error, i);
15914 if (sw_if_index_set == 0)
15916 errmsg ("missing interface name or sw_if_index");
15920 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15922 mp->sw_if_index = ntohl (sw_if_index);
15923 mp->ip4_table_index = ntohl (ip4_table_index);
15924 mp->ip6_table_index = ntohl (ip6_table_index);
15925 mp->l2_table_index = ntohl (l2_table_index);
15926 mp->is_add = is_add;
15934 api_policer_classify_dump (vat_main_t * vam)
15936 unformat_input_t *i = vam->input;
15937 vl_api_policer_classify_dump_t *mp;
15938 vl_api_control_ping_t *mp_ping;
15939 u8 type = POLICER_CLASSIFY_N_TABLES;
15942 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15946 errmsg ("classify table type must be specified");
15950 if (!vam->json_output)
15952 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15955 M (POLICER_CLASSIFY_DUMP, mp);
15960 /* Use a control ping for synchronization */
15961 M (CONTROL_PING, mp_ping);
15964 /* Wait for a reply... */
15970 api_netmap_create (vat_main_t * vam)
15972 unformat_input_t *i = vam->input;
15973 vl_api_netmap_create_t *mp;
15976 u8 random_hw_addr = 1;
15981 memset (hw_addr, 0, sizeof (hw_addr));
15983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15985 if (unformat (i, "name %s", &if_name))
15986 vec_add1 (if_name, 0);
15987 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15988 random_hw_addr = 0;
15989 else if (unformat (i, "pipe"))
15991 else if (unformat (i, "master"))
15993 else if (unformat (i, "slave"))
15999 if (!vec_len (if_name))
16001 errmsg ("interface name must be specified");
16005 if (vec_len (if_name) > 64)
16007 errmsg ("interface name too long");
16011 M (NETMAP_CREATE, mp);
16013 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16014 clib_memcpy (mp->hw_addr, hw_addr, 6);
16015 mp->use_random_hw_addr = random_hw_addr;
16016 mp->is_pipe = is_pipe;
16017 mp->is_master = is_master;
16018 vec_free (if_name);
16026 api_netmap_delete (vat_main_t * vam)
16028 unformat_input_t *i = vam->input;
16029 vl_api_netmap_delete_t *mp;
16033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16035 if (unformat (i, "name %s", &if_name))
16036 vec_add1 (if_name, 0);
16041 if (!vec_len (if_name))
16043 errmsg ("interface name must be specified");
16047 if (vec_len (if_name) > 64)
16049 errmsg ("interface name too long");
16053 M (NETMAP_DELETE, mp);
16055 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
16056 vec_free (if_name);
16063 static void vl_api_mpls_tunnel_details_t_handler
16064 (vl_api_mpls_tunnel_details_t * mp)
16066 vat_main_t *vam = &vat_main;
16067 i32 len = mp->mt_next_hop_n_labels;
16070 print (vam->ofp, "[%d]: via %U %d labels ",
16072 format_ip4_address, mp->mt_next_hop,
16073 ntohl (mp->mt_next_hop_sw_if_index));
16074 for (i = 0; i < len; i++)
16076 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
16078 print (vam->ofp, "");
16081 static void vl_api_mpls_tunnel_details_t_handler_json
16082 (vl_api_mpls_tunnel_details_t * mp)
16084 vat_main_t *vam = &vat_main;
16085 vat_json_node_t *node = NULL;
16086 struct in_addr ip4;
16088 i32 len = mp->mt_next_hop_n_labels;
16090 if (VAT_JSON_ARRAY != vam->json_tree.type)
16092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16093 vat_json_init_array (&vam->json_tree);
16095 node = vat_json_array_add (&vam->json_tree);
16097 vat_json_init_object (node);
16098 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
16099 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
16100 vat_json_object_add_ip4 (node, "next_hop", ip4);
16101 vat_json_object_add_uint (node, "next_hop_sw_if_index",
16102 ntohl (mp->mt_next_hop_sw_if_index));
16103 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
16104 vat_json_object_add_uint (node, "label_count", len);
16105 for (i = 0; i < len; i++)
16107 vat_json_object_add_uint (node, "label",
16108 ntohl (mp->mt_next_hop_out_labels[i]));
16113 api_mpls_tunnel_dump (vat_main_t * vam)
16115 vl_api_mpls_tunnel_dump_t *mp;
16116 vl_api_control_ping_t *mp_ping;
16120 /* Parse args required to build the message */
16121 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
16123 if (!unformat (vam->input, "tunnel_index %d", &index))
16130 print (vam->ofp, " tunnel_index %d", index);
16132 M (MPLS_TUNNEL_DUMP, mp);
16133 mp->tunnel_index = htonl (index);
16136 /* Use a control ping for synchronization */
16137 M (CONTROL_PING, mp_ping);
16144 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
16145 #define vl_api_mpls_fib_details_t_print vl_noop_handler
16148 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
16150 vat_main_t *vam = &vat_main;
16151 int count = ntohl (mp->count);
16152 vl_api_fib_path2_t *fp;
16156 "table-id %d, label %u, ess_bit %u",
16157 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
16159 for (i = 0; i < count; i++)
16161 if (fp->afi == IP46_TYPE_IP6)
16163 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16164 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16165 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16166 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16167 format_ip6_address, fp->next_hop);
16168 else if (fp->afi == IP46_TYPE_IP4)
16170 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16171 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16172 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16173 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16174 format_ip4_address, fp->next_hop);
16179 static void vl_api_mpls_fib_details_t_handler_json
16180 (vl_api_mpls_fib_details_t * mp)
16182 vat_main_t *vam = &vat_main;
16183 int count = ntohl (mp->count);
16184 vat_json_node_t *node = NULL;
16185 struct in_addr ip4;
16186 struct in6_addr ip6;
16187 vl_api_fib_path2_t *fp;
16190 if (VAT_JSON_ARRAY != vam->json_tree.type)
16192 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16193 vat_json_init_array (&vam->json_tree);
16195 node = vat_json_array_add (&vam->json_tree);
16197 vat_json_init_object (node);
16198 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16199 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
16200 vat_json_object_add_uint (node, "label", ntohl (mp->label));
16201 vat_json_object_add_uint (node, "path_count", count);
16203 for (i = 0; i < count; i++)
16205 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16206 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16207 vat_json_object_add_uint (node, "is_local", fp->is_local);
16208 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16209 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16210 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16211 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16212 if (fp->afi == IP46_TYPE_IP4)
16214 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16215 vat_json_object_add_ip4 (node, "next_hop", ip4);
16217 else if (fp->afi == IP46_TYPE_IP6)
16219 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16220 vat_json_object_add_ip6 (node, "next_hop", ip6);
16226 api_mpls_fib_dump (vat_main_t * vam)
16228 vl_api_mpls_fib_dump_t *mp;
16229 vl_api_control_ping_t *mp_ping;
16232 M (MPLS_FIB_DUMP, mp);
16235 /* Use a control ping for synchronization */
16236 M (CONTROL_PING, mp_ping);
16243 #define vl_api_ip_fib_details_t_endian vl_noop_handler
16244 #define vl_api_ip_fib_details_t_print vl_noop_handler
16247 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
16249 vat_main_t *vam = &vat_main;
16250 int count = ntohl (mp->count);
16251 vl_api_fib_path_t *fp;
16255 "table-id %d, prefix %U/%d",
16256 ntohl (mp->table_id), format_ip4_address, mp->address,
16257 mp->address_length);
16259 for (i = 0; i < count; i++)
16261 if (fp->afi == IP46_TYPE_IP6)
16263 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16264 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16265 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16266 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16267 format_ip6_address, fp->next_hop);
16268 else if (fp->afi == IP46_TYPE_IP4)
16270 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16271 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16272 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16273 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16274 format_ip4_address, fp->next_hop);
16279 static void vl_api_ip_fib_details_t_handler_json
16280 (vl_api_ip_fib_details_t * mp)
16282 vat_main_t *vam = &vat_main;
16283 int count = ntohl (mp->count);
16284 vat_json_node_t *node = NULL;
16285 struct in_addr ip4;
16286 struct in6_addr ip6;
16287 vl_api_fib_path_t *fp;
16290 if (VAT_JSON_ARRAY != vam->json_tree.type)
16292 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16293 vat_json_init_array (&vam->json_tree);
16295 node = vat_json_array_add (&vam->json_tree);
16297 vat_json_init_object (node);
16298 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16299 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16300 vat_json_object_add_ip4 (node, "prefix", ip4);
16301 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16302 vat_json_object_add_uint (node, "path_count", count);
16304 for (i = 0; i < count; i++)
16306 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16307 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16308 vat_json_object_add_uint (node, "is_local", fp->is_local);
16309 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16310 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16311 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16312 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16313 if (fp->afi == IP46_TYPE_IP4)
16315 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16316 vat_json_object_add_ip4 (node, "next_hop", ip4);
16318 else if (fp->afi == IP46_TYPE_IP6)
16320 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16321 vat_json_object_add_ip6 (node, "next_hop", ip6);
16327 api_ip_fib_dump (vat_main_t * vam)
16329 vl_api_ip_fib_dump_t *mp;
16330 vl_api_control_ping_t *mp_ping;
16333 M (IP_FIB_DUMP, mp);
16336 /* Use a control ping for synchronization */
16337 M (CONTROL_PING, mp_ping);
16345 api_ip_mfib_dump (vat_main_t * vam)
16347 vl_api_ip_mfib_dump_t *mp;
16348 vl_api_control_ping_t *mp_ping;
16351 M (IP_MFIB_DUMP, mp);
16354 /* Use a control ping for synchronization */
16355 M (CONTROL_PING, mp_ping);
16362 static void vl_api_ip_neighbor_details_t_handler
16363 (vl_api_ip_neighbor_details_t * mp)
16365 vat_main_t *vam = &vat_main;
16367 print (vam->ofp, "%c %U %U",
16368 (mp->is_static) ? 'S' : 'D',
16369 format_ethernet_address, &mp->mac_address,
16370 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16374 static void vl_api_ip_neighbor_details_t_handler_json
16375 (vl_api_ip_neighbor_details_t * mp)
16378 vat_main_t *vam = &vat_main;
16379 vat_json_node_t *node;
16380 struct in_addr ip4;
16381 struct in6_addr ip6;
16383 if (VAT_JSON_ARRAY != vam->json_tree.type)
16385 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16386 vat_json_init_array (&vam->json_tree);
16388 node = vat_json_array_add (&vam->json_tree);
16390 vat_json_init_object (node);
16391 vat_json_object_add_string_copy (node, "flag",
16392 (mp->is_static) ? (u8 *) "static" : (u8 *)
16395 vat_json_object_add_string_copy (node, "link_layer",
16396 format (0, "%U", format_ethernet_address,
16397 &mp->mac_address));
16401 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16402 vat_json_object_add_ip6 (node, "ip_address", ip6);
16406 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16407 vat_json_object_add_ip4 (node, "ip_address", ip4);
16412 api_ip_neighbor_dump (vat_main_t * vam)
16414 unformat_input_t *i = vam->input;
16415 vl_api_ip_neighbor_dump_t *mp;
16416 vl_api_control_ping_t *mp_ping;
16418 u32 sw_if_index = ~0;
16421 /* Parse args required to build the message */
16422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16428 else if (unformat (i, "ip6"))
16434 if (sw_if_index == ~0)
16436 errmsg ("missing interface name or sw_if_index");
16440 M (IP_NEIGHBOR_DUMP, mp);
16441 mp->is_ipv6 = (u8) is_ipv6;
16442 mp->sw_if_index = ntohl (sw_if_index);
16445 /* Use a control ping for synchronization */
16446 M (CONTROL_PING, mp_ping);
16453 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16454 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16457 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16459 vat_main_t *vam = &vat_main;
16460 int count = ntohl (mp->count);
16461 vl_api_fib_path_t *fp;
16465 "table-id %d, prefix %U/%d",
16466 ntohl (mp->table_id), format_ip6_address, mp->address,
16467 mp->address_length);
16469 for (i = 0; i < count; i++)
16471 if (fp->afi == IP46_TYPE_IP6)
16473 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16474 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16475 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16476 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16477 format_ip6_address, fp->next_hop);
16478 else if (fp->afi == IP46_TYPE_IP4)
16480 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16481 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16482 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16483 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16484 format_ip4_address, fp->next_hop);
16489 static void vl_api_ip6_fib_details_t_handler_json
16490 (vl_api_ip6_fib_details_t * mp)
16492 vat_main_t *vam = &vat_main;
16493 int count = ntohl (mp->count);
16494 vat_json_node_t *node = NULL;
16495 struct in_addr ip4;
16496 struct in6_addr ip6;
16497 vl_api_fib_path_t *fp;
16500 if (VAT_JSON_ARRAY != vam->json_tree.type)
16502 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16503 vat_json_init_array (&vam->json_tree);
16505 node = vat_json_array_add (&vam->json_tree);
16507 vat_json_init_object (node);
16508 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16509 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16510 vat_json_object_add_ip6 (node, "prefix", ip6);
16511 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16512 vat_json_object_add_uint (node, "path_count", count);
16514 for (i = 0; i < count; i++)
16516 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16517 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16518 vat_json_object_add_uint (node, "is_local", fp->is_local);
16519 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16520 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16521 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16522 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16523 if (fp->afi == IP46_TYPE_IP4)
16525 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16526 vat_json_object_add_ip4 (node, "next_hop", ip4);
16528 else if (fp->afi == IP46_TYPE_IP6)
16530 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16531 vat_json_object_add_ip6 (node, "next_hop", ip6);
16537 api_ip6_fib_dump (vat_main_t * vam)
16539 vl_api_ip6_fib_dump_t *mp;
16540 vl_api_control_ping_t *mp_ping;
16543 M (IP6_FIB_DUMP, mp);
16546 /* Use a control ping for synchronization */
16547 M (CONTROL_PING, mp_ping);
16555 api_ip6_mfib_dump (vat_main_t * vam)
16557 vl_api_ip6_mfib_dump_t *mp;
16558 vl_api_control_ping_t *mp_ping;
16561 M (IP6_MFIB_DUMP, mp);
16564 /* Use a control ping for synchronization */
16565 M (CONTROL_PING, mp_ping);
16573 api_classify_table_ids (vat_main_t * vam)
16575 vl_api_classify_table_ids_t *mp;
16578 /* Construct the API message */
16579 M (CLASSIFY_TABLE_IDS, mp);
16588 api_classify_table_by_interface (vat_main_t * vam)
16590 unformat_input_t *input = vam->input;
16591 vl_api_classify_table_by_interface_t *mp;
16593 u32 sw_if_index = ~0;
16595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16597 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16599 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16604 if (sw_if_index == ~0)
16606 errmsg ("missing interface name or sw_if_index");
16610 /* Construct the API message */
16611 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16613 mp->sw_if_index = ntohl (sw_if_index);
16621 api_classify_table_info (vat_main_t * vam)
16623 unformat_input_t *input = vam->input;
16624 vl_api_classify_table_info_t *mp;
16628 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16630 if (unformat (input, "table_id %d", &table_id))
16635 if (table_id == ~0)
16637 errmsg ("missing table id");
16641 /* Construct the API message */
16642 M (CLASSIFY_TABLE_INFO, mp);
16644 mp->table_id = ntohl (table_id);
16652 api_classify_session_dump (vat_main_t * vam)
16654 unformat_input_t *input = vam->input;
16655 vl_api_classify_session_dump_t *mp;
16656 vl_api_control_ping_t *mp_ping;
16660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16662 if (unformat (input, "table_id %d", &table_id))
16667 if (table_id == ~0)
16669 errmsg ("missing table id");
16673 /* Construct the API message */
16674 M (CLASSIFY_SESSION_DUMP, mp);
16676 mp->table_id = ntohl (table_id);
16679 /* Use a control ping for synchronization */
16680 M (CONTROL_PING, mp_ping);
16688 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16690 vat_main_t *vam = &vat_main;
16692 print (vam->ofp, "collector_address %U, collector_port %d, "
16693 "src_address %U, vrf_id %d, path_mtu %u, "
16694 "template_interval %u, udp_checksum %d",
16695 format_ip4_address, mp->collector_address,
16696 ntohs (mp->collector_port),
16697 format_ip4_address, mp->src_address,
16698 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16699 ntohl (mp->template_interval), mp->udp_checksum);
16702 vam->result_ready = 1;
16706 vl_api_ipfix_exporter_details_t_handler_json
16707 (vl_api_ipfix_exporter_details_t * mp)
16709 vat_main_t *vam = &vat_main;
16710 vat_json_node_t node;
16711 struct in_addr collector_address;
16712 struct in_addr src_address;
16714 vat_json_init_object (&node);
16715 clib_memcpy (&collector_address, &mp->collector_address,
16716 sizeof (collector_address));
16717 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16718 vat_json_object_add_uint (&node, "collector_port",
16719 ntohs (mp->collector_port));
16720 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16721 vat_json_object_add_ip4 (&node, "src_address", src_address);
16722 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16723 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16724 vat_json_object_add_uint (&node, "template_interval",
16725 ntohl (mp->template_interval));
16726 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16728 vat_json_print (vam->ofp, &node);
16729 vat_json_free (&node);
16731 vam->result_ready = 1;
16735 api_ipfix_exporter_dump (vat_main_t * vam)
16737 vl_api_ipfix_exporter_dump_t *mp;
16740 /* Construct the API message */
16741 M (IPFIX_EXPORTER_DUMP, mp);
16750 api_ipfix_classify_stream_dump (vat_main_t * vam)
16752 vl_api_ipfix_classify_stream_dump_t *mp;
16755 /* Construct the API message */
16756 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16767 vl_api_ipfix_classify_stream_details_t_handler
16768 (vl_api_ipfix_classify_stream_details_t * mp)
16770 vat_main_t *vam = &vat_main;
16771 print (vam->ofp, "domain_id %d, src_port %d",
16772 ntohl (mp->domain_id), ntohs (mp->src_port));
16774 vam->result_ready = 1;
16778 vl_api_ipfix_classify_stream_details_t_handler_json
16779 (vl_api_ipfix_classify_stream_details_t * mp)
16781 vat_main_t *vam = &vat_main;
16782 vat_json_node_t node;
16784 vat_json_init_object (&node);
16785 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16786 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16788 vat_json_print (vam->ofp, &node);
16789 vat_json_free (&node);
16791 vam->result_ready = 1;
16795 api_ipfix_classify_table_dump (vat_main_t * vam)
16797 vl_api_ipfix_classify_table_dump_t *mp;
16798 vl_api_control_ping_t *mp_ping;
16801 if (!vam->json_output)
16803 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16804 "transport_protocol");
16807 /* Construct the API message */
16808 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16813 /* Use a control ping for synchronization */
16814 M (CONTROL_PING, mp_ping);
16822 vl_api_ipfix_classify_table_details_t_handler
16823 (vl_api_ipfix_classify_table_details_t * mp)
16825 vat_main_t *vam = &vat_main;
16826 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16827 mp->transport_protocol);
16831 vl_api_ipfix_classify_table_details_t_handler_json
16832 (vl_api_ipfix_classify_table_details_t * mp)
16834 vat_json_node_t *node = NULL;
16835 vat_main_t *vam = &vat_main;
16837 if (VAT_JSON_ARRAY != vam->json_tree.type)
16839 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16840 vat_json_init_array (&vam->json_tree);
16843 node = vat_json_array_add (&vam->json_tree);
16844 vat_json_init_object (node);
16846 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16847 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16848 vat_json_object_add_uint (node, "transport_protocol",
16849 mp->transport_protocol);
16853 api_sw_interface_span_enable_disable (vat_main_t * vam)
16855 unformat_input_t *i = vam->input;
16856 vl_api_sw_interface_span_enable_disable_t *mp;
16857 u32 src_sw_if_index = ~0;
16858 u32 dst_sw_if_index = ~0;
16862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16865 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16867 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16871 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16873 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16875 else if (unformat (i, "disable"))
16877 else if (unformat (i, "rx"))
16879 else if (unformat (i, "tx"))
16881 else if (unformat (i, "both"))
16887 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16889 mp->sw_if_index_from = htonl (src_sw_if_index);
16890 mp->sw_if_index_to = htonl (dst_sw_if_index);
16899 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16902 vat_main_t *vam = &vat_main;
16903 u8 *sw_if_from_name = 0;
16904 u8 *sw_if_to_name = 0;
16905 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16906 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16907 char *states[] = { "none", "rx", "tx", "both" };
16911 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16913 if ((u32) p->value[0] == sw_if_index_from)
16915 sw_if_from_name = (u8 *)(p->key);
16919 if ((u32) p->value[0] == sw_if_index_to)
16921 sw_if_to_name = (u8 *)(p->key);
16922 if (sw_if_from_name)
16927 print (vam->ofp, "%20s => %20s (%s)",
16928 sw_if_from_name, sw_if_to_name, states[mp->state]);
16932 vl_api_sw_interface_span_details_t_handler_json
16933 (vl_api_sw_interface_span_details_t * mp)
16935 vat_main_t *vam = &vat_main;
16936 vat_json_node_t *node = NULL;
16937 u8 *sw_if_from_name = 0;
16938 u8 *sw_if_to_name = 0;
16939 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16940 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16944 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16946 if ((u32) p->value[0] == sw_if_index_from)
16948 sw_if_from_name = (u8 *)(p->key);
16952 if ((u32) p->value[0] == sw_if_index_to)
16954 sw_if_to_name = (u8 *)(p->key);
16955 if (sw_if_from_name)
16961 if (VAT_JSON_ARRAY != vam->json_tree.type)
16963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16964 vat_json_init_array (&vam->json_tree);
16966 node = vat_json_array_add (&vam->json_tree);
16968 vat_json_init_object (node);
16969 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16970 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16971 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16972 if (0 != sw_if_to_name)
16974 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16976 vat_json_object_add_uint (node, "state", mp->state);
16980 api_sw_interface_span_dump (vat_main_t * vam)
16982 vl_api_sw_interface_span_dump_t *mp;
16983 vl_api_control_ping_t *mp_ping;
16986 M (SW_INTERFACE_SPAN_DUMP, mp);
16989 /* Use a control ping for synchronization */
16990 M (CONTROL_PING, mp_ping);
16998 api_pg_create_interface (vat_main_t * vam)
17000 unformat_input_t *input = vam->input;
17001 vl_api_pg_create_interface_t *mp;
17005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17007 if (unformat (input, "if_id %d", &if_id))
17014 errmsg ("missing pg interface index");
17018 /* Construct the API message */
17019 M (PG_CREATE_INTERFACE, mp);
17021 mp->interface_id = ntohl (if_id);
17029 api_pg_capture (vat_main_t * vam)
17031 unformat_input_t *input = vam->input;
17032 vl_api_pg_capture_t *mp;
17037 u8 pcap_file_set = 0;
17040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17042 if (unformat (input, "if_id %d", &if_id))
17044 else if (unformat (input, "pcap %s", &pcap_file))
17046 else if (unformat (input, "count %d", &count))
17048 else if (unformat (input, "disable"))
17055 errmsg ("missing pg interface index");
17058 if (pcap_file_set > 0)
17060 if (vec_len (pcap_file) > 255)
17062 errmsg ("pcap file name is too long");
17067 u32 name_len = vec_len (pcap_file);
17068 /* Construct the API message */
17069 M (PG_CAPTURE, mp);
17071 mp->interface_id = ntohl (if_id);
17072 mp->is_enabled = enable;
17073 mp->count = ntohl (count);
17074 mp->pcap_name_length = ntohl (name_len);
17075 if (pcap_file_set != 0)
17077 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
17079 vec_free (pcap_file);
17087 api_pg_enable_disable (vat_main_t * vam)
17089 unformat_input_t *input = vam->input;
17090 vl_api_pg_enable_disable_t *mp;
17093 u8 stream_name_set = 0;
17094 u8 *stream_name = 0;
17096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17098 if (unformat (input, "stream %s", &stream_name))
17099 stream_name_set = 1;
17100 else if (unformat (input, "disable"))
17106 if (stream_name_set > 0)
17108 if (vec_len (stream_name) > 255)
17110 errmsg ("stream name too long");
17115 u32 name_len = vec_len (stream_name);
17116 /* Construct the API message */
17117 M (PG_ENABLE_DISABLE, mp);
17119 mp->is_enabled = enable;
17120 if (stream_name_set != 0)
17122 mp->stream_name_length = ntohl (name_len);
17123 clib_memcpy (mp->stream_name, stream_name, name_len);
17125 vec_free (stream_name);
17133 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
17135 unformat_input_t *input = vam->input;
17136 vl_api_ip_source_and_port_range_check_add_del_t *mp;
17138 u16 *low_ports = 0;
17139 u16 *high_ports = 0;
17142 ip4_address_t ip4_addr;
17143 ip6_address_t ip6_addr;
17152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17154 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
17160 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
17165 else if (unformat (input, "vrf %d", &vrf_id))
17167 else if (unformat (input, "del"))
17169 else if (unformat (input, "port %d", &tmp))
17171 if (tmp == 0 || tmp > 65535)
17173 errmsg ("port %d out of range", tmp);
17177 this_hi = this_low + 1;
17178 vec_add1 (low_ports, this_low);
17179 vec_add1 (high_ports, this_hi);
17181 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
17183 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
17185 errmsg ("incorrect range parameters");
17189 /* Note: in debug CLI +1 is added to high before
17190 passing to real fn that does "the work"
17191 (ip_source_and_port_range_check_add_del).
17192 This fn is a wrapper around the binary API fn a
17193 control plane will call, which expects this increment
17194 to have occurred. Hence letting the binary API control
17195 plane fn do the increment for consistency between VAT
17196 and other control planes.
17199 vec_add1 (low_ports, this_low);
17200 vec_add1 (high_ports, this_hi);
17206 if (prefix_set == 0)
17208 errmsg ("<address>/<mask> not specified");
17214 errmsg ("VRF ID required, not specified");
17221 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17225 if (vec_len (low_ports) == 0)
17227 errmsg ("At least one port or port range required");
17231 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
17233 mp->is_add = is_add;
17238 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
17243 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
17246 mp->mask_length = length;
17247 mp->number_of_ranges = vec_len (low_ports);
17249 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
17250 vec_free (low_ports);
17252 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
17253 vec_free (high_ports);
17255 mp->vrf_id = ntohl (vrf_id);
17263 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
17265 unformat_input_t *input = vam->input;
17266 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
17267 u32 sw_if_index = ~0;
17269 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17270 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17276 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17278 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17280 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17282 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17284 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17286 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17288 else if (unformat (input, "del"))
17294 if (sw_if_index == ~0)
17296 errmsg ("Interface required but not specified");
17302 errmsg ("VRF ID required but not specified");
17306 if (tcp_out_vrf_id == 0
17307 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17310 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17314 /* Construct the API message */
17315 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17317 mp->sw_if_index = ntohl (sw_if_index);
17318 mp->is_add = is_add;
17319 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17320 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17321 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17322 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17327 /* Wait for a reply... */
17333 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17335 unformat_input_t *i = vam->input;
17336 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17337 u32 local_sa_id = 0;
17338 u32 remote_sa_id = 0;
17339 ip4_address_t src_address;
17340 ip4_address_t dst_address;
17344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17346 if (unformat (i, "local_sa %d", &local_sa_id))
17348 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17350 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17352 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17354 else if (unformat (i, "del"))
17358 clib_warning ("parse error '%U'", format_unformat_error, i);
17363 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17365 mp->local_sa_id = ntohl (local_sa_id);
17366 mp->remote_sa_id = ntohl (remote_sa_id);
17367 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17368 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17369 mp->is_add = is_add;
17377 api_punt (vat_main_t * vam)
17379 unformat_input_t *i = vam->input;
17387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17389 if (unformat (i, "ip %d", &ipv))
17391 else if (unformat (i, "protocol %d", &protocol))
17393 else if (unformat (i, "port %d", &port))
17395 else if (unformat (i, "del"))
17399 clib_warning ("parse error '%U'", format_unformat_error, i);
17406 mp->is_add = (u8) is_add;
17407 mp->ipv = (u8) ipv;
17408 mp->l4_protocol = (u8) protocol;
17409 mp->l4_port = htons ((u16) port);
17416 static void vl_api_ipsec_gre_tunnel_details_t_handler
17417 (vl_api_ipsec_gre_tunnel_details_t * mp)
17419 vat_main_t *vam = &vat_main;
17421 print (vam->ofp, "%11d%15U%15U%14d%14d",
17422 ntohl (mp->sw_if_index),
17423 format_ip4_address, &mp->src_address,
17424 format_ip4_address, &mp->dst_address,
17425 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17428 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17429 (vl_api_ipsec_gre_tunnel_details_t * mp)
17431 vat_main_t *vam = &vat_main;
17432 vat_json_node_t *node = NULL;
17433 struct in_addr ip4;
17435 if (VAT_JSON_ARRAY != vam->json_tree.type)
17437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17438 vat_json_init_array (&vam->json_tree);
17440 node = vat_json_array_add (&vam->json_tree);
17442 vat_json_init_object (node);
17443 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17444 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17445 vat_json_object_add_ip4 (node, "src_address", ip4);
17446 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17447 vat_json_object_add_ip4 (node, "dst_address", ip4);
17448 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17449 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17453 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17455 unformat_input_t *i = vam->input;
17456 vl_api_ipsec_gre_tunnel_dump_t *mp;
17457 vl_api_control_ping_t *mp_ping;
17459 u8 sw_if_index_set = 0;
17462 /* Parse args required to build the message */
17463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17465 if (unformat (i, "sw_if_index %d", &sw_if_index))
17466 sw_if_index_set = 1;
17471 if (sw_if_index_set == 0)
17476 if (!vam->json_output)
17478 print (vam->ofp, "%11s%15s%15s%14s%14s",
17479 "sw_if_index", "src_address", "dst_address",
17480 "local_sa_id", "remote_sa_id");
17483 /* Get list of gre-tunnel interfaces */
17484 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17486 mp->sw_if_index = htonl (sw_if_index);
17490 /* Use a control ping for synchronization */
17491 M (CONTROL_PING, mp_ping);
17499 api_delete_subif (vat_main_t * vam)
17501 unformat_input_t *i = vam->input;
17502 vl_api_delete_subif_t *mp;
17503 u32 sw_if_index = ~0;
17506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17510 if (unformat (i, "sw_if_index %d", &sw_if_index))
17516 if (sw_if_index == ~0)
17518 errmsg ("missing sw_if_index");
17522 /* Construct the API message */
17523 M (DELETE_SUBIF, mp);
17524 mp->sw_if_index = ntohl (sw_if_index);
17531 #define foreach_pbb_vtr_op \
17532 _("disable", L2_VTR_DISABLED) \
17533 _("pop", L2_VTR_POP_2) \
17534 _("push", L2_VTR_PUSH_2)
17537 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17539 unformat_input_t *i = vam->input;
17540 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17541 u32 sw_if_index = ~0, vtr_op = ~0;
17542 u16 outer_tag = ~0;
17543 u8 dmac[6], smac[6];
17544 u8 dmac_set = 0, smac_set = 0;
17550 /* Shut up coverity */
17551 memset (dmac, 0, sizeof (dmac));
17552 memset (smac, 0, sizeof (smac));
17554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17560 else if (unformat (i, "vtr_op %d", &vtr_op))
17562 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17565 else if (unformat (i, "translate_pbb_stag"))
17567 if (unformat (i, "%d", &tmp))
17569 vtr_op = L2_VTR_TRANSLATE_2_1;
17575 ("translate_pbb_stag operation requires outer tag definition");
17579 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17581 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17583 else if (unformat (i, "sid %d", &sid))
17585 else if (unformat (i, "vlanid %d", &tmp))
17589 clib_warning ("parse error '%U'", format_unformat_error, i);
17594 if ((sw_if_index == ~0) || (vtr_op == ~0))
17596 errmsg ("missing sw_if_index or vtr operation");
17599 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17600 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17603 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17607 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17608 mp->sw_if_index = ntohl (sw_if_index);
17609 mp->vtr_op = ntohl (vtr_op);
17610 mp->outer_tag = ntohs (outer_tag);
17611 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17612 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17613 mp->b_vlanid = ntohs (vlanid);
17614 mp->i_sid = ntohl (sid);
17622 api_flow_classify_set_interface (vat_main_t * vam)
17624 unformat_input_t *i = vam->input;
17625 vl_api_flow_classify_set_interface_t *mp;
17627 int sw_if_index_set;
17628 u32 ip4_table_index = ~0;
17629 u32 ip6_table_index = ~0;
17633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17636 sw_if_index_set = 1;
17637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17638 sw_if_index_set = 1;
17639 else if (unformat (i, "del"))
17641 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17643 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17647 clib_warning ("parse error '%U'", format_unformat_error, i);
17652 if (sw_if_index_set == 0)
17654 errmsg ("missing interface name or sw_if_index");
17658 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17660 mp->sw_if_index = ntohl (sw_if_index);
17661 mp->ip4_table_index = ntohl (ip4_table_index);
17662 mp->ip6_table_index = ntohl (ip6_table_index);
17663 mp->is_add = is_add;
17671 api_flow_classify_dump (vat_main_t * vam)
17673 unformat_input_t *i = vam->input;
17674 vl_api_flow_classify_dump_t *mp;
17675 vl_api_control_ping_t *mp_ping;
17676 u8 type = FLOW_CLASSIFY_N_TABLES;
17679 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17683 errmsg ("classify table type must be specified");
17687 if (!vam->json_output)
17689 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17692 M (FLOW_CLASSIFY_DUMP, mp);
17697 /* Use a control ping for synchronization */
17698 M (CONTROL_PING, mp_ping);
17701 /* Wait for a reply... */
17707 api_feature_enable_disable (vat_main_t * vam)
17709 unformat_input_t *i = vam->input;
17710 vl_api_feature_enable_disable_t *mp;
17712 u8 *feature_name = 0;
17713 u32 sw_if_index = ~0;
17717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17719 if (unformat (i, "arc_name %s", &arc_name))
17721 else if (unformat (i, "feature_name %s", &feature_name))
17724 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17726 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17728 else if (unformat (i, "disable"))
17736 errmsg ("missing arc name");
17739 if (vec_len (arc_name) > 63)
17741 errmsg ("arc name too long");
17744 if (feature_name == 0)
17746 errmsg ("missing feature name");
17749 if (vec_len (feature_name) > 63)
17751 errmsg ("feature name too long");
17754 if (sw_if_index == ~0)
17756 errmsg ("missing interface name or sw_if_index");
17760 /* Construct the API message */
17761 M (FEATURE_ENABLE_DISABLE, mp);
17762 mp->sw_if_index = ntohl (sw_if_index);
17763 mp->enable = enable;
17764 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17765 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17766 vec_free (arc_name);
17767 vec_free (feature_name);
17775 api_sw_interface_tag_add_del (vat_main_t * vam)
17777 unformat_input_t *i = vam->input;
17778 vl_api_sw_interface_tag_add_del_t *mp;
17779 u32 sw_if_index = ~0;
17784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17786 if (unformat (i, "tag %s", &tag))
17788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17792 else if (unformat (i, "del"))
17798 if (sw_if_index == ~0)
17800 errmsg ("missing interface name or sw_if_index");
17804 if (enable && (tag == 0))
17806 errmsg ("no tag specified");
17810 /* Construct the API message */
17811 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17812 mp->sw_if_index = ntohl (sw_if_index);
17813 mp->is_add = enable;
17815 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17823 static void vl_api_l2_xconnect_details_t_handler
17824 (vl_api_l2_xconnect_details_t * mp)
17826 vat_main_t *vam = &vat_main;
17828 print (vam->ofp, "%15d%15d",
17829 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17832 static void vl_api_l2_xconnect_details_t_handler_json
17833 (vl_api_l2_xconnect_details_t * mp)
17835 vat_main_t *vam = &vat_main;
17836 vat_json_node_t *node = NULL;
17838 if (VAT_JSON_ARRAY != vam->json_tree.type)
17840 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17841 vat_json_init_array (&vam->json_tree);
17843 node = vat_json_array_add (&vam->json_tree);
17845 vat_json_init_object (node);
17846 vat_json_object_add_uint (node, "rx_sw_if_index",
17847 ntohl (mp->rx_sw_if_index));
17848 vat_json_object_add_uint (node, "tx_sw_if_index",
17849 ntohl (mp->tx_sw_if_index));
17853 api_l2_xconnect_dump (vat_main_t * vam)
17855 vl_api_l2_xconnect_dump_t *mp;
17856 vl_api_control_ping_t *mp_ping;
17859 if (!vam->json_output)
17861 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17864 M (L2_XCONNECT_DUMP, mp);
17868 /* Use a control ping for synchronization */
17869 M (CONTROL_PING, mp_ping);
17877 api_sw_interface_set_mtu (vat_main_t * vam)
17879 unformat_input_t *i = vam->input;
17880 vl_api_sw_interface_set_mtu_t *mp;
17881 u32 sw_if_index = ~0;
17885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17887 if (unformat (i, "mtu %d", &mtu))
17889 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17891 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17897 if (sw_if_index == ~0)
17899 errmsg ("missing interface name or sw_if_index");
17905 errmsg ("no mtu specified");
17909 /* Construct the API message */
17910 M (SW_INTERFACE_SET_MTU, mp);
17911 mp->sw_if_index = ntohl (sw_if_index);
17912 mp->mtu = ntohs ((u16) mtu);
17921 q_or_quit (vat_main_t * vam)
17923 #if VPP_API_TEST_BUILTIN == 0
17924 longjmp (vam->jump_buf, 1);
17926 return 0; /* not so much */
17930 q (vat_main_t * vam)
17932 return q_or_quit (vam);
17936 quit (vat_main_t * vam)
17938 return q_or_quit (vam);
17942 comment (vat_main_t * vam)
17948 cmd_cmp (void *a1, void *a2)
17953 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17957 help (vat_main_t * vam)
17962 unformat_input_t *i = vam->input;
17965 if (unformat (i, "%s", &name))
17969 vec_add1 (name, 0);
17971 hs = hash_get_mem (vam->help_by_name, name);
17973 print (vam->ofp, "usage: %s %s", name, hs[0]);
17975 print (vam->ofp, "No such msg / command '%s'", name);
17980 print (vam->ofp, "Help is available for the following:");
17983 hash_foreach_pair (p, vam->function_by_name,
17985 vec_add1 (cmds, (u8 *)(p->key));
17989 vec_sort_with_function (cmds, cmd_cmp);
17991 for (j = 0; j < vec_len (cmds); j++)
17992 print (vam->ofp, "%s", cmds[j]);
17999 set (vat_main_t * vam)
18001 u8 *name = 0, *value = 0;
18002 unformat_input_t *i = vam->input;
18004 if (unformat (i, "%s", &name))
18006 /* The input buffer is a vector, not a string. */
18007 value = vec_dup (i->buffer);
18008 vec_delete (value, i->index, 0);
18009 /* Almost certainly has a trailing newline */
18010 if (value[vec_len (value) - 1] == '\n')
18011 value[vec_len (value) - 1] = 0;
18012 /* Make sure it's a proper string, one way or the other */
18013 vec_add1 (value, 0);
18014 (void) clib_macro_set_value (&vam->macro_main,
18015 (char *) name, (char *) value);
18018 errmsg ("usage: set <name> <value>");
18026 unset (vat_main_t * vam)
18030 if (unformat (vam->input, "%s", &name))
18031 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
18032 errmsg ("unset: %s wasn't set", name);
18045 macro_sort_cmp (void *a1, void *a2)
18047 macro_sort_t *s1 = a1;
18048 macro_sort_t *s2 = a2;
18050 return strcmp ((char *) (s1->name), (char *) (s2->name));
18054 dump_macro_table (vat_main_t * vam)
18056 macro_sort_t *sort_me = 0, *sm;
18061 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
18063 vec_add2 (sort_me, sm, 1);
18064 sm->name = (u8 *)(p->key);
18065 sm->value = (u8 *) (p->value[0]);
18069 vec_sort_with_function (sort_me, macro_sort_cmp);
18071 if (vec_len (sort_me))
18072 print (vam->ofp, "%-15s%s", "Name", "Value");
18074 print (vam->ofp, "The macro table is empty...");
18076 for (i = 0; i < vec_len (sort_me); i++)
18077 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
18082 dump_node_table (vat_main_t * vam)
18085 vlib_node_t *node, *next_node;
18087 if (vec_len (vam->graph_nodes) == 0)
18089 print (vam->ofp, "Node table empty, issue get_node_graph...");
18093 for (i = 0; i < vec_len (vam->graph_nodes); i++)
18095 node = vam->graph_nodes[i];
18096 print (vam->ofp, "[%d] %s", i, node->name);
18097 for (j = 0; j < vec_len (node->next_nodes); j++)
18099 if (node->next_nodes[j] != ~0)
18101 next_node = vam->graph_nodes[node->next_nodes[j]];
18102 print (vam->ofp, " [%d] %s", j, next_node->name);
18110 value_sort_cmp (void *a1, void *a2)
18112 name_sort_t *n1 = a1;
18113 name_sort_t *n2 = a2;
18115 if (n1->value < n2->value)
18117 if (n1->value > n2->value)
18124 dump_msg_api_table (vat_main_t * vam)
18126 api_main_t *am = &api_main;
18127 name_sort_t *nses = 0, *ns;
18132 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
18134 vec_add2 (nses, ns, 1);
18135 ns->name = (u8 *)(hp->key);
18136 ns->value = (u32) hp->value[0];
18140 vec_sort_with_function (nses, value_sort_cmp);
18142 for (i = 0; i < vec_len (nses); i++)
18143 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
18149 get_msg_id (vat_main_t * vam)
18154 if (unformat (vam->input, "%s", &name_and_crc))
18156 message_index = vl_api_get_msg_index (name_and_crc);
18157 if (message_index == ~0)
18159 print (vam->ofp, " '%s' not found", name_and_crc);
18162 print (vam->ofp, " '%s' has message index %d",
18163 name_and_crc, message_index);
18166 errmsg ("name_and_crc required...");
18171 search_node_table (vat_main_t * vam)
18173 unformat_input_t *line_input = vam->input;
18176 vlib_node_t *node, *next_node;
18179 if (vam->graph_node_index_by_name == 0)
18181 print (vam->ofp, "Node table empty, issue get_node_graph...");
18185 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
18187 if (unformat (line_input, "%s", &node_to_find))
18189 vec_add1 (node_to_find, 0);
18190 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
18193 print (vam->ofp, "%s not found...", node_to_find);
18196 node = vam->graph_nodes[p[0]];
18197 print (vam->ofp, "[%d] %s", p[0], node->name);
18198 for (j = 0; j < vec_len (node->next_nodes); j++)
18200 if (node->next_nodes[j] != ~0)
18202 next_node = vam->graph_nodes[node->next_nodes[j]];
18203 print (vam->ofp, " [%d] %s", j, next_node->name);
18210 clib_warning ("parse error '%U'", format_unformat_error,
18216 vec_free (node_to_find);
18225 script (vat_main_t * vam)
18227 #if (VPP_API_TEST_BUILTIN==0)
18229 char *save_current_file;
18230 unformat_input_t save_input;
18231 jmp_buf save_jump_buf;
18232 u32 save_line_number;
18234 FILE *new_fp, *save_ifp;
18236 if (unformat (vam->input, "%s", &s))
18238 new_fp = fopen ((char *) s, "r");
18241 errmsg ("Couldn't open script file %s", s);
18248 errmsg ("Missing script name");
18252 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
18253 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
18254 save_ifp = vam->ifp;
18255 save_line_number = vam->input_line_number;
18256 save_current_file = (char *) vam->current_file;
18258 vam->input_line_number = 0;
18260 vam->current_file = s;
18263 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
18264 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
18265 vam->ifp = save_ifp;
18266 vam->input_line_number = save_line_number;
18267 vam->current_file = (u8 *) save_current_file;
18272 clib_warning ("use the exec command...");
18278 echo (vat_main_t * vam)
18280 print (vam->ofp, "%v", vam->input->buffer);
18284 /* List of API message constructors, CLI names map to api_xxx */
18285 #define foreach_vpe_api_msg \
18286 _(create_loopback,"[mac <mac-addr>]") \
18287 _(sw_interface_dump,"") \
18288 _(sw_interface_set_flags, \
18289 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18290 _(sw_interface_add_del_address, \
18291 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18292 _(sw_interface_set_table, \
18293 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18294 _(sw_interface_set_mpls_enable, \
18295 "<intfc> | sw_if_index [disable | dis]") \
18296 _(sw_interface_set_vpath, \
18297 "<intfc> | sw_if_index <id> enable | disable") \
18298 _(sw_interface_set_vxlan_bypass, \
18299 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18300 _(sw_interface_set_l2_xconnect, \
18301 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18302 "enable | disable") \
18303 _(sw_interface_set_l2_bridge, \
18304 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18305 "[shg <split-horizon-group>] [bvi]\n" \
18306 "enable | disable") \
18307 _(bridge_domain_add_del, \
18308 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18309 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18311 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18313 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18315 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18317 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18319 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18321 "<vpp-if-name> | sw_if_index <id>") \
18322 _(sw_interface_tap_dump, "") \
18323 _(ip_add_del_route, \
18324 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18325 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18326 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18327 "[multipath] [count <n>]") \
18328 _(ip_mroute_add_del, \
18329 "<src> <grp>/<mask> [table-id <n>]\n" \
18330 "[<intfc> | sw_if_index <id>] [local] [del]") \
18331 _(mpls_route_add_del, \
18332 "<label> <eos> via <addr> [table-id <n>]\n" \
18333 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18334 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18335 "[multipath] [count <n>]") \
18336 _(mpls_ip_bind_unbind, \
18337 "<label> <addr/len>") \
18338 _(mpls_tunnel_add_del, \
18339 " via <addr> [table-id <n>]\n" \
18340 "sw_if_index <id>] [l2] [del]") \
18341 _(proxy_arp_add_del, \
18342 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18343 _(proxy_arp_intfc_enable_disable, \
18344 "<intfc> | sw_if_index <id> enable | disable") \
18345 _(sw_interface_set_unnumbered, \
18346 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18347 _(ip_neighbor_add_del, \
18348 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18349 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18350 _(reset_vrf, "vrf <id> [ipv6]") \
18351 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18352 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18353 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18354 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18355 "[outer_vlan_id_any][inner_vlan_id_any]") \
18356 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18357 _(reset_fib, "vrf <n> [ipv6]") \
18358 _(dhcp_proxy_config, \
18359 "svr <v46-address> src <v46-address>\n" \
18360 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18361 _(dhcp_proxy_set_vss, \
18362 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18363 _(dhcp_proxy_dump, "ip6") \
18364 _(dhcp_client_config, \
18365 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18366 _(set_ip_flow_hash, \
18367 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18368 _(sw_interface_ip6_enable_disable, \
18369 "<intfc> | sw_if_index <id> enable | disable") \
18370 _(sw_interface_ip6_set_link_local_address, \
18371 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18372 _(sw_interface_ip6nd_ra_prefix, \
18373 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18374 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18375 "[nolink] [isno]") \
18376 _(sw_interface_ip6nd_ra_config, \
18377 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18378 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18379 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18380 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18381 _(l2_patch_add_del, \
18382 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18383 "enable | disable") \
18384 _(sr_tunnel_add_del, \
18385 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
18386 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
18387 "[policy <policy_name>]") \
18388 _(sr_policy_add_del, \
18389 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
18390 _(sr_multicast_map_add_del, \
18391 "address [ip6 multicast address] sr-policy [policy name] [del]") \
18392 _(classify_add_del_table, \
18393 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18394 " [del] [del-chain] mask <mask-value>\n" \
18395 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18396 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18397 _(classify_add_del_session, \
18398 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18399 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18400 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18401 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18402 _(classify_set_interface_ip_table, \
18403 "<intfc> | sw_if_index <nn> table <nn>") \
18404 _(classify_set_interface_l2_tables, \
18405 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18406 " [other-table <nn>]") \
18407 _(get_node_index, "node <node-name") \
18408 _(add_node_next, "node <node-name> next <next-node-name>") \
18409 _(l2tpv3_create_tunnel, \
18410 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18411 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18412 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18413 _(l2tpv3_set_tunnel_cookies, \
18414 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18415 "[new_remote_cookie <nn>]\n") \
18416 _(l2tpv3_interface_enable_disable, \
18417 "<intfc> | sw_if_index <nn> enable | disable") \
18418 _(l2tpv3_set_lookup_key, \
18419 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18420 _(sw_if_l2tpv3_tunnel_dump, "") \
18421 _(vxlan_add_del_tunnel, \
18422 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18423 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18424 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18425 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18426 _(gre_add_del_tunnel, \
18427 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18428 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18429 _(l2_fib_clear_table, "") \
18430 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18431 _(l2_interface_vlan_tag_rewrite, \
18432 "<intfc> | sw_if_index <nn> \n" \
18433 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18434 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18435 _(create_vhost_user_if, \
18436 "socket <filename> [server] [renumber <dev_instance>] " \
18437 "[mac <mac_address>]") \
18438 _(modify_vhost_user_if, \
18439 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18440 "[server] [renumber <dev_instance>]") \
18441 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18442 _(sw_interface_vhost_user_dump, "") \
18443 _(show_version, "") \
18444 _(vxlan_gpe_add_del_tunnel, \
18445 "local <addr> remote <addr> vni <nn>\n" \
18446 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18447 "[next-ethernet] [next-nsh]\n") \
18448 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18449 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18450 _(interface_name_renumber, \
18451 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18452 _(input_acl_set_interface, \
18453 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18454 " [l2-table <nn>] [del]") \
18455 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18456 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18457 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18458 _(ip_dump, "ipv4 | ipv6") \
18459 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18460 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18462 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18463 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18464 " integ_alg <alg> integ_key <hex>") \
18465 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18466 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18467 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18468 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18469 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18470 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18471 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18472 "(auth_data 0x<data> | auth_data <data>)") \
18473 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18474 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18475 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18476 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18477 "(local|remote)") \
18478 _(ikev2_set_local_key, "file <absolute_file_path>") \
18479 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18480 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18481 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18482 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18483 _(ikev2_initiate_sa_init, "<profile_name>") \
18484 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18485 _(ikev2_initiate_del_child_sa, "<ispi>") \
18486 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18487 _(delete_loopback,"sw_if_index <nn>") \
18488 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18489 _(map_add_domain, \
18490 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18491 "ip6-src <ip6addr> " \
18492 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18493 _(map_del_domain, "index <n>") \
18494 _(map_add_del_rule, \
18495 "index <n> psid <n> dst <ip6addr> [del]") \
18496 _(map_domain_dump, "") \
18497 _(map_rule_dump, "index <map-domain>") \
18498 _(want_interface_events, "enable|disable") \
18499 _(want_stats,"enable|disable") \
18500 _(get_first_msg_id, "client <name>") \
18501 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18502 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18503 "fib-id <nn> [ip4][ip6][default]") \
18504 _(get_node_graph, " ") \
18505 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18506 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18507 _(ioam_disable, "") \
18508 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18509 " sw_if_index <sw_if_index> p <priority> " \
18510 "w <weight>] [del]") \
18511 _(one_add_del_locator, "locator-set <locator_name> " \
18512 "iface <intf> | sw_if_index <sw_if_index> " \
18513 "p <priority> w <weight> [del]") \
18514 _(one_add_del_local_eid,"vni <vni> eid " \
18515 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18516 "locator-set <locator_name> [del]" \
18517 "[key-id sha1|sha256 secret-key <secret-key>]")\
18518 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18519 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18520 _(one_enable_disable, "enable|disable") \
18521 _(one_map_register_enable_disable, "enable|disable") \
18522 _(one_rloc_probe_enable_disable, "enable|disable") \
18523 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18525 "rloc <locator> p <prio> " \
18526 "w <weight> [rloc <loc> ... ] " \
18527 "action <action> [del-all]") \
18528 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18530 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18531 _(one_map_request_mode, "src-dst|dst-only") \
18532 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18533 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18534 _(one_locator_set_dump, "[local | remote]") \
18535 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18536 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18537 "[local] | [remote]") \
18538 _(one_eid_table_vni_dump, "") \
18539 _(one_eid_table_map_dump, "l2|l3") \
18540 _(one_map_resolver_dump, "") \
18541 _(one_map_server_dump, "") \
18542 _(one_adjacencies_get, "vni <vni>") \
18543 _(show_one_rloc_probe_state, "") \
18544 _(show_one_map_register_state, "") \
18545 _(show_one_status, "") \
18546 _(one_get_map_request_itr_rlocs, "") \
18547 _(show_one_pitr, "") \
18548 _(show_one_map_request_mode, "") \
18549 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18550 " sw_if_index <sw_if_index> p <priority> " \
18551 "w <weight>] [del]") \
18552 _(lisp_add_del_locator, "locator-set <locator_name> " \
18553 "iface <intf> | sw_if_index <sw_if_index> " \
18554 "p <priority> w <weight> [del]") \
18555 _(lisp_add_del_local_eid,"vni <vni> eid " \
18556 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18557 "locator-set <locator_name> [del]" \
18558 "[key-id sha1|sha256 secret-key <secret-key>]") \
18559 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18560 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18561 _(lisp_enable_disable, "enable|disable") \
18562 _(lisp_map_register_enable_disable, "enable|disable") \
18563 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18564 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18566 "rloc <locator> p <prio> " \
18567 "w <weight> [rloc <loc> ... ] " \
18568 "action <action> [del-all]") \
18569 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18571 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18572 _(lisp_map_request_mode, "src-dst|dst-only") \
18573 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18574 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18575 _(lisp_locator_set_dump, "[local | remote]") \
18576 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18577 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18578 "[local] | [remote]") \
18579 _(lisp_eid_table_vni_dump, "") \
18580 _(lisp_eid_table_map_dump, "l2|l3") \
18581 _(lisp_map_resolver_dump, "") \
18582 _(lisp_map_server_dump, "") \
18583 _(lisp_adjacencies_get, "vni <vni>") \
18584 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18585 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18586 _(gpe_set_encap_mode, "lisp|vxlan") \
18587 _(gpe_get_encap_mode, "") \
18588 _(lisp_gpe_add_del_iface, "up|down") \
18589 _(lisp_gpe_enable_disable, "enable|disable") \
18590 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18591 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18592 _(show_lisp_rloc_probe_state, "") \
18593 _(show_lisp_map_register_state, "") \
18594 _(show_lisp_status, "") \
18595 _(lisp_get_map_request_itr_rlocs, "") \
18596 _(show_lisp_pitr, "") \
18597 _(show_lisp_map_request_mode, "") \
18598 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18599 _(af_packet_delete, "name <host interface name>") \
18600 _(policer_add_del, "name <policer name> <params> [del]") \
18601 _(policer_dump, "[name <policer name>]") \
18602 _(policer_classify_set_interface, \
18603 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18604 " [l2-table <nn>] [del]") \
18605 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18606 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18607 "[master|slave]") \
18608 _(netmap_delete, "name <interface name>") \
18609 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18610 _(mpls_fib_dump, "") \
18611 _(classify_table_ids, "") \
18612 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18613 _(classify_table_info, "table_id <nn>") \
18614 _(classify_session_dump, "table_id <nn>") \
18615 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18616 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18617 "[template_interval <nn>] [udp_checksum]") \
18618 _(ipfix_exporter_dump, "") \
18619 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18620 _(ipfix_classify_stream_dump, "") \
18621 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18622 _(ipfix_classify_table_dump, "") \
18623 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18624 _(sw_interface_span_dump, "") \
18625 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18626 _(pg_create_interface, "if_id <nn>") \
18627 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18628 _(pg_enable_disable, "[stream <id>] disable") \
18629 _(ip_source_and_port_range_check_add_del, \
18630 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18631 _(ip_source_and_port_range_check_interface_add_del, \
18632 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18633 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18634 _(ipsec_gre_add_del_tunnel, \
18635 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18636 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18637 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18638 _(l2_interface_pbb_tag_rewrite, \
18639 "<intfc> | sw_if_index <nn> \n" \
18640 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18641 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18642 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18643 _(flow_classify_set_interface, \
18644 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18645 _(flow_classify_dump, "type [ip4|ip6]") \
18646 _(ip_fib_dump, "") \
18647 _(ip_mfib_dump, "") \
18648 _(ip6_fib_dump, "") \
18649 _(ip6_mfib_dump, "") \
18650 _(feature_enable_disable, "arc_name <arc_name> " \
18651 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18652 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18654 _(l2_xconnect_dump, "") \
18655 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18656 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18657 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18660 #define foreach_vpe_dpdk_api_msg \
18661 _(sw_interface_set_dpdk_hqos_pipe, \
18662 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
18663 "profile <profile-id>\n") \
18664 _(sw_interface_set_dpdk_hqos_subport, \
18665 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
18666 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
18667 _(sw_interface_set_dpdk_hqos_tctbl, \
18668 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
18671 /* List of command functions, CLI names map directly to functions */
18672 #define foreach_cli_function \
18673 _(comment, "usage: comment <ignore-rest-of-line>") \
18674 _(dump_interface_table, "usage: dump_interface_table") \
18675 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18676 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18677 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18678 _(dump_stats_table, "usage: dump_stats_table") \
18679 _(dump_macro_table, "usage: dump_macro_table ") \
18680 _(dump_node_table, "usage: dump_node_table") \
18681 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18682 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18683 _(echo, "usage: echo <message>") \
18684 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18685 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18686 _(help, "usage: help") \
18687 _(q, "usage: quit") \
18688 _(quit, "usage: quit") \
18689 _(search_node_table, "usage: search_node_table <name>...") \
18690 _(set, "usage: set <variable-name> <value>") \
18691 _(script, "usage: script <file-name>") \
18692 _(unset, "usage: unset <variable-name>")
18695 static void vl_api_##n##_t_handler_uni \
18696 (vl_api_##n##_t * mp) \
18698 vat_main_t * vam = &vat_main; \
18699 if (vam->json_output) { \
18700 vl_api_##n##_t_handler_json(mp); \
18702 vl_api_##n##_t_handler(mp); \
18705 foreach_vpe_api_reply_msg;
18710 static void vl_api_##n##_t_handler_uni \
18711 (vl_api_##n##_t * mp) \
18713 vat_main_t * vam = &vat_main; \
18714 if (vam->json_output) { \
18715 vl_api_##n##_t_handler_json(mp); \
18717 vl_api_##n##_t_handler(mp); \
18720 foreach_vpe_dpdk_api_reply_msg;
18725 vat_api_hookup (vat_main_t * vam)
18728 vl_msg_api_set_handlers(VL_API_##N, #n, \
18729 vl_api_##n##_t_handler_uni, \
18731 vl_api_##n##_t_endian, \
18732 vl_api_##n##_t_print, \
18733 sizeof(vl_api_##n##_t), 1);
18734 foreach_vpe_api_reply_msg;
18739 vl_msg_api_set_handlers(VL_API_##N, #n, \
18740 vl_api_##n##_t_handler_uni, \
18742 vl_api_##n##_t_endian, \
18743 vl_api_##n##_t_print, \
18744 sizeof(vl_api_##n##_t), 1);
18745 foreach_vpe_dpdk_api_reply_msg;
18749 #if (VPP_API_TEST_BUILTIN==0)
18750 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18753 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18755 vam->function_by_name = hash_create_string (0, sizeof (uword));
18757 vam->help_by_name = hash_create_string (0, sizeof (uword));
18759 /* API messages we can send */
18760 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18761 foreach_vpe_api_msg;
18764 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18765 foreach_vpe_dpdk_api_msg;
18770 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18771 foreach_vpe_api_msg;
18774 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18775 foreach_vpe_dpdk_api_msg;
18779 /* CLI functions */
18780 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18781 foreach_cli_function;
18785 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18786 foreach_cli_function;
18791 * fd.io coding-style-patch-verification: ON
18794 * eval: (c-set-style "gnu")