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 static void vl_api_##n##_t_handler \
3975 (vl_api_##n##_t * mp) \
3977 vat_main_t * vam = &vat_main; \
3978 i32 retval = ntohl(mp->retval); \
3979 if (vam->async_mode) { \
3980 vam->async_errors += (retval < 0); \
3982 vam->retval = retval; \
3983 vam->result_ready = 1; \
3986 foreach_standard_reply_retval_handler;
3990 static void vl_api_##n##_t_handler_json \
3991 (vl_api_##n##_t * mp) \
3993 vat_main_t * vam = &vat_main; \
3994 vat_json_node_t node; \
3995 vat_json_init_object(&node); \
3996 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3997 vat_json_print(vam->ofp, &node); \
3998 vam->retval = ntohl(mp->retval); \
3999 vam->result_ready = 1; \
4001 foreach_standard_reply_retval_handler;
4005 * Table of message reply handlers, must include boilerplate handlers
4009 #define foreach_vpe_api_reply_msg \
4010 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4011 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4012 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4013 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4014 _(CONTROL_PING_REPLY, control_ping_reply) \
4015 _(CLI_REPLY, cli_reply) \
4016 _(CLI_INBAND_REPLY, cli_inband_reply) \
4017 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4018 sw_interface_add_del_address_reply) \
4019 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4020 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4021 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4022 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4023 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4024 sw_interface_set_l2_xconnect_reply) \
4025 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4026 sw_interface_set_l2_bridge_reply) \
4027 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4028 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4029 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4030 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4031 _(L2_FLAGS_REPLY, l2_flags_reply) \
4032 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4033 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4034 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4035 _(TAP_DELETE_REPLY, tap_delete_reply) \
4036 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4037 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4038 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4039 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4040 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4041 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4042 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4043 proxy_arp_intfc_enable_disable_reply) \
4044 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4045 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4046 sw_interface_set_unnumbered_reply) \
4047 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4048 _(RESET_VRF_REPLY, reset_vrf_reply) \
4049 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4050 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4051 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4052 _(RESET_FIB_REPLY, reset_fib_reply) \
4053 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4054 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4055 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4056 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4057 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4058 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4059 sw_interface_ip6_enable_disable_reply) \
4060 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4061 sw_interface_ip6_set_link_local_address_reply) \
4062 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4063 sw_interface_ip6nd_ra_prefix_reply) \
4064 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4065 sw_interface_ip6nd_ra_config_reply) \
4066 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4067 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4068 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
4069 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
4070 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
4071 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4072 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4073 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4074 classify_set_interface_ip_table_reply) \
4075 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4076 classify_set_interface_l2_tables_reply) \
4077 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4078 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4079 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4080 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4081 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4082 l2tpv3_interface_enable_disable_reply) \
4083 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4084 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4085 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4086 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4087 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4088 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4089 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4090 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4091 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4092 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4093 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4094 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4095 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4096 _(SHOW_VERSION_REPLY, show_version_reply) \
4097 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4098 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4099 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4100 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4101 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4102 _(IP4_ARP_EVENT, ip4_arp_event) \
4103 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4104 _(IP6_ND_EVENT, ip6_nd_event) \
4105 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4106 _(IP_ADDRESS_DETAILS, ip_address_details) \
4107 _(IP_DETAILS, ip_details) \
4108 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4109 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4110 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4111 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4112 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4113 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4114 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4115 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4116 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4117 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4118 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4119 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4120 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4121 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4122 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4123 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4124 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4125 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4126 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4127 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4128 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4129 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4130 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4131 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4132 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4133 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
4134 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4135 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4136 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4137 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4138 _(MAP_RULE_DETAILS, map_rule_details) \
4139 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4140 _(WANT_STATS_REPLY, want_stats_reply) \
4141 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4142 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4143 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4144 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4145 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4146 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4147 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4148 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4149 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4150 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4151 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4152 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4153 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4154 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4155 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4156 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4157 one_map_register_enable_disable_reply) \
4158 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4159 one_rloc_probe_enable_disable_reply) \
4160 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4161 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4162 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4163 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4164 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4165 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4166 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4167 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4168 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4169 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4170 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4171 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4172 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4173 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4174 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4175 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4176 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4177 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4178 gpe_fwd_entry_path_details) \
4179 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4180 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4181 one_add_del_map_request_itr_rlocs_reply) \
4182 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4183 one_get_map_request_itr_rlocs_reply) \
4184 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4185 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4186 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4187 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4188 show_one_map_register_state_reply) \
4189 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4190 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4191 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4192 _(POLICER_DETAILS, policer_details) \
4193 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4194 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4195 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4196 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4197 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4198 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4199 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4200 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4201 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4202 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4203 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4204 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4205 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4206 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4207 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4208 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4209 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4210 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4211 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4212 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4213 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4214 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4215 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4216 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4217 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4218 ip_source_and_port_range_check_add_del_reply) \
4219 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4220 ip_source_and_port_range_check_interface_add_del_reply) \
4221 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4222 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4223 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4224 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4225 _(PUNT_REPLY, punt_reply) \
4226 _(IP_FIB_DETAILS, ip_fib_details) \
4227 _(IP6_FIB_DETAILS, ip6_fib_details) \
4228 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4229 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4230 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4231 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4232 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4233 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4242 #define STR_VTR_OP_CASE(op) \
4243 case L2_VTR_ ## op: \
4247 str_vtr_op (u32 vtr_op)
4251 STR_VTR_OP_CASE (DISABLED);
4252 STR_VTR_OP_CASE (PUSH_1);
4253 STR_VTR_OP_CASE (PUSH_2);
4254 STR_VTR_OP_CASE (POP_1);
4255 STR_VTR_OP_CASE (POP_2);
4256 STR_VTR_OP_CASE (TRANSLATE_1_1);
4257 STR_VTR_OP_CASE (TRANSLATE_1_2);
4258 STR_VTR_OP_CASE (TRANSLATE_2_1);
4259 STR_VTR_OP_CASE (TRANSLATE_2_2);
4266 dump_sub_interface_table (vat_main_t * vam)
4268 const sw_interface_subif_t *sub = NULL;
4270 if (vam->json_output)
4273 ("JSON output supported only for VPE API calls and dump_stats_table");
4278 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4279 "Interface", "sw_if_index",
4280 "sub id", "dot1ad", "tags", "outer id",
4281 "inner id", "exact", "default", "outer any", "inner any");
4283 vec_foreach (sub, vam->sw_if_subif_table)
4286 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4287 sub->interface_name,
4289 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4290 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4291 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4292 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4293 if (sub->vtr_op != L2_VTR_DISABLED)
4296 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4297 "tag1: %d tag2: %d ]",
4298 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4299 sub->vtr_tag1, sub->vtr_tag2);
4307 name_sort_cmp (void *a1, void *a2)
4309 name_sort_t *n1 = a1;
4310 name_sort_t *n2 = a2;
4312 return strcmp ((char *) n1->name, (char *) n2->name);
4316 dump_interface_table (vat_main_t * vam)
4319 name_sort_t *nses = 0, *ns;
4321 if (vam->json_output)
4324 ("JSON output supported only for VPE API calls and dump_stats_table");
4329 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4331 vec_add2 (nses, ns, 1);
4332 ns->name = (u8 *)(p->key);
4333 ns->value = (u32) p->value[0];
4337 vec_sort_with_function (nses, name_sort_cmp);
4339 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4340 vec_foreach (ns, nses)
4342 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4349 dump_ip_table (vat_main_t * vam, int is_ipv6)
4351 const ip_details_t *det = NULL;
4352 const ip_address_details_t *address = NULL;
4355 print (vam->ofp, "%-12s", "sw_if_index");
4357 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4364 print (vam->ofp, "%-12d", i);
4365 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4370 vec_foreach (address, det->addr)
4374 is_ipv6 ? format_ip6_address : format_ip4_address,
4375 address->ip, address->prefix_length);
4383 dump_ipv4_table (vat_main_t * vam)
4385 if (vam->json_output)
4388 ("JSON output supported only for VPE API calls and dump_stats_table");
4392 return dump_ip_table (vam, 0);
4396 dump_ipv6_table (vat_main_t * vam)
4398 if (vam->json_output)
4401 ("JSON output supported only for VPE API calls and dump_stats_table");
4405 return dump_ip_table (vam, 1);
4409 counter_type_to_str (u8 counter_type, u8 is_combined)
4413 switch (counter_type)
4415 case VNET_INTERFACE_COUNTER_DROP:
4417 case VNET_INTERFACE_COUNTER_PUNT:
4419 case VNET_INTERFACE_COUNTER_IP4:
4421 case VNET_INTERFACE_COUNTER_IP6:
4423 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4425 case VNET_INTERFACE_COUNTER_RX_MISS:
4427 case VNET_INTERFACE_COUNTER_RX_ERROR:
4429 case VNET_INTERFACE_COUNTER_TX_ERROR:
4432 return "INVALID-COUNTER-TYPE";
4437 switch (counter_type)
4439 case VNET_INTERFACE_COUNTER_RX:
4441 case VNET_INTERFACE_COUNTER_TX:
4444 return "INVALID-COUNTER-TYPE";
4450 dump_stats_table (vat_main_t * vam)
4452 vat_json_node_t node;
4453 vat_json_node_t *msg_array;
4454 vat_json_node_t *msg;
4455 vat_json_node_t *counter_array;
4456 vat_json_node_t *counter;
4457 interface_counter_t c;
4459 ip4_fib_counter_t *c4;
4460 ip6_fib_counter_t *c6;
4461 ip4_nbr_counter_t *n4;
4462 ip6_nbr_counter_t *n6;
4465 if (!vam->json_output)
4467 clib_warning ("dump_stats_table supported only in JSON format");
4471 vat_json_init_object (&node);
4473 /* interface counters */
4474 msg_array = vat_json_object_add (&node, "interface_counters");
4475 vat_json_init_array (msg_array);
4476 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4478 msg = vat_json_array_add (msg_array);
4479 vat_json_init_object (msg);
4480 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4481 (u8 *) counter_type_to_str (i, 0));
4482 vat_json_object_add_int (msg, "is_combined", 0);
4483 counter_array = vat_json_object_add (msg, "data");
4484 vat_json_init_array (counter_array);
4485 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4487 packets = vam->simple_interface_counters[i][j];
4488 vat_json_array_add_uint (counter_array, packets);
4491 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4493 msg = vat_json_array_add (msg_array);
4494 vat_json_init_object (msg);
4495 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4496 (u8 *) counter_type_to_str (i, 1));
4497 vat_json_object_add_int (msg, "is_combined", 1);
4498 counter_array = vat_json_object_add (msg, "data");
4499 vat_json_init_array (counter_array);
4500 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4502 c = vam->combined_interface_counters[i][j];
4503 counter = vat_json_array_add (counter_array);
4504 vat_json_init_object (counter);
4505 vat_json_object_add_uint (counter, "packets", c.packets);
4506 vat_json_object_add_uint (counter, "bytes", c.bytes);
4510 /* ip4 fib counters */
4511 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4512 vat_json_init_array (msg_array);
4513 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4515 msg = vat_json_array_add (msg_array);
4516 vat_json_init_object (msg);
4517 vat_json_object_add_uint (msg, "vrf_id",
4518 vam->ip4_fib_counters_vrf_id_by_index[i]);
4519 counter_array = vat_json_object_add (msg, "c");
4520 vat_json_init_array (counter_array);
4521 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4523 counter = vat_json_array_add (counter_array);
4524 vat_json_init_object (counter);
4525 c4 = &vam->ip4_fib_counters[i][j];
4526 vat_json_object_add_ip4 (counter, "address", c4->address);
4527 vat_json_object_add_uint (counter, "address_length",
4528 c4->address_length);
4529 vat_json_object_add_uint (counter, "packets", c4->packets);
4530 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4534 /* ip6 fib counters */
4535 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4536 vat_json_init_array (msg_array);
4537 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4539 msg = vat_json_array_add (msg_array);
4540 vat_json_init_object (msg);
4541 vat_json_object_add_uint (msg, "vrf_id",
4542 vam->ip6_fib_counters_vrf_id_by_index[i]);
4543 counter_array = vat_json_object_add (msg, "c");
4544 vat_json_init_array (counter_array);
4545 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4547 counter = vat_json_array_add (counter_array);
4548 vat_json_init_object (counter);
4549 c6 = &vam->ip6_fib_counters[i][j];
4550 vat_json_object_add_ip6 (counter, "address", c6->address);
4551 vat_json_object_add_uint (counter, "address_length",
4552 c6->address_length);
4553 vat_json_object_add_uint (counter, "packets", c6->packets);
4554 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4558 /* ip4 nbr counters */
4559 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4560 vat_json_init_array (msg_array);
4561 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4563 msg = vat_json_array_add (msg_array);
4564 vat_json_init_object (msg);
4565 vat_json_object_add_uint (msg, "sw_if_index", i);
4566 counter_array = vat_json_object_add (msg, "c");
4567 vat_json_init_array (counter_array);
4568 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4570 counter = vat_json_array_add (counter_array);
4571 vat_json_init_object (counter);
4572 n4 = &vam->ip4_nbr_counters[i][j];
4573 vat_json_object_add_ip4 (counter, "address", n4->address);
4574 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4575 vat_json_object_add_uint (counter, "packets", n4->packets);
4576 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4580 /* ip6 nbr counters */
4581 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4582 vat_json_init_array (msg_array);
4583 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4585 msg = vat_json_array_add (msg_array);
4586 vat_json_init_object (msg);
4587 vat_json_object_add_uint (msg, "sw_if_index", i);
4588 counter_array = vat_json_object_add (msg, "c");
4589 vat_json_init_array (counter_array);
4590 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4592 counter = vat_json_array_add (counter_array);
4593 vat_json_init_object (counter);
4594 n6 = &vam->ip6_nbr_counters[i][j];
4595 vat_json_object_add_ip6 (counter, "address", n6->address);
4596 vat_json_object_add_uint (counter, "packets", n6->packets);
4597 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4601 vat_json_print (vam->ofp, &node);
4602 vat_json_free (&node);
4608 exec (vat_main_t * vam)
4610 api_main_t *am = &api_main;
4611 vl_api_cli_request_t *mp;
4615 unformat_input_t *i = vam->input;
4617 if (vec_len (i->buffer) == 0)
4620 if (vam->exec_mode == 0 && unformat (i, "mode"))
4625 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4632 M (CLI_REQUEST, mp);
4635 * Copy cmd into shared memory.
4636 * In order for the CLI command to work, it
4637 * must be a vector ending in \n, not a C-string ending
4640 pthread_mutex_lock (&am->vlib_rp->mutex);
4641 oldheap = svm_push_data_heap (am->vlib_rp);
4643 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4644 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4646 svm_pop_heap (oldheap);
4647 pthread_mutex_unlock (&am->vlib_rp->mutex);
4649 mp->cmd_in_shmem = (u64) cmd;
4651 timeout = vat_time_now (vam) + 10.0;
4653 while (vat_time_now (vam) < timeout)
4655 if (vam->result_ready == 1)
4658 if (vam->shmem_result != NULL)
4659 print (vam->ofp, "%s", vam->shmem_result);
4660 pthread_mutex_lock (&am->vlib_rp->mutex);
4661 oldheap = svm_push_data_heap (am->vlib_rp);
4663 free_me = (u8 *) vam->shmem_result;
4666 svm_pop_heap (oldheap);
4667 pthread_mutex_unlock (&am->vlib_rp->mutex);
4675 * Future replacement of exec() that passes CLI buffers directly in
4676 * the API messages instead of an additional shared memory area.
4679 exec_inband (vat_main_t * vam)
4681 vl_api_cli_inband_t *mp;
4682 unformat_input_t *i = vam->input;
4685 if (vec_len (i->buffer) == 0)
4688 if (vam->exec_mode == 0 && unformat (i, "mode"))
4693 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4700 * In order for the CLI command to work, it
4701 * must be a vector ending in \n, not a C-string ending
4704 u32 len = vec_len (vam->input->buffer);
4705 M2 (CLI_INBAND, mp, len);
4706 clib_memcpy (mp->cmd, vam->input->buffer, len);
4707 mp->length = htonl (len);
4710 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4715 api_create_loopback (vat_main_t * vam)
4717 unformat_input_t *i = vam->input;
4718 vl_api_create_loopback_t *mp;
4723 memset (mac_address, 0, sizeof (mac_address));
4725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4727 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4733 /* Construct the API message */
4734 M (CREATE_LOOPBACK, mp);
4736 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4744 api_delete_loopback (vat_main_t * vam)
4746 unformat_input_t *i = vam->input;
4747 vl_api_delete_loopback_t *mp;
4748 u32 sw_if_index = ~0;
4751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4753 if (unformat (i, "sw_if_index %d", &sw_if_index))
4759 if (sw_if_index == ~0)
4761 errmsg ("missing sw_if_index");
4765 /* Construct the API message */
4766 M (DELETE_LOOPBACK, mp);
4767 mp->sw_if_index = ntohl (sw_if_index);
4775 api_want_stats (vat_main_t * vam)
4777 unformat_input_t *i = vam->input;
4778 vl_api_want_stats_t *mp;
4782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4784 if (unformat (i, "enable"))
4786 else if (unformat (i, "disable"))
4794 errmsg ("missing enable|disable");
4799 mp->enable_disable = enable;
4807 api_want_interface_events (vat_main_t * vam)
4809 unformat_input_t *i = vam->input;
4810 vl_api_want_interface_events_t *mp;
4814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4816 if (unformat (i, "enable"))
4818 else if (unformat (i, "disable"))
4826 errmsg ("missing enable|disable");
4830 M (WANT_INTERFACE_EVENTS, mp);
4831 mp->enable_disable = enable;
4833 vam->interface_event_display = enable;
4841 /* Note: non-static, called once to set up the initial intfc table */
4843 api_sw_interface_dump (vat_main_t * vam)
4845 vl_api_sw_interface_dump_t *mp;
4846 vl_api_control_ping_t *mp_ping;
4848 name_sort_t *nses = 0, *ns;
4849 sw_interface_subif_t *sub = NULL;
4852 /* Toss the old name table */
4854 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4856 vec_add2 (nses, ns, 1);
4857 ns->name = (u8 *)(p->key);
4858 ns->value = (u32) p->value[0];
4862 hash_free (vam->sw_if_index_by_interface_name);
4864 vec_foreach (ns, nses) vec_free (ns->name);
4868 vec_foreach (sub, vam->sw_if_subif_table)
4870 vec_free (sub->interface_name);
4872 vec_free (vam->sw_if_subif_table);
4874 /* recreate the interface name hash table */
4875 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4877 /* Get list of ethernets */
4878 M (SW_INTERFACE_DUMP, mp);
4879 mp->name_filter_valid = 1;
4880 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4883 /* and local / loopback interfaces */
4884 M (SW_INTERFACE_DUMP, mp);
4885 mp->name_filter_valid = 1;
4886 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4889 /* and packet-generator interfaces */
4890 M (SW_INTERFACE_DUMP, mp);
4891 mp->name_filter_valid = 1;
4892 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4895 /* and vxlan-gpe tunnel interfaces */
4896 M (SW_INTERFACE_DUMP, mp);
4897 mp->name_filter_valid = 1;
4898 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4899 sizeof (mp->name_filter) - 1);
4902 /* and vxlan tunnel interfaces */
4903 M (SW_INTERFACE_DUMP, mp);
4904 mp->name_filter_valid = 1;
4905 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4908 /* and host (af_packet) interfaces */
4909 M (SW_INTERFACE_DUMP, mp);
4910 mp->name_filter_valid = 1;
4911 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4914 /* and l2tpv3 tunnel interfaces */
4915 M (SW_INTERFACE_DUMP, mp);
4916 mp->name_filter_valid = 1;
4917 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4918 sizeof (mp->name_filter) - 1);
4921 /* and GRE tunnel interfaces */
4922 M (SW_INTERFACE_DUMP, mp);
4923 mp->name_filter_valid = 1;
4924 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4927 /* and LISP-GPE interfaces */
4928 M (SW_INTERFACE_DUMP, mp);
4929 mp->name_filter_valid = 1;
4930 strncpy ((char *) mp->name_filter, "lisp_gpe",
4931 sizeof (mp->name_filter) - 1);
4934 /* and IPSEC tunnel interfaces */
4935 M (SW_INTERFACE_DUMP, mp);
4936 mp->name_filter_valid = 1;
4937 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4940 /* Use a control ping for synchronization */
4941 M (CONTROL_PING, mp_ping);
4949 api_sw_interface_set_flags (vat_main_t * vam)
4951 unformat_input_t *i = vam->input;
4952 vl_api_sw_interface_set_flags_t *mp;
4954 u8 sw_if_index_set = 0;
4955 u8 admin_up = 0, link_up = 0;
4958 /* Parse args required to build the message */
4959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4961 if (unformat (i, "admin-up"))
4963 else if (unformat (i, "admin-down"))
4965 else if (unformat (i, "link-up"))
4967 else if (unformat (i, "link-down"))
4970 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4971 sw_if_index_set = 1;
4972 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4973 sw_if_index_set = 1;
4978 if (sw_if_index_set == 0)
4980 errmsg ("missing interface name or sw_if_index");
4984 /* Construct the API message */
4985 M (SW_INTERFACE_SET_FLAGS, mp);
4986 mp->sw_if_index = ntohl (sw_if_index);
4987 mp->admin_up_down = admin_up;
4988 mp->link_up_down = link_up;
4993 /* Wait for a reply, return the good/bad news... */
4999 api_sw_interface_clear_stats (vat_main_t * vam)
5001 unformat_input_t *i = vam->input;
5002 vl_api_sw_interface_clear_stats_t *mp;
5004 u8 sw_if_index_set = 0;
5007 /* Parse args required to build the message */
5008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5010 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5011 sw_if_index_set = 1;
5012 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5013 sw_if_index_set = 1;
5018 /* Construct the API message */
5019 M (SW_INTERFACE_CLEAR_STATS, mp);
5021 if (sw_if_index_set == 1)
5022 mp->sw_if_index = ntohl (sw_if_index);
5024 mp->sw_if_index = ~0;
5029 /* Wait for a reply, return the good/bad news... */
5035 api_sw_interface_add_del_address (vat_main_t * vam)
5037 unformat_input_t *i = vam->input;
5038 vl_api_sw_interface_add_del_address_t *mp;
5040 u8 sw_if_index_set = 0;
5041 u8 is_add = 1, del_all = 0;
5042 u32 address_length = 0;
5043 u8 v4_address_set = 0;
5044 u8 v6_address_set = 0;
5045 ip4_address_t v4address;
5046 ip6_address_t v6address;
5049 /* Parse args required to build the message */
5050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5052 if (unformat (i, "del-all"))
5054 else if (unformat (i, "del"))
5057 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5058 sw_if_index_set = 1;
5059 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5060 sw_if_index_set = 1;
5061 else if (unformat (i, "%U/%d",
5062 unformat_ip4_address, &v4address, &address_length))
5064 else if (unformat (i, "%U/%d",
5065 unformat_ip6_address, &v6address, &address_length))
5071 if (sw_if_index_set == 0)
5073 errmsg ("missing interface name or sw_if_index");
5076 if (v4_address_set && v6_address_set)
5078 errmsg ("both v4 and v6 addresses set");
5081 if (!v4_address_set && !v6_address_set && !del_all)
5083 errmsg ("no addresses set");
5087 /* Construct the API message */
5088 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5090 mp->sw_if_index = ntohl (sw_if_index);
5091 mp->is_add = is_add;
5092 mp->del_all = del_all;
5096 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5100 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5102 mp->address_length = address_length;
5107 /* Wait for a reply, return good/bad news */
5113 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5115 unformat_input_t *i = vam->input;
5116 vl_api_sw_interface_set_mpls_enable_t *mp;
5118 u8 sw_if_index_set = 0;
5122 /* Parse args required to build the message */
5123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5125 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5126 sw_if_index_set = 1;
5127 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5128 sw_if_index_set = 1;
5129 else if (unformat (i, "disable"))
5131 else if (unformat (i, "dis"))
5137 if (sw_if_index_set == 0)
5139 errmsg ("missing interface name or sw_if_index");
5143 /* Construct the API message */
5144 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5146 mp->sw_if_index = ntohl (sw_if_index);
5147 mp->enable = enable;
5152 /* Wait for a reply... */
5158 api_sw_interface_set_table (vat_main_t * vam)
5160 unformat_input_t *i = vam->input;
5161 vl_api_sw_interface_set_table_t *mp;
5162 u32 sw_if_index, vrf_id = 0;
5163 u8 sw_if_index_set = 0;
5167 /* Parse args required to build the message */
5168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5170 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5171 sw_if_index_set = 1;
5172 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5173 sw_if_index_set = 1;
5174 else if (unformat (i, "vrf %d", &vrf_id))
5176 else if (unformat (i, "ipv6"))
5182 if (sw_if_index_set == 0)
5184 errmsg ("missing interface name or sw_if_index");
5188 /* Construct the API message */
5189 M (SW_INTERFACE_SET_TABLE, mp);
5191 mp->sw_if_index = ntohl (sw_if_index);
5192 mp->is_ipv6 = is_ipv6;
5193 mp->vrf_id = ntohl (vrf_id);
5198 /* Wait for a reply... */
5203 static void vl_api_sw_interface_get_table_reply_t_handler
5204 (vl_api_sw_interface_get_table_reply_t * mp)
5206 vat_main_t *vam = &vat_main;
5208 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5210 vam->retval = ntohl (mp->retval);
5211 vam->result_ready = 1;
5215 static void vl_api_sw_interface_get_table_reply_t_handler_json
5216 (vl_api_sw_interface_get_table_reply_t * mp)
5218 vat_main_t *vam = &vat_main;
5219 vat_json_node_t node;
5221 vat_json_init_object (&node);
5222 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5223 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5225 vat_json_print (vam->ofp, &node);
5226 vat_json_free (&node);
5228 vam->retval = ntohl (mp->retval);
5229 vam->result_ready = 1;
5233 api_sw_interface_get_table (vat_main_t * vam)
5235 unformat_input_t *i = vam->input;
5236 vl_api_sw_interface_get_table_t *mp;
5238 u8 sw_if_index_set = 0;
5242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5244 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5245 sw_if_index_set = 1;
5246 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5247 sw_if_index_set = 1;
5248 else if (unformat (i, "ipv6"))
5254 if (sw_if_index_set == 0)
5256 errmsg ("missing interface name or sw_if_index");
5260 M (SW_INTERFACE_GET_TABLE, mp);
5261 mp->sw_if_index = htonl (sw_if_index);
5262 mp->is_ipv6 = is_ipv6;
5270 api_sw_interface_set_vpath (vat_main_t * vam)
5272 unformat_input_t *i = vam->input;
5273 vl_api_sw_interface_set_vpath_t *mp;
5274 u32 sw_if_index = 0;
5275 u8 sw_if_index_set = 0;
5279 /* Parse args required to build the message */
5280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5282 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5283 sw_if_index_set = 1;
5284 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5285 sw_if_index_set = 1;
5286 else if (unformat (i, "enable"))
5288 else if (unformat (i, "disable"))
5294 if (sw_if_index_set == 0)
5296 errmsg ("missing interface name or sw_if_index");
5300 /* Construct the API message */
5301 M (SW_INTERFACE_SET_VPATH, mp);
5303 mp->sw_if_index = ntohl (sw_if_index);
5304 mp->enable = is_enable;
5309 /* Wait for a reply... */
5315 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5317 unformat_input_t *i = vam->input;
5318 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5319 u32 sw_if_index = 0;
5320 u8 sw_if_index_set = 0;
5325 /* Parse args required to build the message */
5326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5328 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5329 sw_if_index_set = 1;
5330 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5331 sw_if_index_set = 1;
5332 else if (unformat (i, "enable"))
5334 else if (unformat (i, "disable"))
5336 else if (unformat (i, "ip4"))
5338 else if (unformat (i, "ip6"))
5344 if (sw_if_index_set == 0)
5346 errmsg ("missing interface name or sw_if_index");
5350 /* Construct the API message */
5351 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5353 mp->sw_if_index = ntohl (sw_if_index);
5354 mp->enable = is_enable;
5355 mp->is_ipv6 = is_ipv6;
5360 /* Wait for a reply... */
5366 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5368 unformat_input_t *i = vam->input;
5369 vl_api_sw_interface_set_l2_xconnect_t *mp;
5371 u8 rx_sw_if_index_set = 0;
5373 u8 tx_sw_if_index_set = 0;
5377 /* Parse args required to build the message */
5378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5380 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5381 rx_sw_if_index_set = 1;
5382 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5383 tx_sw_if_index_set = 1;
5384 else if (unformat (i, "rx"))
5386 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5388 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5390 rx_sw_if_index_set = 1;
5395 else if (unformat (i, "tx"))
5397 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5399 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5401 tx_sw_if_index_set = 1;
5406 else if (unformat (i, "enable"))
5408 else if (unformat (i, "disable"))
5414 if (rx_sw_if_index_set == 0)
5416 errmsg ("missing rx interface name or rx_sw_if_index");
5420 if (enable && (tx_sw_if_index_set == 0))
5422 errmsg ("missing tx interface name or tx_sw_if_index");
5426 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5428 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5429 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5430 mp->enable = enable;
5438 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5440 unformat_input_t *i = vam->input;
5441 vl_api_sw_interface_set_l2_bridge_t *mp;
5443 u8 rx_sw_if_index_set = 0;
5451 /* Parse args required to build the message */
5452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5454 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5455 rx_sw_if_index_set = 1;
5456 else if (unformat (i, "bd_id %d", &bd_id))
5460 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5461 rx_sw_if_index_set = 1;
5462 else if (unformat (i, "shg %d", &shg))
5464 else if (unformat (i, "bvi"))
5466 else if (unformat (i, "enable"))
5468 else if (unformat (i, "disable"))
5474 if (rx_sw_if_index_set == 0)
5476 errmsg ("missing rx interface name or sw_if_index");
5480 if (enable && (bd_id_set == 0))
5482 errmsg ("missing bridge domain");
5486 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5488 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5489 mp->bd_id = ntohl (bd_id);
5492 mp->enable = enable;
5500 api_bridge_domain_dump (vat_main_t * vam)
5502 unformat_input_t *i = vam->input;
5503 vl_api_bridge_domain_dump_t *mp;
5504 vl_api_control_ping_t *mp_ping;
5508 /* Parse args required to build the message */
5509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5511 if (unformat (i, "bd_id %d", &bd_id))
5517 M (BRIDGE_DOMAIN_DUMP, mp);
5518 mp->bd_id = ntohl (bd_id);
5521 /* Use a control ping for synchronization */
5522 M (CONTROL_PING, mp_ping);
5530 api_bridge_domain_add_del (vat_main_t * vam)
5532 unformat_input_t *i = vam->input;
5533 vl_api_bridge_domain_add_del_t *mp;
5536 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5540 /* Parse args required to build the message */
5541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5543 if (unformat (i, "bd_id %d", &bd_id))
5545 else if (unformat (i, "flood %d", &flood))
5547 else if (unformat (i, "uu-flood %d", &uu_flood))
5549 else if (unformat (i, "forward %d", &forward))
5551 else if (unformat (i, "learn %d", &learn))
5553 else if (unformat (i, "arp-term %d", &arp_term))
5555 else if (unformat (i, "mac-age %d", &mac_age))
5557 else if (unformat (i, "del"))
5560 flood = uu_flood = forward = learn = 0;
5568 errmsg ("missing bridge domain");
5574 errmsg ("mac age must be less than 256 ");
5578 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5580 mp->bd_id = ntohl (bd_id);
5582 mp->uu_flood = uu_flood;
5583 mp->forward = forward;
5585 mp->arp_term = arp_term;
5586 mp->is_add = is_add;
5587 mp->mac_age = (u8) mac_age;
5595 api_l2fib_add_del (vat_main_t * vam)
5597 unformat_input_t *i = vam->input;
5598 vl_api_l2fib_add_del_t *mp;
5604 u32 sw_if_index = ~0;
5605 u8 sw_if_index_set = 0;
5614 /* Parse args required to build the message */
5615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5617 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5619 else if (unformat (i, "bd_id %d", &bd_id))
5621 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5622 sw_if_index_set = 1;
5623 else if (unformat (i, "sw_if"))
5625 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5628 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5629 sw_if_index_set = 1;
5634 else if (unformat (i, "static"))
5636 else if (unformat (i, "filter"))
5641 else if (unformat (i, "bvi"))
5646 else if (unformat (i, "del"))
5648 else if (unformat (i, "count %d", &count))
5656 errmsg ("missing mac address");
5662 errmsg ("missing bridge domain");
5666 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5668 errmsg ("missing interface name or sw_if_index");
5674 /* Turn on async mode */
5675 vam->async_mode = 1;
5676 vam->async_errors = 0;
5677 before = vat_time_now (vam);
5680 for (j = 0; j < count; j++)
5682 M (L2FIB_ADD_DEL, mp);
5685 mp->bd_id = ntohl (bd_id);
5686 mp->is_add = is_add;
5690 mp->sw_if_index = ntohl (sw_if_index);
5691 mp->static_mac = static_mac;
5692 mp->filter_mac = filter_mac;
5693 mp->bvi_mac = bvi_mac;
5695 increment_mac_address (&mac);
5702 vl_api_control_ping_t *mp_ping;
5705 /* Shut off async mode */
5706 vam->async_mode = 0;
5708 M (CONTROL_PING, mp_ping);
5711 timeout = vat_time_now (vam) + 1.0;
5712 while (vat_time_now (vam) < timeout)
5713 if (vam->result_ready == 1)
5718 if (vam->retval == -99)
5721 if (vam->async_errors > 0)
5723 errmsg ("%d asynchronous errors", vam->async_errors);
5726 vam->async_errors = 0;
5727 after = vat_time_now (vam);
5729 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5730 count, after - before, count / (after - before));
5736 /* Wait for a reply... */
5740 /* Return the good/bad news */
5741 return (vam->retval);
5745 api_l2_flags (vat_main_t * vam)
5747 unformat_input_t *i = vam->input;
5748 vl_api_l2_flags_t *mp;
5750 u32 feature_bitmap = 0;
5751 u8 sw_if_index_set = 0;
5754 /* Parse args required to build the message */
5755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5757 if (unformat (i, "sw_if_index %d", &sw_if_index))
5758 sw_if_index_set = 1;
5759 else if (unformat (i, "sw_if"))
5761 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5764 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5765 sw_if_index_set = 1;
5770 else if (unformat (i, "learn"))
5771 feature_bitmap |= L2INPUT_FEAT_LEARN;
5772 else if (unformat (i, "forward"))
5773 feature_bitmap |= L2INPUT_FEAT_FWD;
5774 else if (unformat (i, "flood"))
5775 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5776 else if (unformat (i, "uu-flood"))
5777 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5782 if (sw_if_index_set == 0)
5784 errmsg ("missing interface name or sw_if_index");
5790 mp->sw_if_index = ntohl (sw_if_index);
5791 mp->feature_bitmap = ntohl (feature_bitmap);
5799 api_bridge_flags (vat_main_t * vam)
5801 unformat_input_t *i = vam->input;
5802 vl_api_bridge_flags_t *mp;
5809 /* Parse args required to build the message */
5810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5812 if (unformat (i, "bd_id %d", &bd_id))
5814 else if (unformat (i, "learn"))
5816 else if (unformat (i, "forward"))
5818 else if (unformat (i, "flood"))
5820 else if (unformat (i, "uu-flood"))
5821 flags |= L2_UU_FLOOD;
5822 else if (unformat (i, "arp-term"))
5823 flags |= L2_ARP_TERM;
5824 else if (unformat (i, "off"))
5826 else if (unformat (i, "disable"))
5834 errmsg ("missing bridge domain");
5838 M (BRIDGE_FLAGS, mp);
5840 mp->bd_id = ntohl (bd_id);
5841 mp->feature_bitmap = ntohl (flags);
5842 mp->is_set = is_set;
5850 api_bd_ip_mac_add_del (vat_main_t * vam)
5852 unformat_input_t *i = vam->input;
5853 vl_api_bd_ip_mac_add_del_t *mp;
5860 ip4_address_t v4addr;
5861 ip6_address_t v6addr;
5866 /* Parse args required to build the message */
5867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5869 if (unformat (i, "bd_id %d", &bd_id))
5873 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5877 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5882 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5886 else if (unformat (i, "del"))
5894 errmsg ("missing bridge domain");
5897 else if (ip_set == 0)
5899 errmsg ("missing IP address");
5902 else if (mac_set == 0)
5904 errmsg ("missing MAC address");
5908 M (BD_IP_MAC_ADD_DEL, mp);
5910 mp->bd_id = ntohl (bd_id);
5911 mp->is_ipv6 = is_ipv6;
5912 mp->is_add = is_add;
5914 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5916 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5917 clib_memcpy (mp->mac_address, macaddr, 6);
5924 api_tap_connect (vat_main_t * vam)
5926 unformat_input_t *i = vam->input;
5927 vl_api_tap_connect_t *mp;
5933 ip4_address_t ip4_address;
5935 int ip4_address_set = 0;
5936 ip6_address_t ip6_address;
5938 int ip6_address_set = 0;
5941 memset (mac_address, 0, sizeof (mac_address));
5943 /* Parse args required to build the message */
5944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5946 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5950 else if (unformat (i, "random-mac"))
5952 else if (unformat (i, "tapname %s", &tap_name))
5954 else if (unformat (i, "tag %s", &tag))
5956 else if (unformat (i, "address %U/%d",
5957 unformat_ip4_address, &ip4_address, &ip4_mask_width))
5958 ip4_address_set = 1;
5959 else if (unformat (i, "address %U/%d",
5960 unformat_ip6_address, &ip6_address, &ip6_mask_width))
5961 ip6_address_set = 1;
5968 errmsg ("missing tap name");
5971 if (vec_len (tap_name) > 63)
5973 errmsg ("tap name too long");
5976 vec_add1 (tap_name, 0);
5978 if (vec_len (tag) > 63)
5980 errmsg ("tag too long");
5984 /* Construct the API message */
5985 M (TAP_CONNECT, mp);
5987 mp->use_random_mac = random_mac;
5988 clib_memcpy (mp->mac_address, mac_address, 6);
5989 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5991 clib_memcpy (mp->tag, tag, vec_len (tag));
5993 if (ip4_address_set)
5995 mp->ip4_address_set = 1;
5996 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
5997 mp->ip4_mask_width = ip4_mask_width;
5999 if (ip6_address_set)
6001 mp->ip6_address_set = 1;
6002 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6003 mp->ip6_mask_width = ip6_mask_width;
6006 vec_free (tap_name);
6012 /* Wait for a reply... */
6018 api_tap_modify (vat_main_t * vam)
6020 unformat_input_t *i = vam->input;
6021 vl_api_tap_modify_t *mp;
6026 u32 sw_if_index = ~0;
6027 u8 sw_if_index_set = 0;
6030 memset (mac_address, 0, sizeof (mac_address));
6032 /* Parse args required to build the message */
6033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6035 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6036 sw_if_index_set = 1;
6037 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6038 sw_if_index_set = 1;
6039 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6043 else if (unformat (i, "random-mac"))
6045 else if (unformat (i, "tapname %s", &tap_name))
6051 if (sw_if_index_set == 0)
6053 errmsg ("missing vpp interface name");
6058 errmsg ("missing tap name");
6061 if (vec_len (tap_name) > 63)
6063 errmsg ("tap name too long");
6065 vec_add1 (tap_name, 0);
6067 /* Construct the API message */
6070 mp->use_random_mac = random_mac;
6071 mp->sw_if_index = ntohl (sw_if_index);
6072 clib_memcpy (mp->mac_address, mac_address, 6);
6073 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6074 vec_free (tap_name);
6079 /* Wait for a reply... */
6085 api_tap_delete (vat_main_t * vam)
6087 unformat_input_t *i = vam->input;
6088 vl_api_tap_delete_t *mp;
6089 u32 sw_if_index = ~0;
6090 u8 sw_if_index_set = 0;
6093 /* Parse args required to build the message */
6094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6096 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6097 sw_if_index_set = 1;
6098 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6099 sw_if_index_set = 1;
6104 if (sw_if_index_set == 0)
6106 errmsg ("missing vpp interface name");
6110 /* Construct the API message */
6113 mp->sw_if_index = ntohl (sw_if_index);
6118 /* Wait for a reply... */
6124 api_ip_add_del_route (vat_main_t * vam)
6126 unformat_input_t *i = vam->input;
6127 vl_api_ip_add_del_route_t *mp;
6128 u32 sw_if_index = ~0, vrf_id = 0;
6130 u8 is_local = 0, is_drop = 0;
6131 u8 is_unreach = 0, is_prohibit = 0;
6132 u8 create_vrf_if_needed = 0;
6134 u32 next_hop_weight = 1;
6136 u8 is_multipath = 0;
6138 u8 address_length_set = 0;
6139 u32 next_hop_table_id = 0;
6140 u32 resolve_attempts = 0;
6141 u32 dst_address_length = 0;
6142 u8 next_hop_set = 0;
6143 ip4_address_t v4_dst_address, v4_next_hop_address;
6144 ip6_address_t v6_dst_address, v6_next_hop_address;
6148 u32 random_add_del = 0;
6149 u32 *random_vector = 0;
6151 u32 random_seed = 0xdeaddabe;
6152 u32 classify_table_index = ~0;
6154 u8 resolve_host = 0, resolve_attached = 0;
6155 mpls_label_t *next_hop_out_label_stack = NULL;
6156 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6157 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6159 /* Parse args required to build the message */
6160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6166 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6171 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6176 else if (unformat (i, "/%d", &dst_address_length))
6178 address_length_set = 1;
6181 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6182 &v4_next_hop_address))
6186 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6187 &v6_next_hop_address))
6191 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6193 else if (unformat (i, "weight %d", &next_hop_weight))
6195 else if (unformat (i, "drop"))
6199 else if (unformat (i, "null-send-unreach"))
6203 else if (unformat (i, "null-send-prohibit"))
6207 else if (unformat (i, "local"))
6211 else if (unformat (i, "classify %d", &classify_table_index))
6215 else if (unformat (i, "del"))
6217 else if (unformat (i, "add"))
6219 else if (unformat (i, "not-last"))
6221 else if (unformat (i, "resolve-via-host"))
6223 else if (unformat (i, "resolve-via-attached"))
6224 resolve_attached = 1;
6225 else if (unformat (i, "multipath"))
6227 else if (unformat (i, "vrf %d", &vrf_id))
6229 else if (unformat (i, "create-vrf"))
6230 create_vrf_if_needed = 1;
6231 else if (unformat (i, "count %d", &count))
6233 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6235 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6237 else if (unformat (i, "out-label %d", &next_hop_out_label))
6238 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6239 else if (unformat (i, "via-label %d", &next_hop_via_label))
6241 else if (unformat (i, "random"))
6243 else if (unformat (i, "seed %d", &random_seed))
6247 clib_warning ("parse error '%U'", format_unformat_error, i);
6252 if (!next_hop_set && !is_drop && !is_local &&
6253 !is_classify && !is_unreach && !is_prohibit &&
6254 MPLS_LABEL_INVALID == next_hop_via_label)
6257 ("next hop / local / drop / unreach / prohibit / classify not set");
6261 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6263 errmsg ("next hop and next-hop via label set");
6266 if (address_set == 0)
6268 errmsg ("missing addresses");
6272 if (address_length_set == 0)
6274 errmsg ("missing address length");
6278 /* Generate a pile of unique, random routes */
6281 u32 this_random_address;
6282 random_hash = hash_create (count, sizeof (uword));
6284 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6285 for (j = 0; j <= count; j++)
6289 this_random_address = random_u32 (&random_seed);
6290 this_random_address =
6291 clib_host_to_net_u32 (this_random_address);
6293 while (hash_get (random_hash, this_random_address));
6294 vec_add1 (random_vector, this_random_address);
6295 hash_set (random_hash, this_random_address, 1);
6297 hash_free (random_hash);
6298 v4_dst_address.as_u32 = random_vector[0];
6303 /* Turn on async mode */
6304 vam->async_mode = 1;
6305 vam->async_errors = 0;
6306 before = vat_time_now (vam);
6309 for (j = 0; j < count; j++)
6311 /* Construct the API message */
6312 M2 (IP_ADD_DEL_ROUTE, mp,
6313 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6315 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6316 mp->table_id = ntohl (vrf_id);
6317 mp->create_vrf_if_needed = create_vrf_if_needed;
6319 mp->is_add = is_add;
6320 mp->is_drop = is_drop;
6321 mp->is_unreach = is_unreach;
6322 mp->is_prohibit = is_prohibit;
6323 mp->is_ipv6 = is_ipv6;
6324 mp->is_local = is_local;
6325 mp->is_classify = is_classify;
6326 mp->is_multipath = is_multipath;
6327 mp->is_resolve_host = resolve_host;
6328 mp->is_resolve_attached = resolve_attached;
6329 mp->not_last = not_last;
6330 mp->next_hop_weight = next_hop_weight;
6331 mp->dst_address_length = dst_address_length;
6332 mp->next_hop_table_id = ntohl (next_hop_table_id);
6333 mp->classify_table_index = ntohl (classify_table_index);
6334 mp->next_hop_via_label = ntohl (next_hop_via_label);
6335 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6336 if (0 != mp->next_hop_n_out_labels)
6338 memcpy (mp->next_hop_out_label_stack,
6339 next_hop_out_label_stack,
6340 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6341 vec_free (next_hop_out_label_stack);
6346 clib_memcpy (mp->dst_address, &v6_dst_address,
6347 sizeof (v6_dst_address));
6349 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6350 sizeof (v6_next_hop_address));
6351 increment_v6_address (&v6_dst_address);
6355 clib_memcpy (mp->dst_address, &v4_dst_address,
6356 sizeof (v4_dst_address));
6358 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6359 sizeof (v4_next_hop_address));
6361 v4_dst_address.as_u32 = random_vector[j + 1];
6363 increment_v4_address (&v4_dst_address);
6367 /* If we receive SIGTERM, stop now... */
6372 /* When testing multiple add/del ops, use a control-ping to sync */
6375 vl_api_control_ping_t *mp_ping;
6379 /* Shut off async mode */
6380 vam->async_mode = 0;
6382 M (CONTROL_PING, mp_ping);
6385 timeout = vat_time_now (vam) + 1.0;
6386 while (vat_time_now (vam) < timeout)
6387 if (vam->result_ready == 1)
6392 if (vam->retval == -99)
6395 if (vam->async_errors > 0)
6397 errmsg ("%d asynchronous errors", vam->async_errors);
6400 vam->async_errors = 0;
6401 after = vat_time_now (vam);
6403 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6407 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6408 count, after - before, count / (after - before));
6414 /* Wait for a reply... */
6419 /* Return the good/bad news */
6420 return (vam->retval);
6424 api_ip_mroute_add_del (vat_main_t * vam)
6426 unformat_input_t *i = vam->input;
6427 vl_api_ip_mroute_add_del_t *mp;
6428 u32 sw_if_index = ~0, vrf_id = 0;
6431 u8 create_vrf_if_needed = 0;
6434 u32 grp_address_length = 0;
6435 ip4_address_t v4_grp_address, v4_src_address;
6436 ip6_address_t v6_grp_address, v6_src_address;
6437 mfib_itf_flags_t iflags = 0;
6438 mfib_entry_flags_t eflags = 0;
6441 /* Parse args required to build the message */
6442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6444 if (unformat (i, "sw_if_index %d", &sw_if_index))
6446 else if (unformat (i, "%U %U",
6447 unformat_ip4_address, &v4_src_address,
6448 unformat_ip4_address, &v4_grp_address))
6450 grp_address_length = 64;
6454 else if (unformat (i, "%U %U",
6455 unformat_ip6_address, &v6_src_address,
6456 unformat_ip6_address, &v6_grp_address))
6458 grp_address_length = 256;
6462 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6464 memset (&v4_src_address, 0, sizeof (v4_src_address));
6465 grp_address_length = 32;
6469 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6471 memset (&v6_src_address, 0, sizeof (v6_src_address));
6472 grp_address_length = 128;
6476 else if (unformat (i, "/%d", &grp_address_length))
6478 else if (unformat (i, "local"))
6482 else if (unformat (i, "del"))
6484 else if (unformat (i, "add"))
6486 else if (unformat (i, "vrf %d", &vrf_id))
6488 else if (unformat (i, "create-vrf"))
6489 create_vrf_if_needed = 1;
6490 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6492 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6496 clib_warning ("parse error '%U'", format_unformat_error, i);
6501 if (address_set == 0)
6503 errmsg ("missing addresses\n");
6507 /* Construct the API message */
6508 M (IP_MROUTE_ADD_DEL, mp);
6510 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6511 mp->table_id = ntohl (vrf_id);
6512 mp->create_vrf_if_needed = create_vrf_if_needed;
6514 mp->is_add = is_add;
6515 mp->is_ipv6 = is_ipv6;
6516 mp->is_local = is_local;
6517 mp->itf_flags = ntohl (iflags);
6518 mp->entry_flags = ntohl (eflags);
6519 mp->grp_address_length = grp_address_length;
6520 mp->grp_address_length = ntohs (mp->grp_address_length);
6524 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6525 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6529 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6530 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6536 /* Wait for a reply... */
6542 api_mpls_route_add_del (vat_main_t * vam)
6544 unformat_input_t *i = vam->input;
6545 vl_api_mpls_route_add_del_t *mp;
6546 u32 sw_if_index = ~0, table_id = 0;
6547 u8 create_table_if_needed = 0;
6549 u32 next_hop_weight = 1;
6550 u8 is_multipath = 0;
6551 u32 next_hop_table_id = 0;
6552 u8 next_hop_set = 0;
6553 ip4_address_t v4_next_hop_address = {
6556 ip6_address_t v6_next_hop_address = { {0} };
6560 u32 classify_table_index = ~0;
6562 u8 resolve_host = 0, resolve_attached = 0;
6563 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6564 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6565 mpls_label_t *next_hop_out_label_stack = NULL;
6566 mpls_label_t local_label = MPLS_LABEL_INVALID;
6568 u8 next_hop_proto_is_ip4 = 1;
6570 /* Parse args required to build the message */
6571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6573 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6575 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6577 else if (unformat (i, "%d", &local_label))
6579 else if (unformat (i, "eos"))
6581 else if (unformat (i, "non-eos"))
6583 else if (unformat (i, "via %U", unformat_ip4_address,
6584 &v4_next_hop_address))
6587 next_hop_proto_is_ip4 = 1;
6589 else if (unformat (i, "via %U", unformat_ip6_address,
6590 &v6_next_hop_address))
6593 next_hop_proto_is_ip4 = 0;
6595 else if (unformat (i, "weight %d", &next_hop_weight))
6597 else if (unformat (i, "create-table"))
6598 create_table_if_needed = 1;
6599 else if (unformat (i, "classify %d", &classify_table_index))
6603 else if (unformat (i, "del"))
6605 else if (unformat (i, "add"))
6607 else if (unformat (i, "resolve-via-host"))
6609 else if (unformat (i, "resolve-via-attached"))
6610 resolve_attached = 1;
6611 else if (unformat (i, "multipath"))
6613 else if (unformat (i, "count %d", &count))
6615 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6618 next_hop_proto_is_ip4 = 1;
6620 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6623 next_hop_proto_is_ip4 = 0;
6625 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6627 else if (unformat (i, "via-label %d", &next_hop_via_label))
6629 else if (unformat (i, "out-label %d", &next_hop_out_label))
6630 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6633 clib_warning ("parse error '%U'", format_unformat_error, i);
6638 if (!next_hop_set && !is_classify)
6640 errmsg ("next hop / classify not set");
6644 if (MPLS_LABEL_INVALID == local_label)
6646 errmsg ("missing label");
6652 /* Turn on async mode */
6653 vam->async_mode = 1;
6654 vam->async_errors = 0;
6655 before = vat_time_now (vam);
6658 for (j = 0; j < count; j++)
6660 /* Construct the API message */
6661 M2 (MPLS_ROUTE_ADD_DEL, mp,
6662 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6664 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6665 mp->mr_table_id = ntohl (table_id);
6666 mp->mr_create_table_if_needed = create_table_if_needed;
6668 mp->mr_is_add = is_add;
6669 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6670 mp->mr_is_classify = is_classify;
6671 mp->mr_is_multipath = is_multipath;
6672 mp->mr_is_resolve_host = resolve_host;
6673 mp->mr_is_resolve_attached = resolve_attached;
6674 mp->mr_next_hop_weight = next_hop_weight;
6675 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6676 mp->mr_classify_table_index = ntohl (classify_table_index);
6677 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6678 mp->mr_label = ntohl (local_label);
6679 mp->mr_eos = is_eos;
6681 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6682 if (0 != mp->mr_next_hop_n_out_labels)
6684 memcpy (mp->mr_next_hop_out_label_stack,
6685 next_hop_out_label_stack,
6686 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6687 vec_free (next_hop_out_label_stack);
6692 if (next_hop_proto_is_ip4)
6694 clib_memcpy (mp->mr_next_hop,
6695 &v4_next_hop_address,
6696 sizeof (v4_next_hop_address));
6700 clib_memcpy (mp->mr_next_hop,
6701 &v6_next_hop_address,
6702 sizeof (v6_next_hop_address));
6709 /* If we receive SIGTERM, stop now... */
6714 /* When testing multiple add/del ops, use a control-ping to sync */
6717 vl_api_control_ping_t *mp_ping;
6721 /* Shut off async mode */
6722 vam->async_mode = 0;
6724 M (CONTROL_PING, mp_ping);
6727 timeout = vat_time_now (vam) + 1.0;
6728 while (vat_time_now (vam) < timeout)
6729 if (vam->result_ready == 1)
6734 if (vam->retval == -99)
6737 if (vam->async_errors > 0)
6739 errmsg ("%d asynchronous errors", vam->async_errors);
6742 vam->async_errors = 0;
6743 after = vat_time_now (vam);
6745 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6749 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6750 count, after - before, count / (after - before));
6756 /* Wait for a reply... */
6761 /* Return the good/bad news */
6762 return (vam->retval);
6766 api_mpls_ip_bind_unbind (vat_main_t * vam)
6768 unformat_input_t *i = vam->input;
6769 vl_api_mpls_ip_bind_unbind_t *mp;
6770 u32 ip_table_id = 0;
6771 u8 create_table_if_needed = 0;
6774 ip4_address_t v4_address;
6775 ip6_address_t v6_address;
6778 mpls_label_t local_label = MPLS_LABEL_INVALID;
6781 /* Parse args required to build the message */
6782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6784 if (unformat (i, "%U/%d", unformat_ip4_address,
6785 &v4_address, &address_length))
6790 else if (unformat (i, "%U/%d", unformat_ip6_address,
6791 &v6_address, &address_length))
6796 else if (unformat (i, "%d", &local_label))
6798 else if (unformat (i, "create-table"))
6799 create_table_if_needed = 1;
6800 else if (unformat (i, "table-id %d", &ip_table_id))
6802 else if (unformat (i, "unbind"))
6804 else if (unformat (i, "bind"))
6808 clib_warning ("parse error '%U'", format_unformat_error, i);
6815 errmsg ("IP addres not set");
6819 if (MPLS_LABEL_INVALID == local_label)
6821 errmsg ("missing label");
6825 /* Construct the API message */
6826 M (MPLS_IP_BIND_UNBIND, mp);
6828 mp->mb_create_table_if_needed = create_table_if_needed;
6829 mp->mb_is_bind = is_bind;
6830 mp->mb_is_ip4 = is_ip4;
6831 mp->mb_ip_table_id = ntohl (ip_table_id);
6832 mp->mb_mpls_table_id = 0;
6833 mp->mb_label = ntohl (local_label);
6834 mp->mb_address_length = address_length;
6837 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6839 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6844 /* Wait for a reply... */
6850 api_proxy_arp_add_del (vat_main_t * vam)
6852 unformat_input_t *i = vam->input;
6853 vl_api_proxy_arp_add_del_t *mp;
6856 ip4_address_t lo, hi;
6860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6862 if (unformat (i, "vrf %d", &vrf_id))
6864 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6865 unformat_ip4_address, &hi))
6867 else if (unformat (i, "del"))
6871 clib_warning ("parse error '%U'", format_unformat_error, i);
6878 errmsg ("address range not set");
6882 M (PROXY_ARP_ADD_DEL, mp);
6884 mp->vrf_id = ntohl (vrf_id);
6885 mp->is_add = is_add;
6886 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6887 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6895 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6897 unformat_input_t *i = vam->input;
6898 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6901 u8 sw_if_index_set = 0;
6904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6907 sw_if_index_set = 1;
6908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6909 sw_if_index_set = 1;
6910 else if (unformat (i, "enable"))
6912 else if (unformat (i, "disable"))
6916 clib_warning ("parse error '%U'", format_unformat_error, i);
6921 if (sw_if_index_set == 0)
6923 errmsg ("missing interface name or sw_if_index");
6927 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
6929 mp->sw_if_index = ntohl (sw_if_index);
6930 mp->enable_disable = enable;
6938 api_mpls_tunnel_add_del (vat_main_t * vam)
6940 unformat_input_t *i = vam->input;
6941 vl_api_mpls_tunnel_add_del_t *mp;
6945 u32 sw_if_index = ~0;
6946 u32 next_hop_sw_if_index = ~0;
6947 u32 next_hop_proto_is_ip4 = 1;
6949 u32 next_hop_table_id = 0;
6950 ip4_address_t v4_next_hop_address = {
6953 ip6_address_t v6_next_hop_address = { {0} };
6954 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6959 if (unformat (i, "add"))
6961 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6963 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6965 else if (unformat (i, "via %U",
6966 unformat_ip4_address, &v4_next_hop_address))
6968 next_hop_proto_is_ip4 = 1;
6970 else if (unformat (i, "via %U",
6971 unformat_ip6_address, &v6_next_hop_address))
6973 next_hop_proto_is_ip4 = 0;
6975 else if (unformat (i, "l2-only"))
6977 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6979 else if (unformat (i, "out-label %d", &next_hop_out_label))
6980 vec_add1 (labels, ntohl (next_hop_out_label));
6983 clib_warning ("parse error '%U'", format_unformat_error, i);
6988 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
6990 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6991 mp->mt_sw_if_index = ntohl (sw_if_index);
6992 mp->mt_is_add = is_add;
6993 mp->mt_l2_only = l2_only;
6994 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6995 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6997 mp->mt_next_hop_n_out_labels = vec_len (labels);
6999 if (0 != mp->mt_next_hop_n_out_labels)
7001 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7002 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7006 if (next_hop_proto_is_ip4)
7008 clib_memcpy (mp->mt_next_hop,
7009 &v4_next_hop_address, sizeof (v4_next_hop_address));
7013 clib_memcpy (mp->mt_next_hop,
7014 &v6_next_hop_address, sizeof (v6_next_hop_address));
7023 api_sw_interface_set_unnumbered (vat_main_t * vam)
7025 unformat_input_t *i = vam->input;
7026 vl_api_sw_interface_set_unnumbered_t *mp;
7028 u32 unnum_sw_index = ~0;
7030 u8 sw_if_index_set = 0;
7033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7035 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7036 sw_if_index_set = 1;
7037 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7038 sw_if_index_set = 1;
7039 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7041 else if (unformat (i, "del"))
7045 clib_warning ("parse error '%U'", format_unformat_error, i);
7050 if (sw_if_index_set == 0)
7052 errmsg ("missing interface name or sw_if_index");
7056 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7058 mp->sw_if_index = ntohl (sw_if_index);
7059 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7060 mp->is_add = is_add;
7068 api_ip_neighbor_add_del (vat_main_t * vam)
7070 unformat_input_t *i = vam->input;
7071 vl_api_ip_neighbor_add_del_t *mp;
7073 u8 sw_if_index_set = 0;
7079 u8 v4_address_set = 0;
7080 u8 v6_address_set = 0;
7081 ip4_address_t v4address;
7082 ip6_address_t v6address;
7085 memset (mac_address, 0, sizeof (mac_address));
7087 /* Parse args required to build the message */
7088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7090 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7094 else if (unformat (i, "del"))
7097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7098 sw_if_index_set = 1;
7099 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7100 sw_if_index_set = 1;
7101 else if (unformat (i, "is_static"))
7103 else if (unformat (i, "vrf %d", &vrf_id))
7105 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7107 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7111 clib_warning ("parse error '%U'", format_unformat_error, i);
7116 if (sw_if_index_set == 0)
7118 errmsg ("missing interface name or sw_if_index");
7121 if (v4_address_set && v6_address_set)
7123 errmsg ("both v4 and v6 addresses set");
7126 if (!v4_address_set && !v6_address_set)
7128 errmsg ("no address set");
7132 /* Construct the API message */
7133 M (IP_NEIGHBOR_ADD_DEL, mp);
7135 mp->sw_if_index = ntohl (sw_if_index);
7136 mp->is_add = is_add;
7137 mp->vrf_id = ntohl (vrf_id);
7138 mp->is_static = is_static;
7140 clib_memcpy (mp->mac_address, mac_address, 6);
7144 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7148 /* mp->is_ipv6 = 0; via memset in M macro above */
7149 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7155 /* Wait for a reply, return good/bad news */
7161 api_reset_vrf (vat_main_t * vam)
7163 unformat_input_t *i = vam->input;
7164 vl_api_reset_vrf_t *mp;
7170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7172 if (unformat (i, "vrf %d", &vrf_id))
7174 else if (unformat (i, "ipv6"))
7178 clib_warning ("parse error '%U'", format_unformat_error, i);
7183 if (vrf_id_set == 0)
7185 errmsg ("missing vrf id");
7191 mp->vrf_id = ntohl (vrf_id);
7192 mp->is_ipv6 = is_ipv6;
7200 api_create_vlan_subif (vat_main_t * vam)
7202 unformat_input_t *i = vam->input;
7203 vl_api_create_vlan_subif_t *mp;
7205 u8 sw_if_index_set = 0;
7210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7212 if (unformat (i, "sw_if_index %d", &sw_if_index))
7213 sw_if_index_set = 1;
7215 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7216 sw_if_index_set = 1;
7217 else if (unformat (i, "vlan %d", &vlan_id))
7221 clib_warning ("parse error '%U'", format_unformat_error, i);
7226 if (sw_if_index_set == 0)
7228 errmsg ("missing interface name or sw_if_index");
7232 if (vlan_id_set == 0)
7234 errmsg ("missing vlan_id");
7237 M (CREATE_VLAN_SUBIF, mp);
7239 mp->sw_if_index = ntohl (sw_if_index);
7240 mp->vlan_id = ntohl (vlan_id);
7247 #define foreach_create_subif_bit \
7254 _(outer_vlan_id_any) \
7255 _(inner_vlan_id_any)
7258 api_create_subif (vat_main_t * vam)
7260 unformat_input_t *i = vam->input;
7261 vl_api_create_subif_t *mp;
7263 u8 sw_if_index_set = 0;
7270 u32 exact_match = 0;
7271 u32 default_sub = 0;
7272 u32 outer_vlan_id_any = 0;
7273 u32 inner_vlan_id_any = 0;
7275 u16 outer_vlan_id = 0;
7276 u16 inner_vlan_id = 0;
7279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7281 if (unformat (i, "sw_if_index %d", &sw_if_index))
7282 sw_if_index_set = 1;
7284 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7285 sw_if_index_set = 1;
7286 else if (unformat (i, "sub_id %d", &sub_id))
7288 else if (unformat (i, "outer_vlan_id %d", &tmp))
7289 outer_vlan_id = tmp;
7290 else if (unformat (i, "inner_vlan_id %d", &tmp))
7291 inner_vlan_id = tmp;
7293 #define _(a) else if (unformat (i, #a)) a = 1 ;
7294 foreach_create_subif_bit
7298 clib_warning ("parse error '%U'", format_unformat_error, i);
7303 if (sw_if_index_set == 0)
7305 errmsg ("missing interface name or sw_if_index");
7309 if (sub_id_set == 0)
7311 errmsg ("missing sub_id");
7314 M (CREATE_SUBIF, mp);
7316 mp->sw_if_index = ntohl (sw_if_index);
7317 mp->sub_id = ntohl (sub_id);
7319 #define _(a) mp->a = a;
7320 foreach_create_subif_bit;
7323 mp->outer_vlan_id = ntohs (outer_vlan_id);
7324 mp->inner_vlan_id = ntohs (inner_vlan_id);
7332 api_oam_add_del (vat_main_t * vam)
7334 unformat_input_t *i = vam->input;
7335 vl_api_oam_add_del_t *mp;
7338 ip4_address_t src, dst;
7343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7345 if (unformat (i, "vrf %d", &vrf_id))
7347 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7349 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7351 else if (unformat (i, "del"))
7355 clib_warning ("parse error '%U'", format_unformat_error, i);
7362 errmsg ("missing src addr");
7368 errmsg ("missing dst addr");
7372 M (OAM_ADD_DEL, mp);
7374 mp->vrf_id = ntohl (vrf_id);
7375 mp->is_add = is_add;
7376 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7377 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7385 api_reset_fib (vat_main_t * vam)
7387 unformat_input_t *i = vam->input;
7388 vl_api_reset_fib_t *mp;
7394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7396 if (unformat (i, "vrf %d", &vrf_id))
7398 else if (unformat (i, "ipv6"))
7402 clib_warning ("parse error '%U'", format_unformat_error, i);
7407 if (vrf_id_set == 0)
7409 errmsg ("missing vrf id");
7415 mp->vrf_id = ntohl (vrf_id);
7416 mp->is_ipv6 = is_ipv6;
7424 api_dhcp_proxy_config (vat_main_t * vam)
7426 unformat_input_t *i = vam->input;
7427 vl_api_dhcp_proxy_config_t *mp;
7429 u32 server_vrf_id = 0;
7431 u8 v4_address_set = 0;
7432 u8 v6_address_set = 0;
7433 ip4_address_t v4address;
7434 ip6_address_t v6address;
7435 u8 v4_src_address_set = 0;
7436 u8 v6_src_address_set = 0;
7437 ip4_address_t v4srcaddress;
7438 ip6_address_t v6srcaddress;
7441 /* Parse args required to build the message */
7442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7444 if (unformat (i, "del"))
7446 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7448 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7450 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7452 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7454 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7455 v4_src_address_set = 1;
7456 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7457 v6_src_address_set = 1;
7462 if (v4_address_set && v6_address_set)
7464 errmsg ("both v4 and v6 server addresses set");
7467 if (!v4_address_set && !v6_address_set)
7469 errmsg ("no server addresses set");
7473 if (v4_src_address_set && v6_src_address_set)
7475 errmsg ("both v4 and v6 src addresses set");
7478 if (!v4_src_address_set && !v6_src_address_set)
7480 errmsg ("no src addresses set");
7484 if (!(v4_src_address_set && v4_address_set) &&
7485 !(v6_src_address_set && v6_address_set))
7487 errmsg ("no matching server and src addresses set");
7491 /* Construct the API message */
7492 M (DHCP_PROXY_CONFIG, mp);
7494 mp->is_add = is_add;
7495 mp->rx_vrf_id = ntohl (rx_vrf_id);
7496 mp->server_vrf_id = ntohl (server_vrf_id);
7500 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7501 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7505 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7506 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7512 /* Wait for a reply, return good/bad news */
7517 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7518 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7521 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7523 vat_main_t *vam = &vat_main;
7527 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7528 ntohl (mp->rx_vrf_id),
7529 ntohl (mp->server_vrf_id),
7530 format_ip6_address, mp->dhcp_server,
7531 format_ip6_address, mp->dhcp_src_address,
7532 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7535 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7536 ntohl (mp->rx_vrf_id),
7537 ntohl (mp->server_vrf_id),
7538 format_ip4_address, mp->dhcp_server,
7539 format_ip4_address, mp->dhcp_src_address,
7540 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7543 static void vl_api_dhcp_proxy_details_t_handler_json
7544 (vl_api_dhcp_proxy_details_t * mp)
7546 vat_main_t *vam = &vat_main;
7547 vat_json_node_t *node = NULL;
7549 struct in6_addr ip6;
7551 if (VAT_JSON_ARRAY != vam->json_tree.type)
7553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7554 vat_json_init_array (&vam->json_tree);
7556 node = vat_json_array_add (&vam->json_tree);
7558 vat_json_init_object (node);
7559 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7560 vat_json_object_add_uint (node, "server-table-id",
7561 ntohl (mp->server_vrf_id));
7564 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7565 vat_json_object_add_ip6 (node, "server_address", ip6);
7566 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7567 vat_json_object_add_ip6 (node, "src_address", ip6);
7571 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7572 vat_json_object_add_ip4 (node, "server_address", ip4);
7573 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7574 vat_json_object_add_ip4 (node, "src_address", ip4);
7576 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7577 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7581 api_dhcp_proxy_dump (vat_main_t * vam)
7583 unformat_input_t *i = vam->input;
7584 vl_api_control_ping_t *mp_ping;
7585 vl_api_dhcp_proxy_dump_t *mp;
7589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7591 if (unformat (i, "ipv6"))
7595 clib_warning ("parse error '%U'", format_unformat_error, i);
7600 M (DHCP_PROXY_DUMP, mp);
7602 mp->is_ip6 = is_ipv6;
7605 /* Use a control ping for synchronization */
7606 M (CONTROL_PING, mp_ping);
7614 api_dhcp_proxy_set_vss (vat_main_t * vam)
7616 unformat_input_t *i = vam->input;
7617 vl_api_dhcp_proxy_set_vss_t *mp;
7628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7630 if (unformat (i, "tbl_id %d", &tbl_id))
7632 if (unformat (i, "fib_id %d", &fib_id))
7634 if (unformat (i, "oui %d", &oui))
7636 else if (unformat (i, "ipv6"))
7638 else if (unformat (i, "del"))
7642 clib_warning ("parse error '%U'", format_unformat_error, i);
7647 if (tbl_id_set == 0)
7649 errmsg ("missing tbl id");
7653 if (fib_id_set == 0)
7655 errmsg ("missing fib id");
7660 errmsg ("missing oui");
7664 M (DHCP_PROXY_SET_VSS, mp);
7665 mp->tbl_id = ntohl (tbl_id);
7666 mp->fib_id = ntohl (fib_id);
7667 mp->oui = ntohl (oui);
7668 mp->is_ipv6 = is_ipv6;
7669 mp->is_add = is_add;
7677 api_dhcp_client_config (vat_main_t * vam)
7679 unformat_input_t *i = vam->input;
7680 vl_api_dhcp_client_config_t *mp;
7682 u8 sw_if_index_set = 0;
7685 u8 disable_event = 0;
7688 /* Parse args required to build the message */
7689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7691 if (unformat (i, "del"))
7694 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7695 sw_if_index_set = 1;
7696 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7697 sw_if_index_set = 1;
7698 else if (unformat (i, "hostname %s", &hostname))
7700 else if (unformat (i, "disable_event"))
7706 if (sw_if_index_set == 0)
7708 errmsg ("missing interface name or sw_if_index");
7712 if (vec_len (hostname) > 63)
7714 errmsg ("hostname too long");
7716 vec_add1 (hostname, 0);
7718 /* Construct the API message */
7719 M (DHCP_CLIENT_CONFIG, mp);
7721 mp->sw_if_index = ntohl (sw_if_index);
7722 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7723 vec_free (hostname);
7724 mp->is_add = is_add;
7725 mp->want_dhcp_event = disable_event ? 0 : 1;
7726 mp->pid = getpid ();
7731 /* Wait for a reply, return good/bad news */
7737 api_set_ip_flow_hash (vat_main_t * vam)
7739 unformat_input_t *i = vam->input;
7740 vl_api_set_ip_flow_hash_t *mp;
7752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7754 if (unformat (i, "vrf %d", &vrf_id))
7756 else if (unformat (i, "ipv6"))
7758 else if (unformat (i, "src"))
7760 else if (unformat (i, "dst"))
7762 else if (unformat (i, "sport"))
7764 else if (unformat (i, "dport"))
7766 else if (unformat (i, "proto"))
7768 else if (unformat (i, "reverse"))
7773 clib_warning ("parse error '%U'", format_unformat_error, i);
7778 if (vrf_id_set == 0)
7780 errmsg ("missing vrf id");
7784 M (SET_IP_FLOW_HASH, mp);
7790 mp->reverse = reverse;
7791 mp->vrf_id = ntohl (vrf_id);
7792 mp->is_ipv6 = is_ipv6;
7800 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7802 unformat_input_t *i = vam->input;
7803 vl_api_sw_interface_ip6_enable_disable_t *mp;
7805 u8 sw_if_index_set = 0;
7809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7811 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7812 sw_if_index_set = 1;
7813 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7814 sw_if_index_set = 1;
7815 else if (unformat (i, "enable"))
7817 else if (unformat (i, "disable"))
7821 clib_warning ("parse error '%U'", format_unformat_error, i);
7826 if (sw_if_index_set == 0)
7828 errmsg ("missing interface name or sw_if_index");
7832 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7834 mp->sw_if_index = ntohl (sw_if_index);
7835 mp->enable = enable;
7843 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7845 unformat_input_t *i = vam->input;
7846 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7848 u8 sw_if_index_set = 0;
7849 u8 v6_address_set = 0;
7850 ip6_address_t v6address;
7853 /* Parse args required to build the message */
7854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7857 sw_if_index_set = 1;
7858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7859 sw_if_index_set = 1;
7860 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7866 if (sw_if_index_set == 0)
7868 errmsg ("missing interface name or sw_if_index");
7871 if (!v6_address_set)
7873 errmsg ("no address set");
7877 /* Construct the API message */
7878 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
7880 mp->sw_if_index = ntohl (sw_if_index);
7881 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7886 /* Wait for a reply, return good/bad news */
7893 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7895 unformat_input_t *i = vam->input;
7896 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7898 u8 sw_if_index_set = 0;
7899 u32 address_length = 0;
7900 u8 v6_address_set = 0;
7901 ip6_address_t v6address;
7903 u8 no_advertise = 0;
7905 u8 no_autoconfig = 0;
7908 u32 val_lifetime = 0;
7909 u32 pref_lifetime = 0;
7912 /* Parse args required to build the message */
7913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7915 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7916 sw_if_index_set = 1;
7917 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7918 sw_if_index_set = 1;
7919 else if (unformat (i, "%U/%d",
7920 unformat_ip6_address, &v6address, &address_length))
7922 else if (unformat (i, "val_life %d", &val_lifetime))
7924 else if (unformat (i, "pref_life %d", &pref_lifetime))
7926 else if (unformat (i, "def"))
7928 else if (unformat (i, "noadv"))
7930 else if (unformat (i, "offl"))
7932 else if (unformat (i, "noauto"))
7934 else if (unformat (i, "nolink"))
7936 else if (unformat (i, "isno"))
7940 clib_warning ("parse error '%U'", format_unformat_error, i);
7945 if (sw_if_index_set == 0)
7947 errmsg ("missing interface name or sw_if_index");
7950 if (!v6_address_set)
7952 errmsg ("no address set");
7956 /* Construct the API message */
7957 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
7959 mp->sw_if_index = ntohl (sw_if_index);
7960 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7961 mp->address_length = address_length;
7962 mp->use_default = use_default;
7963 mp->no_advertise = no_advertise;
7964 mp->off_link = off_link;
7965 mp->no_autoconfig = no_autoconfig;
7966 mp->no_onlink = no_onlink;
7968 mp->val_lifetime = ntohl (val_lifetime);
7969 mp->pref_lifetime = ntohl (pref_lifetime);
7974 /* Wait for a reply, return good/bad news */
7980 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7982 unformat_input_t *i = vam->input;
7983 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7985 u8 sw_if_index_set = 0;
7990 u8 send_unicast = 0;
7993 u8 default_router = 0;
7994 u32 max_interval = 0;
7995 u32 min_interval = 0;
7997 u32 initial_count = 0;
7998 u32 initial_interval = 0;
8002 /* Parse args required to build the message */
8003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8006 sw_if_index_set = 1;
8007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8008 sw_if_index_set = 1;
8009 else if (unformat (i, "maxint %d", &max_interval))
8011 else if (unformat (i, "minint %d", &min_interval))
8013 else if (unformat (i, "life %d", &lifetime))
8015 else if (unformat (i, "count %d", &initial_count))
8017 else if (unformat (i, "interval %d", &initial_interval))
8019 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8021 else if (unformat (i, "managed"))
8023 else if (unformat (i, "other"))
8025 else if (unformat (i, "ll"))
8027 else if (unformat (i, "send"))
8029 else if (unformat (i, "cease"))
8031 else if (unformat (i, "isno"))
8033 else if (unformat (i, "def"))
8037 clib_warning ("parse error '%U'", format_unformat_error, i);
8042 if (sw_if_index_set == 0)
8044 errmsg ("missing interface name or sw_if_index");
8048 /* Construct the API message */
8049 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8051 mp->sw_if_index = ntohl (sw_if_index);
8052 mp->max_interval = ntohl (max_interval);
8053 mp->min_interval = ntohl (min_interval);
8054 mp->lifetime = ntohl (lifetime);
8055 mp->initial_count = ntohl (initial_count);
8056 mp->initial_interval = ntohl (initial_interval);
8057 mp->suppress = suppress;
8058 mp->managed = managed;
8060 mp->ll_option = ll_option;
8061 mp->send_unicast = send_unicast;
8064 mp->default_router = default_router;
8069 /* Wait for a reply, return good/bad news */
8075 api_set_arp_neighbor_limit (vat_main_t * vam)
8077 unformat_input_t *i = vam->input;
8078 vl_api_set_arp_neighbor_limit_t *mp;
8084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8086 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8088 else if (unformat (i, "ipv6"))
8092 clib_warning ("parse error '%U'", format_unformat_error, i);
8099 errmsg ("missing limit value");
8103 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8105 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8106 mp->is_ipv6 = is_ipv6;
8114 api_l2_patch_add_del (vat_main_t * vam)
8116 unformat_input_t *i = vam->input;
8117 vl_api_l2_patch_add_del_t *mp;
8119 u8 rx_sw_if_index_set = 0;
8121 u8 tx_sw_if_index_set = 0;
8125 /* Parse args required to build the message */
8126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8128 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8129 rx_sw_if_index_set = 1;
8130 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8131 tx_sw_if_index_set = 1;
8132 else if (unformat (i, "rx"))
8134 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8136 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8138 rx_sw_if_index_set = 1;
8143 else if (unformat (i, "tx"))
8145 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8147 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8149 tx_sw_if_index_set = 1;
8154 else if (unformat (i, "del"))
8160 if (rx_sw_if_index_set == 0)
8162 errmsg ("missing rx interface name or rx_sw_if_index");
8166 if (tx_sw_if_index_set == 0)
8168 errmsg ("missing tx interface name or tx_sw_if_index");
8172 M (L2_PATCH_ADD_DEL, mp);
8174 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8175 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8176 mp->is_add = is_add;
8184 api_ioam_enable (vat_main_t * vam)
8186 unformat_input_t *input = vam->input;
8187 vl_api_ioam_enable_t *mp;
8189 int has_trace_option = 0;
8190 int has_pot_option = 0;
8191 int has_seqno_option = 0;
8192 int has_analyse_option = 0;
8195 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8197 if (unformat (input, "trace"))
8198 has_trace_option = 1;
8199 else if (unformat (input, "pot"))
8201 else if (unformat (input, "seqno"))
8202 has_seqno_option = 1;
8203 else if (unformat (input, "analyse"))
8204 has_analyse_option = 1;
8208 M (IOAM_ENABLE, mp);
8209 mp->id = htons (id);
8210 mp->seqno = has_seqno_option;
8211 mp->analyse = has_analyse_option;
8212 mp->pot_enable = has_pot_option;
8213 mp->trace_enable = has_trace_option;
8222 api_ioam_disable (vat_main_t * vam)
8224 vl_api_ioam_disable_t *mp;
8227 M (IOAM_DISABLE, mp);
8234 api_sr_tunnel_add_del (vat_main_t * vam)
8236 unformat_input_t *i = vam->input;
8237 vl_api_sr_tunnel_add_del_t *mp;
8240 ip6_address_t src_address;
8241 int src_address_set = 0;
8242 ip6_address_t dst_address;
8244 int dst_address_set = 0;
8246 u32 rx_table_id = 0;
8247 u32 tx_table_id = 0;
8248 ip6_address_t *segments = 0;
8249 ip6_address_t *this_seg;
8250 ip6_address_t *tags = 0;
8251 ip6_address_t *this_tag;
8252 ip6_address_t next_address, tag;
8254 u8 *policy_name = 0;
8257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8259 if (unformat (i, "del"))
8261 else if (unformat (i, "name %s", &name))
8263 else if (unformat (i, "policy %s", &policy_name))
8265 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8267 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8269 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8270 src_address_set = 1;
8271 else if (unformat (i, "dst %U/%d",
8272 unformat_ip6_address, &dst_address, &dst_mask_width))
8273 dst_address_set = 1;
8274 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8276 vec_add2 (segments, this_seg, 1);
8277 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8278 sizeof (*this_seg));
8280 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8282 vec_add2 (tags, this_tag, 1);
8283 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8285 else if (unformat (i, "clean"))
8286 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8287 else if (unformat (i, "protected"))
8288 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8289 else if (unformat (i, "InPE %d", &pl_index))
8291 if (pl_index <= 0 || pl_index > 4)
8293 pl_index_range_error:
8294 errmsg ("pl index %d out of range", pl_index);
8298 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8300 else if (unformat (i, "EgPE %d", &pl_index))
8302 if (pl_index <= 0 || pl_index > 4)
8303 goto pl_index_range_error;
8305 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8307 else if (unformat (i, "OrgSrc %d", &pl_index))
8309 if (pl_index <= 0 || pl_index > 4)
8310 goto pl_index_range_error;
8312 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8318 if (!src_address_set)
8320 errmsg ("src address required");
8324 if (!dst_address_set)
8326 errmsg ("dst address required");
8332 errmsg ("at least one sr segment required");
8336 M2 (SR_TUNNEL_ADD_DEL, mp,
8337 vec_len (segments) * sizeof (ip6_address_t)
8338 + vec_len (tags) * sizeof (ip6_address_t));
8340 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8341 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8342 mp->dst_mask_width = dst_mask_width;
8343 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8344 mp->n_segments = vec_len (segments);
8345 mp->n_tags = vec_len (tags);
8346 mp->is_add = is_del == 0;
8347 clib_memcpy (mp->segs_and_tags, segments,
8348 vec_len (segments) * sizeof (ip6_address_t));
8349 clib_memcpy (mp->segs_and_tags +
8350 vec_len (segments) * sizeof (ip6_address_t), tags,
8351 vec_len (tags) * sizeof (ip6_address_t));
8353 mp->outer_vrf_id = ntohl (rx_table_id);
8354 mp->inner_vrf_id = ntohl (tx_table_id);
8355 memcpy (mp->name, name, vec_len (name));
8356 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8358 vec_free (segments);
8367 api_sr_policy_add_del (vat_main_t * vam)
8369 unformat_input_t *input = vam->input;
8370 vl_api_sr_policy_add_del_t *mp;
8373 u8 *tunnel_name = 0;
8374 u8 **tunnel_names = 0;
8379 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8380 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8383 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8385 if (unformat (input, "del"))
8387 else if (unformat (input, "name %s", &name))
8389 else if (unformat (input, "tunnel %s", &tunnel_name))
8393 vec_add1 (tunnel_names, tunnel_name);
8395 - length = #bytes to store in serial vector
8396 - +1 = byte to store that length
8398 tunnel_names_length += (vec_len (tunnel_name) + 1);
8409 errmsg ("policy name required");
8413 if ((!tunnel_set) && (!is_del))
8415 errmsg ("tunnel name required");
8419 M2 (SR_POLICY_ADD_DEL, mp, tunnel_names_length);
8423 mp->is_add = !is_del;
8425 memcpy (mp->name, name, vec_len (name));
8426 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8427 u8 *serial_orig = 0;
8428 vec_validate (serial_orig, tunnel_names_length);
8429 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8430 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8432 for (j = 0; j < vec_len (tunnel_names); j++)
8434 tun_name_len = vec_len (tunnel_names[j]);
8435 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8436 serial_orig += 1; // Move along one byte to store the actual tunnel name
8437 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8438 serial_orig += tun_name_len; // Advance past the copy
8440 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8442 vec_free (tunnel_names);
8443 vec_free (tunnel_name);
8451 api_sr_multicast_map_add_del (vat_main_t * vam)
8453 unformat_input_t *input = vam->input;
8454 vl_api_sr_multicast_map_add_del_t *mp;
8456 ip6_address_t multicast_address;
8457 u8 *policy_name = 0;
8458 int multicast_address_set = 0;
8461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8463 if (unformat (input, "del"))
8467 (input, "address %U", unformat_ip6_address, &multicast_address))
8468 multicast_address_set = 1;
8469 else if (unformat (input, "sr-policy %s", &policy_name))
8475 if (!is_del && !policy_name)
8477 errmsg ("sr-policy name required");
8482 if (!multicast_address_set)
8484 errmsg ("address required");
8488 M (SR_MULTICAST_MAP_ADD_DEL, mp);
8490 mp->is_add = !is_del;
8491 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8492 clib_memcpy (mp->multicast_address, &multicast_address,
8493 sizeof (mp->multicast_address));
8496 vec_free (policy_name);
8504 #define foreach_tcp_proto_field \
8508 #define foreach_udp_proto_field \
8512 #define foreach_ip4_proto_field \
8524 u16 src_port, dst_port;
8527 #if VPP_API_TEST_BUILTIN == 0
8529 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8531 u8 **maskp = va_arg (*args, u8 **);
8533 u8 found_something = 0;
8536 #define _(a) u8 a=0;
8537 foreach_tcp_proto_field;
8540 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8543 #define _(a) else if (unformat (input, #a)) a=1;
8544 foreach_tcp_proto_field
8550 #define _(a) found_something += a;
8551 foreach_tcp_proto_field;
8554 if (found_something == 0)
8557 vec_validate (mask, sizeof (*tcp) - 1);
8559 tcp = (tcp_header_t *) mask;
8561 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8562 foreach_tcp_proto_field;
8570 unformat_udp_mask (unformat_input_t * input, va_list * args)
8572 u8 **maskp = va_arg (*args, u8 **);
8574 u8 found_something = 0;
8577 #define _(a) u8 a=0;
8578 foreach_udp_proto_field;
8581 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8584 #define _(a) else if (unformat (input, #a)) a=1;
8585 foreach_udp_proto_field
8591 #define _(a) found_something += a;
8592 foreach_udp_proto_field;
8595 if (found_something == 0)
8598 vec_validate (mask, sizeof (*udp) - 1);
8600 udp = (udp_header_t *) mask;
8602 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8603 foreach_udp_proto_field;
8611 unformat_l4_mask (unformat_input_t * input, va_list * args)
8613 u8 **maskp = va_arg (*args, u8 **);
8614 u16 src_port = 0, dst_port = 0;
8615 tcpudp_header_t *tcpudp;
8617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8619 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8621 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8623 else if (unformat (input, "src_port"))
8625 else if (unformat (input, "dst_port"))
8631 if (!src_port && !dst_port)
8635 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8637 tcpudp = (tcpudp_header_t *) mask;
8638 tcpudp->src_port = src_port;
8639 tcpudp->dst_port = dst_port;
8647 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8649 u8 **maskp = va_arg (*args, u8 **);
8651 u8 found_something = 0;
8654 #define _(a) u8 a=0;
8655 foreach_ip4_proto_field;
8661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8663 if (unformat (input, "version"))
8665 else if (unformat (input, "hdr_length"))
8667 else if (unformat (input, "src"))
8669 else if (unformat (input, "dst"))
8671 else if (unformat (input, "proto"))
8674 #define _(a) else if (unformat (input, #a)) a=1;
8675 foreach_ip4_proto_field
8681 #define _(a) found_something += a;
8682 foreach_ip4_proto_field;
8685 if (found_something == 0)
8688 vec_validate (mask, sizeof (*ip) - 1);
8690 ip = (ip4_header_t *) mask;
8692 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8693 foreach_ip4_proto_field;
8696 ip->ip_version_and_header_length = 0;
8699 ip->ip_version_and_header_length |= 0xF0;
8702 ip->ip_version_and_header_length |= 0x0F;
8708 #define foreach_ip6_proto_field \
8716 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8718 u8 **maskp = va_arg (*args, u8 **);
8720 u8 found_something = 0;
8722 u32 ip_version_traffic_class_and_flow_label;
8724 #define _(a) u8 a=0;
8725 foreach_ip6_proto_field;
8728 u8 traffic_class = 0;
8731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8733 if (unformat (input, "version"))
8735 else if (unformat (input, "traffic-class"))
8737 else if (unformat (input, "flow-label"))
8739 else if (unformat (input, "src"))
8741 else if (unformat (input, "dst"))
8743 else if (unformat (input, "proto"))
8746 #define _(a) else if (unformat (input, #a)) a=1;
8747 foreach_ip6_proto_field
8753 #define _(a) found_something += a;
8754 foreach_ip6_proto_field;
8757 if (found_something == 0)
8760 vec_validate (mask, sizeof (*ip) - 1);
8762 ip = (ip6_header_t *) mask;
8764 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8765 foreach_ip6_proto_field;
8768 ip_version_traffic_class_and_flow_label = 0;
8771 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8774 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8777 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8779 ip->ip_version_traffic_class_and_flow_label =
8780 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8787 unformat_l3_mask (unformat_input_t * input, va_list * args)
8789 u8 **maskp = va_arg (*args, u8 **);
8791 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8793 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8795 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8804 unformat_l2_mask (unformat_input_t * input, va_list * args)
8806 u8 **maskp = va_arg (*args, u8 **);
8821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8823 if (unformat (input, "src"))
8825 else if (unformat (input, "dst"))
8827 else if (unformat (input, "proto"))
8829 else if (unformat (input, "tag1"))
8831 else if (unformat (input, "tag2"))
8833 else if (unformat (input, "ignore-tag1"))
8835 else if (unformat (input, "ignore-tag2"))
8837 else if (unformat (input, "cos1"))
8839 else if (unformat (input, "cos2"))
8841 else if (unformat (input, "dot1q"))
8843 else if (unformat (input, "dot1ad"))
8848 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8849 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8852 if (tag1 || ignore_tag1 || cos1 || dot1q)
8854 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8857 vec_validate (mask, len - 1);
8860 memset (mask, 0xff, 6);
8863 memset (mask + 6, 0xff, 6);
8867 /* inner vlan tag */
8876 mask[21] = mask[20] = 0xff;
8897 mask[16] = mask[17] = 0xff;
8907 mask[12] = mask[13] = 0xff;
8914 unformat_classify_mask (unformat_input_t * input, va_list * args)
8916 u8 **maskp = va_arg (*args, u8 **);
8917 u32 *skipp = va_arg (*args, u32 *);
8918 u32 *matchp = va_arg (*args, u32 *);
8926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8928 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8930 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8932 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8934 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8948 if (mask || l2 || l3 || l4)
8952 /* "With a free Ethernet header in every package" */
8954 vec_validate (l2, 13);
8958 vec_append (mask, l3);
8963 vec_append (mask, l4);
8968 /* Scan forward looking for the first significant mask octet */
8969 for (i = 0; i < vec_len (mask); i++)
8973 /* compute (skip, match) params */
8974 *skipp = i / sizeof (u32x4);
8975 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8977 /* Pad mask to an even multiple of the vector size */
8978 while (vec_len (mask) % sizeof (u32x4))
8981 match = vec_len (mask) / sizeof (u32x4);
8983 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8985 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8986 if (*tmp || *(tmp + 1))
8991 clib_warning ("BUG: match 0");
8993 _vec_len (mask) = match * sizeof (u32x4);
9003 #endif /* VPP_API_TEST_BUILTIN */
9005 #define foreach_l2_next \
9007 _(ethernet, ETHERNET_INPUT) \
9012 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9014 u32 *miss_next_indexp = va_arg (*args, u32 *);
9019 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9023 if (unformat (input, "%d", &tmp))
9032 *miss_next_indexp = next_index;
9036 #define foreach_ip_next \
9042 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9044 u32 *miss_next_indexp = va_arg (*args, u32 *);
9049 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9053 if (unformat (input, "%d", &tmp))
9062 *miss_next_indexp = next_index;
9066 #define foreach_acl_next \
9070 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9072 u32 *miss_next_indexp = va_arg (*args, u32 *);
9077 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9081 if (unformat (input, "permit"))
9086 else if (unformat (input, "%d", &tmp))
9095 *miss_next_indexp = next_index;
9100 unformat_policer_precolor (unformat_input_t * input, va_list * args)
9102 u32 *r = va_arg (*args, u32 *);
9104 if (unformat (input, "conform-color"))
9105 *r = POLICE_CONFORM;
9106 else if (unformat (input, "exceed-color"))
9115 api_classify_add_del_table (vat_main_t * vam)
9117 unformat_input_t *i = vam->input;
9118 vl_api_classify_add_del_table_t *mp;
9125 u32 table_index = ~0;
9126 u32 next_table_index = ~0;
9127 u32 miss_next_index = ~0;
9128 u32 memory_size = 32 << 20;
9130 u32 current_data_flag = 0;
9131 int current_data_offset = 0;
9134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9136 if (unformat (i, "del"))
9138 else if (unformat (i, "del-chain"))
9143 else if (unformat (i, "buckets %d", &nbuckets))
9145 else if (unformat (i, "memory_size %d", &memory_size))
9147 else if (unformat (i, "skip %d", &skip))
9149 else if (unformat (i, "match %d", &match))
9151 else if (unformat (i, "table %d", &table_index))
9153 else if (unformat (i, "mask %U", unformat_classify_mask,
9154 &mask, &skip, &match))
9156 else if (unformat (i, "next-table %d", &next_table_index))
9158 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9161 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9164 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9167 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9169 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9175 if (is_add && mask == 0)
9177 errmsg ("Mask required");
9181 if (is_add && skip == ~0)
9183 errmsg ("skip count required");
9187 if (is_add && match == ~0)
9189 errmsg ("match count required");
9193 if (!is_add && table_index == ~0)
9195 errmsg ("table index required for delete");
9199 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9201 mp->is_add = is_add;
9202 mp->del_chain = del_chain;
9203 mp->table_index = ntohl (table_index);
9204 mp->nbuckets = ntohl (nbuckets);
9205 mp->memory_size = ntohl (memory_size);
9206 mp->skip_n_vectors = ntohl (skip);
9207 mp->match_n_vectors = ntohl (match);
9208 mp->next_table_index = ntohl (next_table_index);
9209 mp->miss_next_index = ntohl (miss_next_index);
9210 mp->current_data_flag = ntohl (current_data_flag);
9211 mp->current_data_offset = ntohl (current_data_offset);
9212 clib_memcpy (mp->mask, mask, vec_len (mask));
9221 #if VPP_API_TEST_BUILTIN == 0
9223 unformat_l4_match (unformat_input_t * input, va_list * args)
9225 u8 **matchp = va_arg (*args, u8 **);
9227 u8 *proto_header = 0;
9233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9235 if (unformat (input, "src_port %d", &src_port))
9237 else if (unformat (input, "dst_port %d", &dst_port))
9243 h.src_port = clib_host_to_net_u16 (src_port);
9244 h.dst_port = clib_host_to_net_u16 (dst_port);
9245 vec_validate (proto_header, sizeof (h) - 1);
9246 memcpy (proto_header, &h, sizeof (h));
9248 *matchp = proto_header;
9254 unformat_ip4_match (unformat_input_t * input, va_list * args)
9256 u8 **matchp = va_arg (*args, u8 **);
9263 int src = 0, dst = 0;
9264 ip4_address_t src_val, dst_val;
9271 int fragment_id = 0;
9272 u32 fragment_id_val;
9278 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9280 if (unformat (input, "version %d", &version_val))
9282 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9284 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9286 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9288 else if (unformat (input, "proto %d", &proto_val))
9290 else if (unformat (input, "tos %d", &tos_val))
9292 else if (unformat (input, "length %d", &length_val))
9294 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9296 else if (unformat (input, "ttl %d", &ttl_val))
9298 else if (unformat (input, "checksum %d", &checksum_val))
9304 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9305 + ttl + checksum == 0)
9309 * Aligned because we use the real comparison functions
9311 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9313 ip = (ip4_header_t *) match;
9315 /* These are realistically matched in practice */
9317 ip->src_address.as_u32 = src_val.as_u32;
9320 ip->dst_address.as_u32 = dst_val.as_u32;
9323 ip->protocol = proto_val;
9326 /* These are not, but they're included for completeness */
9328 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9331 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9337 ip->length = clib_host_to_net_u16 (length_val);
9343 ip->checksum = clib_host_to_net_u16 (checksum_val);
9350 unformat_ip6_match (unformat_input_t * input, va_list * args)
9352 u8 **matchp = va_arg (*args, u8 **);
9357 u8 traffic_class = 0;
9358 u32 traffic_class_val = 0;
9361 int src = 0, dst = 0;
9362 ip6_address_t src_val, dst_val;
9365 int payload_length = 0;
9366 u32 payload_length_val;
9369 u32 ip_version_traffic_class_and_flow_label;
9371 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9373 if (unformat (input, "version %d", &version_val))
9375 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9377 else if (unformat (input, "flow_label %d", &flow_label_val))
9379 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9381 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9383 else if (unformat (input, "proto %d", &proto_val))
9385 else if (unformat (input, "payload_length %d", &payload_length_val))
9387 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9393 if (version + traffic_class + flow_label + src + dst + proto +
9394 payload_length + hop_limit == 0)
9398 * Aligned because we use the real comparison functions
9400 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9402 ip = (ip6_header_t *) match;
9405 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9408 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9411 ip->protocol = proto_val;
9413 ip_version_traffic_class_and_flow_label = 0;
9416 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9419 ip_version_traffic_class_and_flow_label |=
9420 (traffic_class_val & 0xFF) << 20;
9423 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9425 ip->ip_version_traffic_class_and_flow_label =
9426 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9429 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9432 ip->hop_limit = hop_limit_val;
9439 unformat_l3_match (unformat_input_t * input, va_list * args)
9441 u8 **matchp = va_arg (*args, u8 **);
9443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9445 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9447 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9456 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9458 u8 *tagp = va_arg (*args, u8 *);
9461 if (unformat (input, "%d", &tag))
9463 tagp[0] = (tag >> 8) & 0x0F;
9464 tagp[1] = tag & 0xFF;
9472 unformat_l2_match (unformat_input_t * input, va_list * args)
9474 u8 **matchp = va_arg (*args, u8 **);
9494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9496 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9499 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9501 else if (unformat (input, "proto %U",
9502 unformat_ethernet_type_host_byte_order, &proto_val))
9504 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9506 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9508 else if (unformat (input, "ignore-tag1"))
9510 else if (unformat (input, "ignore-tag2"))
9512 else if (unformat (input, "cos1 %d", &cos1_val))
9514 else if (unformat (input, "cos2 %d", &cos2_val))
9519 if ((src + dst + proto + tag1 + tag2 +
9520 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9523 if (tag1 || ignore_tag1 || cos1)
9525 if (tag2 || ignore_tag2 || cos2)
9528 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9531 clib_memcpy (match, dst_val, 6);
9534 clib_memcpy (match + 6, src_val, 6);
9538 /* inner vlan tag */
9539 match[19] = tag2_val[1];
9540 match[18] = tag2_val[0];
9542 match[18] |= (cos2_val & 0x7) << 5;
9545 match[21] = proto_val & 0xff;
9546 match[20] = proto_val >> 8;
9550 match[15] = tag1_val[1];
9551 match[14] = tag1_val[0];
9554 match[14] |= (cos1_val & 0x7) << 5;
9560 match[15] = tag1_val[1];
9561 match[14] = tag1_val[0];
9564 match[17] = proto_val & 0xff;
9565 match[16] = proto_val >> 8;
9568 match[14] |= (cos1_val & 0x7) << 5;
9574 match[18] |= (cos2_val & 0x7) << 5;
9576 match[14] |= (cos1_val & 0x7) << 5;
9579 match[13] = proto_val & 0xff;
9580 match[12] = proto_val >> 8;
9589 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9591 u8 **matchp = va_arg (*args, u8 **);
9592 u32 skip_n_vectors = va_arg (*args, u32);
9593 u32 match_n_vectors = va_arg (*args, u32);
9600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9602 if (unformat (input, "hex %U", unformat_hex_string, &match))
9604 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9606 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9608 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9622 if (match || l2 || l3 || l4)
9626 /* "Win a free Ethernet header in every packet" */
9628 vec_validate_aligned (l2, 13, sizeof (u32x4));
9632 vec_append_aligned (match, l3, sizeof (u32x4));
9637 vec_append_aligned (match, l4, sizeof (u32x4));
9642 /* Make sure the vector is big enough even if key is all 0's */
9643 vec_validate_aligned
9644 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9647 /* Set size, include skipped vectors */
9648 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9659 api_classify_add_del_session (vat_main_t * vam)
9661 unformat_input_t *i = vam->input;
9662 vl_api_classify_add_del_session_t *mp;
9664 u32 table_index = ~0;
9665 u32 hit_next_index = ~0;
9666 u32 opaque_index = ~0;
9669 u32 skip_n_vectors = 0;
9670 u32 match_n_vectors = 0;
9676 * Warning: you have to supply skip_n and match_n
9677 * because the API client cant simply look at the classify
9681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9683 if (unformat (i, "del"))
9685 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9688 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9691 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9694 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9696 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9698 else if (unformat (i, "opaque-index %d", &opaque_index))
9700 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9702 else if (unformat (i, "match_n %d", &match_n_vectors))
9704 else if (unformat (i, "match %U", api_unformat_classify_match,
9705 &match, skip_n_vectors, match_n_vectors))
9707 else if (unformat (i, "advance %d", &advance))
9709 else if (unformat (i, "table-index %d", &table_index))
9711 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9713 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9715 else if (unformat (i, "action %d", &action))
9717 else if (unformat (i, "metadata %d", &metadata))
9723 if (table_index == ~0)
9725 errmsg ("Table index required");
9729 if (is_add && match == 0)
9731 errmsg ("Match value required");
9735 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9737 mp->is_add = is_add;
9738 mp->table_index = ntohl (table_index);
9739 mp->hit_next_index = ntohl (hit_next_index);
9740 mp->opaque_index = ntohl (opaque_index);
9741 mp->advance = ntohl (advance);
9742 mp->action = action;
9743 mp->metadata = ntohl (metadata);
9744 clib_memcpy (mp->match, match, vec_len (match));
9753 api_classify_set_interface_ip_table (vat_main_t * vam)
9755 unformat_input_t *i = vam->input;
9756 vl_api_classify_set_interface_ip_table_t *mp;
9758 int sw_if_index_set;
9759 u32 table_index = ~0;
9763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9765 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9766 sw_if_index_set = 1;
9767 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9768 sw_if_index_set = 1;
9769 else if (unformat (i, "table %d", &table_index))
9773 clib_warning ("parse error '%U'", format_unformat_error, i);
9778 if (sw_if_index_set == 0)
9780 errmsg ("missing interface name or sw_if_index");
9785 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9787 mp->sw_if_index = ntohl (sw_if_index);
9788 mp->table_index = ntohl (table_index);
9789 mp->is_ipv6 = is_ipv6;
9797 api_classify_set_interface_l2_tables (vat_main_t * vam)
9799 unformat_input_t *i = vam->input;
9800 vl_api_classify_set_interface_l2_tables_t *mp;
9802 int sw_if_index_set;
9803 u32 ip4_table_index = ~0;
9804 u32 ip6_table_index = ~0;
9805 u32 other_table_index = ~0;
9809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9811 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9812 sw_if_index_set = 1;
9813 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9814 sw_if_index_set = 1;
9815 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9817 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9819 else if (unformat (i, "other-table %d", &other_table_index))
9821 else if (unformat (i, "is-input %d", &is_input))
9825 clib_warning ("parse error '%U'", format_unformat_error, i);
9830 if (sw_if_index_set == 0)
9832 errmsg ("missing interface name or sw_if_index");
9837 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9839 mp->sw_if_index = ntohl (sw_if_index);
9840 mp->ip4_table_index = ntohl (ip4_table_index);
9841 mp->ip6_table_index = ntohl (ip6_table_index);
9842 mp->other_table_index = ntohl (other_table_index);
9843 mp->is_input = (u8) is_input;
9851 api_set_ipfix_exporter (vat_main_t * vam)
9853 unformat_input_t *i = vam->input;
9854 vl_api_set_ipfix_exporter_t *mp;
9855 ip4_address_t collector_address;
9856 u8 collector_address_set = 0;
9857 u32 collector_port = ~0;
9858 ip4_address_t src_address;
9859 u8 src_address_set = 0;
9862 u32 template_interval = ~0;
9863 u8 udp_checksum = 0;
9866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9868 if (unformat (i, "collector_address %U", unformat_ip4_address,
9869 &collector_address))
9870 collector_address_set = 1;
9871 else if (unformat (i, "collector_port %d", &collector_port))
9873 else if (unformat (i, "src_address %U", unformat_ip4_address,
9875 src_address_set = 1;
9876 else if (unformat (i, "vrf_id %d", &vrf_id))
9878 else if (unformat (i, "path_mtu %d", &path_mtu))
9880 else if (unformat (i, "template_interval %d", &template_interval))
9882 else if (unformat (i, "udp_checksum"))
9888 if (collector_address_set == 0)
9890 errmsg ("collector_address required");
9894 if (src_address_set == 0)
9896 errmsg ("src_address required");
9900 M (SET_IPFIX_EXPORTER, mp);
9902 memcpy (mp->collector_address, collector_address.data,
9903 sizeof (collector_address.data));
9904 mp->collector_port = htons ((u16) collector_port);
9905 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9906 mp->vrf_id = htonl (vrf_id);
9907 mp->path_mtu = htonl (path_mtu);
9908 mp->template_interval = htonl (template_interval);
9909 mp->udp_checksum = udp_checksum;
9917 api_set_ipfix_classify_stream (vat_main_t * vam)
9919 unformat_input_t *i = vam->input;
9920 vl_api_set_ipfix_classify_stream_t *mp;
9922 u32 src_port = UDP_DST_PORT_ipfix;
9925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9927 if (unformat (i, "domain %d", &domain_id))
9929 else if (unformat (i, "src_port %d", &src_port))
9933 errmsg ("unknown input `%U'", format_unformat_error, i);
9938 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9940 mp->domain_id = htonl (domain_id);
9941 mp->src_port = htons ((u16) src_port);
9949 api_ipfix_classify_table_add_del (vat_main_t * vam)
9951 unformat_input_t *i = vam->input;
9952 vl_api_ipfix_classify_table_add_del_t *mp;
9954 u32 classify_table_index = ~0;
9956 u8 transport_protocol = 255;
9959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9961 if (unformat (i, "add"))
9963 else if (unformat (i, "del"))
9965 else if (unformat (i, "table %d", &classify_table_index))
9967 else if (unformat (i, "ip4"))
9969 else if (unformat (i, "ip6"))
9971 else if (unformat (i, "tcp"))
9972 transport_protocol = 6;
9973 else if (unformat (i, "udp"))
9974 transport_protocol = 17;
9977 errmsg ("unknown input `%U'", format_unformat_error, i);
9984 errmsg ("expecting: add|del");
9987 if (classify_table_index == ~0)
9989 errmsg ("classifier table not specified");
9992 if (ip_version == 0)
9994 errmsg ("IP version not specified");
9998 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10000 mp->is_add = is_add;
10001 mp->table_id = htonl (classify_table_index);
10002 mp->ip_version = ip_version;
10003 mp->transport_protocol = transport_protocol;
10011 api_get_node_index (vat_main_t * vam)
10013 unformat_input_t *i = vam->input;
10014 vl_api_get_node_index_t *mp;
10018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10020 if (unformat (i, "node %s", &name))
10027 errmsg ("node name required");
10030 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10032 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10036 M (GET_NODE_INDEX, mp);
10037 clib_memcpy (mp->node_name, name, vec_len (name));
10046 api_get_next_index (vat_main_t * vam)
10048 unformat_input_t *i = vam->input;
10049 vl_api_get_next_index_t *mp;
10050 u8 *node_name = 0, *next_node_name = 0;
10053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10055 if (unformat (i, "node-name %s", &node_name))
10057 else if (unformat (i, "next-node-name %s", &next_node_name))
10061 if (node_name == 0)
10063 errmsg ("node name required");
10066 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
10068 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10072 if (next_node_name == 0)
10074 errmsg ("next node name required");
10077 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
10079 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
10083 M (GET_NEXT_INDEX, mp);
10084 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
10085 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
10086 vec_free (node_name);
10087 vec_free (next_node_name);
10095 api_add_node_next (vat_main_t * vam)
10097 unformat_input_t *i = vam->input;
10098 vl_api_add_node_next_t *mp;
10103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10105 if (unformat (i, "node %s", &name))
10107 else if (unformat (i, "next %s", &next))
10114 errmsg ("node name required");
10117 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10119 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10124 errmsg ("next node required");
10127 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10129 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10133 M (ADD_NODE_NEXT, mp);
10134 clib_memcpy (mp->node_name, name, vec_len (name));
10135 clib_memcpy (mp->next_name, next, vec_len (next));
10145 api_l2tpv3_create_tunnel (vat_main_t * vam)
10147 unformat_input_t *i = vam->input;
10148 ip6_address_t client_address, our_address;
10149 int client_address_set = 0;
10150 int our_address_set = 0;
10151 u32 local_session_id = 0;
10152 u32 remote_session_id = 0;
10153 u64 local_cookie = 0;
10154 u64 remote_cookie = 0;
10155 u8 l2_sublayer_present = 0;
10156 vl_api_l2tpv3_create_tunnel_t *mp;
10159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10161 if (unformat (i, "client_address %U", unformat_ip6_address,
10163 client_address_set = 1;
10164 else if (unformat (i, "our_address %U", unformat_ip6_address,
10166 our_address_set = 1;
10167 else if (unformat (i, "local_session_id %d", &local_session_id))
10169 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10171 else if (unformat (i, "local_cookie %lld", &local_cookie))
10173 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10175 else if (unformat (i, "l2-sublayer-present"))
10176 l2_sublayer_present = 1;
10181 if (client_address_set == 0)
10183 errmsg ("client_address required");
10187 if (our_address_set == 0)
10189 errmsg ("our_address required");
10193 M (L2TPV3_CREATE_TUNNEL, mp);
10195 clib_memcpy (mp->client_address, client_address.as_u8,
10196 sizeof (mp->client_address));
10198 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10200 mp->local_session_id = ntohl (local_session_id);
10201 mp->remote_session_id = ntohl (remote_session_id);
10202 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10203 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10204 mp->l2_sublayer_present = l2_sublayer_present;
10213 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10215 unformat_input_t *i = vam->input;
10217 u8 sw_if_index_set = 0;
10218 u64 new_local_cookie = 0;
10219 u64 new_remote_cookie = 0;
10220 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10225 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10226 sw_if_index_set = 1;
10227 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10228 sw_if_index_set = 1;
10229 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10231 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10237 if (sw_if_index_set == 0)
10239 errmsg ("missing interface name or sw_if_index");
10243 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10245 mp->sw_if_index = ntohl (sw_if_index);
10246 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10247 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10255 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10257 unformat_input_t *i = vam->input;
10258 vl_api_l2tpv3_interface_enable_disable_t *mp;
10260 u8 sw_if_index_set = 0;
10261 u8 enable_disable = 1;
10264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10266 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10267 sw_if_index_set = 1;
10268 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10269 sw_if_index_set = 1;
10270 else if (unformat (i, "enable"))
10271 enable_disable = 1;
10272 else if (unformat (i, "disable"))
10273 enable_disable = 0;
10278 if (sw_if_index_set == 0)
10280 errmsg ("missing interface name or sw_if_index");
10284 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10286 mp->sw_if_index = ntohl (sw_if_index);
10287 mp->enable_disable = enable_disable;
10295 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10297 unformat_input_t *i = vam->input;
10298 vl_api_l2tpv3_set_lookup_key_t *mp;
10302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10304 if (unformat (i, "lookup_v6_src"))
10305 key = L2T_LOOKUP_SRC_ADDRESS;
10306 else if (unformat (i, "lookup_v6_dst"))
10307 key = L2T_LOOKUP_DST_ADDRESS;
10308 else if (unformat (i, "lookup_session_id"))
10309 key = L2T_LOOKUP_SESSION_ID;
10314 if (key == (u8) ~ 0)
10316 errmsg ("l2tp session lookup key unset");
10320 M (L2TPV3_SET_LOOKUP_KEY, mp);
10329 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10330 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10332 vat_main_t *vam = &vat_main;
10334 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10335 format_ip6_address, mp->our_address,
10336 format_ip6_address, mp->client_address,
10337 clib_net_to_host_u32 (mp->sw_if_index));
10340 " local cookies %016llx %016llx remote cookie %016llx",
10341 clib_net_to_host_u64 (mp->local_cookie[0]),
10342 clib_net_to_host_u64 (mp->local_cookie[1]),
10343 clib_net_to_host_u64 (mp->remote_cookie));
10345 print (vam->ofp, " local session-id %d remote session-id %d",
10346 clib_net_to_host_u32 (mp->local_session_id),
10347 clib_net_to_host_u32 (mp->remote_session_id));
10349 print (vam->ofp, " l2 specific sublayer %s\n",
10350 mp->l2_sublayer_present ? "preset" : "absent");
10354 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10355 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10357 vat_main_t *vam = &vat_main;
10358 vat_json_node_t *node = NULL;
10359 struct in6_addr addr;
10361 if (VAT_JSON_ARRAY != vam->json_tree.type)
10363 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10364 vat_json_init_array (&vam->json_tree);
10366 node = vat_json_array_add (&vam->json_tree);
10368 vat_json_init_object (node);
10370 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10371 vat_json_object_add_ip6 (node, "our_address", addr);
10372 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10373 vat_json_object_add_ip6 (node, "client_address", addr);
10375 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10376 vat_json_init_array (lc);
10377 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10378 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10379 vat_json_object_add_uint (node, "remote_cookie",
10380 clib_net_to_host_u64 (mp->remote_cookie));
10382 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10383 vat_json_object_add_uint (node, "local_session_id",
10384 clib_net_to_host_u32 (mp->local_session_id));
10385 vat_json_object_add_uint (node, "remote_session_id",
10386 clib_net_to_host_u32 (mp->remote_session_id));
10387 vat_json_object_add_string_copy (node, "l2_sublayer",
10388 mp->l2_sublayer_present ? (u8 *) "present"
10389 : (u8 *) "absent");
10393 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10395 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10396 vl_api_control_ping_t *mp_ping;
10399 /* Get list of l2tpv3-tunnel interfaces */
10400 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10403 /* Use a control ping for synchronization */
10404 M (CONTROL_PING, mp_ping);
10412 static void vl_api_sw_interface_tap_details_t_handler
10413 (vl_api_sw_interface_tap_details_t * mp)
10415 vat_main_t *vam = &vat_main;
10417 print (vam->ofp, "%-16s %d",
10418 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10421 static void vl_api_sw_interface_tap_details_t_handler_json
10422 (vl_api_sw_interface_tap_details_t * mp)
10424 vat_main_t *vam = &vat_main;
10425 vat_json_node_t *node = NULL;
10427 if (VAT_JSON_ARRAY != vam->json_tree.type)
10429 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10430 vat_json_init_array (&vam->json_tree);
10432 node = vat_json_array_add (&vam->json_tree);
10434 vat_json_init_object (node);
10435 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10436 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10440 api_sw_interface_tap_dump (vat_main_t * vam)
10442 vl_api_sw_interface_tap_dump_t *mp;
10443 vl_api_control_ping_t *mp_ping;
10446 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10447 /* Get list of tap interfaces */
10448 M (SW_INTERFACE_TAP_DUMP, mp);
10451 /* Use a control ping for synchronization */
10452 M (CONTROL_PING, mp_ping);
10459 static uword unformat_vxlan_decap_next
10460 (unformat_input_t * input, va_list * args)
10462 u32 *result = va_arg (*args, u32 *);
10465 if (unformat (input, "l2"))
10466 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10467 else if (unformat (input, "%d", &tmp))
10475 api_vxlan_add_del_tunnel (vat_main_t * vam)
10477 unformat_input_t *line_input = vam->input;
10478 vl_api_vxlan_add_del_tunnel_t *mp;
10479 ip46_address_t src, dst;
10481 u8 ipv4_set = 0, ipv6_set = 0;
10485 u32 mcast_sw_if_index = ~0;
10486 u32 encap_vrf_id = 0;
10487 u32 decap_next_index = ~0;
10491 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10492 memset (&src, 0, sizeof src);
10493 memset (&dst, 0, sizeof dst);
10495 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10497 if (unformat (line_input, "del"))
10500 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10506 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10512 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10518 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10523 else if (unformat (line_input, "group %U %U",
10524 unformat_ip4_address, &dst.ip4,
10525 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10527 grp_set = dst_set = 1;
10530 else if (unformat (line_input, "group %U",
10531 unformat_ip4_address, &dst.ip4))
10533 grp_set = dst_set = 1;
10536 else if (unformat (line_input, "group %U %U",
10537 unformat_ip6_address, &dst.ip6,
10538 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10540 grp_set = dst_set = 1;
10543 else if (unformat (line_input, "group %U",
10544 unformat_ip6_address, &dst.ip6))
10546 grp_set = dst_set = 1;
10550 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10552 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10554 else if (unformat (line_input, "decap-next %U",
10555 unformat_vxlan_decap_next, &decap_next_index))
10557 else if (unformat (line_input, "vni %d", &vni))
10561 errmsg ("parse error '%U'", format_unformat_error, line_input);
10568 errmsg ("tunnel src address not specified");
10573 errmsg ("tunnel dst address not specified");
10577 if (grp_set && !ip46_address_is_multicast (&dst))
10579 errmsg ("tunnel group address not multicast");
10582 if (grp_set && mcast_sw_if_index == ~0)
10584 errmsg ("tunnel nonexistent multicast device");
10587 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10589 errmsg ("tunnel dst address must be unicast");
10594 if (ipv4_set && ipv6_set)
10596 errmsg ("both IPv4 and IPv6 addresses specified");
10600 if ((vni == 0) || (vni >> 24))
10602 errmsg ("vni not specified or out of range");
10606 M (VXLAN_ADD_DEL_TUNNEL, mp);
10610 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10611 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10615 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10616 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10618 mp->encap_vrf_id = ntohl (encap_vrf_id);
10619 mp->decap_next_index = ntohl (decap_next_index);
10620 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10621 mp->vni = ntohl (vni);
10622 mp->is_add = is_add;
10623 mp->is_ipv6 = ipv6_set;
10630 static void vl_api_vxlan_tunnel_details_t_handler
10631 (vl_api_vxlan_tunnel_details_t * mp)
10633 vat_main_t *vam = &vat_main;
10634 ip46_address_t src, dst;
10636 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10637 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10639 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10640 ntohl (mp->sw_if_index),
10641 format_ip46_address, &src, IP46_TYPE_ANY,
10642 format_ip46_address, &dst, IP46_TYPE_ANY,
10643 ntohl (mp->encap_vrf_id),
10644 ntohl (mp->decap_next_index), ntohl (mp->vni),
10645 ntohl (mp->mcast_sw_if_index));
10648 static void vl_api_vxlan_tunnel_details_t_handler_json
10649 (vl_api_vxlan_tunnel_details_t * mp)
10651 vat_main_t *vam = &vat_main;
10652 vat_json_node_t *node = NULL;
10654 if (VAT_JSON_ARRAY != vam->json_tree.type)
10656 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10657 vat_json_init_array (&vam->json_tree);
10659 node = vat_json_array_add (&vam->json_tree);
10661 vat_json_init_object (node);
10662 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10665 struct in6_addr ip6;
10667 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10668 vat_json_object_add_ip6 (node, "src_address", ip6);
10669 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10670 vat_json_object_add_ip6 (node, "dst_address", ip6);
10674 struct in_addr ip4;
10676 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10677 vat_json_object_add_ip4 (node, "src_address", ip4);
10678 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10679 vat_json_object_add_ip4 (node, "dst_address", ip4);
10681 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10682 vat_json_object_add_uint (node, "decap_next_index",
10683 ntohl (mp->decap_next_index));
10684 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10685 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10686 vat_json_object_add_uint (node, "mcast_sw_if_index",
10687 ntohl (mp->mcast_sw_if_index));
10691 api_vxlan_tunnel_dump (vat_main_t * vam)
10693 unformat_input_t *i = vam->input;
10694 vl_api_vxlan_tunnel_dump_t *mp;
10695 vl_api_control_ping_t *mp_ping;
10697 u8 sw_if_index_set = 0;
10700 /* Parse args required to build the message */
10701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10703 if (unformat (i, "sw_if_index %d", &sw_if_index))
10704 sw_if_index_set = 1;
10709 if (sw_if_index_set == 0)
10714 if (!vam->json_output)
10716 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10717 "sw_if_index", "src_address", "dst_address",
10718 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10721 /* Get list of vxlan-tunnel interfaces */
10722 M (VXLAN_TUNNEL_DUMP, mp);
10724 mp->sw_if_index = htonl (sw_if_index);
10728 /* Use a control ping for synchronization */
10729 M (CONTROL_PING, mp_ping);
10737 api_gre_add_del_tunnel (vat_main_t * vam)
10739 unformat_input_t *line_input = vam->input;
10740 vl_api_gre_add_del_tunnel_t *mp;
10741 ip4_address_t src4, dst4;
10746 u32 outer_fib_id = 0;
10749 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10751 if (unformat (line_input, "del"))
10753 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10755 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10757 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10759 else if (unformat (line_input, "teb"))
10763 errmsg ("parse error '%U'", format_unformat_error, line_input);
10770 errmsg ("tunnel src address not specified");
10775 errmsg ("tunnel dst address not specified");
10780 M (GRE_ADD_DEL_TUNNEL, mp);
10782 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10783 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10784 mp->outer_fib_id = ntohl (outer_fib_id);
10785 mp->is_add = is_add;
10793 static void vl_api_gre_tunnel_details_t_handler
10794 (vl_api_gre_tunnel_details_t * mp)
10796 vat_main_t *vam = &vat_main;
10798 print (vam->ofp, "%11d%15U%15U%6d%14d",
10799 ntohl (mp->sw_if_index),
10800 format_ip4_address, &mp->src_address,
10801 format_ip4_address, &mp->dst_address,
10802 mp->teb, ntohl (mp->outer_fib_id));
10805 static void vl_api_gre_tunnel_details_t_handler_json
10806 (vl_api_gre_tunnel_details_t * mp)
10808 vat_main_t *vam = &vat_main;
10809 vat_json_node_t *node = NULL;
10810 struct in_addr ip4;
10812 if (VAT_JSON_ARRAY != vam->json_tree.type)
10814 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10815 vat_json_init_array (&vam->json_tree);
10817 node = vat_json_array_add (&vam->json_tree);
10819 vat_json_init_object (node);
10820 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10821 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10822 vat_json_object_add_ip4 (node, "src_address", ip4);
10823 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10824 vat_json_object_add_ip4 (node, "dst_address", ip4);
10825 vat_json_object_add_uint (node, "teb", mp->teb);
10826 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10830 api_gre_tunnel_dump (vat_main_t * vam)
10832 unformat_input_t *i = vam->input;
10833 vl_api_gre_tunnel_dump_t *mp;
10834 vl_api_control_ping_t *mp_ping;
10836 u8 sw_if_index_set = 0;
10839 /* Parse args required to build the message */
10840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10842 if (unformat (i, "sw_if_index %d", &sw_if_index))
10843 sw_if_index_set = 1;
10848 if (sw_if_index_set == 0)
10853 if (!vam->json_output)
10855 print (vam->ofp, "%11s%15s%15s%6s%14s",
10856 "sw_if_index", "src_address", "dst_address", "teb",
10860 /* Get list of gre-tunnel interfaces */
10861 M (GRE_TUNNEL_DUMP, mp);
10863 mp->sw_if_index = htonl (sw_if_index);
10867 /* Use a control ping for synchronization */
10868 M (CONTROL_PING, mp_ping);
10876 api_l2_fib_clear_table (vat_main_t * vam)
10878 // unformat_input_t * i = vam->input;
10879 vl_api_l2_fib_clear_table_t *mp;
10882 M (L2_FIB_CLEAR_TABLE, mp);
10890 api_l2_interface_efp_filter (vat_main_t * vam)
10892 unformat_input_t *i = vam->input;
10893 vl_api_l2_interface_efp_filter_t *mp;
10896 u8 sw_if_index_set = 0;
10899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10902 sw_if_index_set = 1;
10903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10904 sw_if_index_set = 1;
10905 else if (unformat (i, "enable"))
10907 else if (unformat (i, "disable"))
10911 clib_warning ("parse error '%U'", format_unformat_error, i);
10916 if (sw_if_index_set == 0)
10918 errmsg ("missing sw_if_index");
10922 M (L2_INTERFACE_EFP_FILTER, mp);
10924 mp->sw_if_index = ntohl (sw_if_index);
10925 mp->enable_disable = enable;
10932 #define foreach_vtr_op \
10933 _("disable", L2_VTR_DISABLED) \
10934 _("push-1", L2_VTR_PUSH_1) \
10935 _("push-2", L2_VTR_PUSH_2) \
10936 _("pop-1", L2_VTR_POP_1) \
10937 _("pop-2", L2_VTR_POP_2) \
10938 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10939 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10940 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10941 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10944 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10946 unformat_input_t *i = vam->input;
10947 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10949 u8 sw_if_index_set = 0;
10952 u32 push_dot1q = 1;
10957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10960 sw_if_index_set = 1;
10961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10962 sw_if_index_set = 1;
10963 else if (unformat (i, "vtr_op %d", &vtr_op))
10965 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10968 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10970 else if (unformat (i, "tag1 %d", &tag1))
10972 else if (unformat (i, "tag2 %d", &tag2))
10976 clib_warning ("parse error '%U'", format_unformat_error, i);
10981 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10983 errmsg ("missing vtr operation or sw_if_index");
10987 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
10988 mp->sw_if_index = ntohl (sw_if_index);
10989 mp->vtr_op = ntohl (vtr_op);
10990 mp->push_dot1q = ntohl (push_dot1q);
10991 mp->tag1 = ntohl (tag1);
10992 mp->tag2 = ntohl (tag2);
11000 api_create_vhost_user_if (vat_main_t * vam)
11002 unformat_input_t *i = vam->input;
11003 vl_api_create_vhost_user_if_t *mp;
11006 u8 file_name_set = 0;
11007 u32 custom_dev_instance = ~0;
11009 u8 use_custom_mac = 0;
11013 /* Shut up coverity */
11014 memset (hwaddr, 0, sizeof (hwaddr));
11016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11018 if (unformat (i, "socket %s", &file_name))
11022 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11024 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
11025 use_custom_mac = 1;
11026 else if (unformat (i, "server"))
11028 else if (unformat (i, "tag %s", &tag))
11034 if (file_name_set == 0)
11036 errmsg ("missing socket file name");
11040 if (vec_len (file_name) > 255)
11042 errmsg ("socket file name too long");
11045 vec_add1 (file_name, 0);
11047 M (CREATE_VHOST_USER_IF, mp);
11049 mp->is_server = is_server;
11050 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11051 vec_free (file_name);
11052 if (custom_dev_instance != ~0)
11055 mp->custom_dev_instance = ntohl (custom_dev_instance);
11057 mp->use_custom_mac = use_custom_mac;
11058 clib_memcpy (mp->mac_address, hwaddr, 6);
11060 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
11069 api_modify_vhost_user_if (vat_main_t * vam)
11071 unformat_input_t *i = vam->input;
11072 vl_api_modify_vhost_user_if_t *mp;
11075 u8 file_name_set = 0;
11076 u32 custom_dev_instance = ~0;
11077 u8 sw_if_index_set = 0;
11078 u32 sw_if_index = (u32) ~ 0;
11081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11083 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11084 sw_if_index_set = 1;
11085 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11086 sw_if_index_set = 1;
11087 else if (unformat (i, "socket %s", &file_name))
11091 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
11093 else if (unformat (i, "server"))
11099 if (sw_if_index_set == 0)
11101 errmsg ("missing sw_if_index or interface name");
11105 if (file_name_set == 0)
11107 errmsg ("missing socket file name");
11111 if (vec_len (file_name) > 255)
11113 errmsg ("socket file name too long");
11116 vec_add1 (file_name, 0);
11118 M (MODIFY_VHOST_USER_IF, mp);
11120 mp->sw_if_index = ntohl (sw_if_index);
11121 mp->is_server = is_server;
11122 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11123 vec_free (file_name);
11124 if (custom_dev_instance != ~0)
11127 mp->custom_dev_instance = ntohl (custom_dev_instance);
11136 api_delete_vhost_user_if (vat_main_t * vam)
11138 unformat_input_t *i = vam->input;
11139 vl_api_delete_vhost_user_if_t *mp;
11140 u32 sw_if_index = ~0;
11141 u8 sw_if_index_set = 0;
11144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11146 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11147 sw_if_index_set = 1;
11148 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11149 sw_if_index_set = 1;
11154 if (sw_if_index_set == 0)
11156 errmsg ("missing sw_if_index or interface name");
11161 M (DELETE_VHOST_USER_IF, mp);
11163 mp->sw_if_index = ntohl (sw_if_index);
11170 static void vl_api_sw_interface_vhost_user_details_t_handler
11171 (vl_api_sw_interface_vhost_user_details_t * mp)
11173 vat_main_t *vam = &vat_main;
11175 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11176 (char *) mp->interface_name,
11177 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11178 clib_net_to_host_u64 (mp->features), mp->is_server,
11179 ntohl (mp->num_regions), (char *) mp->sock_filename);
11180 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11183 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11184 (vl_api_sw_interface_vhost_user_details_t * mp)
11186 vat_main_t *vam = &vat_main;
11187 vat_json_node_t *node = NULL;
11189 if (VAT_JSON_ARRAY != vam->json_tree.type)
11191 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11192 vat_json_init_array (&vam->json_tree);
11194 node = vat_json_array_add (&vam->json_tree);
11196 vat_json_init_object (node);
11197 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11198 vat_json_object_add_string_copy (node, "interface_name",
11199 mp->interface_name);
11200 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11201 ntohl (mp->virtio_net_hdr_sz));
11202 vat_json_object_add_uint (node, "features",
11203 clib_net_to_host_u64 (mp->features));
11204 vat_json_object_add_uint (node, "is_server", mp->is_server);
11205 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11206 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11207 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11211 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11213 vl_api_sw_interface_vhost_user_dump_t *mp;
11214 vl_api_control_ping_t *mp_ping;
11217 "Interface name idx hdr_sz features server regions filename");
11219 /* Get list of vhost-user interfaces */
11220 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11223 /* Use a control ping for synchronization */
11224 M (CONTROL_PING, mp_ping);
11232 api_show_version (vat_main_t * vam)
11234 vl_api_show_version_t *mp;
11237 M (SHOW_VERSION, mp);
11246 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11248 unformat_input_t *line_input = vam->input;
11249 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11250 ip4_address_t local4, remote4;
11251 ip6_address_t local6, remote6;
11253 u8 ipv4_set = 0, ipv6_set = 0;
11256 u32 encap_vrf_id = 0;
11257 u32 decap_vrf_id = 0;
11263 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11265 if (unformat (line_input, "del"))
11267 else if (unformat (line_input, "local %U",
11268 unformat_ip4_address, &local4))
11273 else if (unformat (line_input, "remote %U",
11274 unformat_ip4_address, &remote4))
11279 else if (unformat (line_input, "local %U",
11280 unformat_ip6_address, &local6))
11285 else if (unformat (line_input, "remote %U",
11286 unformat_ip6_address, &remote6))
11291 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11293 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11295 else if (unformat (line_input, "vni %d", &vni))
11297 else if (unformat (line_input, "next-ip4"))
11299 else if (unformat (line_input, "next-ip6"))
11301 else if (unformat (line_input, "next-ethernet"))
11303 else if (unformat (line_input, "next-nsh"))
11307 errmsg ("parse error '%U'", format_unformat_error, line_input);
11312 if (local_set == 0)
11314 errmsg ("tunnel local address not specified");
11317 if (remote_set == 0)
11319 errmsg ("tunnel remote address not specified");
11322 if (ipv4_set && ipv6_set)
11324 errmsg ("both IPv4 and IPv6 addresses specified");
11330 errmsg ("vni not specified");
11334 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11339 clib_memcpy (&mp->local, &local6, sizeof (local6));
11340 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11344 clib_memcpy (&mp->local, &local4, sizeof (local4));
11345 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11348 mp->encap_vrf_id = ntohl (encap_vrf_id);
11349 mp->decap_vrf_id = ntohl (decap_vrf_id);
11350 mp->protocol = protocol;
11351 mp->vni = ntohl (vni);
11352 mp->is_add = is_add;
11353 mp->is_ipv6 = ipv6_set;
11360 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11361 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11363 vat_main_t *vam = &vat_main;
11365 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11366 ntohl (mp->sw_if_index),
11367 format_ip46_address, &(mp->local[0]),
11368 format_ip46_address, &(mp->remote[0]),
11370 ntohl (mp->protocol),
11371 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11374 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11375 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11377 vat_main_t *vam = &vat_main;
11378 vat_json_node_t *node = NULL;
11379 struct in_addr ip4;
11380 struct in6_addr ip6;
11382 if (VAT_JSON_ARRAY != vam->json_tree.type)
11384 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11385 vat_json_init_array (&vam->json_tree);
11387 node = vat_json_array_add (&vam->json_tree);
11389 vat_json_init_object (node);
11390 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11393 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11394 vat_json_object_add_ip6 (node, "local", ip6);
11395 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11396 vat_json_object_add_ip6 (node, "remote", ip6);
11400 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11401 vat_json_object_add_ip4 (node, "local", ip4);
11402 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11403 vat_json_object_add_ip4 (node, "remote", ip4);
11405 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11406 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11407 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11408 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11409 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11413 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11415 unformat_input_t *i = vam->input;
11416 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11417 vl_api_control_ping_t *mp_ping;
11419 u8 sw_if_index_set = 0;
11422 /* Parse args required to build the message */
11423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11425 if (unformat (i, "sw_if_index %d", &sw_if_index))
11426 sw_if_index_set = 1;
11431 if (sw_if_index_set == 0)
11436 if (!vam->json_output)
11438 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11439 "sw_if_index", "local", "remote", "vni",
11440 "protocol", "encap_vrf_id", "decap_vrf_id");
11443 /* Get list of vxlan-tunnel interfaces */
11444 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11446 mp->sw_if_index = htonl (sw_if_index);
11450 /* Use a control ping for synchronization */
11451 M (CONTROL_PING, mp_ping);
11459 format_l2_fib_mac_address (u8 * s, va_list * args)
11461 u8 *a = va_arg (*args, u8 *);
11463 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11464 a[2], a[3], a[4], a[5], a[6], a[7]);
11467 static void vl_api_l2_fib_table_entry_t_handler
11468 (vl_api_l2_fib_table_entry_t * mp)
11470 vat_main_t *vam = &vat_main;
11472 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11474 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11475 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11479 static void vl_api_l2_fib_table_entry_t_handler_json
11480 (vl_api_l2_fib_table_entry_t * mp)
11482 vat_main_t *vam = &vat_main;
11483 vat_json_node_t *node = NULL;
11485 if (VAT_JSON_ARRAY != vam->json_tree.type)
11487 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11488 vat_json_init_array (&vam->json_tree);
11490 node = vat_json_array_add (&vam->json_tree);
11492 vat_json_init_object (node);
11493 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11494 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11495 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11496 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11497 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11498 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11502 api_l2_fib_table_dump (vat_main_t * vam)
11504 unformat_input_t *i = vam->input;
11505 vl_api_l2_fib_table_dump_t *mp;
11506 vl_api_control_ping_t *mp_ping;
11511 /* Parse args required to build the message */
11512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11514 if (unformat (i, "bd_id %d", &bd_id))
11520 if (bd_id_set == 0)
11522 errmsg ("missing bridge domain");
11526 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11528 /* Get list of l2 fib entries */
11529 M (L2_FIB_TABLE_DUMP, mp);
11531 mp->bd_id = ntohl (bd_id);
11534 /* Use a control ping for synchronization */
11535 M (CONTROL_PING, mp_ping);
11544 api_interface_name_renumber (vat_main_t * vam)
11546 unformat_input_t *line_input = vam->input;
11547 vl_api_interface_name_renumber_t *mp;
11548 u32 sw_if_index = ~0;
11549 u32 new_show_dev_instance = ~0;
11552 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11554 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11557 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11559 else if (unformat (line_input, "new_show_dev_instance %d",
11560 &new_show_dev_instance))
11566 if (sw_if_index == ~0)
11568 errmsg ("missing interface name or sw_if_index");
11572 if (new_show_dev_instance == ~0)
11574 errmsg ("missing new_show_dev_instance");
11578 M (INTERFACE_NAME_RENUMBER, mp);
11580 mp->sw_if_index = ntohl (sw_if_index);
11581 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11589 api_want_ip4_arp_events (vat_main_t * vam)
11591 unformat_input_t *line_input = vam->input;
11592 vl_api_want_ip4_arp_events_t *mp;
11593 ip4_address_t address;
11594 int address_set = 0;
11595 u32 enable_disable = 1;
11598 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11600 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11602 else if (unformat (line_input, "del"))
11603 enable_disable = 0;
11608 if (address_set == 0)
11610 errmsg ("missing addresses");
11614 M (WANT_IP4_ARP_EVENTS, mp);
11615 mp->enable_disable = enable_disable;
11616 mp->pid = getpid ();
11617 mp->address = address.as_u32;
11625 api_want_ip6_nd_events (vat_main_t * vam)
11627 unformat_input_t *line_input = vam->input;
11628 vl_api_want_ip6_nd_events_t *mp;
11629 ip6_address_t address;
11630 int address_set = 0;
11631 u32 enable_disable = 1;
11634 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11636 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11638 else if (unformat (line_input, "del"))
11639 enable_disable = 0;
11644 if (address_set == 0)
11646 errmsg ("missing addresses");
11650 M (WANT_IP6_ND_EVENTS, mp);
11651 mp->enable_disable = enable_disable;
11652 mp->pid = getpid ();
11653 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11661 api_input_acl_set_interface (vat_main_t * vam)
11663 unformat_input_t *i = vam->input;
11664 vl_api_input_acl_set_interface_t *mp;
11666 int sw_if_index_set;
11667 u32 ip4_table_index = ~0;
11668 u32 ip6_table_index = ~0;
11669 u32 l2_table_index = ~0;
11673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11675 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11676 sw_if_index_set = 1;
11677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11678 sw_if_index_set = 1;
11679 else if (unformat (i, "del"))
11681 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11683 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11685 else if (unformat (i, "l2-table %d", &l2_table_index))
11689 clib_warning ("parse error '%U'", format_unformat_error, i);
11694 if (sw_if_index_set == 0)
11696 errmsg ("missing interface name or sw_if_index");
11700 M (INPUT_ACL_SET_INTERFACE, mp);
11702 mp->sw_if_index = ntohl (sw_if_index);
11703 mp->ip4_table_index = ntohl (ip4_table_index);
11704 mp->ip6_table_index = ntohl (ip6_table_index);
11705 mp->l2_table_index = ntohl (l2_table_index);
11706 mp->is_add = is_add;
11714 api_ip_address_dump (vat_main_t * vam)
11716 unformat_input_t *i = vam->input;
11717 vl_api_ip_address_dump_t *mp;
11718 vl_api_control_ping_t *mp_ping;
11719 u32 sw_if_index = ~0;
11720 u8 sw_if_index_set = 0;
11725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11727 if (unformat (i, "sw_if_index %d", &sw_if_index))
11728 sw_if_index_set = 1;
11730 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11731 sw_if_index_set = 1;
11732 else if (unformat (i, "ipv4"))
11734 else if (unformat (i, "ipv6"))
11740 if (ipv4_set && ipv6_set)
11742 errmsg ("ipv4 and ipv6 flags cannot be both set");
11746 if ((!ipv4_set) && (!ipv6_set))
11748 errmsg ("no ipv4 nor ipv6 flag set");
11752 if (sw_if_index_set == 0)
11754 errmsg ("missing interface name or sw_if_index");
11758 vam->current_sw_if_index = sw_if_index;
11759 vam->is_ipv6 = ipv6_set;
11761 M (IP_ADDRESS_DUMP, mp);
11762 mp->sw_if_index = ntohl (sw_if_index);
11763 mp->is_ipv6 = ipv6_set;
11766 /* Use a control ping for synchronization */
11767 M (CONTROL_PING, mp_ping);
11775 api_ip_dump (vat_main_t * vam)
11777 vl_api_ip_dump_t *mp;
11778 vl_api_control_ping_t *mp_ping;
11779 unformat_input_t *in = vam->input;
11786 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11788 if (unformat (in, "ipv4"))
11790 else if (unformat (in, "ipv6"))
11796 if (ipv4_set && ipv6_set)
11798 errmsg ("ipv4 and ipv6 flags cannot be both set");
11802 if ((!ipv4_set) && (!ipv6_set))
11804 errmsg ("no ipv4 nor ipv6 flag set");
11808 is_ipv6 = ipv6_set;
11809 vam->is_ipv6 = is_ipv6;
11811 /* free old data */
11812 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11814 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11816 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11819 mp->is_ipv6 = ipv6_set;
11822 /* Use a control ping for synchronization */
11823 M (CONTROL_PING, mp_ping);
11831 api_ipsec_spd_add_del (vat_main_t * vam)
11833 unformat_input_t *i = vam->input;
11834 vl_api_ipsec_spd_add_del_t *mp;
11839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11841 if (unformat (i, "spd_id %d", &spd_id))
11843 else if (unformat (i, "del"))
11847 clib_warning ("parse error '%U'", format_unformat_error, i);
11853 errmsg ("spd_id must be set");
11857 M (IPSEC_SPD_ADD_DEL, mp);
11859 mp->spd_id = ntohl (spd_id);
11860 mp->is_add = is_add;
11868 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11870 unformat_input_t *i = vam->input;
11871 vl_api_ipsec_interface_add_del_spd_t *mp;
11873 u8 sw_if_index_set = 0;
11874 u32 spd_id = (u32) ~ 0;
11878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11880 if (unformat (i, "del"))
11882 else if (unformat (i, "spd_id %d", &spd_id))
11885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11886 sw_if_index_set = 1;
11887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11888 sw_if_index_set = 1;
11891 clib_warning ("parse error '%U'", format_unformat_error, i);
11897 if (spd_id == (u32) ~ 0)
11899 errmsg ("spd_id must be set");
11903 if (sw_if_index_set == 0)
11905 errmsg ("missing interface name or sw_if_index");
11909 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11911 mp->spd_id = ntohl (spd_id);
11912 mp->sw_if_index = ntohl (sw_if_index);
11913 mp->is_add = is_add;
11921 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11923 unformat_input_t *i = vam->input;
11924 vl_api_ipsec_spd_add_del_entry_t *mp;
11925 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11926 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11928 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11929 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11930 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11931 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11934 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11935 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11936 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11937 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11938 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11939 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11943 if (unformat (i, "del"))
11945 if (unformat (i, "outbound"))
11947 if (unformat (i, "inbound"))
11949 else if (unformat (i, "spd_id %d", &spd_id))
11951 else if (unformat (i, "sa_id %d", &sa_id))
11953 else if (unformat (i, "priority %d", &priority))
11955 else if (unformat (i, "protocol %d", &protocol))
11957 else if (unformat (i, "lport_start %d", &lport_start))
11959 else if (unformat (i, "lport_stop %d", &lport_stop))
11961 else if (unformat (i, "rport_start %d", &rport_start))
11963 else if (unformat (i, "rport_stop %d", &rport_stop))
11967 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11973 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11980 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11986 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11993 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11999 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
12006 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
12012 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
12018 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
12020 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
12022 clib_warning ("unsupported action: 'resolve'");
12028 clib_warning ("parse error '%U'", format_unformat_error, i);
12034 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
12036 mp->spd_id = ntohl (spd_id);
12037 mp->priority = ntohl (priority);
12038 mp->is_outbound = is_outbound;
12040 mp->is_ipv6 = is_ipv6;
12041 if (is_ipv6 || is_ip_any)
12043 clib_memcpy (mp->remote_address_start, &raddr6_start,
12044 sizeof (ip6_address_t));
12045 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
12046 sizeof (ip6_address_t));
12047 clib_memcpy (mp->local_address_start, &laddr6_start,
12048 sizeof (ip6_address_t));
12049 clib_memcpy (mp->local_address_stop, &laddr6_stop,
12050 sizeof (ip6_address_t));
12054 clib_memcpy (mp->remote_address_start, &raddr4_start,
12055 sizeof (ip4_address_t));
12056 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
12057 sizeof (ip4_address_t));
12058 clib_memcpy (mp->local_address_start, &laddr4_start,
12059 sizeof (ip4_address_t));
12060 clib_memcpy (mp->local_address_stop, &laddr4_stop,
12061 sizeof (ip4_address_t));
12063 mp->protocol = (u8) protocol;
12064 mp->local_port_start = ntohs ((u16) lport_start);
12065 mp->local_port_stop = ntohs ((u16) lport_stop);
12066 mp->remote_port_start = ntohs ((u16) rport_start);
12067 mp->remote_port_stop = ntohs ((u16) rport_stop);
12068 mp->policy = (u8) policy;
12069 mp->sa_id = ntohl (sa_id);
12070 mp->is_add = is_add;
12071 mp->is_ip_any = is_ip_any;
12078 api_ipsec_sad_add_del_entry (vat_main_t * vam)
12080 unformat_input_t *i = vam->input;
12081 vl_api_ipsec_sad_add_del_entry_t *mp;
12082 u32 sad_id = 0, spi = 0;
12083 u8 *ck = 0, *ik = 0;
12086 u8 protocol = IPSEC_PROTOCOL_AH;
12087 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
12088 u32 crypto_alg = 0, integ_alg = 0;
12089 ip4_address_t tun_src4;
12090 ip4_address_t tun_dst4;
12091 ip6_address_t tun_src6;
12092 ip6_address_t tun_dst6;
12095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12097 if (unformat (i, "del"))
12099 else if (unformat (i, "sad_id %d", &sad_id))
12101 else if (unformat (i, "spi %d", &spi))
12103 else if (unformat (i, "esp"))
12104 protocol = IPSEC_PROTOCOL_ESP;
12105 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
12108 is_tunnel_ipv6 = 0;
12110 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12113 is_tunnel_ipv6 = 0;
12115 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12118 is_tunnel_ipv6 = 1;
12120 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12123 is_tunnel_ipv6 = 1;
12127 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12129 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12130 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12132 clib_warning ("unsupported crypto-alg: '%U'",
12133 format_ipsec_crypto_alg, crypto_alg);
12137 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12141 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12143 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12144 integ_alg >= IPSEC_INTEG_N_ALG)
12146 clib_warning ("unsupported integ-alg: '%U'",
12147 format_ipsec_integ_alg, integ_alg);
12151 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12155 clib_warning ("parse error '%U'", format_unformat_error, i);
12161 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12163 mp->sad_id = ntohl (sad_id);
12164 mp->is_add = is_add;
12165 mp->protocol = protocol;
12166 mp->spi = ntohl (spi);
12167 mp->is_tunnel = is_tunnel;
12168 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12169 mp->crypto_algorithm = crypto_alg;
12170 mp->integrity_algorithm = integ_alg;
12171 mp->crypto_key_length = vec_len (ck);
12172 mp->integrity_key_length = vec_len (ik);
12174 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12175 mp->crypto_key_length = sizeof (mp->crypto_key);
12177 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12178 mp->integrity_key_length = sizeof (mp->integrity_key);
12181 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12183 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12187 if (is_tunnel_ipv6)
12189 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12190 sizeof (ip6_address_t));
12191 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12192 sizeof (ip6_address_t));
12196 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12197 sizeof (ip4_address_t));
12198 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12199 sizeof (ip4_address_t));
12209 api_ipsec_sa_set_key (vat_main_t * vam)
12211 unformat_input_t *i = vam->input;
12212 vl_api_ipsec_sa_set_key_t *mp;
12214 u8 *ck = 0, *ik = 0;
12217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12219 if (unformat (i, "sa_id %d", &sa_id))
12221 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12223 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12227 clib_warning ("parse error '%U'", format_unformat_error, i);
12232 M (IPSEC_SA_SET_KEY, mp);
12234 mp->sa_id = ntohl (sa_id);
12235 mp->crypto_key_length = vec_len (ck);
12236 mp->integrity_key_length = vec_len (ik);
12238 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12239 mp->crypto_key_length = sizeof (mp->crypto_key);
12241 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12242 mp->integrity_key_length = sizeof (mp->integrity_key);
12245 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12247 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12255 api_ikev2_profile_add_del (vat_main_t * vam)
12257 unformat_input_t *i = vam->input;
12258 vl_api_ikev2_profile_add_del_t *mp;
12263 const char *valid_chars = "a-zA-Z0-9_";
12265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12267 if (unformat (i, "del"))
12269 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12270 vec_add1 (name, 0);
12273 errmsg ("parse error '%U'", format_unformat_error, i);
12278 if (!vec_len (name))
12280 errmsg ("profile name must be specified");
12284 if (vec_len (name) > 64)
12286 errmsg ("profile name too long");
12290 M (IKEV2_PROFILE_ADD_DEL, mp);
12292 clib_memcpy (mp->name, name, vec_len (name));
12293 mp->is_add = is_add;
12302 api_ikev2_profile_set_auth (vat_main_t * vam)
12304 unformat_input_t *i = vam->input;
12305 vl_api_ikev2_profile_set_auth_t *mp;
12308 u32 auth_method = 0;
12312 const char *valid_chars = "a-zA-Z0-9_";
12314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12316 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12317 vec_add1 (name, 0);
12318 else if (unformat (i, "auth_method %U",
12319 unformat_ikev2_auth_method, &auth_method))
12321 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12323 else if (unformat (i, "auth_data %v", &data))
12327 errmsg ("parse error '%U'", format_unformat_error, i);
12332 if (!vec_len (name))
12334 errmsg ("profile name must be specified");
12338 if (vec_len (name) > 64)
12340 errmsg ("profile name too long");
12344 if (!vec_len (data))
12346 errmsg ("auth_data must be specified");
12352 errmsg ("auth_method must be specified");
12356 M (IKEV2_PROFILE_SET_AUTH, mp);
12358 mp->is_hex = is_hex;
12359 mp->auth_method = (u8) auth_method;
12360 mp->data_len = vec_len (data);
12361 clib_memcpy (mp->name, name, vec_len (name));
12362 clib_memcpy (mp->data, data, vec_len (data));
12372 api_ikev2_profile_set_id (vat_main_t * vam)
12374 unformat_input_t *i = vam->input;
12375 vl_api_ikev2_profile_set_id_t *mp;
12383 const char *valid_chars = "a-zA-Z0-9_";
12385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12387 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12388 vec_add1 (name, 0);
12389 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12391 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12393 data = vec_new (u8, 4);
12394 clib_memcpy (data, ip4.as_u8, 4);
12396 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12398 else if (unformat (i, "id_data %v", &data))
12400 else if (unformat (i, "local"))
12402 else if (unformat (i, "remote"))
12406 errmsg ("parse error '%U'", format_unformat_error, i);
12411 if (!vec_len (name))
12413 errmsg ("profile name must be specified");
12417 if (vec_len (name) > 64)
12419 errmsg ("profile name too long");
12423 if (!vec_len (data))
12425 errmsg ("id_data must be specified");
12431 errmsg ("id_type must be specified");
12435 M (IKEV2_PROFILE_SET_ID, mp);
12437 mp->is_local = is_local;
12438 mp->id_type = (u8) id_type;
12439 mp->data_len = vec_len (data);
12440 clib_memcpy (mp->name, name, vec_len (name));
12441 clib_memcpy (mp->data, data, vec_len (data));
12451 api_ikev2_profile_set_ts (vat_main_t * vam)
12453 unformat_input_t *i = vam->input;
12454 vl_api_ikev2_profile_set_ts_t *mp;
12457 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12458 ip4_address_t start_addr, end_addr;
12460 const char *valid_chars = "a-zA-Z0-9_";
12463 start_addr.as_u32 = 0;
12464 end_addr.as_u32 = (u32) ~ 0;
12466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12468 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12469 vec_add1 (name, 0);
12470 else if (unformat (i, "protocol %d", &proto))
12472 else if (unformat (i, "start_port %d", &start_port))
12474 else if (unformat (i, "end_port %d", &end_port))
12477 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12479 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12481 else if (unformat (i, "local"))
12483 else if (unformat (i, "remote"))
12487 errmsg ("parse error '%U'", format_unformat_error, i);
12492 if (!vec_len (name))
12494 errmsg ("profile name must be specified");
12498 if (vec_len (name) > 64)
12500 errmsg ("profile name too long");
12504 M (IKEV2_PROFILE_SET_TS, mp);
12506 mp->is_local = is_local;
12507 mp->proto = (u8) proto;
12508 mp->start_port = (u16) start_port;
12509 mp->end_port = (u16) end_port;
12510 mp->start_addr = start_addr.as_u32;
12511 mp->end_addr = end_addr.as_u32;
12512 clib_memcpy (mp->name, name, vec_len (name));
12521 api_ikev2_set_local_key (vat_main_t * vam)
12523 unformat_input_t *i = vam->input;
12524 vl_api_ikev2_set_local_key_t *mp;
12528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12530 if (unformat (i, "file %v", &file))
12531 vec_add1 (file, 0);
12534 errmsg ("parse error '%U'", format_unformat_error, i);
12539 if (!vec_len (file))
12541 errmsg ("RSA key file must be specified");
12545 if (vec_len (file) > 256)
12547 errmsg ("file name too long");
12551 M (IKEV2_SET_LOCAL_KEY, mp);
12553 clib_memcpy (mp->key_file, file, vec_len (file));
12562 api_ikev2_set_responder (vat_main_t * vam)
12564 unformat_input_t *i = vam->input;
12565 vl_api_ikev2_set_responder_t *mp;
12568 u32 sw_if_index = ~0;
12569 ip4_address_t address;
12571 const char *valid_chars = "a-zA-Z0-9_";
12573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12576 (i, "%U interface %d address %U", unformat_token, valid_chars,
12577 &name, &sw_if_index, unformat_ip4_address, &address))
12578 vec_add1 (name, 0);
12581 errmsg ("parse error '%U'", format_unformat_error, i);
12586 if (!vec_len (name))
12588 errmsg ("profile name must be specified");
12592 if (vec_len (name) > 64)
12594 errmsg ("profile name too long");
12598 M (IKEV2_SET_RESPONDER, mp);
12600 clib_memcpy (mp->name, name, vec_len (name));
12603 mp->sw_if_index = sw_if_index;
12604 clib_memcpy (mp->address, &address, sizeof (address));
12612 api_ikev2_set_ike_transforms (vat_main_t * vam)
12614 unformat_input_t *i = vam->input;
12615 vl_api_ikev2_set_ike_transforms_t *mp;
12618 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12620 const char *valid_chars = "a-zA-Z0-9_";
12622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12624 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12625 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12626 vec_add1 (name, 0);
12629 errmsg ("parse error '%U'", format_unformat_error, i);
12634 if (!vec_len (name))
12636 errmsg ("profile name must be specified");
12640 if (vec_len (name) > 64)
12642 errmsg ("profile name too long");
12646 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12648 clib_memcpy (mp->name, name, vec_len (name));
12650 mp->crypto_alg = crypto_alg;
12651 mp->crypto_key_size = crypto_key_size;
12652 mp->integ_alg = integ_alg;
12653 mp->dh_group = dh_group;
12662 api_ikev2_set_esp_transforms (vat_main_t * vam)
12664 unformat_input_t *i = vam->input;
12665 vl_api_ikev2_set_esp_transforms_t *mp;
12668 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12670 const char *valid_chars = "a-zA-Z0-9_";
12672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12674 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12675 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12676 vec_add1 (name, 0);
12679 errmsg ("parse error '%U'", format_unformat_error, i);
12684 if (!vec_len (name))
12686 errmsg ("profile name must be specified");
12690 if (vec_len (name) > 64)
12692 errmsg ("profile name too long");
12696 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12698 clib_memcpy (mp->name, name, vec_len (name));
12700 mp->crypto_alg = crypto_alg;
12701 mp->crypto_key_size = crypto_key_size;
12702 mp->integ_alg = integ_alg;
12703 mp->dh_group = dh_group;
12711 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12713 unformat_input_t *i = vam->input;
12714 vl_api_ikev2_set_sa_lifetime_t *mp;
12717 u64 lifetime, lifetime_maxdata;
12718 u32 lifetime_jitter, handover;
12720 const char *valid_chars = "a-zA-Z0-9_";
12722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12724 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12725 &lifetime, &lifetime_jitter, &handover,
12726 &lifetime_maxdata))
12727 vec_add1 (name, 0);
12730 errmsg ("parse error '%U'", format_unformat_error, i);
12735 if (!vec_len (name))
12737 errmsg ("profile name must be specified");
12741 if (vec_len (name) > 64)
12743 errmsg ("profile name too long");
12747 M (IKEV2_SET_SA_LIFETIME, mp);
12749 clib_memcpy (mp->name, name, vec_len (name));
12751 mp->lifetime = lifetime;
12752 mp->lifetime_jitter = lifetime_jitter;
12753 mp->handover = handover;
12754 mp->lifetime_maxdata = lifetime_maxdata;
12762 api_ikev2_initiate_sa_init (vat_main_t * vam)
12764 unformat_input_t *i = vam->input;
12765 vl_api_ikev2_initiate_sa_init_t *mp;
12769 const char *valid_chars = "a-zA-Z0-9_";
12771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12773 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12774 vec_add1 (name, 0);
12777 errmsg ("parse error '%U'", format_unformat_error, i);
12782 if (!vec_len (name))
12784 errmsg ("profile name must be specified");
12788 if (vec_len (name) > 64)
12790 errmsg ("profile name too long");
12794 M (IKEV2_INITIATE_SA_INIT, mp);
12796 clib_memcpy (mp->name, name, vec_len (name));
12805 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12807 unformat_input_t *i = vam->input;
12808 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12815 if (unformat (i, "%lx", &ispi))
12819 errmsg ("parse error '%U'", format_unformat_error, i);
12824 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12834 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12836 unformat_input_t *i = vam->input;
12837 vl_api_ikev2_initiate_del_child_sa_t *mp;
12842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12844 if (unformat (i, "%x", &ispi))
12848 errmsg ("parse error '%U'", format_unformat_error, i);
12853 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12863 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12865 unformat_input_t *i = vam->input;
12866 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12873 if (unformat (i, "%x", &ispi))
12877 errmsg ("parse error '%U'", format_unformat_error, i);
12882 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12895 api_map_add_domain (vat_main_t * vam)
12897 unformat_input_t *i = vam->input;
12898 vl_api_map_add_domain_t *mp;
12900 ip4_address_t ip4_prefix;
12901 ip6_address_t ip6_prefix;
12902 ip6_address_t ip6_src;
12903 u32 num_m_args = 0;
12904 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12905 0, psid_length = 0;
12906 u8 is_translation = 0;
12908 u32 ip6_src_len = 128;
12911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12913 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12914 &ip4_prefix, &ip4_prefix_len))
12916 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12917 &ip6_prefix, &ip6_prefix_len))
12921 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12924 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12926 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12928 else if (unformat (i, "psid-offset %d", &psid_offset))
12930 else if (unformat (i, "psid-len %d", &psid_length))
12932 else if (unformat (i, "mtu %d", &mtu))
12934 else if (unformat (i, "map-t"))
12935 is_translation = 1;
12938 clib_warning ("parse error '%U'", format_unformat_error, i);
12943 if (num_m_args < 3)
12945 errmsg ("mandatory argument(s) missing");
12949 /* Construct the API message */
12950 M (MAP_ADD_DOMAIN, mp);
12952 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12953 mp->ip4_prefix_len = ip4_prefix_len;
12955 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12956 mp->ip6_prefix_len = ip6_prefix_len;
12958 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12959 mp->ip6_src_prefix_len = ip6_src_len;
12961 mp->ea_bits_len = ea_bits_len;
12962 mp->psid_offset = psid_offset;
12963 mp->psid_length = psid_length;
12964 mp->is_translation = is_translation;
12965 mp->mtu = htons (mtu);
12970 /* Wait for a reply, return good/bad news */
12976 api_map_del_domain (vat_main_t * vam)
12978 unformat_input_t *i = vam->input;
12979 vl_api_map_del_domain_t *mp;
12981 u32 num_m_args = 0;
12985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12987 if (unformat (i, "index %d", &index))
12991 clib_warning ("parse error '%U'", format_unformat_error, i);
12996 if (num_m_args != 1)
12998 errmsg ("mandatory argument(s) missing");
13002 /* Construct the API message */
13003 M (MAP_DEL_DOMAIN, mp);
13005 mp->index = ntohl (index);
13010 /* Wait for a reply, return good/bad news */
13016 api_map_add_del_rule (vat_main_t * vam)
13018 unformat_input_t *i = vam->input;
13019 vl_api_map_add_del_rule_t *mp;
13021 ip6_address_t ip6_dst;
13022 u32 num_m_args = 0, index, psid = 0;
13025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13027 if (unformat (i, "index %d", &index))
13029 else if (unformat (i, "psid %d", &psid))
13031 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
13033 else if (unformat (i, "del"))
13039 clib_warning ("parse error '%U'", format_unformat_error, i);
13044 /* Construct the API message */
13045 M (MAP_ADD_DEL_RULE, mp);
13047 mp->index = ntohl (index);
13048 mp->is_add = is_add;
13049 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
13050 mp->psid = ntohs (psid);
13055 /* Wait for a reply, return good/bad news */
13061 api_map_domain_dump (vat_main_t * vam)
13063 vl_api_map_domain_dump_t *mp;
13064 vl_api_control_ping_t *mp_ping;
13067 /* Construct the API message */
13068 M (MAP_DOMAIN_DUMP, mp);
13073 /* Use a control ping for synchronization */
13074 M (CONTROL_PING, mp_ping);
13082 api_map_rule_dump (vat_main_t * vam)
13084 unformat_input_t *i = vam->input;
13085 vl_api_map_rule_dump_t *mp;
13086 vl_api_control_ping_t *mp_ping;
13087 u32 domain_index = ~0;
13090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13092 if (unformat (i, "index %u", &domain_index))
13098 if (domain_index == ~0)
13100 clib_warning ("parse error: domain index expected");
13104 /* Construct the API message */
13105 M (MAP_RULE_DUMP, mp);
13107 mp->domain_index = htonl (domain_index);
13112 /* Use a control ping for synchronization */
13113 M (CONTROL_PING, mp_ping);
13120 static void vl_api_map_add_domain_reply_t_handler
13121 (vl_api_map_add_domain_reply_t * mp)
13123 vat_main_t *vam = &vat_main;
13124 i32 retval = ntohl (mp->retval);
13126 if (vam->async_mode)
13128 vam->async_errors += (retval < 0);
13132 vam->retval = retval;
13133 vam->result_ready = 1;
13137 static void vl_api_map_add_domain_reply_t_handler_json
13138 (vl_api_map_add_domain_reply_t * mp)
13140 vat_main_t *vam = &vat_main;
13141 vat_json_node_t node;
13143 vat_json_init_object (&node);
13144 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13145 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13147 vat_json_print (vam->ofp, &node);
13148 vat_json_free (&node);
13150 vam->retval = ntohl (mp->retval);
13151 vam->result_ready = 1;
13155 api_get_first_msg_id (vat_main_t * vam)
13157 vl_api_get_first_msg_id_t *mp;
13158 unformat_input_t *i = vam->input;
13163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13165 if (unformat (i, "client %s", &name))
13173 errmsg ("missing client name");
13176 vec_add1 (name, 0);
13178 if (vec_len (name) > 63)
13180 errmsg ("client name too long");
13184 M (GET_FIRST_MSG_ID, mp);
13185 clib_memcpy (mp->name, name, vec_len (name));
13192 api_cop_interface_enable_disable (vat_main_t * vam)
13194 unformat_input_t *line_input = vam->input;
13195 vl_api_cop_interface_enable_disable_t *mp;
13196 u32 sw_if_index = ~0;
13197 u8 enable_disable = 1;
13200 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13202 if (unformat (line_input, "disable"))
13203 enable_disable = 0;
13204 if (unformat (line_input, "enable"))
13205 enable_disable = 1;
13206 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13207 vam, &sw_if_index))
13209 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13215 if (sw_if_index == ~0)
13217 errmsg ("missing interface name or sw_if_index");
13221 /* Construct the API message */
13222 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13223 mp->sw_if_index = ntohl (sw_if_index);
13224 mp->enable_disable = enable_disable;
13228 /* Wait for the reply */
13234 api_cop_whitelist_enable_disable (vat_main_t * vam)
13236 unformat_input_t *line_input = vam->input;
13237 vl_api_cop_whitelist_enable_disable_t *mp;
13238 u32 sw_if_index = ~0;
13239 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13243 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13245 if (unformat (line_input, "ip4"))
13247 else if (unformat (line_input, "ip6"))
13249 else if (unformat (line_input, "default"))
13251 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13252 vam, &sw_if_index))
13254 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13256 else if (unformat (line_input, "fib-id %d", &fib_id))
13262 if (sw_if_index == ~0)
13264 errmsg ("missing interface name or sw_if_index");
13268 /* Construct the API message */
13269 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13270 mp->sw_if_index = ntohl (sw_if_index);
13271 mp->fib_id = ntohl (fib_id);
13274 mp->default_cop = default_cop;
13278 /* Wait for the reply */
13284 api_get_node_graph (vat_main_t * vam)
13286 vl_api_get_node_graph_t *mp;
13289 M (GET_NODE_GRAPH, mp);
13293 /* Wait for the reply */
13299 /** Used for parsing LISP eids */
13300 typedef CLIB_PACKED(struct{
13301 u8 addr[16]; /**< eid address */
13302 u32 len; /**< prefix length if IP */
13303 u8 type; /**< type of eid */
13308 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13310 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13312 memset (a, 0, sizeof (a[0]));
13314 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13316 a->type = 0; /* ipv4 type */
13318 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13320 a->type = 1; /* ipv6 type */
13322 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13324 a->type = 2; /* mac type */
13331 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13340 lisp_eid_size_vat (u8 type)
13355 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13357 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13361 api_one_add_del_locator_set (vat_main_t * vam)
13363 unformat_input_t *input = vam->input;
13364 vl_api_one_add_del_locator_set_t *mp;
13366 u8 *locator_set_name = NULL;
13367 u8 locator_set_name_set = 0;
13368 vl_api_local_locator_t locator, *locators = 0;
13369 u32 sw_if_index, priority, weight;
13373 /* Parse args required to build the message */
13374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13376 if (unformat (input, "del"))
13380 else if (unformat (input, "locator-set %s", &locator_set_name))
13382 locator_set_name_set = 1;
13384 else if (unformat (input, "sw_if_index %u p %u w %u",
13385 &sw_if_index, &priority, &weight))
13387 locator.sw_if_index = htonl (sw_if_index);
13388 locator.priority = priority;
13389 locator.weight = weight;
13390 vec_add1 (locators, locator);
13394 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13395 &sw_if_index, &priority, &weight))
13397 locator.sw_if_index = htonl (sw_if_index);
13398 locator.priority = priority;
13399 locator.weight = weight;
13400 vec_add1 (locators, locator);
13406 if (locator_set_name_set == 0)
13408 errmsg ("missing locator-set name");
13409 vec_free (locators);
13413 if (vec_len (locator_set_name) > 64)
13415 errmsg ("locator-set name too long");
13416 vec_free (locator_set_name);
13417 vec_free (locators);
13420 vec_add1 (locator_set_name, 0);
13422 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13424 /* Construct the API message */
13425 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13427 mp->is_add = is_add;
13428 clib_memcpy (mp->locator_set_name, locator_set_name,
13429 vec_len (locator_set_name));
13430 vec_free (locator_set_name);
13432 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13434 clib_memcpy (mp->locators, locators, data_len);
13435 vec_free (locators);
13440 /* Wait for a reply... */
13445 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13448 api_one_add_del_locator (vat_main_t * vam)
13450 unformat_input_t *input = vam->input;
13451 vl_api_one_add_del_locator_t *mp;
13452 u32 tmp_if_index = ~0;
13453 u32 sw_if_index = ~0;
13454 u8 sw_if_index_set = 0;
13455 u8 sw_if_index_if_name_set = 0;
13457 u8 priority_set = 0;
13461 u8 *locator_set_name = NULL;
13462 u8 locator_set_name_set = 0;
13465 /* Parse args required to build the message */
13466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13468 if (unformat (input, "del"))
13472 else if (unformat (input, "locator-set %s", &locator_set_name))
13474 locator_set_name_set = 1;
13476 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13479 sw_if_index_if_name_set = 1;
13480 sw_if_index = tmp_if_index;
13482 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13484 sw_if_index_set = 1;
13485 sw_if_index = tmp_if_index;
13487 else if (unformat (input, "p %d", &priority))
13491 else if (unformat (input, "w %d", &weight))
13499 if (locator_set_name_set == 0)
13501 errmsg ("missing locator-set name");
13505 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13507 errmsg ("missing sw_if_index");
13508 vec_free (locator_set_name);
13512 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13514 errmsg ("cannot use both params interface name and sw_if_index");
13515 vec_free (locator_set_name);
13519 if (priority_set == 0)
13521 errmsg ("missing locator-set priority");
13522 vec_free (locator_set_name);
13526 if (weight_set == 0)
13528 errmsg ("missing locator-set weight");
13529 vec_free (locator_set_name);
13533 if (vec_len (locator_set_name) > 64)
13535 errmsg ("locator-set name too long");
13536 vec_free (locator_set_name);
13539 vec_add1 (locator_set_name, 0);
13541 /* Construct the API message */
13542 M (ONE_ADD_DEL_LOCATOR, mp);
13544 mp->is_add = is_add;
13545 mp->sw_if_index = ntohl (sw_if_index);
13546 mp->priority = priority;
13547 mp->weight = weight;
13548 clib_memcpy (mp->locator_set_name, locator_set_name,
13549 vec_len (locator_set_name));
13550 vec_free (locator_set_name);
13555 /* Wait for a reply... */
13560 #define api_lisp_add_del_locator api_one_add_del_locator
13563 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13565 u32 *key_id = va_arg (*args, u32 *);
13568 if (unformat (input, "%s", &s))
13570 if (!strcmp ((char *) s, "sha1"))
13571 key_id[0] = HMAC_SHA_1_96;
13572 else if (!strcmp ((char *) s, "sha256"))
13573 key_id[0] = HMAC_SHA_256_128;
13576 clib_warning ("invalid key_id: '%s'", s);
13577 key_id[0] = HMAC_NO_KEY;
13588 api_one_add_del_local_eid (vat_main_t * vam)
13590 unformat_input_t *input = vam->input;
13591 vl_api_one_add_del_local_eid_t *mp;
13594 lisp_eid_vat_t _eid, *eid = &_eid;
13595 u8 *locator_set_name = 0;
13596 u8 locator_set_name_set = 0;
13602 /* Parse args required to build the message */
13603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13605 if (unformat (input, "del"))
13609 else if (unformat (input, "vni %d", &vni))
13613 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13617 else if (unformat (input, "locator-set %s", &locator_set_name))
13619 locator_set_name_set = 1;
13621 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13623 else if (unformat (input, "secret-key %_%v%_", &key))
13629 if (locator_set_name_set == 0)
13631 errmsg ("missing locator-set name");
13637 errmsg ("EID address not set!");
13638 vec_free (locator_set_name);
13642 if (key && (0 == key_id))
13644 errmsg ("invalid key_id!");
13648 if (vec_len (key) > 64)
13650 errmsg ("key too long");
13655 if (vec_len (locator_set_name) > 64)
13657 errmsg ("locator-set name too long");
13658 vec_free (locator_set_name);
13661 vec_add1 (locator_set_name, 0);
13663 /* Construct the API message */
13664 M (ONE_ADD_DEL_LOCAL_EID, mp);
13666 mp->is_add = is_add;
13667 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13668 mp->eid_type = eid->type;
13669 mp->prefix_len = eid->len;
13670 mp->vni = clib_host_to_net_u32 (vni);
13671 mp->key_id = clib_host_to_net_u16 (key_id);
13672 clib_memcpy (mp->locator_set_name, locator_set_name,
13673 vec_len (locator_set_name));
13674 clib_memcpy (mp->key, key, vec_len (key));
13676 vec_free (locator_set_name);
13682 /* Wait for a reply... */
13687 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13690 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13692 u32 dp_table = 0, vni = 0;;
13693 unformat_input_t *input = vam->input;
13694 vl_api_gpe_add_del_fwd_entry_t *mp;
13696 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13697 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13698 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13699 u32 action = ~0, w;
13700 ip4_address_t rmt_rloc4, lcl_rloc4;
13701 ip6_address_t rmt_rloc6, lcl_rloc6;
13702 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13705 memset (&rloc, 0, sizeof (rloc));
13707 /* Parse args required to build the message */
13708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13710 if (unformat (input, "del"))
13712 else if (unformat (input, "add"))
13714 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13718 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13722 else if (unformat (input, "vrf %d", &dp_table))
13724 else if (unformat (input, "bd %d", &dp_table))
13726 else if (unformat (input, "vni %d", &vni))
13728 else if (unformat (input, "w %d", &w))
13732 errmsg ("No RLOC configured for setting priority/weight!");
13735 curr_rloc->weight = w;
13737 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13738 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13742 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13744 vec_add1 (lcl_locs, rloc);
13746 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13747 vec_add1 (rmt_locs, rloc);
13748 /* weight saved in rmt loc */
13749 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13751 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13752 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13755 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13757 vec_add1 (lcl_locs, rloc);
13759 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13760 vec_add1 (rmt_locs, rloc);
13761 /* weight saved in rmt loc */
13762 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13764 else if (unformat (input, "action %d", &action))
13770 clib_warning ("parse error '%U'", format_unformat_error, input);
13777 errmsg ("remote eid addresses not set");
13781 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13783 errmsg ("eid types don't match");
13787 if (0 == rmt_locs && (u32) ~ 0 == action)
13789 errmsg ("action not set for negative mapping");
13793 /* Construct the API message */
13794 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13795 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13797 mp->is_add = is_add;
13798 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13799 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13800 mp->eid_type = rmt_eid->type;
13801 mp->dp_table = clib_host_to_net_u32 (dp_table);
13802 mp->vni = clib_host_to_net_u32 (vni);
13803 mp->rmt_len = rmt_eid->len;
13804 mp->lcl_len = lcl_eid->len;
13805 mp->action = action;
13807 if (0 != rmt_locs && 0 != lcl_locs)
13809 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13810 clib_memcpy (mp->locs, lcl_locs,
13811 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13813 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13814 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13815 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13817 vec_free (lcl_locs);
13818 vec_free (rmt_locs);
13823 /* Wait for a reply... */
13829 api_one_add_del_map_server (vat_main_t * vam)
13831 unformat_input_t *input = vam->input;
13832 vl_api_one_add_del_map_server_t *mp;
13836 ip4_address_t ipv4;
13837 ip6_address_t ipv6;
13840 /* Parse args required to build the message */
13841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13843 if (unformat (input, "del"))
13847 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13851 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13859 if (ipv4_set && ipv6_set)
13861 errmsg ("both eid v4 and v6 addresses set");
13865 if (!ipv4_set && !ipv6_set)
13867 errmsg ("eid addresses not set");
13871 /* Construct the API message */
13872 M (ONE_ADD_DEL_MAP_SERVER, mp);
13874 mp->is_add = is_add;
13878 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13883 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13889 /* Wait for a reply... */
13894 #define api_lisp_add_del_map_server api_one_add_del_map_server
13897 api_one_add_del_map_resolver (vat_main_t * vam)
13899 unformat_input_t *input = vam->input;
13900 vl_api_one_add_del_map_resolver_t *mp;
13904 ip4_address_t ipv4;
13905 ip6_address_t ipv6;
13908 /* Parse args required to build the message */
13909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13911 if (unformat (input, "del"))
13915 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13919 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13927 if (ipv4_set && ipv6_set)
13929 errmsg ("both eid v4 and v6 addresses set");
13933 if (!ipv4_set && !ipv6_set)
13935 errmsg ("eid addresses not set");
13939 /* Construct the API message */
13940 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13942 mp->is_add = is_add;
13946 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13951 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13957 /* Wait for a reply... */
13962 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
13965 api_lisp_gpe_enable_disable (vat_main_t * vam)
13967 unformat_input_t *input = vam->input;
13968 vl_api_gpe_enable_disable_t *mp;
13973 /* Parse args required to build the message */
13974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13976 if (unformat (input, "enable"))
13981 else if (unformat (input, "disable"))
13992 errmsg ("Value not set");
13996 /* Construct the API message */
13997 M (GPE_ENABLE_DISABLE, mp);
14004 /* Wait for a reply... */
14010 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14012 unformat_input_t *input = vam->input;
14013 vl_api_one_rloc_probe_enable_disable_t *mp;
14018 /* Parse args required to build the message */
14019 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14021 if (unformat (input, "enable"))
14026 else if (unformat (input, "disable"))
14034 errmsg ("Value not set");
14038 /* Construct the API message */
14039 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14041 mp->is_enabled = is_en;
14046 /* Wait for a reply... */
14051 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14054 api_one_map_register_enable_disable (vat_main_t * vam)
14056 unformat_input_t *input = vam->input;
14057 vl_api_one_map_register_enable_disable_t *mp;
14062 /* Parse args required to build the message */
14063 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14065 if (unformat (input, "enable"))
14070 else if (unformat (input, "disable"))
14078 errmsg ("Value not set");
14082 /* Construct the API message */
14083 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14085 mp->is_enabled = is_en;
14090 /* Wait for a reply... */
14095 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14098 api_one_enable_disable (vat_main_t * vam)
14100 unformat_input_t *input = vam->input;
14101 vl_api_one_enable_disable_t *mp;
14106 /* Parse args required to build the message */
14107 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14109 if (unformat (input, "enable"))
14114 else if (unformat (input, "disable"))
14124 errmsg ("Value not set");
14128 /* Construct the API message */
14129 M (ONE_ENABLE_DISABLE, mp);
14136 /* Wait for a reply... */
14141 #define api_lisp_enable_disable api_one_enable_disable
14144 api_show_one_map_register_state (vat_main_t * vam)
14146 vl_api_show_one_map_register_state_t *mp;
14149 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14154 /* wait for reply */
14159 #define api_show_lisp_map_register_state api_show_one_map_register_state
14162 api_show_one_rloc_probe_state (vat_main_t * vam)
14164 vl_api_show_one_rloc_probe_state_t *mp;
14167 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14172 /* wait for reply */
14177 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14180 api_show_one_map_request_mode (vat_main_t * vam)
14182 vl_api_show_one_map_request_mode_t *mp;
14185 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14190 /* wait for reply */
14195 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14198 api_one_map_request_mode (vat_main_t * vam)
14200 unformat_input_t *input = vam->input;
14201 vl_api_one_map_request_mode_t *mp;
14205 /* Parse args required to build the message */
14206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14208 if (unformat (input, "dst-only"))
14210 else if (unformat (input, "src-dst"))
14214 errmsg ("parse error '%U'", format_unformat_error, input);
14219 M (ONE_MAP_REQUEST_MODE, mp);
14226 /* wait for reply */
14231 #define api_lisp_map_request_mode api_one_map_request_mode
14234 * Enable/disable ONE proxy ITR.
14236 * @param vam vpp API test context
14237 * @return return code
14240 api_one_pitr_set_locator_set (vat_main_t * vam)
14242 u8 ls_name_set = 0;
14243 unformat_input_t *input = vam->input;
14244 vl_api_one_pitr_set_locator_set_t *mp;
14249 /* Parse args required to build the message */
14250 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14252 if (unformat (input, "del"))
14254 else if (unformat (input, "locator-set %s", &ls_name))
14258 errmsg ("parse error '%U'", format_unformat_error, input);
14265 errmsg ("locator-set name not set!");
14269 M (ONE_PITR_SET_LOCATOR_SET, mp);
14271 mp->is_add = is_add;
14272 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14273 vec_free (ls_name);
14278 /* wait for reply */
14283 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14286 api_show_one_pitr (vat_main_t * vam)
14288 vl_api_show_one_pitr_t *mp;
14291 if (!vam->json_output)
14293 print (vam->ofp, "%=20s", "lisp status:");
14296 M (SHOW_ONE_PITR, mp);
14300 /* Wait for a reply... */
14305 #define api_show_lisp_pitr api_show_one_pitr
14308 * Add/delete mapping between vni and vrf
14311 api_one_eid_table_add_del_map (vat_main_t * vam)
14313 unformat_input_t *input = vam->input;
14314 vl_api_one_eid_table_add_del_map_t *mp;
14315 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14316 u32 vni, vrf, bd_index;
14319 /* Parse args required to build the message */
14320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14322 if (unformat (input, "del"))
14324 else if (unformat (input, "vrf %d", &vrf))
14326 else if (unformat (input, "bd_index %d", &bd_index))
14328 else if (unformat (input, "vni %d", &vni))
14334 if (!vni_set || (!vrf_set && !bd_index_set))
14336 errmsg ("missing arguments!");
14340 if (vrf_set && bd_index_set)
14342 errmsg ("error: both vrf and bd entered!");
14346 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14348 mp->is_add = is_add;
14349 mp->vni = htonl (vni);
14350 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14351 mp->is_l2 = bd_index_set;
14356 /* wait for reply */
14361 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14364 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14366 u32 *action = va_arg (*args, u32 *);
14369 if (unformat (input, "%s", &s))
14371 if (!strcmp ((char *) s, "no-action"))
14373 else if (!strcmp ((char *) s, "natively-forward"))
14375 else if (!strcmp ((char *) s, "send-map-request"))
14377 else if (!strcmp ((char *) s, "drop"))
14381 clib_warning ("invalid action: '%s'", s);
14393 * Add/del remote mapping to/from ONE control plane
14395 * @param vam vpp API test context
14396 * @return return code
14399 api_one_add_del_remote_mapping (vat_main_t * vam)
14401 unformat_input_t *input = vam->input;
14402 vl_api_one_add_del_remote_mapping_t *mp;
14404 lisp_eid_vat_t _eid, *eid = &_eid;
14405 lisp_eid_vat_t _seid, *seid = &_seid;
14406 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14407 u32 action = ~0, p, w, data_len;
14408 ip4_address_t rloc4;
14409 ip6_address_t rloc6;
14410 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14413 memset (&rloc, 0, sizeof (rloc));
14415 /* Parse args required to build the message */
14416 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14418 if (unformat (input, "del-all"))
14422 else if (unformat (input, "del"))
14426 else if (unformat (input, "add"))
14430 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14434 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14438 else if (unformat (input, "vni %d", &vni))
14442 else if (unformat (input, "p %d w %d", &p, &w))
14446 errmsg ("No RLOC configured for setting priority/weight!");
14449 curr_rloc->priority = p;
14450 curr_rloc->weight = w;
14452 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14455 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14456 vec_add1 (rlocs, rloc);
14457 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14459 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14462 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14463 vec_add1 (rlocs, rloc);
14464 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14466 else if (unformat (input, "action %U",
14467 unformat_negative_mapping_action, &action))
14473 clib_warning ("parse error '%U'", format_unformat_error, input);
14480 errmsg ("missing params!");
14484 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14486 errmsg ("no action set for negative map-reply!");
14490 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14492 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14493 mp->is_add = is_add;
14494 mp->vni = htonl (vni);
14495 mp->action = (u8) action;
14496 mp->is_src_dst = seid_set;
14497 mp->eid_len = eid->len;
14498 mp->seid_len = seid->len;
14499 mp->del_all = del_all;
14500 mp->eid_type = eid->type;
14501 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14502 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14504 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14505 clib_memcpy (mp->rlocs, rlocs, data_len);
14511 /* Wait for a reply... */
14516 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14519 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14520 * forwarding entries in data-plane accordingly.
14522 * @param vam vpp API test context
14523 * @return return code
14526 api_one_add_del_adjacency (vat_main_t * vam)
14528 unformat_input_t *input = vam->input;
14529 vl_api_one_add_del_adjacency_t *mp;
14531 ip4_address_t leid4, reid4;
14532 ip6_address_t leid6, reid6;
14533 u8 reid_mac[6] = { 0 };
14534 u8 leid_mac[6] = { 0 };
14535 u8 reid_type, leid_type;
14536 u32 leid_len = 0, reid_len = 0, len;
14540 leid_type = reid_type = (u8) ~ 0;
14542 /* Parse args required to build the message */
14543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14545 if (unformat (input, "del"))
14549 else if (unformat (input, "add"))
14553 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14556 reid_type = 0; /* ipv4 */
14559 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14562 reid_type = 1; /* ipv6 */
14565 else if (unformat (input, "reid %U", unformat_ethernet_address,
14568 reid_type = 2; /* mac */
14570 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14573 leid_type = 0; /* ipv4 */
14576 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14579 leid_type = 1; /* ipv6 */
14582 else if (unformat (input, "leid %U", unformat_ethernet_address,
14585 leid_type = 2; /* mac */
14587 else if (unformat (input, "vni %d", &vni))
14593 errmsg ("parse error '%U'", format_unformat_error, input);
14598 if ((u8) ~ 0 == reid_type)
14600 errmsg ("missing params!");
14604 if (leid_type != reid_type)
14606 errmsg ("remote and local EIDs are of different types!");
14610 M (ONE_ADD_DEL_ADJACENCY, mp);
14611 mp->is_add = is_add;
14612 mp->vni = htonl (vni);
14613 mp->leid_len = leid_len;
14614 mp->reid_len = reid_len;
14615 mp->eid_type = reid_type;
14617 switch (mp->eid_type)
14620 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14621 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14624 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14625 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14628 clib_memcpy (mp->leid, leid_mac, 6);
14629 clib_memcpy (mp->reid, reid_mac, 6);
14632 errmsg ("unknown EID type %d!", mp->eid_type);
14639 /* Wait for a reply... */
14644 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14647 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14649 u32 *mode = va_arg (*args, u32 *);
14651 if (unformat (input, "lisp"))
14653 else if (unformat (input, "vxlan"))
14662 api_gpe_get_encap_mode (vat_main_t * vam)
14664 vl_api_gpe_get_encap_mode_t *mp;
14667 /* Construct the API message */
14668 M (GPE_GET_ENCAP_MODE, mp);
14673 /* Wait for a reply... */
14679 api_gpe_set_encap_mode (vat_main_t * vam)
14681 unformat_input_t *input = vam->input;
14682 vl_api_gpe_set_encap_mode_t *mp;
14686 /* Parse args required to build the message */
14687 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14689 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14695 /* Construct the API message */
14696 M (GPE_SET_ENCAP_MODE, mp);
14703 /* Wait for a reply... */
14709 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14711 unformat_input_t *input = vam->input;
14712 vl_api_gpe_add_del_iface_t *mp;
14713 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14714 u32 dp_table = 0, vni = 0;
14717 /* Parse args required to build the message */
14718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14720 if (unformat (input, "up"))
14725 else if (unformat (input, "down"))
14730 else if (unformat (input, "table_id %d", &dp_table))
14734 else if (unformat (input, "bd_id %d", &dp_table))
14739 else if (unformat (input, "vni %d", &vni))
14747 if (action_set == 0)
14749 errmsg ("Action not set");
14752 if (dp_table_set == 0 || vni_set == 0)
14754 errmsg ("vni and dp_table must be set");
14758 /* Construct the API message */
14759 M (GPE_ADD_DEL_IFACE, mp);
14761 mp->is_add = is_add;
14762 mp->dp_table = dp_table;
14769 /* Wait for a reply... */
14775 * Add/del map request itr rlocs from ONE control plane and updates
14777 * @param vam vpp API test context
14778 * @return return code
14781 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14783 unformat_input_t *input = vam->input;
14784 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14785 u8 *locator_set_name = 0;
14786 u8 locator_set_name_set = 0;
14790 /* Parse args required to build the message */
14791 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14793 if (unformat (input, "del"))
14797 else if (unformat (input, "%_%v%_", &locator_set_name))
14799 locator_set_name_set = 1;
14803 clib_warning ("parse error '%U'", format_unformat_error, input);
14808 if (is_add && !locator_set_name_set)
14810 errmsg ("itr-rloc is not set!");
14814 if (is_add && vec_len (locator_set_name) > 64)
14816 errmsg ("itr-rloc locator-set name too long");
14817 vec_free (locator_set_name);
14821 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14822 mp->is_add = is_add;
14825 clib_memcpy (mp->locator_set_name, locator_set_name,
14826 vec_len (locator_set_name));
14830 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14832 vec_free (locator_set_name);
14837 /* Wait for a reply... */
14842 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14845 api_one_locator_dump (vat_main_t * vam)
14847 unformat_input_t *input = vam->input;
14848 vl_api_one_locator_dump_t *mp;
14849 vl_api_control_ping_t *mp_ping;
14850 u8 is_index_set = 0, is_name_set = 0;
14855 /* Parse args required to build the message */
14856 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14858 if (unformat (input, "ls_name %_%v%_", &ls_name))
14862 else if (unformat (input, "ls_index %d", &ls_index))
14868 errmsg ("parse error '%U'", format_unformat_error, input);
14873 if (!is_index_set && !is_name_set)
14875 errmsg ("error: expected one of index or name!");
14879 if (is_index_set && is_name_set)
14881 errmsg ("error: only one param expected!");
14885 if (vec_len (ls_name) > 62)
14887 errmsg ("error: locator set name too long!");
14891 if (!vam->json_output)
14893 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14896 M (ONE_LOCATOR_DUMP, mp);
14897 mp->is_index_set = is_index_set;
14900 mp->ls_index = clib_host_to_net_u32 (ls_index);
14903 vec_add1 (ls_name, 0);
14904 strncpy ((char *) mp->ls_name, (char *) ls_name,
14905 sizeof (mp->ls_name) - 1);
14911 /* Use a control ping for synchronization */
14912 M (CONTROL_PING, mp_ping);
14915 /* Wait for a reply... */
14920 #define api_lisp_locator_dump api_one_locator_dump
14923 api_one_locator_set_dump (vat_main_t * vam)
14925 vl_api_one_locator_set_dump_t *mp;
14926 vl_api_control_ping_t *mp_ping;
14927 unformat_input_t *input = vam->input;
14931 /* Parse args required to build the message */
14932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14934 if (unformat (input, "local"))
14938 else if (unformat (input, "remote"))
14944 errmsg ("parse error '%U'", format_unformat_error, input);
14949 if (!vam->json_output)
14951 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14954 M (ONE_LOCATOR_SET_DUMP, mp);
14956 mp->filter = filter;
14961 /* Use a control ping for synchronization */
14962 M (CONTROL_PING, mp_ping);
14965 /* Wait for a reply... */
14970 #define api_lisp_locator_set_dump api_one_locator_set_dump
14973 api_one_eid_table_map_dump (vat_main_t * vam)
14977 unformat_input_t *input = vam->input;
14978 vl_api_one_eid_table_map_dump_t *mp;
14979 vl_api_control_ping_t *mp_ping;
14982 /* Parse args required to build the message */
14983 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14985 if (unformat (input, "l2"))
14990 else if (unformat (input, "l3"))
14997 errmsg ("parse error '%U'", format_unformat_error, input);
15004 errmsg ("expected one of 'l2' or 'l3' parameter!");
15008 if (!vam->json_output)
15010 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
15013 M (ONE_EID_TABLE_MAP_DUMP, mp);
15019 /* Use a control ping for synchronization */
15020 M (CONTROL_PING, mp_ping);
15023 /* Wait for a reply... */
15028 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
15031 api_one_eid_table_vni_dump (vat_main_t * vam)
15033 vl_api_one_eid_table_vni_dump_t *mp;
15034 vl_api_control_ping_t *mp_ping;
15037 if (!vam->json_output)
15039 print (vam->ofp, "VNI");
15042 M (ONE_EID_TABLE_VNI_DUMP, mp);
15047 /* Use a control ping for synchronization */
15048 M (CONTROL_PING, mp_ping);
15051 /* Wait for a reply... */
15056 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
15059 api_one_eid_table_dump (vat_main_t * vam)
15061 unformat_input_t *i = vam->input;
15062 vl_api_one_eid_table_dump_t *mp;
15063 vl_api_control_ping_t *mp_ping;
15064 struct in_addr ip4;
15065 struct in6_addr ip6;
15067 u8 eid_type = ~0, eid_set = 0;
15068 u32 prefix_length = ~0, t, vni = 0;
15072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15074 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
15080 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
15086 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
15091 else if (unformat (i, "vni %d", &t))
15095 else if (unformat (i, "local"))
15099 else if (unformat (i, "remote"))
15105 errmsg ("parse error '%U'", format_unformat_error, i);
15110 if (!vam->json_output)
15112 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
15113 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
15116 M (ONE_EID_TABLE_DUMP, mp);
15118 mp->filter = filter;
15122 mp->vni = htonl (vni);
15123 mp->eid_type = eid_type;
15127 mp->prefix_length = prefix_length;
15128 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
15131 mp->prefix_length = prefix_length;
15132 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15135 clib_memcpy (mp->eid, mac, sizeof (mac));
15138 errmsg ("unknown EID type %d!", eid_type);
15146 /* Use a control ping for synchronization */
15147 M (CONTROL_PING, mp_ping);
15150 /* Wait for a reply... */
15155 #define api_lisp_eid_table_dump api_one_eid_table_dump
15158 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15160 unformat_input_t *i = vam->input;
15161 vl_api_gpe_fwd_entries_get_t *mp;
15166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15168 if (unformat (i, "vni %d", &vni))
15174 errmsg ("parse error '%U'", format_unformat_error, i);
15181 errmsg ("vni not set!");
15185 if (!vam->json_output)
15187 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15191 M (GPE_FWD_ENTRIES_GET, mp);
15192 mp->vni = clib_host_to_net_u32 (vni);
15197 /* Wait for a reply... */
15202 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15203 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15204 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15205 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15208 api_one_adjacencies_get (vat_main_t * vam)
15210 unformat_input_t *i = vam->input;
15211 vl_api_one_adjacencies_get_t *mp;
15216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15218 if (unformat (i, "vni %d", &vni))
15224 errmsg ("parse error '%U'", format_unformat_error, i);
15231 errmsg ("vni not set!");
15235 if (!vam->json_output)
15237 print (vam->ofp, "%s %40s", "leid", "reid");
15240 M (ONE_ADJACENCIES_GET, mp);
15241 mp->vni = clib_host_to_net_u32 (vni);
15246 /* Wait for a reply... */
15251 #define api_lisp_adjacencies_get api_one_adjacencies_get
15254 api_one_map_server_dump (vat_main_t * vam)
15256 vl_api_one_map_server_dump_t *mp;
15257 vl_api_control_ping_t *mp_ping;
15260 if (!vam->json_output)
15262 print (vam->ofp, "%=20s", "Map server");
15265 M (ONE_MAP_SERVER_DUMP, mp);
15269 /* Use a control ping for synchronization */
15270 M (CONTROL_PING, mp_ping);
15273 /* Wait for a reply... */
15278 #define api_lisp_map_server_dump api_one_map_server_dump
15281 api_one_map_resolver_dump (vat_main_t * vam)
15283 vl_api_one_map_resolver_dump_t *mp;
15284 vl_api_control_ping_t *mp_ping;
15287 if (!vam->json_output)
15289 print (vam->ofp, "%=20s", "Map resolver");
15292 M (ONE_MAP_RESOLVER_DUMP, mp);
15296 /* Use a control ping for synchronization */
15297 M (CONTROL_PING, mp_ping);
15300 /* Wait for a reply... */
15305 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15308 api_show_one_status (vat_main_t * vam)
15310 vl_api_show_one_status_t *mp;
15313 if (!vam->json_output)
15315 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15318 M (SHOW_ONE_STATUS, mp);
15321 /* Wait for a reply... */
15326 #define api_show_lisp_status api_show_one_status
15329 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15331 vl_api_gpe_fwd_entry_path_dump_t *mp;
15332 vl_api_control_ping_t *mp_ping;
15333 unformat_input_t *i = vam->input;
15334 u32 fwd_entry_index = ~0;
15337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15339 if (unformat (i, "index %d", &fwd_entry_index))
15345 if (~0 == fwd_entry_index)
15347 errmsg ("no index specified!");
15351 if (!vam->json_output)
15353 print (vam->ofp, "first line");
15356 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15360 /* Use a control ping for synchronization */
15361 M (CONTROL_PING, mp_ping);
15364 /* Wait for a reply... */
15370 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15372 vl_api_one_get_map_request_itr_rlocs_t *mp;
15375 if (!vam->json_output)
15377 print (vam->ofp, "%=20s", "itr-rlocs:");
15380 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15383 /* Wait for a reply... */
15388 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15391 api_af_packet_create (vat_main_t * vam)
15393 unformat_input_t *i = vam->input;
15394 vl_api_af_packet_create_t *mp;
15395 u8 *host_if_name = 0;
15397 u8 random_hw_addr = 1;
15400 memset (hw_addr, 0, sizeof (hw_addr));
15402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15404 if (unformat (i, "name %s", &host_if_name))
15405 vec_add1 (host_if_name, 0);
15406 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15407 random_hw_addr = 0;
15412 if (!vec_len (host_if_name))
15414 errmsg ("host-interface name must be specified");
15418 if (vec_len (host_if_name) > 64)
15420 errmsg ("host-interface name too long");
15424 M (AF_PACKET_CREATE, mp);
15426 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15427 clib_memcpy (mp->hw_addr, hw_addr, 6);
15428 mp->use_random_hw_addr = random_hw_addr;
15429 vec_free (host_if_name);
15432 W2 (ret, fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
15437 api_af_packet_delete (vat_main_t * vam)
15439 unformat_input_t *i = vam->input;
15440 vl_api_af_packet_delete_t *mp;
15441 u8 *host_if_name = 0;
15444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15446 if (unformat (i, "name %s", &host_if_name))
15447 vec_add1 (host_if_name, 0);
15452 if (!vec_len (host_if_name))
15454 errmsg ("host-interface name must be specified");
15458 if (vec_len (host_if_name) > 64)
15460 errmsg ("host-interface name too long");
15464 M (AF_PACKET_DELETE, mp);
15466 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15467 vec_free (host_if_name);
15475 api_policer_add_del (vat_main_t * vam)
15477 unformat_input_t *i = vam->input;
15478 vl_api_policer_add_del_t *mp;
15488 u8 color_aware = 0;
15489 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15492 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15493 conform_action.dscp = 0;
15494 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15495 exceed_action.dscp = 0;
15496 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15497 violate_action.dscp = 0;
15499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15501 if (unformat (i, "del"))
15503 else if (unformat (i, "name %s", &name))
15504 vec_add1 (name, 0);
15505 else if (unformat (i, "cir %u", &cir))
15507 else if (unformat (i, "eir %u", &eir))
15509 else if (unformat (i, "cb %u", &cb))
15511 else if (unformat (i, "eb %u", &eb))
15513 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15516 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15519 else if (unformat (i, "type %U", unformat_policer_type, &type))
15521 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15524 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15527 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15530 else if (unformat (i, "color-aware"))
15536 if (!vec_len (name))
15538 errmsg ("policer name must be specified");
15542 if (vec_len (name) > 64)
15544 errmsg ("policer name too long");
15548 M (POLICER_ADD_DEL, mp);
15550 clib_memcpy (mp->name, name, vec_len (name));
15552 mp->is_add = is_add;
15557 mp->rate_type = rate_type;
15558 mp->round_type = round_type;
15560 mp->conform_action_type = conform_action.action_type;
15561 mp->conform_dscp = conform_action.dscp;
15562 mp->exceed_action_type = exceed_action.action_type;
15563 mp->exceed_dscp = exceed_action.dscp;
15564 mp->violate_action_type = violate_action.action_type;
15565 mp->violate_dscp = violate_action.dscp;
15566 mp->color_aware = color_aware;
15574 api_policer_dump (vat_main_t * vam)
15576 unformat_input_t *i = vam->input;
15577 vl_api_policer_dump_t *mp;
15578 vl_api_control_ping_t *mp_ping;
15579 u8 *match_name = 0;
15580 u8 match_name_valid = 0;
15583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15585 if (unformat (i, "name %s", &match_name))
15587 vec_add1 (match_name, 0);
15588 match_name_valid = 1;
15594 M (POLICER_DUMP, mp);
15595 mp->match_name_valid = match_name_valid;
15596 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15597 vec_free (match_name);
15601 /* Use a control ping for synchronization */
15602 M (CONTROL_PING, mp_ping);
15605 /* Wait for a reply... */
15611 api_policer_classify_set_interface (vat_main_t * vam)
15613 unformat_input_t *i = vam->input;
15614 vl_api_policer_classify_set_interface_t *mp;
15616 int sw_if_index_set;
15617 u32 ip4_table_index = ~0;
15618 u32 ip6_table_index = ~0;
15619 u32 l2_table_index = ~0;
15623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15625 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15626 sw_if_index_set = 1;
15627 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15628 sw_if_index_set = 1;
15629 else if (unformat (i, "del"))
15631 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15633 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15635 else if (unformat (i, "l2-table %d", &l2_table_index))
15639 clib_warning ("parse error '%U'", format_unformat_error, i);
15644 if (sw_if_index_set == 0)
15646 errmsg ("missing interface name or sw_if_index");
15650 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15652 mp->sw_if_index = ntohl (sw_if_index);
15653 mp->ip4_table_index = ntohl (ip4_table_index);
15654 mp->ip6_table_index = ntohl (ip6_table_index);
15655 mp->l2_table_index = ntohl (l2_table_index);
15656 mp->is_add = is_add;
15664 api_policer_classify_dump (vat_main_t * vam)
15666 unformat_input_t *i = vam->input;
15667 vl_api_policer_classify_dump_t *mp;
15668 vl_api_control_ping_t *mp_ping;
15669 u8 type = POLICER_CLASSIFY_N_TABLES;
15672 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15676 errmsg ("classify table type must be specified");
15680 if (!vam->json_output)
15682 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15685 M (POLICER_CLASSIFY_DUMP, mp);
15690 /* Use a control ping for synchronization */
15691 M (CONTROL_PING, mp_ping);
15694 /* Wait for a reply... */
15700 api_netmap_create (vat_main_t * vam)
15702 unformat_input_t *i = vam->input;
15703 vl_api_netmap_create_t *mp;
15706 u8 random_hw_addr = 1;
15711 memset (hw_addr, 0, sizeof (hw_addr));
15713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15715 if (unformat (i, "name %s", &if_name))
15716 vec_add1 (if_name, 0);
15717 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15718 random_hw_addr = 0;
15719 else if (unformat (i, "pipe"))
15721 else if (unformat (i, "master"))
15723 else if (unformat (i, "slave"))
15729 if (!vec_len (if_name))
15731 errmsg ("interface name must be specified");
15735 if (vec_len (if_name) > 64)
15737 errmsg ("interface name too long");
15741 M (NETMAP_CREATE, mp);
15743 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15744 clib_memcpy (mp->hw_addr, hw_addr, 6);
15745 mp->use_random_hw_addr = random_hw_addr;
15746 mp->is_pipe = is_pipe;
15747 mp->is_master = is_master;
15748 vec_free (if_name);
15756 api_netmap_delete (vat_main_t * vam)
15758 unformat_input_t *i = vam->input;
15759 vl_api_netmap_delete_t *mp;
15763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15765 if (unformat (i, "name %s", &if_name))
15766 vec_add1 (if_name, 0);
15771 if (!vec_len (if_name))
15773 errmsg ("interface name must be specified");
15777 if (vec_len (if_name) > 64)
15779 errmsg ("interface name too long");
15783 M (NETMAP_DELETE, mp);
15785 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15786 vec_free (if_name);
15793 static void vl_api_mpls_tunnel_details_t_handler
15794 (vl_api_mpls_tunnel_details_t * mp)
15796 vat_main_t *vam = &vat_main;
15797 i32 len = mp->mt_next_hop_n_labels;
15800 print (vam->ofp, "[%d]: via %U %d labels ",
15802 format_ip4_address, mp->mt_next_hop,
15803 ntohl (mp->mt_next_hop_sw_if_index));
15804 for (i = 0; i < len; i++)
15806 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15808 print (vam->ofp, "");
15811 static void vl_api_mpls_tunnel_details_t_handler_json
15812 (vl_api_mpls_tunnel_details_t * mp)
15814 vat_main_t *vam = &vat_main;
15815 vat_json_node_t *node = NULL;
15816 struct in_addr ip4;
15818 i32 len = mp->mt_next_hop_n_labels;
15820 if (VAT_JSON_ARRAY != vam->json_tree.type)
15822 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15823 vat_json_init_array (&vam->json_tree);
15825 node = vat_json_array_add (&vam->json_tree);
15827 vat_json_init_object (node);
15828 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15829 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15830 vat_json_object_add_ip4 (node, "next_hop", ip4);
15831 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15832 ntohl (mp->mt_next_hop_sw_if_index));
15833 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15834 vat_json_object_add_uint (node, "label_count", len);
15835 for (i = 0; i < len; i++)
15837 vat_json_object_add_uint (node, "label",
15838 ntohl (mp->mt_next_hop_out_labels[i]));
15843 api_mpls_tunnel_dump (vat_main_t * vam)
15845 vl_api_mpls_tunnel_dump_t *mp;
15846 vl_api_control_ping_t *mp_ping;
15850 /* Parse args required to build the message */
15851 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15853 if (!unformat (vam->input, "tunnel_index %d", &index))
15860 print (vam->ofp, " tunnel_index %d", index);
15862 M (MPLS_TUNNEL_DUMP, mp);
15863 mp->tunnel_index = htonl (index);
15866 /* Use a control ping for synchronization */
15867 M (CONTROL_PING, mp_ping);
15874 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15875 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15878 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15880 vat_main_t *vam = &vat_main;
15881 int count = ntohl (mp->count);
15882 vl_api_fib_path2_t *fp;
15886 "table-id %d, label %u, ess_bit %u",
15887 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15889 for (i = 0; i < count; i++)
15891 if (fp->afi == IP46_TYPE_IP6)
15893 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15894 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15895 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15896 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15897 format_ip6_address, fp->next_hop);
15898 else if (fp->afi == IP46_TYPE_IP4)
15900 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15901 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15902 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15903 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15904 format_ip4_address, fp->next_hop);
15909 static void vl_api_mpls_fib_details_t_handler_json
15910 (vl_api_mpls_fib_details_t * mp)
15912 vat_main_t *vam = &vat_main;
15913 int count = ntohl (mp->count);
15914 vat_json_node_t *node = NULL;
15915 struct in_addr ip4;
15916 struct in6_addr ip6;
15917 vl_api_fib_path2_t *fp;
15920 if (VAT_JSON_ARRAY != vam->json_tree.type)
15922 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15923 vat_json_init_array (&vam->json_tree);
15925 node = vat_json_array_add (&vam->json_tree);
15927 vat_json_init_object (node);
15928 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15929 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15930 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15931 vat_json_object_add_uint (node, "path_count", count);
15933 for (i = 0; i < count; i++)
15935 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15936 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15937 vat_json_object_add_uint (node, "is_local", fp->is_local);
15938 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15939 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15940 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15941 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15942 if (fp->afi == IP46_TYPE_IP4)
15944 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15945 vat_json_object_add_ip4 (node, "next_hop", ip4);
15947 else if (fp->afi == IP46_TYPE_IP6)
15949 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15950 vat_json_object_add_ip6 (node, "next_hop", ip6);
15956 api_mpls_fib_dump (vat_main_t * vam)
15958 vl_api_mpls_fib_dump_t *mp;
15959 vl_api_control_ping_t *mp_ping;
15962 M (MPLS_FIB_DUMP, mp);
15965 /* Use a control ping for synchronization */
15966 M (CONTROL_PING, mp_ping);
15973 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15974 #define vl_api_ip_fib_details_t_print vl_noop_handler
15977 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15979 vat_main_t *vam = &vat_main;
15980 int count = ntohl (mp->count);
15981 vl_api_fib_path_t *fp;
15985 "table-id %d, prefix %U/%d",
15986 ntohl (mp->table_id), format_ip4_address, mp->address,
15987 mp->address_length);
15989 for (i = 0; i < count; i++)
15991 if (fp->afi == IP46_TYPE_IP6)
15993 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15994 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15995 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15996 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15997 format_ip6_address, fp->next_hop);
15998 else if (fp->afi == IP46_TYPE_IP4)
16000 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16001 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16002 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16003 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16004 format_ip4_address, fp->next_hop);
16009 static void vl_api_ip_fib_details_t_handler_json
16010 (vl_api_ip_fib_details_t * mp)
16012 vat_main_t *vam = &vat_main;
16013 int count = ntohl (mp->count);
16014 vat_json_node_t *node = NULL;
16015 struct in_addr ip4;
16016 struct in6_addr ip6;
16017 vl_api_fib_path_t *fp;
16020 if (VAT_JSON_ARRAY != vam->json_tree.type)
16022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16023 vat_json_init_array (&vam->json_tree);
16025 node = vat_json_array_add (&vam->json_tree);
16027 vat_json_init_object (node);
16028 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16029 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
16030 vat_json_object_add_ip4 (node, "prefix", ip4);
16031 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16032 vat_json_object_add_uint (node, "path_count", count);
16034 for (i = 0; i < count; i++)
16036 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16037 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16038 vat_json_object_add_uint (node, "is_local", fp->is_local);
16039 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16040 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16041 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16042 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16043 if (fp->afi == IP46_TYPE_IP4)
16045 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16046 vat_json_object_add_ip4 (node, "next_hop", ip4);
16048 else if (fp->afi == IP46_TYPE_IP6)
16050 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16051 vat_json_object_add_ip6 (node, "next_hop", ip6);
16057 api_ip_fib_dump (vat_main_t * vam)
16059 vl_api_ip_fib_dump_t *mp;
16060 vl_api_control_ping_t *mp_ping;
16063 M (IP_FIB_DUMP, mp);
16066 /* Use a control ping for synchronization */
16067 M (CONTROL_PING, mp_ping);
16075 api_ip_mfib_dump (vat_main_t * vam)
16077 vl_api_ip_mfib_dump_t *mp;
16078 vl_api_control_ping_t *mp_ping;
16081 M (IP_MFIB_DUMP, mp);
16084 /* Use a control ping for synchronization */
16085 M (CONTROL_PING, mp_ping);
16092 static void vl_api_ip_neighbor_details_t_handler
16093 (vl_api_ip_neighbor_details_t * mp)
16095 vat_main_t *vam = &vat_main;
16097 print (vam->ofp, "%c %U %U",
16098 (mp->is_static) ? 'S' : 'D',
16099 format_ethernet_address, &mp->mac_address,
16100 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
16104 static void vl_api_ip_neighbor_details_t_handler_json
16105 (vl_api_ip_neighbor_details_t * mp)
16108 vat_main_t *vam = &vat_main;
16109 vat_json_node_t *node;
16110 struct in_addr ip4;
16111 struct in6_addr ip6;
16113 if (VAT_JSON_ARRAY != vam->json_tree.type)
16115 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16116 vat_json_init_array (&vam->json_tree);
16118 node = vat_json_array_add (&vam->json_tree);
16120 vat_json_init_object (node);
16121 vat_json_object_add_string_copy (node, "flag",
16122 (mp->is_static) ? (u8 *) "static" : (u8 *)
16125 vat_json_object_add_string_copy (node, "link_layer",
16126 format (0, "%U", format_ethernet_address,
16127 &mp->mac_address));
16131 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16132 vat_json_object_add_ip6 (node, "ip_address", ip6);
16136 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16137 vat_json_object_add_ip4 (node, "ip_address", ip4);
16142 api_ip_neighbor_dump (vat_main_t * vam)
16144 unformat_input_t *i = vam->input;
16145 vl_api_ip_neighbor_dump_t *mp;
16146 vl_api_control_ping_t *mp_ping;
16148 u32 sw_if_index = ~0;
16151 /* Parse args required to build the message */
16152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16154 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16156 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16158 else if (unformat (i, "ip6"))
16164 if (sw_if_index == ~0)
16166 errmsg ("missing interface name or sw_if_index");
16170 M (IP_NEIGHBOR_DUMP, mp);
16171 mp->is_ipv6 = (u8) is_ipv6;
16172 mp->sw_if_index = ntohl (sw_if_index);
16175 /* Use a control ping for synchronization */
16176 M (CONTROL_PING, mp_ping);
16183 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16184 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16187 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16189 vat_main_t *vam = &vat_main;
16190 int count = ntohl (mp->count);
16191 vl_api_fib_path_t *fp;
16195 "table-id %d, prefix %U/%d",
16196 ntohl (mp->table_id), format_ip6_address, mp->address,
16197 mp->address_length);
16199 for (i = 0; i < count; i++)
16201 if (fp->afi == IP46_TYPE_IP6)
16203 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16204 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16205 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16206 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16207 format_ip6_address, fp->next_hop);
16208 else if (fp->afi == IP46_TYPE_IP4)
16210 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16211 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16212 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16213 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16214 format_ip4_address, fp->next_hop);
16219 static void vl_api_ip6_fib_details_t_handler_json
16220 (vl_api_ip6_fib_details_t * mp)
16222 vat_main_t *vam = &vat_main;
16223 int count = ntohl (mp->count);
16224 vat_json_node_t *node = NULL;
16225 struct in_addr ip4;
16226 struct in6_addr ip6;
16227 vl_api_fib_path_t *fp;
16230 if (VAT_JSON_ARRAY != vam->json_tree.type)
16232 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16233 vat_json_init_array (&vam->json_tree);
16235 node = vat_json_array_add (&vam->json_tree);
16237 vat_json_init_object (node);
16238 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16239 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16240 vat_json_object_add_ip6 (node, "prefix", ip6);
16241 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16242 vat_json_object_add_uint (node, "path_count", count);
16244 for (i = 0; i < count; i++)
16246 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16247 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16248 vat_json_object_add_uint (node, "is_local", fp->is_local);
16249 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16250 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16251 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16252 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16253 if (fp->afi == IP46_TYPE_IP4)
16255 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16256 vat_json_object_add_ip4 (node, "next_hop", ip4);
16258 else if (fp->afi == IP46_TYPE_IP6)
16260 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16261 vat_json_object_add_ip6 (node, "next_hop", ip6);
16267 api_ip6_fib_dump (vat_main_t * vam)
16269 vl_api_ip6_fib_dump_t *mp;
16270 vl_api_control_ping_t *mp_ping;
16273 M (IP6_FIB_DUMP, mp);
16276 /* Use a control ping for synchronization */
16277 M (CONTROL_PING, mp_ping);
16285 api_ip6_mfib_dump (vat_main_t * vam)
16287 vl_api_ip6_mfib_dump_t *mp;
16288 vl_api_control_ping_t *mp_ping;
16291 M (IP6_MFIB_DUMP, mp);
16294 /* Use a control ping for synchronization */
16295 M (CONTROL_PING, mp_ping);
16303 api_classify_table_ids (vat_main_t * vam)
16305 vl_api_classify_table_ids_t *mp;
16308 /* Construct the API message */
16309 M (CLASSIFY_TABLE_IDS, mp);
16318 api_classify_table_by_interface (vat_main_t * vam)
16320 unformat_input_t *input = vam->input;
16321 vl_api_classify_table_by_interface_t *mp;
16323 u32 sw_if_index = ~0;
16325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16327 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16329 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16334 if (sw_if_index == ~0)
16336 errmsg ("missing interface name or sw_if_index");
16340 /* Construct the API message */
16341 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16343 mp->sw_if_index = ntohl (sw_if_index);
16351 api_classify_table_info (vat_main_t * vam)
16353 unformat_input_t *input = vam->input;
16354 vl_api_classify_table_info_t *mp;
16358 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16360 if (unformat (input, "table_id %d", &table_id))
16365 if (table_id == ~0)
16367 errmsg ("missing table id");
16371 /* Construct the API message */
16372 M (CLASSIFY_TABLE_INFO, mp);
16374 mp->table_id = ntohl (table_id);
16382 api_classify_session_dump (vat_main_t * vam)
16384 unformat_input_t *input = vam->input;
16385 vl_api_classify_session_dump_t *mp;
16386 vl_api_control_ping_t *mp_ping;
16390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16392 if (unformat (input, "table_id %d", &table_id))
16397 if (table_id == ~0)
16399 errmsg ("missing table id");
16403 /* Construct the API message */
16404 M (CLASSIFY_SESSION_DUMP, mp);
16406 mp->table_id = ntohl (table_id);
16409 /* Use a control ping for synchronization */
16410 M (CONTROL_PING, mp_ping);
16418 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16420 vat_main_t *vam = &vat_main;
16422 print (vam->ofp, "collector_address %U, collector_port %d, "
16423 "src_address %U, vrf_id %d, path_mtu %u, "
16424 "template_interval %u, udp_checksum %d",
16425 format_ip4_address, mp->collector_address,
16426 ntohs (mp->collector_port),
16427 format_ip4_address, mp->src_address,
16428 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16429 ntohl (mp->template_interval), mp->udp_checksum);
16432 vam->result_ready = 1;
16436 vl_api_ipfix_exporter_details_t_handler_json
16437 (vl_api_ipfix_exporter_details_t * mp)
16439 vat_main_t *vam = &vat_main;
16440 vat_json_node_t node;
16441 struct in_addr collector_address;
16442 struct in_addr src_address;
16444 vat_json_init_object (&node);
16445 clib_memcpy (&collector_address, &mp->collector_address,
16446 sizeof (collector_address));
16447 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16448 vat_json_object_add_uint (&node, "collector_port",
16449 ntohs (mp->collector_port));
16450 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16451 vat_json_object_add_ip4 (&node, "src_address", src_address);
16452 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16453 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16454 vat_json_object_add_uint (&node, "template_interval",
16455 ntohl (mp->template_interval));
16456 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16458 vat_json_print (vam->ofp, &node);
16459 vat_json_free (&node);
16461 vam->result_ready = 1;
16465 api_ipfix_exporter_dump (vat_main_t * vam)
16467 vl_api_ipfix_exporter_dump_t *mp;
16470 /* Construct the API message */
16471 M (IPFIX_EXPORTER_DUMP, mp);
16480 api_ipfix_classify_stream_dump (vat_main_t * vam)
16482 vl_api_ipfix_classify_stream_dump_t *mp;
16485 /* Construct the API message */
16486 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16497 vl_api_ipfix_classify_stream_details_t_handler
16498 (vl_api_ipfix_classify_stream_details_t * mp)
16500 vat_main_t *vam = &vat_main;
16501 print (vam->ofp, "domain_id %d, src_port %d",
16502 ntohl (mp->domain_id), ntohs (mp->src_port));
16504 vam->result_ready = 1;
16508 vl_api_ipfix_classify_stream_details_t_handler_json
16509 (vl_api_ipfix_classify_stream_details_t * mp)
16511 vat_main_t *vam = &vat_main;
16512 vat_json_node_t node;
16514 vat_json_init_object (&node);
16515 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16516 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16518 vat_json_print (vam->ofp, &node);
16519 vat_json_free (&node);
16521 vam->result_ready = 1;
16525 api_ipfix_classify_table_dump (vat_main_t * vam)
16527 vl_api_ipfix_classify_table_dump_t *mp;
16528 vl_api_control_ping_t *mp_ping;
16531 if (!vam->json_output)
16533 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16534 "transport_protocol");
16537 /* Construct the API message */
16538 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16543 /* Use a control ping for synchronization */
16544 M (CONTROL_PING, mp_ping);
16552 vl_api_ipfix_classify_table_details_t_handler
16553 (vl_api_ipfix_classify_table_details_t * mp)
16555 vat_main_t *vam = &vat_main;
16556 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16557 mp->transport_protocol);
16561 vl_api_ipfix_classify_table_details_t_handler_json
16562 (vl_api_ipfix_classify_table_details_t * mp)
16564 vat_json_node_t *node = NULL;
16565 vat_main_t *vam = &vat_main;
16567 if (VAT_JSON_ARRAY != vam->json_tree.type)
16569 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16570 vat_json_init_array (&vam->json_tree);
16573 node = vat_json_array_add (&vam->json_tree);
16574 vat_json_init_object (node);
16576 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16577 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16578 vat_json_object_add_uint (node, "transport_protocol",
16579 mp->transport_protocol);
16583 api_sw_interface_span_enable_disable (vat_main_t * vam)
16585 unformat_input_t *i = vam->input;
16586 vl_api_sw_interface_span_enable_disable_t *mp;
16587 u32 src_sw_if_index = ~0;
16588 u32 dst_sw_if_index = ~0;
16592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16595 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16597 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16601 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16603 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16605 else if (unformat (i, "disable"))
16607 else if (unformat (i, "rx"))
16609 else if (unformat (i, "tx"))
16611 else if (unformat (i, "both"))
16617 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16619 mp->sw_if_index_from = htonl (src_sw_if_index);
16620 mp->sw_if_index_to = htonl (dst_sw_if_index);
16629 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16632 vat_main_t *vam = &vat_main;
16633 u8 *sw_if_from_name = 0;
16634 u8 *sw_if_to_name = 0;
16635 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16636 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16637 char *states[] = { "none", "rx", "tx", "both" };
16641 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16643 if ((u32) p->value[0] == sw_if_index_from)
16645 sw_if_from_name = (u8 *)(p->key);
16649 if ((u32) p->value[0] == sw_if_index_to)
16651 sw_if_to_name = (u8 *)(p->key);
16652 if (sw_if_from_name)
16657 print (vam->ofp, "%20s => %20s (%s)",
16658 sw_if_from_name, sw_if_to_name, states[mp->state]);
16662 vl_api_sw_interface_span_details_t_handler_json
16663 (vl_api_sw_interface_span_details_t * mp)
16665 vat_main_t *vam = &vat_main;
16666 vat_json_node_t *node = NULL;
16667 u8 *sw_if_from_name = 0;
16668 u8 *sw_if_to_name = 0;
16669 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16670 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16674 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16676 if ((u32) p->value[0] == sw_if_index_from)
16678 sw_if_from_name = (u8 *)(p->key);
16682 if ((u32) p->value[0] == sw_if_index_to)
16684 sw_if_to_name = (u8 *)(p->key);
16685 if (sw_if_from_name)
16691 if (VAT_JSON_ARRAY != vam->json_tree.type)
16693 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16694 vat_json_init_array (&vam->json_tree);
16696 node = vat_json_array_add (&vam->json_tree);
16698 vat_json_init_object (node);
16699 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16700 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16701 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16702 if (0 != sw_if_to_name)
16704 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16706 vat_json_object_add_uint (node, "state", mp->state);
16710 api_sw_interface_span_dump (vat_main_t * vam)
16712 vl_api_sw_interface_span_dump_t *mp;
16713 vl_api_control_ping_t *mp_ping;
16716 M (SW_INTERFACE_SPAN_DUMP, mp);
16719 /* Use a control ping for synchronization */
16720 M (CONTROL_PING, mp_ping);
16728 api_pg_create_interface (vat_main_t * vam)
16730 unformat_input_t *input = vam->input;
16731 vl_api_pg_create_interface_t *mp;
16735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16737 if (unformat (input, "if_id %d", &if_id))
16744 errmsg ("missing pg interface index");
16748 /* Construct the API message */
16749 M (PG_CREATE_INTERFACE, mp);
16751 mp->interface_id = ntohl (if_id);
16759 api_pg_capture (vat_main_t * vam)
16761 unformat_input_t *input = vam->input;
16762 vl_api_pg_capture_t *mp;
16767 u8 pcap_file_set = 0;
16770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16772 if (unformat (input, "if_id %d", &if_id))
16774 else if (unformat (input, "pcap %s", &pcap_file))
16776 else if (unformat (input, "count %d", &count))
16778 else if (unformat (input, "disable"))
16785 errmsg ("missing pg interface index");
16788 if (pcap_file_set > 0)
16790 if (vec_len (pcap_file) > 255)
16792 errmsg ("pcap file name is too long");
16797 u32 name_len = vec_len (pcap_file);
16798 /* Construct the API message */
16799 M (PG_CAPTURE, mp);
16801 mp->interface_id = ntohl (if_id);
16802 mp->is_enabled = enable;
16803 mp->count = ntohl (count);
16804 mp->pcap_name_length = ntohl (name_len);
16805 if (pcap_file_set != 0)
16807 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16809 vec_free (pcap_file);
16817 api_pg_enable_disable (vat_main_t * vam)
16819 unformat_input_t *input = vam->input;
16820 vl_api_pg_enable_disable_t *mp;
16823 u8 stream_name_set = 0;
16824 u8 *stream_name = 0;
16826 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16828 if (unformat (input, "stream %s", &stream_name))
16829 stream_name_set = 1;
16830 else if (unformat (input, "disable"))
16836 if (stream_name_set > 0)
16838 if (vec_len (stream_name) > 255)
16840 errmsg ("stream name too long");
16845 u32 name_len = vec_len (stream_name);
16846 /* Construct the API message */
16847 M (PG_ENABLE_DISABLE, mp);
16849 mp->is_enabled = enable;
16850 if (stream_name_set != 0)
16852 mp->stream_name_length = ntohl (name_len);
16853 clib_memcpy (mp->stream_name, stream_name, name_len);
16855 vec_free (stream_name);
16863 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16865 unformat_input_t *input = vam->input;
16866 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16868 u16 *low_ports = 0;
16869 u16 *high_ports = 0;
16872 ip4_address_t ip4_addr;
16873 ip6_address_t ip6_addr;
16882 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16884 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16890 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16895 else if (unformat (input, "vrf %d", &vrf_id))
16897 else if (unformat (input, "del"))
16899 else if (unformat (input, "port %d", &tmp))
16901 if (tmp == 0 || tmp > 65535)
16903 errmsg ("port %d out of range", tmp);
16907 this_hi = this_low + 1;
16908 vec_add1 (low_ports, this_low);
16909 vec_add1 (high_ports, this_hi);
16911 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16913 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16915 errmsg ("incorrect range parameters");
16919 /* Note: in debug CLI +1 is added to high before
16920 passing to real fn that does "the work"
16921 (ip_source_and_port_range_check_add_del).
16922 This fn is a wrapper around the binary API fn a
16923 control plane will call, which expects this increment
16924 to have occurred. Hence letting the binary API control
16925 plane fn do the increment for consistency between VAT
16926 and other control planes.
16929 vec_add1 (low_ports, this_low);
16930 vec_add1 (high_ports, this_hi);
16936 if (prefix_set == 0)
16938 errmsg ("<address>/<mask> not specified");
16944 errmsg ("VRF ID required, not specified");
16951 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16955 if (vec_len (low_ports) == 0)
16957 errmsg ("At least one port or port range required");
16961 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16963 mp->is_add = is_add;
16968 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16973 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16976 mp->mask_length = length;
16977 mp->number_of_ranges = vec_len (low_ports);
16979 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16980 vec_free (low_ports);
16982 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16983 vec_free (high_ports);
16985 mp->vrf_id = ntohl (vrf_id);
16993 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16995 unformat_input_t *input = vam->input;
16996 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16997 u32 sw_if_index = ~0;
16999 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
17000 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
17004 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17006 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17008 else if (unformat (input, "sw_if_index %d", &sw_if_index))
17010 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
17012 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
17014 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
17016 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
17018 else if (unformat (input, "del"))
17024 if (sw_if_index == ~0)
17026 errmsg ("Interface required but not specified");
17032 errmsg ("VRF ID required but not specified");
17036 if (tcp_out_vrf_id == 0
17037 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
17040 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
17044 /* Construct the API message */
17045 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
17047 mp->sw_if_index = ntohl (sw_if_index);
17048 mp->is_add = is_add;
17049 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
17050 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
17051 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
17052 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
17057 /* Wait for a reply... */
17063 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
17065 unformat_input_t *i = vam->input;
17066 vl_api_ipsec_gre_add_del_tunnel_t *mp;
17067 u32 local_sa_id = 0;
17068 u32 remote_sa_id = 0;
17069 ip4_address_t src_address;
17070 ip4_address_t dst_address;
17074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17076 if (unformat (i, "local_sa %d", &local_sa_id))
17078 else if (unformat (i, "remote_sa %d", &remote_sa_id))
17080 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
17082 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
17084 else if (unformat (i, "del"))
17088 clib_warning ("parse error '%U'", format_unformat_error, i);
17093 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
17095 mp->local_sa_id = ntohl (local_sa_id);
17096 mp->remote_sa_id = ntohl (remote_sa_id);
17097 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
17098 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
17099 mp->is_add = is_add;
17107 api_punt (vat_main_t * vam)
17109 unformat_input_t *i = vam->input;
17117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17119 if (unformat (i, "ip %d", &ipv))
17121 else if (unformat (i, "protocol %d", &protocol))
17123 else if (unformat (i, "port %d", &port))
17125 else if (unformat (i, "del"))
17129 clib_warning ("parse error '%U'", format_unformat_error, i);
17136 mp->is_add = (u8) is_add;
17137 mp->ipv = (u8) ipv;
17138 mp->l4_protocol = (u8) protocol;
17139 mp->l4_port = htons ((u16) port);
17146 static void vl_api_ipsec_gre_tunnel_details_t_handler
17147 (vl_api_ipsec_gre_tunnel_details_t * mp)
17149 vat_main_t *vam = &vat_main;
17151 print (vam->ofp, "%11d%15U%15U%14d%14d",
17152 ntohl (mp->sw_if_index),
17153 format_ip4_address, &mp->src_address,
17154 format_ip4_address, &mp->dst_address,
17155 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17158 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17159 (vl_api_ipsec_gre_tunnel_details_t * mp)
17161 vat_main_t *vam = &vat_main;
17162 vat_json_node_t *node = NULL;
17163 struct in_addr ip4;
17165 if (VAT_JSON_ARRAY != vam->json_tree.type)
17167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17168 vat_json_init_array (&vam->json_tree);
17170 node = vat_json_array_add (&vam->json_tree);
17172 vat_json_init_object (node);
17173 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17174 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17175 vat_json_object_add_ip4 (node, "src_address", ip4);
17176 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17177 vat_json_object_add_ip4 (node, "dst_address", ip4);
17178 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17179 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17183 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17185 unformat_input_t *i = vam->input;
17186 vl_api_ipsec_gre_tunnel_dump_t *mp;
17187 vl_api_control_ping_t *mp_ping;
17189 u8 sw_if_index_set = 0;
17192 /* Parse args required to build the message */
17193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17195 if (unformat (i, "sw_if_index %d", &sw_if_index))
17196 sw_if_index_set = 1;
17201 if (sw_if_index_set == 0)
17206 if (!vam->json_output)
17208 print (vam->ofp, "%11s%15s%15s%14s%14s",
17209 "sw_if_index", "src_address", "dst_address",
17210 "local_sa_id", "remote_sa_id");
17213 /* Get list of gre-tunnel interfaces */
17214 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17216 mp->sw_if_index = htonl (sw_if_index);
17220 /* Use a control ping for synchronization */
17221 M (CONTROL_PING, mp_ping);
17229 api_delete_subif (vat_main_t * vam)
17231 unformat_input_t *i = vam->input;
17232 vl_api_delete_subif_t *mp;
17233 u32 sw_if_index = ~0;
17236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17238 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17240 if (unformat (i, "sw_if_index %d", &sw_if_index))
17246 if (sw_if_index == ~0)
17248 errmsg ("missing sw_if_index");
17252 /* Construct the API message */
17253 M (DELETE_SUBIF, mp);
17254 mp->sw_if_index = ntohl (sw_if_index);
17261 #define foreach_pbb_vtr_op \
17262 _("disable", L2_VTR_DISABLED) \
17263 _("pop", L2_VTR_POP_2) \
17264 _("push", L2_VTR_PUSH_2)
17267 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17269 unformat_input_t *i = vam->input;
17270 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17271 u32 sw_if_index = ~0, vtr_op = ~0;
17272 u16 outer_tag = ~0;
17273 u8 dmac[6], smac[6];
17274 u8 dmac_set = 0, smac_set = 0;
17280 /* Shut up coverity */
17281 memset (dmac, 0, sizeof (dmac));
17282 memset (smac, 0, sizeof (smac));
17284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17286 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17288 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17290 else if (unformat (i, "vtr_op %d", &vtr_op))
17292 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17295 else if (unformat (i, "translate_pbb_stag"))
17297 if (unformat (i, "%d", &tmp))
17299 vtr_op = L2_VTR_TRANSLATE_2_1;
17305 ("translate_pbb_stag operation requires outer tag definition");
17309 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17311 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17313 else if (unformat (i, "sid %d", &sid))
17315 else if (unformat (i, "vlanid %d", &tmp))
17319 clib_warning ("parse error '%U'", format_unformat_error, i);
17324 if ((sw_if_index == ~0) || (vtr_op == ~0))
17326 errmsg ("missing sw_if_index or vtr operation");
17329 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17330 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17333 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17337 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17338 mp->sw_if_index = ntohl (sw_if_index);
17339 mp->vtr_op = ntohl (vtr_op);
17340 mp->outer_tag = ntohs (outer_tag);
17341 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17342 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17343 mp->b_vlanid = ntohs (vlanid);
17344 mp->i_sid = ntohl (sid);
17352 api_flow_classify_set_interface (vat_main_t * vam)
17354 unformat_input_t *i = vam->input;
17355 vl_api_flow_classify_set_interface_t *mp;
17357 int sw_if_index_set;
17358 u32 ip4_table_index = ~0;
17359 u32 ip6_table_index = ~0;
17363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17365 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17366 sw_if_index_set = 1;
17367 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17368 sw_if_index_set = 1;
17369 else if (unformat (i, "del"))
17371 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17373 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17377 clib_warning ("parse error '%U'", format_unformat_error, i);
17382 if (sw_if_index_set == 0)
17384 errmsg ("missing interface name or sw_if_index");
17388 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17390 mp->sw_if_index = ntohl (sw_if_index);
17391 mp->ip4_table_index = ntohl (ip4_table_index);
17392 mp->ip6_table_index = ntohl (ip6_table_index);
17393 mp->is_add = is_add;
17401 api_flow_classify_dump (vat_main_t * vam)
17403 unformat_input_t *i = vam->input;
17404 vl_api_flow_classify_dump_t *mp;
17405 vl_api_control_ping_t *mp_ping;
17406 u8 type = FLOW_CLASSIFY_N_TABLES;
17409 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17413 errmsg ("classify table type must be specified");
17417 if (!vam->json_output)
17419 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17422 M (FLOW_CLASSIFY_DUMP, mp);
17427 /* Use a control ping for synchronization */
17428 M (CONTROL_PING, mp_ping);
17431 /* Wait for a reply... */
17437 api_feature_enable_disable (vat_main_t * vam)
17439 unformat_input_t *i = vam->input;
17440 vl_api_feature_enable_disable_t *mp;
17442 u8 *feature_name = 0;
17443 u32 sw_if_index = ~0;
17447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17449 if (unformat (i, "arc_name %s", &arc_name))
17451 else if (unformat (i, "feature_name %s", &feature_name))
17454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17458 else if (unformat (i, "disable"))
17466 errmsg ("missing arc name");
17469 if (vec_len (arc_name) > 63)
17471 errmsg ("arc name too long");
17474 if (feature_name == 0)
17476 errmsg ("missing feature name");
17479 if (vec_len (feature_name) > 63)
17481 errmsg ("feature name too long");
17484 if (sw_if_index == ~0)
17486 errmsg ("missing interface name or sw_if_index");
17490 /* Construct the API message */
17491 M (FEATURE_ENABLE_DISABLE, mp);
17492 mp->sw_if_index = ntohl (sw_if_index);
17493 mp->enable = enable;
17494 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17495 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17496 vec_free (arc_name);
17497 vec_free (feature_name);
17505 api_sw_interface_tag_add_del (vat_main_t * vam)
17507 unformat_input_t *i = vam->input;
17508 vl_api_sw_interface_tag_add_del_t *mp;
17509 u32 sw_if_index = ~0;
17514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17516 if (unformat (i, "tag %s", &tag))
17518 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17520 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17522 else if (unformat (i, "del"))
17528 if (sw_if_index == ~0)
17530 errmsg ("missing interface name or sw_if_index");
17534 if (enable && (tag == 0))
17536 errmsg ("no tag specified");
17540 /* Construct the API message */
17541 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17542 mp->sw_if_index = ntohl (sw_if_index);
17543 mp->is_add = enable;
17545 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17553 static void vl_api_l2_xconnect_details_t_handler
17554 (vl_api_l2_xconnect_details_t * mp)
17556 vat_main_t *vam = &vat_main;
17558 print (vam->ofp, "%15d%15d",
17559 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17562 static void vl_api_l2_xconnect_details_t_handler_json
17563 (vl_api_l2_xconnect_details_t * mp)
17565 vat_main_t *vam = &vat_main;
17566 vat_json_node_t *node = NULL;
17568 if (VAT_JSON_ARRAY != vam->json_tree.type)
17570 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17571 vat_json_init_array (&vam->json_tree);
17573 node = vat_json_array_add (&vam->json_tree);
17575 vat_json_init_object (node);
17576 vat_json_object_add_uint (node, "rx_sw_if_index",
17577 ntohl (mp->rx_sw_if_index));
17578 vat_json_object_add_uint (node, "tx_sw_if_index",
17579 ntohl (mp->tx_sw_if_index));
17583 api_l2_xconnect_dump (vat_main_t * vam)
17585 vl_api_l2_xconnect_dump_t *mp;
17586 vl_api_control_ping_t *mp_ping;
17589 if (!vam->json_output)
17591 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17594 M (L2_XCONNECT_DUMP, mp);
17598 /* Use a control ping for synchronization */
17599 M (CONTROL_PING, mp_ping);
17607 api_sw_interface_set_mtu (vat_main_t * vam)
17609 unformat_input_t *i = vam->input;
17610 vl_api_sw_interface_set_mtu_t *mp;
17611 u32 sw_if_index = ~0;
17615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17617 if (unformat (i, "mtu %d", &mtu))
17619 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17621 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17627 if (sw_if_index == ~0)
17629 errmsg ("missing interface name or sw_if_index");
17635 errmsg ("no mtu specified");
17639 /* Construct the API message */
17640 M (SW_INTERFACE_SET_MTU, mp);
17641 mp->sw_if_index = ntohl (sw_if_index);
17642 mp->mtu = ntohs ((u16) mtu);
17651 q_or_quit (vat_main_t * vam)
17653 #if VPP_API_TEST_BUILTIN == 0
17654 longjmp (vam->jump_buf, 1);
17656 return 0; /* not so much */
17660 q (vat_main_t * vam)
17662 return q_or_quit (vam);
17666 quit (vat_main_t * vam)
17668 return q_or_quit (vam);
17672 comment (vat_main_t * vam)
17678 cmd_cmp (void *a1, void *a2)
17683 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17687 help (vat_main_t * vam)
17692 unformat_input_t *i = vam->input;
17695 if (unformat (i, "%s", &name))
17699 vec_add1 (name, 0);
17701 hs = hash_get_mem (vam->help_by_name, name);
17703 print (vam->ofp, "usage: %s %s", name, hs[0]);
17705 print (vam->ofp, "No such msg / command '%s'", name);
17710 print (vam->ofp, "Help is available for the following:");
17713 hash_foreach_pair (p, vam->function_by_name,
17715 vec_add1 (cmds, (u8 *)(p->key));
17719 vec_sort_with_function (cmds, cmd_cmp);
17721 for (j = 0; j < vec_len (cmds); j++)
17722 print (vam->ofp, "%s", cmds[j]);
17729 set (vat_main_t * vam)
17731 u8 *name = 0, *value = 0;
17732 unformat_input_t *i = vam->input;
17734 if (unformat (i, "%s", &name))
17736 /* The input buffer is a vector, not a string. */
17737 value = vec_dup (i->buffer);
17738 vec_delete (value, i->index, 0);
17739 /* Almost certainly has a trailing newline */
17740 if (value[vec_len (value) - 1] == '\n')
17741 value[vec_len (value) - 1] = 0;
17742 /* Make sure it's a proper string, one way or the other */
17743 vec_add1 (value, 0);
17744 (void) clib_macro_set_value (&vam->macro_main,
17745 (char *) name, (char *) value);
17748 errmsg ("usage: set <name> <value>");
17756 unset (vat_main_t * vam)
17760 if (unformat (vam->input, "%s", &name))
17761 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17762 errmsg ("unset: %s wasn't set", name);
17775 macro_sort_cmp (void *a1, void *a2)
17777 macro_sort_t *s1 = a1;
17778 macro_sort_t *s2 = a2;
17780 return strcmp ((char *) (s1->name), (char *) (s2->name));
17784 dump_macro_table (vat_main_t * vam)
17786 macro_sort_t *sort_me = 0, *sm;
17791 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17793 vec_add2 (sort_me, sm, 1);
17794 sm->name = (u8 *)(p->key);
17795 sm->value = (u8 *) (p->value[0]);
17799 vec_sort_with_function (sort_me, macro_sort_cmp);
17801 if (vec_len (sort_me))
17802 print (vam->ofp, "%-15s%s", "Name", "Value");
17804 print (vam->ofp, "The macro table is empty...");
17806 for (i = 0; i < vec_len (sort_me); i++)
17807 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17812 dump_node_table (vat_main_t * vam)
17815 vlib_node_t *node, *next_node;
17817 if (vec_len (vam->graph_nodes) == 0)
17819 print (vam->ofp, "Node table empty, issue get_node_graph...");
17823 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17825 node = vam->graph_nodes[i];
17826 print (vam->ofp, "[%d] %s", i, node->name);
17827 for (j = 0; j < vec_len (node->next_nodes); j++)
17829 if (node->next_nodes[j] != ~0)
17831 next_node = vam->graph_nodes[node->next_nodes[j]];
17832 print (vam->ofp, " [%d] %s", j, next_node->name);
17840 value_sort_cmp (void *a1, void *a2)
17842 name_sort_t *n1 = a1;
17843 name_sort_t *n2 = a2;
17845 if (n1->value < n2->value)
17847 if (n1->value > n2->value)
17854 dump_msg_api_table (vat_main_t * vam)
17856 api_main_t *am = &api_main;
17857 name_sort_t *nses = 0, *ns;
17862 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17864 vec_add2 (nses, ns, 1);
17865 ns->name = (u8 *)(hp->key);
17866 ns->value = (u32) hp->value[0];
17870 vec_sort_with_function (nses, value_sort_cmp);
17872 for (i = 0; i < vec_len (nses); i++)
17873 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17879 get_msg_id (vat_main_t * vam)
17884 if (unformat (vam->input, "%s", &name_and_crc))
17886 message_index = vl_api_get_msg_index (name_and_crc);
17887 if (message_index == ~0)
17889 print (vam->ofp, " '%s' not found", name_and_crc);
17892 print (vam->ofp, " '%s' has message index %d",
17893 name_and_crc, message_index);
17896 errmsg ("name_and_crc required...");
17901 search_node_table (vat_main_t * vam)
17903 unformat_input_t *line_input = vam->input;
17906 vlib_node_t *node, *next_node;
17909 if (vam->graph_node_index_by_name == 0)
17911 print (vam->ofp, "Node table empty, issue get_node_graph...");
17915 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17917 if (unformat (line_input, "%s", &node_to_find))
17919 vec_add1 (node_to_find, 0);
17920 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17923 print (vam->ofp, "%s not found...", node_to_find);
17926 node = vam->graph_nodes[p[0]];
17927 print (vam->ofp, "[%d] %s", p[0], node->name);
17928 for (j = 0; j < vec_len (node->next_nodes); j++)
17930 if (node->next_nodes[j] != ~0)
17932 next_node = vam->graph_nodes[node->next_nodes[j]];
17933 print (vam->ofp, " [%d] %s", j, next_node->name);
17940 clib_warning ("parse error '%U'", format_unformat_error,
17946 vec_free (node_to_find);
17955 script (vat_main_t * vam)
17957 #if (VPP_API_TEST_BUILTIN==0)
17959 char *save_current_file;
17960 unformat_input_t save_input;
17961 jmp_buf save_jump_buf;
17962 u32 save_line_number;
17964 FILE *new_fp, *save_ifp;
17966 if (unformat (vam->input, "%s", &s))
17968 new_fp = fopen ((char *) s, "r");
17971 errmsg ("Couldn't open script file %s", s);
17978 errmsg ("Missing script name");
17982 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17983 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17984 save_ifp = vam->ifp;
17985 save_line_number = vam->input_line_number;
17986 save_current_file = (char *) vam->current_file;
17988 vam->input_line_number = 0;
17990 vam->current_file = s;
17993 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17994 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17995 vam->ifp = save_ifp;
17996 vam->input_line_number = save_line_number;
17997 vam->current_file = (u8 *) save_current_file;
18002 clib_warning ("use the exec command...");
18008 echo (vat_main_t * vam)
18010 print (vam->ofp, "%v", vam->input->buffer);
18014 /* List of API message constructors, CLI names map to api_xxx */
18015 #define foreach_vpe_api_msg \
18016 _(create_loopback,"[mac <mac-addr>]") \
18017 _(sw_interface_dump,"") \
18018 _(sw_interface_set_flags, \
18019 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
18020 _(sw_interface_add_del_address, \
18021 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
18022 _(sw_interface_set_table, \
18023 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
18024 _(sw_interface_set_mpls_enable, \
18025 "<intfc> | sw_if_index [disable | dis]") \
18026 _(sw_interface_set_vpath, \
18027 "<intfc> | sw_if_index <id> enable | disable") \
18028 _(sw_interface_set_vxlan_bypass, \
18029 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
18030 _(sw_interface_set_l2_xconnect, \
18031 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18032 "enable | disable") \
18033 _(sw_interface_set_l2_bridge, \
18034 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
18035 "[shg <split-horizon-group>] [bvi]\n" \
18036 "enable | disable") \
18037 _(bridge_domain_add_del, \
18038 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
18039 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
18041 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
18043 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
18045 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
18047 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
18049 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
18051 "<vpp-if-name> | sw_if_index <id>") \
18052 _(sw_interface_tap_dump, "") \
18053 _(ip_add_del_route, \
18054 "<addr>/<mask> via <addr> [table-id <n>]\n" \
18055 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18056 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18057 "[multipath] [count <n>]") \
18058 _(ip_mroute_add_del, \
18059 "<src> <grp>/<mask> [table-id <n>]\n" \
18060 "[<intfc> | sw_if_index <id>] [local] [del]") \
18061 _(mpls_route_add_del, \
18062 "<label> <eos> via <addr> [table-id <n>]\n" \
18063 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
18064 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
18065 "[multipath] [count <n>]") \
18066 _(mpls_ip_bind_unbind, \
18067 "<label> <addr/len>") \
18068 _(mpls_tunnel_add_del, \
18069 " via <addr> [table-id <n>]\n" \
18070 "sw_if_index <id>] [l2] [del]") \
18071 _(proxy_arp_add_del, \
18072 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
18073 _(proxy_arp_intfc_enable_disable, \
18074 "<intfc> | sw_if_index <id> enable | disable") \
18075 _(sw_interface_set_unnumbered, \
18076 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
18077 _(ip_neighbor_add_del, \
18078 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
18079 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
18080 _(reset_vrf, "vrf <id> [ipv6]") \
18081 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
18082 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
18083 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
18084 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
18085 "[outer_vlan_id_any][inner_vlan_id_any]") \
18086 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
18087 _(reset_fib, "vrf <n> [ipv6]") \
18088 _(dhcp_proxy_config, \
18089 "svr <v46-address> src <v46-address>\n" \
18090 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
18091 _(dhcp_proxy_set_vss, \
18092 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
18093 _(dhcp_proxy_dump, "ip6") \
18094 _(dhcp_client_config, \
18095 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
18096 _(set_ip_flow_hash, \
18097 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
18098 _(sw_interface_ip6_enable_disable, \
18099 "<intfc> | sw_if_index <id> enable | disable") \
18100 _(sw_interface_ip6_set_link_local_address, \
18101 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
18102 _(sw_interface_ip6nd_ra_prefix, \
18103 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
18104 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
18105 "[nolink] [isno]") \
18106 _(sw_interface_ip6nd_ra_config, \
18107 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
18108 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
18109 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
18110 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
18111 _(l2_patch_add_del, \
18112 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
18113 "enable | disable") \
18114 _(sr_tunnel_add_del, \
18115 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
18116 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
18117 "[policy <policy_name>]") \
18118 _(sr_policy_add_del, \
18119 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
18120 _(sr_multicast_map_add_del, \
18121 "address [ip6 multicast address] sr-policy [policy name] [del]") \
18122 _(classify_add_del_table, \
18123 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
18124 " [del] [del-chain] mask <mask-value>\n" \
18125 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
18126 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
18127 _(classify_add_del_session, \
18128 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
18129 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18130 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18131 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18132 _(classify_set_interface_ip_table, \
18133 "<intfc> | sw_if_index <nn> table <nn>") \
18134 _(classify_set_interface_l2_tables, \
18135 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18136 " [other-table <nn>]") \
18137 _(get_node_index, "node <node-name") \
18138 _(add_node_next, "node <node-name> next <next-node-name>") \
18139 _(l2tpv3_create_tunnel, \
18140 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18141 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18142 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18143 _(l2tpv3_set_tunnel_cookies, \
18144 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18145 "[new_remote_cookie <nn>]\n") \
18146 _(l2tpv3_interface_enable_disable, \
18147 "<intfc> | sw_if_index <nn> enable | disable") \
18148 _(l2tpv3_set_lookup_key, \
18149 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18150 _(sw_if_l2tpv3_tunnel_dump, "") \
18151 _(vxlan_add_del_tunnel, \
18152 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18153 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18154 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18155 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18156 _(gre_add_del_tunnel, \
18157 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18158 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18159 _(l2_fib_clear_table, "") \
18160 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18161 _(l2_interface_vlan_tag_rewrite, \
18162 "<intfc> | sw_if_index <nn> \n" \
18163 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18164 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18165 _(create_vhost_user_if, \
18166 "socket <filename> [server] [renumber <dev_instance>] " \
18167 "[mac <mac_address>]") \
18168 _(modify_vhost_user_if, \
18169 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18170 "[server] [renumber <dev_instance>]") \
18171 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18172 _(sw_interface_vhost_user_dump, "") \
18173 _(show_version, "") \
18174 _(vxlan_gpe_add_del_tunnel, \
18175 "local <addr> remote <addr> vni <nn>\n" \
18176 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18177 "[next-ethernet] [next-nsh]\n") \
18178 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18179 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18180 _(interface_name_renumber, \
18181 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18182 _(input_acl_set_interface, \
18183 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18184 " [l2-table <nn>] [del]") \
18185 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18186 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18187 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18188 _(ip_dump, "ipv4 | ipv6") \
18189 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18190 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18192 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18193 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18194 " integ_alg <alg> integ_key <hex>") \
18195 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18196 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18197 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18198 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18199 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18200 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18201 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18202 "(auth_data 0x<data> | auth_data <data>)") \
18203 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18204 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18205 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18206 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18207 "(local|remote)") \
18208 _(ikev2_set_local_key, "file <absolute_file_path>") \
18209 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18210 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18211 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18212 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18213 _(ikev2_initiate_sa_init, "<profile_name>") \
18214 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18215 _(ikev2_initiate_del_child_sa, "<ispi>") \
18216 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18217 _(delete_loopback,"sw_if_index <nn>") \
18218 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18219 _(map_add_domain, \
18220 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18221 "ip6-src <ip6addr> " \
18222 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18223 _(map_del_domain, "index <n>") \
18224 _(map_add_del_rule, \
18225 "index <n> psid <n> dst <ip6addr> [del]") \
18226 _(map_domain_dump, "") \
18227 _(map_rule_dump, "index <map-domain>") \
18228 _(want_interface_events, "enable|disable") \
18229 _(want_stats,"enable|disable") \
18230 _(get_first_msg_id, "client <name>") \
18231 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18232 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18233 "fib-id <nn> [ip4][ip6][default]") \
18234 _(get_node_graph, " ") \
18235 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18236 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18237 _(ioam_disable, "") \
18238 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18239 " sw_if_index <sw_if_index> p <priority> " \
18240 "w <weight>] [del]") \
18241 _(one_add_del_locator, "locator-set <locator_name> " \
18242 "iface <intf> | sw_if_index <sw_if_index> " \
18243 "p <priority> w <weight> [del]") \
18244 _(one_add_del_local_eid,"vni <vni> eid " \
18245 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18246 "locator-set <locator_name> [del]" \
18247 "[key-id sha1|sha256 secret-key <secret-key>]")\
18248 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18249 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18250 _(one_enable_disable, "enable|disable") \
18251 _(one_map_register_enable_disable, "enable|disable") \
18252 _(one_rloc_probe_enable_disable, "enable|disable") \
18253 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18255 "rloc <locator> p <prio> " \
18256 "w <weight> [rloc <loc> ... ] " \
18257 "action <action> [del-all]") \
18258 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18260 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18261 _(one_map_request_mode, "src-dst|dst-only") \
18262 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18263 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18264 _(one_locator_set_dump, "[local | remote]") \
18265 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18266 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18267 "[local] | [remote]") \
18268 _(one_eid_table_vni_dump, "") \
18269 _(one_eid_table_map_dump, "l2|l3") \
18270 _(one_map_resolver_dump, "") \
18271 _(one_map_server_dump, "") \
18272 _(one_adjacencies_get, "vni <vni>") \
18273 _(show_one_rloc_probe_state, "") \
18274 _(show_one_map_register_state, "") \
18275 _(show_one_status, "") \
18276 _(one_get_map_request_itr_rlocs, "") \
18277 _(show_one_pitr, "") \
18278 _(show_one_map_request_mode, "") \
18279 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18280 " sw_if_index <sw_if_index> p <priority> " \
18281 "w <weight>] [del]") \
18282 _(lisp_add_del_locator, "locator-set <locator_name> " \
18283 "iface <intf> | sw_if_index <sw_if_index> " \
18284 "p <priority> w <weight> [del]") \
18285 _(lisp_add_del_local_eid,"vni <vni> eid " \
18286 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18287 "locator-set <locator_name> [del]" \
18288 "[key-id sha1|sha256 secret-key <secret-key>]") \
18289 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18290 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18291 _(lisp_enable_disable, "enable|disable") \
18292 _(lisp_map_register_enable_disable, "enable|disable") \
18293 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18294 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18296 "rloc <locator> p <prio> " \
18297 "w <weight> [rloc <loc> ... ] " \
18298 "action <action> [del-all]") \
18299 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18301 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18302 _(lisp_map_request_mode, "src-dst|dst-only") \
18303 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18304 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18305 _(lisp_locator_set_dump, "[local | remote]") \
18306 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18307 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18308 "[local] | [remote]") \
18309 _(lisp_eid_table_vni_dump, "") \
18310 _(lisp_eid_table_map_dump, "l2|l3") \
18311 _(lisp_map_resolver_dump, "") \
18312 _(lisp_map_server_dump, "") \
18313 _(lisp_adjacencies_get, "vni <vni>") \
18314 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18315 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18316 _(gpe_set_encap_mode, "lisp|vxlan") \
18317 _(gpe_get_encap_mode, "") \
18318 _(lisp_gpe_add_del_iface, "up|down") \
18319 _(lisp_gpe_enable_disable, "enable|disable") \
18320 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18321 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18322 _(show_lisp_rloc_probe_state, "") \
18323 _(show_lisp_map_register_state, "") \
18324 _(show_lisp_status, "") \
18325 _(lisp_get_map_request_itr_rlocs, "") \
18326 _(show_lisp_pitr, "") \
18327 _(show_lisp_map_request_mode, "") \
18328 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18329 _(af_packet_delete, "name <host interface name>") \
18330 _(policer_add_del, "name <policer name> <params> [del]") \
18331 _(policer_dump, "[name <policer name>]") \
18332 _(policer_classify_set_interface, \
18333 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18334 " [l2-table <nn>] [del]") \
18335 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18336 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18337 "[master|slave]") \
18338 _(netmap_delete, "name <interface name>") \
18339 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18340 _(mpls_fib_dump, "") \
18341 _(classify_table_ids, "") \
18342 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18343 _(classify_table_info, "table_id <nn>") \
18344 _(classify_session_dump, "table_id <nn>") \
18345 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18346 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18347 "[template_interval <nn>] [udp_checksum]") \
18348 _(ipfix_exporter_dump, "") \
18349 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18350 _(ipfix_classify_stream_dump, "") \
18351 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18352 _(ipfix_classify_table_dump, "") \
18353 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18354 _(sw_interface_span_dump, "") \
18355 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18356 _(pg_create_interface, "if_id <nn>") \
18357 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18358 _(pg_enable_disable, "[stream <id>] disable") \
18359 _(ip_source_and_port_range_check_add_del, \
18360 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18361 _(ip_source_and_port_range_check_interface_add_del, \
18362 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18363 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18364 _(ipsec_gre_add_del_tunnel, \
18365 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18366 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18367 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18368 _(l2_interface_pbb_tag_rewrite, \
18369 "<intfc> | sw_if_index <nn> \n" \
18370 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18371 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18372 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18373 _(flow_classify_set_interface, \
18374 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18375 _(flow_classify_dump, "type [ip4|ip6]") \
18376 _(ip_fib_dump, "") \
18377 _(ip_mfib_dump, "") \
18378 _(ip6_fib_dump, "") \
18379 _(ip6_mfib_dump, "") \
18380 _(feature_enable_disable, "arc_name <arc_name> " \
18381 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18382 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18384 _(l2_xconnect_dump, "") \
18385 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18386 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18387 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18389 /* List of command functions, CLI names map directly to functions */
18390 #define foreach_cli_function \
18391 _(comment, "usage: comment <ignore-rest-of-line>") \
18392 _(dump_interface_table, "usage: dump_interface_table") \
18393 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18394 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18395 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18396 _(dump_stats_table, "usage: dump_stats_table") \
18397 _(dump_macro_table, "usage: dump_macro_table ") \
18398 _(dump_node_table, "usage: dump_node_table") \
18399 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18400 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18401 _(echo, "usage: echo <message>") \
18402 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18403 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18404 _(help, "usage: help") \
18405 _(q, "usage: quit") \
18406 _(quit, "usage: quit") \
18407 _(search_node_table, "usage: search_node_table <name>...") \
18408 _(set, "usage: set <variable-name> <value>") \
18409 _(script, "usage: script <file-name>") \
18410 _(unset, "usage: unset <variable-name>")
18413 static void vl_api_##n##_t_handler_uni \
18414 (vl_api_##n##_t * mp) \
18416 vat_main_t * vam = &vat_main; \
18417 if (vam->json_output) { \
18418 vl_api_##n##_t_handler_json(mp); \
18420 vl_api_##n##_t_handler(mp); \
18423 foreach_vpe_api_reply_msg;
18427 vat_api_hookup (vat_main_t * vam)
18430 vl_msg_api_set_handlers(VL_API_##N, #n, \
18431 vl_api_##n##_t_handler_uni, \
18433 vl_api_##n##_t_endian, \
18434 vl_api_##n##_t_print, \
18435 sizeof(vl_api_##n##_t), 1);
18436 foreach_vpe_api_reply_msg;
18439 #if (VPP_API_TEST_BUILTIN==0)
18440 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18443 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18445 vam->function_by_name = hash_create_string (0, sizeof (uword));
18447 vam->help_by_name = hash_create_string (0, sizeof (uword));
18449 /* API messages we can send */
18450 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18451 foreach_vpe_api_msg;
18455 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18456 foreach_vpe_api_msg;
18459 /* CLI functions */
18460 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18461 foreach_cli_function;
18465 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18466 foreach_cli_function;
18471 * fd.io coding-style-patch-verification: ON
18474 * eval: (c-set-style "gnu")