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 <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/geneve/geneve.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/in_out_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>
52 #include <vnet/dhcp/dhcp_proxy.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp/api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp/api/vpe_all_api_h.h>
76 #define __plugin_msg_base 0
77 #include <vlibapi/vat_helper_macros.h>
79 #if VPP_API_TEST_BUILTIN == 0
89 vat_socket_connect (vat_main_t * vam)
91 vam->socket_client_main = &socket_client_main;
92 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
93 0 /* default socket rx, tx buffer */ );
95 #else /* vpp built-in case, we don't do sockets... */
97 vat_socket_connect (vat_main_t * vam)
103 vl_socket_client_read (int wait)
109 vl_socket_client_write ()
115 vl_socket_client_msg_alloc (int nbytes)
123 vat_time_now (vat_main_t * vam)
125 #if VPP_API_TEST_BUILTIN
126 return vlib_time_now (vam->vlib_main);
128 return clib_time_now (&vam->clib_time);
133 errmsg (char *fmt, ...)
135 vat_main_t *vam = &vat_main;
140 s = va_format (0, fmt, &va);
145 #if VPP_API_TEST_BUILTIN
146 vlib_cli_output (vam->vlib_main, (char *) s);
149 if (vam->ifp != stdin)
150 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
151 vam->input_line_number);
152 fformat (vam->ofp, (char *) s);
160 #if VPP_API_TEST_BUILTIN == 0
162 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
164 vat_main_t *vam = va_arg (*args, vat_main_t *);
165 u32 *result = va_arg (*args, u32 *);
169 if (!unformat (input, "%s", &if_name))
172 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
179 /* Parse an IP4 address %d.%d.%d.%d. */
181 unformat_ip4_address (unformat_input_t * input, va_list * args)
183 u8 *result = va_arg (*args, u8 *);
186 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
189 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
201 unformat_ethernet_address (unformat_input_t * input, va_list * args)
203 u8 *result = va_arg (*args, u8 *);
206 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
207 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
211 for (i = 0; i < 6; i++)
212 if (a[i] >= (1 << 8))
215 for (i = 0; i < 6; i++)
221 /* Returns ethernet type as an int in host byte order. */
223 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
226 u16 *result = va_arg (*args, u16 *);
230 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
232 if (type >= (1 << 16))
240 /* Parse an IP6 address. */
242 unformat_ip6_address (unformat_input_t * input, va_list * args)
244 ip6_address_t *result = va_arg (*args, ip6_address_t *);
246 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
247 uword c, n_colon, double_colon_index;
249 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
250 double_colon_index = ARRAY_LEN (hex_quads);
251 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
254 if (c >= '0' && c <= '9')
256 else if (c >= 'a' && c <= 'f')
257 hex_digit = c + 10 - 'a';
258 else if (c >= 'A' && c <= 'F')
259 hex_digit = c + 10 - 'A';
260 else if (c == ':' && n_colon < 2)
264 unformat_put_input (input);
268 /* Too many hex quads. */
269 if (n_hex_quads >= ARRAY_LEN (hex_quads))
274 hex_quad = (hex_quad << 4) | hex_digit;
276 /* Hex quad must fit in 16 bits. */
277 if (n_hex_digits >= 4)
284 /* Save position of :: */
287 /* More than one :: ? */
288 if (double_colon_index < ARRAY_LEN (hex_quads))
290 double_colon_index = n_hex_quads;
293 if (n_colon > 0 && n_hex_digits > 0)
295 hex_quads[n_hex_quads++] = hex_quad;
301 if (n_hex_digits > 0)
302 hex_quads[n_hex_quads++] = hex_quad;
307 /* Expand :: to appropriate number of zero hex quads. */
308 if (double_colon_index < ARRAY_LEN (hex_quads))
310 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
312 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
313 hex_quads[n_zero + i] = hex_quads[i];
315 for (i = 0; i < n_zero; i++)
316 hex_quads[double_colon_index + i] = 0;
318 n_hex_quads = ARRAY_LEN (hex_quads);
321 /* Too few hex quads given. */
322 if (n_hex_quads < ARRAY_LEN (hex_quads))
325 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
326 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
333 unformat_ipsec_policy_action (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_POLICY_ACTION_##f;
339 foreach_ipsec_policy_action
347 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
349 u32 *r = va_arg (*args, u32 *);
352 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
353 foreach_ipsec_crypto_alg
361 format_ipsec_crypto_alg (u8 * s, va_list * args)
363 u32 i = va_arg (*args, u32);
368 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
369 foreach_ipsec_crypto_alg
372 return format (s, "unknown");
374 return format (s, "%s", t);
378 unformat_ipsec_integ_alg (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 = IPSEC_INTEG_ALG_##f;
384 foreach_ipsec_integ_alg
392 format_ipsec_integ_alg (u8 * s, va_list * args)
394 u32 i = va_arg (*args, u32);
399 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
400 foreach_ipsec_integ_alg
403 return format (s, "unknown");
405 return format (s, "%s", t);
409 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
415 foreach_ikev2_auth_method
423 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
425 u32 *r = va_arg (*args, u32 *);
428 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
429 foreach_ikev2_id_type
435 #else /* VPP_API_TEST_BUILTIN == 1 */
437 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
439 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
440 vnet_main_t *vnm = vnet_get_main ();
441 u32 *result = va_arg (*args, u32 *);
444 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
447 *result = sw_if_index;
450 #endif /* VPP_API_TEST_BUILTIN */
453 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "kbps"))
458 *r = SSE2_QOS_RATE_KBPS;
459 else if (unformat (input, "pps"))
460 *r = SSE2_QOS_RATE_PPS;
467 unformat_policer_round_type (unformat_input_t * input, va_list * args)
469 u8 *r = va_arg (*args, u8 *);
471 if (unformat (input, "closest"))
472 *r = SSE2_QOS_ROUND_TO_CLOSEST;
473 else if (unformat (input, "up"))
474 *r = SSE2_QOS_ROUND_TO_UP;
475 else if (unformat (input, "down"))
476 *r = SSE2_QOS_ROUND_TO_DOWN;
483 unformat_policer_type (unformat_input_t * input, va_list * args)
485 u8 *r = va_arg (*args, u8 *);
487 if (unformat (input, "1r2c"))
488 *r = SSE2_QOS_POLICER_TYPE_1R2C;
489 else if (unformat (input, "1r3c"))
490 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
491 else if (unformat (input, "2r3c-2698"))
492 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
493 else if (unformat (input, "2r3c-4115"))
494 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
495 else if (unformat (input, "2r3c-mef5cf1"))
496 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
503 unformat_dscp (unformat_input_t * input, va_list * va)
505 u8 *r = va_arg (*va, u8 *);
508 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
517 unformat_policer_action_type (unformat_input_t * input, va_list * va)
519 sse2_qos_pol_action_params_st *a
520 = va_arg (*va, sse2_qos_pol_action_params_st *);
522 if (unformat (input, "drop"))
523 a->action_type = SSE2_QOS_ACTION_DROP;
524 else if (unformat (input, "transmit"))
525 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
526 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
527 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
534 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
536 u32 *r = va_arg (*va, u32 *);
539 if (unformat (input, "ip4"))
540 tid = POLICER_CLASSIFY_TABLE_IP4;
541 else if (unformat (input, "ip6"))
542 tid = POLICER_CLASSIFY_TABLE_IP6;
543 else if (unformat (input, "l2"))
544 tid = POLICER_CLASSIFY_TABLE_L2;
553 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
555 u32 *r = va_arg (*va, u32 *);
558 if (unformat (input, "ip4"))
559 tid = FLOW_CLASSIFY_TABLE_IP4;
560 else if (unformat (input, "ip6"))
561 tid = FLOW_CLASSIFY_TABLE_IP6;
569 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
570 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
571 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
572 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
574 #if (VPP_API_TEST_BUILTIN==0)
576 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
578 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
579 mfib_itf_attribute_t attr;
582 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
584 if (unformat (input, mfib_itf_flag_long_names[attr]))
585 *iflags |= (1 << attr);
587 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
589 if (unformat (input, mfib_itf_flag_names[attr]))
590 *iflags |= (1 << attr);
593 return (old == *iflags ? 0 : 1);
597 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
599 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
600 mfib_entry_attribute_t attr;
603 FOR_EACH_MFIB_ATTRIBUTE (attr)
605 if (unformat (input, mfib_flag_long_names[attr]))
606 *eflags |= (1 << attr);
608 FOR_EACH_MFIB_ATTRIBUTE (attr)
610 if (unformat (input, mfib_flag_names[attr]))
611 *eflags |= (1 << attr);
614 return (old == *eflags ? 0 : 1);
618 format_ip4_address (u8 * s, va_list * args)
620 u8 *a = va_arg (*args, u8 *);
621 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
625 format_ip6_address (u8 * s, va_list * args)
627 ip6_address_t *a = va_arg (*args, ip6_address_t *);
628 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
630 i_max_n_zero = ARRAY_LEN (a->as_u16);
632 i_first_zero = i_max_n_zero;
634 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
636 u32 is_zero = a->as_u16[i] == 0;
637 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
643 if ((!is_zero && n_zeros > max_n_zeros)
644 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
646 i_max_n_zero = i_first_zero;
647 max_n_zeros = n_zeros;
648 i_first_zero = ARRAY_LEN (a->as_u16);
653 last_double_colon = 0;
654 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
656 if (i == i_max_n_zero && max_n_zeros > 1)
658 s = format (s, "::");
659 i += max_n_zeros - 1;
660 last_double_colon = 1;
664 s = format (s, "%s%x",
665 (last_double_colon || i == 0) ? "" : ":",
666 clib_net_to_host_u16 (a->as_u16[i]));
667 last_double_colon = 0;
674 /* Format an IP46 address. */
676 format_ip46_address (u8 * s, va_list * args)
678 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
679 ip46_type_t type = va_arg (*args, ip46_type_t);
685 is_ip4 = ip46_address_is_ip4 (ip46);
696 format (s, "%U", format_ip4_address, &ip46->ip4) :
697 format (s, "%U", format_ip6_address, &ip46->ip6);
701 format_ethernet_address (u8 * s, va_list * args)
703 u8 *a = va_arg (*args, u8 *);
705 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
706 a[0], a[1], a[2], a[3], a[4], a[5]);
711 increment_v4_address (ip4_address_t * a)
715 v = ntohl (a->as_u32) + 1;
716 a->as_u32 = ntohl (v);
720 increment_v6_address (ip6_address_t * a)
724 v0 = clib_net_to_host_u64 (a->as_u64[0]);
725 v1 = clib_net_to_host_u64 (a->as_u64[1]);
730 a->as_u64[0] = clib_net_to_host_u64 (v0);
731 a->as_u64[1] = clib_net_to_host_u64 (v1);
735 increment_mac_address (u8 * mac)
737 u64 tmp = *((u64 *) mac);
738 tmp = clib_net_to_host_u64 (tmp);
739 tmp += 1 << 16; /* skip unused (least significant) octets */
740 tmp = clib_host_to_net_u64 (tmp);
742 clib_memcpy (mac, &tmp, 6);
745 static void vl_api_create_loopback_reply_t_handler
746 (vl_api_create_loopback_reply_t * mp)
748 vat_main_t *vam = &vat_main;
749 i32 retval = ntohl (mp->retval);
751 vam->retval = retval;
752 vam->regenerate_interface_table = 1;
753 vam->sw_if_index = ntohl (mp->sw_if_index);
754 vam->result_ready = 1;
757 static void vl_api_create_loopback_reply_t_handler_json
758 (vl_api_create_loopback_reply_t * mp)
760 vat_main_t *vam = &vat_main;
761 vat_json_node_t node;
763 vat_json_init_object (&node);
764 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
765 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
767 vat_json_print (vam->ofp, &node);
768 vat_json_free (&node);
769 vam->retval = ntohl (mp->retval);
770 vam->result_ready = 1;
773 static void vl_api_create_loopback_instance_reply_t_handler
774 (vl_api_create_loopback_instance_reply_t * mp)
776 vat_main_t *vam = &vat_main;
777 i32 retval = ntohl (mp->retval);
779 vam->retval = retval;
780 vam->regenerate_interface_table = 1;
781 vam->sw_if_index = ntohl (mp->sw_if_index);
782 vam->result_ready = 1;
785 static void vl_api_create_loopback_instance_reply_t_handler_json
786 (vl_api_create_loopback_instance_reply_t * mp)
788 vat_main_t *vam = &vat_main;
789 vat_json_node_t node;
791 vat_json_init_object (&node);
792 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
793 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
795 vat_json_print (vam->ofp, &node);
796 vat_json_free (&node);
797 vam->retval = ntohl (mp->retval);
798 vam->result_ready = 1;
801 static void vl_api_af_packet_create_reply_t_handler
802 (vl_api_af_packet_create_reply_t * mp)
804 vat_main_t *vam = &vat_main;
805 i32 retval = ntohl (mp->retval);
807 vam->retval = retval;
808 vam->regenerate_interface_table = 1;
809 vam->sw_if_index = ntohl (mp->sw_if_index);
810 vam->result_ready = 1;
813 static void vl_api_af_packet_create_reply_t_handler_json
814 (vl_api_af_packet_create_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 vat_json_node_t node;
819 vat_json_init_object (&node);
820 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
821 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
823 vat_json_print (vam->ofp, &node);
824 vat_json_free (&node);
826 vam->retval = ntohl (mp->retval);
827 vam->result_ready = 1;
830 static void vl_api_create_vlan_subif_reply_t_handler
831 (vl_api_create_vlan_subif_reply_t * mp)
833 vat_main_t *vam = &vat_main;
834 i32 retval = ntohl (mp->retval);
836 vam->retval = retval;
837 vam->regenerate_interface_table = 1;
838 vam->sw_if_index = ntohl (mp->sw_if_index);
839 vam->result_ready = 1;
842 static void vl_api_create_vlan_subif_reply_t_handler_json
843 (vl_api_create_vlan_subif_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 vat_json_node_t node;
848 vat_json_init_object (&node);
849 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
850 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
852 vat_json_print (vam->ofp, &node);
853 vat_json_free (&node);
855 vam->retval = ntohl (mp->retval);
856 vam->result_ready = 1;
859 static void vl_api_create_subif_reply_t_handler
860 (vl_api_create_subif_reply_t * mp)
862 vat_main_t *vam = &vat_main;
863 i32 retval = ntohl (mp->retval);
865 vam->retval = retval;
866 vam->regenerate_interface_table = 1;
867 vam->sw_if_index = ntohl (mp->sw_if_index);
868 vam->result_ready = 1;
871 static void vl_api_create_subif_reply_t_handler_json
872 (vl_api_create_subif_reply_t * mp)
874 vat_main_t *vam = &vat_main;
875 vat_json_node_t node;
877 vat_json_init_object (&node);
878 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
879 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
881 vat_json_print (vam->ofp, &node);
882 vat_json_free (&node);
884 vam->retval = ntohl (mp->retval);
885 vam->result_ready = 1;
888 static void vl_api_interface_name_renumber_reply_t_handler
889 (vl_api_interface_name_renumber_reply_t * mp)
891 vat_main_t *vam = &vat_main;
892 i32 retval = ntohl (mp->retval);
894 vam->retval = retval;
895 vam->regenerate_interface_table = 1;
896 vam->result_ready = 1;
899 static void vl_api_interface_name_renumber_reply_t_handler_json
900 (vl_api_interface_name_renumber_reply_t * mp)
902 vat_main_t *vam = &vat_main;
903 vat_json_node_t node;
905 vat_json_init_object (&node);
906 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
908 vat_json_print (vam->ofp, &node);
909 vat_json_free (&node);
911 vam->retval = ntohl (mp->retval);
912 vam->result_ready = 1;
916 * Special-case: build the interface table, maintain
917 * the next loopback sw_if_index vbl.
919 static void vl_api_sw_interface_details_t_handler
920 (vl_api_sw_interface_details_t * mp)
922 vat_main_t *vam = &vat_main;
923 u8 *s = format (0, "%s%c", mp->interface_name, 0);
925 hash_set_mem (vam->sw_if_index_by_interface_name, s,
926 ntohl (mp->sw_if_index));
928 /* In sub interface case, fill the sub interface table entry */
929 if (mp->sw_if_index != mp->sup_sw_if_index)
931 sw_interface_subif_t *sub = NULL;
933 vec_add2 (vam->sw_if_subif_table, sub, 1);
935 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
936 strncpy ((char *) sub->interface_name, (char *) s,
937 vec_len (sub->interface_name));
938 sub->sw_if_index = ntohl (mp->sw_if_index);
939 sub->sub_id = ntohl (mp->sub_id);
941 sub->sub_dot1ad = mp->sub_dot1ad;
942 sub->sub_number_of_tags = mp->sub_number_of_tags;
943 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
944 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
945 sub->sub_exact_match = mp->sub_exact_match;
946 sub->sub_default = mp->sub_default;
947 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
948 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
950 /* vlan tag rewrite */
951 sub->vtr_op = ntohl (mp->vtr_op);
952 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
953 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
954 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
958 static void vl_api_sw_interface_details_t_handler_json
959 (vl_api_sw_interface_details_t * mp)
961 vat_main_t *vam = &vat_main;
962 vat_json_node_t *node = NULL;
964 if (VAT_JSON_ARRAY != vam->json_tree.type)
966 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
967 vat_json_init_array (&vam->json_tree);
969 node = vat_json_array_add (&vam->json_tree);
971 vat_json_init_object (node);
972 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
973 vat_json_object_add_uint (node, "sup_sw_if_index",
974 ntohl (mp->sup_sw_if_index));
975 vat_json_object_add_uint (node, "l2_address_length",
976 ntohl (mp->l2_address_length));
977 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
978 sizeof (mp->l2_address));
979 vat_json_object_add_string_copy (node, "interface_name",
981 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
982 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
983 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
984 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
985 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
986 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
987 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
988 vat_json_object_add_uint (node, "sub_number_of_tags",
989 mp->sub_number_of_tags);
990 vat_json_object_add_uint (node, "sub_outer_vlan_id",
991 ntohs (mp->sub_outer_vlan_id));
992 vat_json_object_add_uint (node, "sub_inner_vlan_id",
993 ntohs (mp->sub_inner_vlan_id));
994 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
995 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
996 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
997 mp->sub_outer_vlan_id_any);
998 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
999 mp->sub_inner_vlan_id_any);
1000 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1001 vat_json_object_add_uint (node, "vtr_push_dot1q",
1002 ntohl (mp->vtr_push_dot1q));
1003 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1004 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1007 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1009 format_ethernet_address,
1011 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1013 format_ethernet_address,
1015 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1016 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1020 #if VPP_API_TEST_BUILTIN == 0
1021 static void vl_api_sw_interface_event_t_handler
1022 (vl_api_sw_interface_event_t * mp)
1024 vat_main_t *vam = &vat_main;
1025 if (vam->interface_event_display)
1026 errmsg ("interface flags: sw_if_index %d %s %s",
1027 ntohl (mp->sw_if_index),
1028 mp->admin_up_down ? "admin-up" : "admin-down",
1029 mp->link_up_down ? "link-up" : "link-down");
1033 static void vl_api_sw_interface_event_t_handler_json
1034 (vl_api_sw_interface_event_t * mp)
1036 /* JSON output not supported */
1040 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1042 vat_main_t *vam = &vat_main;
1043 i32 retval = ntohl (mp->retval);
1045 vam->retval = retval;
1046 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1047 vam->result_ready = 1;
1051 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1053 vat_main_t *vam = &vat_main;
1054 vat_json_node_t node;
1055 api_main_t *am = &api_main;
1059 vat_json_init_object (&node);
1060 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1061 vat_json_object_add_uint (&node, "reply_in_shmem",
1062 ntohl (mp->reply_in_shmem));
1063 /* Toss the shared-memory original... */
1064 pthread_mutex_lock (&am->vlib_rp->mutex);
1065 oldheap = svm_push_data_heap (am->vlib_rp);
1067 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1070 svm_pop_heap (oldheap);
1071 pthread_mutex_unlock (&am->vlib_rp->mutex);
1073 vat_json_print (vam->ofp, &node);
1074 vat_json_free (&node);
1076 vam->retval = ntohl (mp->retval);
1077 vam->result_ready = 1;
1081 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1083 vat_main_t *vam = &vat_main;
1084 i32 retval = ntohl (mp->retval);
1085 u32 length = ntohl (mp->length);
1087 vec_reset_length (vam->cmd_reply);
1089 vam->retval = retval;
1092 vec_validate (vam->cmd_reply, length);
1093 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1094 vam->cmd_reply[length] = 0;
1096 vam->result_ready = 1;
1100 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1102 vat_main_t *vam = &vat_main;
1103 vat_json_node_t node;
1105 vec_reset_length (vam->cmd_reply);
1107 vat_json_init_object (&node);
1108 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1109 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1111 vat_json_print (vam->ofp, &node);
1112 vat_json_free (&node);
1114 vam->retval = ntohl (mp->retval);
1115 vam->result_ready = 1;
1118 static void vl_api_classify_add_del_table_reply_t_handler
1119 (vl_api_classify_add_del_table_reply_t * mp)
1121 vat_main_t *vam = &vat_main;
1122 i32 retval = ntohl (mp->retval);
1123 if (vam->async_mode)
1125 vam->async_errors += (retval < 0);
1129 vam->retval = retval;
1131 ((mp->new_table_index != 0xFFFFFFFF) ||
1132 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1133 (mp->match_n_vectors != 0xFFFFFFFF)))
1135 * Note: this is just barely thread-safe, depends on
1136 * the main thread spinning waiting for an answer...
1138 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1139 ntohl (mp->new_table_index),
1140 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1141 vam->result_ready = 1;
1145 static void vl_api_classify_add_del_table_reply_t_handler_json
1146 (vl_api_classify_add_del_table_reply_t * mp)
1148 vat_main_t *vam = &vat_main;
1149 vat_json_node_t node;
1151 vat_json_init_object (&node);
1152 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1153 vat_json_object_add_uint (&node, "new_table_index",
1154 ntohl (mp->new_table_index));
1155 vat_json_object_add_uint (&node, "skip_n_vectors",
1156 ntohl (mp->skip_n_vectors));
1157 vat_json_object_add_uint (&node, "match_n_vectors",
1158 ntohl (mp->match_n_vectors));
1160 vat_json_print (vam->ofp, &node);
1161 vat_json_free (&node);
1163 vam->retval = ntohl (mp->retval);
1164 vam->result_ready = 1;
1167 static void vl_api_get_node_index_reply_t_handler
1168 (vl_api_get_node_index_reply_t * mp)
1170 vat_main_t *vam = &vat_main;
1171 i32 retval = ntohl (mp->retval);
1172 if (vam->async_mode)
1174 vam->async_errors += (retval < 0);
1178 vam->retval = retval;
1180 errmsg ("node index %d", ntohl (mp->node_index));
1181 vam->result_ready = 1;
1185 static void vl_api_get_node_index_reply_t_handler_json
1186 (vl_api_get_node_index_reply_t * mp)
1188 vat_main_t *vam = &vat_main;
1189 vat_json_node_t node;
1191 vat_json_init_object (&node);
1192 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1193 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1195 vat_json_print (vam->ofp, &node);
1196 vat_json_free (&node);
1198 vam->retval = ntohl (mp->retval);
1199 vam->result_ready = 1;
1202 static void vl_api_get_next_index_reply_t_handler
1203 (vl_api_get_next_index_reply_t * mp)
1205 vat_main_t *vam = &vat_main;
1206 i32 retval = ntohl (mp->retval);
1207 if (vam->async_mode)
1209 vam->async_errors += (retval < 0);
1213 vam->retval = retval;
1215 errmsg ("next node index %d", ntohl (mp->next_index));
1216 vam->result_ready = 1;
1220 static void vl_api_get_next_index_reply_t_handler_json
1221 (vl_api_get_next_index_reply_t * mp)
1223 vat_main_t *vam = &vat_main;
1224 vat_json_node_t node;
1226 vat_json_init_object (&node);
1227 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1228 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1230 vat_json_print (vam->ofp, &node);
1231 vat_json_free (&node);
1233 vam->retval = ntohl (mp->retval);
1234 vam->result_ready = 1;
1237 static void vl_api_add_node_next_reply_t_handler
1238 (vl_api_add_node_next_reply_t * mp)
1240 vat_main_t *vam = &vat_main;
1241 i32 retval = ntohl (mp->retval);
1242 if (vam->async_mode)
1244 vam->async_errors += (retval < 0);
1248 vam->retval = retval;
1250 errmsg ("next index %d", ntohl (mp->next_index));
1251 vam->result_ready = 1;
1255 static void vl_api_add_node_next_reply_t_handler_json
1256 (vl_api_add_node_next_reply_t * mp)
1258 vat_main_t *vam = &vat_main;
1259 vat_json_node_t node;
1261 vat_json_init_object (&node);
1262 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1263 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1265 vat_json_print (vam->ofp, &node);
1266 vat_json_free (&node);
1268 vam->retval = ntohl (mp->retval);
1269 vam->result_ready = 1;
1272 static void vl_api_show_version_reply_t_handler
1273 (vl_api_show_version_reply_t * mp)
1275 vat_main_t *vam = &vat_main;
1276 i32 retval = ntohl (mp->retval);
1280 errmsg (" program: %s", mp->program);
1281 errmsg (" version: %s", mp->version);
1282 errmsg (" build date: %s", mp->build_date);
1283 errmsg ("build directory: %s", mp->build_directory);
1285 vam->retval = retval;
1286 vam->result_ready = 1;
1289 static void vl_api_show_version_reply_t_handler_json
1290 (vl_api_show_version_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 vat_json_node_t node;
1295 vat_json_init_object (&node);
1296 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1297 vat_json_object_add_string_copy (&node, "program", mp->program);
1298 vat_json_object_add_string_copy (&node, "version", mp->version);
1299 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1300 vat_json_object_add_string_copy (&node, "build_directory",
1301 mp->build_directory);
1303 vat_json_print (vam->ofp, &node);
1304 vat_json_free (&node);
1306 vam->retval = ntohl (mp->retval);
1307 vam->result_ready = 1;
1311 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1313 u32 sw_if_index = ntohl (mp->sw_if_index);
1314 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1315 mp->mac_ip ? "mac/ip binding" : "address resolution",
1316 ntohl (mp->pid), format_ip4_address, &mp->address,
1317 format_ethernet_address, mp->new_mac, sw_if_index);
1321 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1323 /* JSON output not supported */
1327 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1329 u32 sw_if_index = ntohl (mp->sw_if_index);
1330 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1331 mp->mac_ip ? "mac/ip binding" : "address resolution",
1332 ntohl (mp->pid), format_ip6_address, mp->address,
1333 format_ethernet_address, mp->new_mac, sw_if_index);
1337 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1339 /* JSON output not supported */
1343 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1345 u32 n_macs = ntohl (mp->n_macs);
1346 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1347 ntohl (mp->pid), mp->client_index, n_macs);
1349 for (i = 0; i < n_macs; i++)
1351 vl_api_mac_entry_t *mac = &mp->mac[i];
1352 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1353 i + 1, ntohl (mac->sw_if_index),
1354 format_ethernet_address, mac->mac_addr, mac->action);
1361 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1363 /* JSON output not supported */
1366 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1367 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1370 * Special-case: build the bridge domain table, maintain
1371 * the next bd id vbl.
1373 static void vl_api_bridge_domain_details_t_handler
1374 (vl_api_bridge_domain_details_t * mp)
1376 vat_main_t *vam = &vat_main;
1377 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1380 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1381 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1383 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1384 ntohl (mp->bd_id), mp->learn, mp->forward,
1385 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1389 vl_api_bridge_domain_sw_if_t *sw_ifs;
1390 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1393 sw_ifs = mp->sw_if_details;
1394 for (i = 0; i < n_sw_ifs; i++)
1400 sw_if_index = ntohl (sw_ifs->sw_if_index);
1403 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1405 if ((u32) p->value[0] == sw_if_index)
1407 sw_if_name = (u8 *)(p->key);
1412 print (vam->ofp, "%7d %3d %s", sw_if_index,
1413 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1414 "sw_if_index not found!");
1421 static void vl_api_bridge_domain_details_t_handler_json
1422 (vl_api_bridge_domain_details_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 vat_json_node_t *node, *array = NULL;
1426 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1428 if (VAT_JSON_ARRAY != vam->json_tree.type)
1430 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1431 vat_json_init_array (&vam->json_tree);
1433 node = vat_json_array_add (&vam->json_tree);
1435 vat_json_init_object (node);
1436 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1437 vat_json_object_add_uint (node, "flood", mp->flood);
1438 vat_json_object_add_uint (node, "forward", mp->forward);
1439 vat_json_object_add_uint (node, "learn", mp->learn);
1440 vat_json_object_add_uint (node, "bvi_sw_if_index",
1441 ntohl (mp->bvi_sw_if_index));
1442 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1443 array = vat_json_object_add (node, "sw_if");
1444 vat_json_init_array (array);
1450 vl_api_bridge_domain_sw_if_t *sw_ifs;
1453 sw_ifs = mp->sw_if_details;
1454 for (i = 0; i < n_sw_ifs; i++)
1456 node = vat_json_array_add (array);
1457 vat_json_init_object (node);
1458 vat_json_object_add_uint (node, "sw_if_index",
1459 ntohl (sw_ifs->sw_if_index));
1460 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1466 static void vl_api_control_ping_reply_t_handler
1467 (vl_api_control_ping_reply_t * mp)
1469 vat_main_t *vam = &vat_main;
1470 i32 retval = ntohl (mp->retval);
1471 if (vam->async_mode)
1473 vam->async_errors += (retval < 0);
1477 vam->retval = retval;
1478 vam->result_ready = 1;
1480 if (vam->socket_client_main)
1481 vam->socket_client_main->control_pings_outstanding--;
1484 static void vl_api_control_ping_reply_t_handler_json
1485 (vl_api_control_ping_reply_t * mp)
1487 vat_main_t *vam = &vat_main;
1488 i32 retval = ntohl (mp->retval);
1490 if (VAT_JSON_NONE != vam->json_tree.type)
1492 vat_json_print (vam->ofp, &vam->json_tree);
1493 vat_json_free (&vam->json_tree);
1494 vam->json_tree.type = VAT_JSON_NONE;
1499 vat_json_init_array (&vam->json_tree);
1500 vat_json_print (vam->ofp, &vam->json_tree);
1501 vam->json_tree.type = VAT_JSON_NONE;
1504 vam->retval = retval;
1505 vam->result_ready = 1;
1509 vl_api_bridge_domain_set_mac_age_reply_t_handler
1510 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1512 vat_main_t *vam = &vat_main;
1513 i32 retval = ntohl (mp->retval);
1514 if (vam->async_mode)
1516 vam->async_errors += (retval < 0);
1520 vam->retval = retval;
1521 vam->result_ready = 1;
1525 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1526 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 vat_json_node_t node;
1531 vat_json_init_object (&node);
1532 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1534 vat_json_print (vam->ofp, &node);
1535 vat_json_free (&node);
1537 vam->retval = ntohl (mp->retval);
1538 vam->result_ready = 1;
1542 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1544 vat_main_t *vam = &vat_main;
1545 i32 retval = ntohl (mp->retval);
1546 if (vam->async_mode)
1548 vam->async_errors += (retval < 0);
1552 vam->retval = retval;
1553 vam->result_ready = 1;
1557 static void vl_api_l2_flags_reply_t_handler_json
1558 (vl_api_l2_flags_reply_t * mp)
1560 vat_main_t *vam = &vat_main;
1561 vat_json_node_t node;
1563 vat_json_init_object (&node);
1564 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1565 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1566 ntohl (mp->resulting_feature_bitmap));
1568 vat_json_print (vam->ofp, &node);
1569 vat_json_free (&node);
1571 vam->retval = ntohl (mp->retval);
1572 vam->result_ready = 1;
1575 static void vl_api_bridge_flags_reply_t_handler
1576 (vl_api_bridge_flags_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 i32 retval = ntohl (mp->retval);
1580 if (vam->async_mode)
1582 vam->async_errors += (retval < 0);
1586 vam->retval = retval;
1587 vam->result_ready = 1;
1591 static void vl_api_bridge_flags_reply_t_handler_json
1592 (vl_api_bridge_flags_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 vat_json_node_t node;
1597 vat_json_init_object (&node);
1598 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1599 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1600 ntohl (mp->resulting_feature_bitmap));
1602 vat_json_print (vam->ofp, &node);
1603 vat_json_free (&node);
1605 vam->retval = ntohl (mp->retval);
1606 vam->result_ready = 1;
1609 static void vl_api_tap_connect_reply_t_handler
1610 (vl_api_tap_connect_reply_t * mp)
1612 vat_main_t *vam = &vat_main;
1613 i32 retval = ntohl (mp->retval);
1614 if (vam->async_mode)
1616 vam->async_errors += (retval < 0);
1620 vam->retval = retval;
1621 vam->sw_if_index = ntohl (mp->sw_if_index);
1622 vam->result_ready = 1;
1627 static void vl_api_tap_connect_reply_t_handler_json
1628 (vl_api_tap_connect_reply_t * mp)
1630 vat_main_t *vam = &vat_main;
1631 vat_json_node_t node;
1633 vat_json_init_object (&node);
1634 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1635 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1637 vat_json_print (vam->ofp, &node);
1638 vat_json_free (&node);
1640 vam->retval = ntohl (mp->retval);
1641 vam->result_ready = 1;
1646 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 i32 retval = ntohl (mp->retval);
1650 if (vam->async_mode)
1652 vam->async_errors += (retval < 0);
1656 vam->retval = retval;
1657 vam->sw_if_index = ntohl (mp->sw_if_index);
1658 vam->result_ready = 1;
1662 static void vl_api_tap_modify_reply_t_handler_json
1663 (vl_api_tap_modify_reply_t * mp)
1665 vat_main_t *vam = &vat_main;
1666 vat_json_node_t node;
1668 vat_json_init_object (&node);
1669 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1670 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1672 vat_json_print (vam->ofp, &node);
1673 vat_json_free (&node);
1675 vam->retval = ntohl (mp->retval);
1676 vam->result_ready = 1;
1680 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1682 vat_main_t *vam = &vat_main;
1683 i32 retval = ntohl (mp->retval);
1684 if (vam->async_mode)
1686 vam->async_errors += (retval < 0);
1690 vam->retval = retval;
1691 vam->result_ready = 1;
1695 static void vl_api_tap_delete_reply_t_handler_json
1696 (vl_api_tap_delete_reply_t * mp)
1698 vat_main_t *vam = &vat_main;
1699 vat_json_node_t node;
1701 vat_json_init_object (&node);
1702 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1704 vat_json_print (vam->ofp, &node);
1705 vat_json_free (&node);
1707 vam->retval = ntohl (mp->retval);
1708 vam->result_ready = 1;
1712 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1714 vat_main_t *vam = &vat_main;
1715 i32 retval = ntohl (mp->retval);
1716 if (vam->async_mode)
1718 vam->async_errors += (retval < 0);
1722 vam->retval = retval;
1723 vam->sw_if_index = ntohl (mp->sw_if_index);
1724 vam->result_ready = 1;
1729 static void vl_api_tap_create_v2_reply_t_handler_json
1730 (vl_api_tap_create_v2_reply_t * mp)
1732 vat_main_t *vam = &vat_main;
1733 vat_json_node_t node;
1735 vat_json_init_object (&node);
1736 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1737 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1739 vat_json_print (vam->ofp, &node);
1740 vat_json_free (&node);
1742 vam->retval = ntohl (mp->retval);
1743 vam->result_ready = 1;
1748 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 i32 retval = ntohl (mp->retval);
1752 if (vam->async_mode)
1754 vam->async_errors += (retval < 0);
1758 vam->retval = retval;
1759 vam->result_ready = 1;
1763 static void vl_api_tap_delete_v2_reply_t_handler_json
1764 (vl_api_tap_delete_v2_reply_t * mp)
1766 vat_main_t *vam = &vat_main;
1767 vat_json_node_t node;
1769 vat_json_init_object (&node);
1770 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1772 vat_json_print (vam->ofp, &node);
1773 vat_json_free (&node);
1775 vam->retval = ntohl (mp->retval);
1776 vam->result_ready = 1;
1780 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1782 vat_main_t *vam = &vat_main;
1783 i32 retval = ntohl (mp->retval);
1785 if (vam->async_mode)
1787 vam->async_errors += (retval < 0);
1791 vam->retval = retval;
1792 vam->sw_if_index = ntohl (mp->sw_if_index);
1793 vam->result_ready = 1;
1797 static void vl_api_bond_create_reply_t_handler_json
1798 (vl_api_bond_create_reply_t * mp)
1800 vat_main_t *vam = &vat_main;
1801 vat_json_node_t node;
1803 vat_json_init_object (&node);
1804 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1805 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1807 vat_json_print (vam->ofp, &node);
1808 vat_json_free (&node);
1810 vam->retval = ntohl (mp->retval);
1811 vam->result_ready = 1;
1815 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1817 vat_main_t *vam = &vat_main;
1818 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 vam->retval = retval;
1827 vam->result_ready = 1;
1831 static void vl_api_bond_delete_reply_t_handler_json
1832 (vl_api_bond_delete_reply_t * mp)
1834 vat_main_t *vam = &vat_main;
1835 vat_json_node_t node;
1837 vat_json_init_object (&node);
1838 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1840 vat_json_print (vam->ofp, &node);
1841 vat_json_free (&node);
1843 vam->retval = ntohl (mp->retval);
1844 vam->result_ready = 1;
1848 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1850 vat_main_t *vam = &vat_main;
1851 i32 retval = ntohl (mp->retval);
1853 if (vam->async_mode)
1855 vam->async_errors += (retval < 0);
1859 vam->retval = retval;
1860 vam->result_ready = 1;
1864 static void vl_api_bond_enslave_reply_t_handler_json
1865 (vl_api_bond_enslave_reply_t * mp)
1867 vat_main_t *vam = &vat_main;
1868 vat_json_node_t node;
1870 vat_json_init_object (&node);
1871 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1873 vat_json_print (vam->ofp, &node);
1874 vat_json_free (&node);
1876 vam->retval = ntohl (mp->retval);
1877 vam->result_ready = 1;
1881 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1884 vat_main_t *vam = &vat_main;
1885 i32 retval = ntohl (mp->retval);
1887 if (vam->async_mode)
1889 vam->async_errors += (retval < 0);
1893 vam->retval = retval;
1894 vam->result_ready = 1;
1898 static void vl_api_bond_detach_slave_reply_t_handler_json
1899 (vl_api_bond_detach_slave_reply_t * mp)
1901 vat_main_t *vam = &vat_main;
1902 vat_json_node_t node;
1904 vat_json_init_object (&node);
1905 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1907 vat_json_print (vam->ofp, &node);
1908 vat_json_free (&node);
1910 vam->retval = ntohl (mp->retval);
1911 vam->result_ready = 1;
1914 static void vl_api_sw_interface_bond_details_t_handler
1915 (vl_api_sw_interface_bond_details_t * mp)
1917 vat_main_t *vam = &vat_main;
1920 "%-16s %-12d %-12U %-13U %-14u %-14u",
1921 mp->interface_name, ntohl (mp->sw_if_index),
1922 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1923 ntohl (mp->active_slaves), ntohl (mp->slaves));
1926 static void vl_api_sw_interface_bond_details_t_handler_json
1927 (vl_api_sw_interface_bond_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1930 vat_json_node_t *node = NULL;
1932 if (VAT_JSON_ARRAY != vam->json_tree.type)
1934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1935 vat_json_init_array (&vam->json_tree);
1937 node = vat_json_array_add (&vam->json_tree);
1939 vat_json_init_object (node);
1940 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1941 vat_json_object_add_string_copy (node, "interface_name",
1942 mp->interface_name);
1943 vat_json_object_add_uint (node, "mode", mp->mode);
1944 vat_json_object_add_uint (node, "load_balance", mp->lb);
1945 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1946 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1950 api_sw_interface_bond_dump (vat_main_t * vam)
1952 vl_api_sw_interface_bond_dump_t *mp;
1953 vl_api_control_ping_t *mp_ping;
1957 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1958 "interface name", "sw_if_index", "mode", "load balance",
1959 "active slaves", "slaves");
1961 /* Get list of bond interfaces */
1962 M (SW_INTERFACE_BOND_DUMP, mp);
1965 /* Use a control ping for synchronization */
1966 MPING (CONTROL_PING, mp_ping);
1973 static void vl_api_sw_interface_slave_details_t_handler
1974 (vl_api_sw_interface_slave_details_t * mp)
1976 vat_main_t *vam = &vat_main;
1979 "%-25s %-12d %-12d %d", mp->interface_name,
1980 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1983 static void vl_api_sw_interface_slave_details_t_handler_json
1984 (vl_api_sw_interface_slave_details_t * mp)
1986 vat_main_t *vam = &vat_main;
1987 vat_json_node_t *node = NULL;
1989 if (VAT_JSON_ARRAY != vam->json_tree.type)
1991 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1992 vat_json_init_array (&vam->json_tree);
1994 node = vat_json_array_add (&vam->json_tree);
1996 vat_json_init_object (node);
1997 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1998 vat_json_object_add_string_copy (node, "interface_name",
1999 mp->interface_name);
2000 vat_json_object_add_uint (node, "passive", mp->is_passive);
2001 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2005 api_sw_interface_slave_dump (vat_main_t * vam)
2007 unformat_input_t *i = vam->input;
2008 vl_api_sw_interface_slave_dump_t *mp;
2009 vl_api_control_ping_t *mp_ping;
2010 u32 sw_if_index = ~0;
2011 u8 sw_if_index_set = 0;
2014 /* Parse args required to build the message */
2015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2018 sw_if_index_set = 1;
2019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2020 sw_if_index_set = 1;
2025 if (sw_if_index_set == 0)
2027 errmsg ("missing vpp interface name. ");
2032 "\n%-25s %-12s %-12s %s",
2033 "slave interface name", "sw_if_index", "passive", "long_timeout");
2035 /* Get list of bond interfaces */
2036 M (SW_INTERFACE_SLAVE_DUMP, mp);
2037 mp->sw_if_index = ntohl (sw_if_index);
2040 /* Use a control ping for synchronization */
2041 MPING (CONTROL_PING, mp_ping);
2048 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2049 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2051 vat_main_t *vam = &vat_main;
2052 i32 retval = ntohl (mp->retval);
2053 if (vam->async_mode)
2055 vam->async_errors += (retval < 0);
2059 vam->retval = retval;
2060 vam->result_ready = 1;
2064 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2065 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2067 vat_main_t *vam = &vat_main;
2068 vat_json_node_t node;
2070 vat_json_init_object (&node);
2071 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2072 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2073 ntohl (mp->sw_if_index));
2075 vat_json_print (vam->ofp, &node);
2076 vat_json_free (&node);
2078 vam->retval = ntohl (mp->retval);
2079 vam->result_ready = 1;
2082 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2083 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2085 vat_main_t *vam = &vat_main;
2086 i32 retval = ntohl (mp->retval);
2087 if (vam->async_mode)
2089 vam->async_errors += (retval < 0);
2093 vam->retval = retval;
2094 vam->sw_if_index = ntohl (mp->sw_if_index);
2095 vam->result_ready = 1;
2099 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2100 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2102 vat_main_t *vam = &vat_main;
2103 vat_json_node_t node;
2105 vat_json_init_object (&node);
2106 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2107 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2109 vat_json_print (vam->ofp, &node);
2110 vat_json_free (&node);
2112 vam->retval = ntohl (mp->retval);
2113 vam->result_ready = 1;
2116 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2117 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2119 vat_main_t *vam = &vat_main;
2120 i32 retval = ntohl (mp->retval);
2121 if (vam->async_mode)
2123 vam->async_errors += (retval < 0);
2127 vam->retval = retval;
2128 vam->result_ready = 1;
2132 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2133 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2135 vat_main_t *vam = &vat_main;
2136 vat_json_node_t node;
2138 vat_json_init_object (&node);
2139 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2140 vat_json_object_add_uint (&node, "fwd_entry_index",
2141 clib_net_to_host_u32 (mp->fwd_entry_index));
2143 vat_json_print (vam->ofp, &node);
2144 vat_json_free (&node);
2146 vam->retval = ntohl (mp->retval);
2147 vam->result_ready = 1;
2151 format_lisp_transport_protocol (u8 * s, va_list * args)
2153 u32 proto = va_arg (*args, u32);
2158 return format (s, "udp");
2160 return format (s, "api");
2167 static void vl_api_one_get_transport_protocol_reply_t_handler
2168 (vl_api_one_get_transport_protocol_reply_t * mp)
2170 vat_main_t *vam = &vat_main;
2171 i32 retval = ntohl (mp->retval);
2172 if (vam->async_mode)
2174 vam->async_errors += (retval < 0);
2178 u32 proto = mp->protocol;
2179 print (vam->ofp, "Transport protocol: %U",
2180 format_lisp_transport_protocol, proto);
2181 vam->retval = retval;
2182 vam->result_ready = 1;
2186 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2187 (vl_api_one_get_transport_protocol_reply_t * mp)
2189 vat_main_t *vam = &vat_main;
2190 vat_json_node_t node;
2193 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2196 vat_json_init_object (&node);
2197 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2198 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2201 vat_json_print (vam->ofp, &node);
2202 vat_json_free (&node);
2204 vam->retval = ntohl (mp->retval);
2205 vam->result_ready = 1;
2208 static void vl_api_one_add_del_locator_set_reply_t_handler
2209 (vl_api_one_add_del_locator_set_reply_t * mp)
2211 vat_main_t *vam = &vat_main;
2212 i32 retval = ntohl (mp->retval);
2213 if (vam->async_mode)
2215 vam->async_errors += (retval < 0);
2219 vam->retval = retval;
2220 vam->result_ready = 1;
2224 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2225 (vl_api_one_add_del_locator_set_reply_t * mp)
2227 vat_main_t *vam = &vat_main;
2228 vat_json_node_t node;
2230 vat_json_init_object (&node);
2231 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2232 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2234 vat_json_print (vam->ofp, &node);
2235 vat_json_free (&node);
2237 vam->retval = ntohl (mp->retval);
2238 vam->result_ready = 1;
2241 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2242 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2244 vat_main_t *vam = &vat_main;
2245 i32 retval = ntohl (mp->retval);
2246 if (vam->async_mode)
2248 vam->async_errors += (retval < 0);
2252 vam->retval = retval;
2253 vam->sw_if_index = ntohl (mp->sw_if_index);
2254 vam->result_ready = 1;
2256 vam->regenerate_interface_table = 1;
2259 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2260 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2262 vat_main_t *vam = &vat_main;
2263 vat_json_node_t node;
2265 vat_json_init_object (&node);
2266 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2267 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2269 vat_json_print (vam->ofp, &node);
2270 vat_json_free (&node);
2272 vam->retval = ntohl (mp->retval);
2273 vam->result_ready = 1;
2276 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2277 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2279 vat_main_t *vam = &vat_main;
2280 i32 retval = ntohl (mp->retval);
2281 if (vam->async_mode)
2283 vam->async_errors += (retval < 0);
2287 vam->retval = retval;
2288 vam->sw_if_index = ntohl (mp->sw_if_index);
2289 vam->result_ready = 1;
2293 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2294 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2296 vat_main_t *vam = &vat_main;
2297 vat_json_node_t node;
2299 vat_json_init_object (&node);
2300 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2301 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2303 vat_json_print (vam->ofp, &node);
2304 vat_json_free (&node);
2306 vam->retval = ntohl (mp->retval);
2307 vam->result_ready = 1;
2310 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2311 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2313 vat_main_t *vam = &vat_main;
2314 i32 retval = ntohl (mp->retval);
2315 if (vam->async_mode)
2317 vam->async_errors += (retval < 0);
2321 vam->retval = retval;
2322 vam->sw_if_index = ntohl (mp->sw_if_index);
2323 vam->result_ready = 1;
2325 vam->regenerate_interface_table = 1;
2328 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2329 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2331 vat_main_t *vam = &vat_main;
2332 vat_json_node_t node;
2334 vat_json_init_object (&node);
2335 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2336 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2338 vat_json_print (vam->ofp, &node);
2339 vat_json_free (&node);
2341 vam->retval = ntohl (mp->retval);
2342 vam->result_ready = 1;
2345 static void vl_api_gre_add_del_tunnel_reply_t_handler
2346 (vl_api_gre_add_del_tunnel_reply_t * mp)
2348 vat_main_t *vam = &vat_main;
2349 i32 retval = ntohl (mp->retval);
2350 if (vam->async_mode)
2352 vam->async_errors += (retval < 0);
2356 vam->retval = retval;
2357 vam->sw_if_index = ntohl (mp->sw_if_index);
2358 vam->result_ready = 1;
2362 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2363 (vl_api_gre_add_del_tunnel_reply_t * mp)
2365 vat_main_t *vam = &vat_main;
2366 vat_json_node_t node;
2368 vat_json_init_object (&node);
2369 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2370 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2372 vat_json_print (vam->ofp, &node);
2373 vat_json_free (&node);
2375 vam->retval = ntohl (mp->retval);
2376 vam->result_ready = 1;
2379 static void vl_api_create_vhost_user_if_reply_t_handler
2380 (vl_api_create_vhost_user_if_reply_t * mp)
2382 vat_main_t *vam = &vat_main;
2383 i32 retval = ntohl (mp->retval);
2384 if (vam->async_mode)
2386 vam->async_errors += (retval < 0);
2390 vam->retval = retval;
2391 vam->sw_if_index = ntohl (mp->sw_if_index);
2392 vam->result_ready = 1;
2394 vam->regenerate_interface_table = 1;
2397 static void vl_api_create_vhost_user_if_reply_t_handler_json
2398 (vl_api_create_vhost_user_if_reply_t * mp)
2400 vat_main_t *vam = &vat_main;
2401 vat_json_node_t node;
2403 vat_json_init_object (&node);
2404 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2405 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2407 vat_json_print (vam->ofp, &node);
2408 vat_json_free (&node);
2410 vam->retval = ntohl (mp->retval);
2411 vam->result_ready = 1;
2414 static clib_error_t *
2415 receive_fd_msg (int socket_fd, int *my_fd)
2418 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2419 struct msghdr mh = { 0 };
2420 struct iovec iov[1];
2422 struct ucred *cr = 0;
2423 struct cmsghdr *cmsg;
2424 pid_t pid __attribute__ ((unused));
2425 uid_t uid __attribute__ ((unused));
2426 gid_t gid __attribute__ ((unused));
2428 iov[0].iov_base = msgbuf;
2432 mh.msg_control = ctl;
2433 mh.msg_controllen = sizeof (ctl);
2435 memset (ctl, 0, sizeof (ctl));
2437 /* receive the incoming message */
2438 size = recvmsg (socket_fd, &mh, 0);
2441 return (size == 0) ? clib_error_return (0, "disconnected") :
2442 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2446 cmsg = CMSG_FIRSTHDR (&mh);
2449 if (cmsg->cmsg_level == SOL_SOCKET)
2451 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2453 cr = (struct ucred *) CMSG_DATA (cmsg);
2458 else if (cmsg->cmsg_type == SCM_RIGHTS)
2460 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2463 cmsg = CMSG_NXTHDR (&mh, cmsg);
2468 static void vl_api_memfd_segment_create_reply_t_handler
2469 (vl_api_memfd_segment_create_reply_t * mp)
2471 /* Dont bother in the builtin version */
2472 #if VPP_API_TEST_BUILTIN == 0
2473 vat_main_t *vam = &vat_main;
2474 api_main_t *am = &api_main;
2475 socket_client_main_t *scm = vam->socket_client_main;
2477 clib_error_t *error;
2478 ssvm_private_t memfd;
2479 i32 retval = ntohl (mp->retval);
2483 error = receive_fd_msg (scm->socket_fd, &my_fd);
2490 memset (&memfd, 0, sizeof (memfd));
2493 vam->client_index_invalid = 1;
2495 /* Note: this closes memfd.fd */
2496 retval = ssvm_slave_init_memfd (&memfd);
2498 clib_warning ("WARNING: segment map returned %d", retval);
2500 /* Pivot to the memory client segment that vpp just created */
2502 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2504 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2506 vl_client_install_client_message_handlers ();
2508 vl_client_connect_to_vlib_no_map ("pvt",
2510 32 /* input_queue_length */ );
2511 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2513 vl_socket_client_enable_disable (0 /* disable socket */ );
2517 if (vam->async_mode)
2519 vam->async_errors += (retval < 0);
2523 vam->retval = retval;
2524 vam->result_ready = 1;
2529 static void vl_api_memfd_segment_create_reply_t_handler_json
2530 (vl_api_memfd_segment_create_reply_t * mp)
2532 clib_warning ("no");
2535 static void vl_api_dns_resolve_name_reply_t_handler
2536 (vl_api_dns_resolve_name_reply_t * mp)
2538 vat_main_t *vam = &vat_main;
2539 i32 retval = ntohl (mp->retval);
2540 if (vam->async_mode)
2542 vam->async_errors += (retval < 0);
2546 vam->retval = retval;
2547 vam->result_ready = 1;
2552 clib_warning ("ip4 address %U", format_ip4_address,
2553 (ip4_address_t *) mp->ip4_address);
2555 clib_warning ("ip6 address %U", format_ip6_address,
2556 (ip6_address_t *) mp->ip6_address);
2559 clib_warning ("retval %d", retval);
2563 static void vl_api_dns_resolve_name_reply_t_handler_json
2564 (vl_api_dns_resolve_name_reply_t * mp)
2566 clib_warning ("not implemented");
2569 static void vl_api_dns_resolve_ip_reply_t_handler
2570 (vl_api_dns_resolve_ip_reply_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 i32 retval = ntohl (mp->retval);
2574 if (vam->async_mode)
2576 vam->async_errors += (retval < 0);
2580 vam->retval = retval;
2581 vam->result_ready = 1;
2585 clib_warning ("canonical name %s", mp->name);
2588 clib_warning ("retval %d", retval);
2592 static void vl_api_dns_resolve_ip_reply_t_handler_json
2593 (vl_api_dns_resolve_ip_reply_t * mp)
2595 clib_warning ("not implemented");
2599 static void vl_api_ip_address_details_t_handler
2600 (vl_api_ip_address_details_t * mp)
2602 vat_main_t *vam = &vat_main;
2603 static ip_address_details_t empty_ip_address_details = { {0} };
2604 ip_address_details_t *address = NULL;
2605 ip_details_t *current_ip_details = NULL;
2606 ip_details_t *details = NULL;
2608 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2610 if (!details || vam->current_sw_if_index >= vec_len (details)
2611 || !details[vam->current_sw_if_index].present)
2613 errmsg ("ip address details arrived but not stored");
2614 errmsg ("ip_dump should be called first");
2618 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2620 #define addresses (current_ip_details->addr)
2622 vec_validate_init_empty (addresses, vec_len (addresses),
2623 empty_ip_address_details);
2625 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2627 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2628 address->prefix_length = mp->prefix_length;
2632 static void vl_api_ip_address_details_t_handler_json
2633 (vl_api_ip_address_details_t * mp)
2635 vat_main_t *vam = &vat_main;
2636 vat_json_node_t *node = NULL;
2637 struct in6_addr ip6;
2640 if (VAT_JSON_ARRAY != vam->json_tree.type)
2642 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2643 vat_json_init_array (&vam->json_tree);
2645 node = vat_json_array_add (&vam->json_tree);
2647 vat_json_init_object (node);
2650 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2651 vat_json_object_add_ip6 (node, "ip", ip6);
2655 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2656 vat_json_object_add_ip4 (node, "ip", ip4);
2658 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2662 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2664 vat_main_t *vam = &vat_main;
2665 static ip_details_t empty_ip_details = { 0 };
2666 ip_details_t *ip = NULL;
2667 u32 sw_if_index = ~0;
2669 sw_if_index = ntohl (mp->sw_if_index);
2671 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2672 sw_if_index, empty_ip_details);
2674 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2681 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2683 vat_main_t *vam = &vat_main;
2685 if (VAT_JSON_ARRAY != vam->json_tree.type)
2687 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2688 vat_json_init_array (&vam->json_tree);
2690 vat_json_array_add_uint (&vam->json_tree,
2691 clib_net_to_host_u32 (mp->sw_if_index));
2694 static void vl_api_map_domain_details_t_handler_json
2695 (vl_api_map_domain_details_t * mp)
2697 vat_json_node_t *node = NULL;
2698 vat_main_t *vam = &vat_main;
2699 struct in6_addr ip6;
2702 if (VAT_JSON_ARRAY != vam->json_tree.type)
2704 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2705 vat_json_init_array (&vam->json_tree);
2708 node = vat_json_array_add (&vam->json_tree);
2709 vat_json_init_object (node);
2711 vat_json_object_add_uint (node, "domain_index",
2712 clib_net_to_host_u32 (mp->domain_index));
2713 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2714 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2715 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2716 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2717 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2718 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2719 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2720 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2721 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2722 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2723 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2724 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2725 vat_json_object_add_uint (node, "flags", mp->flags);
2726 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2727 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2730 static void vl_api_map_domain_details_t_handler
2731 (vl_api_map_domain_details_t * mp)
2733 vat_main_t *vam = &vat_main;
2735 if (mp->is_translation)
2738 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2739 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2740 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2741 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2742 clib_net_to_host_u32 (mp->domain_index));
2747 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2748 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2749 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2750 format_ip6_address, mp->ip6_src,
2751 clib_net_to_host_u32 (mp->domain_index));
2753 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2754 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2755 mp->is_translation ? "map-t" : "");
2758 static void vl_api_map_rule_details_t_handler_json
2759 (vl_api_map_rule_details_t * mp)
2761 struct in6_addr ip6;
2762 vat_json_node_t *node = NULL;
2763 vat_main_t *vam = &vat_main;
2765 if (VAT_JSON_ARRAY != vam->json_tree.type)
2767 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2768 vat_json_init_array (&vam->json_tree);
2771 node = vat_json_array_add (&vam->json_tree);
2772 vat_json_init_object (node);
2774 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2775 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2776 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2780 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2782 vat_main_t *vam = &vat_main;
2783 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2784 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2788 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2790 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2791 "router_addr %U host_mac %U",
2792 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2793 format_ip4_address, &mp->host_address,
2794 format_ip4_address, &mp->router_address,
2795 format_ethernet_address, mp->host_mac);
2798 static void vl_api_dhcp_compl_event_t_handler_json
2799 (vl_api_dhcp_compl_event_t * mp)
2801 /* JSON output not supported */
2805 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2808 vat_main_t *vam = &vat_main;
2809 static u64 default_counter = 0;
2811 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2813 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2814 sw_if_index, default_counter);
2815 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2819 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2820 interface_counter_t counter)
2822 vat_main_t *vam = &vat_main;
2823 static interface_counter_t default_counter = { 0, };
2825 vec_validate_init_empty (vam->combined_interface_counters,
2826 vnet_counter_type, NULL);
2827 vec_validate_init_empty (vam->combined_interface_counters
2828 [vnet_counter_type], sw_if_index, default_counter);
2829 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2832 static void vl_api_vnet_interface_simple_counters_t_handler
2833 (vl_api_vnet_interface_simple_counters_t * mp)
2838 static void vl_api_vnet_interface_combined_counters_t_handler
2839 (vl_api_vnet_interface_combined_counters_t * mp)
2844 static void vl_api_vnet_interface_simple_counters_t_handler_json
2845 (vl_api_vnet_interface_simple_counters_t * mp)
2850 u32 first_sw_if_index;
2853 count = ntohl (mp->count);
2854 first_sw_if_index = ntohl (mp->first_sw_if_index);
2856 v_packets = (u64 *) & mp->data;
2857 for (i = 0; i < count; i++)
2859 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2860 set_simple_interface_counter (mp->vnet_counter_type,
2861 first_sw_if_index + i, packets);
2866 static void vl_api_vnet_interface_combined_counters_t_handler_json
2867 (vl_api_vnet_interface_combined_counters_t * mp)
2869 interface_counter_t counter;
2871 u32 first_sw_if_index;
2875 count = ntohl (mp->count);
2876 first_sw_if_index = ntohl (mp->first_sw_if_index);
2878 v = (vlib_counter_t *) & mp->data;
2879 for (i = 0; i < count; i++)
2882 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2884 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2885 set_combined_interface_counter (mp->vnet_counter_type,
2886 first_sw_if_index + i, counter);
2892 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2894 vat_main_t *vam = &vat_main;
2897 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2899 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2908 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2910 vat_main_t *vam = &vat_main;
2913 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2915 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2923 static void vl_api_vnet_ip4_fib_counters_t_handler
2924 (vl_api_vnet_ip4_fib_counters_t * mp)
2929 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2930 (vl_api_vnet_ip4_fib_counters_t * mp)
2932 vat_main_t *vam = &vat_main;
2933 vl_api_ip4_fib_counter_t *v;
2934 ip4_fib_counter_t *counter;
2941 vrf_id = ntohl (mp->vrf_id);
2942 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2943 if (~0 == vrf_index)
2945 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2946 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2947 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2948 vec_validate (vam->ip4_fib_counters, vrf_index);
2949 vam->ip4_fib_counters[vrf_index] = NULL;
2952 vec_free (vam->ip4_fib_counters[vrf_index]);
2953 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2954 count = ntohl (mp->count);
2955 for (i = 0; i < count; i++)
2957 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2958 counter = &vam->ip4_fib_counters[vrf_index][i];
2959 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2960 counter->address = ip4;
2961 counter->address_length = v->address_length;
2962 counter->packets = clib_net_to_host_u64 (v->packets);
2963 counter->bytes = clib_net_to_host_u64 (v->bytes);
2968 static void vl_api_vnet_ip4_nbr_counters_t_handler
2969 (vl_api_vnet_ip4_nbr_counters_t * mp)
2974 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2975 (vl_api_vnet_ip4_nbr_counters_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vl_api_ip4_nbr_counter_t *v;
2979 ip4_nbr_counter_t *counter;
2984 sw_if_index = ntohl (mp->sw_if_index);
2985 count = ntohl (mp->count);
2986 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2989 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2991 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2992 for (i = 0; i < count; i++)
2994 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2995 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2996 counter->address.s_addr = v->address;
2997 counter->packets = clib_net_to_host_u64 (v->packets);
2998 counter->bytes = clib_net_to_host_u64 (v->bytes);
2999 counter->linkt = v->link_type;
3004 static void vl_api_vnet_ip6_fib_counters_t_handler
3005 (vl_api_vnet_ip6_fib_counters_t * mp)
3010 static void vl_api_vnet_ip6_fib_counters_t_handler_json
3011 (vl_api_vnet_ip6_fib_counters_t * mp)
3013 vat_main_t *vam = &vat_main;
3014 vl_api_ip6_fib_counter_t *v;
3015 ip6_fib_counter_t *counter;
3016 struct in6_addr ip6;
3022 vrf_id = ntohl (mp->vrf_id);
3023 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
3024 if (~0 == vrf_index)
3026 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
3027 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
3028 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
3029 vec_validate (vam->ip6_fib_counters, vrf_index);
3030 vam->ip6_fib_counters[vrf_index] = NULL;
3033 vec_free (vam->ip6_fib_counters[vrf_index]);
3034 v = (vl_api_ip6_fib_counter_t *) & mp->c;
3035 count = ntohl (mp->count);
3036 for (i = 0; i < count; i++)
3038 vec_validate (vam->ip6_fib_counters[vrf_index], i);
3039 counter = &vam->ip6_fib_counters[vrf_index][i];
3040 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3041 counter->address = ip6;
3042 counter->address_length = v->address_length;
3043 counter->packets = clib_net_to_host_u64 (v->packets);
3044 counter->bytes = clib_net_to_host_u64 (v->bytes);
3049 static void vl_api_vnet_ip6_nbr_counters_t_handler
3050 (vl_api_vnet_ip6_nbr_counters_t * mp)
3055 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
3056 (vl_api_vnet_ip6_nbr_counters_t * mp)
3058 vat_main_t *vam = &vat_main;
3059 vl_api_ip6_nbr_counter_t *v;
3060 ip6_nbr_counter_t *counter;
3061 struct in6_addr ip6;
3066 sw_if_index = ntohl (mp->sw_if_index);
3067 count = ntohl (mp->count);
3068 vec_validate (vam->ip6_nbr_counters, sw_if_index);
3071 vec_free (vam->ip6_nbr_counters[sw_if_index]);
3073 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
3074 for (i = 0; i < count; i++)
3076 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
3077 counter = &vam->ip6_nbr_counters[sw_if_index][i];
3078 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3079 counter->address = ip6;
3080 counter->packets = clib_net_to_host_u64 (v->packets);
3081 counter->bytes = clib_net_to_host_u64 (v->bytes);
3086 static void vl_api_get_first_msg_id_reply_t_handler
3087 (vl_api_get_first_msg_id_reply_t * mp)
3089 vat_main_t *vam = &vat_main;
3090 i32 retval = ntohl (mp->retval);
3092 if (vam->async_mode)
3094 vam->async_errors += (retval < 0);
3098 vam->retval = retval;
3099 vam->result_ready = 1;
3103 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3107 static void vl_api_get_first_msg_id_reply_t_handler_json
3108 (vl_api_get_first_msg_id_reply_t * mp)
3110 vat_main_t *vam = &vat_main;
3111 vat_json_node_t node;
3113 vat_json_init_object (&node);
3114 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3115 vat_json_object_add_uint (&node, "first_msg_id",
3116 (uint) ntohs (mp->first_msg_id));
3118 vat_json_print (vam->ofp, &node);
3119 vat_json_free (&node);
3121 vam->retval = ntohl (mp->retval);
3122 vam->result_ready = 1;
3125 static void vl_api_get_node_graph_reply_t_handler
3126 (vl_api_get_node_graph_reply_t * mp)
3128 vat_main_t *vam = &vat_main;
3129 api_main_t *am = &api_main;
3130 i32 retval = ntohl (mp->retval);
3131 u8 *pvt_copy, *reply;
3136 if (vam->async_mode)
3138 vam->async_errors += (retval < 0);
3142 vam->retval = retval;
3143 vam->result_ready = 1;
3146 /* "Should never happen..." */
3150 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3151 pvt_copy = vec_dup (reply);
3153 /* Toss the shared-memory original... */
3154 pthread_mutex_lock (&am->vlib_rp->mutex);
3155 oldheap = svm_push_data_heap (am->vlib_rp);
3159 svm_pop_heap (oldheap);
3160 pthread_mutex_unlock (&am->vlib_rp->mutex);
3162 if (vam->graph_nodes)
3164 hash_free (vam->graph_node_index_by_name);
3166 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3168 node = vam->graph_nodes[i];
3169 vec_free (node->name);
3170 vec_free (node->next_nodes);
3173 vec_free (vam->graph_nodes);
3176 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3177 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3178 vec_free (pvt_copy);
3180 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3182 node = vam->graph_nodes[i];
3183 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3187 static void vl_api_get_node_graph_reply_t_handler_json
3188 (vl_api_get_node_graph_reply_t * mp)
3190 vat_main_t *vam = &vat_main;
3191 api_main_t *am = &api_main;
3193 vat_json_node_t node;
3196 /* $$$$ make this real? */
3197 vat_json_init_object (&node);
3198 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3199 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3201 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3203 /* Toss the shared-memory original... */
3204 pthread_mutex_lock (&am->vlib_rp->mutex);
3205 oldheap = svm_push_data_heap (am->vlib_rp);
3209 svm_pop_heap (oldheap);
3210 pthread_mutex_unlock (&am->vlib_rp->mutex);
3212 vat_json_print (vam->ofp, &node);
3213 vat_json_free (&node);
3215 vam->retval = ntohl (mp->retval);
3216 vam->result_ready = 1;
3220 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3222 vat_main_t *vam = &vat_main;
3227 s = format (s, "%=16d%=16d%=16d",
3228 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3232 s = format (s, "%=16U%=16d%=16d",
3233 mp->is_ipv6 ? format_ip6_address :
3235 mp->ip_address, mp->priority, mp->weight);
3238 print (vam->ofp, "%v", s);
3243 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3245 vat_main_t *vam = &vat_main;
3246 vat_json_node_t *node = NULL;
3247 struct in6_addr ip6;
3250 if (VAT_JSON_ARRAY != vam->json_tree.type)
3252 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3253 vat_json_init_array (&vam->json_tree);
3255 node = vat_json_array_add (&vam->json_tree);
3256 vat_json_init_object (node);
3258 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3259 vat_json_object_add_uint (node, "priority", mp->priority);
3260 vat_json_object_add_uint (node, "weight", mp->weight);
3263 vat_json_object_add_uint (node, "sw_if_index",
3264 clib_net_to_host_u32 (mp->sw_if_index));
3269 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3270 vat_json_object_add_ip6 (node, "address", ip6);
3274 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3275 vat_json_object_add_ip4 (node, "address", ip4);
3281 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3284 vat_main_t *vam = &vat_main;
3287 ls_name = format (0, "%s", mp->ls_name);
3289 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3295 vl_api_one_locator_set_details_t_handler_json
3296 (vl_api_one_locator_set_details_t * mp)
3298 vat_main_t *vam = &vat_main;
3299 vat_json_node_t *node = 0;
3302 ls_name = format (0, "%s", mp->ls_name);
3303 vec_add1 (ls_name, 0);
3305 if (VAT_JSON_ARRAY != vam->json_tree.type)
3307 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3308 vat_json_init_array (&vam->json_tree);
3310 node = vat_json_array_add (&vam->json_tree);
3312 vat_json_init_object (node);
3313 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3314 vat_json_object_add_uint (node, "ls_index",
3315 clib_net_to_host_u32 (mp->ls_index));
3323 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3326 unformat_nsh_address (unformat_input_t * input, va_list * args)
3328 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3329 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3333 format_nsh_address_vat (u8 * s, va_list * args)
3335 nsh_t *a = va_arg (*args, nsh_t *);
3336 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3340 format_lisp_flat_eid (u8 * s, va_list * args)
3342 u32 type = va_arg (*args, u32);
3343 u8 *eid = va_arg (*args, u8 *);
3344 u32 eid_len = va_arg (*args, u32);
3349 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3351 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3353 return format (s, "%U", format_ethernet_address, eid);
3355 return format (s, "%U", format_nsh_address_vat, eid);
3361 format_lisp_eid_vat (u8 * s, va_list * args)
3363 u32 type = va_arg (*args, u32);
3364 u8 *eid = va_arg (*args, u8 *);
3365 u32 eid_len = va_arg (*args, u32);
3366 u8 *seid = va_arg (*args, u8 *);
3367 u32 seid_len = va_arg (*args, u32);
3368 u32 is_src_dst = va_arg (*args, u32);
3371 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3373 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3379 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3381 vat_main_t *vam = &vat_main;
3382 u8 *s = 0, *eid = 0;
3384 if (~0 == mp->locator_set_index)
3385 s = format (0, "action: %d", mp->action);
3387 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3389 eid = format (0, "%U", format_lisp_eid_vat,
3393 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3396 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3397 clib_net_to_host_u32 (mp->vni),
3399 mp->is_local ? "local" : "remote",
3400 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3401 clib_net_to_host_u16 (mp->key_id), mp->key);
3408 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3411 vat_main_t *vam = &vat_main;
3412 vat_json_node_t *node = 0;
3415 if (VAT_JSON_ARRAY != vam->json_tree.type)
3417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3418 vat_json_init_array (&vam->json_tree);
3420 node = vat_json_array_add (&vam->json_tree);
3422 vat_json_init_object (node);
3423 if (~0 == mp->locator_set_index)
3424 vat_json_object_add_uint (node, "action", mp->action);
3426 vat_json_object_add_uint (node, "locator_set_index",
3427 clib_net_to_host_u32 (mp->locator_set_index));
3429 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3430 if (mp->eid_type == 3)
3432 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3433 vat_json_init_object (nsh_json);
3434 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3435 vat_json_object_add_uint (nsh_json, "spi",
3436 clib_net_to_host_u32 (nsh->spi));
3437 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3441 eid = format (0, "%U", format_lisp_eid_vat,
3445 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3447 vat_json_object_add_string_copy (node, "eid", eid);
3450 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3451 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3452 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3456 vat_json_object_add_uint (node, "key_id",
3457 clib_net_to_host_u16 (mp->key_id));
3458 vat_json_object_add_string_copy (node, "key", mp->key);
3463 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 u8 *seid = 0, *deid = 0;
3467 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3469 deid = format (0, "%U", format_lisp_eid_vat,
3470 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3472 seid = format (0, "%U", format_lisp_eid_vat,
3473 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3479 format_ip_address_fcn = format_ip4_address;
3481 format_ip_address_fcn = format_ip6_address;
3484 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3485 clib_net_to_host_u32 (mp->vni),
3487 format_ip_address_fcn, mp->lloc,
3488 format_ip_address_fcn, mp->rloc,
3489 clib_net_to_host_u32 (mp->pkt_count),
3490 clib_net_to_host_u32 (mp->bytes));
3497 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3499 struct in6_addr ip6;
3501 vat_main_t *vam = &vat_main;
3502 vat_json_node_t *node = 0;
3503 u8 *deid = 0, *seid = 0;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3512 vat_json_init_object (node);
3513 deid = format (0, "%U", format_lisp_eid_vat,
3514 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3516 seid = format (0, "%U", format_lisp_eid_vat,
3517 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3522 vat_json_object_add_string_copy (node, "seid", seid);
3523 vat_json_object_add_string_copy (node, "deid", deid);
3524 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3528 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3529 vat_json_object_add_ip4 (node, "lloc", ip4);
3530 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3531 vat_json_object_add_ip4 (node, "rloc", ip4);
3535 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3536 vat_json_object_add_ip6 (node, "lloc", ip6);
3537 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3538 vat_json_object_add_ip6 (node, "rloc", ip6);
3540 vat_json_object_add_uint (node, "pkt_count",
3541 clib_net_to_host_u32 (mp->pkt_count));
3542 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3549 vl_api_one_eid_table_map_details_t_handler
3550 (vl_api_one_eid_table_map_details_t * mp)
3552 vat_main_t *vam = &vat_main;
3554 u8 *line = format (0, "%=10d%=10d",
3555 clib_net_to_host_u32 (mp->vni),
3556 clib_net_to_host_u32 (mp->dp_table));
3557 print (vam->ofp, "%v", line);
3562 vl_api_one_eid_table_map_details_t_handler_json
3563 (vl_api_one_eid_table_map_details_t * mp)
3565 vat_main_t *vam = &vat_main;
3566 vat_json_node_t *node = NULL;
3568 if (VAT_JSON_ARRAY != vam->json_tree.type)
3570 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3571 vat_json_init_array (&vam->json_tree);
3573 node = vat_json_array_add (&vam->json_tree);
3574 vat_json_init_object (node);
3575 vat_json_object_add_uint (node, "dp_table",
3576 clib_net_to_host_u32 (mp->dp_table));
3577 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3581 vl_api_one_eid_table_vni_details_t_handler
3582 (vl_api_one_eid_table_vni_details_t * mp)
3584 vat_main_t *vam = &vat_main;
3586 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3587 print (vam->ofp, "%v", line);
3592 vl_api_one_eid_table_vni_details_t_handler_json
3593 (vl_api_one_eid_table_vni_details_t * mp)
3595 vat_main_t *vam = &vat_main;
3596 vat_json_node_t *node = NULL;
3598 if (VAT_JSON_ARRAY != vam->json_tree.type)
3600 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3601 vat_json_init_array (&vam->json_tree);
3603 node = vat_json_array_add (&vam->json_tree);
3604 vat_json_init_object (node);
3605 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3609 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3610 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3612 vat_main_t *vam = &vat_main;
3613 int retval = clib_net_to_host_u32 (mp->retval);
3615 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3616 print (vam->ofp, "fallback threshold value: %d", mp->value);
3618 vam->retval = retval;
3619 vam->result_ready = 1;
3623 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3624 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3626 vat_main_t *vam = &vat_main;
3627 vat_json_node_t _node, *node = &_node;
3628 int retval = clib_net_to_host_u32 (mp->retval);
3630 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3631 vat_json_init_object (node);
3632 vat_json_object_add_uint (node, "value", mp->value);
3634 vat_json_print (vam->ofp, node);
3635 vat_json_free (node);
3637 vam->retval = retval;
3638 vam->result_ready = 1;
3642 vl_api_show_one_map_register_state_reply_t_handler
3643 (vl_api_show_one_map_register_state_reply_t * mp)
3645 vat_main_t *vam = &vat_main;
3646 int retval = clib_net_to_host_u32 (mp->retval);
3648 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3650 vam->retval = retval;
3651 vam->result_ready = 1;
3655 vl_api_show_one_map_register_state_reply_t_handler_json
3656 (vl_api_show_one_map_register_state_reply_t * mp)
3658 vat_main_t *vam = &vat_main;
3659 vat_json_node_t _node, *node = &_node;
3660 int retval = clib_net_to_host_u32 (mp->retval);
3662 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3664 vat_json_init_object (node);
3665 vat_json_object_add_string_copy (node, "state", s);
3667 vat_json_print (vam->ofp, node);
3668 vat_json_free (node);
3670 vam->retval = retval;
3671 vam->result_ready = 1;
3676 vl_api_show_one_rloc_probe_state_reply_t_handler
3677 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3679 vat_main_t *vam = &vat_main;
3680 int retval = clib_net_to_host_u32 (mp->retval);
3685 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3687 vam->retval = retval;
3688 vam->result_ready = 1;
3692 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3693 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3695 vat_main_t *vam = &vat_main;
3696 vat_json_node_t _node, *node = &_node;
3697 int retval = clib_net_to_host_u32 (mp->retval);
3699 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3700 vat_json_init_object (node);
3701 vat_json_object_add_string_copy (node, "state", s);
3703 vat_json_print (vam->ofp, node);
3704 vat_json_free (node);
3706 vam->retval = retval;
3707 vam->result_ready = 1;
3712 vl_api_show_one_stats_enable_disable_reply_t_handler
3713 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3715 vat_main_t *vam = &vat_main;
3716 int retval = clib_net_to_host_u32 (mp->retval);
3721 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3723 vam->retval = retval;
3724 vam->result_ready = 1;
3728 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3729 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3731 vat_main_t *vam = &vat_main;
3732 vat_json_node_t _node, *node = &_node;
3733 int retval = clib_net_to_host_u32 (mp->retval);
3735 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3736 vat_json_init_object (node);
3737 vat_json_object_add_string_copy (node, "state", s);
3739 vat_json_print (vam->ofp, node);
3740 vat_json_free (node);
3742 vam->retval = retval;
3743 vam->result_ready = 1;
3748 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3750 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3751 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3752 e->vni = clib_net_to_host_u32 (e->vni);
3756 gpe_fwd_entries_get_reply_t_net_to_host
3757 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3761 mp->count = clib_net_to_host_u32 (mp->count);
3762 for (i = 0; i < mp->count; i++)
3764 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3769 format_gpe_encap_mode (u8 * s, va_list * args)
3771 u32 mode = va_arg (*args, u32);
3776 return format (s, "lisp");
3778 return format (s, "vxlan");
3784 vl_api_gpe_get_encap_mode_reply_t_handler
3785 (vl_api_gpe_get_encap_mode_reply_t * mp)
3787 vat_main_t *vam = &vat_main;
3789 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3790 vam->retval = ntohl (mp->retval);
3791 vam->result_ready = 1;
3795 vl_api_gpe_get_encap_mode_reply_t_handler_json
3796 (vl_api_gpe_get_encap_mode_reply_t * mp)
3798 vat_main_t *vam = &vat_main;
3799 vat_json_node_t node;
3801 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3802 vec_add1 (encap_mode, 0);
3804 vat_json_init_object (&node);
3805 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3807 vec_free (encap_mode);
3808 vat_json_print (vam->ofp, &node);
3809 vat_json_free (&node);
3811 vam->retval = ntohl (mp->retval);
3812 vam->result_ready = 1;
3816 vl_api_gpe_fwd_entry_path_details_t_handler
3817 (vl_api_gpe_fwd_entry_path_details_t * mp)
3819 vat_main_t *vam = &vat_main;
3820 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3822 if (mp->lcl_loc.is_ip4)
3823 format_ip_address_fcn = format_ip4_address;
3825 format_ip_address_fcn = format_ip6_address;
3827 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3828 format_ip_address_fcn, &mp->lcl_loc,
3829 format_ip_address_fcn, &mp->rmt_loc);
3833 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3835 struct in6_addr ip6;
3840 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3841 vat_json_object_add_ip4 (n, "address", ip4);
3845 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3846 vat_json_object_add_ip6 (n, "address", ip6);
3848 vat_json_object_add_uint (n, "weight", loc->weight);
3852 vl_api_gpe_fwd_entry_path_details_t_handler_json
3853 (vl_api_gpe_fwd_entry_path_details_t * mp)
3855 vat_main_t *vam = &vat_main;
3856 vat_json_node_t *node = NULL;
3857 vat_json_node_t *loc_node;
3859 if (VAT_JSON_ARRAY != vam->json_tree.type)
3861 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3862 vat_json_init_array (&vam->json_tree);
3864 node = vat_json_array_add (&vam->json_tree);
3865 vat_json_init_object (node);
3867 loc_node = vat_json_object_add (node, "local_locator");
3868 vat_json_init_object (loc_node);
3869 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3871 loc_node = vat_json_object_add (node, "remote_locator");
3872 vat_json_init_object (loc_node);
3873 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3877 vl_api_gpe_fwd_entries_get_reply_t_handler
3878 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3880 vat_main_t *vam = &vat_main;
3882 int retval = clib_net_to_host_u32 (mp->retval);
3883 vl_api_gpe_fwd_entry_t *e;
3888 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3890 for (i = 0; i < mp->count; i++)
3892 e = &mp->entries[i];
3893 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3894 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3895 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3899 vam->retval = retval;
3900 vam->result_ready = 1;
3904 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3905 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3908 vat_main_t *vam = &vat_main;
3909 vat_json_node_t *e = 0, root;
3911 int retval = clib_net_to_host_u32 (mp->retval);
3912 vl_api_gpe_fwd_entry_t *fwd;
3917 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3918 vat_json_init_array (&root);
3920 for (i = 0; i < mp->count; i++)
3922 e = vat_json_array_add (&root);
3923 fwd = &mp->entries[i];
3925 vat_json_init_object (e);
3926 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3927 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3928 vat_json_object_add_int (e, "vni", fwd->vni);
3929 vat_json_object_add_int (e, "action", fwd->action);
3931 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3932 fwd->leid_prefix_len);
3934 vat_json_object_add_string_copy (e, "leid", s);
3937 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3938 fwd->reid_prefix_len);
3940 vat_json_object_add_string_copy (e, "reid", s);
3944 vat_json_print (vam->ofp, &root);
3945 vat_json_free (&root);
3948 vam->retval = retval;
3949 vam->result_ready = 1;
3953 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3954 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3956 vat_main_t *vam = &vat_main;
3958 int retval = clib_net_to_host_u32 (mp->retval);
3959 vl_api_gpe_native_fwd_rpath_t *r;
3964 n = clib_net_to_host_u32 (mp->count);
3966 for (i = 0; i < n; i++)
3968 r = &mp->entries[i];
3969 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3970 clib_net_to_host_u32 (r->fib_index),
3971 clib_net_to_host_u32 (r->nh_sw_if_index),
3972 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3976 vam->retval = retval;
3977 vam->result_ready = 1;
3981 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3982 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3984 vat_main_t *vam = &vat_main;
3985 vat_json_node_t root, *e;
3987 int retval = clib_net_to_host_u32 (mp->retval);
3988 vl_api_gpe_native_fwd_rpath_t *r;
3994 n = clib_net_to_host_u32 (mp->count);
3995 vat_json_init_array (&root);
3997 for (i = 0; i < n; i++)
3999 e = vat_json_array_add (&root);
4000 vat_json_init_object (e);
4001 r = &mp->entries[i];
4003 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
4006 vat_json_object_add_string_copy (e, "ip4", s);
4009 vat_json_object_add_uint (e, "fib_index",
4010 clib_net_to_host_u32 (r->fib_index));
4011 vat_json_object_add_uint (e, "nh_sw_if_index",
4012 clib_net_to_host_u32 (r->nh_sw_if_index));
4015 vat_json_print (vam->ofp, &root);
4016 vat_json_free (&root);
4019 vam->retval = retval;
4020 vam->result_ready = 1;
4024 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
4025 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
4027 vat_main_t *vam = &vat_main;
4029 int retval = clib_net_to_host_u32 (mp->retval);
4034 n = clib_net_to_host_u32 (mp->count);
4036 for (i = 0; i < n; i++)
4037 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
4040 vam->retval = retval;
4041 vam->result_ready = 1;
4045 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
4046 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
4048 vat_main_t *vam = &vat_main;
4049 vat_json_node_t root;
4051 int retval = clib_net_to_host_u32 (mp->retval);
4056 n = clib_net_to_host_u32 (mp->count);
4057 vat_json_init_array (&root);
4059 for (i = 0; i < n; i++)
4060 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
4062 vat_json_print (vam->ofp, &root);
4063 vat_json_free (&root);
4066 vam->retval = retval;
4067 vam->result_ready = 1;
4071 vl_api_one_ndp_entries_get_reply_t_handler
4072 (vl_api_one_ndp_entries_get_reply_t * mp)
4074 vat_main_t *vam = &vat_main;
4076 int retval = clib_net_to_host_u32 (mp->retval);
4081 n = clib_net_to_host_u32 (mp->count);
4083 for (i = 0; i < n; i++)
4084 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4085 format_ethernet_address, mp->entries[i].mac);
4088 vam->retval = retval;
4089 vam->result_ready = 1;
4093 vl_api_one_ndp_entries_get_reply_t_handler_json
4094 (vl_api_one_ndp_entries_get_reply_t * mp)
4097 vat_main_t *vam = &vat_main;
4098 vat_json_node_t *e = 0, root;
4100 int retval = clib_net_to_host_u32 (mp->retval);
4101 vl_api_one_ndp_entry_t *arp_entry;
4106 n = clib_net_to_host_u32 (mp->count);
4107 vat_json_init_array (&root);
4109 for (i = 0; i < n; i++)
4111 e = vat_json_array_add (&root);
4112 arp_entry = &mp->entries[i];
4114 vat_json_init_object (e);
4115 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4118 vat_json_object_add_string_copy (e, "mac", s);
4121 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4123 vat_json_object_add_string_copy (e, "ip6", s);
4127 vat_json_print (vam->ofp, &root);
4128 vat_json_free (&root);
4131 vam->retval = retval;
4132 vam->result_ready = 1;
4136 vl_api_one_l2_arp_entries_get_reply_t_handler
4137 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4141 int retval = clib_net_to_host_u32 (mp->retval);
4146 n = clib_net_to_host_u32 (mp->count);
4148 for (i = 0; i < n; i++)
4149 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4150 format_ethernet_address, mp->entries[i].mac);
4153 vam->retval = retval;
4154 vam->result_ready = 1;
4158 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4159 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4162 vat_main_t *vam = &vat_main;
4163 vat_json_node_t *e = 0, root;
4165 int retval = clib_net_to_host_u32 (mp->retval);
4166 vl_api_one_l2_arp_entry_t *arp_entry;
4171 n = clib_net_to_host_u32 (mp->count);
4172 vat_json_init_array (&root);
4174 for (i = 0; i < n; i++)
4176 e = vat_json_array_add (&root);
4177 arp_entry = &mp->entries[i];
4179 vat_json_init_object (e);
4180 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4183 vat_json_object_add_string_copy (e, "mac", s);
4186 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4188 vat_json_object_add_string_copy (e, "ip4", s);
4192 vat_json_print (vam->ofp, &root);
4193 vat_json_free (&root);
4196 vam->retval = retval;
4197 vam->result_ready = 1;
4201 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4203 vat_main_t *vam = &vat_main;
4205 int retval = clib_net_to_host_u32 (mp->retval);
4210 n = clib_net_to_host_u32 (mp->count);
4212 for (i = 0; i < n; i++)
4214 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4218 vam->retval = retval;
4219 vam->result_ready = 1;
4223 vl_api_one_ndp_bd_get_reply_t_handler_json
4224 (vl_api_one_ndp_bd_get_reply_t * mp)
4226 vat_main_t *vam = &vat_main;
4227 vat_json_node_t root;
4229 int retval = clib_net_to_host_u32 (mp->retval);
4234 n = clib_net_to_host_u32 (mp->count);
4235 vat_json_init_array (&root);
4237 for (i = 0; i < n; i++)
4239 vat_json_array_add_uint (&root,
4240 clib_net_to_host_u32 (mp->bridge_domains[i]));
4243 vat_json_print (vam->ofp, &root);
4244 vat_json_free (&root);
4247 vam->retval = retval;
4248 vam->result_ready = 1;
4252 vl_api_one_l2_arp_bd_get_reply_t_handler
4253 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4255 vat_main_t *vam = &vat_main;
4257 int retval = clib_net_to_host_u32 (mp->retval);
4262 n = clib_net_to_host_u32 (mp->count);
4264 for (i = 0; i < n; i++)
4266 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4270 vam->retval = retval;
4271 vam->result_ready = 1;
4275 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4276 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4278 vat_main_t *vam = &vat_main;
4279 vat_json_node_t root;
4281 int retval = clib_net_to_host_u32 (mp->retval);
4286 n = clib_net_to_host_u32 (mp->count);
4287 vat_json_init_array (&root);
4289 for (i = 0; i < n; i++)
4291 vat_json_array_add_uint (&root,
4292 clib_net_to_host_u32 (mp->bridge_domains[i]));
4295 vat_json_print (vam->ofp, &root);
4296 vat_json_free (&root);
4299 vam->retval = retval;
4300 vam->result_ready = 1;
4304 vl_api_one_adjacencies_get_reply_t_handler
4305 (vl_api_one_adjacencies_get_reply_t * mp)
4307 vat_main_t *vam = &vat_main;
4309 int retval = clib_net_to_host_u32 (mp->retval);
4310 vl_api_one_adjacency_t *a;
4315 n = clib_net_to_host_u32 (mp->count);
4317 for (i = 0; i < n; i++)
4319 a = &mp->adjacencies[i];
4320 print (vam->ofp, "%U %40U",
4321 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4322 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4326 vam->retval = retval;
4327 vam->result_ready = 1;
4331 vl_api_one_adjacencies_get_reply_t_handler_json
4332 (vl_api_one_adjacencies_get_reply_t * mp)
4335 vat_main_t *vam = &vat_main;
4336 vat_json_node_t *e = 0, root;
4338 int retval = clib_net_to_host_u32 (mp->retval);
4339 vl_api_one_adjacency_t *a;
4344 n = clib_net_to_host_u32 (mp->count);
4345 vat_json_init_array (&root);
4347 for (i = 0; i < n; i++)
4349 e = vat_json_array_add (&root);
4350 a = &mp->adjacencies[i];
4352 vat_json_init_object (e);
4353 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4354 a->leid_prefix_len);
4356 vat_json_object_add_string_copy (e, "leid", s);
4359 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4360 a->reid_prefix_len);
4362 vat_json_object_add_string_copy (e, "reid", s);
4366 vat_json_print (vam->ofp, &root);
4367 vat_json_free (&root);
4370 vam->retval = retval;
4371 vam->result_ready = 1;
4375 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4377 vat_main_t *vam = &vat_main;
4379 print (vam->ofp, "%=20U",
4380 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4385 vl_api_one_map_server_details_t_handler_json
4386 (vl_api_one_map_server_details_t * mp)
4388 vat_main_t *vam = &vat_main;
4389 vat_json_node_t *node = NULL;
4390 struct in6_addr ip6;
4393 if (VAT_JSON_ARRAY != vam->json_tree.type)
4395 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4396 vat_json_init_array (&vam->json_tree);
4398 node = vat_json_array_add (&vam->json_tree);
4400 vat_json_init_object (node);
4403 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4404 vat_json_object_add_ip6 (node, "map-server", ip6);
4408 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4409 vat_json_object_add_ip4 (node, "map-server", ip4);
4414 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4417 vat_main_t *vam = &vat_main;
4419 print (vam->ofp, "%=20U",
4420 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4425 vl_api_one_map_resolver_details_t_handler_json
4426 (vl_api_one_map_resolver_details_t * mp)
4428 vat_main_t *vam = &vat_main;
4429 vat_json_node_t *node = NULL;
4430 struct in6_addr ip6;
4433 if (VAT_JSON_ARRAY != vam->json_tree.type)
4435 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4436 vat_json_init_array (&vam->json_tree);
4438 node = vat_json_array_add (&vam->json_tree);
4440 vat_json_init_object (node);
4443 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4444 vat_json_object_add_ip6 (node, "map resolver", ip6);
4448 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4449 vat_json_object_add_ip4 (node, "map resolver", ip4);
4454 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4456 vat_main_t *vam = &vat_main;
4457 i32 retval = ntohl (mp->retval);
4461 print (vam->ofp, "feature: %s\ngpe: %s",
4462 mp->feature_status ? "enabled" : "disabled",
4463 mp->gpe_status ? "enabled" : "disabled");
4466 vam->retval = retval;
4467 vam->result_ready = 1;
4471 vl_api_show_one_status_reply_t_handler_json
4472 (vl_api_show_one_status_reply_t * mp)
4474 vat_main_t *vam = &vat_main;
4475 vat_json_node_t node;
4476 u8 *gpe_status = NULL;
4477 u8 *feature_status = NULL;
4479 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4480 feature_status = format (0, "%s",
4481 mp->feature_status ? "enabled" : "disabled");
4482 vec_add1 (gpe_status, 0);
4483 vec_add1 (feature_status, 0);
4485 vat_json_init_object (&node);
4486 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4487 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4489 vec_free (gpe_status);
4490 vec_free (feature_status);
4492 vat_json_print (vam->ofp, &node);
4493 vat_json_free (&node);
4495 vam->retval = ntohl (mp->retval);
4496 vam->result_ready = 1;
4500 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4501 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4503 vat_main_t *vam = &vat_main;
4504 i32 retval = ntohl (mp->retval);
4508 print (vam->ofp, "%=20s", mp->locator_set_name);
4511 vam->retval = retval;
4512 vam->result_ready = 1;
4516 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4517 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4519 vat_main_t *vam = &vat_main;
4520 vat_json_node_t *node = NULL;
4522 if (VAT_JSON_ARRAY != vam->json_tree.type)
4524 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4525 vat_json_init_array (&vam->json_tree);
4527 node = vat_json_array_add (&vam->json_tree);
4529 vat_json_init_object (node);
4530 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4532 vat_json_print (vam->ofp, node);
4533 vat_json_free (node);
4535 vam->retval = ntohl (mp->retval);
4536 vam->result_ready = 1;
4540 format_lisp_map_request_mode (u8 * s, va_list * args)
4542 u32 mode = va_arg (*args, u32);
4547 return format (0, "dst-only");
4549 return format (0, "src-dst");
4555 vl_api_show_one_map_request_mode_reply_t_handler
4556 (vl_api_show_one_map_request_mode_reply_t * mp)
4558 vat_main_t *vam = &vat_main;
4559 i32 retval = ntohl (mp->retval);
4563 u32 mode = mp->mode;
4564 print (vam->ofp, "map_request_mode: %U",
4565 format_lisp_map_request_mode, mode);
4568 vam->retval = retval;
4569 vam->result_ready = 1;
4573 vl_api_show_one_map_request_mode_reply_t_handler_json
4574 (vl_api_show_one_map_request_mode_reply_t * mp)
4576 vat_main_t *vam = &vat_main;
4577 vat_json_node_t node;
4582 s = format (0, "%U", format_lisp_map_request_mode, mode);
4585 vat_json_init_object (&node);
4586 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4587 vat_json_print (vam->ofp, &node);
4588 vat_json_free (&node);
4591 vam->retval = ntohl (mp->retval);
4592 vam->result_ready = 1;
4596 vl_api_one_show_xtr_mode_reply_t_handler
4597 (vl_api_one_show_xtr_mode_reply_t * mp)
4599 vat_main_t *vam = &vat_main;
4600 i32 retval = ntohl (mp->retval);
4604 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4607 vam->retval = retval;
4608 vam->result_ready = 1;
4612 vl_api_one_show_xtr_mode_reply_t_handler_json
4613 (vl_api_one_show_xtr_mode_reply_t * mp)
4615 vat_main_t *vam = &vat_main;
4616 vat_json_node_t node;
4619 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4620 vec_add1 (status, 0);
4622 vat_json_init_object (&node);
4623 vat_json_object_add_string_copy (&node, "status", status);
4627 vat_json_print (vam->ofp, &node);
4628 vat_json_free (&node);
4630 vam->retval = ntohl (mp->retval);
4631 vam->result_ready = 1;
4635 vl_api_one_show_pitr_mode_reply_t_handler
4636 (vl_api_one_show_pitr_mode_reply_t * mp)
4638 vat_main_t *vam = &vat_main;
4639 i32 retval = ntohl (mp->retval);
4643 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4646 vam->retval = retval;
4647 vam->result_ready = 1;
4651 vl_api_one_show_pitr_mode_reply_t_handler_json
4652 (vl_api_one_show_pitr_mode_reply_t * mp)
4654 vat_main_t *vam = &vat_main;
4655 vat_json_node_t node;
4658 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4659 vec_add1 (status, 0);
4661 vat_json_init_object (&node);
4662 vat_json_object_add_string_copy (&node, "status", status);
4666 vat_json_print (vam->ofp, &node);
4667 vat_json_free (&node);
4669 vam->retval = ntohl (mp->retval);
4670 vam->result_ready = 1;
4674 vl_api_one_show_petr_mode_reply_t_handler
4675 (vl_api_one_show_petr_mode_reply_t * mp)
4677 vat_main_t *vam = &vat_main;
4678 i32 retval = ntohl (mp->retval);
4682 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4685 vam->retval = retval;
4686 vam->result_ready = 1;
4690 vl_api_one_show_petr_mode_reply_t_handler_json
4691 (vl_api_one_show_petr_mode_reply_t * mp)
4693 vat_main_t *vam = &vat_main;
4694 vat_json_node_t node;
4697 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4698 vec_add1 (status, 0);
4700 vat_json_init_object (&node);
4701 vat_json_object_add_string_copy (&node, "status", status);
4705 vat_json_print (vam->ofp, &node);
4706 vat_json_free (&node);
4708 vam->retval = ntohl (mp->retval);
4709 vam->result_ready = 1;
4713 vl_api_show_one_use_petr_reply_t_handler
4714 (vl_api_show_one_use_petr_reply_t * mp)
4716 vat_main_t *vam = &vat_main;
4717 i32 retval = ntohl (mp->retval);
4721 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4724 print (vam->ofp, "Proxy-ETR address; %U",
4725 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4730 vam->retval = retval;
4731 vam->result_ready = 1;
4735 vl_api_show_one_use_petr_reply_t_handler_json
4736 (vl_api_show_one_use_petr_reply_t * mp)
4738 vat_main_t *vam = &vat_main;
4739 vat_json_node_t node;
4742 struct in6_addr ip6;
4744 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4745 vec_add1 (status, 0);
4747 vat_json_init_object (&node);
4748 vat_json_object_add_string_copy (&node, "status", status);
4753 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4754 vat_json_object_add_ip6 (&node, "address", ip6);
4758 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4759 vat_json_object_add_ip4 (&node, "address", ip4);
4765 vat_json_print (vam->ofp, &node);
4766 vat_json_free (&node);
4768 vam->retval = ntohl (mp->retval);
4769 vam->result_ready = 1;
4773 vl_api_show_one_nsh_mapping_reply_t_handler
4774 (vl_api_show_one_nsh_mapping_reply_t * mp)
4776 vat_main_t *vam = &vat_main;
4777 i32 retval = ntohl (mp->retval);
4781 print (vam->ofp, "%-20s%-16s",
4782 mp->is_set ? "set" : "not-set",
4783 mp->is_set ? (char *) mp->locator_set_name : "");
4786 vam->retval = retval;
4787 vam->result_ready = 1;
4791 vl_api_show_one_nsh_mapping_reply_t_handler_json
4792 (vl_api_show_one_nsh_mapping_reply_t * mp)
4794 vat_main_t *vam = &vat_main;
4795 vat_json_node_t node;
4798 status = format (0, "%s", mp->is_set ? "yes" : "no");
4799 vec_add1 (status, 0);
4801 vat_json_init_object (&node);
4802 vat_json_object_add_string_copy (&node, "is_set", status);
4805 vat_json_object_add_string_copy (&node, "locator_set",
4806 mp->locator_set_name);
4811 vat_json_print (vam->ofp, &node);
4812 vat_json_free (&node);
4814 vam->retval = ntohl (mp->retval);
4815 vam->result_ready = 1;
4819 vl_api_show_one_map_register_ttl_reply_t_handler
4820 (vl_api_show_one_map_register_ttl_reply_t * mp)
4822 vat_main_t *vam = &vat_main;
4823 i32 retval = ntohl (mp->retval);
4825 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4829 print (vam->ofp, "ttl: %u", mp->ttl);
4832 vam->retval = retval;
4833 vam->result_ready = 1;
4837 vl_api_show_one_map_register_ttl_reply_t_handler_json
4838 (vl_api_show_one_map_register_ttl_reply_t * mp)
4840 vat_main_t *vam = &vat_main;
4841 vat_json_node_t node;
4843 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4844 vat_json_init_object (&node);
4845 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4847 vat_json_print (vam->ofp, &node);
4848 vat_json_free (&node);
4850 vam->retval = ntohl (mp->retval);
4851 vam->result_ready = 1;
4855 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4857 vat_main_t *vam = &vat_main;
4858 i32 retval = ntohl (mp->retval);
4862 print (vam->ofp, "%-20s%-16s",
4863 mp->status ? "enabled" : "disabled",
4864 mp->status ? (char *) mp->locator_set_name : "");
4867 vam->retval = retval;
4868 vam->result_ready = 1;
4872 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4874 vat_main_t *vam = &vat_main;
4875 vat_json_node_t node;
4878 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4879 vec_add1 (status, 0);
4881 vat_json_init_object (&node);
4882 vat_json_object_add_string_copy (&node, "status", status);
4885 vat_json_object_add_string_copy (&node, "locator_set",
4886 mp->locator_set_name);
4891 vat_json_print (vam->ofp, &node);
4892 vat_json_free (&node);
4894 vam->retval = ntohl (mp->retval);
4895 vam->result_ready = 1;
4899 format_policer_type (u8 * s, va_list * va)
4901 u32 i = va_arg (*va, u32);
4903 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4904 s = format (s, "1r2c");
4905 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4906 s = format (s, "1r3c");
4907 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4908 s = format (s, "2r3c-2698");
4909 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4910 s = format (s, "2r3c-4115");
4911 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4912 s = format (s, "2r3c-mef5cf1");
4914 s = format (s, "ILLEGAL");
4919 format_policer_rate_type (u8 * s, va_list * va)
4921 u32 i = va_arg (*va, u32);
4923 if (i == SSE2_QOS_RATE_KBPS)
4924 s = format (s, "kbps");
4925 else if (i == SSE2_QOS_RATE_PPS)
4926 s = format (s, "pps");
4928 s = format (s, "ILLEGAL");
4933 format_policer_round_type (u8 * s, va_list * va)
4935 u32 i = va_arg (*va, u32);
4937 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4938 s = format (s, "closest");
4939 else if (i == SSE2_QOS_ROUND_TO_UP)
4940 s = format (s, "up");
4941 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4942 s = format (s, "down");
4944 s = format (s, "ILLEGAL");
4949 format_policer_action_type (u8 * s, va_list * va)
4951 u32 i = va_arg (*va, u32);
4953 if (i == SSE2_QOS_ACTION_DROP)
4954 s = format (s, "drop");
4955 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4956 s = format (s, "transmit");
4957 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4958 s = format (s, "mark-and-transmit");
4960 s = format (s, "ILLEGAL");
4965 format_dscp (u8 * s, va_list * va)
4967 u32 i = va_arg (*va, u32);
4972 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4976 return format (s, "ILLEGAL");
4978 s = format (s, "%s", t);
4983 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4985 vat_main_t *vam = &vat_main;
4986 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4988 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4989 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4991 conform_dscp_str = format (0, "");
4993 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4994 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4996 exceed_dscp_str = format (0, "");
4998 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4999 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5001 violate_dscp_str = format (0, "");
5003 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
5004 "rate type %U, round type %U, %s rate, %s color-aware, "
5005 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
5006 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
5007 "conform action %U%s, exceed action %U%s, violate action %U%s",
5009 format_policer_type, mp->type,
5012 clib_net_to_host_u64 (mp->cb),
5013 clib_net_to_host_u64 (mp->eb),
5014 format_policer_rate_type, mp->rate_type,
5015 format_policer_round_type, mp->round_type,
5016 mp->single_rate ? "single" : "dual",
5017 mp->color_aware ? "is" : "not",
5018 ntohl (mp->cir_tokens_per_period),
5019 ntohl (mp->pir_tokens_per_period),
5021 ntohl (mp->current_limit),
5022 ntohl (mp->current_bucket),
5023 ntohl (mp->extended_limit),
5024 ntohl (mp->extended_bucket),
5025 clib_net_to_host_u64 (mp->last_update_time),
5026 format_policer_action_type, mp->conform_action_type,
5028 format_policer_action_type, mp->exceed_action_type,
5030 format_policer_action_type, mp->violate_action_type,
5033 vec_free (conform_dscp_str);
5034 vec_free (exceed_dscp_str);
5035 vec_free (violate_dscp_str);
5038 static void vl_api_policer_details_t_handler_json
5039 (vl_api_policer_details_t * mp)
5041 vat_main_t *vam = &vat_main;
5042 vat_json_node_t *node;
5043 u8 *rate_type_str, *round_type_str, *type_str;
5044 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
5046 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
5048 format (0, "%U", format_policer_round_type, mp->round_type);
5049 type_str = format (0, "%U", format_policer_type, mp->type);
5050 conform_action_str = format (0, "%U", format_policer_action_type,
5051 mp->conform_action_type);
5052 exceed_action_str = format (0, "%U", format_policer_action_type,
5053 mp->exceed_action_type);
5054 violate_action_str = format (0, "%U", format_policer_action_type,
5055 mp->violate_action_type);
5057 if (VAT_JSON_ARRAY != vam->json_tree.type)
5059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5060 vat_json_init_array (&vam->json_tree);
5062 node = vat_json_array_add (&vam->json_tree);
5064 vat_json_init_object (node);
5065 vat_json_object_add_string_copy (node, "name", mp->name);
5066 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
5067 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
5068 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
5069 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
5070 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
5071 vat_json_object_add_string_copy (node, "round_type", round_type_str);
5072 vat_json_object_add_string_copy (node, "type", type_str);
5073 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
5074 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5075 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5076 vat_json_object_add_uint (node, "cir_tokens_per_period",
5077 ntohl (mp->cir_tokens_per_period));
5078 vat_json_object_add_uint (node, "eir_tokens_per_period",
5079 ntohl (mp->pir_tokens_per_period));
5080 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5081 vat_json_object_add_uint (node, "current_bucket",
5082 ntohl (mp->current_bucket));
5083 vat_json_object_add_uint (node, "extended_limit",
5084 ntohl (mp->extended_limit));
5085 vat_json_object_add_uint (node, "extended_bucket",
5086 ntohl (mp->extended_bucket));
5087 vat_json_object_add_uint (node, "last_update_time",
5088 ntohl (mp->last_update_time));
5089 vat_json_object_add_string_copy (node, "conform_action",
5090 conform_action_str);
5091 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5093 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5094 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5095 vec_free (dscp_str);
5097 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5098 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5100 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5101 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5102 vec_free (dscp_str);
5104 vat_json_object_add_string_copy (node, "violate_action",
5105 violate_action_str);
5106 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5108 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5109 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5110 vec_free (dscp_str);
5113 vec_free (rate_type_str);
5114 vec_free (round_type_str);
5115 vec_free (type_str);
5116 vec_free (conform_action_str);
5117 vec_free (exceed_action_str);
5118 vec_free (violate_action_str);
5122 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5125 vat_main_t *vam = &vat_main;
5126 int i, count = ntohl (mp->count);
5129 print (vam->ofp, "classify table ids (%d) : ", count);
5130 for (i = 0; i < count; i++)
5132 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5133 print (vam->ofp, (i < count - 1) ? "," : "");
5135 vam->retval = ntohl (mp->retval);
5136 vam->result_ready = 1;
5140 vl_api_classify_table_ids_reply_t_handler_json
5141 (vl_api_classify_table_ids_reply_t * mp)
5143 vat_main_t *vam = &vat_main;
5144 int i, count = ntohl (mp->count);
5148 vat_json_node_t node;
5150 vat_json_init_object (&node);
5151 for (i = 0; i < count; i++)
5153 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5155 vat_json_print (vam->ofp, &node);
5156 vat_json_free (&node);
5158 vam->retval = ntohl (mp->retval);
5159 vam->result_ready = 1;
5163 vl_api_classify_table_by_interface_reply_t_handler
5164 (vl_api_classify_table_by_interface_reply_t * mp)
5166 vat_main_t *vam = &vat_main;
5169 table_id = ntohl (mp->l2_table_id);
5171 print (vam->ofp, "l2 table id : %d", table_id);
5173 print (vam->ofp, "l2 table id : No input ACL tables configured");
5174 table_id = ntohl (mp->ip4_table_id);
5176 print (vam->ofp, "ip4 table id : %d", table_id);
5178 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5179 table_id = ntohl (mp->ip6_table_id);
5181 print (vam->ofp, "ip6 table id : %d", table_id);
5183 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5184 vam->retval = ntohl (mp->retval);
5185 vam->result_ready = 1;
5189 vl_api_classify_table_by_interface_reply_t_handler_json
5190 (vl_api_classify_table_by_interface_reply_t * mp)
5192 vat_main_t *vam = &vat_main;
5193 vat_json_node_t node;
5195 vat_json_init_object (&node);
5197 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5198 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5199 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5201 vat_json_print (vam->ofp, &node);
5202 vat_json_free (&node);
5204 vam->retval = ntohl (mp->retval);
5205 vam->result_ready = 1;
5208 static void vl_api_policer_add_del_reply_t_handler
5209 (vl_api_policer_add_del_reply_t * mp)
5211 vat_main_t *vam = &vat_main;
5212 i32 retval = ntohl (mp->retval);
5213 if (vam->async_mode)
5215 vam->async_errors += (retval < 0);
5219 vam->retval = retval;
5220 vam->result_ready = 1;
5221 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5223 * Note: this is just barely thread-safe, depends on
5224 * the main thread spinning waiting for an answer...
5226 errmsg ("policer index %d", ntohl (mp->policer_index));
5230 static void vl_api_policer_add_del_reply_t_handler_json
5231 (vl_api_policer_add_del_reply_t * mp)
5233 vat_main_t *vam = &vat_main;
5234 vat_json_node_t node;
5236 vat_json_init_object (&node);
5237 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5238 vat_json_object_add_uint (&node, "policer_index",
5239 ntohl (mp->policer_index));
5241 vat_json_print (vam->ofp, &node);
5242 vat_json_free (&node);
5244 vam->retval = ntohl (mp->retval);
5245 vam->result_ready = 1;
5248 /* Format hex dump. */
5250 format_hex_bytes (u8 * s, va_list * va)
5252 u8 *bytes = va_arg (*va, u8 *);
5253 int n_bytes = va_arg (*va, int);
5256 /* Print short or long form depending on byte count. */
5257 uword short_form = n_bytes <= 32;
5258 u32 indent = format_get_indent (s);
5263 for (i = 0; i < n_bytes; i++)
5265 if (!short_form && (i % 32) == 0)
5266 s = format (s, "%08x: ", i);
5267 s = format (s, "%02x", bytes[i]);
5268 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5269 s = format (s, "\n%U", format_white_space, indent);
5276 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5279 vat_main_t *vam = &vat_main;
5280 i32 retval = ntohl (mp->retval);
5283 print (vam->ofp, "classify table info :");
5284 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5285 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5286 ntohl (mp->miss_next_index));
5287 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5288 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5289 ntohl (mp->match_n_vectors));
5290 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5291 ntohl (mp->mask_length));
5293 vam->retval = retval;
5294 vam->result_ready = 1;
5298 vl_api_classify_table_info_reply_t_handler_json
5299 (vl_api_classify_table_info_reply_t * mp)
5301 vat_main_t *vam = &vat_main;
5302 vat_json_node_t node;
5304 i32 retval = ntohl (mp->retval);
5307 vat_json_init_object (&node);
5309 vat_json_object_add_int (&node, "sessions",
5310 ntohl (mp->active_sessions));
5311 vat_json_object_add_int (&node, "nexttbl",
5312 ntohl (mp->next_table_index));
5313 vat_json_object_add_int (&node, "nextnode",
5314 ntohl (mp->miss_next_index));
5315 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5316 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5317 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5318 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5319 ntohl (mp->mask_length), 0);
5320 vat_json_object_add_string_copy (&node, "mask", s);
5322 vat_json_print (vam->ofp, &node);
5323 vat_json_free (&node);
5325 vam->retval = ntohl (mp->retval);
5326 vam->result_ready = 1;
5330 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5333 vat_main_t *vam = &vat_main;
5335 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5336 ntohl (mp->hit_next_index), ntohl (mp->advance),
5337 ntohl (mp->opaque_index));
5338 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5339 ntohl (mp->match_length));
5343 vl_api_classify_session_details_t_handler_json
5344 (vl_api_classify_session_details_t * mp)
5346 vat_main_t *vam = &vat_main;
5347 vat_json_node_t *node = NULL;
5349 if (VAT_JSON_ARRAY != vam->json_tree.type)
5351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5352 vat_json_init_array (&vam->json_tree);
5354 node = vat_json_array_add (&vam->json_tree);
5356 vat_json_init_object (node);
5357 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5358 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5359 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5361 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5363 vat_json_object_add_string_copy (node, "match", s);
5366 static void vl_api_pg_create_interface_reply_t_handler
5367 (vl_api_pg_create_interface_reply_t * mp)
5369 vat_main_t *vam = &vat_main;
5371 vam->retval = ntohl (mp->retval);
5372 vam->result_ready = 1;
5375 static void vl_api_pg_create_interface_reply_t_handler_json
5376 (vl_api_pg_create_interface_reply_t * mp)
5378 vat_main_t *vam = &vat_main;
5379 vat_json_node_t node;
5381 i32 retval = ntohl (mp->retval);
5384 vat_json_init_object (&node);
5386 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5388 vat_json_print (vam->ofp, &node);
5389 vat_json_free (&node);
5391 vam->retval = ntohl (mp->retval);
5392 vam->result_ready = 1;
5395 static void vl_api_policer_classify_details_t_handler
5396 (vl_api_policer_classify_details_t * mp)
5398 vat_main_t *vam = &vat_main;
5400 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5401 ntohl (mp->table_index));
5404 static void vl_api_policer_classify_details_t_handler_json
5405 (vl_api_policer_classify_details_t * mp)
5407 vat_main_t *vam = &vat_main;
5408 vat_json_node_t *node;
5410 if (VAT_JSON_ARRAY != vam->json_tree.type)
5412 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5413 vat_json_init_array (&vam->json_tree);
5415 node = vat_json_array_add (&vam->json_tree);
5417 vat_json_init_object (node);
5418 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5419 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5422 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5423 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5425 vat_main_t *vam = &vat_main;
5426 i32 retval = ntohl (mp->retval);
5427 if (vam->async_mode)
5429 vam->async_errors += (retval < 0);
5433 vam->retval = retval;
5434 vam->sw_if_index = ntohl (mp->sw_if_index);
5435 vam->result_ready = 1;
5437 vam->regenerate_interface_table = 1;
5440 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5441 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5443 vat_main_t *vam = &vat_main;
5444 vat_json_node_t node;
5446 vat_json_init_object (&node);
5447 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5448 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5450 vat_json_print (vam->ofp, &node);
5451 vat_json_free (&node);
5453 vam->retval = ntohl (mp->retval);
5454 vam->result_ready = 1;
5457 static void vl_api_flow_classify_details_t_handler
5458 (vl_api_flow_classify_details_t * mp)
5460 vat_main_t *vam = &vat_main;
5462 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5463 ntohl (mp->table_index));
5466 static void vl_api_flow_classify_details_t_handler_json
5467 (vl_api_flow_classify_details_t * mp)
5469 vat_main_t *vam = &vat_main;
5470 vat_json_node_t *node;
5472 if (VAT_JSON_ARRAY != vam->json_tree.type)
5474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5475 vat_json_init_array (&vam->json_tree);
5477 node = vat_json_array_add (&vam->json_tree);
5479 vat_json_init_object (node);
5480 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5481 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5484 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5485 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5486 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5487 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5488 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5489 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5490 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5491 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5492 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5493 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5494 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5495 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5496 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5497 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5498 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5499 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5500 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5501 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5502 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5503 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5504 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5505 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5508 * Generate boilerplate reply handlers, which
5509 * dig the return value out of the xxx_reply_t API message,
5510 * stick it into vam->retval, and set vam->result_ready
5512 * Could also do this by pointing N message decode slots at
5513 * a single function, but that could break in subtle ways.
5516 #define foreach_standard_reply_retval_handler \
5517 _(sw_interface_set_flags_reply) \
5518 _(sw_interface_add_del_address_reply) \
5519 _(sw_interface_set_rx_mode_reply) \
5520 _(sw_interface_set_table_reply) \
5521 _(sw_interface_set_mpls_enable_reply) \
5522 _(sw_interface_set_vpath_reply) \
5523 _(sw_interface_set_vxlan_bypass_reply) \
5524 _(sw_interface_set_geneve_bypass_reply) \
5525 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5526 _(sw_interface_set_l2_bridge_reply) \
5527 _(bridge_domain_add_del_reply) \
5528 _(sw_interface_set_l2_xconnect_reply) \
5529 _(l2fib_add_del_reply) \
5530 _(l2fib_flush_int_reply) \
5531 _(l2fib_flush_bd_reply) \
5532 _(ip_add_del_route_reply) \
5533 _(ip_table_add_del_reply) \
5534 _(ip_mroute_add_del_reply) \
5535 _(mpls_route_add_del_reply) \
5536 _(mpls_table_add_del_reply) \
5537 _(mpls_ip_bind_unbind_reply) \
5538 _(bier_route_add_del_reply) \
5539 _(bier_table_add_del_reply) \
5540 _(proxy_arp_add_del_reply) \
5541 _(proxy_arp_intfc_enable_disable_reply) \
5542 _(sw_interface_set_unnumbered_reply) \
5543 _(ip_neighbor_add_del_reply) \
5544 _(oam_add_del_reply) \
5545 _(reset_fib_reply) \
5546 _(dhcp_proxy_config_reply) \
5547 _(dhcp_proxy_set_vss_reply) \
5548 _(dhcp_client_config_reply) \
5549 _(set_ip_flow_hash_reply) \
5550 _(sw_interface_ip6_enable_disable_reply) \
5551 _(sw_interface_ip6_set_link_local_address_reply) \
5552 _(ip6nd_proxy_add_del_reply) \
5553 _(sw_interface_ip6nd_ra_prefix_reply) \
5554 _(sw_interface_ip6nd_ra_config_reply) \
5555 _(set_arp_neighbor_limit_reply) \
5556 _(l2_patch_add_del_reply) \
5557 _(sr_policy_add_reply) \
5558 _(sr_policy_mod_reply) \
5559 _(sr_policy_del_reply) \
5560 _(sr_localsid_add_del_reply) \
5561 _(sr_steering_add_del_reply) \
5562 _(classify_add_del_session_reply) \
5563 _(classify_set_interface_ip_table_reply) \
5564 _(classify_set_interface_l2_tables_reply) \
5565 _(l2tpv3_set_tunnel_cookies_reply) \
5566 _(l2tpv3_interface_enable_disable_reply) \
5567 _(l2tpv3_set_lookup_key_reply) \
5568 _(l2_fib_clear_table_reply) \
5569 _(l2_interface_efp_filter_reply) \
5570 _(l2_interface_vlan_tag_rewrite_reply) \
5571 _(modify_vhost_user_if_reply) \
5572 _(delete_vhost_user_if_reply) \
5573 _(ip_probe_neighbor_reply) \
5574 _(want_ip4_arp_events_reply) \
5575 _(want_ip6_nd_events_reply) \
5576 _(want_l2_macs_events_reply) \
5577 _(input_acl_set_interface_reply) \
5578 _(ipsec_spd_add_del_reply) \
5579 _(ipsec_interface_add_del_spd_reply) \
5580 _(ipsec_spd_add_del_entry_reply) \
5581 _(ipsec_sad_add_del_entry_reply) \
5582 _(ipsec_sa_set_key_reply) \
5583 _(ipsec_tunnel_if_add_del_reply) \
5584 _(ipsec_tunnel_if_set_key_reply) \
5585 _(ipsec_tunnel_if_set_sa_reply) \
5586 _(ikev2_profile_add_del_reply) \
5587 _(ikev2_profile_set_auth_reply) \
5588 _(ikev2_profile_set_id_reply) \
5589 _(ikev2_profile_set_ts_reply) \
5590 _(ikev2_set_local_key_reply) \
5591 _(ikev2_set_responder_reply) \
5592 _(ikev2_set_ike_transforms_reply) \
5593 _(ikev2_set_esp_transforms_reply) \
5594 _(ikev2_set_sa_lifetime_reply) \
5595 _(ikev2_initiate_sa_init_reply) \
5596 _(ikev2_initiate_del_ike_sa_reply) \
5597 _(ikev2_initiate_del_child_sa_reply) \
5598 _(ikev2_initiate_rekey_child_sa_reply) \
5599 _(delete_loopback_reply) \
5600 _(bd_ip_mac_add_del_reply) \
5601 _(map_del_domain_reply) \
5602 _(map_add_del_rule_reply) \
5603 _(want_interface_events_reply) \
5604 _(want_stats_reply) \
5605 _(cop_interface_enable_disable_reply) \
5606 _(cop_whitelist_enable_disable_reply) \
5607 _(sw_interface_clear_stats_reply) \
5608 _(ioam_enable_reply) \
5609 _(ioam_disable_reply) \
5610 _(one_add_del_locator_reply) \
5611 _(one_add_del_local_eid_reply) \
5612 _(one_add_del_remote_mapping_reply) \
5613 _(one_add_del_adjacency_reply) \
5614 _(one_add_del_map_resolver_reply) \
5615 _(one_add_del_map_server_reply) \
5616 _(one_enable_disable_reply) \
5617 _(one_rloc_probe_enable_disable_reply) \
5618 _(one_map_register_enable_disable_reply) \
5619 _(one_map_register_set_ttl_reply) \
5620 _(one_set_transport_protocol_reply) \
5621 _(one_map_register_fallback_threshold_reply) \
5622 _(one_pitr_set_locator_set_reply) \
5623 _(one_map_request_mode_reply) \
5624 _(one_add_del_map_request_itr_rlocs_reply) \
5625 _(one_eid_table_add_del_map_reply) \
5626 _(one_use_petr_reply) \
5627 _(one_stats_enable_disable_reply) \
5628 _(one_add_del_l2_arp_entry_reply) \
5629 _(one_add_del_ndp_entry_reply) \
5630 _(one_stats_flush_reply) \
5631 _(one_enable_disable_xtr_mode_reply) \
5632 _(one_enable_disable_pitr_mode_reply) \
5633 _(one_enable_disable_petr_mode_reply) \
5634 _(gpe_enable_disable_reply) \
5635 _(gpe_set_encap_mode_reply) \
5636 _(gpe_add_del_iface_reply) \
5637 _(gpe_add_del_native_fwd_rpath_reply) \
5638 _(af_packet_delete_reply) \
5639 _(policer_classify_set_interface_reply) \
5640 _(netmap_create_reply) \
5641 _(netmap_delete_reply) \
5642 _(set_ipfix_exporter_reply) \
5643 _(set_ipfix_classify_stream_reply) \
5644 _(ipfix_classify_table_add_del_reply) \
5645 _(flow_classify_set_interface_reply) \
5646 _(sw_interface_span_enable_disable_reply) \
5647 _(pg_capture_reply) \
5648 _(pg_enable_disable_reply) \
5649 _(ip_source_and_port_range_check_add_del_reply) \
5650 _(ip_source_and_port_range_check_interface_add_del_reply)\
5651 _(delete_subif_reply) \
5652 _(l2_interface_pbb_tag_rewrite_reply) \
5654 _(feature_enable_disable_reply) \
5655 _(sw_interface_tag_add_del_reply) \
5656 _(sw_interface_set_mtu_reply) \
5657 _(p2p_ethernet_add_reply) \
5658 _(p2p_ethernet_del_reply) \
5659 _(lldp_config_reply) \
5660 _(sw_interface_set_lldp_reply) \
5661 _(tcp_configure_src_addresses_reply) \
5662 _(dns_enable_disable_reply) \
5663 _(dns_name_server_add_del_reply) \
5664 _(session_rule_add_del_reply) \
5665 _(ip_container_proxy_add_del_reply) \
5666 _(output_acl_set_interface_reply) \
5667 _(qos_record_enable_disable_reply)
5670 static void vl_api_##n##_t_handler \
5671 (vl_api_##n##_t * mp) \
5673 vat_main_t * vam = &vat_main; \
5674 i32 retval = ntohl(mp->retval); \
5675 if (vam->async_mode) { \
5676 vam->async_errors += (retval < 0); \
5678 vam->retval = retval; \
5679 vam->result_ready = 1; \
5682 foreach_standard_reply_retval_handler;
5686 static void vl_api_##n##_t_handler_json \
5687 (vl_api_##n##_t * mp) \
5689 vat_main_t * vam = &vat_main; \
5690 vat_json_node_t node; \
5691 vat_json_init_object(&node); \
5692 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5693 vat_json_print(vam->ofp, &node); \
5694 vam->retval = ntohl(mp->retval); \
5695 vam->result_ready = 1; \
5697 foreach_standard_reply_retval_handler;
5701 * Table of message reply handlers, must include boilerplate handlers
5705 #define foreach_vpe_api_reply_msg \
5706 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5707 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5708 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5709 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5710 _(CONTROL_PING_REPLY, control_ping_reply) \
5711 _(CLI_REPLY, cli_reply) \
5712 _(CLI_INBAND_REPLY, cli_inband_reply) \
5713 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5714 sw_interface_add_del_address_reply) \
5715 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5716 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5717 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5718 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5719 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5720 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5721 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5722 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5723 sw_interface_set_l2_xconnect_reply) \
5724 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5725 sw_interface_set_l2_bridge_reply) \
5726 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5727 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5728 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5729 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5730 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5731 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5732 _(L2_FLAGS_REPLY, l2_flags_reply) \
5733 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5734 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5735 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5736 _(TAP_DELETE_REPLY, tap_delete_reply) \
5737 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5738 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5739 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5740 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5741 _(BOND_CREATE_REPLY, bond_create_reply) \
5742 _(BOND_DELETE_REPLY, bond_delete_reply) \
5743 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5744 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5745 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5746 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5747 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5748 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5749 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5750 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5751 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5752 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5753 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5754 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5755 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5756 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5757 proxy_arp_intfc_enable_disable_reply) \
5758 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5759 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5760 sw_interface_set_unnumbered_reply) \
5761 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5762 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5763 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5764 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5765 _(RESET_FIB_REPLY, reset_fib_reply) \
5766 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5767 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5768 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5769 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5770 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5771 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5772 sw_interface_ip6_enable_disable_reply) \
5773 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5774 sw_interface_ip6_set_link_local_address_reply) \
5775 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5776 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5777 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5778 sw_interface_ip6nd_ra_prefix_reply) \
5779 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5780 sw_interface_ip6nd_ra_config_reply) \
5781 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5782 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5783 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5784 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5785 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5786 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5787 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5788 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5789 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5790 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5791 classify_set_interface_ip_table_reply) \
5792 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5793 classify_set_interface_l2_tables_reply) \
5794 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5795 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5796 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5797 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5798 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5799 l2tpv3_interface_enable_disable_reply) \
5800 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5801 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5802 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5803 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5804 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5805 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5806 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5807 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5808 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5809 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5810 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5811 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5812 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5813 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5814 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5815 _(SHOW_VERSION_REPLY, show_version_reply) \
5816 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5817 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5818 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5819 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5820 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5821 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5822 _(IP4_ARP_EVENT, ip4_arp_event) \
5823 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5824 _(IP6_ND_EVENT, ip6_nd_event) \
5825 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5826 _(L2_MACS_EVENT, l2_macs_event) \
5827 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5828 _(IP_ADDRESS_DETAILS, ip_address_details) \
5829 _(IP_DETAILS, ip_details) \
5830 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5831 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5832 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5833 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5834 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5835 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5836 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5837 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5838 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5839 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5840 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5841 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5842 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5843 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5844 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5845 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5846 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5847 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5848 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5849 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5850 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5851 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5852 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5853 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5854 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5855 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5856 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5857 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5858 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5859 _(MAP_RULE_DETAILS, map_rule_details) \
5860 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5861 _(WANT_STATS_REPLY, want_stats_reply) \
5862 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5863 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5864 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5865 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5866 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5867 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5868 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5869 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5870 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5871 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5872 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5873 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5874 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5875 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5876 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5877 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5878 one_map_register_enable_disable_reply) \
5879 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5880 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5881 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5882 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5883 one_map_register_fallback_threshold_reply) \
5884 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5885 one_rloc_probe_enable_disable_reply) \
5886 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5887 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5888 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5889 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5890 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5891 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5892 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5893 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5894 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5895 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5896 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5897 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5898 _(ONE_STATS_DETAILS, one_stats_details) \
5899 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5900 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5901 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5902 show_one_stats_enable_disable_reply) \
5903 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5904 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5905 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5906 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5907 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5908 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5909 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5910 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5911 one_enable_disable_pitr_mode_reply) \
5912 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5913 one_enable_disable_petr_mode_reply) \
5914 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5915 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5916 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5917 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5918 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5919 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5920 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5921 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5922 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5923 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5924 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5925 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5926 gpe_add_del_native_fwd_rpath_reply) \
5927 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5928 gpe_fwd_entry_path_details) \
5929 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5930 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5931 one_add_del_map_request_itr_rlocs_reply) \
5932 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5933 one_get_map_request_itr_rlocs_reply) \
5934 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5935 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5936 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5937 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5938 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5939 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5940 show_one_map_register_state_reply) \
5941 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5942 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5943 show_one_map_register_fallback_threshold_reply) \
5944 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5945 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5946 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5947 _(POLICER_DETAILS, policer_details) \
5948 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5949 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5950 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5951 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5952 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5953 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5954 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5955 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5956 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5957 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5958 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5959 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5960 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5961 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5962 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5963 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5964 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5965 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5966 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5967 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5968 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5969 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5970 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5971 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5972 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5973 ip_source_and_port_range_check_add_del_reply) \
5974 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5975 ip_source_and_port_range_check_interface_add_del_reply) \
5976 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5977 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5978 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5979 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5980 _(PUNT_REPLY, punt_reply) \
5981 _(IP_FIB_DETAILS, ip_fib_details) \
5982 _(IP6_FIB_DETAILS, ip6_fib_details) \
5983 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5984 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5985 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5986 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5987 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5988 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5989 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5990 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5991 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5992 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5993 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5994 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5995 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5996 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5997 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5998 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5999 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
6000 _(SESSION_RULES_DETAILS, session_rules_details) \
6001 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
6002 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
6003 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
6005 #define foreach_standalone_reply_msg \
6006 _(SW_INTERFACE_EVENT, sw_interface_event) \
6007 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
6008 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
6009 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
6010 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
6011 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
6012 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
6013 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
6022 #define STR_VTR_OP_CASE(op) \
6023 case L2_VTR_ ## op: \
6027 str_vtr_op (u32 vtr_op)
6031 STR_VTR_OP_CASE (DISABLED);
6032 STR_VTR_OP_CASE (PUSH_1);
6033 STR_VTR_OP_CASE (PUSH_2);
6034 STR_VTR_OP_CASE (POP_1);
6035 STR_VTR_OP_CASE (POP_2);
6036 STR_VTR_OP_CASE (TRANSLATE_1_1);
6037 STR_VTR_OP_CASE (TRANSLATE_1_2);
6038 STR_VTR_OP_CASE (TRANSLATE_2_1);
6039 STR_VTR_OP_CASE (TRANSLATE_2_2);
6046 dump_sub_interface_table (vat_main_t * vam)
6048 const sw_interface_subif_t *sub = NULL;
6050 if (vam->json_output)
6053 ("JSON output supported only for VPE API calls and dump_stats_table");
6058 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
6059 "Interface", "sw_if_index",
6060 "sub id", "dot1ad", "tags", "outer id",
6061 "inner id", "exact", "default", "outer any", "inner any");
6063 vec_foreach (sub, vam->sw_if_subif_table)
6066 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
6067 sub->interface_name,
6069 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
6070 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
6071 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
6072 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
6073 if (sub->vtr_op != L2_VTR_DISABLED)
6076 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6077 "tag1: %d tag2: %d ]",
6078 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6079 sub->vtr_tag1, sub->vtr_tag2);
6087 name_sort_cmp (void *a1, void *a2)
6089 name_sort_t *n1 = a1;
6090 name_sort_t *n2 = a2;
6092 return strcmp ((char *) n1->name, (char *) n2->name);
6096 dump_interface_table (vat_main_t * vam)
6099 name_sort_t *nses = 0, *ns;
6101 if (vam->json_output)
6104 ("JSON output supported only for VPE API calls and dump_stats_table");
6109 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6111 vec_add2 (nses, ns, 1);
6112 ns->name = (u8 *)(p->key);
6113 ns->value = (u32) p->value[0];
6117 vec_sort_with_function (nses, name_sort_cmp);
6119 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6120 vec_foreach (ns, nses)
6122 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6129 dump_ip_table (vat_main_t * vam, int is_ipv6)
6131 const ip_details_t *det = NULL;
6132 const ip_address_details_t *address = NULL;
6135 print (vam->ofp, "%-12s", "sw_if_index");
6137 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6144 print (vam->ofp, "%-12d", i);
6145 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6150 vec_foreach (address, det->addr)
6154 is_ipv6 ? format_ip6_address : format_ip4_address,
6155 address->ip, address->prefix_length);
6163 dump_ipv4_table (vat_main_t * vam)
6165 if (vam->json_output)
6168 ("JSON output supported only for VPE API calls and dump_stats_table");
6172 return dump_ip_table (vam, 0);
6176 dump_ipv6_table (vat_main_t * vam)
6178 if (vam->json_output)
6181 ("JSON output supported only for VPE API calls and dump_stats_table");
6185 return dump_ip_table (vam, 1);
6189 counter_type_to_str (u8 counter_type, u8 is_combined)
6193 switch (counter_type)
6195 case VNET_INTERFACE_COUNTER_DROP:
6197 case VNET_INTERFACE_COUNTER_PUNT:
6199 case VNET_INTERFACE_COUNTER_IP4:
6201 case VNET_INTERFACE_COUNTER_IP6:
6203 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6205 case VNET_INTERFACE_COUNTER_RX_MISS:
6207 case VNET_INTERFACE_COUNTER_RX_ERROR:
6209 case VNET_INTERFACE_COUNTER_TX_ERROR:
6212 return "INVALID-COUNTER-TYPE";
6217 switch (counter_type)
6219 case VNET_INTERFACE_COUNTER_RX:
6221 case VNET_INTERFACE_COUNTER_TX:
6224 return "INVALID-COUNTER-TYPE";
6230 dump_stats_table (vat_main_t * vam)
6232 vat_json_node_t node;
6233 vat_json_node_t *msg_array;
6234 vat_json_node_t *msg;
6235 vat_json_node_t *counter_array;
6236 vat_json_node_t *counter;
6237 interface_counter_t c;
6239 ip4_fib_counter_t *c4;
6240 ip6_fib_counter_t *c6;
6241 ip4_nbr_counter_t *n4;
6242 ip6_nbr_counter_t *n6;
6245 if (!vam->json_output)
6247 clib_warning ("dump_stats_table supported only in JSON format");
6251 vat_json_init_object (&node);
6253 /* interface counters */
6254 msg_array = vat_json_object_add (&node, "interface_counters");
6255 vat_json_init_array (msg_array);
6256 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6258 msg = vat_json_array_add (msg_array);
6259 vat_json_init_object (msg);
6260 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6261 (u8 *) counter_type_to_str (i, 0));
6262 vat_json_object_add_int (msg, "is_combined", 0);
6263 counter_array = vat_json_object_add (msg, "data");
6264 vat_json_init_array (counter_array);
6265 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6267 packets = vam->simple_interface_counters[i][j];
6268 vat_json_array_add_uint (counter_array, packets);
6271 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6273 msg = vat_json_array_add (msg_array);
6274 vat_json_init_object (msg);
6275 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6276 (u8 *) counter_type_to_str (i, 1));
6277 vat_json_object_add_int (msg, "is_combined", 1);
6278 counter_array = vat_json_object_add (msg, "data");
6279 vat_json_init_array (counter_array);
6280 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6282 c = vam->combined_interface_counters[i][j];
6283 counter = vat_json_array_add (counter_array);
6284 vat_json_init_object (counter);
6285 vat_json_object_add_uint (counter, "packets", c.packets);
6286 vat_json_object_add_uint (counter, "bytes", c.bytes);
6290 /* ip4 fib counters */
6291 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6292 vat_json_init_array (msg_array);
6293 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6295 msg = vat_json_array_add (msg_array);
6296 vat_json_init_object (msg);
6297 vat_json_object_add_uint (msg, "vrf_id",
6298 vam->ip4_fib_counters_vrf_id_by_index[i]);
6299 counter_array = vat_json_object_add (msg, "c");
6300 vat_json_init_array (counter_array);
6301 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6303 counter = vat_json_array_add (counter_array);
6304 vat_json_init_object (counter);
6305 c4 = &vam->ip4_fib_counters[i][j];
6306 vat_json_object_add_ip4 (counter, "address", c4->address);
6307 vat_json_object_add_uint (counter, "address_length",
6308 c4->address_length);
6309 vat_json_object_add_uint (counter, "packets", c4->packets);
6310 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6314 /* ip6 fib counters */
6315 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6316 vat_json_init_array (msg_array);
6317 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6319 msg = vat_json_array_add (msg_array);
6320 vat_json_init_object (msg);
6321 vat_json_object_add_uint (msg, "vrf_id",
6322 vam->ip6_fib_counters_vrf_id_by_index[i]);
6323 counter_array = vat_json_object_add (msg, "c");
6324 vat_json_init_array (counter_array);
6325 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6327 counter = vat_json_array_add (counter_array);
6328 vat_json_init_object (counter);
6329 c6 = &vam->ip6_fib_counters[i][j];
6330 vat_json_object_add_ip6 (counter, "address", c6->address);
6331 vat_json_object_add_uint (counter, "address_length",
6332 c6->address_length);
6333 vat_json_object_add_uint (counter, "packets", c6->packets);
6334 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6338 /* ip4 nbr counters */
6339 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6340 vat_json_init_array (msg_array);
6341 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6343 msg = vat_json_array_add (msg_array);
6344 vat_json_init_object (msg);
6345 vat_json_object_add_uint (msg, "sw_if_index", i);
6346 counter_array = vat_json_object_add (msg, "c");
6347 vat_json_init_array (counter_array);
6348 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6350 counter = vat_json_array_add (counter_array);
6351 vat_json_init_object (counter);
6352 n4 = &vam->ip4_nbr_counters[i][j];
6353 vat_json_object_add_ip4 (counter, "address", n4->address);
6354 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6355 vat_json_object_add_uint (counter, "packets", n4->packets);
6356 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6360 /* ip6 nbr counters */
6361 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6362 vat_json_init_array (msg_array);
6363 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6365 msg = vat_json_array_add (msg_array);
6366 vat_json_init_object (msg);
6367 vat_json_object_add_uint (msg, "sw_if_index", i);
6368 counter_array = vat_json_object_add (msg, "c");
6369 vat_json_init_array (counter_array);
6370 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6372 counter = vat_json_array_add (counter_array);
6373 vat_json_init_object (counter);
6374 n6 = &vam->ip6_nbr_counters[i][j];
6375 vat_json_object_add_ip6 (counter, "address", n6->address);
6376 vat_json_object_add_uint (counter, "packets", n6->packets);
6377 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6381 vat_json_print (vam->ofp, &node);
6382 vat_json_free (&node);
6388 * Pass CLI buffers directly in the CLI_INBAND API message,
6389 * instead of an additional shared memory area.
6392 exec_inband (vat_main_t * vam)
6394 vl_api_cli_inband_t *mp;
6395 unformat_input_t *i = vam->input;
6398 if (vec_len (i->buffer) == 0)
6401 if (vam->exec_mode == 0 && unformat (i, "mode"))
6406 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6413 * In order for the CLI command to work, it
6414 * must be a vector ending in \n, not a C-string ending
6417 u32 len = vec_len (vam->input->buffer);
6418 M2 (CLI_INBAND, mp, len);
6419 clib_memcpy (mp->cmd, vam->input->buffer, len);
6420 mp->length = htonl (len);
6424 /* json responses may or may not include a useful reply... */
6425 if (vec_len (vam->cmd_reply))
6426 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6431 exec (vat_main_t * vam)
6433 return exec_inband (vam);
6437 api_create_loopback (vat_main_t * vam)
6439 unformat_input_t *i = vam->input;
6440 vl_api_create_loopback_t *mp;
6441 vl_api_create_loopback_instance_t *mp_lbi;
6444 u8 is_specified = 0;
6445 u32 user_instance = 0;
6448 memset (mac_address, 0, sizeof (mac_address));
6450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6452 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6454 if (unformat (i, "instance %d", &user_instance))
6462 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6463 mp_lbi->is_specified = is_specified;
6465 mp_lbi->user_instance = htonl (user_instance);
6467 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6472 /* Construct the API message */
6473 M (CREATE_LOOPBACK, mp);
6475 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6484 api_delete_loopback (vat_main_t * vam)
6486 unformat_input_t *i = vam->input;
6487 vl_api_delete_loopback_t *mp;
6488 u32 sw_if_index = ~0;
6491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6493 if (unformat (i, "sw_if_index %d", &sw_if_index))
6499 if (sw_if_index == ~0)
6501 errmsg ("missing sw_if_index");
6505 /* Construct the API message */
6506 M (DELETE_LOOPBACK, mp);
6507 mp->sw_if_index = ntohl (sw_if_index);
6515 api_want_stats (vat_main_t * vam)
6517 unformat_input_t *i = vam->input;
6518 vl_api_want_stats_t *mp;
6522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6524 if (unformat (i, "enable"))
6526 else if (unformat (i, "disable"))
6534 errmsg ("missing enable|disable");
6539 mp->enable_disable = enable;
6547 api_want_interface_events (vat_main_t * vam)
6549 unformat_input_t *i = vam->input;
6550 vl_api_want_interface_events_t *mp;
6554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6556 if (unformat (i, "enable"))
6558 else if (unformat (i, "disable"))
6566 errmsg ("missing enable|disable");
6570 M (WANT_INTERFACE_EVENTS, mp);
6571 mp->enable_disable = enable;
6573 vam->interface_event_display = enable;
6581 /* Note: non-static, called once to set up the initial intfc table */
6583 api_sw_interface_dump (vat_main_t * vam)
6585 vl_api_sw_interface_dump_t *mp;
6586 vl_api_control_ping_t *mp_ping;
6588 name_sort_t *nses = 0, *ns;
6589 sw_interface_subif_t *sub = NULL;
6592 /* Toss the old name table */
6594 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6596 vec_add2 (nses, ns, 1);
6597 ns->name = (u8 *)(p->key);
6598 ns->value = (u32) p->value[0];
6602 hash_free (vam->sw_if_index_by_interface_name);
6604 vec_foreach (ns, nses) vec_free (ns->name);
6608 vec_foreach (sub, vam->sw_if_subif_table)
6610 vec_free (sub->interface_name);
6612 vec_free (vam->sw_if_subif_table);
6614 /* recreate the interface name hash table */
6615 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6618 * Ask for all interface names. Otherwise, the epic catalog of
6619 * name filters becomes ridiculously long, and vat ends up needing
6620 * to be taught about new interface types.
6622 M (SW_INTERFACE_DUMP, mp);
6625 /* Use a control ping for synchronization */
6626 MPING (CONTROL_PING, mp_ping);
6634 api_sw_interface_set_flags (vat_main_t * vam)
6636 unformat_input_t *i = vam->input;
6637 vl_api_sw_interface_set_flags_t *mp;
6639 u8 sw_if_index_set = 0;
6643 /* Parse args required to build the message */
6644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6646 if (unformat (i, "admin-up"))
6648 else if (unformat (i, "admin-down"))
6651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6652 sw_if_index_set = 1;
6653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6654 sw_if_index_set = 1;
6659 if (sw_if_index_set == 0)
6661 errmsg ("missing interface name or sw_if_index");
6665 /* Construct the API message */
6666 M (SW_INTERFACE_SET_FLAGS, mp);
6667 mp->sw_if_index = ntohl (sw_if_index);
6668 mp->admin_up_down = admin_up;
6673 /* Wait for a reply, return the good/bad news... */
6679 api_sw_interface_set_rx_mode (vat_main_t * vam)
6681 unformat_input_t *i = vam->input;
6682 vl_api_sw_interface_set_rx_mode_t *mp;
6684 u8 sw_if_index_set = 0;
6686 u8 queue_id_valid = 0;
6688 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6690 /* Parse args required to build the message */
6691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6693 if (unformat (i, "queue %d", &queue_id))
6695 else if (unformat (i, "polling"))
6696 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6697 else if (unformat (i, "interrupt"))
6698 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6699 else if (unformat (i, "adaptive"))
6700 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6703 sw_if_index_set = 1;
6704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6705 sw_if_index_set = 1;
6710 if (sw_if_index_set == 0)
6712 errmsg ("missing interface name or sw_if_index");
6715 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6717 errmsg ("missing rx-mode");
6721 /* Construct the API message */
6722 M (SW_INTERFACE_SET_RX_MODE, mp);
6723 mp->sw_if_index = ntohl (sw_if_index);
6725 mp->queue_id_valid = queue_id_valid;
6726 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6731 /* Wait for a reply, return the good/bad news... */
6737 api_sw_interface_clear_stats (vat_main_t * vam)
6739 unformat_input_t *i = vam->input;
6740 vl_api_sw_interface_clear_stats_t *mp;
6742 u8 sw_if_index_set = 0;
6745 /* Parse args required to build the message */
6746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6749 sw_if_index_set = 1;
6750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6751 sw_if_index_set = 1;
6756 /* Construct the API message */
6757 M (SW_INTERFACE_CLEAR_STATS, mp);
6759 if (sw_if_index_set == 1)
6760 mp->sw_if_index = ntohl (sw_if_index);
6762 mp->sw_if_index = ~0;
6767 /* Wait for a reply, return the good/bad news... */
6773 api_sw_interface_add_del_address (vat_main_t * vam)
6775 unformat_input_t *i = vam->input;
6776 vl_api_sw_interface_add_del_address_t *mp;
6778 u8 sw_if_index_set = 0;
6779 u8 is_add = 1, del_all = 0;
6780 u32 address_length = 0;
6781 u8 v4_address_set = 0;
6782 u8 v6_address_set = 0;
6783 ip4_address_t v4address;
6784 ip6_address_t v6address;
6787 /* Parse args required to build the message */
6788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6790 if (unformat (i, "del-all"))
6792 else if (unformat (i, "del"))
6795 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6796 sw_if_index_set = 1;
6797 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6798 sw_if_index_set = 1;
6799 else if (unformat (i, "%U/%d",
6800 unformat_ip4_address, &v4address, &address_length))
6802 else if (unformat (i, "%U/%d",
6803 unformat_ip6_address, &v6address, &address_length))
6809 if (sw_if_index_set == 0)
6811 errmsg ("missing interface name or sw_if_index");
6814 if (v4_address_set && v6_address_set)
6816 errmsg ("both v4 and v6 addresses set");
6819 if (!v4_address_set && !v6_address_set && !del_all)
6821 errmsg ("no addresses set");
6825 /* Construct the API message */
6826 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6828 mp->sw_if_index = ntohl (sw_if_index);
6829 mp->is_add = is_add;
6830 mp->del_all = del_all;
6834 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6838 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6840 mp->address_length = address_length;
6845 /* Wait for a reply, return good/bad news */
6851 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6853 unformat_input_t *i = vam->input;
6854 vl_api_sw_interface_set_mpls_enable_t *mp;
6856 u8 sw_if_index_set = 0;
6860 /* Parse args required to build the message */
6861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6864 sw_if_index_set = 1;
6865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6866 sw_if_index_set = 1;
6867 else if (unformat (i, "disable"))
6869 else if (unformat (i, "dis"))
6875 if (sw_if_index_set == 0)
6877 errmsg ("missing interface name or sw_if_index");
6881 /* Construct the API message */
6882 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6884 mp->sw_if_index = ntohl (sw_if_index);
6885 mp->enable = enable;
6890 /* Wait for a reply... */
6896 api_sw_interface_set_table (vat_main_t * vam)
6898 unformat_input_t *i = vam->input;
6899 vl_api_sw_interface_set_table_t *mp;
6900 u32 sw_if_index, vrf_id = 0;
6901 u8 sw_if_index_set = 0;
6905 /* Parse args required to build the message */
6906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6909 sw_if_index_set = 1;
6910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6911 sw_if_index_set = 1;
6912 else if (unformat (i, "vrf %d", &vrf_id))
6914 else if (unformat (i, "ipv6"))
6920 if (sw_if_index_set == 0)
6922 errmsg ("missing interface name or sw_if_index");
6926 /* Construct the API message */
6927 M (SW_INTERFACE_SET_TABLE, mp);
6929 mp->sw_if_index = ntohl (sw_if_index);
6930 mp->is_ipv6 = is_ipv6;
6931 mp->vrf_id = ntohl (vrf_id);
6936 /* Wait for a reply... */
6941 static void vl_api_sw_interface_get_table_reply_t_handler
6942 (vl_api_sw_interface_get_table_reply_t * mp)
6944 vat_main_t *vam = &vat_main;
6946 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6948 vam->retval = ntohl (mp->retval);
6949 vam->result_ready = 1;
6953 static void vl_api_sw_interface_get_table_reply_t_handler_json
6954 (vl_api_sw_interface_get_table_reply_t * mp)
6956 vat_main_t *vam = &vat_main;
6957 vat_json_node_t node;
6959 vat_json_init_object (&node);
6960 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6961 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6963 vat_json_print (vam->ofp, &node);
6964 vat_json_free (&node);
6966 vam->retval = ntohl (mp->retval);
6967 vam->result_ready = 1;
6971 api_sw_interface_get_table (vat_main_t * vam)
6973 unformat_input_t *i = vam->input;
6974 vl_api_sw_interface_get_table_t *mp;
6976 u8 sw_if_index_set = 0;
6980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6983 sw_if_index_set = 1;
6984 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6985 sw_if_index_set = 1;
6986 else if (unformat (i, "ipv6"))
6992 if (sw_if_index_set == 0)
6994 errmsg ("missing interface name or sw_if_index");
6998 M (SW_INTERFACE_GET_TABLE, mp);
6999 mp->sw_if_index = htonl (sw_if_index);
7000 mp->is_ipv6 = is_ipv6;
7008 api_sw_interface_set_vpath (vat_main_t * vam)
7010 unformat_input_t *i = vam->input;
7011 vl_api_sw_interface_set_vpath_t *mp;
7012 u32 sw_if_index = 0;
7013 u8 sw_if_index_set = 0;
7017 /* Parse args required to build the message */
7018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7021 sw_if_index_set = 1;
7022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7023 sw_if_index_set = 1;
7024 else if (unformat (i, "enable"))
7026 else if (unformat (i, "disable"))
7032 if (sw_if_index_set == 0)
7034 errmsg ("missing interface name or sw_if_index");
7038 /* Construct the API message */
7039 M (SW_INTERFACE_SET_VPATH, mp);
7041 mp->sw_if_index = ntohl (sw_if_index);
7042 mp->enable = is_enable;
7047 /* Wait for a reply... */
7053 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
7055 unformat_input_t *i = vam->input;
7056 vl_api_sw_interface_set_vxlan_bypass_t *mp;
7057 u32 sw_if_index = 0;
7058 u8 sw_if_index_set = 0;
7063 /* Parse args required to build the message */
7064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7066 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7067 sw_if_index_set = 1;
7068 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7069 sw_if_index_set = 1;
7070 else if (unformat (i, "enable"))
7072 else if (unformat (i, "disable"))
7074 else if (unformat (i, "ip4"))
7076 else if (unformat (i, "ip6"))
7082 if (sw_if_index_set == 0)
7084 errmsg ("missing interface name or sw_if_index");
7088 /* Construct the API message */
7089 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7091 mp->sw_if_index = ntohl (sw_if_index);
7092 mp->enable = is_enable;
7093 mp->is_ipv6 = is_ipv6;
7098 /* Wait for a reply... */
7104 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7106 unformat_input_t *i = vam->input;
7107 vl_api_sw_interface_set_geneve_bypass_t *mp;
7108 u32 sw_if_index = 0;
7109 u8 sw_if_index_set = 0;
7114 /* Parse args required to build the message */
7115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7118 sw_if_index_set = 1;
7119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7120 sw_if_index_set = 1;
7121 else if (unformat (i, "enable"))
7123 else if (unformat (i, "disable"))
7125 else if (unformat (i, "ip4"))
7127 else if (unformat (i, "ip6"))
7133 if (sw_if_index_set == 0)
7135 errmsg ("missing interface name or sw_if_index");
7139 /* Construct the API message */
7140 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7142 mp->sw_if_index = ntohl (sw_if_index);
7143 mp->enable = is_enable;
7144 mp->is_ipv6 = is_ipv6;
7149 /* Wait for a reply... */
7155 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7157 unformat_input_t *i = vam->input;
7158 vl_api_sw_interface_set_l2_xconnect_t *mp;
7160 u8 rx_sw_if_index_set = 0;
7162 u8 tx_sw_if_index_set = 0;
7166 /* Parse args required to build the message */
7167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7169 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7170 rx_sw_if_index_set = 1;
7171 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7172 tx_sw_if_index_set = 1;
7173 else if (unformat (i, "rx"))
7175 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7177 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7179 rx_sw_if_index_set = 1;
7184 else if (unformat (i, "tx"))
7186 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7188 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7190 tx_sw_if_index_set = 1;
7195 else if (unformat (i, "enable"))
7197 else if (unformat (i, "disable"))
7203 if (rx_sw_if_index_set == 0)
7205 errmsg ("missing rx interface name or rx_sw_if_index");
7209 if (enable && (tx_sw_if_index_set == 0))
7211 errmsg ("missing tx interface name or tx_sw_if_index");
7215 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7217 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7218 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7219 mp->enable = enable;
7227 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7229 unformat_input_t *i = vam->input;
7230 vl_api_sw_interface_set_l2_bridge_t *mp;
7232 u8 rx_sw_if_index_set = 0;
7240 /* Parse args required to build the message */
7241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7243 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7244 rx_sw_if_index_set = 1;
7245 else if (unformat (i, "bd_id %d", &bd_id))
7249 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7250 rx_sw_if_index_set = 1;
7251 else if (unformat (i, "shg %d", &shg))
7253 else if (unformat (i, "bvi"))
7255 else if (unformat (i, "enable"))
7257 else if (unformat (i, "disable"))
7263 if (rx_sw_if_index_set == 0)
7265 errmsg ("missing rx interface name or sw_if_index");
7269 if (enable && (bd_id_set == 0))
7271 errmsg ("missing bridge domain");
7275 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7277 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7278 mp->bd_id = ntohl (bd_id);
7281 mp->enable = enable;
7289 api_bridge_domain_dump (vat_main_t * vam)
7291 unformat_input_t *i = vam->input;
7292 vl_api_bridge_domain_dump_t *mp;
7293 vl_api_control_ping_t *mp_ping;
7297 /* Parse args required to build the message */
7298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7300 if (unformat (i, "bd_id %d", &bd_id))
7306 M (BRIDGE_DOMAIN_DUMP, mp);
7307 mp->bd_id = ntohl (bd_id);
7310 /* Use a control ping for synchronization */
7311 MPING (CONTROL_PING, mp_ping);
7319 api_bridge_domain_add_del (vat_main_t * vam)
7321 unformat_input_t *i = vam->input;
7322 vl_api_bridge_domain_add_del_t *mp;
7325 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7330 /* Parse args required to build the message */
7331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7333 if (unformat (i, "bd_id %d", &bd_id))
7335 else if (unformat (i, "flood %d", &flood))
7337 else if (unformat (i, "uu-flood %d", &uu_flood))
7339 else if (unformat (i, "forward %d", &forward))
7341 else if (unformat (i, "learn %d", &learn))
7343 else if (unformat (i, "arp-term %d", &arp_term))
7345 else if (unformat (i, "mac-age %d", &mac_age))
7347 else if (unformat (i, "bd-tag %s", &bd_tag))
7349 else if (unformat (i, "del"))
7352 flood = uu_flood = forward = learn = 0;
7360 errmsg ("missing bridge domain");
7367 errmsg ("mac age must be less than 256 ");
7372 if ((bd_tag) && (vec_len (bd_tag) > 63))
7374 errmsg ("bd-tag cannot be longer than 63");
7379 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7381 mp->bd_id = ntohl (bd_id);
7383 mp->uu_flood = uu_flood;
7384 mp->forward = forward;
7386 mp->arp_term = arp_term;
7387 mp->is_add = is_add;
7388 mp->mac_age = (u8) mac_age;
7391 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7392 mp->bd_tag[vec_len (bd_tag)] = 0;
7403 api_l2fib_flush_bd (vat_main_t * vam)
7405 unformat_input_t *i = vam->input;
7406 vl_api_l2fib_flush_bd_t *mp;
7410 /* Parse args required to build the message */
7411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7413 if (unformat (i, "bd_id %d", &bd_id));
7420 errmsg ("missing bridge domain");
7424 M (L2FIB_FLUSH_BD, mp);
7426 mp->bd_id = htonl (bd_id);
7434 api_l2fib_flush_int (vat_main_t * vam)
7436 unformat_input_t *i = vam->input;
7437 vl_api_l2fib_flush_int_t *mp;
7438 u32 sw_if_index = ~0;
7441 /* Parse args required to build the message */
7442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7444 if (unformat (i, "sw_if_index %d", &sw_if_index));
7446 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7451 if (sw_if_index == ~0)
7453 errmsg ("missing interface name or sw_if_index");
7457 M (L2FIB_FLUSH_INT, mp);
7459 mp->sw_if_index = ntohl (sw_if_index);
7467 api_l2fib_add_del (vat_main_t * vam)
7469 unformat_input_t *i = vam->input;
7470 vl_api_l2fib_add_del_t *mp;
7476 u32 sw_if_index = ~0;
7477 u8 sw_if_index_set = 0;
7486 /* Parse args required to build the message */
7487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7489 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7491 else if (unformat (i, "bd_id %d", &bd_id))
7493 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7494 sw_if_index_set = 1;
7495 else if (unformat (i, "sw_if"))
7497 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7500 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7501 sw_if_index_set = 1;
7506 else if (unformat (i, "static"))
7508 else if (unformat (i, "filter"))
7513 else if (unformat (i, "bvi"))
7518 else if (unformat (i, "del"))
7520 else if (unformat (i, "count %d", &count))
7528 errmsg ("missing mac address");
7534 errmsg ("missing bridge domain");
7538 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7540 errmsg ("missing interface name or sw_if_index");
7546 /* Turn on async mode */
7547 vam->async_mode = 1;
7548 vam->async_errors = 0;
7549 before = vat_time_now (vam);
7552 for (j = 0; j < count; j++)
7554 M (L2FIB_ADD_DEL, mp);
7556 clib_memcpy (mp->mac, mac, 6);
7557 mp->bd_id = ntohl (bd_id);
7558 mp->is_add = is_add;
7562 mp->sw_if_index = ntohl (sw_if_index);
7563 mp->static_mac = static_mac;
7564 mp->filter_mac = filter_mac;
7565 mp->bvi_mac = bvi_mac;
7567 increment_mac_address (mac);
7574 vl_api_control_ping_t *mp_ping;
7577 /* Shut off async mode */
7578 vam->async_mode = 0;
7580 MPING (CONTROL_PING, mp_ping);
7583 timeout = vat_time_now (vam) + 1.0;
7584 while (vat_time_now (vam) < timeout)
7585 if (vam->result_ready == 1)
7590 if (vam->retval == -99)
7593 if (vam->async_errors > 0)
7595 errmsg ("%d asynchronous errors", vam->async_errors);
7598 vam->async_errors = 0;
7599 after = vat_time_now (vam);
7601 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7602 count, after - before, count / (after - before));
7608 /* Wait for a reply... */
7612 /* Return the good/bad news */
7613 return (vam->retval);
7617 api_bridge_domain_set_mac_age (vat_main_t * vam)
7619 unformat_input_t *i = vam->input;
7620 vl_api_bridge_domain_set_mac_age_t *mp;
7625 /* Parse args required to build the message */
7626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7628 if (unformat (i, "bd_id %d", &bd_id));
7629 else if (unformat (i, "mac-age %d", &mac_age));
7636 errmsg ("missing bridge domain");
7642 errmsg ("mac age must be less than 256 ");
7646 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7648 mp->bd_id = htonl (bd_id);
7649 mp->mac_age = (u8) mac_age;
7657 api_l2_flags (vat_main_t * vam)
7659 unformat_input_t *i = vam->input;
7660 vl_api_l2_flags_t *mp;
7663 u8 sw_if_index_set = 0;
7667 /* Parse args required to build the message */
7668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7670 if (unformat (i, "sw_if_index %d", &sw_if_index))
7671 sw_if_index_set = 1;
7672 else if (unformat (i, "sw_if"))
7674 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7677 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7678 sw_if_index_set = 1;
7683 else if (unformat (i, "learn"))
7685 else if (unformat (i, "forward"))
7687 else if (unformat (i, "flood"))
7689 else if (unformat (i, "uu-flood"))
7690 flags |= L2_UU_FLOOD;
7691 else if (unformat (i, "arp-term"))
7692 flags |= L2_ARP_TERM;
7693 else if (unformat (i, "off"))
7695 else if (unformat (i, "disable"))
7701 if (sw_if_index_set == 0)
7703 errmsg ("missing interface name or sw_if_index");
7709 mp->sw_if_index = ntohl (sw_if_index);
7710 mp->feature_bitmap = ntohl (flags);
7711 mp->is_set = is_set;
7719 api_bridge_flags (vat_main_t * vam)
7721 unformat_input_t *i = vam->input;
7722 vl_api_bridge_flags_t *mp;
7729 /* Parse args required to build the message */
7730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7732 if (unformat (i, "bd_id %d", &bd_id))
7734 else if (unformat (i, "learn"))
7736 else if (unformat (i, "forward"))
7738 else if (unformat (i, "flood"))
7740 else if (unformat (i, "uu-flood"))
7741 flags |= L2_UU_FLOOD;
7742 else if (unformat (i, "arp-term"))
7743 flags |= L2_ARP_TERM;
7744 else if (unformat (i, "off"))
7746 else if (unformat (i, "disable"))
7754 errmsg ("missing bridge domain");
7758 M (BRIDGE_FLAGS, mp);
7760 mp->bd_id = ntohl (bd_id);
7761 mp->feature_bitmap = ntohl (flags);
7762 mp->is_set = is_set;
7770 api_bd_ip_mac_add_del (vat_main_t * vam)
7772 unformat_input_t *i = vam->input;
7773 vl_api_bd_ip_mac_add_del_t *mp;
7780 ip4_address_t v4addr;
7781 ip6_address_t v6addr;
7786 /* Parse args required to build the message */
7787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7789 if (unformat (i, "bd_id %d", &bd_id))
7793 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7797 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7802 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7806 else if (unformat (i, "del"))
7814 errmsg ("missing bridge domain");
7817 else if (ip_set == 0)
7819 errmsg ("missing IP address");
7822 else if (mac_set == 0)
7824 errmsg ("missing MAC address");
7828 M (BD_IP_MAC_ADD_DEL, mp);
7830 mp->bd_id = ntohl (bd_id);
7831 mp->is_ipv6 = is_ipv6;
7832 mp->is_add = is_add;
7834 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7836 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7837 clib_memcpy (mp->mac_address, macaddr, 6);
7844 api_tap_connect (vat_main_t * vam)
7846 unformat_input_t *i = vam->input;
7847 vl_api_tap_connect_t *mp;
7853 ip4_address_t ip4_address;
7855 int ip4_address_set = 0;
7856 ip6_address_t ip6_address;
7858 int ip6_address_set = 0;
7861 memset (mac_address, 0, sizeof (mac_address));
7863 /* Parse args required to build the message */
7864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7866 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7870 else if (unformat (i, "random-mac"))
7872 else if (unformat (i, "tapname %s", &tap_name))
7874 else if (unformat (i, "tag %s", &tag))
7876 else if (unformat (i, "address %U/%d",
7877 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7878 ip4_address_set = 1;
7879 else if (unformat (i, "address %U/%d",
7880 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7881 ip6_address_set = 1;
7888 errmsg ("missing tap name");
7891 if (vec_len (tap_name) > 63)
7893 errmsg ("tap name too long");
7896 vec_add1 (tap_name, 0);
7898 if (vec_len (tag) > 63)
7900 errmsg ("tag too long");
7904 /* Construct the API message */
7905 M (TAP_CONNECT, mp);
7907 mp->use_random_mac = random_mac;
7908 clib_memcpy (mp->mac_address, mac_address, 6);
7909 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7911 clib_memcpy (mp->tag, tag, vec_len (tag));
7913 if (ip4_address_set)
7915 mp->ip4_address_set = 1;
7916 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7917 mp->ip4_mask_width = ip4_mask_width;
7919 if (ip6_address_set)
7921 mp->ip6_address_set = 1;
7922 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7923 mp->ip6_mask_width = ip6_mask_width;
7926 vec_free (tap_name);
7932 /* Wait for a reply... */
7938 api_tap_modify (vat_main_t * vam)
7940 unformat_input_t *i = vam->input;
7941 vl_api_tap_modify_t *mp;
7946 u32 sw_if_index = ~0;
7947 u8 sw_if_index_set = 0;
7950 memset (mac_address, 0, sizeof (mac_address));
7952 /* Parse args required to build the message */
7953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7955 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7956 sw_if_index_set = 1;
7957 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7958 sw_if_index_set = 1;
7959 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7963 else if (unformat (i, "random-mac"))
7965 else if (unformat (i, "tapname %s", &tap_name))
7971 if (sw_if_index_set == 0)
7973 errmsg ("missing vpp interface name");
7978 errmsg ("missing tap name");
7981 if (vec_len (tap_name) > 63)
7983 errmsg ("tap name too long");
7985 vec_add1 (tap_name, 0);
7987 /* Construct the API message */
7990 mp->use_random_mac = random_mac;
7991 mp->sw_if_index = ntohl (sw_if_index);
7992 clib_memcpy (mp->mac_address, mac_address, 6);
7993 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7994 vec_free (tap_name);
7999 /* Wait for a reply... */
8005 api_tap_delete (vat_main_t * vam)
8007 unformat_input_t *i = vam->input;
8008 vl_api_tap_delete_t *mp;
8009 u32 sw_if_index = ~0;
8010 u8 sw_if_index_set = 0;
8013 /* Parse args required to build the message */
8014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8017 sw_if_index_set = 1;
8018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8019 sw_if_index_set = 1;
8024 if (sw_if_index_set == 0)
8026 errmsg ("missing vpp interface name");
8030 /* Construct the API message */
8033 mp->sw_if_index = ntohl (sw_if_index);
8038 /* Wait for a reply... */
8044 api_tap_create_v2 (vat_main_t * vam)
8046 unformat_input_t *i = vam->input;
8047 vl_api_tap_create_v2_t *mp;
8051 u8 *host_if_name = 0;
8053 u8 host_mac_addr[6];
8054 u8 host_mac_addr_set = 0;
8055 u8 *host_bridge = 0;
8056 ip4_address_t host_ip4_addr;
8057 ip4_address_t host_ip4_gw;
8058 u8 host_ip4_gw_set = 0;
8059 u32 host_ip4_prefix_len = 0;
8060 ip6_address_t host_ip6_addr;
8061 ip6_address_t host_ip6_gw;
8062 u8 host_ip6_gw_set = 0;
8063 u32 host_ip6_prefix_len = 0;
8065 u32 rx_ring_sz = 0, tx_ring_sz = 0;
8067 memset (mac_address, 0, sizeof (mac_address));
8069 /* Parse args required to build the message */
8070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8072 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8076 else if (unformat (i, "id %u", &id))
8078 else if (unformat (i, "host-if-name %s", &host_if_name))
8080 else if (unformat (i, "host-ns %s", &host_ns))
8082 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8084 host_mac_addr_set = 1;
8085 else if (unformat (i, "host-bridge %s", &host_bridge))
8087 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8088 &host_ip4_addr, &host_ip4_prefix_len))
8090 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8091 &host_ip6_addr, &host_ip6_prefix_len))
8093 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8095 host_ip4_gw_set = 1;
8096 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8098 host_ip6_gw_set = 1;
8099 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8101 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8107 if (vec_len (host_if_name) > 63)
8109 errmsg ("tap name too long. ");
8112 if (vec_len (host_ns) > 63)
8114 errmsg ("host name space too long. ");
8117 if (vec_len (host_bridge) > 63)
8119 errmsg ("host bridge name too long. ");
8122 if (host_ip4_prefix_len > 32)
8124 errmsg ("host ip4 prefix length not valid. ");
8127 if (host_ip6_prefix_len > 128)
8129 errmsg ("host ip6 prefix length not valid. ");
8132 if (!is_pow2 (rx_ring_sz))
8134 errmsg ("rx ring size must be power of 2. ");
8137 if (rx_ring_sz > 32768)
8139 errmsg ("rx ring size must be 32768 or lower. ");
8142 if (!is_pow2 (tx_ring_sz))
8144 errmsg ("tx ring size must be power of 2. ");
8147 if (tx_ring_sz > 32768)
8149 errmsg ("tx ring size must be 32768 or lower. ");
8153 /* Construct the API message */
8154 M (TAP_CREATE_V2, mp);
8156 mp->use_random_mac = random_mac;
8158 mp->id = ntohl (id);
8159 mp->host_namespace_set = host_ns != 0;
8160 mp->host_bridge_set = host_bridge != 0;
8161 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8162 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8163 mp->rx_ring_sz = ntohs (rx_ring_sz);
8164 mp->tx_ring_sz = ntohs (tx_ring_sz);
8166 if (random_mac == 0)
8167 clib_memcpy (mp->mac_address, mac_address, 6);
8168 if (host_mac_addr_set)
8169 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8171 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8173 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8175 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8176 if (host_ip4_prefix_len)
8177 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8178 if (host_ip4_prefix_len)
8179 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8180 if (host_ip4_gw_set)
8181 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8182 if (host_ip6_gw_set)
8183 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8186 vec_free (host_if_name);
8187 vec_free (host_bridge);
8192 /* Wait for a reply... */
8198 api_tap_delete_v2 (vat_main_t * vam)
8200 unformat_input_t *i = vam->input;
8201 vl_api_tap_delete_v2_t *mp;
8202 u32 sw_if_index = ~0;
8203 u8 sw_if_index_set = 0;
8206 /* Parse args required to build the message */
8207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8210 sw_if_index_set = 1;
8211 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8212 sw_if_index_set = 1;
8217 if (sw_if_index_set == 0)
8219 errmsg ("missing vpp interface name. ");
8223 /* Construct the API message */
8224 M (TAP_DELETE_V2, mp);
8226 mp->sw_if_index = ntohl (sw_if_index);
8231 /* Wait for a reply... */
8237 api_bond_create (vat_main_t * vam)
8239 unformat_input_t *i = vam->input;
8240 vl_api_bond_create_t *mp;
8248 memset (mac_address, 0, sizeof (mac_address));
8251 /* Parse args required to build the message */
8252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8254 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8256 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8257 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8259 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8266 if (mode_is_set == 0)
8268 errmsg ("Missing bond mode. ");
8272 /* Construct the API message */
8273 M (BOND_CREATE, mp);
8275 mp->use_custom_mac = custom_mac;
8281 clib_memcpy (mp->mac_address, mac_address, 6);
8286 /* Wait for a reply... */
8292 api_bond_delete (vat_main_t * vam)
8294 unformat_input_t *i = vam->input;
8295 vl_api_bond_delete_t *mp;
8296 u32 sw_if_index = ~0;
8297 u8 sw_if_index_set = 0;
8300 /* Parse args required to build the message */
8301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8304 sw_if_index_set = 1;
8305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8306 sw_if_index_set = 1;
8311 if (sw_if_index_set == 0)
8313 errmsg ("missing vpp interface name. ");
8317 /* Construct the API message */
8318 M (BOND_DELETE, mp);
8320 mp->sw_if_index = ntohl (sw_if_index);
8325 /* Wait for a reply... */
8331 api_bond_enslave (vat_main_t * vam)
8333 unformat_input_t *i = vam->input;
8334 vl_api_bond_enslave_t *mp;
8335 u32 bond_sw_if_index;
8339 u32 bond_sw_if_index_is_set = 0;
8341 u8 sw_if_index_is_set = 0;
8343 /* Parse args required to build the message */
8344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8346 if (unformat (i, "sw_if_index %d", &sw_if_index))
8347 sw_if_index_is_set = 1;
8348 else if (unformat (i, "bond %u", &bond_sw_if_index))
8349 bond_sw_if_index_is_set = 1;
8350 else if (unformat (i, "passive %d", &is_passive))
8352 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8358 if (bond_sw_if_index_is_set == 0)
8360 errmsg ("Missing bond sw_if_index. ");
8363 if (sw_if_index_is_set == 0)
8365 errmsg ("Missing slave sw_if_index. ");
8369 /* Construct the API message */
8370 M (BOND_ENSLAVE, mp);
8372 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8373 mp->sw_if_index = ntohl (sw_if_index);
8374 mp->is_long_timeout = is_long_timeout;
8375 mp->is_passive = is_passive;
8380 /* Wait for a reply... */
8386 api_bond_detach_slave (vat_main_t * vam)
8388 unformat_input_t *i = vam->input;
8389 vl_api_bond_detach_slave_t *mp;
8390 u32 sw_if_index = ~0;
8391 u8 sw_if_index_set = 0;
8394 /* Parse args required to build the message */
8395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8398 sw_if_index_set = 1;
8399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8400 sw_if_index_set = 1;
8405 if (sw_if_index_set == 0)
8407 errmsg ("missing vpp interface name. ");
8411 /* Construct the API message */
8412 M (BOND_DETACH_SLAVE, mp);
8414 mp->sw_if_index = ntohl (sw_if_index);
8419 /* Wait for a reply... */
8425 api_ip_table_add_del (vat_main_t * vam)
8427 unformat_input_t *i = vam->input;
8428 vl_api_ip_table_add_del_t *mp;
8434 /* Parse args required to build the message */
8435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8437 if (unformat (i, "ipv6"))
8439 else if (unformat (i, "del"))
8441 else if (unformat (i, "add"))
8443 else if (unformat (i, "table %d", &table_id))
8447 clib_warning ("parse error '%U'", format_unformat_error, i);
8454 errmsg ("missing table-ID");
8458 /* Construct the API message */
8459 M (IP_TABLE_ADD_DEL, mp);
8461 mp->table_id = ntohl (table_id);
8462 mp->is_ipv6 = is_ipv6;
8463 mp->is_add = is_add;
8468 /* Wait for a reply... */
8475 api_ip_add_del_route (vat_main_t * vam)
8477 unformat_input_t *i = vam->input;
8478 vl_api_ip_add_del_route_t *mp;
8479 u32 sw_if_index = ~0, vrf_id = 0;
8481 u8 is_local = 0, is_drop = 0;
8482 u8 is_unreach = 0, is_prohibit = 0;
8484 u32 next_hop_weight = 1;
8485 u8 is_multipath = 0;
8487 u8 address_length_set = 0;
8488 u32 next_hop_table_id = 0;
8489 u32 resolve_attempts = 0;
8490 u32 dst_address_length = 0;
8491 u8 next_hop_set = 0;
8492 ip4_address_t v4_dst_address, v4_next_hop_address;
8493 ip6_address_t v6_dst_address, v6_next_hop_address;
8497 u32 random_add_del = 0;
8498 u32 *random_vector = 0;
8500 u32 random_seed = 0xdeaddabe;
8501 u32 classify_table_index = ~0;
8503 u8 resolve_host = 0, resolve_attached = 0;
8504 mpls_label_t *next_hop_out_label_stack = NULL;
8505 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8506 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8508 /* Parse args required to build the message */
8509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8513 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8515 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8520 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8525 else if (unformat (i, "/%d", &dst_address_length))
8527 address_length_set = 1;
8530 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8531 &v4_next_hop_address))
8535 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8536 &v6_next_hop_address))
8540 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8542 else if (unformat (i, "weight %d", &next_hop_weight))
8544 else if (unformat (i, "drop"))
8548 else if (unformat (i, "null-send-unreach"))
8552 else if (unformat (i, "null-send-prohibit"))
8556 else if (unformat (i, "local"))
8560 else if (unformat (i, "classify %d", &classify_table_index))
8564 else if (unformat (i, "del"))
8566 else if (unformat (i, "add"))
8568 else if (unformat (i, "resolve-via-host"))
8570 else if (unformat (i, "resolve-via-attached"))
8571 resolve_attached = 1;
8572 else if (unformat (i, "multipath"))
8574 else if (unformat (i, "vrf %d", &vrf_id))
8576 else if (unformat (i, "count %d", &count))
8578 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8580 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8582 else if (unformat (i, "out-label %d", &next_hop_out_label))
8583 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8584 else if (unformat (i, "via-label %d", &next_hop_via_label))
8586 else if (unformat (i, "random"))
8588 else if (unformat (i, "seed %d", &random_seed))
8592 clib_warning ("parse error '%U'", format_unformat_error, i);
8597 if (!next_hop_set && !is_drop && !is_local &&
8598 !is_classify && !is_unreach && !is_prohibit &&
8599 MPLS_LABEL_INVALID == next_hop_via_label)
8602 ("next hop / local / drop / unreach / prohibit / classify not set");
8606 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8608 errmsg ("next hop and next-hop via label set");
8611 if (address_set == 0)
8613 errmsg ("missing addresses");
8617 if (address_length_set == 0)
8619 errmsg ("missing address length");
8623 /* Generate a pile of unique, random routes */
8626 u32 this_random_address;
8627 random_hash = hash_create (count, sizeof (uword));
8629 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8630 for (j = 0; j <= count; j++)
8634 this_random_address = random_u32 (&random_seed);
8635 this_random_address =
8636 clib_host_to_net_u32 (this_random_address);
8638 while (hash_get (random_hash, this_random_address));
8639 vec_add1 (random_vector, this_random_address);
8640 hash_set (random_hash, this_random_address, 1);
8642 hash_free (random_hash);
8643 v4_dst_address.as_u32 = random_vector[0];
8648 /* Turn on async mode */
8649 vam->async_mode = 1;
8650 vam->async_errors = 0;
8651 before = vat_time_now (vam);
8654 for (j = 0; j < count; j++)
8656 /* Construct the API message */
8657 M2 (IP_ADD_DEL_ROUTE, mp,
8658 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8660 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8661 mp->table_id = ntohl (vrf_id);
8663 mp->is_add = is_add;
8664 mp->is_drop = is_drop;
8665 mp->is_unreach = is_unreach;
8666 mp->is_prohibit = is_prohibit;
8667 mp->is_ipv6 = is_ipv6;
8668 mp->is_local = is_local;
8669 mp->is_classify = is_classify;
8670 mp->is_multipath = is_multipath;
8671 mp->is_resolve_host = resolve_host;
8672 mp->is_resolve_attached = resolve_attached;
8673 mp->next_hop_weight = next_hop_weight;
8674 mp->dst_address_length = dst_address_length;
8675 mp->next_hop_table_id = ntohl (next_hop_table_id);
8676 mp->classify_table_index = ntohl (classify_table_index);
8677 mp->next_hop_via_label = ntohl (next_hop_via_label);
8678 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8679 if (0 != mp->next_hop_n_out_labels)
8681 memcpy (mp->next_hop_out_label_stack,
8682 next_hop_out_label_stack,
8683 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8684 vec_free (next_hop_out_label_stack);
8689 clib_memcpy (mp->dst_address, &v6_dst_address,
8690 sizeof (v6_dst_address));
8692 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8693 sizeof (v6_next_hop_address));
8694 increment_v6_address (&v6_dst_address);
8698 clib_memcpy (mp->dst_address, &v4_dst_address,
8699 sizeof (v4_dst_address));
8701 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8702 sizeof (v4_next_hop_address));
8704 v4_dst_address.as_u32 = random_vector[j + 1];
8706 increment_v4_address (&v4_dst_address);
8710 /* If we receive SIGTERM, stop now... */
8715 /* When testing multiple add/del ops, use a control-ping to sync */
8718 vl_api_control_ping_t *mp_ping;
8722 /* Shut off async mode */
8723 vam->async_mode = 0;
8725 MPING (CONTROL_PING, mp_ping);
8728 timeout = vat_time_now (vam) + 1.0;
8729 while (vat_time_now (vam) < timeout)
8730 if (vam->result_ready == 1)
8735 if (vam->retval == -99)
8738 if (vam->async_errors > 0)
8740 errmsg ("%d asynchronous errors", vam->async_errors);
8743 vam->async_errors = 0;
8744 after = vat_time_now (vam);
8746 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8750 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8751 count, after - before, count / (after - before));
8757 /* Wait for a reply... */
8762 /* Return the good/bad news */
8763 return (vam->retval);
8767 api_ip_mroute_add_del (vat_main_t * vam)
8769 unformat_input_t *i = vam->input;
8770 vl_api_ip_mroute_add_del_t *mp;
8771 u32 sw_if_index = ~0, vrf_id = 0;
8776 u32 grp_address_length = 0;
8777 ip4_address_t v4_grp_address, v4_src_address;
8778 ip6_address_t v6_grp_address, v6_src_address;
8779 mfib_itf_flags_t iflags = 0;
8780 mfib_entry_flags_t eflags = 0;
8783 /* Parse args required to build the message */
8784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8786 if (unformat (i, "sw_if_index %d", &sw_if_index))
8788 else if (unformat (i, "%U %U",
8789 unformat_ip4_address, &v4_src_address,
8790 unformat_ip4_address, &v4_grp_address))
8792 grp_address_length = 64;
8796 else if (unformat (i, "%U %U",
8797 unformat_ip6_address, &v6_src_address,
8798 unformat_ip6_address, &v6_grp_address))
8800 grp_address_length = 256;
8804 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8806 memset (&v4_src_address, 0, sizeof (v4_src_address));
8807 grp_address_length = 32;
8811 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8813 memset (&v6_src_address, 0, sizeof (v6_src_address));
8814 grp_address_length = 128;
8818 else if (unformat (i, "/%d", &grp_address_length))
8820 else if (unformat (i, "local"))
8824 else if (unformat (i, "del"))
8826 else if (unformat (i, "add"))
8828 else if (unformat (i, "vrf %d", &vrf_id))
8830 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8832 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8836 clib_warning ("parse error '%U'", format_unformat_error, i);
8841 if (address_set == 0)
8843 errmsg ("missing addresses\n");
8847 /* Construct the API message */
8848 M (IP_MROUTE_ADD_DEL, mp);
8850 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8851 mp->table_id = ntohl (vrf_id);
8853 mp->is_add = is_add;
8854 mp->is_ipv6 = is_ipv6;
8855 mp->is_local = is_local;
8856 mp->itf_flags = ntohl (iflags);
8857 mp->entry_flags = ntohl (eflags);
8858 mp->grp_address_length = grp_address_length;
8859 mp->grp_address_length = ntohs (mp->grp_address_length);
8863 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8864 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8868 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8869 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8875 /* Wait for a reply... */
8881 api_mpls_table_add_del (vat_main_t * vam)
8883 unformat_input_t *i = vam->input;
8884 vl_api_mpls_table_add_del_t *mp;
8889 /* Parse args required to build the message */
8890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8892 if (unformat (i, "table %d", &table_id))
8894 else if (unformat (i, "del"))
8896 else if (unformat (i, "add"))
8900 clib_warning ("parse error '%U'", format_unformat_error, i);
8907 errmsg ("missing table-ID");
8911 /* Construct the API message */
8912 M (MPLS_TABLE_ADD_DEL, mp);
8914 mp->mt_table_id = ntohl (table_id);
8915 mp->mt_is_add = is_add;
8920 /* Wait for a reply... */
8927 api_mpls_route_add_del (vat_main_t * vam)
8929 unformat_input_t *i = vam->input;
8930 vl_api_mpls_route_add_del_t *mp;
8931 u32 sw_if_index = ~0, table_id = 0;
8933 u32 next_hop_weight = 1;
8934 u8 is_multipath = 0;
8935 u32 next_hop_table_id = 0;
8936 u8 next_hop_set = 0;
8937 ip4_address_t v4_next_hop_address = {
8940 ip6_address_t v6_next_hop_address = { {0} };
8944 u32 classify_table_index = ~0;
8946 u8 resolve_host = 0, resolve_attached = 0;
8947 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8948 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8949 mpls_label_t *next_hop_out_label_stack = NULL;
8950 mpls_label_t local_label = MPLS_LABEL_INVALID;
8952 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8954 /* Parse args required to build the message */
8955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8957 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8959 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8961 else if (unformat (i, "%d", &local_label))
8963 else if (unformat (i, "eos"))
8965 else if (unformat (i, "non-eos"))
8967 else if (unformat (i, "via %U", unformat_ip4_address,
8968 &v4_next_hop_address))
8971 next_hop_proto = DPO_PROTO_IP4;
8973 else if (unformat (i, "via %U", unformat_ip6_address,
8974 &v6_next_hop_address))
8977 next_hop_proto = DPO_PROTO_IP6;
8979 else if (unformat (i, "weight %d", &next_hop_weight))
8981 else if (unformat (i, "classify %d", &classify_table_index))
8985 else if (unformat (i, "del"))
8987 else if (unformat (i, "add"))
8989 else if (unformat (i, "resolve-via-host"))
8991 else if (unformat (i, "resolve-via-attached"))
8992 resolve_attached = 1;
8993 else if (unformat (i, "multipath"))
8995 else if (unformat (i, "count %d", &count))
8997 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
9000 next_hop_proto = DPO_PROTO_IP4;
9002 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
9005 next_hop_proto = DPO_PROTO_IP6;
9007 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9009 else if (unformat (i, "via-label %d", &next_hop_via_label))
9011 else if (unformat (i, "out-label %d", &next_hop_out_label))
9012 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
9015 clib_warning ("parse error '%U'", format_unformat_error, i);
9020 if (!next_hop_set && !is_classify)
9022 errmsg ("next hop / classify not set");
9026 if (MPLS_LABEL_INVALID == local_label)
9028 errmsg ("missing label");
9034 /* Turn on async mode */
9035 vam->async_mode = 1;
9036 vam->async_errors = 0;
9037 before = vat_time_now (vam);
9040 for (j = 0; j < count; j++)
9042 /* Construct the API message */
9043 M2 (MPLS_ROUTE_ADD_DEL, mp,
9044 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
9046 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
9047 mp->mr_table_id = ntohl (table_id);
9049 mp->mr_is_add = is_add;
9050 mp->mr_next_hop_proto = next_hop_proto;
9051 mp->mr_is_classify = is_classify;
9052 mp->mr_is_multipath = is_multipath;
9053 mp->mr_is_resolve_host = resolve_host;
9054 mp->mr_is_resolve_attached = resolve_attached;
9055 mp->mr_next_hop_weight = next_hop_weight;
9056 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
9057 mp->mr_classify_table_index = ntohl (classify_table_index);
9058 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
9059 mp->mr_label = ntohl (local_label);
9060 mp->mr_eos = is_eos;
9062 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9063 if (0 != mp->mr_next_hop_n_out_labels)
9065 memcpy (mp->mr_next_hop_out_label_stack,
9066 next_hop_out_label_stack,
9067 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
9068 vec_free (next_hop_out_label_stack);
9073 if (DPO_PROTO_IP4 == next_hop_proto)
9075 clib_memcpy (mp->mr_next_hop,
9076 &v4_next_hop_address,
9077 sizeof (v4_next_hop_address));
9079 else if (DPO_PROTO_IP6 == next_hop_proto)
9082 clib_memcpy (mp->mr_next_hop,
9083 &v6_next_hop_address,
9084 sizeof (v6_next_hop_address));
9091 /* If we receive SIGTERM, stop now... */
9096 /* When testing multiple add/del ops, use a control-ping to sync */
9099 vl_api_control_ping_t *mp_ping;
9103 /* Shut off async mode */
9104 vam->async_mode = 0;
9106 MPING (CONTROL_PING, mp_ping);
9109 timeout = vat_time_now (vam) + 1.0;
9110 while (vat_time_now (vam) < timeout)
9111 if (vam->result_ready == 1)
9116 if (vam->retval == -99)
9119 if (vam->async_errors > 0)
9121 errmsg ("%d asynchronous errors", vam->async_errors);
9124 vam->async_errors = 0;
9125 after = vat_time_now (vam);
9127 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9131 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9132 count, after - before, count / (after - before));
9138 /* Wait for a reply... */
9143 /* Return the good/bad news */
9144 return (vam->retval);
9148 api_mpls_ip_bind_unbind (vat_main_t * vam)
9150 unformat_input_t *i = vam->input;
9151 vl_api_mpls_ip_bind_unbind_t *mp;
9152 u32 ip_table_id = 0;
9155 ip4_address_t v4_address;
9156 ip6_address_t v6_address;
9159 mpls_label_t local_label = MPLS_LABEL_INVALID;
9162 /* Parse args required to build the message */
9163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9165 if (unformat (i, "%U/%d", unformat_ip4_address,
9166 &v4_address, &address_length))
9171 else if (unformat (i, "%U/%d", unformat_ip6_address,
9172 &v6_address, &address_length))
9177 else if (unformat (i, "%d", &local_label))
9179 else if (unformat (i, "table-id %d", &ip_table_id))
9181 else if (unformat (i, "unbind"))
9183 else if (unformat (i, "bind"))
9187 clib_warning ("parse error '%U'", format_unformat_error, i);
9194 errmsg ("IP addres not set");
9198 if (MPLS_LABEL_INVALID == local_label)
9200 errmsg ("missing label");
9204 /* Construct the API message */
9205 M (MPLS_IP_BIND_UNBIND, mp);
9207 mp->mb_is_bind = is_bind;
9208 mp->mb_is_ip4 = is_ip4;
9209 mp->mb_ip_table_id = ntohl (ip_table_id);
9210 mp->mb_mpls_table_id = 0;
9211 mp->mb_label = ntohl (local_label);
9212 mp->mb_address_length = address_length;
9215 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9217 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9222 /* Wait for a reply... */
9228 api_bier_table_add_del (vat_main_t * vam)
9230 unformat_input_t *i = vam->input;
9231 vl_api_bier_table_add_del_t *mp;
9233 u32 set = 0, sub_domain = 0, hdr_len = 3;
9234 mpls_label_t local_label = MPLS_LABEL_INVALID;
9237 /* Parse args required to build the message */
9238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9240 if (unformat (i, "sub-domain %d", &sub_domain))
9242 else if (unformat (i, "set %d", &set))
9244 else if (unformat (i, "label %d", &local_label))
9246 else if (unformat (i, "hdr-len %d", &hdr_len))
9248 else if (unformat (i, "add"))
9250 else if (unformat (i, "del"))
9254 clib_warning ("parse error '%U'", format_unformat_error, i);
9259 if (MPLS_LABEL_INVALID == local_label)
9261 errmsg ("missing label\n");
9265 /* Construct the API message */
9266 M (BIER_TABLE_ADD_DEL, mp);
9268 mp->bt_is_add = is_add;
9269 mp->bt_label = ntohl (local_label);
9270 mp->bt_tbl_id.bt_set = set;
9271 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9272 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9277 /* Wait for a reply... */
9284 api_bier_route_add_del (vat_main_t * vam)
9286 unformat_input_t *i = vam->input;
9287 vl_api_bier_route_add_del_t *mp;
9289 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9290 ip4_address_t v4_next_hop_address;
9291 ip6_address_t v6_next_hop_address;
9292 u8 next_hop_set = 0;
9293 u8 next_hop_proto_is_ip4 = 1;
9294 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9297 /* Parse args required to build the message */
9298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9300 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9302 next_hop_proto_is_ip4 = 1;
9305 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9307 next_hop_proto_is_ip4 = 0;
9310 if (unformat (i, "sub-domain %d", &sub_domain))
9312 else if (unformat (i, "set %d", &set))
9314 else if (unformat (i, "hdr-len %d", &hdr_len))
9316 else if (unformat (i, "bp %d", &bp))
9318 else if (unformat (i, "add"))
9320 else if (unformat (i, "del"))
9322 else if (unformat (i, "out-label %d", &next_hop_out_label))
9326 clib_warning ("parse error '%U'", format_unformat_error, i);
9331 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9333 errmsg ("next hop / label set\n");
9338 errmsg ("bit=position not set\n");
9342 /* Construct the API message */
9343 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9345 mp->br_is_add = is_add;
9346 mp->br_tbl_id.bt_set = set;
9347 mp->br_tbl_id.bt_sub_domain = sub_domain;
9348 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9349 mp->br_bp = ntohs (bp);
9351 mp->br_paths[0].n_labels = 1;
9352 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9353 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9355 if (next_hop_proto_is_ip4)
9357 clib_memcpy (mp->br_paths[0].next_hop,
9358 &v4_next_hop_address, sizeof (v4_next_hop_address));
9362 clib_memcpy (mp->br_paths[0].next_hop,
9363 &v6_next_hop_address, sizeof (v6_next_hop_address));
9369 /* Wait for a reply... */
9376 api_proxy_arp_add_del (vat_main_t * vam)
9378 unformat_input_t *i = vam->input;
9379 vl_api_proxy_arp_add_del_t *mp;
9382 ip4_address_t lo, hi;
9386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9388 if (unformat (i, "vrf %d", &vrf_id))
9390 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9391 unformat_ip4_address, &hi))
9393 else if (unformat (i, "del"))
9397 clib_warning ("parse error '%U'", format_unformat_error, i);
9404 errmsg ("address range not set");
9408 M (PROXY_ARP_ADD_DEL, mp);
9410 mp->vrf_id = ntohl (vrf_id);
9411 mp->is_add = is_add;
9412 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
9413 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
9421 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9423 unformat_input_t *i = vam->input;
9424 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9427 u8 sw_if_index_set = 0;
9430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9432 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9433 sw_if_index_set = 1;
9434 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9435 sw_if_index_set = 1;
9436 else if (unformat (i, "enable"))
9438 else if (unformat (i, "disable"))
9442 clib_warning ("parse error '%U'", format_unformat_error, i);
9447 if (sw_if_index_set == 0)
9449 errmsg ("missing interface name or sw_if_index");
9453 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9455 mp->sw_if_index = ntohl (sw_if_index);
9456 mp->enable_disable = enable;
9464 api_mpls_tunnel_add_del (vat_main_t * vam)
9466 unformat_input_t *i = vam->input;
9467 vl_api_mpls_tunnel_add_del_t *mp;
9471 u32 sw_if_index = ~0;
9472 u32 next_hop_sw_if_index = ~0;
9473 u32 next_hop_proto_is_ip4 = 1;
9475 u32 next_hop_table_id = 0;
9476 ip4_address_t v4_next_hop_address = {
9479 ip6_address_t v6_next_hop_address = { {0} };
9480 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9485 if (unformat (i, "add"))
9487 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9489 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9491 else if (unformat (i, "via %U",
9492 unformat_ip4_address, &v4_next_hop_address))
9494 next_hop_proto_is_ip4 = 1;
9496 else if (unformat (i, "via %U",
9497 unformat_ip6_address, &v6_next_hop_address))
9499 next_hop_proto_is_ip4 = 0;
9501 else if (unformat (i, "l2-only"))
9503 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9505 else if (unformat (i, "out-label %d", &next_hop_out_label))
9506 vec_add1 (labels, ntohl (next_hop_out_label));
9509 clib_warning ("parse error '%U'", format_unformat_error, i);
9514 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9516 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9517 mp->mt_sw_if_index = ntohl (sw_if_index);
9518 mp->mt_is_add = is_add;
9519 mp->mt_l2_only = l2_only;
9520 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9521 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9523 mp->mt_next_hop_n_out_labels = vec_len (labels);
9525 if (0 != mp->mt_next_hop_n_out_labels)
9527 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9528 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9532 if (next_hop_proto_is_ip4)
9534 clib_memcpy (mp->mt_next_hop,
9535 &v4_next_hop_address, sizeof (v4_next_hop_address));
9539 clib_memcpy (mp->mt_next_hop,
9540 &v6_next_hop_address, sizeof (v6_next_hop_address));
9549 api_sw_interface_set_unnumbered (vat_main_t * vam)
9551 unformat_input_t *i = vam->input;
9552 vl_api_sw_interface_set_unnumbered_t *mp;
9554 u32 unnum_sw_index = ~0;
9556 u8 sw_if_index_set = 0;
9559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9562 sw_if_index_set = 1;
9563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9564 sw_if_index_set = 1;
9565 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9567 else if (unformat (i, "del"))
9571 clib_warning ("parse error '%U'", format_unformat_error, i);
9576 if (sw_if_index_set == 0)
9578 errmsg ("missing interface name or sw_if_index");
9582 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9584 mp->sw_if_index = ntohl (sw_if_index);
9585 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9586 mp->is_add = is_add;
9594 api_ip_neighbor_add_del (vat_main_t * vam)
9596 unformat_input_t *i = vam->input;
9597 vl_api_ip_neighbor_add_del_t *mp;
9599 u8 sw_if_index_set = 0;
9602 u8 is_no_fib_entry = 0;
9605 u8 v4_address_set = 0;
9606 u8 v6_address_set = 0;
9607 ip4_address_t v4address;
9608 ip6_address_t v6address;
9611 memset (mac_address, 0, sizeof (mac_address));
9613 /* Parse args required to build the message */
9614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9616 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9620 else if (unformat (i, "del"))
9623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9624 sw_if_index_set = 1;
9625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9626 sw_if_index_set = 1;
9627 else if (unformat (i, "is_static"))
9629 else if (unformat (i, "no-fib-entry"))
9630 is_no_fib_entry = 1;
9631 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9633 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9637 clib_warning ("parse error '%U'", format_unformat_error, i);
9642 if (sw_if_index_set == 0)
9644 errmsg ("missing interface name or sw_if_index");
9647 if (v4_address_set && v6_address_set)
9649 errmsg ("both v4 and v6 addresses set");
9652 if (!v4_address_set && !v6_address_set)
9654 errmsg ("no address set");
9658 /* Construct the API message */
9659 M (IP_NEIGHBOR_ADD_DEL, mp);
9661 mp->sw_if_index = ntohl (sw_if_index);
9662 mp->is_add = is_add;
9663 mp->is_static = is_static;
9664 mp->is_no_adj_fib = is_no_fib_entry;
9666 clib_memcpy (mp->mac_address, mac_address, 6);
9670 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9674 /* mp->is_ipv6 = 0; via memset in M macro above */
9675 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9681 /* Wait for a reply, return good/bad news */
9687 api_create_vlan_subif (vat_main_t * vam)
9689 unformat_input_t *i = vam->input;
9690 vl_api_create_vlan_subif_t *mp;
9692 u8 sw_if_index_set = 0;
9697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9699 if (unformat (i, "sw_if_index %d", &sw_if_index))
9700 sw_if_index_set = 1;
9702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9703 sw_if_index_set = 1;
9704 else if (unformat (i, "vlan %d", &vlan_id))
9708 clib_warning ("parse error '%U'", format_unformat_error, i);
9713 if (sw_if_index_set == 0)
9715 errmsg ("missing interface name or sw_if_index");
9719 if (vlan_id_set == 0)
9721 errmsg ("missing vlan_id");
9724 M (CREATE_VLAN_SUBIF, mp);
9726 mp->sw_if_index = ntohl (sw_if_index);
9727 mp->vlan_id = ntohl (vlan_id);
9734 #define foreach_create_subif_bit \
9741 _(outer_vlan_id_any) \
9742 _(inner_vlan_id_any)
9745 api_create_subif (vat_main_t * vam)
9747 unformat_input_t *i = vam->input;
9748 vl_api_create_subif_t *mp;
9750 u8 sw_if_index_set = 0;
9757 u32 exact_match = 0;
9758 u32 default_sub = 0;
9759 u32 outer_vlan_id_any = 0;
9760 u32 inner_vlan_id_any = 0;
9762 u16 outer_vlan_id = 0;
9763 u16 inner_vlan_id = 0;
9766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9768 if (unformat (i, "sw_if_index %d", &sw_if_index))
9769 sw_if_index_set = 1;
9771 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9772 sw_if_index_set = 1;
9773 else if (unformat (i, "sub_id %d", &sub_id))
9775 else if (unformat (i, "outer_vlan_id %d", &tmp))
9776 outer_vlan_id = tmp;
9777 else if (unformat (i, "inner_vlan_id %d", &tmp))
9778 inner_vlan_id = tmp;
9780 #define _(a) else if (unformat (i, #a)) a = 1 ;
9781 foreach_create_subif_bit
9785 clib_warning ("parse error '%U'", format_unformat_error, i);
9790 if (sw_if_index_set == 0)
9792 errmsg ("missing interface name or sw_if_index");
9796 if (sub_id_set == 0)
9798 errmsg ("missing sub_id");
9801 M (CREATE_SUBIF, mp);
9803 mp->sw_if_index = ntohl (sw_if_index);
9804 mp->sub_id = ntohl (sub_id);
9806 #define _(a) mp->a = a;
9807 foreach_create_subif_bit;
9810 mp->outer_vlan_id = ntohs (outer_vlan_id);
9811 mp->inner_vlan_id = ntohs (inner_vlan_id);
9819 api_oam_add_del (vat_main_t * vam)
9821 unformat_input_t *i = vam->input;
9822 vl_api_oam_add_del_t *mp;
9825 ip4_address_t src, dst;
9830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9832 if (unformat (i, "vrf %d", &vrf_id))
9834 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9836 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9838 else if (unformat (i, "del"))
9842 clib_warning ("parse error '%U'", format_unformat_error, i);
9849 errmsg ("missing src addr");
9855 errmsg ("missing dst addr");
9859 M (OAM_ADD_DEL, mp);
9861 mp->vrf_id = ntohl (vrf_id);
9862 mp->is_add = is_add;
9863 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9864 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9872 api_reset_fib (vat_main_t * vam)
9874 unformat_input_t *i = vam->input;
9875 vl_api_reset_fib_t *mp;
9881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9883 if (unformat (i, "vrf %d", &vrf_id))
9885 else if (unformat (i, "ipv6"))
9889 clib_warning ("parse error '%U'", format_unformat_error, i);
9894 if (vrf_id_set == 0)
9896 errmsg ("missing vrf id");
9902 mp->vrf_id = ntohl (vrf_id);
9903 mp->is_ipv6 = is_ipv6;
9911 api_dhcp_proxy_config (vat_main_t * vam)
9913 unformat_input_t *i = vam->input;
9914 vl_api_dhcp_proxy_config_t *mp;
9916 u32 server_vrf_id = 0;
9918 u8 v4_address_set = 0;
9919 u8 v6_address_set = 0;
9920 ip4_address_t v4address;
9921 ip6_address_t v6address;
9922 u8 v4_src_address_set = 0;
9923 u8 v6_src_address_set = 0;
9924 ip4_address_t v4srcaddress;
9925 ip6_address_t v6srcaddress;
9928 /* Parse args required to build the message */
9929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9931 if (unformat (i, "del"))
9933 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9935 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9937 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9939 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9941 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9942 v4_src_address_set = 1;
9943 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9944 v6_src_address_set = 1;
9949 if (v4_address_set && v6_address_set)
9951 errmsg ("both v4 and v6 server addresses set");
9954 if (!v4_address_set && !v6_address_set)
9956 errmsg ("no server addresses set");
9960 if (v4_src_address_set && v6_src_address_set)
9962 errmsg ("both v4 and v6 src addresses set");
9965 if (!v4_src_address_set && !v6_src_address_set)
9967 errmsg ("no src addresses set");
9971 if (!(v4_src_address_set && v4_address_set) &&
9972 !(v6_src_address_set && v6_address_set))
9974 errmsg ("no matching server and src addresses set");
9978 /* Construct the API message */
9979 M (DHCP_PROXY_CONFIG, mp);
9981 mp->is_add = is_add;
9982 mp->rx_vrf_id = ntohl (rx_vrf_id);
9983 mp->server_vrf_id = ntohl (server_vrf_id);
9987 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9988 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9992 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9993 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9999 /* Wait for a reply, return good/bad news */
10004 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
10005 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
10008 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
10010 vat_main_t *vam = &vat_main;
10011 u32 i, count = mp->count;
10012 vl_api_dhcp_server_t *s;
10016 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10017 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10018 ntohl (mp->rx_vrf_id),
10019 format_ip6_address, mp->dhcp_src_address,
10020 mp->vss_type, mp->vss_vpn_ascii_id,
10021 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10024 "RX Table-ID %d, Source Address %U, VSS Type %d, "
10025 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
10026 ntohl (mp->rx_vrf_id),
10027 format_ip4_address, mp->dhcp_src_address,
10028 mp->vss_type, mp->vss_vpn_ascii_id,
10029 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
10031 for (i = 0; i < count; i++)
10033 s = &mp->servers[i];
10037 " Server Table-ID %d, Server Address %U",
10038 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
10041 " Server Table-ID %d, Server Address %U",
10042 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
10046 static void vl_api_dhcp_proxy_details_t_handler_json
10047 (vl_api_dhcp_proxy_details_t * mp)
10049 vat_main_t *vam = &vat_main;
10050 vat_json_node_t *node = NULL;
10051 u32 i, count = mp->count;
10052 struct in_addr ip4;
10053 struct in6_addr ip6;
10054 vl_api_dhcp_server_t *s;
10056 if (VAT_JSON_ARRAY != vam->json_tree.type)
10058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10059 vat_json_init_array (&vam->json_tree);
10061 node = vat_json_array_add (&vam->json_tree);
10063 vat_json_init_object (node);
10064 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
10065 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
10066 sizeof (mp->vss_type));
10067 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
10068 mp->vss_vpn_ascii_id);
10069 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
10070 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10074 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10075 vat_json_object_add_ip6 (node, "src_address", ip6);
10079 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10080 vat_json_object_add_ip4 (node, "src_address", ip4);
10083 for (i = 0; i < count; i++)
10085 s = &mp->servers[i];
10087 vat_json_object_add_uint (node, "server-table-id",
10088 ntohl (s->server_vrf_id));
10092 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10093 vat_json_object_add_ip4 (node, "src_address", ip4);
10097 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10098 vat_json_object_add_ip6 (node, "server_address", ip6);
10104 api_dhcp_proxy_dump (vat_main_t * vam)
10106 unformat_input_t *i = vam->input;
10107 vl_api_control_ping_t *mp_ping;
10108 vl_api_dhcp_proxy_dump_t *mp;
10112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10114 if (unformat (i, "ipv6"))
10118 clib_warning ("parse error '%U'", format_unformat_error, i);
10123 M (DHCP_PROXY_DUMP, mp);
10125 mp->is_ip6 = is_ipv6;
10128 /* Use a control ping for synchronization */
10129 MPING (CONTROL_PING, mp_ping);
10137 api_dhcp_proxy_set_vss (vat_main_t * vam)
10139 unformat_input_t *i = vam->input;
10140 vl_api_dhcp_proxy_set_vss_t *mp;
10144 u8 vss_type = VSS_TYPE_DEFAULT;
10145 u8 *vpn_ascii_id = 0;
10150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10152 if (unformat (i, "tbl_id %d", &tbl_id))
10154 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10155 vss_type = VSS_TYPE_ASCII;
10156 else if (unformat (i, "fib_id %d", &fib_id))
10157 vss_type = VSS_TYPE_VPN_ID;
10158 else if (unformat (i, "oui %d", &oui))
10159 vss_type = VSS_TYPE_VPN_ID;
10160 else if (unformat (i, "ipv6"))
10162 else if (unformat (i, "del"))
10170 errmsg ("missing tbl_id ");
10171 vec_free (vpn_ascii_id);
10175 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10177 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10178 vec_free (vpn_ascii_id);
10182 M (DHCP_PROXY_SET_VSS, mp);
10183 mp->tbl_id = ntohl (tbl_id);
10184 mp->vss_type = vss_type;
10187 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10188 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10190 mp->vpn_index = ntohl (fib_id);
10191 mp->oui = ntohl (oui);
10192 mp->is_ipv6 = is_ipv6;
10193 mp->is_add = is_add;
10198 vec_free (vpn_ascii_id);
10203 api_dhcp_client_config (vat_main_t * vam)
10205 unformat_input_t *i = vam->input;
10206 vl_api_dhcp_client_config_t *mp;
10208 u8 sw_if_index_set = 0;
10211 u8 disable_event = 0;
10214 /* Parse args required to build the message */
10215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10217 if (unformat (i, "del"))
10220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10221 sw_if_index_set = 1;
10222 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10223 sw_if_index_set = 1;
10224 else if (unformat (i, "hostname %s", &hostname))
10226 else if (unformat (i, "disable_event"))
10232 if (sw_if_index_set == 0)
10234 errmsg ("missing interface name or sw_if_index");
10238 if (vec_len (hostname) > 63)
10240 errmsg ("hostname too long");
10242 vec_add1 (hostname, 0);
10244 /* Construct the API message */
10245 M (DHCP_CLIENT_CONFIG, mp);
10247 mp->sw_if_index = htonl (sw_if_index);
10248 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
10249 vec_free (hostname);
10250 mp->is_add = is_add;
10251 mp->want_dhcp_event = disable_event ? 0 : 1;
10252 mp->pid = htonl (getpid ());
10257 /* Wait for a reply, return good/bad news */
10263 api_set_ip_flow_hash (vat_main_t * vam)
10265 unformat_input_t *i = vam->input;
10266 vl_api_set_ip_flow_hash_t *mp;
10278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10280 if (unformat (i, "vrf %d", &vrf_id))
10282 else if (unformat (i, "ipv6"))
10284 else if (unformat (i, "src"))
10286 else if (unformat (i, "dst"))
10288 else if (unformat (i, "sport"))
10290 else if (unformat (i, "dport"))
10292 else if (unformat (i, "proto"))
10294 else if (unformat (i, "reverse"))
10299 clib_warning ("parse error '%U'", format_unformat_error, i);
10304 if (vrf_id_set == 0)
10306 errmsg ("missing vrf id");
10310 M (SET_IP_FLOW_HASH, mp);
10316 mp->reverse = reverse;
10317 mp->vrf_id = ntohl (vrf_id);
10318 mp->is_ipv6 = is_ipv6;
10326 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10328 unformat_input_t *i = vam->input;
10329 vl_api_sw_interface_ip6_enable_disable_t *mp;
10331 u8 sw_if_index_set = 0;
10335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10338 sw_if_index_set = 1;
10339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10340 sw_if_index_set = 1;
10341 else if (unformat (i, "enable"))
10343 else if (unformat (i, "disable"))
10347 clib_warning ("parse error '%U'", format_unformat_error, i);
10352 if (sw_if_index_set == 0)
10354 errmsg ("missing interface name or sw_if_index");
10358 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10360 mp->sw_if_index = ntohl (sw_if_index);
10361 mp->enable = enable;
10369 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10371 unformat_input_t *i = vam->input;
10372 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10374 u8 sw_if_index_set = 0;
10375 u8 v6_address_set = 0;
10376 ip6_address_t v6address;
10379 /* Parse args required to build the message */
10380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10383 sw_if_index_set = 1;
10384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10385 sw_if_index_set = 1;
10386 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10387 v6_address_set = 1;
10392 if (sw_if_index_set == 0)
10394 errmsg ("missing interface name or sw_if_index");
10397 if (!v6_address_set)
10399 errmsg ("no address set");
10403 /* Construct the API message */
10404 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10406 mp->sw_if_index = ntohl (sw_if_index);
10407 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10412 /* Wait for a reply, return good/bad news */
10418 api_ip6nd_proxy_add_del (vat_main_t * vam)
10420 unformat_input_t *i = vam->input;
10421 vl_api_ip6nd_proxy_add_del_t *mp;
10422 u32 sw_if_index = ~0;
10423 u8 v6_address_set = 0;
10424 ip6_address_t v6address;
10428 /* Parse args required to build the message */
10429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10431 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10433 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10435 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10436 v6_address_set = 1;
10437 if (unformat (i, "del"))
10441 clib_warning ("parse error '%U'", format_unformat_error, i);
10446 if (sw_if_index == ~0)
10448 errmsg ("missing interface name or sw_if_index");
10451 if (!v6_address_set)
10453 errmsg ("no address set");
10457 /* Construct the API message */
10458 M (IP6ND_PROXY_ADD_DEL, mp);
10460 mp->is_del = is_del;
10461 mp->sw_if_index = ntohl (sw_if_index);
10462 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10467 /* Wait for a reply, return good/bad news */
10473 api_ip6nd_proxy_dump (vat_main_t * vam)
10475 vl_api_ip6nd_proxy_dump_t *mp;
10476 vl_api_control_ping_t *mp_ping;
10479 M (IP6ND_PROXY_DUMP, mp);
10483 /* Use a control ping for synchronization */
10484 MPING (CONTROL_PING, mp_ping);
10491 static void vl_api_ip6nd_proxy_details_t_handler
10492 (vl_api_ip6nd_proxy_details_t * mp)
10494 vat_main_t *vam = &vat_main;
10496 print (vam->ofp, "host %U sw_if_index %d",
10497 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10500 static void vl_api_ip6nd_proxy_details_t_handler_json
10501 (vl_api_ip6nd_proxy_details_t * mp)
10503 vat_main_t *vam = &vat_main;
10504 struct in6_addr ip6;
10505 vat_json_node_t *node = NULL;
10507 if (VAT_JSON_ARRAY != vam->json_tree.type)
10509 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10510 vat_json_init_array (&vam->json_tree);
10512 node = vat_json_array_add (&vam->json_tree);
10514 vat_json_init_object (node);
10515 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10517 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10518 vat_json_object_add_ip6 (node, "host", ip6);
10522 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10524 unformat_input_t *i = vam->input;
10525 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10527 u8 sw_if_index_set = 0;
10528 u32 address_length = 0;
10529 u8 v6_address_set = 0;
10530 ip6_address_t v6address;
10531 u8 use_default = 0;
10532 u8 no_advertise = 0;
10534 u8 no_autoconfig = 0;
10537 u32 val_lifetime = 0;
10538 u32 pref_lifetime = 0;
10541 /* Parse args required to build the message */
10542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10544 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10545 sw_if_index_set = 1;
10546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10547 sw_if_index_set = 1;
10548 else if (unformat (i, "%U/%d",
10549 unformat_ip6_address, &v6address, &address_length))
10550 v6_address_set = 1;
10551 else if (unformat (i, "val_life %d", &val_lifetime))
10553 else if (unformat (i, "pref_life %d", &pref_lifetime))
10555 else if (unformat (i, "def"))
10557 else if (unformat (i, "noadv"))
10559 else if (unformat (i, "offl"))
10561 else if (unformat (i, "noauto"))
10563 else if (unformat (i, "nolink"))
10565 else if (unformat (i, "isno"))
10569 clib_warning ("parse error '%U'", format_unformat_error, i);
10574 if (sw_if_index_set == 0)
10576 errmsg ("missing interface name or sw_if_index");
10579 if (!v6_address_set)
10581 errmsg ("no address set");
10585 /* Construct the API message */
10586 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10588 mp->sw_if_index = ntohl (sw_if_index);
10589 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10590 mp->address_length = address_length;
10591 mp->use_default = use_default;
10592 mp->no_advertise = no_advertise;
10593 mp->off_link = off_link;
10594 mp->no_autoconfig = no_autoconfig;
10595 mp->no_onlink = no_onlink;
10597 mp->val_lifetime = ntohl (val_lifetime);
10598 mp->pref_lifetime = ntohl (pref_lifetime);
10603 /* Wait for a reply, return good/bad news */
10609 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10611 unformat_input_t *i = vam->input;
10612 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10614 u8 sw_if_index_set = 0;
10619 u8 send_unicast = 0;
10622 u8 default_router = 0;
10623 u32 max_interval = 0;
10624 u32 min_interval = 0;
10626 u32 initial_count = 0;
10627 u32 initial_interval = 0;
10631 /* Parse args required to build the message */
10632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10635 sw_if_index_set = 1;
10636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10637 sw_if_index_set = 1;
10638 else if (unformat (i, "maxint %d", &max_interval))
10640 else if (unformat (i, "minint %d", &min_interval))
10642 else if (unformat (i, "life %d", &lifetime))
10644 else if (unformat (i, "count %d", &initial_count))
10646 else if (unformat (i, "interval %d", &initial_interval))
10648 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10650 else if (unformat (i, "managed"))
10652 else if (unformat (i, "other"))
10654 else if (unformat (i, "ll"))
10656 else if (unformat (i, "send"))
10658 else if (unformat (i, "cease"))
10660 else if (unformat (i, "isno"))
10662 else if (unformat (i, "def"))
10663 default_router = 1;
10666 clib_warning ("parse error '%U'", format_unformat_error, i);
10671 if (sw_if_index_set == 0)
10673 errmsg ("missing interface name or sw_if_index");
10677 /* Construct the API message */
10678 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10680 mp->sw_if_index = ntohl (sw_if_index);
10681 mp->max_interval = ntohl (max_interval);
10682 mp->min_interval = ntohl (min_interval);
10683 mp->lifetime = ntohl (lifetime);
10684 mp->initial_count = ntohl (initial_count);
10685 mp->initial_interval = ntohl (initial_interval);
10686 mp->suppress = suppress;
10687 mp->managed = managed;
10689 mp->ll_option = ll_option;
10690 mp->send_unicast = send_unicast;
10693 mp->default_router = default_router;
10698 /* Wait for a reply, return good/bad news */
10704 api_set_arp_neighbor_limit (vat_main_t * vam)
10706 unformat_input_t *i = vam->input;
10707 vl_api_set_arp_neighbor_limit_t *mp;
10713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10715 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10717 else if (unformat (i, "ipv6"))
10721 clib_warning ("parse error '%U'", format_unformat_error, i);
10726 if (limit_set == 0)
10728 errmsg ("missing limit value");
10732 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10734 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10735 mp->is_ipv6 = is_ipv6;
10743 api_l2_patch_add_del (vat_main_t * vam)
10745 unformat_input_t *i = vam->input;
10746 vl_api_l2_patch_add_del_t *mp;
10747 u32 rx_sw_if_index;
10748 u8 rx_sw_if_index_set = 0;
10749 u32 tx_sw_if_index;
10750 u8 tx_sw_if_index_set = 0;
10754 /* Parse args required to build the message */
10755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10757 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10758 rx_sw_if_index_set = 1;
10759 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10760 tx_sw_if_index_set = 1;
10761 else if (unformat (i, "rx"))
10763 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10765 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10767 rx_sw_if_index_set = 1;
10772 else if (unformat (i, "tx"))
10774 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10776 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10778 tx_sw_if_index_set = 1;
10783 else if (unformat (i, "del"))
10789 if (rx_sw_if_index_set == 0)
10791 errmsg ("missing rx interface name or rx_sw_if_index");
10795 if (tx_sw_if_index_set == 0)
10797 errmsg ("missing tx interface name or tx_sw_if_index");
10801 M (L2_PATCH_ADD_DEL, mp);
10803 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10804 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10805 mp->is_add = is_add;
10813 u8 localsid_addr[16];
10822 api_sr_localsid_add_del (vat_main_t * vam)
10824 unformat_input_t *i = vam->input;
10825 vl_api_sr_localsid_add_del_t *mp;
10828 ip6_address_t localsid;
10832 u32 fib_table = ~(u32) 0;
10833 ip6_address_t next_hop;
10835 bool nexthop_set = 0;
10839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10841 if (unformat (i, "del"))
10843 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10844 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10846 else if (unformat (i, "behavior %u", &behavior));
10847 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10848 else if (unformat (i, "fib-table %u", &fib_table));
10849 else if (unformat (i, "end.psp %u", &behavior));
10854 M (SR_LOCALSID_ADD_DEL, mp);
10856 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10858 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10859 mp->behavior = behavior;
10860 mp->sw_if_index = ntohl (sw_if_index);
10861 mp->fib_table = ntohl (fib_table);
10862 mp->end_psp = end_psp;
10863 mp->is_del = is_del;
10871 api_ioam_enable (vat_main_t * vam)
10873 unformat_input_t *input = vam->input;
10874 vl_api_ioam_enable_t *mp;
10876 int has_trace_option = 0;
10877 int has_pot_option = 0;
10878 int has_seqno_option = 0;
10879 int has_analyse_option = 0;
10882 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10884 if (unformat (input, "trace"))
10885 has_trace_option = 1;
10886 else if (unformat (input, "pot"))
10887 has_pot_option = 1;
10888 else if (unformat (input, "seqno"))
10889 has_seqno_option = 1;
10890 else if (unformat (input, "analyse"))
10891 has_analyse_option = 1;
10895 M (IOAM_ENABLE, mp);
10896 mp->id = htons (id);
10897 mp->seqno = has_seqno_option;
10898 mp->analyse = has_analyse_option;
10899 mp->pot_enable = has_pot_option;
10900 mp->trace_enable = has_trace_option;
10909 api_ioam_disable (vat_main_t * vam)
10911 vl_api_ioam_disable_t *mp;
10914 M (IOAM_DISABLE, mp);
10920 #define foreach_tcp_proto_field \
10924 #define foreach_udp_proto_field \
10928 #define foreach_ip4_proto_field \
10940 u16 src_port, dst_port;
10943 #if VPP_API_TEST_BUILTIN == 0
10945 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10947 u8 **maskp = va_arg (*args, u8 **);
10949 u8 found_something = 0;
10952 #define _(a) u8 a=0;
10953 foreach_tcp_proto_field;
10956 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10959 #define _(a) else if (unformat (input, #a)) a=1;
10960 foreach_tcp_proto_field
10966 #define _(a) found_something += a;
10967 foreach_tcp_proto_field;
10970 if (found_something == 0)
10973 vec_validate (mask, sizeof (*tcp) - 1);
10975 tcp = (tcp_header_t *) mask;
10977 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10978 foreach_tcp_proto_field;
10986 unformat_udp_mask (unformat_input_t * input, va_list * args)
10988 u8 **maskp = va_arg (*args, u8 **);
10990 u8 found_something = 0;
10993 #define _(a) u8 a=0;
10994 foreach_udp_proto_field;
10997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11000 #define _(a) else if (unformat (input, #a)) a=1;
11001 foreach_udp_proto_field
11007 #define _(a) found_something += a;
11008 foreach_udp_proto_field;
11011 if (found_something == 0)
11014 vec_validate (mask, sizeof (*udp) - 1);
11016 udp = (udp_header_t *) mask;
11018 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
11019 foreach_udp_proto_field;
11027 unformat_l4_mask (unformat_input_t * input, va_list * args)
11029 u8 **maskp = va_arg (*args, u8 **);
11030 u16 src_port = 0, dst_port = 0;
11031 tcpudp_header_t *tcpudp;
11033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11035 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
11037 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
11039 else if (unformat (input, "src_port"))
11041 else if (unformat (input, "dst_port"))
11047 if (!src_port && !dst_port)
11051 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
11053 tcpudp = (tcpudp_header_t *) mask;
11054 tcpudp->src_port = src_port;
11055 tcpudp->dst_port = dst_port;
11063 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11065 u8 **maskp = va_arg (*args, u8 **);
11067 u8 found_something = 0;
11070 #define _(a) u8 a=0;
11071 foreach_ip4_proto_field;
11077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11079 if (unformat (input, "version"))
11081 else if (unformat (input, "hdr_length"))
11083 else if (unformat (input, "src"))
11085 else if (unformat (input, "dst"))
11087 else if (unformat (input, "proto"))
11090 #define _(a) else if (unformat (input, #a)) a=1;
11091 foreach_ip4_proto_field
11097 #define _(a) found_something += a;
11098 foreach_ip4_proto_field;
11101 if (found_something == 0)
11104 vec_validate (mask, sizeof (*ip) - 1);
11106 ip = (ip4_header_t *) mask;
11108 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11109 foreach_ip4_proto_field;
11112 ip->ip_version_and_header_length = 0;
11115 ip->ip_version_and_header_length |= 0xF0;
11118 ip->ip_version_and_header_length |= 0x0F;
11124 #define foreach_ip6_proto_field \
11127 _(payload_length) \
11132 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11134 u8 **maskp = va_arg (*args, u8 **);
11136 u8 found_something = 0;
11138 u32 ip_version_traffic_class_and_flow_label;
11140 #define _(a) u8 a=0;
11141 foreach_ip6_proto_field;
11144 u8 traffic_class = 0;
11147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11149 if (unformat (input, "version"))
11151 else if (unformat (input, "traffic-class"))
11153 else if (unformat (input, "flow-label"))
11155 else if (unformat (input, "src"))
11157 else if (unformat (input, "dst"))
11159 else if (unformat (input, "proto"))
11162 #define _(a) else if (unformat (input, #a)) a=1;
11163 foreach_ip6_proto_field
11169 #define _(a) found_something += a;
11170 foreach_ip6_proto_field;
11173 if (found_something == 0)
11176 vec_validate (mask, sizeof (*ip) - 1);
11178 ip = (ip6_header_t *) mask;
11180 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11181 foreach_ip6_proto_field;
11184 ip_version_traffic_class_and_flow_label = 0;
11187 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11190 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11193 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11195 ip->ip_version_traffic_class_and_flow_label =
11196 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11203 unformat_l3_mask (unformat_input_t * input, va_list * args)
11205 u8 **maskp = va_arg (*args, u8 **);
11207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11209 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11211 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11220 unformat_l2_mask (unformat_input_t * input, va_list * args)
11222 u8 **maskp = va_arg (*args, u8 **);
11229 u8 ignore_tag1 = 0;
11230 u8 ignore_tag2 = 0;
11237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11239 if (unformat (input, "src"))
11241 else if (unformat (input, "dst"))
11243 else if (unformat (input, "proto"))
11245 else if (unformat (input, "tag1"))
11247 else if (unformat (input, "tag2"))
11249 else if (unformat (input, "ignore-tag1"))
11251 else if (unformat (input, "ignore-tag2"))
11253 else if (unformat (input, "cos1"))
11255 else if (unformat (input, "cos2"))
11257 else if (unformat (input, "dot1q"))
11259 else if (unformat (input, "dot1ad"))
11264 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11265 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11268 if (tag1 || ignore_tag1 || cos1 || dot1q)
11270 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11273 vec_validate (mask, len - 1);
11276 memset (mask, 0xff, 6);
11279 memset (mask + 6, 0xff, 6);
11281 if (tag2 || dot1ad)
11283 /* inner vlan tag */
11292 mask[21] = mask[20] = 0xff;
11313 mask[16] = mask[17] = 0xff;
11323 mask[12] = mask[13] = 0xff;
11330 unformat_classify_mask (unformat_input_t * input, va_list * args)
11332 u8 **maskp = va_arg (*args, u8 **);
11333 u32 *skipp = va_arg (*args, u32 *);
11334 u32 *matchp = va_arg (*args, u32 *);
11342 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11344 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11346 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11348 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11350 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11364 if (mask || l2 || l3 || l4)
11366 if (l2 || l3 || l4)
11368 /* "With a free Ethernet header in every package" */
11370 vec_validate (l2, 13);
11374 vec_append (mask, l3);
11379 vec_append (mask, l4);
11384 /* Scan forward looking for the first significant mask octet */
11385 for (i = 0; i < vec_len (mask); i++)
11389 /* compute (skip, match) params */
11390 *skipp = i / sizeof (u32x4);
11391 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11393 /* Pad mask to an even multiple of the vector size */
11394 while (vec_len (mask) % sizeof (u32x4))
11395 vec_add1 (mask, 0);
11397 match = vec_len (mask) / sizeof (u32x4);
11399 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11401 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11402 if (*tmp || *(tmp + 1))
11407 clib_warning ("BUG: match 0");
11409 _vec_len (mask) = match * sizeof (u32x4);
11419 #endif /* VPP_API_TEST_BUILTIN */
11421 #define foreach_l2_next \
11423 _(ethernet, ETHERNET_INPUT) \
11424 _(ip4, IP4_INPUT) \
11428 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11430 u32 *miss_next_indexp = va_arg (*args, u32 *);
11431 u32 next_index = 0;
11435 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11439 if (unformat (input, "%d", &tmp))
11448 *miss_next_indexp = next_index;
11452 #define foreach_ip_next \
11455 _(rewrite, REWRITE)
11458 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11460 u32 *miss_next_indexp = va_arg (*args, u32 *);
11461 u32 next_index = 0;
11465 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11469 if (unformat (input, "%d", &tmp))
11478 *miss_next_indexp = next_index;
11482 #define foreach_acl_next \
11486 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11488 u32 *miss_next_indexp = va_arg (*args, u32 *);
11489 u32 next_index = 0;
11493 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11497 if (unformat (input, "permit"))
11502 else if (unformat (input, "%d", &tmp))
11511 *miss_next_indexp = next_index;
11516 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11518 u32 *r = va_arg (*args, u32 *);
11520 if (unformat (input, "conform-color"))
11521 *r = POLICE_CONFORM;
11522 else if (unformat (input, "exceed-color"))
11523 *r = POLICE_EXCEED;
11531 api_classify_add_del_table (vat_main_t * vam)
11533 unformat_input_t *i = vam->input;
11534 vl_api_classify_add_del_table_t *mp;
11541 u32 table_index = ~0;
11542 u32 next_table_index = ~0;
11543 u32 miss_next_index = ~0;
11544 u32 memory_size = 32 << 20;
11546 u32 current_data_flag = 0;
11547 int current_data_offset = 0;
11550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11552 if (unformat (i, "del"))
11554 else if (unformat (i, "del-chain"))
11559 else if (unformat (i, "buckets %d", &nbuckets))
11561 else if (unformat (i, "memory_size %d", &memory_size))
11563 else if (unformat (i, "skip %d", &skip))
11565 else if (unformat (i, "match %d", &match))
11567 else if (unformat (i, "table %d", &table_index))
11569 else if (unformat (i, "mask %U", unformat_classify_mask,
11570 &mask, &skip, &match))
11572 else if (unformat (i, "next-table %d", &next_table_index))
11574 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11577 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11580 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11583 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11585 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11591 if (is_add && mask == 0)
11593 errmsg ("Mask required");
11597 if (is_add && skip == ~0)
11599 errmsg ("skip count required");
11603 if (is_add && match == ~0)
11605 errmsg ("match count required");
11609 if (!is_add && table_index == ~0)
11611 errmsg ("table index required for delete");
11615 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11617 mp->is_add = is_add;
11618 mp->del_chain = del_chain;
11619 mp->table_index = ntohl (table_index);
11620 mp->nbuckets = ntohl (nbuckets);
11621 mp->memory_size = ntohl (memory_size);
11622 mp->skip_n_vectors = ntohl (skip);
11623 mp->match_n_vectors = ntohl (match);
11624 mp->next_table_index = ntohl (next_table_index);
11625 mp->miss_next_index = ntohl (miss_next_index);
11626 mp->current_data_flag = ntohl (current_data_flag);
11627 mp->current_data_offset = ntohl (current_data_offset);
11628 clib_memcpy (mp->mask, mask, vec_len (mask));
11637 #if VPP_API_TEST_BUILTIN == 0
11639 unformat_l4_match (unformat_input_t * input, va_list * args)
11641 u8 **matchp = va_arg (*args, u8 **);
11643 u8 *proto_header = 0;
11649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11651 if (unformat (input, "src_port %d", &src_port))
11653 else if (unformat (input, "dst_port %d", &dst_port))
11659 h.src_port = clib_host_to_net_u16 (src_port);
11660 h.dst_port = clib_host_to_net_u16 (dst_port);
11661 vec_validate (proto_header, sizeof (h) - 1);
11662 memcpy (proto_header, &h, sizeof (h));
11664 *matchp = proto_header;
11670 unformat_ip4_match (unformat_input_t * input, va_list * args)
11672 u8 **matchp = va_arg (*args, u8 **);
11677 int hdr_length = 0;
11678 u32 hdr_length_val;
11679 int src = 0, dst = 0;
11680 ip4_address_t src_val, dst_val;
11687 int fragment_id = 0;
11688 u32 fragment_id_val;
11694 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11696 if (unformat (input, "version %d", &version_val))
11698 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11700 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11702 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11704 else if (unformat (input, "proto %d", &proto_val))
11706 else if (unformat (input, "tos %d", &tos_val))
11708 else if (unformat (input, "length %d", &length_val))
11710 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11712 else if (unformat (input, "ttl %d", &ttl_val))
11714 else if (unformat (input, "checksum %d", &checksum_val))
11720 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11721 + ttl + checksum == 0)
11725 * Aligned because we use the real comparison functions
11727 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11729 ip = (ip4_header_t *) match;
11731 /* These are realistically matched in practice */
11733 ip->src_address.as_u32 = src_val.as_u32;
11736 ip->dst_address.as_u32 = dst_val.as_u32;
11739 ip->protocol = proto_val;
11742 /* These are not, but they're included for completeness */
11744 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11747 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11753 ip->length = clib_host_to_net_u16 (length_val);
11759 ip->checksum = clib_host_to_net_u16 (checksum_val);
11766 unformat_ip6_match (unformat_input_t * input, va_list * args)
11768 u8 **matchp = va_arg (*args, u8 **);
11773 u8 traffic_class = 0;
11774 u32 traffic_class_val = 0;
11777 int src = 0, dst = 0;
11778 ip6_address_t src_val, dst_val;
11781 int payload_length = 0;
11782 u32 payload_length_val;
11785 u32 ip_version_traffic_class_and_flow_label;
11787 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11789 if (unformat (input, "version %d", &version_val))
11791 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11793 else if (unformat (input, "flow_label %d", &flow_label_val))
11795 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11797 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11799 else if (unformat (input, "proto %d", &proto_val))
11801 else if (unformat (input, "payload_length %d", &payload_length_val))
11802 payload_length = 1;
11803 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11809 if (version + traffic_class + flow_label + src + dst + proto +
11810 payload_length + hop_limit == 0)
11814 * Aligned because we use the real comparison functions
11816 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11818 ip = (ip6_header_t *) match;
11821 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11824 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11827 ip->protocol = proto_val;
11829 ip_version_traffic_class_and_flow_label = 0;
11832 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11835 ip_version_traffic_class_and_flow_label |=
11836 (traffic_class_val & 0xFF) << 20;
11839 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11841 ip->ip_version_traffic_class_and_flow_label =
11842 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11844 if (payload_length)
11845 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11848 ip->hop_limit = hop_limit_val;
11855 unformat_l3_match (unformat_input_t * input, va_list * args)
11857 u8 **matchp = va_arg (*args, u8 **);
11859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11861 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11863 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11872 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11874 u8 *tagp = va_arg (*args, u8 *);
11877 if (unformat (input, "%d", &tag))
11879 tagp[0] = (tag >> 8) & 0x0F;
11880 tagp[1] = tag & 0xFF;
11888 unformat_l2_match (unformat_input_t * input, va_list * args)
11890 u8 **matchp = va_arg (*args, u8 **);
11903 u8 ignore_tag1 = 0;
11904 u8 ignore_tag2 = 0;
11910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11912 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11915 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11917 else if (unformat (input, "proto %U",
11918 unformat_ethernet_type_host_byte_order, &proto_val))
11920 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11922 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11924 else if (unformat (input, "ignore-tag1"))
11926 else if (unformat (input, "ignore-tag2"))
11928 else if (unformat (input, "cos1 %d", &cos1_val))
11930 else if (unformat (input, "cos2 %d", &cos2_val))
11935 if ((src + dst + proto + tag1 + tag2 +
11936 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11939 if (tag1 || ignore_tag1 || cos1)
11941 if (tag2 || ignore_tag2 || cos2)
11944 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11947 clib_memcpy (match, dst_val, 6);
11950 clib_memcpy (match + 6, src_val, 6);
11954 /* inner vlan tag */
11955 match[19] = tag2_val[1];
11956 match[18] = tag2_val[0];
11958 match[18] |= (cos2_val & 0x7) << 5;
11961 match[21] = proto_val & 0xff;
11962 match[20] = proto_val >> 8;
11966 match[15] = tag1_val[1];
11967 match[14] = tag1_val[0];
11970 match[14] |= (cos1_val & 0x7) << 5;
11976 match[15] = tag1_val[1];
11977 match[14] = tag1_val[0];
11980 match[17] = proto_val & 0xff;
11981 match[16] = proto_val >> 8;
11984 match[14] |= (cos1_val & 0x7) << 5;
11990 match[18] |= (cos2_val & 0x7) << 5;
11992 match[14] |= (cos1_val & 0x7) << 5;
11995 match[13] = proto_val & 0xff;
11996 match[12] = proto_val >> 8;
12004 unformat_qos_source (unformat_input_t * input, va_list * args)
12006 int *qs = va_arg (*args, int *);
12008 if (unformat (input, "ip"))
12009 *qs = QOS_SOURCE_IP;
12010 else if (unformat (input, "mpls"))
12011 *qs = QOS_SOURCE_MPLS;
12012 else if (unformat (input, "ext"))
12013 *qs = QOS_SOURCE_EXT;
12014 else if (unformat (input, "vlan"))
12015 *qs = QOS_SOURCE_VLAN;
12024 api_unformat_classify_match (unformat_input_t * input, va_list * args)
12026 u8 **matchp = va_arg (*args, u8 **);
12027 u32 skip_n_vectors = va_arg (*args, u32);
12028 u32 match_n_vectors = va_arg (*args, u32);
12035 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12037 if (unformat (input, "hex %U", unformat_hex_string, &match))
12039 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
12041 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
12043 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
12057 if (match || l2 || l3 || l4)
12059 if (l2 || l3 || l4)
12061 /* "Win a free Ethernet header in every packet" */
12063 vec_validate_aligned (l2, 13, sizeof (u32x4));
12067 vec_append_aligned (match, l3, sizeof (u32x4));
12072 vec_append_aligned (match, l4, sizeof (u32x4));
12077 /* Make sure the vector is big enough even if key is all 0's */
12078 vec_validate_aligned
12079 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12082 /* Set size, include skipped vectors */
12083 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12094 api_classify_add_del_session (vat_main_t * vam)
12096 unformat_input_t *i = vam->input;
12097 vl_api_classify_add_del_session_t *mp;
12099 u32 table_index = ~0;
12100 u32 hit_next_index = ~0;
12101 u32 opaque_index = ~0;
12104 u32 skip_n_vectors = 0;
12105 u32 match_n_vectors = 0;
12111 * Warning: you have to supply skip_n and match_n
12112 * because the API client cant simply look at the classify
12116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12118 if (unformat (i, "del"))
12120 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12123 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12126 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12129 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12131 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12133 else if (unformat (i, "opaque-index %d", &opaque_index))
12135 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12137 else if (unformat (i, "match_n %d", &match_n_vectors))
12139 else if (unformat (i, "match %U", api_unformat_classify_match,
12140 &match, skip_n_vectors, match_n_vectors))
12142 else if (unformat (i, "advance %d", &advance))
12144 else if (unformat (i, "table-index %d", &table_index))
12146 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12148 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12150 else if (unformat (i, "action %d", &action))
12152 else if (unformat (i, "metadata %d", &metadata))
12158 if (table_index == ~0)
12160 errmsg ("Table index required");
12164 if (is_add && match == 0)
12166 errmsg ("Match value required");
12170 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12172 mp->is_add = is_add;
12173 mp->table_index = ntohl (table_index);
12174 mp->hit_next_index = ntohl (hit_next_index);
12175 mp->opaque_index = ntohl (opaque_index);
12176 mp->advance = ntohl (advance);
12177 mp->action = action;
12178 mp->metadata = ntohl (metadata);
12179 clib_memcpy (mp->match, match, vec_len (match));
12188 api_classify_set_interface_ip_table (vat_main_t * vam)
12190 unformat_input_t *i = vam->input;
12191 vl_api_classify_set_interface_ip_table_t *mp;
12193 int sw_if_index_set;
12194 u32 table_index = ~0;
12198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12201 sw_if_index_set = 1;
12202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12203 sw_if_index_set = 1;
12204 else if (unformat (i, "table %d", &table_index))
12208 clib_warning ("parse error '%U'", format_unformat_error, i);
12213 if (sw_if_index_set == 0)
12215 errmsg ("missing interface name or sw_if_index");
12220 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12222 mp->sw_if_index = ntohl (sw_if_index);
12223 mp->table_index = ntohl (table_index);
12224 mp->is_ipv6 = is_ipv6;
12232 api_classify_set_interface_l2_tables (vat_main_t * vam)
12234 unformat_input_t *i = vam->input;
12235 vl_api_classify_set_interface_l2_tables_t *mp;
12237 int sw_if_index_set;
12238 u32 ip4_table_index = ~0;
12239 u32 ip6_table_index = ~0;
12240 u32 other_table_index = ~0;
12244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12246 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12247 sw_if_index_set = 1;
12248 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12249 sw_if_index_set = 1;
12250 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12252 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12254 else if (unformat (i, "other-table %d", &other_table_index))
12256 else if (unformat (i, "is-input %d", &is_input))
12260 clib_warning ("parse error '%U'", format_unformat_error, i);
12265 if (sw_if_index_set == 0)
12267 errmsg ("missing interface name or sw_if_index");
12272 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12274 mp->sw_if_index = ntohl (sw_if_index);
12275 mp->ip4_table_index = ntohl (ip4_table_index);
12276 mp->ip6_table_index = ntohl (ip6_table_index);
12277 mp->other_table_index = ntohl (other_table_index);
12278 mp->is_input = (u8) is_input;
12286 api_set_ipfix_exporter (vat_main_t * vam)
12288 unformat_input_t *i = vam->input;
12289 vl_api_set_ipfix_exporter_t *mp;
12290 ip4_address_t collector_address;
12291 u8 collector_address_set = 0;
12292 u32 collector_port = ~0;
12293 ip4_address_t src_address;
12294 u8 src_address_set = 0;
12297 u32 template_interval = ~0;
12298 u8 udp_checksum = 0;
12301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12303 if (unformat (i, "collector_address %U", unformat_ip4_address,
12304 &collector_address))
12305 collector_address_set = 1;
12306 else if (unformat (i, "collector_port %d", &collector_port))
12308 else if (unformat (i, "src_address %U", unformat_ip4_address,
12310 src_address_set = 1;
12311 else if (unformat (i, "vrf_id %d", &vrf_id))
12313 else if (unformat (i, "path_mtu %d", &path_mtu))
12315 else if (unformat (i, "template_interval %d", &template_interval))
12317 else if (unformat (i, "udp_checksum"))
12323 if (collector_address_set == 0)
12325 errmsg ("collector_address required");
12329 if (src_address_set == 0)
12331 errmsg ("src_address required");
12335 M (SET_IPFIX_EXPORTER, mp);
12337 memcpy (mp->collector_address, collector_address.data,
12338 sizeof (collector_address.data));
12339 mp->collector_port = htons ((u16) collector_port);
12340 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12341 mp->vrf_id = htonl (vrf_id);
12342 mp->path_mtu = htonl (path_mtu);
12343 mp->template_interval = htonl (template_interval);
12344 mp->udp_checksum = udp_checksum;
12352 api_set_ipfix_classify_stream (vat_main_t * vam)
12354 unformat_input_t *i = vam->input;
12355 vl_api_set_ipfix_classify_stream_t *mp;
12357 u32 src_port = UDP_DST_PORT_ipfix;
12360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12362 if (unformat (i, "domain %d", &domain_id))
12364 else if (unformat (i, "src_port %d", &src_port))
12368 errmsg ("unknown input `%U'", format_unformat_error, i);
12373 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12375 mp->domain_id = htonl (domain_id);
12376 mp->src_port = htons ((u16) src_port);
12384 api_ipfix_classify_table_add_del (vat_main_t * vam)
12386 unformat_input_t *i = vam->input;
12387 vl_api_ipfix_classify_table_add_del_t *mp;
12389 u32 classify_table_index = ~0;
12391 u8 transport_protocol = 255;
12394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12396 if (unformat (i, "add"))
12398 else if (unformat (i, "del"))
12400 else if (unformat (i, "table %d", &classify_table_index))
12402 else if (unformat (i, "ip4"))
12404 else if (unformat (i, "ip6"))
12406 else if (unformat (i, "tcp"))
12407 transport_protocol = 6;
12408 else if (unformat (i, "udp"))
12409 transport_protocol = 17;
12412 errmsg ("unknown input `%U'", format_unformat_error, i);
12419 errmsg ("expecting: add|del");
12422 if (classify_table_index == ~0)
12424 errmsg ("classifier table not specified");
12427 if (ip_version == 0)
12429 errmsg ("IP version not specified");
12433 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12435 mp->is_add = is_add;
12436 mp->table_id = htonl (classify_table_index);
12437 mp->ip_version = ip_version;
12438 mp->transport_protocol = transport_protocol;
12446 api_get_node_index (vat_main_t * vam)
12448 unformat_input_t *i = vam->input;
12449 vl_api_get_node_index_t *mp;
12453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12455 if (unformat (i, "node %s", &name))
12462 errmsg ("node name required");
12465 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12467 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12471 M (GET_NODE_INDEX, mp);
12472 clib_memcpy (mp->node_name, name, vec_len (name));
12481 api_get_next_index (vat_main_t * vam)
12483 unformat_input_t *i = vam->input;
12484 vl_api_get_next_index_t *mp;
12485 u8 *node_name = 0, *next_node_name = 0;
12488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12490 if (unformat (i, "node-name %s", &node_name))
12492 else if (unformat (i, "next-node-name %s", &next_node_name))
12496 if (node_name == 0)
12498 errmsg ("node name required");
12501 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12503 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12507 if (next_node_name == 0)
12509 errmsg ("next node name required");
12512 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12514 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12518 M (GET_NEXT_INDEX, mp);
12519 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12520 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12521 vec_free (node_name);
12522 vec_free (next_node_name);
12530 api_add_node_next (vat_main_t * vam)
12532 unformat_input_t *i = vam->input;
12533 vl_api_add_node_next_t *mp;
12538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12540 if (unformat (i, "node %s", &name))
12542 else if (unformat (i, "next %s", &next))
12549 errmsg ("node name required");
12552 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12554 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12559 errmsg ("next node required");
12562 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12564 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12568 M (ADD_NODE_NEXT, mp);
12569 clib_memcpy (mp->node_name, name, vec_len (name));
12570 clib_memcpy (mp->next_name, next, vec_len (next));
12580 api_l2tpv3_create_tunnel (vat_main_t * vam)
12582 unformat_input_t *i = vam->input;
12583 ip6_address_t client_address, our_address;
12584 int client_address_set = 0;
12585 int our_address_set = 0;
12586 u32 local_session_id = 0;
12587 u32 remote_session_id = 0;
12588 u64 local_cookie = 0;
12589 u64 remote_cookie = 0;
12590 u8 l2_sublayer_present = 0;
12591 vl_api_l2tpv3_create_tunnel_t *mp;
12594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12596 if (unformat (i, "client_address %U", unformat_ip6_address,
12598 client_address_set = 1;
12599 else if (unformat (i, "our_address %U", unformat_ip6_address,
12601 our_address_set = 1;
12602 else if (unformat (i, "local_session_id %d", &local_session_id))
12604 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12606 else if (unformat (i, "local_cookie %lld", &local_cookie))
12608 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12610 else if (unformat (i, "l2-sublayer-present"))
12611 l2_sublayer_present = 1;
12616 if (client_address_set == 0)
12618 errmsg ("client_address required");
12622 if (our_address_set == 0)
12624 errmsg ("our_address required");
12628 M (L2TPV3_CREATE_TUNNEL, mp);
12630 clib_memcpy (mp->client_address, client_address.as_u8,
12631 sizeof (mp->client_address));
12633 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12635 mp->local_session_id = ntohl (local_session_id);
12636 mp->remote_session_id = ntohl (remote_session_id);
12637 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12638 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12639 mp->l2_sublayer_present = l2_sublayer_present;
12648 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12650 unformat_input_t *i = vam->input;
12652 u8 sw_if_index_set = 0;
12653 u64 new_local_cookie = 0;
12654 u64 new_remote_cookie = 0;
12655 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12660 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12661 sw_if_index_set = 1;
12662 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12663 sw_if_index_set = 1;
12664 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12666 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12672 if (sw_if_index_set == 0)
12674 errmsg ("missing interface name or sw_if_index");
12678 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12680 mp->sw_if_index = ntohl (sw_if_index);
12681 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12682 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12690 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12692 unformat_input_t *i = vam->input;
12693 vl_api_l2tpv3_interface_enable_disable_t *mp;
12695 u8 sw_if_index_set = 0;
12696 u8 enable_disable = 1;
12699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12701 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12702 sw_if_index_set = 1;
12703 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12704 sw_if_index_set = 1;
12705 else if (unformat (i, "enable"))
12706 enable_disable = 1;
12707 else if (unformat (i, "disable"))
12708 enable_disable = 0;
12713 if (sw_if_index_set == 0)
12715 errmsg ("missing interface name or sw_if_index");
12719 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12721 mp->sw_if_index = ntohl (sw_if_index);
12722 mp->enable_disable = enable_disable;
12730 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12732 unformat_input_t *i = vam->input;
12733 vl_api_l2tpv3_set_lookup_key_t *mp;
12737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12739 if (unformat (i, "lookup_v6_src"))
12740 key = L2T_LOOKUP_SRC_ADDRESS;
12741 else if (unformat (i, "lookup_v6_dst"))
12742 key = L2T_LOOKUP_DST_ADDRESS;
12743 else if (unformat (i, "lookup_session_id"))
12744 key = L2T_LOOKUP_SESSION_ID;
12749 if (key == (u8) ~ 0)
12751 errmsg ("l2tp session lookup key unset");
12755 M (L2TPV3_SET_LOOKUP_KEY, mp);
12764 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12765 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12767 vat_main_t *vam = &vat_main;
12769 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12770 format_ip6_address, mp->our_address,
12771 format_ip6_address, mp->client_address,
12772 clib_net_to_host_u32 (mp->sw_if_index));
12775 " local cookies %016llx %016llx remote cookie %016llx",
12776 clib_net_to_host_u64 (mp->local_cookie[0]),
12777 clib_net_to_host_u64 (mp->local_cookie[1]),
12778 clib_net_to_host_u64 (mp->remote_cookie));
12780 print (vam->ofp, " local session-id %d remote session-id %d",
12781 clib_net_to_host_u32 (mp->local_session_id),
12782 clib_net_to_host_u32 (mp->remote_session_id));
12784 print (vam->ofp, " l2 specific sublayer %s\n",
12785 mp->l2_sublayer_present ? "preset" : "absent");
12789 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12790 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12792 vat_main_t *vam = &vat_main;
12793 vat_json_node_t *node = NULL;
12794 struct in6_addr addr;
12796 if (VAT_JSON_ARRAY != vam->json_tree.type)
12798 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12799 vat_json_init_array (&vam->json_tree);
12801 node = vat_json_array_add (&vam->json_tree);
12803 vat_json_init_object (node);
12805 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12806 vat_json_object_add_ip6 (node, "our_address", addr);
12807 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12808 vat_json_object_add_ip6 (node, "client_address", addr);
12810 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12811 vat_json_init_array (lc);
12812 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12813 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12814 vat_json_object_add_uint (node, "remote_cookie",
12815 clib_net_to_host_u64 (mp->remote_cookie));
12817 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12818 vat_json_object_add_uint (node, "local_session_id",
12819 clib_net_to_host_u32 (mp->local_session_id));
12820 vat_json_object_add_uint (node, "remote_session_id",
12821 clib_net_to_host_u32 (mp->remote_session_id));
12822 vat_json_object_add_string_copy (node, "l2_sublayer",
12823 mp->l2_sublayer_present ? (u8 *) "present"
12824 : (u8 *) "absent");
12828 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12830 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12831 vl_api_control_ping_t *mp_ping;
12834 /* Get list of l2tpv3-tunnel interfaces */
12835 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12838 /* Use a control ping for synchronization */
12839 MPING (CONTROL_PING, mp_ping);
12847 static void vl_api_sw_interface_tap_details_t_handler
12848 (vl_api_sw_interface_tap_details_t * mp)
12850 vat_main_t *vam = &vat_main;
12852 print (vam->ofp, "%-16s %d",
12853 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12856 static void vl_api_sw_interface_tap_details_t_handler_json
12857 (vl_api_sw_interface_tap_details_t * mp)
12859 vat_main_t *vam = &vat_main;
12860 vat_json_node_t *node = NULL;
12862 if (VAT_JSON_ARRAY != vam->json_tree.type)
12864 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12865 vat_json_init_array (&vam->json_tree);
12867 node = vat_json_array_add (&vam->json_tree);
12869 vat_json_init_object (node);
12870 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12871 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12875 api_sw_interface_tap_dump (vat_main_t * vam)
12877 vl_api_sw_interface_tap_dump_t *mp;
12878 vl_api_control_ping_t *mp_ping;
12881 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12882 /* Get list of tap interfaces */
12883 M (SW_INTERFACE_TAP_DUMP, mp);
12886 /* Use a control ping for synchronization */
12887 MPING (CONTROL_PING, mp_ping);
12894 static void vl_api_sw_interface_tap_v2_details_t_handler
12895 (vl_api_sw_interface_tap_v2_details_t * mp)
12897 vat_main_t *vam = &vat_main;
12899 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12900 mp->host_ip4_prefix_len);
12901 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12902 mp->host_ip6_prefix_len);
12905 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12906 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12907 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12908 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12909 mp->host_bridge, ip4, ip6);
12915 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12916 (vl_api_sw_interface_tap_v2_details_t * mp)
12918 vat_main_t *vam = &vat_main;
12919 vat_json_node_t *node = NULL;
12921 if (VAT_JSON_ARRAY != vam->json_tree.type)
12923 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12924 vat_json_init_array (&vam->json_tree);
12926 node = vat_json_array_add (&vam->json_tree);
12928 vat_json_init_object (node);
12929 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12930 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12931 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12932 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12933 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12934 vat_json_object_add_string_copy (node, "host_mac_addr",
12935 format (0, "%U", format_ethernet_address,
12936 &mp->host_mac_addr));
12937 vat_json_object_add_string_copy (node, "host_namespace",
12938 mp->host_namespace);
12939 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12940 vat_json_object_add_string_copy (node, "host_ip4_addr",
12941 format (0, "%U/%d", format_ip4_address,
12943 mp->host_ip4_prefix_len));
12944 vat_json_object_add_string_copy (node, "host_ip6_addr",
12945 format (0, "%U/%d", format_ip6_address,
12947 mp->host_ip6_prefix_len));
12952 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12954 vl_api_sw_interface_tap_v2_dump_t *mp;
12955 vl_api_control_ping_t *mp_ping;
12959 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12960 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12961 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12964 /* Get list of tap interfaces */
12965 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12968 /* Use a control ping for synchronization */
12969 MPING (CONTROL_PING, mp_ping);
12976 static uword unformat_vxlan_decap_next
12977 (unformat_input_t * input, va_list * args)
12979 u32 *result = va_arg (*args, u32 *);
12982 if (unformat (input, "l2"))
12983 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12984 else if (unformat (input, "%d", &tmp))
12992 api_vxlan_add_del_tunnel (vat_main_t * vam)
12994 unformat_input_t *line_input = vam->input;
12995 vl_api_vxlan_add_del_tunnel_t *mp;
12996 ip46_address_t src, dst;
12998 u8 ipv4_set = 0, ipv6_set = 0;
13003 u32 mcast_sw_if_index = ~0;
13004 u32 encap_vrf_id = 0;
13005 u32 decap_next_index = ~0;
13009 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13010 memset (&src, 0, sizeof src);
13011 memset (&dst, 0, sizeof dst);
13013 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13015 if (unformat (line_input, "del"))
13017 else if (unformat (line_input, "instance %d", &instance))
13020 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13026 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13032 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13038 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13043 else if (unformat (line_input, "group %U %U",
13044 unformat_ip4_address, &dst.ip4,
13045 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13047 grp_set = dst_set = 1;
13050 else if (unformat (line_input, "group %U",
13051 unformat_ip4_address, &dst.ip4))
13053 grp_set = dst_set = 1;
13056 else if (unformat (line_input, "group %U %U",
13057 unformat_ip6_address, &dst.ip6,
13058 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13060 grp_set = dst_set = 1;
13063 else if (unformat (line_input, "group %U",
13064 unformat_ip6_address, &dst.ip6))
13066 grp_set = dst_set = 1;
13070 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13072 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13074 else if (unformat (line_input, "decap-next %U",
13075 unformat_vxlan_decap_next, &decap_next_index))
13077 else if (unformat (line_input, "vni %d", &vni))
13081 errmsg ("parse error '%U'", format_unformat_error, line_input);
13088 errmsg ("tunnel src address not specified");
13093 errmsg ("tunnel dst address not specified");
13097 if (grp_set && !ip46_address_is_multicast (&dst))
13099 errmsg ("tunnel group address not multicast");
13102 if (grp_set && mcast_sw_if_index == ~0)
13104 errmsg ("tunnel nonexistent multicast device");
13107 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13109 errmsg ("tunnel dst address must be unicast");
13114 if (ipv4_set && ipv6_set)
13116 errmsg ("both IPv4 and IPv6 addresses specified");
13120 if ((vni == 0) || (vni >> 24))
13122 errmsg ("vni not specified or out of range");
13126 M (VXLAN_ADD_DEL_TUNNEL, mp);
13130 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13131 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13135 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13136 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13139 mp->instance = htonl (instance);
13140 mp->encap_vrf_id = ntohl (encap_vrf_id);
13141 mp->decap_next_index = ntohl (decap_next_index);
13142 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13143 mp->vni = ntohl (vni);
13144 mp->is_add = is_add;
13145 mp->is_ipv6 = ipv6_set;
13152 static void vl_api_vxlan_tunnel_details_t_handler
13153 (vl_api_vxlan_tunnel_details_t * mp)
13155 vat_main_t *vam = &vat_main;
13156 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13157 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13159 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13160 ntohl (mp->sw_if_index),
13161 ntohl (mp->instance),
13162 format_ip46_address, &src, IP46_TYPE_ANY,
13163 format_ip46_address, &dst, IP46_TYPE_ANY,
13164 ntohl (mp->encap_vrf_id),
13165 ntohl (mp->decap_next_index), ntohl (mp->vni),
13166 ntohl (mp->mcast_sw_if_index));
13169 static void vl_api_vxlan_tunnel_details_t_handler_json
13170 (vl_api_vxlan_tunnel_details_t * mp)
13172 vat_main_t *vam = &vat_main;
13173 vat_json_node_t *node = NULL;
13175 if (VAT_JSON_ARRAY != vam->json_tree.type)
13177 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13178 vat_json_init_array (&vam->json_tree);
13180 node = vat_json_array_add (&vam->json_tree);
13182 vat_json_init_object (node);
13183 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13185 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13189 struct in6_addr ip6;
13191 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13192 vat_json_object_add_ip6 (node, "src_address", ip6);
13193 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13194 vat_json_object_add_ip6 (node, "dst_address", ip6);
13198 struct in_addr ip4;
13200 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13201 vat_json_object_add_ip4 (node, "src_address", ip4);
13202 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13203 vat_json_object_add_ip4 (node, "dst_address", ip4);
13205 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13206 vat_json_object_add_uint (node, "decap_next_index",
13207 ntohl (mp->decap_next_index));
13208 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13209 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13210 vat_json_object_add_uint (node, "mcast_sw_if_index",
13211 ntohl (mp->mcast_sw_if_index));
13215 api_vxlan_tunnel_dump (vat_main_t * vam)
13217 unformat_input_t *i = vam->input;
13218 vl_api_vxlan_tunnel_dump_t *mp;
13219 vl_api_control_ping_t *mp_ping;
13221 u8 sw_if_index_set = 0;
13224 /* Parse args required to build the message */
13225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13227 if (unformat (i, "sw_if_index %d", &sw_if_index))
13228 sw_if_index_set = 1;
13233 if (sw_if_index_set == 0)
13238 if (!vam->json_output)
13240 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13241 "sw_if_index", "instance", "src_address", "dst_address",
13242 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13245 /* Get list of vxlan-tunnel interfaces */
13246 M (VXLAN_TUNNEL_DUMP, mp);
13248 mp->sw_if_index = htonl (sw_if_index);
13252 /* Use a control ping for synchronization */
13253 MPING (CONTROL_PING, mp_ping);
13260 static uword unformat_geneve_decap_next
13261 (unformat_input_t * input, va_list * args)
13263 u32 *result = va_arg (*args, u32 *);
13266 if (unformat (input, "l2"))
13267 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13268 else if (unformat (input, "%d", &tmp))
13276 api_geneve_add_del_tunnel (vat_main_t * vam)
13278 unformat_input_t *line_input = vam->input;
13279 vl_api_geneve_add_del_tunnel_t *mp;
13280 ip46_address_t src, dst;
13282 u8 ipv4_set = 0, ipv6_set = 0;
13286 u32 mcast_sw_if_index = ~0;
13287 u32 encap_vrf_id = 0;
13288 u32 decap_next_index = ~0;
13292 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13293 memset (&src, 0, sizeof src);
13294 memset (&dst, 0, sizeof dst);
13296 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13298 if (unformat (line_input, "del"))
13301 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13307 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13313 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13319 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13324 else if (unformat (line_input, "group %U %U",
13325 unformat_ip4_address, &dst.ip4,
13326 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13328 grp_set = dst_set = 1;
13331 else if (unformat (line_input, "group %U",
13332 unformat_ip4_address, &dst.ip4))
13334 grp_set = dst_set = 1;
13337 else if (unformat (line_input, "group %U %U",
13338 unformat_ip6_address, &dst.ip6,
13339 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13341 grp_set = dst_set = 1;
13344 else if (unformat (line_input, "group %U",
13345 unformat_ip6_address, &dst.ip6))
13347 grp_set = dst_set = 1;
13351 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13353 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13355 else if (unformat (line_input, "decap-next %U",
13356 unformat_geneve_decap_next, &decap_next_index))
13358 else if (unformat (line_input, "vni %d", &vni))
13362 errmsg ("parse error '%U'", format_unformat_error, line_input);
13369 errmsg ("tunnel src address not specified");
13374 errmsg ("tunnel dst address not specified");
13378 if (grp_set && !ip46_address_is_multicast (&dst))
13380 errmsg ("tunnel group address not multicast");
13383 if (grp_set && mcast_sw_if_index == ~0)
13385 errmsg ("tunnel nonexistent multicast device");
13388 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13390 errmsg ("tunnel dst address must be unicast");
13395 if (ipv4_set && ipv6_set)
13397 errmsg ("both IPv4 and IPv6 addresses specified");
13401 if ((vni == 0) || (vni >> 24))
13403 errmsg ("vni not specified or out of range");
13407 M (GENEVE_ADD_DEL_TUNNEL, mp);
13411 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13412 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13416 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13417 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13419 mp->encap_vrf_id = ntohl (encap_vrf_id);
13420 mp->decap_next_index = ntohl (decap_next_index);
13421 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13422 mp->vni = ntohl (vni);
13423 mp->is_add = is_add;
13424 mp->is_ipv6 = ipv6_set;
13431 static void vl_api_geneve_tunnel_details_t_handler
13432 (vl_api_geneve_tunnel_details_t * mp)
13434 vat_main_t *vam = &vat_main;
13435 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13436 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13438 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13439 ntohl (mp->sw_if_index),
13440 format_ip46_address, &src, IP46_TYPE_ANY,
13441 format_ip46_address, &dst, IP46_TYPE_ANY,
13442 ntohl (mp->encap_vrf_id),
13443 ntohl (mp->decap_next_index), ntohl (mp->vni),
13444 ntohl (mp->mcast_sw_if_index));
13447 static void vl_api_geneve_tunnel_details_t_handler_json
13448 (vl_api_geneve_tunnel_details_t * mp)
13450 vat_main_t *vam = &vat_main;
13451 vat_json_node_t *node = NULL;
13453 if (VAT_JSON_ARRAY != vam->json_tree.type)
13455 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13456 vat_json_init_array (&vam->json_tree);
13458 node = vat_json_array_add (&vam->json_tree);
13460 vat_json_init_object (node);
13461 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13464 struct in6_addr ip6;
13466 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13467 vat_json_object_add_ip6 (node, "src_address", ip6);
13468 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13469 vat_json_object_add_ip6 (node, "dst_address", ip6);
13473 struct in_addr ip4;
13475 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13476 vat_json_object_add_ip4 (node, "src_address", ip4);
13477 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13478 vat_json_object_add_ip4 (node, "dst_address", ip4);
13480 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13481 vat_json_object_add_uint (node, "decap_next_index",
13482 ntohl (mp->decap_next_index));
13483 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13484 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13485 vat_json_object_add_uint (node, "mcast_sw_if_index",
13486 ntohl (mp->mcast_sw_if_index));
13490 api_geneve_tunnel_dump (vat_main_t * vam)
13492 unformat_input_t *i = vam->input;
13493 vl_api_geneve_tunnel_dump_t *mp;
13494 vl_api_control_ping_t *mp_ping;
13496 u8 sw_if_index_set = 0;
13499 /* Parse args required to build the message */
13500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13502 if (unformat (i, "sw_if_index %d", &sw_if_index))
13503 sw_if_index_set = 1;
13508 if (sw_if_index_set == 0)
13513 if (!vam->json_output)
13515 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13516 "sw_if_index", "local_address", "remote_address",
13517 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13520 /* Get list of geneve-tunnel interfaces */
13521 M (GENEVE_TUNNEL_DUMP, mp);
13523 mp->sw_if_index = htonl (sw_if_index);
13527 /* Use a control ping for synchronization */
13528 M (CONTROL_PING, mp_ping);
13536 api_gre_add_del_tunnel (vat_main_t * vam)
13538 unformat_input_t *line_input = vam->input;
13539 vl_api_gre_add_del_tunnel_t *mp;
13540 ip4_address_t src4, dst4;
13541 ip6_address_t src6, dst6;
13545 u8 t_type = GRE_TUNNEL_TYPE_L3;
13548 u32 outer_fib_id = 0;
13549 u32 session_id = 0;
13553 memset (&src4, 0, sizeof src4);
13554 memset (&dst4, 0, sizeof dst4);
13555 memset (&src6, 0, sizeof src6);
13556 memset (&dst6, 0, sizeof dst6);
13558 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13560 if (unformat (line_input, "del"))
13562 else if (unformat (line_input, "instance %d", &instance))
13564 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13569 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13574 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13579 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13584 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13586 else if (unformat (line_input, "teb"))
13587 t_type = GRE_TUNNEL_TYPE_TEB;
13588 else if (unformat (line_input, "erspan %d", &session_id))
13589 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13592 errmsg ("parse error '%U'", format_unformat_error, line_input);
13599 errmsg ("tunnel src address not specified");
13604 errmsg ("tunnel dst address not specified");
13607 if (ipv4_set && ipv6_set)
13609 errmsg ("both IPv4 and IPv6 addresses specified");
13614 M (GRE_ADD_DEL_TUNNEL, mp);
13618 clib_memcpy (&mp->src_address, &src4, 4);
13619 clib_memcpy (&mp->dst_address, &dst4, 4);
13623 clib_memcpy (&mp->src_address, &src6, 16);
13624 clib_memcpy (&mp->dst_address, &dst6, 16);
13626 mp->instance = htonl (instance);
13627 mp->outer_fib_id = htonl (outer_fib_id);
13628 mp->is_add = is_add;
13629 mp->session_id = htons ((u16) session_id);
13630 mp->tunnel_type = t_type;
13631 mp->is_ipv6 = ipv6_set;
13638 static void vl_api_gre_tunnel_details_t_handler
13639 (vl_api_gre_tunnel_details_t * mp)
13641 vat_main_t *vam = &vat_main;
13642 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13643 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13645 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13646 ntohl (mp->sw_if_index),
13647 ntohl (mp->instance),
13648 format_ip46_address, &src, IP46_TYPE_ANY,
13649 format_ip46_address, &dst, IP46_TYPE_ANY,
13650 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13653 static void vl_api_gre_tunnel_details_t_handler_json
13654 (vl_api_gre_tunnel_details_t * mp)
13656 vat_main_t *vam = &vat_main;
13657 vat_json_node_t *node = NULL;
13658 struct in_addr ip4;
13659 struct in6_addr ip6;
13661 if (VAT_JSON_ARRAY != vam->json_tree.type)
13663 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13664 vat_json_init_array (&vam->json_tree);
13666 node = vat_json_array_add (&vam->json_tree);
13668 vat_json_init_object (node);
13669 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13670 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13673 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13674 vat_json_object_add_ip4 (node, "src_address", ip4);
13675 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13676 vat_json_object_add_ip4 (node, "dst_address", ip4);
13680 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13681 vat_json_object_add_ip6 (node, "src_address", ip6);
13682 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13683 vat_json_object_add_ip6 (node, "dst_address", ip6);
13685 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13686 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13687 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13688 vat_json_object_add_uint (node, "session_id", mp->session_id);
13692 api_gre_tunnel_dump (vat_main_t * vam)
13694 unformat_input_t *i = vam->input;
13695 vl_api_gre_tunnel_dump_t *mp;
13696 vl_api_control_ping_t *mp_ping;
13698 u8 sw_if_index_set = 0;
13701 /* Parse args required to build the message */
13702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13704 if (unformat (i, "sw_if_index %d", &sw_if_index))
13705 sw_if_index_set = 1;
13710 if (sw_if_index_set == 0)
13715 if (!vam->json_output)
13717 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13718 "sw_if_index", "instance", "src_address", "dst_address",
13719 "tunnel_type", "outer_fib_id", "session_id");
13722 /* Get list of gre-tunnel interfaces */
13723 M (GRE_TUNNEL_DUMP, mp);
13725 mp->sw_if_index = htonl (sw_if_index);
13729 /* Use a control ping for synchronization */
13730 MPING (CONTROL_PING, mp_ping);
13738 api_l2_fib_clear_table (vat_main_t * vam)
13740 // unformat_input_t * i = vam->input;
13741 vl_api_l2_fib_clear_table_t *mp;
13744 M (L2_FIB_CLEAR_TABLE, mp);
13752 api_l2_interface_efp_filter (vat_main_t * vam)
13754 unformat_input_t *i = vam->input;
13755 vl_api_l2_interface_efp_filter_t *mp;
13758 u8 sw_if_index_set = 0;
13761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13763 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13764 sw_if_index_set = 1;
13765 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13766 sw_if_index_set = 1;
13767 else if (unformat (i, "enable"))
13769 else if (unformat (i, "disable"))
13773 clib_warning ("parse error '%U'", format_unformat_error, i);
13778 if (sw_if_index_set == 0)
13780 errmsg ("missing sw_if_index");
13784 M (L2_INTERFACE_EFP_FILTER, mp);
13786 mp->sw_if_index = ntohl (sw_if_index);
13787 mp->enable_disable = enable;
13794 #define foreach_vtr_op \
13795 _("disable", L2_VTR_DISABLED) \
13796 _("push-1", L2_VTR_PUSH_1) \
13797 _("push-2", L2_VTR_PUSH_2) \
13798 _("pop-1", L2_VTR_POP_1) \
13799 _("pop-2", L2_VTR_POP_2) \
13800 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13801 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13802 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13803 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13806 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13808 unformat_input_t *i = vam->input;
13809 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13811 u8 sw_if_index_set = 0;
13814 u32 push_dot1q = 1;
13819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13821 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13822 sw_if_index_set = 1;
13823 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13824 sw_if_index_set = 1;
13825 else if (unformat (i, "vtr_op %d", &vtr_op))
13827 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13830 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13832 else if (unformat (i, "tag1 %d", &tag1))
13834 else if (unformat (i, "tag2 %d", &tag2))
13838 clib_warning ("parse error '%U'", format_unformat_error, i);
13843 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13845 errmsg ("missing vtr operation or sw_if_index");
13849 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13850 mp->sw_if_index = ntohl (sw_if_index);
13851 mp->vtr_op = ntohl (vtr_op);
13852 mp->push_dot1q = ntohl (push_dot1q);
13853 mp->tag1 = ntohl (tag1);
13854 mp->tag2 = ntohl (tag2);
13862 api_create_vhost_user_if (vat_main_t * vam)
13864 unformat_input_t *i = vam->input;
13865 vl_api_create_vhost_user_if_t *mp;
13868 u8 file_name_set = 0;
13869 u32 custom_dev_instance = ~0;
13871 u8 use_custom_mac = 0;
13875 /* Shut up coverity */
13876 memset (hwaddr, 0, sizeof (hwaddr));
13878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13880 if (unformat (i, "socket %s", &file_name))
13884 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13886 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13887 use_custom_mac = 1;
13888 else if (unformat (i, "server"))
13890 else if (unformat (i, "tag %s", &tag))
13896 if (file_name_set == 0)
13898 errmsg ("missing socket file name");
13902 if (vec_len (file_name) > 255)
13904 errmsg ("socket file name too long");
13907 vec_add1 (file_name, 0);
13909 M (CREATE_VHOST_USER_IF, mp);
13911 mp->is_server = is_server;
13912 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13913 vec_free (file_name);
13914 if (custom_dev_instance != ~0)
13917 mp->custom_dev_instance = ntohl (custom_dev_instance);
13919 mp->use_custom_mac = use_custom_mac;
13920 clib_memcpy (mp->mac_address, hwaddr, 6);
13922 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13931 api_modify_vhost_user_if (vat_main_t * vam)
13933 unformat_input_t *i = vam->input;
13934 vl_api_modify_vhost_user_if_t *mp;
13937 u8 file_name_set = 0;
13938 u32 custom_dev_instance = ~0;
13939 u8 sw_if_index_set = 0;
13940 u32 sw_if_index = (u32) ~ 0;
13943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13946 sw_if_index_set = 1;
13947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13948 sw_if_index_set = 1;
13949 else if (unformat (i, "socket %s", &file_name))
13953 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13955 else if (unformat (i, "server"))
13961 if (sw_if_index_set == 0)
13963 errmsg ("missing sw_if_index or interface name");
13967 if (file_name_set == 0)
13969 errmsg ("missing socket file name");
13973 if (vec_len (file_name) > 255)
13975 errmsg ("socket file name too long");
13978 vec_add1 (file_name, 0);
13980 M (MODIFY_VHOST_USER_IF, mp);
13982 mp->sw_if_index = ntohl (sw_if_index);
13983 mp->is_server = is_server;
13984 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13985 vec_free (file_name);
13986 if (custom_dev_instance != ~0)
13989 mp->custom_dev_instance = ntohl (custom_dev_instance);
13998 api_delete_vhost_user_if (vat_main_t * vam)
14000 unformat_input_t *i = vam->input;
14001 vl_api_delete_vhost_user_if_t *mp;
14002 u32 sw_if_index = ~0;
14003 u8 sw_if_index_set = 0;
14006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14008 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14009 sw_if_index_set = 1;
14010 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14011 sw_if_index_set = 1;
14016 if (sw_if_index_set == 0)
14018 errmsg ("missing sw_if_index or interface name");
14023 M (DELETE_VHOST_USER_IF, mp);
14025 mp->sw_if_index = ntohl (sw_if_index);
14032 static void vl_api_sw_interface_vhost_user_details_t_handler
14033 (vl_api_sw_interface_vhost_user_details_t * mp)
14035 vat_main_t *vam = &vat_main;
14037 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14038 (char *) mp->interface_name,
14039 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14040 clib_net_to_host_u64 (mp->features), mp->is_server,
14041 ntohl (mp->num_regions), (char *) mp->sock_filename);
14042 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14045 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14046 (vl_api_sw_interface_vhost_user_details_t * mp)
14048 vat_main_t *vam = &vat_main;
14049 vat_json_node_t *node = NULL;
14051 if (VAT_JSON_ARRAY != vam->json_tree.type)
14053 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14054 vat_json_init_array (&vam->json_tree);
14056 node = vat_json_array_add (&vam->json_tree);
14058 vat_json_init_object (node);
14059 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14060 vat_json_object_add_string_copy (node, "interface_name",
14061 mp->interface_name);
14062 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14063 ntohl (mp->virtio_net_hdr_sz));
14064 vat_json_object_add_uint (node, "features",
14065 clib_net_to_host_u64 (mp->features));
14066 vat_json_object_add_uint (node, "is_server", mp->is_server);
14067 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14068 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14069 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14073 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14075 vl_api_sw_interface_vhost_user_dump_t *mp;
14076 vl_api_control_ping_t *mp_ping;
14079 "Interface name idx hdr_sz features server regions filename");
14081 /* Get list of vhost-user interfaces */
14082 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14085 /* Use a control ping for synchronization */
14086 MPING (CONTROL_PING, mp_ping);
14094 api_show_version (vat_main_t * vam)
14096 vl_api_show_version_t *mp;
14099 M (SHOW_VERSION, mp);
14108 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14110 unformat_input_t *line_input = vam->input;
14111 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14112 ip4_address_t local4, remote4;
14113 ip6_address_t local6, remote6;
14115 u8 ipv4_set = 0, ipv6_set = 0;
14119 u32 mcast_sw_if_index = ~0;
14120 u32 encap_vrf_id = 0;
14121 u32 decap_vrf_id = 0;
14127 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14128 memset (&local4, 0, sizeof local4);
14129 memset (&remote4, 0, sizeof remote4);
14130 memset (&local6, 0, sizeof local6);
14131 memset (&remote6, 0, sizeof remote6);
14133 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14135 if (unformat (line_input, "del"))
14137 else if (unformat (line_input, "local %U",
14138 unformat_ip4_address, &local4))
14143 else if (unformat (line_input, "remote %U",
14144 unformat_ip4_address, &remote4))
14149 else if (unformat (line_input, "local %U",
14150 unformat_ip6_address, &local6))
14155 else if (unformat (line_input, "remote %U",
14156 unformat_ip6_address, &remote6))
14161 else if (unformat (line_input, "group %U %U",
14162 unformat_ip4_address, &remote4,
14163 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14165 grp_set = remote_set = 1;
14168 else if (unformat (line_input, "group %U",
14169 unformat_ip4_address, &remote4))
14171 grp_set = remote_set = 1;
14174 else if (unformat (line_input, "group %U %U",
14175 unformat_ip6_address, &remote6,
14176 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14178 grp_set = remote_set = 1;
14181 else if (unformat (line_input, "group %U",
14182 unformat_ip6_address, &remote6))
14184 grp_set = remote_set = 1;
14188 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14190 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14192 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14194 else if (unformat (line_input, "vni %d", &vni))
14196 else if (unformat (line_input, "next-ip4"))
14198 else if (unformat (line_input, "next-ip6"))
14200 else if (unformat (line_input, "next-ethernet"))
14202 else if (unformat (line_input, "next-nsh"))
14206 errmsg ("parse error '%U'", format_unformat_error, line_input);
14211 if (local_set == 0)
14213 errmsg ("tunnel local address not specified");
14216 if (remote_set == 0)
14218 errmsg ("tunnel remote address not specified");
14221 if (grp_set && mcast_sw_if_index == ~0)
14223 errmsg ("tunnel nonexistent multicast device");
14226 if (ipv4_set && ipv6_set)
14228 errmsg ("both IPv4 and IPv6 addresses specified");
14234 errmsg ("vni not specified");
14238 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14243 clib_memcpy (&mp->local, &local6, sizeof (local6));
14244 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14248 clib_memcpy (&mp->local, &local4, sizeof (local4));
14249 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14252 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14253 mp->encap_vrf_id = ntohl (encap_vrf_id);
14254 mp->decap_vrf_id = ntohl (decap_vrf_id);
14255 mp->protocol = protocol;
14256 mp->vni = ntohl (vni);
14257 mp->is_add = is_add;
14258 mp->is_ipv6 = ipv6_set;
14265 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14266 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14268 vat_main_t *vam = &vat_main;
14269 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14270 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14272 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14273 ntohl (mp->sw_if_index),
14274 format_ip46_address, &local, IP46_TYPE_ANY,
14275 format_ip46_address, &remote, IP46_TYPE_ANY,
14276 ntohl (mp->vni), mp->protocol,
14277 ntohl (mp->mcast_sw_if_index),
14278 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14282 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14283 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14285 vat_main_t *vam = &vat_main;
14286 vat_json_node_t *node = NULL;
14287 struct in_addr ip4;
14288 struct in6_addr ip6;
14290 if (VAT_JSON_ARRAY != vam->json_tree.type)
14292 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14293 vat_json_init_array (&vam->json_tree);
14295 node = vat_json_array_add (&vam->json_tree);
14297 vat_json_init_object (node);
14298 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14301 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14302 vat_json_object_add_ip6 (node, "local", ip6);
14303 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14304 vat_json_object_add_ip6 (node, "remote", ip6);
14308 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14309 vat_json_object_add_ip4 (node, "local", ip4);
14310 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14311 vat_json_object_add_ip4 (node, "remote", ip4);
14313 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14314 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14315 vat_json_object_add_uint (node, "mcast_sw_if_index",
14316 ntohl (mp->mcast_sw_if_index));
14317 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14318 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14319 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14323 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14325 unformat_input_t *i = vam->input;
14326 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14327 vl_api_control_ping_t *mp_ping;
14329 u8 sw_if_index_set = 0;
14332 /* Parse args required to build the message */
14333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14335 if (unformat (i, "sw_if_index %d", &sw_if_index))
14336 sw_if_index_set = 1;
14341 if (sw_if_index_set == 0)
14346 if (!vam->json_output)
14348 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14349 "sw_if_index", "local", "remote", "vni",
14350 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14353 /* Get list of vxlan-tunnel interfaces */
14354 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14356 mp->sw_if_index = htonl (sw_if_index);
14360 /* Use a control ping for synchronization */
14361 MPING (CONTROL_PING, mp_ping);
14368 static void vl_api_l2_fib_table_details_t_handler
14369 (vl_api_l2_fib_table_details_t * mp)
14371 vat_main_t *vam = &vat_main;
14373 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14375 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14376 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14380 static void vl_api_l2_fib_table_details_t_handler_json
14381 (vl_api_l2_fib_table_details_t * mp)
14383 vat_main_t *vam = &vat_main;
14384 vat_json_node_t *node = NULL;
14386 if (VAT_JSON_ARRAY != vam->json_tree.type)
14388 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14389 vat_json_init_array (&vam->json_tree);
14391 node = vat_json_array_add (&vam->json_tree);
14393 vat_json_init_object (node);
14394 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14395 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14396 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14397 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14398 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14399 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14403 api_l2_fib_table_dump (vat_main_t * vam)
14405 unformat_input_t *i = vam->input;
14406 vl_api_l2_fib_table_dump_t *mp;
14407 vl_api_control_ping_t *mp_ping;
14412 /* Parse args required to build the message */
14413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14415 if (unformat (i, "bd_id %d", &bd_id))
14421 if (bd_id_set == 0)
14423 errmsg ("missing bridge domain");
14427 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14429 /* Get list of l2 fib entries */
14430 M (L2_FIB_TABLE_DUMP, mp);
14432 mp->bd_id = ntohl (bd_id);
14435 /* Use a control ping for synchronization */
14436 MPING (CONTROL_PING, mp_ping);
14445 api_interface_name_renumber (vat_main_t * vam)
14447 unformat_input_t *line_input = vam->input;
14448 vl_api_interface_name_renumber_t *mp;
14449 u32 sw_if_index = ~0;
14450 u32 new_show_dev_instance = ~0;
14453 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14455 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14458 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14460 else if (unformat (line_input, "new_show_dev_instance %d",
14461 &new_show_dev_instance))
14467 if (sw_if_index == ~0)
14469 errmsg ("missing interface name or sw_if_index");
14473 if (new_show_dev_instance == ~0)
14475 errmsg ("missing new_show_dev_instance");
14479 M (INTERFACE_NAME_RENUMBER, mp);
14481 mp->sw_if_index = ntohl (sw_if_index);
14482 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14490 api_ip_probe_neighbor (vat_main_t * vam)
14492 unformat_input_t *i = vam->input;
14493 vl_api_ip_probe_neighbor_t *mp;
14501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14507 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14509 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14520 errmsg ("missing interface");
14526 errmsg ("missing addresses");
14530 M (IP_PROBE_NEIGHBOR, mp);
14532 mp->sw_if_index = ntohl (sw_if_index);
14533 mp->is_ipv6 = is_ipv6;
14534 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14542 api_want_ip4_arp_events (vat_main_t * vam)
14544 unformat_input_t *line_input = vam->input;
14545 vl_api_want_ip4_arp_events_t *mp;
14546 ip4_address_t address;
14547 int address_set = 0;
14548 u32 enable_disable = 1;
14551 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14553 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14555 else if (unformat (line_input, "del"))
14556 enable_disable = 0;
14561 if (address_set == 0)
14563 errmsg ("missing addresses");
14567 M (WANT_IP4_ARP_EVENTS, mp);
14568 mp->enable_disable = enable_disable;
14569 mp->pid = htonl (getpid ());
14570 mp->address = address.as_u32;
14578 api_want_ip6_nd_events (vat_main_t * vam)
14580 unformat_input_t *line_input = vam->input;
14581 vl_api_want_ip6_nd_events_t *mp;
14582 ip6_address_t address;
14583 int address_set = 0;
14584 u32 enable_disable = 1;
14587 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14589 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14591 else if (unformat (line_input, "del"))
14592 enable_disable = 0;
14597 if (address_set == 0)
14599 errmsg ("missing addresses");
14603 M (WANT_IP6_ND_EVENTS, mp);
14604 mp->enable_disable = enable_disable;
14605 mp->pid = htonl (getpid ());
14606 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14614 api_want_l2_macs_events (vat_main_t * vam)
14616 unformat_input_t *line_input = vam->input;
14617 vl_api_want_l2_macs_events_t *mp;
14618 u8 enable_disable = 1;
14619 u32 scan_delay = 0;
14620 u32 max_macs_in_event = 0;
14621 u32 learn_limit = 0;
14624 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14626 if (unformat (line_input, "learn-limit %d", &learn_limit))
14628 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14630 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14632 else if (unformat (line_input, "disable"))
14633 enable_disable = 0;
14638 M (WANT_L2_MACS_EVENTS, mp);
14639 mp->enable_disable = enable_disable;
14640 mp->pid = htonl (getpid ());
14641 mp->learn_limit = htonl (learn_limit);
14642 mp->scan_delay = (u8) scan_delay;
14643 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14650 api_input_acl_set_interface (vat_main_t * vam)
14652 unformat_input_t *i = vam->input;
14653 vl_api_input_acl_set_interface_t *mp;
14655 int sw_if_index_set;
14656 u32 ip4_table_index = ~0;
14657 u32 ip6_table_index = ~0;
14658 u32 l2_table_index = ~0;
14662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14664 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14665 sw_if_index_set = 1;
14666 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14667 sw_if_index_set = 1;
14668 else if (unformat (i, "del"))
14670 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14672 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14674 else if (unformat (i, "l2-table %d", &l2_table_index))
14678 clib_warning ("parse error '%U'", format_unformat_error, i);
14683 if (sw_if_index_set == 0)
14685 errmsg ("missing interface name or sw_if_index");
14689 M (INPUT_ACL_SET_INTERFACE, mp);
14691 mp->sw_if_index = ntohl (sw_if_index);
14692 mp->ip4_table_index = ntohl (ip4_table_index);
14693 mp->ip6_table_index = ntohl (ip6_table_index);
14694 mp->l2_table_index = ntohl (l2_table_index);
14695 mp->is_add = is_add;
14703 api_output_acl_set_interface (vat_main_t * vam)
14705 unformat_input_t *i = vam->input;
14706 vl_api_output_acl_set_interface_t *mp;
14708 int sw_if_index_set;
14709 u32 ip4_table_index = ~0;
14710 u32 ip6_table_index = ~0;
14711 u32 l2_table_index = ~0;
14715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14717 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14718 sw_if_index_set = 1;
14719 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14720 sw_if_index_set = 1;
14721 else if (unformat (i, "del"))
14723 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14725 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14727 else if (unformat (i, "l2-table %d", &l2_table_index))
14731 clib_warning ("parse error '%U'", format_unformat_error, i);
14736 if (sw_if_index_set == 0)
14738 errmsg ("missing interface name or sw_if_index");
14742 M (OUTPUT_ACL_SET_INTERFACE, mp);
14744 mp->sw_if_index = ntohl (sw_if_index);
14745 mp->ip4_table_index = ntohl (ip4_table_index);
14746 mp->ip6_table_index = ntohl (ip6_table_index);
14747 mp->l2_table_index = ntohl (l2_table_index);
14748 mp->is_add = is_add;
14756 api_ip_address_dump (vat_main_t * vam)
14758 unformat_input_t *i = vam->input;
14759 vl_api_ip_address_dump_t *mp;
14760 vl_api_control_ping_t *mp_ping;
14761 u32 sw_if_index = ~0;
14762 u8 sw_if_index_set = 0;
14767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14769 if (unformat (i, "sw_if_index %d", &sw_if_index))
14770 sw_if_index_set = 1;
14772 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14773 sw_if_index_set = 1;
14774 else if (unformat (i, "ipv4"))
14776 else if (unformat (i, "ipv6"))
14782 if (ipv4_set && ipv6_set)
14784 errmsg ("ipv4 and ipv6 flags cannot be both set");
14788 if ((!ipv4_set) && (!ipv6_set))
14790 errmsg ("no ipv4 nor ipv6 flag set");
14794 if (sw_if_index_set == 0)
14796 errmsg ("missing interface name or sw_if_index");
14800 vam->current_sw_if_index = sw_if_index;
14801 vam->is_ipv6 = ipv6_set;
14803 M (IP_ADDRESS_DUMP, mp);
14804 mp->sw_if_index = ntohl (sw_if_index);
14805 mp->is_ipv6 = ipv6_set;
14808 /* Use a control ping for synchronization */
14809 MPING (CONTROL_PING, mp_ping);
14817 api_ip_dump (vat_main_t * vam)
14819 vl_api_ip_dump_t *mp;
14820 vl_api_control_ping_t *mp_ping;
14821 unformat_input_t *in = vam->input;
14828 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14830 if (unformat (in, "ipv4"))
14832 else if (unformat (in, "ipv6"))
14838 if (ipv4_set && ipv6_set)
14840 errmsg ("ipv4 and ipv6 flags cannot be both set");
14844 if ((!ipv4_set) && (!ipv6_set))
14846 errmsg ("no ipv4 nor ipv6 flag set");
14850 is_ipv6 = ipv6_set;
14851 vam->is_ipv6 = is_ipv6;
14853 /* free old data */
14854 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14856 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14858 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14861 mp->is_ipv6 = ipv6_set;
14864 /* Use a control ping for synchronization */
14865 MPING (CONTROL_PING, mp_ping);
14873 api_ipsec_spd_add_del (vat_main_t * vam)
14875 unformat_input_t *i = vam->input;
14876 vl_api_ipsec_spd_add_del_t *mp;
14881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14883 if (unformat (i, "spd_id %d", &spd_id))
14885 else if (unformat (i, "del"))
14889 clib_warning ("parse error '%U'", format_unformat_error, i);
14895 errmsg ("spd_id must be set");
14899 M (IPSEC_SPD_ADD_DEL, mp);
14901 mp->spd_id = ntohl (spd_id);
14902 mp->is_add = is_add;
14910 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14912 unformat_input_t *i = vam->input;
14913 vl_api_ipsec_interface_add_del_spd_t *mp;
14915 u8 sw_if_index_set = 0;
14916 u32 spd_id = (u32) ~ 0;
14920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14922 if (unformat (i, "del"))
14924 else if (unformat (i, "spd_id %d", &spd_id))
14927 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14928 sw_if_index_set = 1;
14929 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14930 sw_if_index_set = 1;
14933 clib_warning ("parse error '%U'", format_unformat_error, i);
14939 if (spd_id == (u32) ~ 0)
14941 errmsg ("spd_id must be set");
14945 if (sw_if_index_set == 0)
14947 errmsg ("missing interface name or sw_if_index");
14951 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14953 mp->spd_id = ntohl (spd_id);
14954 mp->sw_if_index = ntohl (sw_if_index);
14955 mp->is_add = is_add;
14963 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14965 unformat_input_t *i = vam->input;
14966 vl_api_ipsec_spd_add_del_entry_t *mp;
14967 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14968 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14970 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14971 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14972 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14973 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14976 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14977 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14978 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14979 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14980 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14981 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14985 if (unformat (i, "del"))
14987 if (unformat (i, "outbound"))
14989 if (unformat (i, "inbound"))
14991 else if (unformat (i, "spd_id %d", &spd_id))
14993 else if (unformat (i, "sa_id %d", &sa_id))
14995 else if (unformat (i, "priority %d", &priority))
14997 else if (unformat (i, "protocol %d", &protocol))
14999 else if (unformat (i, "lport_start %d", &lport_start))
15001 else if (unformat (i, "lport_stop %d", &lport_stop))
15003 else if (unformat (i, "rport_start %d", &rport_start))
15005 else if (unformat (i, "rport_stop %d", &rport_stop))
15009 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15015 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15022 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15028 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15035 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15041 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15048 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15054 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15060 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15062 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15064 clib_warning ("unsupported action: 'resolve'");
15070 clib_warning ("parse error '%U'", format_unformat_error, i);
15076 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15078 mp->spd_id = ntohl (spd_id);
15079 mp->priority = ntohl (priority);
15080 mp->is_outbound = is_outbound;
15082 mp->is_ipv6 = is_ipv6;
15083 if (is_ipv6 || is_ip_any)
15085 clib_memcpy (mp->remote_address_start, &raddr6_start,
15086 sizeof (ip6_address_t));
15087 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15088 sizeof (ip6_address_t));
15089 clib_memcpy (mp->local_address_start, &laddr6_start,
15090 sizeof (ip6_address_t));
15091 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15092 sizeof (ip6_address_t));
15096 clib_memcpy (mp->remote_address_start, &raddr4_start,
15097 sizeof (ip4_address_t));
15098 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15099 sizeof (ip4_address_t));
15100 clib_memcpy (mp->local_address_start, &laddr4_start,
15101 sizeof (ip4_address_t));
15102 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15103 sizeof (ip4_address_t));
15105 mp->protocol = (u8) protocol;
15106 mp->local_port_start = ntohs ((u16) lport_start);
15107 mp->local_port_stop = ntohs ((u16) lport_stop);
15108 mp->remote_port_start = ntohs ((u16) rport_start);
15109 mp->remote_port_stop = ntohs ((u16) rport_stop);
15110 mp->policy = (u8) policy;
15111 mp->sa_id = ntohl (sa_id);
15112 mp->is_add = is_add;
15113 mp->is_ip_any = is_ip_any;
15120 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15122 unformat_input_t *i = vam->input;
15123 vl_api_ipsec_sad_add_del_entry_t *mp;
15124 u32 sad_id = 0, spi = 0;
15125 u8 *ck = 0, *ik = 0;
15128 u8 protocol = IPSEC_PROTOCOL_AH;
15129 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15130 u32 crypto_alg = 0, integ_alg = 0;
15131 ip4_address_t tun_src4;
15132 ip4_address_t tun_dst4;
15133 ip6_address_t tun_src6;
15134 ip6_address_t tun_dst6;
15137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15139 if (unformat (i, "del"))
15141 else if (unformat (i, "sad_id %d", &sad_id))
15143 else if (unformat (i, "spi %d", &spi))
15145 else if (unformat (i, "esp"))
15146 protocol = IPSEC_PROTOCOL_ESP;
15147 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15150 is_tunnel_ipv6 = 0;
15152 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15155 is_tunnel_ipv6 = 0;
15157 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15160 is_tunnel_ipv6 = 1;
15162 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15165 is_tunnel_ipv6 = 1;
15169 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15171 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15172 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15174 clib_warning ("unsupported crypto-alg: '%U'",
15175 format_ipsec_crypto_alg, crypto_alg);
15179 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15183 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15185 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15186 integ_alg >= IPSEC_INTEG_N_ALG)
15188 clib_warning ("unsupported integ-alg: '%U'",
15189 format_ipsec_integ_alg, integ_alg);
15193 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15197 clib_warning ("parse error '%U'", format_unformat_error, i);
15203 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15205 mp->sad_id = ntohl (sad_id);
15206 mp->is_add = is_add;
15207 mp->protocol = protocol;
15208 mp->spi = ntohl (spi);
15209 mp->is_tunnel = is_tunnel;
15210 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15211 mp->crypto_algorithm = crypto_alg;
15212 mp->integrity_algorithm = integ_alg;
15213 mp->crypto_key_length = vec_len (ck);
15214 mp->integrity_key_length = vec_len (ik);
15216 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15217 mp->crypto_key_length = sizeof (mp->crypto_key);
15219 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15220 mp->integrity_key_length = sizeof (mp->integrity_key);
15223 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15225 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15229 if (is_tunnel_ipv6)
15231 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15232 sizeof (ip6_address_t));
15233 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15234 sizeof (ip6_address_t));
15238 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15239 sizeof (ip4_address_t));
15240 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15241 sizeof (ip4_address_t));
15251 api_ipsec_sa_set_key (vat_main_t * vam)
15253 unformat_input_t *i = vam->input;
15254 vl_api_ipsec_sa_set_key_t *mp;
15256 u8 *ck = 0, *ik = 0;
15259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15261 if (unformat (i, "sa_id %d", &sa_id))
15263 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15265 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15269 clib_warning ("parse error '%U'", format_unformat_error, i);
15274 M (IPSEC_SA_SET_KEY, mp);
15276 mp->sa_id = ntohl (sa_id);
15277 mp->crypto_key_length = vec_len (ck);
15278 mp->integrity_key_length = vec_len (ik);
15280 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15281 mp->crypto_key_length = sizeof (mp->crypto_key);
15283 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15284 mp->integrity_key_length = sizeof (mp->integrity_key);
15287 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15289 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15297 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15299 unformat_input_t *i = vam->input;
15300 vl_api_ipsec_tunnel_if_add_del_t *mp;
15301 u32 local_spi = 0, remote_spi = 0;
15302 u32 crypto_alg = 0, integ_alg = 0;
15303 u8 *lck = NULL, *rck = NULL;
15304 u8 *lik = NULL, *rik = NULL;
15305 ip4_address_t local_ip = { {0} };
15306 ip4_address_t remote_ip = { {0} };
15309 u8 anti_replay = 0;
15314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15316 if (unformat (i, "del"))
15318 else if (unformat (i, "esn"))
15320 else if (unformat (i, "anti_replay"))
15322 else if (unformat (i, "local_spi %d", &local_spi))
15324 else if (unformat (i, "remote_spi %d", &remote_spi))
15326 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15328 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15330 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15333 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15335 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15337 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15341 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15343 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15344 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15346 errmsg ("unsupported crypto-alg: '%U'\n",
15347 format_ipsec_crypto_alg, crypto_alg);
15353 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15355 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15356 integ_alg >= IPSEC_INTEG_N_ALG)
15358 errmsg ("unsupported integ-alg: '%U'\n",
15359 format_ipsec_integ_alg, integ_alg);
15363 else if (unformat (i, "instance %u", &instance))
15367 errmsg ("parse error '%U'\n", format_unformat_error, i);
15372 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15374 mp->is_add = is_add;
15376 mp->anti_replay = anti_replay;
15378 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15379 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15381 mp->local_spi = htonl (local_spi);
15382 mp->remote_spi = htonl (remote_spi);
15383 mp->crypto_alg = (u8) crypto_alg;
15385 mp->local_crypto_key_len = 0;
15388 mp->local_crypto_key_len = vec_len (lck);
15389 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15390 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15391 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15394 mp->remote_crypto_key_len = 0;
15397 mp->remote_crypto_key_len = vec_len (rck);
15398 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15399 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15400 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15403 mp->integ_alg = (u8) integ_alg;
15405 mp->local_integ_key_len = 0;
15408 mp->local_integ_key_len = vec_len (lik);
15409 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15410 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15411 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15414 mp->remote_integ_key_len = 0;
15417 mp->remote_integ_key_len = vec_len (rik);
15418 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15419 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15420 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15425 mp->renumber = renumber;
15426 mp->show_instance = ntohl (instance);
15435 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15437 vat_main_t *vam = &vat_main;
15439 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15440 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15441 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15442 "tunnel_src_addr %U tunnel_dst_addr %U "
15443 "salt %u seq_outbound %lu last_seq_inbound %lu "
15444 "replay_window %lu total_data_size %lu\n",
15445 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15447 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15448 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15449 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15450 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15451 mp->tunnel_src_addr,
15452 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15453 mp->tunnel_dst_addr,
15455 clib_net_to_host_u64 (mp->seq_outbound),
15456 clib_net_to_host_u64 (mp->last_seq_inbound),
15457 clib_net_to_host_u64 (mp->replay_window),
15458 clib_net_to_host_u64 (mp->total_data_size));
15461 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15462 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15464 static void vl_api_ipsec_sa_details_t_handler_json
15465 (vl_api_ipsec_sa_details_t * mp)
15467 vat_main_t *vam = &vat_main;
15468 vat_json_node_t *node = NULL;
15469 struct in_addr src_ip4, dst_ip4;
15470 struct in6_addr src_ip6, dst_ip6;
15472 if (VAT_JSON_ARRAY != vam->json_tree.type)
15474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15475 vat_json_init_array (&vam->json_tree);
15477 node = vat_json_array_add (&vam->json_tree);
15479 vat_json_init_object (node);
15480 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15481 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15482 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15483 vat_json_object_add_uint (node, "proto", mp->protocol);
15484 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15485 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15486 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15487 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15488 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15489 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15490 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15491 mp->crypto_key_len);
15492 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15493 mp->integ_key_len);
15494 if (mp->is_tunnel_ip6)
15496 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15497 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15498 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15499 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15503 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15504 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15505 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15506 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15508 vat_json_object_add_uint (node, "replay_window",
15509 clib_net_to_host_u64 (mp->replay_window));
15510 vat_json_object_add_uint (node, "total_data_size",
15511 clib_net_to_host_u64 (mp->total_data_size));
15516 api_ipsec_sa_dump (vat_main_t * vam)
15518 unformat_input_t *i = vam->input;
15519 vl_api_ipsec_sa_dump_t *mp;
15520 vl_api_control_ping_t *mp_ping;
15524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15526 if (unformat (i, "sa_id %d", &sa_id))
15530 clib_warning ("parse error '%U'", format_unformat_error, i);
15535 M (IPSEC_SA_DUMP, mp);
15537 mp->sa_id = ntohl (sa_id);
15541 /* Use a control ping for synchronization */
15542 M (CONTROL_PING, mp_ping);
15550 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15552 unformat_input_t *i = vam->input;
15553 vl_api_ipsec_tunnel_if_set_key_t *mp;
15554 u32 sw_if_index = ~0;
15555 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15562 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15565 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15566 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15568 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15569 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15570 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15571 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15573 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15574 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15575 else if (unformat (i, "%U", unformat_hex_string, &key))
15579 clib_warning ("parse error '%U'", format_unformat_error, i);
15584 if (sw_if_index == ~0)
15586 errmsg ("interface must be specified");
15590 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15592 errmsg ("key type must be specified");
15598 errmsg ("algorithm must be specified");
15602 if (vec_len (key) == 0)
15604 errmsg ("key must be specified");
15608 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15610 mp->sw_if_index = htonl (sw_if_index);
15612 mp->key_type = key_type;
15613 mp->key_len = vec_len (key);
15614 clib_memcpy (mp->key, key, vec_len (key));
15623 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15625 unformat_input_t *i = vam->input;
15626 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15627 u32 sw_if_index = ~0;
15629 u8 is_outbound = (u8) ~ 0;
15632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15636 else if (unformat (i, "sa_id %d", &sa_id))
15638 else if (unformat (i, "outbound"))
15640 else if (unformat (i, "inbound"))
15644 clib_warning ("parse error '%U'", format_unformat_error, i);
15649 if (sw_if_index == ~0)
15651 errmsg ("interface must be specified");
15657 errmsg ("SA ID must be specified");
15661 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15663 mp->sw_if_index = htonl (sw_if_index);
15664 mp->sa_id = htonl (sa_id);
15665 mp->is_outbound = is_outbound;
15674 api_ikev2_profile_add_del (vat_main_t * vam)
15676 unformat_input_t *i = vam->input;
15677 vl_api_ikev2_profile_add_del_t *mp;
15682 const char *valid_chars = "a-zA-Z0-9_";
15684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15686 if (unformat (i, "del"))
15688 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15689 vec_add1 (name, 0);
15692 errmsg ("parse error '%U'", format_unformat_error, i);
15697 if (!vec_len (name))
15699 errmsg ("profile name must be specified");
15703 if (vec_len (name) > 64)
15705 errmsg ("profile name too long");
15709 M (IKEV2_PROFILE_ADD_DEL, mp);
15711 clib_memcpy (mp->name, name, vec_len (name));
15712 mp->is_add = is_add;
15721 api_ikev2_profile_set_auth (vat_main_t * vam)
15723 unformat_input_t *i = vam->input;
15724 vl_api_ikev2_profile_set_auth_t *mp;
15727 u32 auth_method = 0;
15731 const char *valid_chars = "a-zA-Z0-9_";
15733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15735 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15736 vec_add1 (name, 0);
15737 else if (unformat (i, "auth_method %U",
15738 unformat_ikev2_auth_method, &auth_method))
15740 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15742 else if (unformat (i, "auth_data %v", &data))
15746 errmsg ("parse error '%U'", format_unformat_error, i);
15751 if (!vec_len (name))
15753 errmsg ("profile name must be specified");
15757 if (vec_len (name) > 64)
15759 errmsg ("profile name too long");
15763 if (!vec_len (data))
15765 errmsg ("auth_data must be specified");
15771 errmsg ("auth_method must be specified");
15775 M (IKEV2_PROFILE_SET_AUTH, mp);
15777 mp->is_hex = is_hex;
15778 mp->auth_method = (u8) auth_method;
15779 mp->data_len = vec_len (data);
15780 clib_memcpy (mp->name, name, vec_len (name));
15781 clib_memcpy (mp->data, data, vec_len (data));
15791 api_ikev2_profile_set_id (vat_main_t * vam)
15793 unformat_input_t *i = vam->input;
15794 vl_api_ikev2_profile_set_id_t *mp;
15802 const char *valid_chars = "a-zA-Z0-9_";
15804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15806 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15807 vec_add1 (name, 0);
15808 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15810 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15812 data = vec_new (u8, 4);
15813 clib_memcpy (data, ip4.as_u8, 4);
15815 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15817 else if (unformat (i, "id_data %v", &data))
15819 else if (unformat (i, "local"))
15821 else if (unformat (i, "remote"))
15825 errmsg ("parse error '%U'", format_unformat_error, i);
15830 if (!vec_len (name))
15832 errmsg ("profile name must be specified");
15836 if (vec_len (name) > 64)
15838 errmsg ("profile name too long");
15842 if (!vec_len (data))
15844 errmsg ("id_data must be specified");
15850 errmsg ("id_type must be specified");
15854 M (IKEV2_PROFILE_SET_ID, mp);
15856 mp->is_local = is_local;
15857 mp->id_type = (u8) id_type;
15858 mp->data_len = vec_len (data);
15859 clib_memcpy (mp->name, name, vec_len (name));
15860 clib_memcpy (mp->data, data, vec_len (data));
15870 api_ikev2_profile_set_ts (vat_main_t * vam)
15872 unformat_input_t *i = vam->input;
15873 vl_api_ikev2_profile_set_ts_t *mp;
15876 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15877 ip4_address_t start_addr, end_addr;
15879 const char *valid_chars = "a-zA-Z0-9_";
15882 start_addr.as_u32 = 0;
15883 end_addr.as_u32 = (u32) ~ 0;
15885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15887 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15888 vec_add1 (name, 0);
15889 else if (unformat (i, "protocol %d", &proto))
15891 else if (unformat (i, "start_port %d", &start_port))
15893 else if (unformat (i, "end_port %d", &end_port))
15896 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15898 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15900 else if (unformat (i, "local"))
15902 else if (unformat (i, "remote"))
15906 errmsg ("parse error '%U'", format_unformat_error, i);
15911 if (!vec_len (name))
15913 errmsg ("profile name must be specified");
15917 if (vec_len (name) > 64)
15919 errmsg ("profile name too long");
15923 M (IKEV2_PROFILE_SET_TS, mp);
15925 mp->is_local = is_local;
15926 mp->proto = (u8) proto;
15927 mp->start_port = (u16) start_port;
15928 mp->end_port = (u16) end_port;
15929 mp->start_addr = start_addr.as_u32;
15930 mp->end_addr = end_addr.as_u32;
15931 clib_memcpy (mp->name, name, vec_len (name));
15940 api_ikev2_set_local_key (vat_main_t * vam)
15942 unformat_input_t *i = vam->input;
15943 vl_api_ikev2_set_local_key_t *mp;
15947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15949 if (unformat (i, "file %v", &file))
15950 vec_add1 (file, 0);
15953 errmsg ("parse error '%U'", format_unformat_error, i);
15958 if (!vec_len (file))
15960 errmsg ("RSA key file must be specified");
15964 if (vec_len (file) > 256)
15966 errmsg ("file name too long");
15970 M (IKEV2_SET_LOCAL_KEY, mp);
15972 clib_memcpy (mp->key_file, file, vec_len (file));
15981 api_ikev2_set_responder (vat_main_t * vam)
15983 unformat_input_t *i = vam->input;
15984 vl_api_ikev2_set_responder_t *mp;
15987 u32 sw_if_index = ~0;
15988 ip4_address_t address;
15990 const char *valid_chars = "a-zA-Z0-9_";
15992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15995 (i, "%U interface %d address %U", unformat_token, valid_chars,
15996 &name, &sw_if_index, unformat_ip4_address, &address))
15997 vec_add1 (name, 0);
16000 errmsg ("parse error '%U'", format_unformat_error, i);
16005 if (!vec_len (name))
16007 errmsg ("profile name must be specified");
16011 if (vec_len (name) > 64)
16013 errmsg ("profile name too long");
16017 M (IKEV2_SET_RESPONDER, mp);
16019 clib_memcpy (mp->name, name, vec_len (name));
16022 mp->sw_if_index = sw_if_index;
16023 clib_memcpy (mp->address, &address, sizeof (address));
16031 api_ikev2_set_ike_transforms (vat_main_t * vam)
16033 unformat_input_t *i = vam->input;
16034 vl_api_ikev2_set_ike_transforms_t *mp;
16037 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16039 const char *valid_chars = "a-zA-Z0-9_";
16041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16043 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16044 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16045 vec_add1 (name, 0);
16048 errmsg ("parse error '%U'", format_unformat_error, i);
16053 if (!vec_len (name))
16055 errmsg ("profile name must be specified");
16059 if (vec_len (name) > 64)
16061 errmsg ("profile name too long");
16065 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16067 clib_memcpy (mp->name, name, vec_len (name));
16069 mp->crypto_alg = crypto_alg;
16070 mp->crypto_key_size = crypto_key_size;
16071 mp->integ_alg = integ_alg;
16072 mp->dh_group = dh_group;
16081 api_ikev2_set_esp_transforms (vat_main_t * vam)
16083 unformat_input_t *i = vam->input;
16084 vl_api_ikev2_set_esp_transforms_t *mp;
16087 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16089 const char *valid_chars = "a-zA-Z0-9_";
16091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16093 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16094 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16095 vec_add1 (name, 0);
16098 errmsg ("parse error '%U'", format_unformat_error, i);
16103 if (!vec_len (name))
16105 errmsg ("profile name must be specified");
16109 if (vec_len (name) > 64)
16111 errmsg ("profile name too long");
16115 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16117 clib_memcpy (mp->name, name, vec_len (name));
16119 mp->crypto_alg = crypto_alg;
16120 mp->crypto_key_size = crypto_key_size;
16121 mp->integ_alg = integ_alg;
16122 mp->dh_group = dh_group;
16130 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16132 unformat_input_t *i = vam->input;
16133 vl_api_ikev2_set_sa_lifetime_t *mp;
16136 u64 lifetime, lifetime_maxdata;
16137 u32 lifetime_jitter, handover;
16139 const char *valid_chars = "a-zA-Z0-9_";
16141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16143 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16144 &lifetime, &lifetime_jitter, &handover,
16145 &lifetime_maxdata))
16146 vec_add1 (name, 0);
16149 errmsg ("parse error '%U'", format_unformat_error, i);
16154 if (!vec_len (name))
16156 errmsg ("profile name must be specified");
16160 if (vec_len (name) > 64)
16162 errmsg ("profile name too long");
16166 M (IKEV2_SET_SA_LIFETIME, mp);
16168 clib_memcpy (mp->name, name, vec_len (name));
16170 mp->lifetime = lifetime;
16171 mp->lifetime_jitter = lifetime_jitter;
16172 mp->handover = handover;
16173 mp->lifetime_maxdata = lifetime_maxdata;
16181 api_ikev2_initiate_sa_init (vat_main_t * vam)
16183 unformat_input_t *i = vam->input;
16184 vl_api_ikev2_initiate_sa_init_t *mp;
16188 const char *valid_chars = "a-zA-Z0-9_";
16190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16192 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16193 vec_add1 (name, 0);
16196 errmsg ("parse error '%U'", format_unformat_error, i);
16201 if (!vec_len (name))
16203 errmsg ("profile name must be specified");
16207 if (vec_len (name) > 64)
16209 errmsg ("profile name too long");
16213 M (IKEV2_INITIATE_SA_INIT, mp);
16215 clib_memcpy (mp->name, name, vec_len (name));
16224 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16226 unformat_input_t *i = vam->input;
16227 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16234 if (unformat (i, "%lx", &ispi))
16238 errmsg ("parse error '%U'", format_unformat_error, i);
16243 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16253 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16255 unformat_input_t *i = vam->input;
16256 vl_api_ikev2_initiate_del_child_sa_t *mp;
16261 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16263 if (unformat (i, "%x", &ispi))
16267 errmsg ("parse error '%U'", format_unformat_error, i);
16272 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16282 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16284 unformat_input_t *i = vam->input;
16285 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16292 if (unformat (i, "%x", &ispi))
16296 errmsg ("parse error '%U'", format_unformat_error, i);
16301 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16314 api_map_add_domain (vat_main_t * vam)
16316 unformat_input_t *i = vam->input;
16317 vl_api_map_add_domain_t *mp;
16319 ip4_address_t ip4_prefix;
16320 ip6_address_t ip6_prefix;
16321 ip6_address_t ip6_src;
16322 u32 num_m_args = 0;
16323 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16324 0, psid_length = 0;
16325 u8 is_translation = 0;
16327 u32 ip6_src_len = 128;
16330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16332 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16333 &ip4_prefix, &ip4_prefix_len))
16335 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16336 &ip6_prefix, &ip6_prefix_len))
16340 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16343 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16345 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16347 else if (unformat (i, "psid-offset %d", &psid_offset))
16349 else if (unformat (i, "psid-len %d", &psid_length))
16351 else if (unformat (i, "mtu %d", &mtu))
16353 else if (unformat (i, "map-t"))
16354 is_translation = 1;
16357 clib_warning ("parse error '%U'", format_unformat_error, i);
16362 if (num_m_args < 3)
16364 errmsg ("mandatory argument(s) missing");
16368 /* Construct the API message */
16369 M (MAP_ADD_DOMAIN, mp);
16371 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16372 mp->ip4_prefix_len = ip4_prefix_len;
16374 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16375 mp->ip6_prefix_len = ip6_prefix_len;
16377 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16378 mp->ip6_src_prefix_len = ip6_src_len;
16380 mp->ea_bits_len = ea_bits_len;
16381 mp->psid_offset = psid_offset;
16382 mp->psid_length = psid_length;
16383 mp->is_translation = is_translation;
16384 mp->mtu = htons (mtu);
16389 /* Wait for a reply, return good/bad news */
16395 api_map_del_domain (vat_main_t * vam)
16397 unformat_input_t *i = vam->input;
16398 vl_api_map_del_domain_t *mp;
16400 u32 num_m_args = 0;
16404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16406 if (unformat (i, "index %d", &index))
16410 clib_warning ("parse error '%U'", format_unformat_error, i);
16415 if (num_m_args != 1)
16417 errmsg ("mandatory argument(s) missing");
16421 /* Construct the API message */
16422 M (MAP_DEL_DOMAIN, mp);
16424 mp->index = ntohl (index);
16429 /* Wait for a reply, return good/bad news */
16435 api_map_add_del_rule (vat_main_t * vam)
16437 unformat_input_t *i = vam->input;
16438 vl_api_map_add_del_rule_t *mp;
16440 ip6_address_t ip6_dst;
16441 u32 num_m_args = 0, index, psid = 0;
16444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16446 if (unformat (i, "index %d", &index))
16448 else if (unformat (i, "psid %d", &psid))
16450 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16452 else if (unformat (i, "del"))
16458 clib_warning ("parse error '%U'", format_unformat_error, i);
16463 /* Construct the API message */
16464 M (MAP_ADD_DEL_RULE, mp);
16466 mp->index = ntohl (index);
16467 mp->is_add = is_add;
16468 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16469 mp->psid = ntohs (psid);
16474 /* Wait for a reply, return good/bad news */
16480 api_map_domain_dump (vat_main_t * vam)
16482 vl_api_map_domain_dump_t *mp;
16483 vl_api_control_ping_t *mp_ping;
16486 /* Construct the API message */
16487 M (MAP_DOMAIN_DUMP, mp);
16492 /* Use a control ping for synchronization */
16493 MPING (CONTROL_PING, mp_ping);
16501 api_map_rule_dump (vat_main_t * vam)
16503 unformat_input_t *i = vam->input;
16504 vl_api_map_rule_dump_t *mp;
16505 vl_api_control_ping_t *mp_ping;
16506 u32 domain_index = ~0;
16509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16511 if (unformat (i, "index %u", &domain_index))
16517 if (domain_index == ~0)
16519 clib_warning ("parse error: domain index expected");
16523 /* Construct the API message */
16524 M (MAP_RULE_DUMP, mp);
16526 mp->domain_index = htonl (domain_index);
16531 /* Use a control ping for synchronization */
16532 MPING (CONTROL_PING, mp_ping);
16539 static void vl_api_map_add_domain_reply_t_handler
16540 (vl_api_map_add_domain_reply_t * mp)
16542 vat_main_t *vam = &vat_main;
16543 i32 retval = ntohl (mp->retval);
16545 if (vam->async_mode)
16547 vam->async_errors += (retval < 0);
16551 vam->retval = retval;
16552 vam->result_ready = 1;
16556 static void vl_api_map_add_domain_reply_t_handler_json
16557 (vl_api_map_add_domain_reply_t * mp)
16559 vat_main_t *vam = &vat_main;
16560 vat_json_node_t node;
16562 vat_json_init_object (&node);
16563 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16564 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16566 vat_json_print (vam->ofp, &node);
16567 vat_json_free (&node);
16569 vam->retval = ntohl (mp->retval);
16570 vam->result_ready = 1;
16574 api_get_first_msg_id (vat_main_t * vam)
16576 vl_api_get_first_msg_id_t *mp;
16577 unformat_input_t *i = vam->input;
16582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16584 if (unformat (i, "client %s", &name))
16592 errmsg ("missing client name");
16595 vec_add1 (name, 0);
16597 if (vec_len (name) > 63)
16599 errmsg ("client name too long");
16603 M (GET_FIRST_MSG_ID, mp);
16604 clib_memcpy (mp->name, name, vec_len (name));
16611 api_cop_interface_enable_disable (vat_main_t * vam)
16613 unformat_input_t *line_input = vam->input;
16614 vl_api_cop_interface_enable_disable_t *mp;
16615 u32 sw_if_index = ~0;
16616 u8 enable_disable = 1;
16619 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16621 if (unformat (line_input, "disable"))
16622 enable_disable = 0;
16623 if (unformat (line_input, "enable"))
16624 enable_disable = 1;
16625 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16626 vam, &sw_if_index))
16628 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16634 if (sw_if_index == ~0)
16636 errmsg ("missing interface name or sw_if_index");
16640 /* Construct the API message */
16641 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16642 mp->sw_if_index = ntohl (sw_if_index);
16643 mp->enable_disable = enable_disable;
16647 /* Wait for the reply */
16653 api_cop_whitelist_enable_disable (vat_main_t * vam)
16655 unformat_input_t *line_input = vam->input;
16656 vl_api_cop_whitelist_enable_disable_t *mp;
16657 u32 sw_if_index = ~0;
16658 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16662 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16664 if (unformat (line_input, "ip4"))
16666 else if (unformat (line_input, "ip6"))
16668 else if (unformat (line_input, "default"))
16670 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16671 vam, &sw_if_index))
16673 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16675 else if (unformat (line_input, "fib-id %d", &fib_id))
16681 if (sw_if_index == ~0)
16683 errmsg ("missing interface name or sw_if_index");
16687 /* Construct the API message */
16688 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16689 mp->sw_if_index = ntohl (sw_if_index);
16690 mp->fib_id = ntohl (fib_id);
16693 mp->default_cop = default_cop;
16697 /* Wait for the reply */
16703 api_get_node_graph (vat_main_t * vam)
16705 vl_api_get_node_graph_t *mp;
16708 M (GET_NODE_GRAPH, mp);
16712 /* Wait for the reply */
16718 /** Used for parsing LISP eids */
16719 typedef CLIB_PACKED(struct{
16720 u8 addr[16]; /**< eid address */
16721 u32 len; /**< prefix length if IP */
16722 u8 type; /**< type of eid */
16727 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16729 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16731 memset (a, 0, sizeof (a[0]));
16733 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16735 a->type = 0; /* ipv4 type */
16737 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16739 a->type = 1; /* ipv6 type */
16741 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16743 a->type = 2; /* mac type */
16745 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16747 a->type = 3; /* NSH type */
16748 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16749 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16756 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16765 lisp_eid_size_vat (u8 type)
16782 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16784 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16788 api_one_add_del_locator_set (vat_main_t * vam)
16790 unformat_input_t *input = vam->input;
16791 vl_api_one_add_del_locator_set_t *mp;
16793 u8 *locator_set_name = NULL;
16794 u8 locator_set_name_set = 0;
16795 vl_api_local_locator_t locator, *locators = 0;
16796 u32 sw_if_index, priority, weight;
16800 /* Parse args required to build the message */
16801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16803 if (unformat (input, "del"))
16807 else if (unformat (input, "locator-set %s", &locator_set_name))
16809 locator_set_name_set = 1;
16811 else if (unformat (input, "sw_if_index %u p %u w %u",
16812 &sw_if_index, &priority, &weight))
16814 locator.sw_if_index = htonl (sw_if_index);
16815 locator.priority = priority;
16816 locator.weight = weight;
16817 vec_add1 (locators, locator);
16821 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16822 &sw_if_index, &priority, &weight))
16824 locator.sw_if_index = htonl (sw_if_index);
16825 locator.priority = priority;
16826 locator.weight = weight;
16827 vec_add1 (locators, locator);
16833 if (locator_set_name_set == 0)
16835 errmsg ("missing locator-set name");
16836 vec_free (locators);
16840 if (vec_len (locator_set_name) > 64)
16842 errmsg ("locator-set name too long");
16843 vec_free (locator_set_name);
16844 vec_free (locators);
16847 vec_add1 (locator_set_name, 0);
16849 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16851 /* Construct the API message */
16852 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16854 mp->is_add = is_add;
16855 clib_memcpy (mp->locator_set_name, locator_set_name,
16856 vec_len (locator_set_name));
16857 vec_free (locator_set_name);
16859 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16861 clib_memcpy (mp->locators, locators, data_len);
16862 vec_free (locators);
16867 /* Wait for a reply... */
16872 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16875 api_one_add_del_locator (vat_main_t * vam)
16877 unformat_input_t *input = vam->input;
16878 vl_api_one_add_del_locator_t *mp;
16879 u32 tmp_if_index = ~0;
16880 u32 sw_if_index = ~0;
16881 u8 sw_if_index_set = 0;
16882 u8 sw_if_index_if_name_set = 0;
16884 u8 priority_set = 0;
16888 u8 *locator_set_name = NULL;
16889 u8 locator_set_name_set = 0;
16892 /* Parse args required to build the message */
16893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16895 if (unformat (input, "del"))
16899 else if (unformat (input, "locator-set %s", &locator_set_name))
16901 locator_set_name_set = 1;
16903 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16906 sw_if_index_if_name_set = 1;
16907 sw_if_index = tmp_if_index;
16909 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16911 sw_if_index_set = 1;
16912 sw_if_index = tmp_if_index;
16914 else if (unformat (input, "p %d", &priority))
16918 else if (unformat (input, "w %d", &weight))
16926 if (locator_set_name_set == 0)
16928 errmsg ("missing locator-set name");
16932 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16934 errmsg ("missing sw_if_index");
16935 vec_free (locator_set_name);
16939 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16941 errmsg ("cannot use both params interface name and sw_if_index");
16942 vec_free (locator_set_name);
16946 if (priority_set == 0)
16948 errmsg ("missing locator-set priority");
16949 vec_free (locator_set_name);
16953 if (weight_set == 0)
16955 errmsg ("missing locator-set weight");
16956 vec_free (locator_set_name);
16960 if (vec_len (locator_set_name) > 64)
16962 errmsg ("locator-set name too long");
16963 vec_free (locator_set_name);
16966 vec_add1 (locator_set_name, 0);
16968 /* Construct the API message */
16969 M (ONE_ADD_DEL_LOCATOR, mp);
16971 mp->is_add = is_add;
16972 mp->sw_if_index = ntohl (sw_if_index);
16973 mp->priority = priority;
16974 mp->weight = weight;
16975 clib_memcpy (mp->locator_set_name, locator_set_name,
16976 vec_len (locator_set_name));
16977 vec_free (locator_set_name);
16982 /* Wait for a reply... */
16987 #define api_lisp_add_del_locator api_one_add_del_locator
16990 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16992 u32 *key_id = va_arg (*args, u32 *);
16995 if (unformat (input, "%s", &s))
16997 if (!strcmp ((char *) s, "sha1"))
16998 key_id[0] = HMAC_SHA_1_96;
16999 else if (!strcmp ((char *) s, "sha256"))
17000 key_id[0] = HMAC_SHA_256_128;
17003 clib_warning ("invalid key_id: '%s'", s);
17004 key_id[0] = HMAC_NO_KEY;
17015 api_one_add_del_local_eid (vat_main_t * vam)
17017 unformat_input_t *input = vam->input;
17018 vl_api_one_add_del_local_eid_t *mp;
17021 lisp_eid_vat_t _eid, *eid = &_eid;
17022 u8 *locator_set_name = 0;
17023 u8 locator_set_name_set = 0;
17029 /* Parse args required to build the message */
17030 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17032 if (unformat (input, "del"))
17036 else if (unformat (input, "vni %d", &vni))
17040 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17044 else if (unformat (input, "locator-set %s", &locator_set_name))
17046 locator_set_name_set = 1;
17048 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17050 else if (unformat (input, "secret-key %_%v%_", &key))
17056 if (locator_set_name_set == 0)
17058 errmsg ("missing locator-set name");
17064 errmsg ("EID address not set!");
17065 vec_free (locator_set_name);
17069 if (key && (0 == key_id))
17071 errmsg ("invalid key_id!");
17075 if (vec_len (key) > 64)
17077 errmsg ("key too long");
17082 if (vec_len (locator_set_name) > 64)
17084 errmsg ("locator-set name too long");
17085 vec_free (locator_set_name);
17088 vec_add1 (locator_set_name, 0);
17090 /* Construct the API message */
17091 M (ONE_ADD_DEL_LOCAL_EID, mp);
17093 mp->is_add = is_add;
17094 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17095 mp->eid_type = eid->type;
17096 mp->prefix_len = eid->len;
17097 mp->vni = clib_host_to_net_u32 (vni);
17098 mp->key_id = clib_host_to_net_u16 (key_id);
17099 clib_memcpy (mp->locator_set_name, locator_set_name,
17100 vec_len (locator_set_name));
17101 clib_memcpy (mp->key, key, vec_len (key));
17103 vec_free (locator_set_name);
17109 /* Wait for a reply... */
17114 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17117 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17119 u32 dp_table = 0, vni = 0;;
17120 unformat_input_t *input = vam->input;
17121 vl_api_gpe_add_del_fwd_entry_t *mp;
17123 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17124 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17125 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17126 u32 action = ~0, w;
17127 ip4_address_t rmt_rloc4, lcl_rloc4;
17128 ip6_address_t rmt_rloc6, lcl_rloc6;
17129 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17132 memset (&rloc, 0, sizeof (rloc));
17134 /* Parse args required to build the message */
17135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17137 if (unformat (input, "del"))
17139 else if (unformat (input, "add"))
17141 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17145 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17149 else if (unformat (input, "vrf %d", &dp_table))
17151 else if (unformat (input, "bd %d", &dp_table))
17153 else if (unformat (input, "vni %d", &vni))
17155 else if (unformat (input, "w %d", &w))
17159 errmsg ("No RLOC configured for setting priority/weight!");
17162 curr_rloc->weight = w;
17164 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17165 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17169 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17171 vec_add1 (lcl_locs, rloc);
17173 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17174 vec_add1 (rmt_locs, rloc);
17175 /* weight saved in rmt loc */
17176 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17178 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17179 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17182 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17184 vec_add1 (lcl_locs, rloc);
17186 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17187 vec_add1 (rmt_locs, rloc);
17188 /* weight saved in rmt loc */
17189 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17191 else if (unformat (input, "action %d", &action))
17197 clib_warning ("parse error '%U'", format_unformat_error, input);
17204 errmsg ("remote eid addresses not set");
17208 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17210 errmsg ("eid types don't match");
17214 if (0 == rmt_locs && (u32) ~ 0 == action)
17216 errmsg ("action not set for negative mapping");
17220 /* Construct the API message */
17221 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17222 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17224 mp->is_add = is_add;
17225 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17226 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17227 mp->eid_type = rmt_eid->type;
17228 mp->dp_table = clib_host_to_net_u32 (dp_table);
17229 mp->vni = clib_host_to_net_u32 (vni);
17230 mp->rmt_len = rmt_eid->len;
17231 mp->lcl_len = lcl_eid->len;
17232 mp->action = action;
17234 if (0 != rmt_locs && 0 != lcl_locs)
17236 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17237 clib_memcpy (mp->locs, lcl_locs,
17238 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17240 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17241 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17242 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17244 vec_free (lcl_locs);
17245 vec_free (rmt_locs);
17250 /* Wait for a reply... */
17256 api_one_add_del_map_server (vat_main_t * vam)
17258 unformat_input_t *input = vam->input;
17259 vl_api_one_add_del_map_server_t *mp;
17263 ip4_address_t ipv4;
17264 ip6_address_t ipv6;
17267 /* Parse args required to build the message */
17268 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17270 if (unformat (input, "del"))
17274 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17278 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17286 if (ipv4_set && ipv6_set)
17288 errmsg ("both eid v4 and v6 addresses set");
17292 if (!ipv4_set && !ipv6_set)
17294 errmsg ("eid addresses not set");
17298 /* Construct the API message */
17299 M (ONE_ADD_DEL_MAP_SERVER, mp);
17301 mp->is_add = is_add;
17305 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17310 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17316 /* Wait for a reply... */
17321 #define api_lisp_add_del_map_server api_one_add_del_map_server
17324 api_one_add_del_map_resolver (vat_main_t * vam)
17326 unformat_input_t *input = vam->input;
17327 vl_api_one_add_del_map_resolver_t *mp;
17331 ip4_address_t ipv4;
17332 ip6_address_t ipv6;
17335 /* Parse args required to build the message */
17336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17338 if (unformat (input, "del"))
17342 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17346 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17354 if (ipv4_set && ipv6_set)
17356 errmsg ("both eid v4 and v6 addresses set");
17360 if (!ipv4_set && !ipv6_set)
17362 errmsg ("eid addresses not set");
17366 /* Construct the API message */
17367 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17369 mp->is_add = is_add;
17373 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17378 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17384 /* Wait for a reply... */
17389 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17392 api_lisp_gpe_enable_disable (vat_main_t * vam)
17394 unformat_input_t *input = vam->input;
17395 vl_api_gpe_enable_disable_t *mp;
17400 /* Parse args required to build the message */
17401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17403 if (unformat (input, "enable"))
17408 else if (unformat (input, "disable"))
17419 errmsg ("Value not set");
17423 /* Construct the API message */
17424 M (GPE_ENABLE_DISABLE, mp);
17431 /* Wait for a reply... */
17437 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17439 unformat_input_t *input = vam->input;
17440 vl_api_one_rloc_probe_enable_disable_t *mp;
17445 /* Parse args required to build the message */
17446 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17448 if (unformat (input, "enable"))
17453 else if (unformat (input, "disable"))
17461 errmsg ("Value not set");
17465 /* Construct the API message */
17466 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17468 mp->is_enabled = is_en;
17473 /* Wait for a reply... */
17478 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17481 api_one_map_register_enable_disable (vat_main_t * vam)
17483 unformat_input_t *input = vam->input;
17484 vl_api_one_map_register_enable_disable_t *mp;
17489 /* Parse args required to build the message */
17490 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17492 if (unformat (input, "enable"))
17497 else if (unformat (input, "disable"))
17505 errmsg ("Value not set");
17509 /* Construct the API message */
17510 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17512 mp->is_enabled = is_en;
17517 /* Wait for a reply... */
17522 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17525 api_one_enable_disable (vat_main_t * vam)
17527 unformat_input_t *input = vam->input;
17528 vl_api_one_enable_disable_t *mp;
17533 /* Parse args required to build the message */
17534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17536 if (unformat (input, "enable"))
17541 else if (unformat (input, "disable"))
17551 errmsg ("Value not set");
17555 /* Construct the API message */
17556 M (ONE_ENABLE_DISABLE, mp);
17563 /* Wait for a reply... */
17568 #define api_lisp_enable_disable api_one_enable_disable
17571 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17573 unformat_input_t *input = vam->input;
17574 vl_api_one_enable_disable_xtr_mode_t *mp;
17579 /* Parse args required to build the message */
17580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17582 if (unformat (input, "enable"))
17587 else if (unformat (input, "disable"))
17597 errmsg ("Value not set");
17601 /* Construct the API message */
17602 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17609 /* Wait for a reply... */
17615 api_one_show_xtr_mode (vat_main_t * vam)
17617 vl_api_one_show_xtr_mode_t *mp;
17620 /* Construct the API message */
17621 M (ONE_SHOW_XTR_MODE, mp);
17626 /* Wait for a reply... */
17632 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17634 unformat_input_t *input = vam->input;
17635 vl_api_one_enable_disable_pitr_mode_t *mp;
17640 /* Parse args required to build the message */
17641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17643 if (unformat (input, "enable"))
17648 else if (unformat (input, "disable"))
17658 errmsg ("Value not set");
17662 /* Construct the API message */
17663 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17670 /* Wait for a reply... */
17676 api_one_show_pitr_mode (vat_main_t * vam)
17678 vl_api_one_show_pitr_mode_t *mp;
17681 /* Construct the API message */
17682 M (ONE_SHOW_PITR_MODE, mp);
17687 /* Wait for a reply... */
17693 api_one_enable_disable_petr_mode (vat_main_t * vam)
17695 unformat_input_t *input = vam->input;
17696 vl_api_one_enable_disable_petr_mode_t *mp;
17701 /* Parse args required to build the message */
17702 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17704 if (unformat (input, "enable"))
17709 else if (unformat (input, "disable"))
17719 errmsg ("Value not set");
17723 /* Construct the API message */
17724 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17731 /* Wait for a reply... */
17737 api_one_show_petr_mode (vat_main_t * vam)
17739 vl_api_one_show_petr_mode_t *mp;
17742 /* Construct the API message */
17743 M (ONE_SHOW_PETR_MODE, mp);
17748 /* Wait for a reply... */
17754 api_show_one_map_register_state (vat_main_t * vam)
17756 vl_api_show_one_map_register_state_t *mp;
17759 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17764 /* wait for reply */
17769 #define api_show_lisp_map_register_state api_show_one_map_register_state
17772 api_show_one_rloc_probe_state (vat_main_t * vam)
17774 vl_api_show_one_rloc_probe_state_t *mp;
17777 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17782 /* wait for reply */
17787 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17790 api_one_add_del_ndp_entry (vat_main_t * vam)
17792 vl_api_one_add_del_ndp_entry_t *mp;
17793 unformat_input_t *input = vam->input;
17798 u8 mac[6] = { 0, };
17799 u8 ip6[16] = { 0, };
17803 /* Parse args required to build the message */
17804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17806 if (unformat (input, "del"))
17808 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17810 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17812 else if (unformat (input, "bd %d", &bd))
17816 errmsg ("parse error '%U'", format_unformat_error, input);
17821 if (!bd_set || !ip_set || (!mac_set && is_add))
17823 errmsg ("Missing BD, IP or MAC!");
17827 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17828 mp->is_add = is_add;
17829 clib_memcpy (mp->mac, mac, 6);
17830 mp->bd = clib_host_to_net_u32 (bd);
17831 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17836 /* wait for reply */
17842 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17844 vl_api_one_add_del_l2_arp_entry_t *mp;
17845 unformat_input_t *input = vam->input;
17850 u8 mac[6] = { 0, };
17851 u32 ip4 = 0, bd = ~0;
17854 /* Parse args required to build the message */
17855 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17857 if (unformat (input, "del"))
17859 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17861 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17863 else if (unformat (input, "bd %d", &bd))
17867 errmsg ("parse error '%U'", format_unformat_error, input);
17872 if (!bd_set || !ip_set || (!mac_set && is_add))
17874 errmsg ("Missing BD, IP or MAC!");
17878 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17879 mp->is_add = is_add;
17880 clib_memcpy (mp->mac, mac, 6);
17881 mp->bd = clib_host_to_net_u32 (bd);
17887 /* wait for reply */
17893 api_one_ndp_bd_get (vat_main_t * vam)
17895 vl_api_one_ndp_bd_get_t *mp;
17898 M (ONE_NDP_BD_GET, mp);
17903 /* wait for reply */
17909 api_one_ndp_entries_get (vat_main_t * vam)
17911 vl_api_one_ndp_entries_get_t *mp;
17912 unformat_input_t *input = vam->input;
17917 /* Parse args required to build the message */
17918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17920 if (unformat (input, "bd %d", &bd))
17924 errmsg ("parse error '%U'", format_unformat_error, input);
17931 errmsg ("Expected bridge domain!");
17935 M (ONE_NDP_ENTRIES_GET, mp);
17936 mp->bd = clib_host_to_net_u32 (bd);
17941 /* wait for reply */
17947 api_one_l2_arp_bd_get (vat_main_t * vam)
17949 vl_api_one_l2_arp_bd_get_t *mp;
17952 M (ONE_L2_ARP_BD_GET, mp);
17957 /* wait for reply */
17963 api_one_l2_arp_entries_get (vat_main_t * vam)
17965 vl_api_one_l2_arp_entries_get_t *mp;
17966 unformat_input_t *input = vam->input;
17971 /* Parse args required to build the message */
17972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17974 if (unformat (input, "bd %d", &bd))
17978 errmsg ("parse error '%U'", format_unformat_error, input);
17985 errmsg ("Expected bridge domain!");
17989 M (ONE_L2_ARP_ENTRIES_GET, mp);
17990 mp->bd = clib_host_to_net_u32 (bd);
17995 /* wait for reply */
18001 api_one_stats_enable_disable (vat_main_t * vam)
18003 vl_api_one_stats_enable_disable_t *mp;
18004 unformat_input_t *input = vam->input;
18009 /* Parse args required to build the message */
18010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18012 if (unformat (input, "enable"))
18017 else if (unformat (input, "disable"))
18027 errmsg ("Value not set");
18031 M (ONE_STATS_ENABLE_DISABLE, mp);
18037 /* wait for reply */
18043 api_show_one_stats_enable_disable (vat_main_t * vam)
18045 vl_api_show_one_stats_enable_disable_t *mp;
18048 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18053 /* wait for reply */
18059 api_show_one_map_request_mode (vat_main_t * vam)
18061 vl_api_show_one_map_request_mode_t *mp;
18064 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18069 /* wait for reply */
18074 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18077 api_one_map_request_mode (vat_main_t * vam)
18079 unformat_input_t *input = vam->input;
18080 vl_api_one_map_request_mode_t *mp;
18084 /* Parse args required to build the message */
18085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18087 if (unformat (input, "dst-only"))
18089 else if (unformat (input, "src-dst"))
18093 errmsg ("parse error '%U'", format_unformat_error, input);
18098 M (ONE_MAP_REQUEST_MODE, mp);
18105 /* wait for reply */
18110 #define api_lisp_map_request_mode api_one_map_request_mode
18113 * Enable/disable ONE proxy ITR.
18115 * @param vam vpp API test context
18116 * @return return code
18119 api_one_pitr_set_locator_set (vat_main_t * vam)
18121 u8 ls_name_set = 0;
18122 unformat_input_t *input = vam->input;
18123 vl_api_one_pitr_set_locator_set_t *mp;
18128 /* Parse args required to build the message */
18129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18131 if (unformat (input, "del"))
18133 else if (unformat (input, "locator-set %s", &ls_name))
18137 errmsg ("parse error '%U'", format_unformat_error, input);
18144 errmsg ("locator-set name not set!");
18148 M (ONE_PITR_SET_LOCATOR_SET, mp);
18150 mp->is_add = is_add;
18151 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18152 vec_free (ls_name);
18157 /* wait for reply */
18162 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18165 api_one_nsh_set_locator_set (vat_main_t * vam)
18167 u8 ls_name_set = 0;
18168 unformat_input_t *input = vam->input;
18169 vl_api_one_nsh_set_locator_set_t *mp;
18174 /* Parse args required to build the message */
18175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18177 if (unformat (input, "del"))
18179 else if (unformat (input, "ls %s", &ls_name))
18183 errmsg ("parse error '%U'", format_unformat_error, input);
18188 if (!ls_name_set && is_add)
18190 errmsg ("locator-set name not set!");
18194 M (ONE_NSH_SET_LOCATOR_SET, mp);
18196 mp->is_add = is_add;
18197 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18198 vec_free (ls_name);
18203 /* wait for reply */
18209 api_show_one_pitr (vat_main_t * vam)
18211 vl_api_show_one_pitr_t *mp;
18214 if (!vam->json_output)
18216 print (vam->ofp, "%=20s", "lisp status:");
18219 M (SHOW_ONE_PITR, mp);
18223 /* Wait for a reply... */
18228 #define api_show_lisp_pitr api_show_one_pitr
18231 api_one_use_petr (vat_main_t * vam)
18233 unformat_input_t *input = vam->input;
18234 vl_api_one_use_petr_t *mp;
18239 memset (&ip, 0, sizeof (ip));
18241 /* Parse args required to build the message */
18242 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18244 if (unformat (input, "disable"))
18247 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18250 ip_addr_version (&ip) = IP4;
18253 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18256 ip_addr_version (&ip) = IP6;
18260 errmsg ("parse error '%U'", format_unformat_error, input);
18265 M (ONE_USE_PETR, mp);
18267 mp->is_add = is_add;
18270 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18272 clib_memcpy (mp->address, &ip, 4);
18274 clib_memcpy (mp->address, &ip, 16);
18280 /* wait for reply */
18285 #define api_lisp_use_petr api_one_use_petr
18288 api_show_one_nsh_mapping (vat_main_t * vam)
18290 vl_api_show_one_use_petr_t *mp;
18293 if (!vam->json_output)
18295 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18298 M (SHOW_ONE_NSH_MAPPING, mp);
18302 /* Wait for a reply... */
18308 api_show_one_use_petr (vat_main_t * vam)
18310 vl_api_show_one_use_petr_t *mp;
18313 if (!vam->json_output)
18315 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18318 M (SHOW_ONE_USE_PETR, mp);
18322 /* Wait for a reply... */
18327 #define api_show_lisp_use_petr api_show_one_use_petr
18330 * Add/delete mapping between vni and vrf
18333 api_one_eid_table_add_del_map (vat_main_t * vam)
18335 unformat_input_t *input = vam->input;
18336 vl_api_one_eid_table_add_del_map_t *mp;
18337 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18338 u32 vni, vrf, bd_index;
18341 /* Parse args required to build the message */
18342 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18344 if (unformat (input, "del"))
18346 else if (unformat (input, "vrf %d", &vrf))
18348 else if (unformat (input, "bd_index %d", &bd_index))
18350 else if (unformat (input, "vni %d", &vni))
18356 if (!vni_set || (!vrf_set && !bd_index_set))
18358 errmsg ("missing arguments!");
18362 if (vrf_set && bd_index_set)
18364 errmsg ("error: both vrf and bd entered!");
18368 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18370 mp->is_add = is_add;
18371 mp->vni = htonl (vni);
18372 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18373 mp->is_l2 = bd_index_set;
18378 /* wait for reply */
18383 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18386 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18388 u32 *action = va_arg (*args, u32 *);
18391 if (unformat (input, "%s", &s))
18393 if (!strcmp ((char *) s, "no-action"))
18395 else if (!strcmp ((char *) s, "natively-forward"))
18397 else if (!strcmp ((char *) s, "send-map-request"))
18399 else if (!strcmp ((char *) s, "drop"))
18403 clib_warning ("invalid action: '%s'", s);
18415 * Add/del remote mapping to/from ONE control plane
18417 * @param vam vpp API test context
18418 * @return return code
18421 api_one_add_del_remote_mapping (vat_main_t * vam)
18423 unformat_input_t *input = vam->input;
18424 vl_api_one_add_del_remote_mapping_t *mp;
18426 lisp_eid_vat_t _eid, *eid = &_eid;
18427 lisp_eid_vat_t _seid, *seid = &_seid;
18428 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18429 u32 action = ~0, p, w, data_len;
18430 ip4_address_t rloc4;
18431 ip6_address_t rloc6;
18432 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18435 memset (&rloc, 0, sizeof (rloc));
18437 /* Parse args required to build the message */
18438 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18440 if (unformat (input, "del-all"))
18444 else if (unformat (input, "del"))
18448 else if (unformat (input, "add"))
18452 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18456 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18460 else if (unformat (input, "vni %d", &vni))
18464 else if (unformat (input, "p %d w %d", &p, &w))
18468 errmsg ("No RLOC configured for setting priority/weight!");
18471 curr_rloc->priority = p;
18472 curr_rloc->weight = w;
18474 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18477 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18478 vec_add1 (rlocs, rloc);
18479 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18481 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18484 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18485 vec_add1 (rlocs, rloc);
18486 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18488 else if (unformat (input, "action %U",
18489 unformat_negative_mapping_action, &action))
18495 clib_warning ("parse error '%U'", format_unformat_error, input);
18502 errmsg ("missing params!");
18506 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18508 errmsg ("no action set for negative map-reply!");
18512 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18514 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18515 mp->is_add = is_add;
18516 mp->vni = htonl (vni);
18517 mp->action = (u8) action;
18518 mp->is_src_dst = seid_set;
18519 mp->eid_len = eid->len;
18520 mp->seid_len = seid->len;
18521 mp->del_all = del_all;
18522 mp->eid_type = eid->type;
18523 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18524 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18526 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18527 clib_memcpy (mp->rlocs, rlocs, data_len);
18533 /* Wait for a reply... */
18538 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18541 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18542 * forwarding entries in data-plane accordingly.
18544 * @param vam vpp API test context
18545 * @return return code
18548 api_one_add_del_adjacency (vat_main_t * vam)
18550 unformat_input_t *input = vam->input;
18551 vl_api_one_add_del_adjacency_t *mp;
18553 ip4_address_t leid4, reid4;
18554 ip6_address_t leid6, reid6;
18555 u8 reid_mac[6] = { 0 };
18556 u8 leid_mac[6] = { 0 };
18557 u8 reid_type, leid_type;
18558 u32 leid_len = 0, reid_len = 0, len;
18562 leid_type = reid_type = (u8) ~ 0;
18564 /* Parse args required to build the message */
18565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18567 if (unformat (input, "del"))
18571 else if (unformat (input, "add"))
18575 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18578 reid_type = 0; /* ipv4 */
18581 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18584 reid_type = 1; /* ipv6 */
18587 else if (unformat (input, "reid %U", unformat_ethernet_address,
18590 reid_type = 2; /* mac */
18592 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18595 leid_type = 0; /* ipv4 */
18598 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18601 leid_type = 1; /* ipv6 */
18604 else if (unformat (input, "leid %U", unformat_ethernet_address,
18607 leid_type = 2; /* mac */
18609 else if (unformat (input, "vni %d", &vni))
18615 errmsg ("parse error '%U'", format_unformat_error, input);
18620 if ((u8) ~ 0 == reid_type)
18622 errmsg ("missing params!");
18626 if (leid_type != reid_type)
18628 errmsg ("remote and local EIDs are of different types!");
18632 M (ONE_ADD_DEL_ADJACENCY, mp);
18633 mp->is_add = is_add;
18634 mp->vni = htonl (vni);
18635 mp->leid_len = leid_len;
18636 mp->reid_len = reid_len;
18637 mp->eid_type = reid_type;
18639 switch (mp->eid_type)
18642 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18643 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18646 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18647 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18650 clib_memcpy (mp->leid, leid_mac, 6);
18651 clib_memcpy (mp->reid, reid_mac, 6);
18654 errmsg ("unknown EID type %d!", mp->eid_type);
18661 /* Wait for a reply... */
18666 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18669 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18671 u32 *mode = va_arg (*args, u32 *);
18673 if (unformat (input, "lisp"))
18675 else if (unformat (input, "vxlan"))
18684 api_gpe_get_encap_mode (vat_main_t * vam)
18686 vl_api_gpe_get_encap_mode_t *mp;
18689 /* Construct the API message */
18690 M (GPE_GET_ENCAP_MODE, mp);
18695 /* Wait for a reply... */
18701 api_gpe_set_encap_mode (vat_main_t * vam)
18703 unformat_input_t *input = vam->input;
18704 vl_api_gpe_set_encap_mode_t *mp;
18708 /* Parse args required to build the message */
18709 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18711 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18717 /* Construct the API message */
18718 M (GPE_SET_ENCAP_MODE, mp);
18725 /* Wait for a reply... */
18731 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18733 unformat_input_t *input = vam->input;
18734 vl_api_gpe_add_del_iface_t *mp;
18735 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18736 u32 dp_table = 0, vni = 0;
18739 /* Parse args required to build the message */
18740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18742 if (unformat (input, "up"))
18747 else if (unformat (input, "down"))
18752 else if (unformat (input, "table_id %d", &dp_table))
18756 else if (unformat (input, "bd_id %d", &dp_table))
18761 else if (unformat (input, "vni %d", &vni))
18769 if (action_set == 0)
18771 errmsg ("Action not set");
18774 if (dp_table_set == 0 || vni_set == 0)
18776 errmsg ("vni and dp_table must be set");
18780 /* Construct the API message */
18781 M (GPE_ADD_DEL_IFACE, mp);
18783 mp->is_add = is_add;
18784 mp->dp_table = clib_host_to_net_u32 (dp_table);
18786 mp->vni = clib_host_to_net_u32 (vni);
18791 /* Wait for a reply... */
18797 api_one_map_register_fallback_threshold (vat_main_t * vam)
18799 unformat_input_t *input = vam->input;
18800 vl_api_one_map_register_fallback_threshold_t *mp;
18805 /* Parse args required to build the message */
18806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18808 if (unformat (input, "%u", &value))
18812 clib_warning ("parse error '%U'", format_unformat_error, input);
18819 errmsg ("fallback threshold value is missing!");
18823 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18824 mp->value = clib_host_to_net_u32 (value);
18829 /* Wait for a reply... */
18835 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18837 vl_api_show_one_map_register_fallback_threshold_t *mp;
18840 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18845 /* Wait for a reply... */
18851 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18853 u32 *proto = va_arg (*args, u32 *);
18855 if (unformat (input, "udp"))
18857 else if (unformat (input, "api"))
18866 api_one_set_transport_protocol (vat_main_t * vam)
18868 unformat_input_t *input = vam->input;
18869 vl_api_one_set_transport_protocol_t *mp;
18874 /* Parse args required to build the message */
18875 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18877 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18881 clib_warning ("parse error '%U'", format_unformat_error, input);
18888 errmsg ("Transport protocol missing!");
18892 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18893 mp->protocol = (u8) protocol;
18898 /* Wait for a reply... */
18904 api_one_get_transport_protocol (vat_main_t * vam)
18906 vl_api_one_get_transport_protocol_t *mp;
18909 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18914 /* Wait for a reply... */
18920 api_one_map_register_set_ttl (vat_main_t * vam)
18922 unformat_input_t *input = vam->input;
18923 vl_api_one_map_register_set_ttl_t *mp;
18928 /* Parse args required to build the message */
18929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18931 if (unformat (input, "%u", &ttl))
18935 clib_warning ("parse error '%U'", format_unformat_error, input);
18942 errmsg ("TTL value missing!");
18946 M (ONE_MAP_REGISTER_SET_TTL, mp);
18947 mp->ttl = clib_host_to_net_u32 (ttl);
18952 /* Wait for a reply... */
18958 api_show_one_map_register_ttl (vat_main_t * vam)
18960 vl_api_show_one_map_register_ttl_t *mp;
18963 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18968 /* Wait for a reply... */
18974 * Add/del map request itr rlocs from ONE control plane and updates
18976 * @param vam vpp API test context
18977 * @return return code
18980 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18982 unformat_input_t *input = vam->input;
18983 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18984 u8 *locator_set_name = 0;
18985 u8 locator_set_name_set = 0;
18989 /* Parse args required to build the message */
18990 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18992 if (unformat (input, "del"))
18996 else if (unformat (input, "%_%v%_", &locator_set_name))
18998 locator_set_name_set = 1;
19002 clib_warning ("parse error '%U'", format_unformat_error, input);
19007 if (is_add && !locator_set_name_set)
19009 errmsg ("itr-rloc is not set!");
19013 if (is_add && vec_len (locator_set_name) > 64)
19015 errmsg ("itr-rloc locator-set name too long");
19016 vec_free (locator_set_name);
19020 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19021 mp->is_add = is_add;
19024 clib_memcpy (mp->locator_set_name, locator_set_name,
19025 vec_len (locator_set_name));
19029 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19031 vec_free (locator_set_name);
19036 /* Wait for a reply... */
19041 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19044 api_one_locator_dump (vat_main_t * vam)
19046 unformat_input_t *input = vam->input;
19047 vl_api_one_locator_dump_t *mp;
19048 vl_api_control_ping_t *mp_ping;
19049 u8 is_index_set = 0, is_name_set = 0;
19054 /* Parse args required to build the message */
19055 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19057 if (unformat (input, "ls_name %_%v%_", &ls_name))
19061 else if (unformat (input, "ls_index %d", &ls_index))
19067 errmsg ("parse error '%U'", format_unformat_error, input);
19072 if (!is_index_set && !is_name_set)
19074 errmsg ("error: expected one of index or name!");
19078 if (is_index_set && is_name_set)
19080 errmsg ("error: only one param expected!");
19084 if (vec_len (ls_name) > 62)
19086 errmsg ("error: locator set name too long!");
19090 if (!vam->json_output)
19092 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19095 M (ONE_LOCATOR_DUMP, mp);
19096 mp->is_index_set = is_index_set;
19099 mp->ls_index = clib_host_to_net_u32 (ls_index);
19102 vec_add1 (ls_name, 0);
19103 strncpy ((char *) mp->ls_name, (char *) ls_name,
19104 sizeof (mp->ls_name) - 1);
19110 /* Use a control ping for synchronization */
19111 MPING (CONTROL_PING, mp_ping);
19114 /* Wait for a reply... */
19119 #define api_lisp_locator_dump api_one_locator_dump
19122 api_one_locator_set_dump (vat_main_t * vam)
19124 vl_api_one_locator_set_dump_t *mp;
19125 vl_api_control_ping_t *mp_ping;
19126 unformat_input_t *input = vam->input;
19130 /* Parse args required to build the message */
19131 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19133 if (unformat (input, "local"))
19137 else if (unformat (input, "remote"))
19143 errmsg ("parse error '%U'", format_unformat_error, input);
19148 if (!vam->json_output)
19150 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19153 M (ONE_LOCATOR_SET_DUMP, mp);
19155 mp->filter = filter;
19160 /* Use a control ping for synchronization */
19161 MPING (CONTROL_PING, mp_ping);
19164 /* Wait for a reply... */
19169 #define api_lisp_locator_set_dump api_one_locator_set_dump
19172 api_one_eid_table_map_dump (vat_main_t * vam)
19176 unformat_input_t *input = vam->input;
19177 vl_api_one_eid_table_map_dump_t *mp;
19178 vl_api_control_ping_t *mp_ping;
19181 /* Parse args required to build the message */
19182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19184 if (unformat (input, "l2"))
19189 else if (unformat (input, "l3"))
19196 errmsg ("parse error '%U'", format_unformat_error, input);
19203 errmsg ("expected one of 'l2' or 'l3' parameter!");
19207 if (!vam->json_output)
19209 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19212 M (ONE_EID_TABLE_MAP_DUMP, mp);
19218 /* Use a control ping for synchronization */
19219 MPING (CONTROL_PING, mp_ping);
19222 /* Wait for a reply... */
19227 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19230 api_one_eid_table_vni_dump (vat_main_t * vam)
19232 vl_api_one_eid_table_vni_dump_t *mp;
19233 vl_api_control_ping_t *mp_ping;
19236 if (!vam->json_output)
19238 print (vam->ofp, "VNI");
19241 M (ONE_EID_TABLE_VNI_DUMP, mp);
19246 /* Use a control ping for synchronization */
19247 MPING (CONTROL_PING, mp_ping);
19250 /* Wait for a reply... */
19255 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19258 api_one_eid_table_dump (vat_main_t * vam)
19260 unformat_input_t *i = vam->input;
19261 vl_api_one_eid_table_dump_t *mp;
19262 vl_api_control_ping_t *mp_ping;
19263 struct in_addr ip4;
19264 struct in6_addr ip6;
19266 u8 eid_type = ~0, eid_set = 0;
19267 u32 prefix_length = ~0, t, vni = 0;
19270 lisp_nsh_api_t nsh;
19272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19274 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19280 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19286 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19291 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19296 else if (unformat (i, "vni %d", &t))
19300 else if (unformat (i, "local"))
19304 else if (unformat (i, "remote"))
19310 errmsg ("parse error '%U'", format_unformat_error, i);
19315 if (!vam->json_output)
19317 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19318 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19321 M (ONE_EID_TABLE_DUMP, mp);
19323 mp->filter = filter;
19327 mp->vni = htonl (vni);
19328 mp->eid_type = eid_type;
19332 mp->prefix_length = prefix_length;
19333 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19336 mp->prefix_length = prefix_length;
19337 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19340 clib_memcpy (mp->eid, mac, sizeof (mac));
19343 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19346 errmsg ("unknown EID type %d!", eid_type);
19354 /* Use a control ping for synchronization */
19355 MPING (CONTROL_PING, mp_ping);
19358 /* Wait for a reply... */
19363 #define api_lisp_eid_table_dump api_one_eid_table_dump
19366 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19368 unformat_input_t *i = vam->input;
19369 vl_api_gpe_fwd_entries_get_t *mp;
19374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19376 if (unformat (i, "vni %d", &vni))
19382 errmsg ("parse error '%U'", format_unformat_error, i);
19389 errmsg ("vni not set!");
19393 if (!vam->json_output)
19395 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19399 M (GPE_FWD_ENTRIES_GET, mp);
19400 mp->vni = clib_host_to_net_u32 (vni);
19405 /* Wait for a reply... */
19410 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19411 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19412 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19413 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19414 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19415 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19416 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19417 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19420 api_one_adjacencies_get (vat_main_t * vam)
19422 unformat_input_t *i = vam->input;
19423 vl_api_one_adjacencies_get_t *mp;
19428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19430 if (unformat (i, "vni %d", &vni))
19436 errmsg ("parse error '%U'", format_unformat_error, i);
19443 errmsg ("vni not set!");
19447 if (!vam->json_output)
19449 print (vam->ofp, "%s %40s", "leid", "reid");
19452 M (ONE_ADJACENCIES_GET, mp);
19453 mp->vni = clib_host_to_net_u32 (vni);
19458 /* Wait for a reply... */
19463 #define api_lisp_adjacencies_get api_one_adjacencies_get
19466 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19468 unformat_input_t *i = vam->input;
19469 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19471 u8 ip_family_set = 0, is_ip4 = 1;
19473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19475 if (unformat (i, "ip4"))
19480 else if (unformat (i, "ip6"))
19487 errmsg ("parse error '%U'", format_unformat_error, i);
19492 if (!ip_family_set)
19494 errmsg ("ip family not set!");
19498 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19499 mp->is_ip4 = is_ip4;
19504 /* Wait for a reply... */
19510 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19512 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19515 if (!vam->json_output)
19517 print (vam->ofp, "VNIs");
19520 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19525 /* Wait for a reply... */
19531 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19533 unformat_input_t *i = vam->input;
19534 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19536 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19537 struct in_addr ip4;
19538 struct in6_addr ip6;
19539 u32 table_id = 0, nh_sw_if_index = ~0;
19541 memset (&ip4, 0, sizeof (ip4));
19542 memset (&ip6, 0, sizeof (ip6));
19544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19546 if (unformat (i, "del"))
19548 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19549 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19554 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19555 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19560 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19564 nh_sw_if_index = ~0;
19566 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19570 nh_sw_if_index = ~0;
19572 else if (unformat (i, "table %d", &table_id))
19576 errmsg ("parse error '%U'", format_unformat_error, i);
19583 errmsg ("nh addr not set!");
19587 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19588 mp->is_add = is_add;
19589 mp->table_id = clib_host_to_net_u32 (table_id);
19590 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19591 mp->is_ip4 = is_ip4;
19593 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19595 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19600 /* Wait for a reply... */
19606 api_one_map_server_dump (vat_main_t * vam)
19608 vl_api_one_map_server_dump_t *mp;
19609 vl_api_control_ping_t *mp_ping;
19612 if (!vam->json_output)
19614 print (vam->ofp, "%=20s", "Map server");
19617 M (ONE_MAP_SERVER_DUMP, mp);
19621 /* Use a control ping for synchronization */
19622 MPING (CONTROL_PING, mp_ping);
19625 /* Wait for a reply... */
19630 #define api_lisp_map_server_dump api_one_map_server_dump
19633 api_one_map_resolver_dump (vat_main_t * vam)
19635 vl_api_one_map_resolver_dump_t *mp;
19636 vl_api_control_ping_t *mp_ping;
19639 if (!vam->json_output)
19641 print (vam->ofp, "%=20s", "Map resolver");
19644 M (ONE_MAP_RESOLVER_DUMP, mp);
19648 /* Use a control ping for synchronization */
19649 MPING (CONTROL_PING, mp_ping);
19652 /* Wait for a reply... */
19657 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19660 api_one_stats_flush (vat_main_t * vam)
19662 vl_api_one_stats_flush_t *mp;
19665 M (ONE_STATS_FLUSH, mp);
19672 api_one_stats_dump (vat_main_t * vam)
19674 vl_api_one_stats_dump_t *mp;
19675 vl_api_control_ping_t *mp_ping;
19678 M (ONE_STATS_DUMP, mp);
19682 /* Use a control ping for synchronization */
19683 MPING (CONTROL_PING, mp_ping);
19686 /* Wait for a reply... */
19692 api_show_one_status (vat_main_t * vam)
19694 vl_api_show_one_status_t *mp;
19697 if (!vam->json_output)
19699 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19702 M (SHOW_ONE_STATUS, mp);
19705 /* Wait for a reply... */
19710 #define api_show_lisp_status api_show_one_status
19713 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19715 vl_api_gpe_fwd_entry_path_dump_t *mp;
19716 vl_api_control_ping_t *mp_ping;
19717 unformat_input_t *i = vam->input;
19718 u32 fwd_entry_index = ~0;
19721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19723 if (unformat (i, "index %d", &fwd_entry_index))
19729 if (~0 == fwd_entry_index)
19731 errmsg ("no index specified!");
19735 if (!vam->json_output)
19737 print (vam->ofp, "first line");
19740 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19744 /* Use a control ping for synchronization */
19745 MPING (CONTROL_PING, mp_ping);
19748 /* Wait for a reply... */
19754 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19756 vl_api_one_get_map_request_itr_rlocs_t *mp;
19759 if (!vam->json_output)
19761 print (vam->ofp, "%=20s", "itr-rlocs:");
19764 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19767 /* Wait for a reply... */
19772 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19775 api_af_packet_create (vat_main_t * vam)
19777 unformat_input_t *i = vam->input;
19778 vl_api_af_packet_create_t *mp;
19779 u8 *host_if_name = 0;
19781 u8 random_hw_addr = 1;
19784 memset (hw_addr, 0, sizeof (hw_addr));
19786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19788 if (unformat (i, "name %s", &host_if_name))
19789 vec_add1 (host_if_name, 0);
19790 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19791 random_hw_addr = 0;
19796 if (!vec_len (host_if_name))
19798 errmsg ("host-interface name must be specified");
19802 if (vec_len (host_if_name) > 64)
19804 errmsg ("host-interface name too long");
19808 M (AF_PACKET_CREATE, mp);
19810 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19811 clib_memcpy (mp->hw_addr, hw_addr, 6);
19812 mp->use_random_hw_addr = random_hw_addr;
19813 vec_free (host_if_name);
19821 fprintf (vam->ofp ? vam->ofp : stderr,
19822 " new sw_if_index = %d\n", vam->sw_if_index);
19829 api_af_packet_delete (vat_main_t * vam)
19831 unformat_input_t *i = vam->input;
19832 vl_api_af_packet_delete_t *mp;
19833 u8 *host_if_name = 0;
19836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19838 if (unformat (i, "name %s", &host_if_name))
19839 vec_add1 (host_if_name, 0);
19844 if (!vec_len (host_if_name))
19846 errmsg ("host-interface name must be specified");
19850 if (vec_len (host_if_name) > 64)
19852 errmsg ("host-interface name too long");
19856 M (AF_PACKET_DELETE, mp);
19858 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19859 vec_free (host_if_name);
19867 api_policer_add_del (vat_main_t * vam)
19869 unformat_input_t *i = vam->input;
19870 vl_api_policer_add_del_t *mp;
19880 u8 color_aware = 0;
19881 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19884 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19885 conform_action.dscp = 0;
19886 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19887 exceed_action.dscp = 0;
19888 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19889 violate_action.dscp = 0;
19891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19893 if (unformat (i, "del"))
19895 else if (unformat (i, "name %s", &name))
19896 vec_add1 (name, 0);
19897 else if (unformat (i, "cir %u", &cir))
19899 else if (unformat (i, "eir %u", &eir))
19901 else if (unformat (i, "cb %u", &cb))
19903 else if (unformat (i, "eb %u", &eb))
19905 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19908 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19911 else if (unformat (i, "type %U", unformat_policer_type, &type))
19913 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19916 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19919 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19922 else if (unformat (i, "color-aware"))
19928 if (!vec_len (name))
19930 errmsg ("policer name must be specified");
19934 if (vec_len (name) > 64)
19936 errmsg ("policer name too long");
19940 M (POLICER_ADD_DEL, mp);
19942 clib_memcpy (mp->name, name, vec_len (name));
19944 mp->is_add = is_add;
19945 mp->cir = ntohl (cir);
19946 mp->eir = ntohl (eir);
19947 mp->cb = clib_net_to_host_u64 (cb);
19948 mp->eb = clib_net_to_host_u64 (eb);
19949 mp->rate_type = rate_type;
19950 mp->round_type = round_type;
19952 mp->conform_action_type = conform_action.action_type;
19953 mp->conform_dscp = conform_action.dscp;
19954 mp->exceed_action_type = exceed_action.action_type;
19955 mp->exceed_dscp = exceed_action.dscp;
19956 mp->violate_action_type = violate_action.action_type;
19957 mp->violate_dscp = violate_action.dscp;
19958 mp->color_aware = color_aware;
19966 api_policer_dump (vat_main_t * vam)
19968 unformat_input_t *i = vam->input;
19969 vl_api_policer_dump_t *mp;
19970 vl_api_control_ping_t *mp_ping;
19971 u8 *match_name = 0;
19972 u8 match_name_valid = 0;
19975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19977 if (unformat (i, "name %s", &match_name))
19979 vec_add1 (match_name, 0);
19980 match_name_valid = 1;
19986 M (POLICER_DUMP, mp);
19987 mp->match_name_valid = match_name_valid;
19988 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19989 vec_free (match_name);
19993 /* Use a control ping for synchronization */
19994 MPING (CONTROL_PING, mp_ping);
19997 /* Wait for a reply... */
20003 api_policer_classify_set_interface (vat_main_t * vam)
20005 unformat_input_t *i = vam->input;
20006 vl_api_policer_classify_set_interface_t *mp;
20008 int sw_if_index_set;
20009 u32 ip4_table_index = ~0;
20010 u32 ip6_table_index = ~0;
20011 u32 l2_table_index = ~0;
20015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20018 sw_if_index_set = 1;
20019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20020 sw_if_index_set = 1;
20021 else if (unformat (i, "del"))
20023 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20025 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20027 else if (unformat (i, "l2-table %d", &l2_table_index))
20031 clib_warning ("parse error '%U'", format_unformat_error, i);
20036 if (sw_if_index_set == 0)
20038 errmsg ("missing interface name or sw_if_index");
20042 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20044 mp->sw_if_index = ntohl (sw_if_index);
20045 mp->ip4_table_index = ntohl (ip4_table_index);
20046 mp->ip6_table_index = ntohl (ip6_table_index);
20047 mp->l2_table_index = ntohl (l2_table_index);
20048 mp->is_add = is_add;
20056 api_policer_classify_dump (vat_main_t * vam)
20058 unformat_input_t *i = vam->input;
20059 vl_api_policer_classify_dump_t *mp;
20060 vl_api_control_ping_t *mp_ping;
20061 u8 type = POLICER_CLASSIFY_N_TABLES;
20064 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20068 errmsg ("classify table type must be specified");
20072 if (!vam->json_output)
20074 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20077 M (POLICER_CLASSIFY_DUMP, mp);
20082 /* Use a control ping for synchronization */
20083 MPING (CONTROL_PING, mp_ping);
20086 /* Wait for a reply... */
20092 api_netmap_create (vat_main_t * vam)
20094 unformat_input_t *i = vam->input;
20095 vl_api_netmap_create_t *mp;
20098 u8 random_hw_addr = 1;
20103 memset (hw_addr, 0, sizeof (hw_addr));
20105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20107 if (unformat (i, "name %s", &if_name))
20108 vec_add1 (if_name, 0);
20109 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20110 random_hw_addr = 0;
20111 else if (unformat (i, "pipe"))
20113 else if (unformat (i, "master"))
20115 else if (unformat (i, "slave"))
20121 if (!vec_len (if_name))
20123 errmsg ("interface name must be specified");
20127 if (vec_len (if_name) > 64)
20129 errmsg ("interface name too long");
20133 M (NETMAP_CREATE, mp);
20135 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20136 clib_memcpy (mp->hw_addr, hw_addr, 6);
20137 mp->use_random_hw_addr = random_hw_addr;
20138 mp->is_pipe = is_pipe;
20139 mp->is_master = is_master;
20140 vec_free (if_name);
20148 api_netmap_delete (vat_main_t * vam)
20150 unformat_input_t *i = vam->input;
20151 vl_api_netmap_delete_t *mp;
20155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20157 if (unformat (i, "name %s", &if_name))
20158 vec_add1 (if_name, 0);
20163 if (!vec_len (if_name))
20165 errmsg ("interface name must be specified");
20169 if (vec_len (if_name) > 64)
20171 errmsg ("interface name too long");
20175 M (NETMAP_DELETE, mp);
20177 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20178 vec_free (if_name);
20186 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20188 if (fp->afi == IP46_TYPE_IP6)
20190 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20191 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20192 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20193 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20194 format_ip6_address, fp->next_hop);
20195 else if (fp->afi == IP46_TYPE_IP4)
20197 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20198 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20199 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20200 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20201 format_ip4_address, fp->next_hop);
20205 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20206 vl_api_fib_path_t * fp)
20208 struct in_addr ip4;
20209 struct in6_addr ip6;
20211 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20212 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20213 vat_json_object_add_uint (node, "is_local", fp->is_local);
20214 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20215 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20216 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20217 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20218 if (fp->afi == IP46_TYPE_IP4)
20220 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20221 vat_json_object_add_ip4 (node, "next_hop", ip4);
20223 else if (fp->afi == IP46_TYPE_IP6)
20225 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20226 vat_json_object_add_ip6 (node, "next_hop", ip6);
20231 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20233 vat_main_t *vam = &vat_main;
20234 int count = ntohl (mp->mt_count);
20235 vl_api_fib_path_t *fp;
20238 print (vam->ofp, "[%d]: sw_if_index %d via:",
20239 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20241 for (i = 0; i < count; i++)
20243 vl_api_mpls_fib_path_print (vam, fp);
20247 print (vam->ofp, "");
20250 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20251 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20254 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20256 vat_main_t *vam = &vat_main;
20257 vat_json_node_t *node = NULL;
20258 int count = ntohl (mp->mt_count);
20259 vl_api_fib_path_t *fp;
20262 if (VAT_JSON_ARRAY != vam->json_tree.type)
20264 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20265 vat_json_init_array (&vam->json_tree);
20267 node = vat_json_array_add (&vam->json_tree);
20269 vat_json_init_object (node);
20270 vat_json_object_add_uint (node, "tunnel_index",
20271 ntohl (mp->mt_tunnel_index));
20272 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20274 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20277 for (i = 0; i < count; i++)
20279 vl_api_mpls_fib_path_json_print (node, fp);
20285 api_mpls_tunnel_dump (vat_main_t * vam)
20287 vl_api_mpls_tunnel_dump_t *mp;
20288 vl_api_control_ping_t *mp_ping;
20292 /* Parse args required to build the message */
20293 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20295 if (!unformat (vam->input, "tunnel_index %d", &index))
20302 print (vam->ofp, " tunnel_index %d", index);
20304 M (MPLS_TUNNEL_DUMP, mp);
20305 mp->tunnel_index = htonl (index);
20308 /* Use a control ping for synchronization */
20309 MPING (CONTROL_PING, mp_ping);
20316 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20317 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20321 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20323 vat_main_t *vam = &vat_main;
20324 int count = ntohl (mp->count);
20325 vl_api_fib_path_t *fp;
20329 "table-id %d, label %u, ess_bit %u",
20330 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20332 for (i = 0; i < count; i++)
20334 vl_api_mpls_fib_path_print (vam, fp);
20339 static void vl_api_mpls_fib_details_t_handler_json
20340 (vl_api_mpls_fib_details_t * mp)
20342 vat_main_t *vam = &vat_main;
20343 int count = ntohl (mp->count);
20344 vat_json_node_t *node = NULL;
20345 vl_api_fib_path_t *fp;
20348 if (VAT_JSON_ARRAY != vam->json_tree.type)
20350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20351 vat_json_init_array (&vam->json_tree);
20353 node = vat_json_array_add (&vam->json_tree);
20355 vat_json_init_object (node);
20356 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20357 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20358 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20359 vat_json_object_add_uint (node, "path_count", count);
20361 for (i = 0; i < count; i++)
20363 vl_api_mpls_fib_path_json_print (node, fp);
20369 api_mpls_fib_dump (vat_main_t * vam)
20371 vl_api_mpls_fib_dump_t *mp;
20372 vl_api_control_ping_t *mp_ping;
20375 M (MPLS_FIB_DUMP, mp);
20378 /* Use a control ping for synchronization */
20379 MPING (CONTROL_PING, mp_ping);
20386 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20387 #define vl_api_ip_fib_details_t_print vl_noop_handler
20390 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20392 vat_main_t *vam = &vat_main;
20393 int count = ntohl (mp->count);
20394 vl_api_fib_path_t *fp;
20398 "table-id %d, prefix %U/%d",
20399 ntohl (mp->table_id), format_ip4_address, mp->address,
20400 mp->address_length);
20402 for (i = 0; i < count; i++)
20404 if (fp->afi == IP46_TYPE_IP6)
20406 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20407 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20408 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20409 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20410 format_ip6_address, fp->next_hop);
20411 else if (fp->afi == IP46_TYPE_IP4)
20413 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20414 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20415 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20416 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20417 format_ip4_address, fp->next_hop);
20422 static void vl_api_ip_fib_details_t_handler_json
20423 (vl_api_ip_fib_details_t * mp)
20425 vat_main_t *vam = &vat_main;
20426 int count = ntohl (mp->count);
20427 vat_json_node_t *node = NULL;
20428 struct in_addr ip4;
20429 struct in6_addr ip6;
20430 vl_api_fib_path_t *fp;
20433 if (VAT_JSON_ARRAY != vam->json_tree.type)
20435 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20436 vat_json_init_array (&vam->json_tree);
20438 node = vat_json_array_add (&vam->json_tree);
20440 vat_json_init_object (node);
20441 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20442 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20443 vat_json_object_add_ip4 (node, "prefix", ip4);
20444 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20445 vat_json_object_add_uint (node, "path_count", count);
20447 for (i = 0; i < count; i++)
20449 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20450 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20451 vat_json_object_add_uint (node, "is_local", fp->is_local);
20452 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20453 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20454 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20455 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20456 if (fp->afi == IP46_TYPE_IP4)
20458 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20459 vat_json_object_add_ip4 (node, "next_hop", ip4);
20461 else if (fp->afi == IP46_TYPE_IP6)
20463 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20464 vat_json_object_add_ip6 (node, "next_hop", ip6);
20470 api_ip_fib_dump (vat_main_t * vam)
20472 vl_api_ip_fib_dump_t *mp;
20473 vl_api_control_ping_t *mp_ping;
20476 M (IP_FIB_DUMP, mp);
20479 /* Use a control ping for synchronization */
20480 MPING (CONTROL_PING, mp_ping);
20488 api_ip_mfib_dump (vat_main_t * vam)
20490 vl_api_ip_mfib_dump_t *mp;
20491 vl_api_control_ping_t *mp_ping;
20494 M (IP_MFIB_DUMP, mp);
20497 /* Use a control ping for synchronization */
20498 MPING (CONTROL_PING, mp_ping);
20505 static void vl_api_ip_neighbor_details_t_handler
20506 (vl_api_ip_neighbor_details_t * mp)
20508 vat_main_t *vam = &vat_main;
20510 print (vam->ofp, "%c %U %U",
20511 (mp->is_static) ? 'S' : 'D',
20512 format_ethernet_address, &mp->mac_address,
20513 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20517 static void vl_api_ip_neighbor_details_t_handler_json
20518 (vl_api_ip_neighbor_details_t * mp)
20521 vat_main_t *vam = &vat_main;
20522 vat_json_node_t *node;
20523 struct in_addr ip4;
20524 struct in6_addr ip6;
20526 if (VAT_JSON_ARRAY != vam->json_tree.type)
20528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20529 vat_json_init_array (&vam->json_tree);
20531 node = vat_json_array_add (&vam->json_tree);
20533 vat_json_init_object (node);
20534 vat_json_object_add_string_copy (node, "flag",
20535 (mp->is_static) ? (u8 *) "static" : (u8 *)
20538 vat_json_object_add_string_copy (node, "link_layer",
20539 format (0, "%U", format_ethernet_address,
20540 &mp->mac_address));
20544 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20545 vat_json_object_add_ip6 (node, "ip_address", ip6);
20549 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20550 vat_json_object_add_ip4 (node, "ip_address", ip4);
20555 api_ip_neighbor_dump (vat_main_t * vam)
20557 unformat_input_t *i = vam->input;
20558 vl_api_ip_neighbor_dump_t *mp;
20559 vl_api_control_ping_t *mp_ping;
20561 u32 sw_if_index = ~0;
20564 /* Parse args required to build the message */
20565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20569 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20571 else if (unformat (i, "ip6"))
20577 if (sw_if_index == ~0)
20579 errmsg ("missing interface name or sw_if_index");
20583 M (IP_NEIGHBOR_DUMP, mp);
20584 mp->is_ipv6 = (u8) is_ipv6;
20585 mp->sw_if_index = ntohl (sw_if_index);
20588 /* Use a control ping for synchronization */
20589 MPING (CONTROL_PING, mp_ping);
20596 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20597 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20600 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20602 vat_main_t *vam = &vat_main;
20603 int count = ntohl (mp->count);
20604 vl_api_fib_path_t *fp;
20608 "table-id %d, prefix %U/%d",
20609 ntohl (mp->table_id), format_ip6_address, mp->address,
20610 mp->address_length);
20612 for (i = 0; i < count; i++)
20614 if (fp->afi == IP46_TYPE_IP6)
20616 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20617 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20618 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20619 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20620 format_ip6_address, fp->next_hop);
20621 else if (fp->afi == IP46_TYPE_IP4)
20623 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20624 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20625 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20626 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20627 format_ip4_address, fp->next_hop);
20632 static void vl_api_ip6_fib_details_t_handler_json
20633 (vl_api_ip6_fib_details_t * mp)
20635 vat_main_t *vam = &vat_main;
20636 int count = ntohl (mp->count);
20637 vat_json_node_t *node = NULL;
20638 struct in_addr ip4;
20639 struct in6_addr ip6;
20640 vl_api_fib_path_t *fp;
20643 if (VAT_JSON_ARRAY != vam->json_tree.type)
20645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20646 vat_json_init_array (&vam->json_tree);
20648 node = vat_json_array_add (&vam->json_tree);
20650 vat_json_init_object (node);
20651 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20652 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20653 vat_json_object_add_ip6 (node, "prefix", ip6);
20654 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20655 vat_json_object_add_uint (node, "path_count", count);
20657 for (i = 0; i < count; i++)
20659 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20660 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20661 vat_json_object_add_uint (node, "is_local", fp->is_local);
20662 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20663 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20664 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20665 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20666 if (fp->afi == IP46_TYPE_IP4)
20668 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20669 vat_json_object_add_ip4 (node, "next_hop", ip4);
20671 else if (fp->afi == IP46_TYPE_IP6)
20673 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20674 vat_json_object_add_ip6 (node, "next_hop", ip6);
20680 api_ip6_fib_dump (vat_main_t * vam)
20682 vl_api_ip6_fib_dump_t *mp;
20683 vl_api_control_ping_t *mp_ping;
20686 M (IP6_FIB_DUMP, mp);
20689 /* Use a control ping for synchronization */
20690 MPING (CONTROL_PING, mp_ping);
20698 api_ip6_mfib_dump (vat_main_t * vam)
20700 vl_api_ip6_mfib_dump_t *mp;
20701 vl_api_control_ping_t *mp_ping;
20704 M (IP6_MFIB_DUMP, mp);
20707 /* Use a control ping for synchronization */
20708 MPING (CONTROL_PING, mp_ping);
20716 api_classify_table_ids (vat_main_t * vam)
20718 vl_api_classify_table_ids_t *mp;
20721 /* Construct the API message */
20722 M (CLASSIFY_TABLE_IDS, mp);
20731 api_classify_table_by_interface (vat_main_t * vam)
20733 unformat_input_t *input = vam->input;
20734 vl_api_classify_table_by_interface_t *mp;
20736 u32 sw_if_index = ~0;
20738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20740 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20742 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20747 if (sw_if_index == ~0)
20749 errmsg ("missing interface name or sw_if_index");
20753 /* Construct the API message */
20754 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20756 mp->sw_if_index = ntohl (sw_if_index);
20764 api_classify_table_info (vat_main_t * vam)
20766 unformat_input_t *input = vam->input;
20767 vl_api_classify_table_info_t *mp;
20771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20773 if (unformat (input, "table_id %d", &table_id))
20778 if (table_id == ~0)
20780 errmsg ("missing table id");
20784 /* Construct the API message */
20785 M (CLASSIFY_TABLE_INFO, mp);
20787 mp->table_id = ntohl (table_id);
20795 api_classify_session_dump (vat_main_t * vam)
20797 unformat_input_t *input = vam->input;
20798 vl_api_classify_session_dump_t *mp;
20799 vl_api_control_ping_t *mp_ping;
20803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20805 if (unformat (input, "table_id %d", &table_id))
20810 if (table_id == ~0)
20812 errmsg ("missing table id");
20816 /* Construct the API message */
20817 M (CLASSIFY_SESSION_DUMP, mp);
20819 mp->table_id = ntohl (table_id);
20822 /* Use a control ping for synchronization */
20823 MPING (CONTROL_PING, mp_ping);
20831 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20833 vat_main_t *vam = &vat_main;
20835 print (vam->ofp, "collector_address %U, collector_port %d, "
20836 "src_address %U, vrf_id %d, path_mtu %u, "
20837 "template_interval %u, udp_checksum %d",
20838 format_ip4_address, mp->collector_address,
20839 ntohs (mp->collector_port),
20840 format_ip4_address, mp->src_address,
20841 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20842 ntohl (mp->template_interval), mp->udp_checksum);
20845 vam->result_ready = 1;
20849 vl_api_ipfix_exporter_details_t_handler_json
20850 (vl_api_ipfix_exporter_details_t * mp)
20852 vat_main_t *vam = &vat_main;
20853 vat_json_node_t node;
20854 struct in_addr collector_address;
20855 struct in_addr src_address;
20857 vat_json_init_object (&node);
20858 clib_memcpy (&collector_address, &mp->collector_address,
20859 sizeof (collector_address));
20860 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20861 vat_json_object_add_uint (&node, "collector_port",
20862 ntohs (mp->collector_port));
20863 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20864 vat_json_object_add_ip4 (&node, "src_address", src_address);
20865 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20866 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20867 vat_json_object_add_uint (&node, "template_interval",
20868 ntohl (mp->template_interval));
20869 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20871 vat_json_print (vam->ofp, &node);
20872 vat_json_free (&node);
20874 vam->result_ready = 1;
20878 api_ipfix_exporter_dump (vat_main_t * vam)
20880 vl_api_ipfix_exporter_dump_t *mp;
20883 /* Construct the API message */
20884 M (IPFIX_EXPORTER_DUMP, mp);
20893 api_ipfix_classify_stream_dump (vat_main_t * vam)
20895 vl_api_ipfix_classify_stream_dump_t *mp;
20898 /* Construct the API message */
20899 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20910 vl_api_ipfix_classify_stream_details_t_handler
20911 (vl_api_ipfix_classify_stream_details_t * mp)
20913 vat_main_t *vam = &vat_main;
20914 print (vam->ofp, "domain_id %d, src_port %d",
20915 ntohl (mp->domain_id), ntohs (mp->src_port));
20917 vam->result_ready = 1;
20921 vl_api_ipfix_classify_stream_details_t_handler_json
20922 (vl_api_ipfix_classify_stream_details_t * mp)
20924 vat_main_t *vam = &vat_main;
20925 vat_json_node_t node;
20927 vat_json_init_object (&node);
20928 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20929 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20931 vat_json_print (vam->ofp, &node);
20932 vat_json_free (&node);
20934 vam->result_ready = 1;
20938 api_ipfix_classify_table_dump (vat_main_t * vam)
20940 vl_api_ipfix_classify_table_dump_t *mp;
20941 vl_api_control_ping_t *mp_ping;
20944 if (!vam->json_output)
20946 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20947 "transport_protocol");
20950 /* Construct the API message */
20951 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20956 /* Use a control ping for synchronization */
20957 MPING (CONTROL_PING, mp_ping);
20965 vl_api_ipfix_classify_table_details_t_handler
20966 (vl_api_ipfix_classify_table_details_t * mp)
20968 vat_main_t *vam = &vat_main;
20969 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20970 mp->transport_protocol);
20974 vl_api_ipfix_classify_table_details_t_handler_json
20975 (vl_api_ipfix_classify_table_details_t * mp)
20977 vat_json_node_t *node = NULL;
20978 vat_main_t *vam = &vat_main;
20980 if (VAT_JSON_ARRAY != vam->json_tree.type)
20982 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20983 vat_json_init_array (&vam->json_tree);
20986 node = vat_json_array_add (&vam->json_tree);
20987 vat_json_init_object (node);
20989 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20990 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20991 vat_json_object_add_uint (node, "transport_protocol",
20992 mp->transport_protocol);
20996 api_sw_interface_span_enable_disable (vat_main_t * vam)
20998 unformat_input_t *i = vam->input;
20999 vl_api_sw_interface_span_enable_disable_t *mp;
21000 u32 src_sw_if_index = ~0;
21001 u32 dst_sw_if_index = ~0;
21006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21009 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21011 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21015 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21017 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21019 else if (unformat (i, "disable"))
21021 else if (unformat (i, "rx"))
21023 else if (unformat (i, "tx"))
21025 else if (unformat (i, "both"))
21027 else if (unformat (i, "l2"))
21033 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21035 mp->sw_if_index_from = htonl (src_sw_if_index);
21036 mp->sw_if_index_to = htonl (dst_sw_if_index);
21046 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21049 vat_main_t *vam = &vat_main;
21050 u8 *sw_if_from_name = 0;
21051 u8 *sw_if_to_name = 0;
21052 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21053 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21054 char *states[] = { "none", "rx", "tx", "both" };
21058 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21060 if ((u32) p->value[0] == sw_if_index_from)
21062 sw_if_from_name = (u8 *)(p->key);
21066 if ((u32) p->value[0] == sw_if_index_to)
21068 sw_if_to_name = (u8 *)(p->key);
21069 if (sw_if_from_name)
21074 print (vam->ofp, "%20s => %20s (%s) %s",
21075 sw_if_from_name, sw_if_to_name, states[mp->state],
21076 mp->is_l2 ? "l2" : "device");
21080 vl_api_sw_interface_span_details_t_handler_json
21081 (vl_api_sw_interface_span_details_t * mp)
21083 vat_main_t *vam = &vat_main;
21084 vat_json_node_t *node = NULL;
21085 u8 *sw_if_from_name = 0;
21086 u8 *sw_if_to_name = 0;
21087 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21088 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21092 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21094 if ((u32) p->value[0] == sw_if_index_from)
21096 sw_if_from_name = (u8 *)(p->key);
21100 if ((u32) p->value[0] == sw_if_index_to)
21102 sw_if_to_name = (u8 *)(p->key);
21103 if (sw_if_from_name)
21109 if (VAT_JSON_ARRAY != vam->json_tree.type)
21111 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21112 vat_json_init_array (&vam->json_tree);
21114 node = vat_json_array_add (&vam->json_tree);
21116 vat_json_init_object (node);
21117 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21118 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21119 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21120 if (0 != sw_if_to_name)
21122 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21124 vat_json_object_add_uint (node, "state", mp->state);
21125 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21129 api_sw_interface_span_dump (vat_main_t * vam)
21131 unformat_input_t *input = vam->input;
21132 vl_api_sw_interface_span_dump_t *mp;
21133 vl_api_control_ping_t *mp_ping;
21137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21139 if (unformat (input, "l2"))
21145 M (SW_INTERFACE_SPAN_DUMP, mp);
21149 /* Use a control ping for synchronization */
21150 MPING (CONTROL_PING, mp_ping);
21158 api_pg_create_interface (vat_main_t * vam)
21160 unformat_input_t *input = vam->input;
21161 vl_api_pg_create_interface_t *mp;
21165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21167 if (unformat (input, "if_id %d", &if_id))
21174 errmsg ("missing pg interface index");
21178 /* Construct the API message */
21179 M (PG_CREATE_INTERFACE, mp);
21181 mp->interface_id = ntohl (if_id);
21189 api_pg_capture (vat_main_t * vam)
21191 unformat_input_t *input = vam->input;
21192 vl_api_pg_capture_t *mp;
21197 u8 pcap_file_set = 0;
21200 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21202 if (unformat (input, "if_id %d", &if_id))
21204 else if (unformat (input, "pcap %s", &pcap_file))
21206 else if (unformat (input, "count %d", &count))
21208 else if (unformat (input, "disable"))
21215 errmsg ("missing pg interface index");
21218 if (pcap_file_set > 0)
21220 if (vec_len (pcap_file) > 255)
21222 errmsg ("pcap file name is too long");
21227 u32 name_len = vec_len (pcap_file);
21228 /* Construct the API message */
21229 M (PG_CAPTURE, mp);
21231 mp->interface_id = ntohl (if_id);
21232 mp->is_enabled = enable;
21233 mp->count = ntohl (count);
21234 mp->pcap_name_length = ntohl (name_len);
21235 if (pcap_file_set != 0)
21237 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21239 vec_free (pcap_file);
21247 api_pg_enable_disable (vat_main_t * vam)
21249 unformat_input_t *input = vam->input;
21250 vl_api_pg_enable_disable_t *mp;
21253 u8 stream_name_set = 0;
21254 u8 *stream_name = 0;
21256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21258 if (unformat (input, "stream %s", &stream_name))
21259 stream_name_set = 1;
21260 else if (unformat (input, "disable"))
21266 if (stream_name_set > 0)
21268 if (vec_len (stream_name) > 255)
21270 errmsg ("stream name too long");
21275 u32 name_len = vec_len (stream_name);
21276 /* Construct the API message */
21277 M (PG_ENABLE_DISABLE, mp);
21279 mp->is_enabled = enable;
21280 if (stream_name_set != 0)
21282 mp->stream_name_length = ntohl (name_len);
21283 clib_memcpy (mp->stream_name, stream_name, name_len);
21285 vec_free (stream_name);
21293 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21295 unformat_input_t *input = vam->input;
21296 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21298 u16 *low_ports = 0;
21299 u16 *high_ports = 0;
21302 ip4_address_t ip4_addr;
21303 ip6_address_t ip6_addr;
21312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21314 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21320 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21325 else if (unformat (input, "vrf %d", &vrf_id))
21327 else if (unformat (input, "del"))
21329 else if (unformat (input, "port %d", &tmp))
21331 if (tmp == 0 || tmp > 65535)
21333 errmsg ("port %d out of range", tmp);
21337 this_hi = this_low + 1;
21338 vec_add1 (low_ports, this_low);
21339 vec_add1 (high_ports, this_hi);
21341 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21343 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21345 errmsg ("incorrect range parameters");
21349 /* Note: in debug CLI +1 is added to high before
21350 passing to real fn that does "the work"
21351 (ip_source_and_port_range_check_add_del).
21352 This fn is a wrapper around the binary API fn a
21353 control plane will call, which expects this increment
21354 to have occurred. Hence letting the binary API control
21355 plane fn do the increment for consistency between VAT
21356 and other control planes.
21359 vec_add1 (low_ports, this_low);
21360 vec_add1 (high_ports, this_hi);
21366 if (prefix_set == 0)
21368 errmsg ("<address>/<mask> not specified");
21374 errmsg ("VRF ID required, not specified");
21381 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21385 if (vec_len (low_ports) == 0)
21387 errmsg ("At least one port or port range required");
21391 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21393 mp->is_add = is_add;
21398 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21403 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21406 mp->mask_length = length;
21407 mp->number_of_ranges = vec_len (low_ports);
21409 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21410 vec_free (low_ports);
21412 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21413 vec_free (high_ports);
21415 mp->vrf_id = ntohl (vrf_id);
21423 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21425 unformat_input_t *input = vam->input;
21426 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21427 u32 sw_if_index = ~0;
21429 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21430 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21434 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21436 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21438 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21440 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21442 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21444 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21446 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21448 else if (unformat (input, "del"))
21454 if (sw_if_index == ~0)
21456 errmsg ("Interface required but not specified");
21462 errmsg ("VRF ID required but not specified");
21466 if (tcp_out_vrf_id == 0
21467 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21470 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21474 /* Construct the API message */
21475 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21477 mp->sw_if_index = ntohl (sw_if_index);
21478 mp->is_add = is_add;
21479 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21480 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21481 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21482 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21487 /* Wait for a reply... */
21493 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21495 unformat_input_t *i = vam->input;
21496 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21497 u32 local_sa_id = 0;
21498 u32 remote_sa_id = 0;
21499 ip4_address_t src_address;
21500 ip4_address_t dst_address;
21504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21506 if (unformat (i, "local_sa %d", &local_sa_id))
21508 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21510 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21512 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21514 else if (unformat (i, "del"))
21518 clib_warning ("parse error '%U'", format_unformat_error, i);
21523 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21525 mp->local_sa_id = ntohl (local_sa_id);
21526 mp->remote_sa_id = ntohl (remote_sa_id);
21527 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21528 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21529 mp->is_add = is_add;
21537 api_punt (vat_main_t * vam)
21539 unformat_input_t *i = vam->input;
21547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21549 if (unformat (i, "ip %d", &ipv))
21551 else if (unformat (i, "protocol %d", &protocol))
21553 else if (unformat (i, "port %d", &port))
21555 else if (unformat (i, "del"))
21559 clib_warning ("parse error '%U'", format_unformat_error, i);
21566 mp->is_add = (u8) is_add;
21567 mp->ipv = (u8) ipv;
21568 mp->l4_protocol = (u8) protocol;
21569 mp->l4_port = htons ((u16) port);
21576 static void vl_api_ipsec_gre_tunnel_details_t_handler
21577 (vl_api_ipsec_gre_tunnel_details_t * mp)
21579 vat_main_t *vam = &vat_main;
21581 print (vam->ofp, "%11d%15U%15U%14d%14d",
21582 ntohl (mp->sw_if_index),
21583 format_ip4_address, &mp->src_address,
21584 format_ip4_address, &mp->dst_address,
21585 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21588 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21589 (vl_api_ipsec_gre_tunnel_details_t * mp)
21591 vat_main_t *vam = &vat_main;
21592 vat_json_node_t *node = NULL;
21593 struct in_addr ip4;
21595 if (VAT_JSON_ARRAY != vam->json_tree.type)
21597 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21598 vat_json_init_array (&vam->json_tree);
21600 node = vat_json_array_add (&vam->json_tree);
21602 vat_json_init_object (node);
21603 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21604 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21605 vat_json_object_add_ip4 (node, "src_address", ip4);
21606 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21607 vat_json_object_add_ip4 (node, "dst_address", ip4);
21608 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21609 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21613 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21615 unformat_input_t *i = vam->input;
21616 vl_api_ipsec_gre_tunnel_dump_t *mp;
21617 vl_api_control_ping_t *mp_ping;
21619 u8 sw_if_index_set = 0;
21622 /* Parse args required to build the message */
21623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21625 if (unformat (i, "sw_if_index %d", &sw_if_index))
21626 sw_if_index_set = 1;
21631 if (sw_if_index_set == 0)
21636 if (!vam->json_output)
21638 print (vam->ofp, "%11s%15s%15s%14s%14s",
21639 "sw_if_index", "src_address", "dst_address",
21640 "local_sa_id", "remote_sa_id");
21643 /* Get list of gre-tunnel interfaces */
21644 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21646 mp->sw_if_index = htonl (sw_if_index);
21650 /* Use a control ping for synchronization */
21651 MPING (CONTROL_PING, mp_ping);
21659 api_delete_subif (vat_main_t * vam)
21661 unformat_input_t *i = vam->input;
21662 vl_api_delete_subif_t *mp;
21663 u32 sw_if_index = ~0;
21666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21670 if (unformat (i, "sw_if_index %d", &sw_if_index))
21676 if (sw_if_index == ~0)
21678 errmsg ("missing sw_if_index");
21682 /* Construct the API message */
21683 M (DELETE_SUBIF, mp);
21684 mp->sw_if_index = ntohl (sw_if_index);
21691 #define foreach_pbb_vtr_op \
21692 _("disable", L2_VTR_DISABLED) \
21693 _("pop", L2_VTR_POP_2) \
21694 _("push", L2_VTR_PUSH_2)
21697 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21699 unformat_input_t *i = vam->input;
21700 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21701 u32 sw_if_index = ~0, vtr_op = ~0;
21702 u16 outer_tag = ~0;
21703 u8 dmac[6], smac[6];
21704 u8 dmac_set = 0, smac_set = 0;
21710 /* Shut up coverity */
21711 memset (dmac, 0, sizeof (dmac));
21712 memset (smac, 0, sizeof (smac));
21714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21716 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21718 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21720 else if (unformat (i, "vtr_op %d", &vtr_op))
21722 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21725 else if (unformat (i, "translate_pbb_stag"))
21727 if (unformat (i, "%d", &tmp))
21729 vtr_op = L2_VTR_TRANSLATE_2_1;
21735 ("translate_pbb_stag operation requires outer tag definition");
21739 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21741 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21743 else if (unformat (i, "sid %d", &sid))
21745 else if (unformat (i, "vlanid %d", &tmp))
21749 clib_warning ("parse error '%U'", format_unformat_error, i);
21754 if ((sw_if_index == ~0) || (vtr_op == ~0))
21756 errmsg ("missing sw_if_index or vtr operation");
21759 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21760 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21763 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21767 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21768 mp->sw_if_index = ntohl (sw_if_index);
21769 mp->vtr_op = ntohl (vtr_op);
21770 mp->outer_tag = ntohs (outer_tag);
21771 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21772 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21773 mp->b_vlanid = ntohs (vlanid);
21774 mp->i_sid = ntohl (sid);
21782 api_flow_classify_set_interface (vat_main_t * vam)
21784 unformat_input_t *i = vam->input;
21785 vl_api_flow_classify_set_interface_t *mp;
21787 int sw_if_index_set;
21788 u32 ip4_table_index = ~0;
21789 u32 ip6_table_index = ~0;
21793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21795 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21796 sw_if_index_set = 1;
21797 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21798 sw_if_index_set = 1;
21799 else if (unformat (i, "del"))
21801 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21803 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21807 clib_warning ("parse error '%U'", format_unformat_error, i);
21812 if (sw_if_index_set == 0)
21814 errmsg ("missing interface name or sw_if_index");
21818 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21820 mp->sw_if_index = ntohl (sw_if_index);
21821 mp->ip4_table_index = ntohl (ip4_table_index);
21822 mp->ip6_table_index = ntohl (ip6_table_index);
21823 mp->is_add = is_add;
21831 api_flow_classify_dump (vat_main_t * vam)
21833 unformat_input_t *i = vam->input;
21834 vl_api_flow_classify_dump_t *mp;
21835 vl_api_control_ping_t *mp_ping;
21836 u8 type = FLOW_CLASSIFY_N_TABLES;
21839 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21843 errmsg ("classify table type must be specified");
21847 if (!vam->json_output)
21849 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21852 M (FLOW_CLASSIFY_DUMP, mp);
21857 /* Use a control ping for synchronization */
21858 MPING (CONTROL_PING, mp_ping);
21861 /* Wait for a reply... */
21867 api_feature_enable_disable (vat_main_t * vam)
21869 unformat_input_t *i = vam->input;
21870 vl_api_feature_enable_disable_t *mp;
21872 u8 *feature_name = 0;
21873 u32 sw_if_index = ~0;
21877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21879 if (unformat (i, "arc_name %s", &arc_name))
21881 else if (unformat (i, "feature_name %s", &feature_name))
21884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21888 else if (unformat (i, "disable"))
21896 errmsg ("missing arc name");
21899 if (vec_len (arc_name) > 63)
21901 errmsg ("arc name too long");
21904 if (feature_name == 0)
21906 errmsg ("missing feature name");
21909 if (vec_len (feature_name) > 63)
21911 errmsg ("feature name too long");
21914 if (sw_if_index == ~0)
21916 errmsg ("missing interface name or sw_if_index");
21920 /* Construct the API message */
21921 M (FEATURE_ENABLE_DISABLE, mp);
21922 mp->sw_if_index = ntohl (sw_if_index);
21923 mp->enable = enable;
21924 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21925 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21926 vec_free (arc_name);
21927 vec_free (feature_name);
21935 api_sw_interface_tag_add_del (vat_main_t * vam)
21937 unformat_input_t *i = vam->input;
21938 vl_api_sw_interface_tag_add_del_t *mp;
21939 u32 sw_if_index = ~0;
21944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21946 if (unformat (i, "tag %s", &tag))
21948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21952 else if (unformat (i, "del"))
21958 if (sw_if_index == ~0)
21960 errmsg ("missing interface name or sw_if_index");
21964 if (enable && (tag == 0))
21966 errmsg ("no tag specified");
21970 /* Construct the API message */
21971 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21972 mp->sw_if_index = ntohl (sw_if_index);
21973 mp->is_add = enable;
21975 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21983 static void vl_api_l2_xconnect_details_t_handler
21984 (vl_api_l2_xconnect_details_t * mp)
21986 vat_main_t *vam = &vat_main;
21988 print (vam->ofp, "%15d%15d",
21989 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21992 static void vl_api_l2_xconnect_details_t_handler_json
21993 (vl_api_l2_xconnect_details_t * mp)
21995 vat_main_t *vam = &vat_main;
21996 vat_json_node_t *node = NULL;
21998 if (VAT_JSON_ARRAY != vam->json_tree.type)
22000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22001 vat_json_init_array (&vam->json_tree);
22003 node = vat_json_array_add (&vam->json_tree);
22005 vat_json_init_object (node);
22006 vat_json_object_add_uint (node, "rx_sw_if_index",
22007 ntohl (mp->rx_sw_if_index));
22008 vat_json_object_add_uint (node, "tx_sw_if_index",
22009 ntohl (mp->tx_sw_if_index));
22013 api_l2_xconnect_dump (vat_main_t * vam)
22015 vl_api_l2_xconnect_dump_t *mp;
22016 vl_api_control_ping_t *mp_ping;
22019 if (!vam->json_output)
22021 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22024 M (L2_XCONNECT_DUMP, mp);
22028 /* Use a control ping for synchronization */
22029 MPING (CONTROL_PING, mp_ping);
22037 api_sw_interface_set_mtu (vat_main_t * vam)
22039 unformat_input_t *i = vam->input;
22040 vl_api_sw_interface_set_mtu_t *mp;
22041 u32 sw_if_index = ~0;
22045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22047 if (unformat (i, "mtu %d", &mtu))
22049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22051 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22057 if (sw_if_index == ~0)
22059 errmsg ("missing interface name or sw_if_index");
22065 errmsg ("no mtu specified");
22069 /* Construct the API message */
22070 M (SW_INTERFACE_SET_MTU, mp);
22071 mp->sw_if_index = ntohl (sw_if_index);
22072 mp->mtu = ntohs ((u16) mtu);
22080 api_p2p_ethernet_add (vat_main_t * vam)
22082 unformat_input_t *i = vam->input;
22083 vl_api_p2p_ethernet_add_t *mp;
22084 u32 parent_if_index = ~0;
22090 memset (remote_mac, 0, sizeof (remote_mac));
22091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22095 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22099 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22101 else if (unformat (i, "sub_id %d", &sub_id))
22105 clib_warning ("parse error '%U'", format_unformat_error, i);
22110 if (parent_if_index == ~0)
22112 errmsg ("missing interface name or sw_if_index");
22117 errmsg ("missing remote mac address");
22122 errmsg ("missing sub-interface id");
22126 M (P2P_ETHERNET_ADD, mp);
22127 mp->parent_if_index = ntohl (parent_if_index);
22128 mp->subif_id = ntohl (sub_id);
22129 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22137 api_p2p_ethernet_del (vat_main_t * vam)
22139 unformat_input_t *i = vam->input;
22140 vl_api_p2p_ethernet_del_t *mp;
22141 u32 parent_if_index = ~0;
22146 memset (remote_mac, 0, sizeof (remote_mac));
22147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22151 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22155 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22159 clib_warning ("parse error '%U'", format_unformat_error, i);
22164 if (parent_if_index == ~0)
22166 errmsg ("missing interface name or sw_if_index");
22171 errmsg ("missing remote mac address");
22175 M (P2P_ETHERNET_DEL, mp);
22176 mp->parent_if_index = ntohl (parent_if_index);
22177 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22185 api_lldp_config (vat_main_t * vam)
22187 unformat_input_t *i = vam->input;
22188 vl_api_lldp_config_t *mp;
22190 int tx_interval = 0;
22191 u8 *sys_name = NULL;
22194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22196 if (unformat (i, "system-name %s", &sys_name))
22198 else if (unformat (i, "tx-hold %d", &tx_hold))
22200 else if (unformat (i, "tx-interval %d", &tx_interval))
22204 clib_warning ("parse error '%U'", format_unformat_error, i);
22209 vec_add1 (sys_name, 0);
22211 M (LLDP_CONFIG, mp);
22212 mp->tx_hold = htonl (tx_hold);
22213 mp->tx_interval = htonl (tx_interval);
22214 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22215 vec_free (sys_name);
22223 api_sw_interface_set_lldp (vat_main_t * vam)
22225 unformat_input_t *i = vam->input;
22226 vl_api_sw_interface_set_lldp_t *mp;
22227 u32 sw_if_index = ~0;
22229 u8 *port_desc = NULL, *mgmt_oid = NULL;
22230 ip4_address_t ip4_addr;
22231 ip6_address_t ip6_addr;
22234 memset (&ip4_addr, 0, sizeof (ip4_addr));
22235 memset (&ip6_addr, 0, sizeof (ip6_addr));
22237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22239 if (unformat (i, "disable"))
22242 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22244 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22246 else if (unformat (i, "port-desc %s", &port_desc))
22248 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22250 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22252 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22258 if (sw_if_index == ~0)
22260 errmsg ("missing interface name or sw_if_index");
22264 /* Construct the API message */
22265 vec_add1 (port_desc, 0);
22266 vec_add1 (mgmt_oid, 0);
22267 M (SW_INTERFACE_SET_LLDP, mp);
22268 mp->sw_if_index = ntohl (sw_if_index);
22269 mp->enable = enable;
22270 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22271 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22272 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22273 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22274 vec_free (port_desc);
22275 vec_free (mgmt_oid);
22283 api_tcp_configure_src_addresses (vat_main_t * vam)
22285 vl_api_tcp_configure_src_addresses_t *mp;
22286 unformat_input_t *i = vam->input;
22287 ip4_address_t v4first, v4last;
22288 ip6_address_t v6first, v6last;
22293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22295 if (unformat (i, "%U - %U",
22296 unformat_ip4_address, &v4first,
22297 unformat_ip4_address, &v4last))
22301 errmsg ("one range per message (range already set)");
22306 else if (unformat (i, "%U - %U",
22307 unformat_ip6_address, &v6first,
22308 unformat_ip6_address, &v6last))
22312 errmsg ("one range per message (range already set)");
22317 else if (unformat (i, "vrf %d", &vrf_id))
22323 if (range_set == 0)
22325 errmsg ("address range not set");
22329 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22330 mp->vrf_id = ntohl (vrf_id);
22332 if (range_set == 2)
22335 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22336 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22341 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22342 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22349 static void vl_api_app_namespace_add_del_reply_t_handler
22350 (vl_api_app_namespace_add_del_reply_t * mp)
22352 vat_main_t *vam = &vat_main;
22353 i32 retval = ntohl (mp->retval);
22354 if (vam->async_mode)
22356 vam->async_errors += (retval < 0);
22360 vam->retval = retval;
22362 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22363 vam->result_ready = 1;
22367 static void vl_api_app_namespace_add_del_reply_t_handler_json
22368 (vl_api_app_namespace_add_del_reply_t * mp)
22370 vat_main_t *vam = &vat_main;
22371 vat_json_node_t node;
22373 vat_json_init_object (&node);
22374 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22375 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22377 vat_json_print (vam->ofp, &node);
22378 vat_json_free (&node);
22380 vam->retval = ntohl (mp->retval);
22381 vam->result_ready = 1;
22385 api_app_namespace_add_del (vat_main_t * vam)
22387 vl_api_app_namespace_add_del_t *mp;
22388 unformat_input_t *i = vam->input;
22389 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22390 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22396 if (unformat (i, "id %_%v%_", &ns_id))
22398 else if (unformat (i, "secret %lu", &secret))
22400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22401 sw_if_index_set = 1;
22402 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22404 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22409 if (!ns_id || !secret_set || !sw_if_index_set)
22411 errmsg ("namespace id, secret and sw_if_index must be set");
22414 if (vec_len (ns_id) > 64)
22416 errmsg ("namespace id too long");
22419 M (APP_NAMESPACE_ADD_DEL, mp);
22421 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22422 mp->namespace_id_len = vec_len (ns_id);
22423 mp->secret = clib_host_to_net_u64 (secret);
22424 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22425 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22426 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22434 api_memfd_segment_create (vat_main_t * vam)
22436 #if VPP_API_TEST_BUILTIN == 0
22437 unformat_input_t *i = vam->input;
22438 vl_api_memfd_segment_create_t *mp;
22439 u64 size = 64 << 20;
22442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22444 if (unformat (i, "size %U", unformat_memory_size, &size))
22450 M (MEMFD_SEGMENT_CREATE, mp);
22451 mp->requested_size = size;
22457 errmsg ("memfd_segment_create (builtin) not supported");
22463 api_sock_init_shm (vat_main_t * vam)
22465 #if VPP_API_TEST_BUILTIN == 0
22466 unformat_input_t *i = vam->input;
22467 vl_api_shm_elem_config_t *config = 0;
22468 u64 size = 64 << 20;
22471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22473 if (unformat (i, "size %U", unformat_memory_size, &size))
22479 /* Try customized config to see if it works */
22480 vec_validate (config, 3);
22481 config[0].type = VL_API_VLIB_RING;
22482 config[0].count = 256;
22483 config[0].size = 256;
22484 config[1].type = VL_API_CLIENT_RING;
22485 config[1].count = 256;
22486 config[1].size = 1024;
22487 config[2].type = VL_API_CLIENT_RING;
22488 config[2].count = 8;
22489 config[2].size = 4096;
22490 config[3].type = VL_API_QUEUE;
22491 config[3].count = 256;
22492 config[3].size = sizeof (uword);
22493 rv = vl_socket_client_init_shm (config);
22495 vam->client_index_invalid = 1;
22503 api_dns_enable_disable (vat_main_t * vam)
22505 unformat_input_t *line_input = vam->input;
22506 vl_api_dns_enable_disable_t *mp;
22507 u8 enable_disable = 1;
22510 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22512 if (unformat (line_input, "disable"))
22513 enable_disable = 0;
22514 if (unformat (line_input, "enable"))
22515 enable_disable = 1;
22520 /* Construct the API message */
22521 M (DNS_ENABLE_DISABLE, mp);
22522 mp->enable = enable_disable;
22526 /* Wait for the reply */
22532 api_dns_resolve_name (vat_main_t * vam)
22534 unformat_input_t *line_input = vam->input;
22535 vl_api_dns_resolve_name_t *mp;
22539 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22541 if (unformat (line_input, "%s", &name))
22547 if (vec_len (name) > 127)
22549 errmsg ("name too long");
22553 /* Construct the API message */
22554 M (DNS_RESOLVE_NAME, mp);
22555 memcpy (mp->name, name, vec_len (name));
22560 /* Wait for the reply */
22566 api_dns_resolve_ip (vat_main_t * vam)
22568 unformat_input_t *line_input = vam->input;
22569 vl_api_dns_resolve_ip_t *mp;
22571 ip4_address_t addr4;
22572 ip6_address_t addr6;
22575 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22577 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22579 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22587 errmsg ("missing address");
22591 /* Construct the API message */
22592 M (DNS_RESOLVE_IP, mp);
22593 mp->is_ip6 = is_ip6;
22595 memcpy (mp->address, &addr6, sizeof (addr6));
22597 memcpy (mp->address, &addr4, sizeof (addr4));
22601 /* Wait for the reply */
22607 api_dns_name_server_add_del (vat_main_t * vam)
22609 unformat_input_t *i = vam->input;
22610 vl_api_dns_name_server_add_del_t *mp;
22612 ip6_address_t ip6_server;
22613 ip4_address_t ip4_server;
22618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22620 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22622 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22624 else if (unformat (i, "del"))
22628 clib_warning ("parse error '%U'", format_unformat_error, i);
22633 if (ip4_set && ip6_set)
22635 errmsg ("Only one server address allowed per message");
22638 if ((ip4_set + ip6_set) == 0)
22640 errmsg ("Server address required");
22644 /* Construct the API message */
22645 M (DNS_NAME_SERVER_ADD_DEL, mp);
22649 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22654 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22658 mp->is_add = is_add;
22663 /* Wait for a reply, return good/bad news */
22669 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22671 vat_main_t *vam = &vat_main;
22676 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22677 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22678 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22679 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22680 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22681 clib_net_to_host_u32 (mp->action_index), mp->tag);
22686 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22687 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22688 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22689 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22690 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22691 clib_net_to_host_u32 (mp->action_index), mp->tag);
22696 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22699 vat_main_t *vam = &vat_main;
22700 vat_json_node_t *node = NULL;
22701 struct in6_addr ip6;
22702 struct in_addr ip4;
22704 if (VAT_JSON_ARRAY != vam->json_tree.type)
22706 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22707 vat_json_init_array (&vam->json_tree);
22709 node = vat_json_array_add (&vam->json_tree);
22710 vat_json_init_object (node);
22712 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22713 vat_json_object_add_uint (node, "appns_index",
22714 clib_net_to_host_u32 (mp->appns_index));
22715 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22716 vat_json_object_add_uint (node, "scope", mp->scope);
22717 vat_json_object_add_uint (node, "action_index",
22718 clib_net_to_host_u32 (mp->action_index));
22719 vat_json_object_add_uint (node, "lcl_port",
22720 clib_net_to_host_u16 (mp->lcl_port));
22721 vat_json_object_add_uint (node, "rmt_port",
22722 clib_net_to_host_u16 (mp->rmt_port));
22723 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22724 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22725 vat_json_object_add_string_copy (node, "tag", mp->tag);
22728 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22729 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22730 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22731 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22735 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22736 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22737 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22738 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22743 api_session_rule_add_del (vat_main_t * vam)
22745 vl_api_session_rule_add_del_t *mp;
22746 unformat_input_t *i = vam->input;
22747 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22748 u32 appns_index = 0, scope = 0;
22749 ip4_address_t lcl_ip4, rmt_ip4;
22750 ip6_address_t lcl_ip6, rmt_ip6;
22751 u8 is_ip4 = 1, conn_set = 0;
22752 u8 is_add = 1, *tag = 0;
22755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22757 if (unformat (i, "del"))
22759 else if (unformat (i, "add"))
22761 else if (unformat (i, "proto tcp"))
22763 else if (unformat (i, "proto udp"))
22765 else if (unformat (i, "appns %d", &appns_index))
22767 else if (unformat (i, "scope %d", &scope))
22769 else if (unformat (i, "tag %_%v%_", &tag))
22773 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22774 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22782 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22783 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22789 else if (unformat (i, "action %d", &action))
22794 if (proto == ~0 || !conn_set || action == ~0)
22796 errmsg ("transport proto, connection and action must be set");
22802 errmsg ("scope should be 0-3");
22806 M (SESSION_RULE_ADD_DEL, mp);
22808 mp->is_ip4 = is_ip4;
22809 mp->transport_proto = proto;
22810 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22811 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22812 mp->lcl_plen = lcl_plen;
22813 mp->rmt_plen = rmt_plen;
22814 mp->action_index = clib_host_to_net_u32 (action);
22815 mp->appns_index = clib_host_to_net_u32 (appns_index);
22817 mp->is_add = is_add;
22820 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22821 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22825 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22826 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22830 clib_memcpy (mp->tag, tag, vec_len (tag));
22840 api_session_rules_dump (vat_main_t * vam)
22842 vl_api_session_rules_dump_t *mp;
22843 vl_api_control_ping_t *mp_ping;
22846 if (!vam->json_output)
22848 print (vam->ofp, "%=20s", "Session Rules");
22851 M (SESSION_RULES_DUMP, mp);
22855 /* Use a control ping for synchronization */
22856 MPING (CONTROL_PING, mp_ping);
22859 /* Wait for a reply... */
22865 api_ip_container_proxy_add_del (vat_main_t * vam)
22867 vl_api_ip_container_proxy_add_del_t *mp;
22868 unformat_input_t *i = vam->input;
22869 u32 plen = ~0, sw_if_index = ~0;
22876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22878 if (unformat (i, "del"))
22880 else if (unformat (i, "add"))
22882 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22887 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22892 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22897 if (sw_if_index == ~0 || plen == ~0)
22899 errmsg ("address and sw_if_index must be set");
22903 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22905 mp->is_ip4 = is_ip4;
22906 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22908 mp->is_add = is_add;
22910 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22912 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22920 api_qos_record_enable_disable (vat_main_t * vam)
22922 unformat_input_t *i = vam->input;
22923 vl_api_qos_record_enable_disable_t *mp;
22924 u32 sw_if_index, qs = 0xff;
22925 u8 sw_if_index_set = 0;
22929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22931 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22932 sw_if_index_set = 1;
22933 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22934 sw_if_index_set = 1;
22935 else if (unformat (i, "%U", unformat_qos_source, &qs))
22937 else if (unformat (i, "disable"))
22941 clib_warning ("parse error '%U'", format_unformat_error, i);
22946 if (sw_if_index_set == 0)
22948 errmsg ("missing interface name or sw_if_index");
22953 errmsg ("input location must be specified");
22957 M (QOS_RECORD_ENABLE_DISABLE, mp);
22959 mp->sw_if_index = ntohl (sw_if_index);
22960 mp->input_source = qs;
22961 mp->enable = enable;
22969 q_or_quit (vat_main_t * vam)
22971 #if VPP_API_TEST_BUILTIN == 0
22972 longjmp (vam->jump_buf, 1);
22974 return 0; /* not so much */
22978 q (vat_main_t * vam)
22980 return q_or_quit (vam);
22984 quit (vat_main_t * vam)
22986 return q_or_quit (vam);
22990 comment (vat_main_t * vam)
22996 cmd_cmp (void *a1, void *a2)
23001 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23005 help (vat_main_t * vam)
23010 unformat_input_t *i = vam->input;
23013 if (unformat (i, "%s", &name))
23017 vec_add1 (name, 0);
23019 hs = hash_get_mem (vam->help_by_name, name);
23021 print (vam->ofp, "usage: %s %s", name, hs[0]);
23023 print (vam->ofp, "No such msg / command '%s'", name);
23028 print (vam->ofp, "Help is available for the following:");
23031 hash_foreach_pair (p, vam->function_by_name,
23033 vec_add1 (cmds, (u8 *)(p->key));
23037 vec_sort_with_function (cmds, cmd_cmp);
23039 for (j = 0; j < vec_len (cmds); j++)
23040 print (vam->ofp, "%s", cmds[j]);
23047 set (vat_main_t * vam)
23049 u8 *name = 0, *value = 0;
23050 unformat_input_t *i = vam->input;
23052 if (unformat (i, "%s", &name))
23054 /* The input buffer is a vector, not a string. */
23055 value = vec_dup (i->buffer);
23056 vec_delete (value, i->index, 0);
23057 /* Almost certainly has a trailing newline */
23058 if (value[vec_len (value) - 1] == '\n')
23059 value[vec_len (value) - 1] = 0;
23060 /* Make sure it's a proper string, one way or the other */
23061 vec_add1 (value, 0);
23062 (void) clib_macro_set_value (&vam->macro_main,
23063 (char *) name, (char *) value);
23066 errmsg ("usage: set <name> <value>");
23074 unset (vat_main_t * vam)
23078 if (unformat (vam->input, "%s", &name))
23079 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23080 errmsg ("unset: %s wasn't set", name);
23093 macro_sort_cmp (void *a1, void *a2)
23095 macro_sort_t *s1 = a1;
23096 macro_sort_t *s2 = a2;
23098 return strcmp ((char *) (s1->name), (char *) (s2->name));
23102 dump_macro_table (vat_main_t * vam)
23104 macro_sort_t *sort_me = 0, *sm;
23109 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23111 vec_add2 (sort_me, sm, 1);
23112 sm->name = (u8 *)(p->key);
23113 sm->value = (u8 *) (p->value[0]);
23117 vec_sort_with_function (sort_me, macro_sort_cmp);
23119 if (vec_len (sort_me))
23120 print (vam->ofp, "%-15s%s", "Name", "Value");
23122 print (vam->ofp, "The macro table is empty...");
23124 for (i = 0; i < vec_len (sort_me); i++)
23125 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23130 dump_node_table (vat_main_t * vam)
23133 vlib_node_t *node, *next_node;
23135 if (vec_len (vam->graph_nodes) == 0)
23137 print (vam->ofp, "Node table empty, issue get_node_graph...");
23141 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23143 node = vam->graph_nodes[i];
23144 print (vam->ofp, "[%d] %s", i, node->name);
23145 for (j = 0; j < vec_len (node->next_nodes); j++)
23147 if (node->next_nodes[j] != ~0)
23149 next_node = vam->graph_nodes[node->next_nodes[j]];
23150 print (vam->ofp, " [%d] %s", j, next_node->name);
23158 value_sort_cmp (void *a1, void *a2)
23160 name_sort_t *n1 = a1;
23161 name_sort_t *n2 = a2;
23163 if (n1->value < n2->value)
23165 if (n1->value > n2->value)
23172 dump_msg_api_table (vat_main_t * vam)
23174 api_main_t *am = &api_main;
23175 name_sort_t *nses = 0, *ns;
23180 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23182 vec_add2 (nses, ns, 1);
23183 ns->name = (u8 *)(hp->key);
23184 ns->value = (u32) hp->value[0];
23188 vec_sort_with_function (nses, value_sort_cmp);
23190 for (i = 0; i < vec_len (nses); i++)
23191 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23197 get_msg_id (vat_main_t * vam)
23202 if (unformat (vam->input, "%s", &name_and_crc))
23204 message_index = vl_msg_api_get_msg_index (name_and_crc);
23205 if (message_index == ~0)
23207 print (vam->ofp, " '%s' not found", name_and_crc);
23210 print (vam->ofp, " '%s' has message index %d",
23211 name_and_crc, message_index);
23214 errmsg ("name_and_crc required...");
23219 search_node_table (vat_main_t * vam)
23221 unformat_input_t *line_input = vam->input;
23224 vlib_node_t *node, *next_node;
23227 if (vam->graph_node_index_by_name == 0)
23229 print (vam->ofp, "Node table empty, issue get_node_graph...");
23233 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23235 if (unformat (line_input, "%s", &node_to_find))
23237 vec_add1 (node_to_find, 0);
23238 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23241 print (vam->ofp, "%s not found...", node_to_find);
23244 node = vam->graph_nodes[p[0]];
23245 print (vam->ofp, "[%d] %s", p[0], node->name);
23246 for (j = 0; j < vec_len (node->next_nodes); j++)
23248 if (node->next_nodes[j] != ~0)
23250 next_node = vam->graph_nodes[node->next_nodes[j]];
23251 print (vam->ofp, " [%d] %s", j, next_node->name);
23258 clib_warning ("parse error '%U'", format_unformat_error,
23264 vec_free (node_to_find);
23273 script (vat_main_t * vam)
23275 #if (VPP_API_TEST_BUILTIN==0)
23277 char *save_current_file;
23278 unformat_input_t save_input;
23279 jmp_buf save_jump_buf;
23280 u32 save_line_number;
23282 FILE *new_fp, *save_ifp;
23284 if (unformat (vam->input, "%s", &s))
23286 new_fp = fopen ((char *) s, "r");
23289 errmsg ("Couldn't open script file %s", s);
23296 errmsg ("Missing script name");
23300 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23301 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23302 save_ifp = vam->ifp;
23303 save_line_number = vam->input_line_number;
23304 save_current_file = (char *) vam->current_file;
23306 vam->input_line_number = 0;
23308 vam->current_file = s;
23311 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
23312 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23313 vam->ifp = save_ifp;
23314 vam->input_line_number = save_line_number;
23315 vam->current_file = (u8 *) save_current_file;
23320 clib_warning ("use the exec command...");
23326 echo (vat_main_t * vam)
23328 print (vam->ofp, "%v", vam->input->buffer);
23332 /* List of API message constructors, CLI names map to api_xxx */
23333 #define foreach_vpe_api_msg \
23334 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23335 _(sw_interface_dump,"") \
23336 _(sw_interface_set_flags, \
23337 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23338 _(sw_interface_add_del_address, \
23339 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23340 _(sw_interface_set_rx_mode, \
23341 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23342 _(sw_interface_set_table, \
23343 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23344 _(sw_interface_set_mpls_enable, \
23345 "<intfc> | sw_if_index [disable | dis]") \
23346 _(sw_interface_set_vpath, \
23347 "<intfc> | sw_if_index <id> enable | disable") \
23348 _(sw_interface_set_vxlan_bypass, \
23349 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23350 _(sw_interface_set_geneve_bypass, \
23351 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23352 _(sw_interface_set_l2_xconnect, \
23353 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23354 "enable | disable") \
23355 _(sw_interface_set_l2_bridge, \
23356 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23357 "[shg <split-horizon-group>] [bvi]\n" \
23358 "enable | disable") \
23359 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23360 _(bridge_domain_add_del, \
23361 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [bd-tag <text>] [del]\n") \
23362 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23364 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23365 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23366 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23368 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23370 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23372 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23374 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23376 "<vpp-if-name> | sw_if_index <id>") \
23377 _(sw_interface_tap_dump, "") \
23379 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23381 "<vpp-if-name> | sw_if_index <id>") \
23382 _(sw_interface_tap_v2_dump, "") \
23384 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23385 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23387 "<vpp-if-name> | sw_if_index <id>") \
23389 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23390 _(bond_detach_slave, \
23391 "sw_if_index <n>") \
23392 _(sw_interface_bond_dump, "") \
23393 _(sw_interface_slave_dump, \
23394 "<vpp-if-name> | sw_if_index <id>") \
23395 _(ip_table_add_del, \
23396 "table-id <n> [ipv6]\n") \
23397 _(ip_add_del_route, \
23398 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23399 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23400 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23401 "[multipath] [count <n>]") \
23402 _(ip_mroute_add_del, \
23403 "<src> <grp>/<mask> [table-id <n>]\n" \
23404 "[<intfc> | sw_if_index <id>] [local] [del]") \
23405 _(mpls_table_add_del, \
23406 "table-id <n>\n") \
23407 _(mpls_route_add_del, \
23408 "<label> <eos> via <addr> [table-id <n>]\n" \
23409 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23410 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23411 "[multipath] [count <n>]") \
23412 _(mpls_ip_bind_unbind, \
23413 "<label> <addr/len>") \
23414 _(mpls_tunnel_add_del, \
23415 " via <addr> [table-id <n>]\n" \
23416 "sw_if_index <id>] [l2] [del]") \
23417 _(bier_table_add_del, \
23418 "<label> <sub-domain> <set> <bsl> [del]") \
23419 _(bier_route_add_del, \
23420 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23421 "[<intfc> | sw_if_index <id>]" \
23422 "[weight <n>] [del] [multipath]") \
23423 _(proxy_arp_add_del, \
23424 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23425 _(proxy_arp_intfc_enable_disable, \
23426 "<intfc> | sw_if_index <id> enable | disable") \
23427 _(sw_interface_set_unnumbered, \
23428 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23429 _(ip_neighbor_add_del, \
23430 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23431 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23432 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23433 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23434 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23435 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23436 "[outer_vlan_id_any][inner_vlan_id_any]") \
23437 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23438 _(reset_fib, "vrf <n> [ipv6]") \
23439 _(dhcp_proxy_config, \
23440 "svr <v46-address> src <v46-address>\n" \
23441 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23442 _(dhcp_proxy_set_vss, \
23443 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23444 _(dhcp_proxy_dump, "ip6") \
23445 _(dhcp_client_config, \
23446 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23447 _(set_ip_flow_hash, \
23448 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23449 _(sw_interface_ip6_enable_disable, \
23450 "<intfc> | sw_if_index <id> enable | disable") \
23451 _(sw_interface_ip6_set_link_local_address, \
23452 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23453 _(ip6nd_proxy_add_del, \
23454 "<intfc> | sw_if_index <id> <ip6-address>") \
23455 _(ip6nd_proxy_dump, "") \
23456 _(sw_interface_ip6nd_ra_prefix, \
23457 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23458 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23459 "[nolink] [isno]") \
23460 _(sw_interface_ip6nd_ra_config, \
23461 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23462 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23463 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23464 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23465 _(l2_patch_add_del, \
23466 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23467 "enable | disable") \
23468 _(sr_localsid_add_del, \
23469 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23470 "fib-table <num> (end.psp) sw_if_index <num>") \
23471 _(classify_add_del_table, \
23472 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23473 " [del] [del-chain] mask <mask-value>\n" \
23474 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23475 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23476 _(classify_add_del_session, \
23477 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23478 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23479 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23480 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23481 _(classify_set_interface_ip_table, \
23482 "<intfc> | sw_if_index <nn> table <nn>") \
23483 _(classify_set_interface_l2_tables, \
23484 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23485 " [other-table <nn>]") \
23486 _(get_node_index, "node <node-name") \
23487 _(add_node_next, "node <node-name> next <next-node-name>") \
23488 _(l2tpv3_create_tunnel, \
23489 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23490 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23491 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23492 _(l2tpv3_set_tunnel_cookies, \
23493 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23494 "[new_remote_cookie <nn>]\n") \
23495 _(l2tpv3_interface_enable_disable, \
23496 "<intfc> | sw_if_index <nn> enable | disable") \
23497 _(l2tpv3_set_lookup_key, \
23498 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23499 _(sw_if_l2tpv3_tunnel_dump, "") \
23500 _(vxlan_add_del_tunnel, \
23501 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23502 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23503 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23504 _(geneve_add_del_tunnel, \
23505 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23506 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23507 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23508 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23509 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23510 _(gre_add_del_tunnel, \
23511 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23512 "[teb | erspan <session-id>] [del]") \
23513 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23514 _(l2_fib_clear_table, "") \
23515 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23516 _(l2_interface_vlan_tag_rewrite, \
23517 "<intfc> | sw_if_index <nn> \n" \
23518 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23519 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23520 _(create_vhost_user_if, \
23521 "socket <filename> [server] [renumber <dev_instance>] " \
23522 "[mac <mac_address>]") \
23523 _(modify_vhost_user_if, \
23524 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23525 "[server] [renumber <dev_instance>]") \
23526 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23527 _(sw_interface_vhost_user_dump, "") \
23528 _(show_version, "") \
23529 _(vxlan_gpe_add_del_tunnel, \
23530 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23531 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23532 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23533 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23534 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23535 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23536 _(interface_name_renumber, \
23537 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23538 _(input_acl_set_interface, \
23539 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23540 " [l2-table <nn>] [del]") \
23541 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23542 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23543 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23544 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23545 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23546 _(ip_dump, "ipv4 | ipv6") \
23547 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23548 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23550 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23551 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23552 " integ_alg <alg> integ_key <hex>") \
23553 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23554 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23555 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23556 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23557 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23558 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23559 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23560 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23561 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23562 " [instance <n>]") \
23563 _(ipsec_sa_dump, "[sa_id <n>]") \
23564 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23565 " <alg> <hex>\n") \
23566 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23567 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23568 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23569 "(auth_data 0x<data> | auth_data <data>)") \
23570 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23571 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23572 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23573 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23574 "(local|remote)") \
23575 _(ikev2_set_local_key, "file <absolute_file_path>") \
23576 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23577 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23578 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23579 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23580 _(ikev2_initiate_sa_init, "<profile_name>") \
23581 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23582 _(ikev2_initiate_del_child_sa, "<ispi>") \
23583 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23584 _(delete_loopback,"sw_if_index <nn>") \
23585 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23586 _(map_add_domain, \
23587 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23588 "ip6-src <ip6addr> " \
23589 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23590 _(map_del_domain, "index <n>") \
23591 _(map_add_del_rule, \
23592 "index <n> psid <n> dst <ip6addr> [del]") \
23593 _(map_domain_dump, "") \
23594 _(map_rule_dump, "index <map-domain>") \
23595 _(want_interface_events, "enable|disable") \
23596 _(want_stats,"enable|disable") \
23597 _(get_first_msg_id, "client <name>") \
23598 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23599 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23600 "fib-id <nn> [ip4][ip6][default]") \
23601 _(get_node_graph, " ") \
23602 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23603 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23604 _(ioam_disable, "") \
23605 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23606 " sw_if_index <sw_if_index> p <priority> " \
23607 "w <weight>] [del]") \
23608 _(one_add_del_locator, "locator-set <locator_name> " \
23609 "iface <intf> | sw_if_index <sw_if_index> " \
23610 "p <priority> w <weight> [del]") \
23611 _(one_add_del_local_eid,"vni <vni> eid " \
23612 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23613 "locator-set <locator_name> [del]" \
23614 "[key-id sha1|sha256 secret-key <secret-key>]")\
23615 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23616 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23617 _(one_enable_disable, "enable|disable") \
23618 _(one_map_register_enable_disable, "enable|disable") \
23619 _(one_map_register_fallback_threshold, "<value>") \
23620 _(one_rloc_probe_enable_disable, "enable|disable") \
23621 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23623 "rloc <locator> p <prio> " \
23624 "w <weight> [rloc <loc> ... ] " \
23625 "action <action> [del-all]") \
23626 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23628 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23629 _(one_use_petr, "ip-address> | disable") \
23630 _(one_map_request_mode, "src-dst|dst-only") \
23631 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23632 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23633 _(one_locator_set_dump, "[local | remote]") \
23634 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23635 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23636 "[local] | [remote]") \
23637 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23638 _(one_ndp_bd_get, "") \
23639 _(one_ndp_entries_get, "bd <bridge-domain>") \
23640 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23641 _(one_l2_arp_bd_get, "") \
23642 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23643 _(one_stats_enable_disable, "enable|disalbe") \
23644 _(show_one_stats_enable_disable, "") \
23645 _(one_eid_table_vni_dump, "") \
23646 _(one_eid_table_map_dump, "l2|l3") \
23647 _(one_map_resolver_dump, "") \
23648 _(one_map_server_dump, "") \
23649 _(one_adjacencies_get, "vni <vni>") \
23650 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23651 _(show_one_rloc_probe_state, "") \
23652 _(show_one_map_register_state, "") \
23653 _(show_one_status, "") \
23654 _(one_stats_dump, "") \
23655 _(one_stats_flush, "") \
23656 _(one_get_map_request_itr_rlocs, "") \
23657 _(one_map_register_set_ttl, "<ttl>") \
23658 _(one_set_transport_protocol, "udp|api") \
23659 _(one_get_transport_protocol, "") \
23660 _(one_enable_disable_xtr_mode, "enable|disable") \
23661 _(one_show_xtr_mode, "") \
23662 _(one_enable_disable_pitr_mode, "enable|disable") \
23663 _(one_show_pitr_mode, "") \
23664 _(one_enable_disable_petr_mode, "enable|disable") \
23665 _(one_show_petr_mode, "") \
23666 _(show_one_nsh_mapping, "") \
23667 _(show_one_pitr, "") \
23668 _(show_one_use_petr, "") \
23669 _(show_one_map_request_mode, "") \
23670 _(show_one_map_register_ttl, "") \
23671 _(show_one_map_register_fallback_threshold, "") \
23672 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23673 " sw_if_index <sw_if_index> p <priority> " \
23674 "w <weight>] [del]") \
23675 _(lisp_add_del_locator, "locator-set <locator_name> " \
23676 "iface <intf> | sw_if_index <sw_if_index> " \
23677 "p <priority> w <weight> [del]") \
23678 _(lisp_add_del_local_eid,"vni <vni> eid " \
23679 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23680 "locator-set <locator_name> [del]" \
23681 "[key-id sha1|sha256 secret-key <secret-key>]") \
23682 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23683 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23684 _(lisp_enable_disable, "enable|disable") \
23685 _(lisp_map_register_enable_disable, "enable|disable") \
23686 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23687 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23689 "rloc <locator> p <prio> " \
23690 "w <weight> [rloc <loc> ... ] " \
23691 "action <action> [del-all]") \
23692 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23694 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23695 _(lisp_use_petr, "<ip-address> | disable") \
23696 _(lisp_map_request_mode, "src-dst|dst-only") \
23697 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23698 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23699 _(lisp_locator_set_dump, "[local | remote]") \
23700 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23701 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23702 "[local] | [remote]") \
23703 _(lisp_eid_table_vni_dump, "") \
23704 _(lisp_eid_table_map_dump, "l2|l3") \
23705 _(lisp_map_resolver_dump, "") \
23706 _(lisp_map_server_dump, "") \
23707 _(lisp_adjacencies_get, "vni <vni>") \
23708 _(gpe_fwd_entry_vnis_get, "") \
23709 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23710 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23711 "[table <table-id>]") \
23712 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23713 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23714 _(gpe_set_encap_mode, "lisp|vxlan") \
23715 _(gpe_get_encap_mode, "") \
23716 _(lisp_gpe_add_del_iface, "up|down") \
23717 _(lisp_gpe_enable_disable, "enable|disable") \
23718 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23719 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23720 _(show_lisp_rloc_probe_state, "") \
23721 _(show_lisp_map_register_state, "") \
23722 _(show_lisp_status, "") \
23723 _(lisp_get_map_request_itr_rlocs, "") \
23724 _(show_lisp_pitr, "") \
23725 _(show_lisp_use_petr, "") \
23726 _(show_lisp_map_request_mode, "") \
23727 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23728 _(af_packet_delete, "name <host interface name>") \
23729 _(policer_add_del, "name <policer name> <params> [del]") \
23730 _(policer_dump, "[name <policer name>]") \
23731 _(policer_classify_set_interface, \
23732 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23733 " [l2-table <nn>] [del]") \
23734 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23735 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23736 "[master|slave]") \
23737 _(netmap_delete, "name <interface name>") \
23738 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23739 _(mpls_fib_dump, "") \
23740 _(classify_table_ids, "") \
23741 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23742 _(classify_table_info, "table_id <nn>") \
23743 _(classify_session_dump, "table_id <nn>") \
23744 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23745 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23746 "[template_interval <nn>] [udp_checksum]") \
23747 _(ipfix_exporter_dump, "") \
23748 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23749 _(ipfix_classify_stream_dump, "") \
23750 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23751 _(ipfix_classify_table_dump, "") \
23752 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23753 _(sw_interface_span_dump, "[l2]") \
23754 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23755 _(pg_create_interface, "if_id <nn>") \
23756 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23757 _(pg_enable_disable, "[stream <id>] disable") \
23758 _(ip_source_and_port_range_check_add_del, \
23759 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23760 _(ip_source_and_port_range_check_interface_add_del, \
23761 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23762 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23763 _(ipsec_gre_add_del_tunnel, \
23764 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23765 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23766 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23767 _(l2_interface_pbb_tag_rewrite, \
23768 "<intfc> | sw_if_index <nn> \n" \
23769 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23770 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23771 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23772 _(flow_classify_set_interface, \
23773 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23774 _(flow_classify_dump, "type [ip4|ip6]") \
23775 _(ip_fib_dump, "") \
23776 _(ip_mfib_dump, "") \
23777 _(ip6_fib_dump, "") \
23778 _(ip6_mfib_dump, "") \
23779 _(feature_enable_disable, "arc_name <arc_name> " \
23780 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23781 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23783 _(l2_xconnect_dump, "") \
23784 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23785 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23786 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23787 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23788 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23789 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23790 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23791 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23792 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23793 _(memfd_segment_create,"size <nnn>") \
23794 _(sock_init_shm, "size <nnn>") \
23795 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23796 _(dns_enable_disable, "[enable][disable]") \
23797 _(dns_name_server_add_del, "<ip-address> [del]") \
23798 _(dns_resolve_name, "<hostname>") \
23799 _(dns_resolve_ip, "<ip4|ip6>") \
23800 _(dns_name_server_add_del, "<ip-address> [del]") \
23801 _(dns_resolve_name, "<hostname>") \
23802 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23803 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23804 _(session_rules_dump, "") \
23805 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23806 _(output_acl_set_interface, \
23807 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23808 " [l2-table <nn>] [del]") \
23809 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23811 /* List of command functions, CLI names map directly to functions */
23812 #define foreach_cli_function \
23813 _(comment, "usage: comment <ignore-rest-of-line>") \
23814 _(dump_interface_table, "usage: dump_interface_table") \
23815 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23816 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23817 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23818 _(dump_stats_table, "usage: dump_stats_table") \
23819 _(dump_macro_table, "usage: dump_macro_table ") \
23820 _(dump_node_table, "usage: dump_node_table") \
23821 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23822 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23823 _(echo, "usage: echo <message>") \
23824 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23825 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23826 _(help, "usage: help") \
23827 _(q, "usage: quit") \
23828 _(quit, "usage: quit") \
23829 _(search_node_table, "usage: search_node_table <name>...") \
23830 _(set, "usage: set <variable-name> <value>") \
23831 _(script, "usage: script <file-name>") \
23832 _(unset, "usage: unset <variable-name>")
23834 static void vl_api_##n##_t_handler_uni \
23835 (vl_api_##n##_t * mp) \
23837 vat_main_t * vam = &vat_main; \
23838 if (vam->json_output) { \
23839 vl_api_##n##_t_handler_json(mp); \
23841 vl_api_##n##_t_handler(mp); \
23844 foreach_vpe_api_reply_msg;
23845 #if VPP_API_TEST_BUILTIN == 0
23846 foreach_standalone_reply_msg;
23851 vat_api_hookup (vat_main_t * vam)
23854 vl_msg_api_set_handlers(VL_API_##N, #n, \
23855 vl_api_##n##_t_handler_uni, \
23857 vl_api_##n##_t_endian, \
23858 vl_api_##n##_t_print, \
23859 sizeof(vl_api_##n##_t), 1);
23860 foreach_vpe_api_reply_msg;
23861 #if VPP_API_TEST_BUILTIN == 0
23862 foreach_standalone_reply_msg;
23866 #if (VPP_API_TEST_BUILTIN==0)
23867 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23869 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23871 vam->function_by_name = hash_create_string (0, sizeof (uword));
23873 vam->help_by_name = hash_create_string (0, sizeof (uword));
23876 /* API messages we can send */
23877 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23878 foreach_vpe_api_msg;
23882 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23883 foreach_vpe_api_msg;
23886 /* CLI functions */
23887 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23888 foreach_cli_function;
23892 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23893 foreach_cli_function;
23897 #if VPP_API_TEST_BUILTIN
23898 static clib_error_t *
23899 vat_api_hookup_shim (vlib_main_t * vm)
23901 vat_api_hookup (&vat_main);
23905 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23909 * fd.io coding-style-patch-verification: ON
23912 * eval: (c-set-style "gnu")