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 void vl_api_dns_resolve_name_reply_t_handler
2415 (vl_api_dns_resolve_name_reply_t * mp)
2417 vat_main_t *vam = &vat_main;
2418 i32 retval = ntohl (mp->retval);
2419 if (vam->async_mode)
2421 vam->async_errors += (retval < 0);
2425 vam->retval = retval;
2426 vam->result_ready = 1;
2431 clib_warning ("ip4 address %U", format_ip4_address,
2432 (ip4_address_t *) mp->ip4_address);
2434 clib_warning ("ip6 address %U", format_ip6_address,
2435 (ip6_address_t *) mp->ip6_address);
2438 clib_warning ("retval %d", retval);
2442 static void vl_api_dns_resolve_name_reply_t_handler_json
2443 (vl_api_dns_resolve_name_reply_t * mp)
2445 clib_warning ("not implemented");
2448 static void vl_api_dns_resolve_ip_reply_t_handler
2449 (vl_api_dns_resolve_ip_reply_t * mp)
2451 vat_main_t *vam = &vat_main;
2452 i32 retval = ntohl (mp->retval);
2453 if (vam->async_mode)
2455 vam->async_errors += (retval < 0);
2459 vam->retval = retval;
2460 vam->result_ready = 1;
2464 clib_warning ("canonical name %s", mp->name);
2467 clib_warning ("retval %d", retval);
2471 static void vl_api_dns_resolve_ip_reply_t_handler_json
2472 (vl_api_dns_resolve_ip_reply_t * mp)
2474 clib_warning ("not implemented");
2478 static void vl_api_ip_address_details_t_handler
2479 (vl_api_ip_address_details_t * mp)
2481 vat_main_t *vam = &vat_main;
2482 static ip_address_details_t empty_ip_address_details = { {0} };
2483 ip_address_details_t *address = NULL;
2484 ip_details_t *current_ip_details = NULL;
2485 ip_details_t *details = NULL;
2487 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2489 if (!details || vam->current_sw_if_index >= vec_len (details)
2490 || !details[vam->current_sw_if_index].present)
2492 errmsg ("ip address details arrived but not stored");
2493 errmsg ("ip_dump should be called first");
2497 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2499 #define addresses (current_ip_details->addr)
2501 vec_validate_init_empty (addresses, vec_len (addresses),
2502 empty_ip_address_details);
2504 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2506 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2507 address->prefix_length = mp->prefix_length;
2511 static void vl_api_ip_address_details_t_handler_json
2512 (vl_api_ip_address_details_t * mp)
2514 vat_main_t *vam = &vat_main;
2515 vat_json_node_t *node = NULL;
2516 struct in6_addr ip6;
2519 if (VAT_JSON_ARRAY != vam->json_tree.type)
2521 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2522 vat_json_init_array (&vam->json_tree);
2524 node = vat_json_array_add (&vam->json_tree);
2526 vat_json_init_object (node);
2529 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2530 vat_json_object_add_ip6 (node, "ip", ip6);
2534 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2535 vat_json_object_add_ip4 (node, "ip", ip4);
2537 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2541 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2543 vat_main_t *vam = &vat_main;
2544 static ip_details_t empty_ip_details = { 0 };
2545 ip_details_t *ip = NULL;
2546 u32 sw_if_index = ~0;
2548 sw_if_index = ntohl (mp->sw_if_index);
2550 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2551 sw_if_index, empty_ip_details);
2553 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2560 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2562 vat_main_t *vam = &vat_main;
2564 if (VAT_JSON_ARRAY != vam->json_tree.type)
2566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2567 vat_json_init_array (&vam->json_tree);
2569 vat_json_array_add_uint (&vam->json_tree,
2570 clib_net_to_host_u32 (mp->sw_if_index));
2573 static void vl_api_map_domain_details_t_handler_json
2574 (vl_api_map_domain_details_t * mp)
2576 vat_json_node_t *node = NULL;
2577 vat_main_t *vam = &vat_main;
2578 struct in6_addr ip6;
2581 if (VAT_JSON_ARRAY != vam->json_tree.type)
2583 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2584 vat_json_init_array (&vam->json_tree);
2587 node = vat_json_array_add (&vam->json_tree);
2588 vat_json_init_object (node);
2590 vat_json_object_add_uint (node, "domain_index",
2591 clib_net_to_host_u32 (mp->domain_index));
2592 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2593 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2594 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2595 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2596 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2597 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2598 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2599 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2600 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2601 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2602 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2603 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2604 vat_json_object_add_uint (node, "flags", mp->flags);
2605 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2606 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2609 static void vl_api_map_domain_details_t_handler
2610 (vl_api_map_domain_details_t * mp)
2612 vat_main_t *vam = &vat_main;
2614 if (mp->is_translation)
2617 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2618 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2619 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2620 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2621 clib_net_to_host_u32 (mp->domain_index));
2626 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2627 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2628 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2629 format_ip6_address, mp->ip6_src,
2630 clib_net_to_host_u32 (mp->domain_index));
2632 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2633 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2634 mp->is_translation ? "map-t" : "");
2637 static void vl_api_map_rule_details_t_handler_json
2638 (vl_api_map_rule_details_t * mp)
2640 struct in6_addr ip6;
2641 vat_json_node_t *node = NULL;
2642 vat_main_t *vam = &vat_main;
2644 if (VAT_JSON_ARRAY != vam->json_tree.type)
2646 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2647 vat_json_init_array (&vam->json_tree);
2650 node = vat_json_array_add (&vam->json_tree);
2651 vat_json_init_object (node);
2653 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2654 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2655 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2659 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2661 vat_main_t *vam = &vat_main;
2662 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2663 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2667 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2669 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2670 "router_addr %U host_mac %U",
2671 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2672 format_ip4_address, &mp->host_address,
2673 format_ip4_address, &mp->router_address,
2674 format_ethernet_address, mp->host_mac);
2677 static void vl_api_dhcp_compl_event_t_handler_json
2678 (vl_api_dhcp_compl_event_t * mp)
2680 /* JSON output not supported */
2684 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2687 vat_main_t *vam = &vat_main;
2688 static u64 default_counter = 0;
2690 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2692 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2693 sw_if_index, default_counter);
2694 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2698 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2699 interface_counter_t counter)
2701 vat_main_t *vam = &vat_main;
2702 static interface_counter_t default_counter = { 0, };
2704 vec_validate_init_empty (vam->combined_interface_counters,
2705 vnet_counter_type, NULL);
2706 vec_validate_init_empty (vam->combined_interface_counters
2707 [vnet_counter_type], sw_if_index, default_counter);
2708 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2711 static void vl_api_vnet_interface_simple_counters_t_handler
2712 (vl_api_vnet_interface_simple_counters_t * mp)
2717 static void vl_api_vnet_interface_combined_counters_t_handler
2718 (vl_api_vnet_interface_combined_counters_t * mp)
2723 static void vl_api_vnet_interface_simple_counters_t_handler_json
2724 (vl_api_vnet_interface_simple_counters_t * mp)
2729 u32 first_sw_if_index;
2732 count = ntohl (mp->count);
2733 first_sw_if_index = ntohl (mp->first_sw_if_index);
2735 v_packets = (u64 *) & mp->data;
2736 for (i = 0; i < count; i++)
2738 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2739 set_simple_interface_counter (mp->vnet_counter_type,
2740 first_sw_if_index + i, packets);
2745 static void vl_api_vnet_interface_combined_counters_t_handler_json
2746 (vl_api_vnet_interface_combined_counters_t * mp)
2748 interface_counter_t counter;
2750 u32 first_sw_if_index;
2754 count = ntohl (mp->count);
2755 first_sw_if_index = ntohl (mp->first_sw_if_index);
2757 v = (vlib_counter_t *) & mp->data;
2758 for (i = 0; i < count; i++)
2761 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2763 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2764 set_combined_interface_counter (mp->vnet_counter_type,
2765 first_sw_if_index + i, counter);
2771 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2773 vat_main_t *vam = &vat_main;
2776 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2778 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2787 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2789 vat_main_t *vam = &vat_main;
2792 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2794 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2802 static void vl_api_vnet_ip4_fib_counters_t_handler
2803 (vl_api_vnet_ip4_fib_counters_t * mp)
2808 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2809 (vl_api_vnet_ip4_fib_counters_t * mp)
2811 vat_main_t *vam = &vat_main;
2812 vl_api_ip4_fib_counter_t *v;
2813 ip4_fib_counter_t *counter;
2820 vrf_id = ntohl (mp->vrf_id);
2821 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2822 if (~0 == vrf_index)
2824 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2825 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2826 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2827 vec_validate (vam->ip4_fib_counters, vrf_index);
2828 vam->ip4_fib_counters[vrf_index] = NULL;
2831 vec_free (vam->ip4_fib_counters[vrf_index]);
2832 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2833 count = ntohl (mp->count);
2834 for (i = 0; i < count; i++)
2836 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2837 counter = &vam->ip4_fib_counters[vrf_index][i];
2838 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2839 counter->address = ip4;
2840 counter->address_length = v->address_length;
2841 counter->packets = clib_net_to_host_u64 (v->packets);
2842 counter->bytes = clib_net_to_host_u64 (v->bytes);
2847 static void vl_api_vnet_ip4_nbr_counters_t_handler
2848 (vl_api_vnet_ip4_nbr_counters_t * mp)
2853 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2854 (vl_api_vnet_ip4_nbr_counters_t * mp)
2856 vat_main_t *vam = &vat_main;
2857 vl_api_ip4_nbr_counter_t *v;
2858 ip4_nbr_counter_t *counter;
2863 sw_if_index = ntohl (mp->sw_if_index);
2864 count = ntohl (mp->count);
2865 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2868 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2870 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2871 for (i = 0; i < count; i++)
2873 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2874 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2875 counter->address.s_addr = v->address;
2876 counter->packets = clib_net_to_host_u64 (v->packets);
2877 counter->bytes = clib_net_to_host_u64 (v->bytes);
2878 counter->linkt = v->link_type;
2883 static void vl_api_vnet_ip6_fib_counters_t_handler
2884 (vl_api_vnet_ip6_fib_counters_t * mp)
2889 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2890 (vl_api_vnet_ip6_fib_counters_t * mp)
2892 vat_main_t *vam = &vat_main;
2893 vl_api_ip6_fib_counter_t *v;
2894 ip6_fib_counter_t *counter;
2895 struct in6_addr ip6;
2901 vrf_id = ntohl (mp->vrf_id);
2902 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2903 if (~0 == vrf_index)
2905 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2906 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2907 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2908 vec_validate (vam->ip6_fib_counters, vrf_index);
2909 vam->ip6_fib_counters[vrf_index] = NULL;
2912 vec_free (vam->ip6_fib_counters[vrf_index]);
2913 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2914 count = ntohl (mp->count);
2915 for (i = 0; i < count; i++)
2917 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2918 counter = &vam->ip6_fib_counters[vrf_index][i];
2919 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2920 counter->address = ip6;
2921 counter->address_length = v->address_length;
2922 counter->packets = clib_net_to_host_u64 (v->packets);
2923 counter->bytes = clib_net_to_host_u64 (v->bytes);
2928 static void vl_api_vnet_ip6_nbr_counters_t_handler
2929 (vl_api_vnet_ip6_nbr_counters_t * mp)
2934 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2935 (vl_api_vnet_ip6_nbr_counters_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 vl_api_ip6_nbr_counter_t *v;
2939 ip6_nbr_counter_t *counter;
2940 struct in6_addr ip6;
2945 sw_if_index = ntohl (mp->sw_if_index);
2946 count = ntohl (mp->count);
2947 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2950 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2952 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2953 for (i = 0; i < count; i++)
2955 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2956 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2957 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2958 counter->address = ip6;
2959 counter->packets = clib_net_to_host_u64 (v->packets);
2960 counter->bytes = clib_net_to_host_u64 (v->bytes);
2965 static void vl_api_get_first_msg_id_reply_t_handler
2966 (vl_api_get_first_msg_id_reply_t * mp)
2968 vat_main_t *vam = &vat_main;
2969 i32 retval = ntohl (mp->retval);
2971 if (vam->async_mode)
2973 vam->async_errors += (retval < 0);
2977 vam->retval = retval;
2978 vam->result_ready = 1;
2982 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2986 static void vl_api_get_first_msg_id_reply_t_handler_json
2987 (vl_api_get_first_msg_id_reply_t * mp)
2989 vat_main_t *vam = &vat_main;
2990 vat_json_node_t node;
2992 vat_json_init_object (&node);
2993 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2994 vat_json_object_add_uint (&node, "first_msg_id",
2995 (uint) ntohs (mp->first_msg_id));
2997 vat_json_print (vam->ofp, &node);
2998 vat_json_free (&node);
3000 vam->retval = ntohl (mp->retval);
3001 vam->result_ready = 1;
3004 static void vl_api_get_node_graph_reply_t_handler
3005 (vl_api_get_node_graph_reply_t * mp)
3007 vat_main_t *vam = &vat_main;
3008 api_main_t *am = &api_main;
3009 i32 retval = ntohl (mp->retval);
3010 u8 *pvt_copy, *reply;
3015 if (vam->async_mode)
3017 vam->async_errors += (retval < 0);
3021 vam->retval = retval;
3022 vam->result_ready = 1;
3025 /* "Should never happen..." */
3029 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3030 pvt_copy = vec_dup (reply);
3032 /* Toss the shared-memory original... */
3033 pthread_mutex_lock (&am->vlib_rp->mutex);
3034 oldheap = svm_push_data_heap (am->vlib_rp);
3038 svm_pop_heap (oldheap);
3039 pthread_mutex_unlock (&am->vlib_rp->mutex);
3041 if (vam->graph_nodes)
3043 hash_free (vam->graph_node_index_by_name);
3045 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3047 node = vam->graph_nodes[i];
3048 vec_free (node->name);
3049 vec_free (node->next_nodes);
3052 vec_free (vam->graph_nodes);
3055 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3056 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3057 vec_free (pvt_copy);
3059 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3061 node = vam->graph_nodes[i];
3062 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3066 static void vl_api_get_node_graph_reply_t_handler_json
3067 (vl_api_get_node_graph_reply_t * mp)
3069 vat_main_t *vam = &vat_main;
3070 api_main_t *am = &api_main;
3072 vat_json_node_t node;
3075 /* $$$$ make this real? */
3076 vat_json_init_object (&node);
3077 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3078 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3080 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3082 /* Toss the shared-memory original... */
3083 pthread_mutex_lock (&am->vlib_rp->mutex);
3084 oldheap = svm_push_data_heap (am->vlib_rp);
3088 svm_pop_heap (oldheap);
3089 pthread_mutex_unlock (&am->vlib_rp->mutex);
3091 vat_json_print (vam->ofp, &node);
3092 vat_json_free (&node);
3094 vam->retval = ntohl (mp->retval);
3095 vam->result_ready = 1;
3099 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3101 vat_main_t *vam = &vat_main;
3106 s = format (s, "%=16d%=16d%=16d",
3107 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3111 s = format (s, "%=16U%=16d%=16d",
3112 mp->is_ipv6 ? format_ip6_address :
3114 mp->ip_address, mp->priority, mp->weight);
3117 print (vam->ofp, "%v", s);
3122 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3124 vat_main_t *vam = &vat_main;
3125 vat_json_node_t *node = NULL;
3126 struct in6_addr ip6;
3129 if (VAT_JSON_ARRAY != vam->json_tree.type)
3131 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3132 vat_json_init_array (&vam->json_tree);
3134 node = vat_json_array_add (&vam->json_tree);
3135 vat_json_init_object (node);
3137 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3138 vat_json_object_add_uint (node, "priority", mp->priority);
3139 vat_json_object_add_uint (node, "weight", mp->weight);
3142 vat_json_object_add_uint (node, "sw_if_index",
3143 clib_net_to_host_u32 (mp->sw_if_index));
3148 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3149 vat_json_object_add_ip6 (node, "address", ip6);
3153 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3154 vat_json_object_add_ip4 (node, "address", ip4);
3160 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3163 vat_main_t *vam = &vat_main;
3166 ls_name = format (0, "%s", mp->ls_name);
3168 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3174 vl_api_one_locator_set_details_t_handler_json
3175 (vl_api_one_locator_set_details_t * mp)
3177 vat_main_t *vam = &vat_main;
3178 vat_json_node_t *node = 0;
3181 ls_name = format (0, "%s", mp->ls_name);
3182 vec_add1 (ls_name, 0);
3184 if (VAT_JSON_ARRAY != vam->json_tree.type)
3186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3187 vat_json_init_array (&vam->json_tree);
3189 node = vat_json_array_add (&vam->json_tree);
3191 vat_json_init_object (node);
3192 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3193 vat_json_object_add_uint (node, "ls_index",
3194 clib_net_to_host_u32 (mp->ls_index));
3202 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3205 unformat_nsh_address (unformat_input_t * input, va_list * args)
3207 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3208 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3212 format_nsh_address_vat (u8 * s, va_list * args)
3214 nsh_t *a = va_arg (*args, nsh_t *);
3215 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3219 format_lisp_flat_eid (u8 * s, va_list * args)
3221 u32 type = va_arg (*args, u32);
3222 u8 *eid = va_arg (*args, u8 *);
3223 u32 eid_len = va_arg (*args, u32);
3228 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3230 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3232 return format (s, "%U", format_ethernet_address, eid);
3234 return format (s, "%U", format_nsh_address_vat, eid);
3240 format_lisp_eid_vat (u8 * s, va_list * args)
3242 u32 type = va_arg (*args, u32);
3243 u8 *eid = va_arg (*args, u8 *);
3244 u32 eid_len = va_arg (*args, u32);
3245 u8 *seid = va_arg (*args, u8 *);
3246 u32 seid_len = va_arg (*args, u32);
3247 u32 is_src_dst = va_arg (*args, u32);
3250 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3252 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3258 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3260 vat_main_t *vam = &vat_main;
3261 u8 *s = 0, *eid = 0;
3263 if (~0 == mp->locator_set_index)
3264 s = format (0, "action: %d", mp->action);
3266 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3268 eid = format (0, "%U", format_lisp_eid_vat,
3272 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3275 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3276 clib_net_to_host_u32 (mp->vni),
3278 mp->is_local ? "local" : "remote",
3279 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3280 clib_net_to_host_u16 (mp->key_id), mp->key);
3287 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3290 vat_main_t *vam = &vat_main;
3291 vat_json_node_t *node = 0;
3294 if (VAT_JSON_ARRAY != vam->json_tree.type)
3296 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3297 vat_json_init_array (&vam->json_tree);
3299 node = vat_json_array_add (&vam->json_tree);
3301 vat_json_init_object (node);
3302 if (~0 == mp->locator_set_index)
3303 vat_json_object_add_uint (node, "action", mp->action);
3305 vat_json_object_add_uint (node, "locator_set_index",
3306 clib_net_to_host_u32 (mp->locator_set_index));
3308 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3309 if (mp->eid_type == 3)
3311 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3312 vat_json_init_object (nsh_json);
3313 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3314 vat_json_object_add_uint (nsh_json, "spi",
3315 clib_net_to_host_u32 (nsh->spi));
3316 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3320 eid = format (0, "%U", format_lisp_eid_vat,
3324 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3326 vat_json_object_add_string_copy (node, "eid", eid);
3329 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3330 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3331 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3335 vat_json_object_add_uint (node, "key_id",
3336 clib_net_to_host_u16 (mp->key_id));
3337 vat_json_object_add_string_copy (node, "key", mp->key);
3342 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3344 vat_main_t *vam = &vat_main;
3345 u8 *seid = 0, *deid = 0;
3346 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3348 deid = format (0, "%U", format_lisp_eid_vat,
3349 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3351 seid = format (0, "%U", format_lisp_eid_vat,
3352 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3358 format_ip_address_fcn = format_ip4_address;
3360 format_ip_address_fcn = format_ip6_address;
3363 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3364 clib_net_to_host_u32 (mp->vni),
3366 format_ip_address_fcn, mp->lloc,
3367 format_ip_address_fcn, mp->rloc,
3368 clib_net_to_host_u32 (mp->pkt_count),
3369 clib_net_to_host_u32 (mp->bytes));
3376 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3378 struct in6_addr ip6;
3380 vat_main_t *vam = &vat_main;
3381 vat_json_node_t *node = 0;
3382 u8 *deid = 0, *seid = 0;
3384 if (VAT_JSON_ARRAY != vam->json_tree.type)
3386 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3387 vat_json_init_array (&vam->json_tree);
3389 node = vat_json_array_add (&vam->json_tree);
3391 vat_json_init_object (node);
3392 deid = format (0, "%U", format_lisp_eid_vat,
3393 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3395 seid = format (0, "%U", format_lisp_eid_vat,
3396 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3401 vat_json_object_add_string_copy (node, "seid", seid);
3402 vat_json_object_add_string_copy (node, "deid", deid);
3403 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3407 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3408 vat_json_object_add_ip4 (node, "lloc", ip4);
3409 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3410 vat_json_object_add_ip4 (node, "rloc", ip4);
3414 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3415 vat_json_object_add_ip6 (node, "lloc", ip6);
3416 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3417 vat_json_object_add_ip6 (node, "rloc", ip6);
3419 vat_json_object_add_uint (node, "pkt_count",
3420 clib_net_to_host_u32 (mp->pkt_count));
3421 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3428 vl_api_one_eid_table_map_details_t_handler
3429 (vl_api_one_eid_table_map_details_t * mp)
3431 vat_main_t *vam = &vat_main;
3433 u8 *line = format (0, "%=10d%=10d",
3434 clib_net_to_host_u32 (mp->vni),
3435 clib_net_to_host_u32 (mp->dp_table));
3436 print (vam->ofp, "%v", line);
3441 vl_api_one_eid_table_map_details_t_handler_json
3442 (vl_api_one_eid_table_map_details_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 vat_json_node_t *node = NULL;
3447 if (VAT_JSON_ARRAY != vam->json_tree.type)
3449 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3450 vat_json_init_array (&vam->json_tree);
3452 node = vat_json_array_add (&vam->json_tree);
3453 vat_json_init_object (node);
3454 vat_json_object_add_uint (node, "dp_table",
3455 clib_net_to_host_u32 (mp->dp_table));
3456 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3460 vl_api_one_eid_table_vni_details_t_handler
3461 (vl_api_one_eid_table_vni_details_t * mp)
3463 vat_main_t *vam = &vat_main;
3465 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3466 print (vam->ofp, "%v", line);
3471 vl_api_one_eid_table_vni_details_t_handler_json
3472 (vl_api_one_eid_table_vni_details_t * mp)
3474 vat_main_t *vam = &vat_main;
3475 vat_json_node_t *node = NULL;
3477 if (VAT_JSON_ARRAY != vam->json_tree.type)
3479 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3480 vat_json_init_array (&vam->json_tree);
3482 node = vat_json_array_add (&vam->json_tree);
3483 vat_json_init_object (node);
3484 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3488 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3489 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3491 vat_main_t *vam = &vat_main;
3492 int retval = clib_net_to_host_u32 (mp->retval);
3494 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3495 print (vam->ofp, "fallback threshold value: %d", mp->value);
3497 vam->retval = retval;
3498 vam->result_ready = 1;
3502 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3503 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3505 vat_main_t *vam = &vat_main;
3506 vat_json_node_t _node, *node = &_node;
3507 int retval = clib_net_to_host_u32 (mp->retval);
3509 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3510 vat_json_init_object (node);
3511 vat_json_object_add_uint (node, "value", mp->value);
3513 vat_json_print (vam->ofp, node);
3514 vat_json_free (node);
3516 vam->retval = retval;
3517 vam->result_ready = 1;
3521 vl_api_show_one_map_register_state_reply_t_handler
3522 (vl_api_show_one_map_register_state_reply_t * mp)
3524 vat_main_t *vam = &vat_main;
3525 int retval = clib_net_to_host_u32 (mp->retval);
3527 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3529 vam->retval = retval;
3530 vam->result_ready = 1;
3534 vl_api_show_one_map_register_state_reply_t_handler_json
3535 (vl_api_show_one_map_register_state_reply_t * mp)
3537 vat_main_t *vam = &vat_main;
3538 vat_json_node_t _node, *node = &_node;
3539 int retval = clib_net_to_host_u32 (mp->retval);
3541 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3543 vat_json_init_object (node);
3544 vat_json_object_add_string_copy (node, "state", s);
3546 vat_json_print (vam->ofp, node);
3547 vat_json_free (node);
3549 vam->retval = retval;
3550 vam->result_ready = 1;
3555 vl_api_show_one_rloc_probe_state_reply_t_handler
3556 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3558 vat_main_t *vam = &vat_main;
3559 int retval = clib_net_to_host_u32 (mp->retval);
3564 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3566 vam->retval = retval;
3567 vam->result_ready = 1;
3571 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3572 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3574 vat_main_t *vam = &vat_main;
3575 vat_json_node_t _node, *node = &_node;
3576 int retval = clib_net_to_host_u32 (mp->retval);
3578 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3579 vat_json_init_object (node);
3580 vat_json_object_add_string_copy (node, "state", s);
3582 vat_json_print (vam->ofp, node);
3583 vat_json_free (node);
3585 vam->retval = retval;
3586 vam->result_ready = 1;
3591 vl_api_show_one_stats_enable_disable_reply_t_handler
3592 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 int retval = clib_net_to_host_u32 (mp->retval);
3600 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3602 vam->retval = retval;
3603 vam->result_ready = 1;
3607 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3608 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3610 vat_main_t *vam = &vat_main;
3611 vat_json_node_t _node, *node = &_node;
3612 int retval = clib_net_to_host_u32 (mp->retval);
3614 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3615 vat_json_init_object (node);
3616 vat_json_object_add_string_copy (node, "state", s);
3618 vat_json_print (vam->ofp, node);
3619 vat_json_free (node);
3621 vam->retval = retval;
3622 vam->result_ready = 1;
3627 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3629 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3630 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3631 e->vni = clib_net_to_host_u32 (e->vni);
3635 gpe_fwd_entries_get_reply_t_net_to_host
3636 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3640 mp->count = clib_net_to_host_u32 (mp->count);
3641 for (i = 0; i < mp->count; i++)
3643 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3648 format_gpe_encap_mode (u8 * s, va_list * args)
3650 u32 mode = va_arg (*args, u32);
3655 return format (s, "lisp");
3657 return format (s, "vxlan");
3663 vl_api_gpe_get_encap_mode_reply_t_handler
3664 (vl_api_gpe_get_encap_mode_reply_t * mp)
3666 vat_main_t *vam = &vat_main;
3668 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3669 vam->retval = ntohl (mp->retval);
3670 vam->result_ready = 1;
3674 vl_api_gpe_get_encap_mode_reply_t_handler_json
3675 (vl_api_gpe_get_encap_mode_reply_t * mp)
3677 vat_main_t *vam = &vat_main;
3678 vat_json_node_t node;
3680 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3681 vec_add1 (encap_mode, 0);
3683 vat_json_init_object (&node);
3684 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3686 vec_free (encap_mode);
3687 vat_json_print (vam->ofp, &node);
3688 vat_json_free (&node);
3690 vam->retval = ntohl (mp->retval);
3691 vam->result_ready = 1;
3695 vl_api_gpe_fwd_entry_path_details_t_handler
3696 (vl_api_gpe_fwd_entry_path_details_t * mp)
3698 vat_main_t *vam = &vat_main;
3699 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3701 if (mp->lcl_loc.is_ip4)
3702 format_ip_address_fcn = format_ip4_address;
3704 format_ip_address_fcn = format_ip6_address;
3706 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3707 format_ip_address_fcn, &mp->lcl_loc,
3708 format_ip_address_fcn, &mp->rmt_loc);
3712 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3714 struct in6_addr ip6;
3719 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3720 vat_json_object_add_ip4 (n, "address", ip4);
3724 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3725 vat_json_object_add_ip6 (n, "address", ip6);
3727 vat_json_object_add_uint (n, "weight", loc->weight);
3731 vl_api_gpe_fwd_entry_path_details_t_handler_json
3732 (vl_api_gpe_fwd_entry_path_details_t * mp)
3734 vat_main_t *vam = &vat_main;
3735 vat_json_node_t *node = NULL;
3736 vat_json_node_t *loc_node;
3738 if (VAT_JSON_ARRAY != vam->json_tree.type)
3740 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3741 vat_json_init_array (&vam->json_tree);
3743 node = vat_json_array_add (&vam->json_tree);
3744 vat_json_init_object (node);
3746 loc_node = vat_json_object_add (node, "local_locator");
3747 vat_json_init_object (loc_node);
3748 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3750 loc_node = vat_json_object_add (node, "remote_locator");
3751 vat_json_init_object (loc_node);
3752 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3756 vl_api_gpe_fwd_entries_get_reply_t_handler
3757 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3759 vat_main_t *vam = &vat_main;
3761 int retval = clib_net_to_host_u32 (mp->retval);
3762 vl_api_gpe_fwd_entry_t *e;
3767 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3769 for (i = 0; i < mp->count; i++)
3771 e = &mp->entries[i];
3772 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3773 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3774 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3778 vam->retval = retval;
3779 vam->result_ready = 1;
3783 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3784 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3787 vat_main_t *vam = &vat_main;
3788 vat_json_node_t *e = 0, root;
3790 int retval = clib_net_to_host_u32 (mp->retval);
3791 vl_api_gpe_fwd_entry_t *fwd;
3796 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3797 vat_json_init_array (&root);
3799 for (i = 0; i < mp->count; i++)
3801 e = vat_json_array_add (&root);
3802 fwd = &mp->entries[i];
3804 vat_json_init_object (e);
3805 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3806 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3807 vat_json_object_add_int (e, "vni", fwd->vni);
3808 vat_json_object_add_int (e, "action", fwd->action);
3810 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3811 fwd->leid_prefix_len);
3813 vat_json_object_add_string_copy (e, "leid", s);
3816 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3817 fwd->reid_prefix_len);
3819 vat_json_object_add_string_copy (e, "reid", s);
3823 vat_json_print (vam->ofp, &root);
3824 vat_json_free (&root);
3827 vam->retval = retval;
3828 vam->result_ready = 1;
3832 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3833 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3835 vat_main_t *vam = &vat_main;
3837 int retval = clib_net_to_host_u32 (mp->retval);
3838 vl_api_gpe_native_fwd_rpath_t *r;
3843 n = clib_net_to_host_u32 (mp->count);
3845 for (i = 0; i < n; i++)
3847 r = &mp->entries[i];
3848 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3849 clib_net_to_host_u32 (r->fib_index),
3850 clib_net_to_host_u32 (r->nh_sw_if_index),
3851 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3855 vam->retval = retval;
3856 vam->result_ready = 1;
3860 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3861 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3863 vat_main_t *vam = &vat_main;
3864 vat_json_node_t root, *e;
3866 int retval = clib_net_to_host_u32 (mp->retval);
3867 vl_api_gpe_native_fwd_rpath_t *r;
3873 n = clib_net_to_host_u32 (mp->count);
3874 vat_json_init_array (&root);
3876 for (i = 0; i < n; i++)
3878 e = vat_json_array_add (&root);
3879 vat_json_init_object (e);
3880 r = &mp->entries[i];
3882 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3885 vat_json_object_add_string_copy (e, "ip4", s);
3888 vat_json_object_add_uint (e, "fib_index",
3889 clib_net_to_host_u32 (r->fib_index));
3890 vat_json_object_add_uint (e, "nh_sw_if_index",
3891 clib_net_to_host_u32 (r->nh_sw_if_index));
3894 vat_json_print (vam->ofp, &root);
3895 vat_json_free (&root);
3898 vam->retval = retval;
3899 vam->result_ready = 1;
3903 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3904 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3906 vat_main_t *vam = &vat_main;
3908 int retval = clib_net_to_host_u32 (mp->retval);
3913 n = clib_net_to_host_u32 (mp->count);
3915 for (i = 0; i < n; i++)
3916 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3919 vam->retval = retval;
3920 vam->result_ready = 1;
3924 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3925 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3927 vat_main_t *vam = &vat_main;
3928 vat_json_node_t root;
3930 int retval = clib_net_to_host_u32 (mp->retval);
3935 n = clib_net_to_host_u32 (mp->count);
3936 vat_json_init_array (&root);
3938 for (i = 0; i < n; i++)
3939 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_ndp_entries_get_reply_t_handler
3951 (vl_api_one_ndp_entries_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3960 n = clib_net_to_host_u32 (mp->count);
3962 for (i = 0; i < n; i++)
3963 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3964 format_ethernet_address, mp->entries[i].mac);
3967 vam->retval = retval;
3968 vam->result_ready = 1;
3972 vl_api_one_ndp_entries_get_reply_t_handler_json
3973 (vl_api_one_ndp_entries_get_reply_t * mp)
3976 vat_main_t *vam = &vat_main;
3977 vat_json_node_t *e = 0, root;
3979 int retval = clib_net_to_host_u32 (mp->retval);
3980 vl_api_one_ndp_entry_t *arp_entry;
3985 n = clib_net_to_host_u32 (mp->count);
3986 vat_json_init_array (&root);
3988 for (i = 0; i < n; i++)
3990 e = vat_json_array_add (&root);
3991 arp_entry = &mp->entries[i];
3993 vat_json_init_object (e);
3994 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3997 vat_json_object_add_string_copy (e, "mac", s);
4000 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4002 vat_json_object_add_string_copy (e, "ip6", s);
4006 vat_json_print (vam->ofp, &root);
4007 vat_json_free (&root);
4010 vam->retval = retval;
4011 vam->result_ready = 1;
4015 vl_api_one_l2_arp_entries_get_reply_t_handler
4016 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4018 vat_main_t *vam = &vat_main;
4020 int retval = clib_net_to_host_u32 (mp->retval);
4025 n = clib_net_to_host_u32 (mp->count);
4027 for (i = 0; i < n; i++)
4028 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4029 format_ethernet_address, mp->entries[i].mac);
4032 vam->retval = retval;
4033 vam->result_ready = 1;
4037 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4038 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4041 vat_main_t *vam = &vat_main;
4042 vat_json_node_t *e = 0, root;
4044 int retval = clib_net_to_host_u32 (mp->retval);
4045 vl_api_one_l2_arp_entry_t *arp_entry;
4050 n = clib_net_to_host_u32 (mp->count);
4051 vat_json_init_array (&root);
4053 for (i = 0; i < n; i++)
4055 e = vat_json_array_add (&root);
4056 arp_entry = &mp->entries[i];
4058 vat_json_init_object (e);
4059 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4062 vat_json_object_add_string_copy (e, "mac", s);
4065 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4067 vat_json_object_add_string_copy (e, "ip4", s);
4071 vat_json_print (vam->ofp, &root);
4072 vat_json_free (&root);
4075 vam->retval = retval;
4076 vam->result_ready = 1;
4080 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4082 vat_main_t *vam = &vat_main;
4084 int retval = clib_net_to_host_u32 (mp->retval);
4089 n = clib_net_to_host_u32 (mp->count);
4091 for (i = 0; i < n; i++)
4093 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4097 vam->retval = retval;
4098 vam->result_ready = 1;
4102 vl_api_one_ndp_bd_get_reply_t_handler_json
4103 (vl_api_one_ndp_bd_get_reply_t * mp)
4105 vat_main_t *vam = &vat_main;
4106 vat_json_node_t root;
4108 int retval = clib_net_to_host_u32 (mp->retval);
4113 n = clib_net_to_host_u32 (mp->count);
4114 vat_json_init_array (&root);
4116 for (i = 0; i < n; i++)
4118 vat_json_array_add_uint (&root,
4119 clib_net_to_host_u32 (mp->bridge_domains[i]));
4122 vat_json_print (vam->ofp, &root);
4123 vat_json_free (&root);
4126 vam->retval = retval;
4127 vam->result_ready = 1;
4131 vl_api_one_l2_arp_bd_get_reply_t_handler
4132 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4134 vat_main_t *vam = &vat_main;
4136 int retval = clib_net_to_host_u32 (mp->retval);
4141 n = clib_net_to_host_u32 (mp->count);
4143 for (i = 0; i < n; i++)
4145 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4149 vam->retval = retval;
4150 vam->result_ready = 1;
4154 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4155 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4157 vat_main_t *vam = &vat_main;
4158 vat_json_node_t root;
4160 int retval = clib_net_to_host_u32 (mp->retval);
4165 n = clib_net_to_host_u32 (mp->count);
4166 vat_json_init_array (&root);
4168 for (i = 0; i < n; i++)
4170 vat_json_array_add_uint (&root,
4171 clib_net_to_host_u32 (mp->bridge_domains[i]));
4174 vat_json_print (vam->ofp, &root);
4175 vat_json_free (&root);
4178 vam->retval = retval;
4179 vam->result_ready = 1;
4183 vl_api_one_adjacencies_get_reply_t_handler
4184 (vl_api_one_adjacencies_get_reply_t * mp)
4186 vat_main_t *vam = &vat_main;
4188 int retval = clib_net_to_host_u32 (mp->retval);
4189 vl_api_one_adjacency_t *a;
4194 n = clib_net_to_host_u32 (mp->count);
4196 for (i = 0; i < n; i++)
4198 a = &mp->adjacencies[i];
4199 print (vam->ofp, "%U %40U",
4200 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4201 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4205 vam->retval = retval;
4206 vam->result_ready = 1;
4210 vl_api_one_adjacencies_get_reply_t_handler_json
4211 (vl_api_one_adjacencies_get_reply_t * mp)
4214 vat_main_t *vam = &vat_main;
4215 vat_json_node_t *e = 0, root;
4217 int retval = clib_net_to_host_u32 (mp->retval);
4218 vl_api_one_adjacency_t *a;
4223 n = clib_net_to_host_u32 (mp->count);
4224 vat_json_init_array (&root);
4226 for (i = 0; i < n; i++)
4228 e = vat_json_array_add (&root);
4229 a = &mp->adjacencies[i];
4231 vat_json_init_object (e);
4232 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4233 a->leid_prefix_len);
4235 vat_json_object_add_string_copy (e, "leid", s);
4238 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4239 a->reid_prefix_len);
4241 vat_json_object_add_string_copy (e, "reid", s);
4245 vat_json_print (vam->ofp, &root);
4246 vat_json_free (&root);
4249 vam->retval = retval;
4250 vam->result_ready = 1;
4254 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4256 vat_main_t *vam = &vat_main;
4258 print (vam->ofp, "%=20U",
4259 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4264 vl_api_one_map_server_details_t_handler_json
4265 (vl_api_one_map_server_details_t * mp)
4267 vat_main_t *vam = &vat_main;
4268 vat_json_node_t *node = NULL;
4269 struct in6_addr ip6;
4272 if (VAT_JSON_ARRAY != vam->json_tree.type)
4274 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4275 vat_json_init_array (&vam->json_tree);
4277 node = vat_json_array_add (&vam->json_tree);
4279 vat_json_init_object (node);
4282 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4283 vat_json_object_add_ip6 (node, "map-server", ip6);
4287 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4288 vat_json_object_add_ip4 (node, "map-server", ip4);
4293 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4296 vat_main_t *vam = &vat_main;
4298 print (vam->ofp, "%=20U",
4299 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4304 vl_api_one_map_resolver_details_t_handler_json
4305 (vl_api_one_map_resolver_details_t * mp)
4307 vat_main_t *vam = &vat_main;
4308 vat_json_node_t *node = NULL;
4309 struct in6_addr ip6;
4312 if (VAT_JSON_ARRAY != vam->json_tree.type)
4314 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4315 vat_json_init_array (&vam->json_tree);
4317 node = vat_json_array_add (&vam->json_tree);
4319 vat_json_init_object (node);
4322 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4323 vat_json_object_add_ip6 (node, "map resolver", ip6);
4327 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4328 vat_json_object_add_ip4 (node, "map resolver", ip4);
4333 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4335 vat_main_t *vam = &vat_main;
4336 i32 retval = ntohl (mp->retval);
4340 print (vam->ofp, "feature: %s\ngpe: %s",
4341 mp->feature_status ? "enabled" : "disabled",
4342 mp->gpe_status ? "enabled" : "disabled");
4345 vam->retval = retval;
4346 vam->result_ready = 1;
4350 vl_api_show_one_status_reply_t_handler_json
4351 (vl_api_show_one_status_reply_t * mp)
4353 vat_main_t *vam = &vat_main;
4354 vat_json_node_t node;
4355 u8 *gpe_status = NULL;
4356 u8 *feature_status = NULL;
4358 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4359 feature_status = format (0, "%s",
4360 mp->feature_status ? "enabled" : "disabled");
4361 vec_add1 (gpe_status, 0);
4362 vec_add1 (feature_status, 0);
4364 vat_json_init_object (&node);
4365 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4366 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4368 vec_free (gpe_status);
4369 vec_free (feature_status);
4371 vat_json_print (vam->ofp, &node);
4372 vat_json_free (&node);
4374 vam->retval = ntohl (mp->retval);
4375 vam->result_ready = 1;
4379 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4380 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4382 vat_main_t *vam = &vat_main;
4383 i32 retval = ntohl (mp->retval);
4387 print (vam->ofp, "%=20s", mp->locator_set_name);
4390 vam->retval = retval;
4391 vam->result_ready = 1;
4395 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4396 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4398 vat_main_t *vam = &vat_main;
4399 vat_json_node_t *node = NULL;
4401 if (VAT_JSON_ARRAY != vam->json_tree.type)
4403 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4404 vat_json_init_array (&vam->json_tree);
4406 node = vat_json_array_add (&vam->json_tree);
4408 vat_json_init_object (node);
4409 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4411 vat_json_print (vam->ofp, node);
4412 vat_json_free (node);
4414 vam->retval = ntohl (mp->retval);
4415 vam->result_ready = 1;
4419 format_lisp_map_request_mode (u8 * s, va_list * args)
4421 u32 mode = va_arg (*args, u32);
4426 return format (0, "dst-only");
4428 return format (0, "src-dst");
4434 vl_api_show_one_map_request_mode_reply_t_handler
4435 (vl_api_show_one_map_request_mode_reply_t * mp)
4437 vat_main_t *vam = &vat_main;
4438 i32 retval = ntohl (mp->retval);
4442 u32 mode = mp->mode;
4443 print (vam->ofp, "map_request_mode: %U",
4444 format_lisp_map_request_mode, mode);
4447 vam->retval = retval;
4448 vam->result_ready = 1;
4452 vl_api_show_one_map_request_mode_reply_t_handler_json
4453 (vl_api_show_one_map_request_mode_reply_t * mp)
4455 vat_main_t *vam = &vat_main;
4456 vat_json_node_t node;
4461 s = format (0, "%U", format_lisp_map_request_mode, mode);
4464 vat_json_init_object (&node);
4465 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4466 vat_json_print (vam->ofp, &node);
4467 vat_json_free (&node);
4470 vam->retval = ntohl (mp->retval);
4471 vam->result_ready = 1;
4475 vl_api_one_show_xtr_mode_reply_t_handler
4476 (vl_api_one_show_xtr_mode_reply_t * mp)
4478 vat_main_t *vam = &vat_main;
4479 i32 retval = ntohl (mp->retval);
4483 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4486 vam->retval = retval;
4487 vam->result_ready = 1;
4491 vl_api_one_show_xtr_mode_reply_t_handler_json
4492 (vl_api_one_show_xtr_mode_reply_t * mp)
4494 vat_main_t *vam = &vat_main;
4495 vat_json_node_t node;
4498 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4499 vec_add1 (status, 0);
4501 vat_json_init_object (&node);
4502 vat_json_object_add_string_copy (&node, "status", status);
4506 vat_json_print (vam->ofp, &node);
4507 vat_json_free (&node);
4509 vam->retval = ntohl (mp->retval);
4510 vam->result_ready = 1;
4514 vl_api_one_show_pitr_mode_reply_t_handler
4515 (vl_api_one_show_pitr_mode_reply_t * mp)
4517 vat_main_t *vam = &vat_main;
4518 i32 retval = ntohl (mp->retval);
4522 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4525 vam->retval = retval;
4526 vam->result_ready = 1;
4530 vl_api_one_show_pitr_mode_reply_t_handler_json
4531 (vl_api_one_show_pitr_mode_reply_t * mp)
4533 vat_main_t *vam = &vat_main;
4534 vat_json_node_t node;
4537 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4538 vec_add1 (status, 0);
4540 vat_json_init_object (&node);
4541 vat_json_object_add_string_copy (&node, "status", status);
4545 vat_json_print (vam->ofp, &node);
4546 vat_json_free (&node);
4548 vam->retval = ntohl (mp->retval);
4549 vam->result_ready = 1;
4553 vl_api_one_show_petr_mode_reply_t_handler
4554 (vl_api_one_show_petr_mode_reply_t * mp)
4556 vat_main_t *vam = &vat_main;
4557 i32 retval = ntohl (mp->retval);
4561 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4564 vam->retval = retval;
4565 vam->result_ready = 1;
4569 vl_api_one_show_petr_mode_reply_t_handler_json
4570 (vl_api_one_show_petr_mode_reply_t * mp)
4572 vat_main_t *vam = &vat_main;
4573 vat_json_node_t node;
4576 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4577 vec_add1 (status, 0);
4579 vat_json_init_object (&node);
4580 vat_json_object_add_string_copy (&node, "status", status);
4584 vat_json_print (vam->ofp, &node);
4585 vat_json_free (&node);
4587 vam->retval = ntohl (mp->retval);
4588 vam->result_ready = 1;
4592 vl_api_show_one_use_petr_reply_t_handler
4593 (vl_api_show_one_use_petr_reply_t * mp)
4595 vat_main_t *vam = &vat_main;
4596 i32 retval = ntohl (mp->retval);
4600 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4603 print (vam->ofp, "Proxy-ETR address; %U",
4604 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4609 vam->retval = retval;
4610 vam->result_ready = 1;
4614 vl_api_show_one_use_petr_reply_t_handler_json
4615 (vl_api_show_one_use_petr_reply_t * mp)
4617 vat_main_t *vam = &vat_main;
4618 vat_json_node_t node;
4621 struct in6_addr ip6;
4623 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4624 vec_add1 (status, 0);
4626 vat_json_init_object (&node);
4627 vat_json_object_add_string_copy (&node, "status", status);
4632 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4633 vat_json_object_add_ip6 (&node, "address", ip6);
4637 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4638 vat_json_object_add_ip4 (&node, "address", ip4);
4644 vat_json_print (vam->ofp, &node);
4645 vat_json_free (&node);
4647 vam->retval = ntohl (mp->retval);
4648 vam->result_ready = 1;
4652 vl_api_show_one_nsh_mapping_reply_t_handler
4653 (vl_api_show_one_nsh_mapping_reply_t * mp)
4655 vat_main_t *vam = &vat_main;
4656 i32 retval = ntohl (mp->retval);
4660 print (vam->ofp, "%-20s%-16s",
4661 mp->is_set ? "set" : "not-set",
4662 mp->is_set ? (char *) mp->locator_set_name : "");
4665 vam->retval = retval;
4666 vam->result_ready = 1;
4670 vl_api_show_one_nsh_mapping_reply_t_handler_json
4671 (vl_api_show_one_nsh_mapping_reply_t * mp)
4673 vat_main_t *vam = &vat_main;
4674 vat_json_node_t node;
4677 status = format (0, "%s", mp->is_set ? "yes" : "no");
4678 vec_add1 (status, 0);
4680 vat_json_init_object (&node);
4681 vat_json_object_add_string_copy (&node, "is_set", status);
4684 vat_json_object_add_string_copy (&node, "locator_set",
4685 mp->locator_set_name);
4690 vat_json_print (vam->ofp, &node);
4691 vat_json_free (&node);
4693 vam->retval = ntohl (mp->retval);
4694 vam->result_ready = 1;
4698 vl_api_show_one_map_register_ttl_reply_t_handler
4699 (vl_api_show_one_map_register_ttl_reply_t * mp)
4701 vat_main_t *vam = &vat_main;
4702 i32 retval = ntohl (mp->retval);
4704 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4708 print (vam->ofp, "ttl: %u", mp->ttl);
4711 vam->retval = retval;
4712 vam->result_ready = 1;
4716 vl_api_show_one_map_register_ttl_reply_t_handler_json
4717 (vl_api_show_one_map_register_ttl_reply_t * mp)
4719 vat_main_t *vam = &vat_main;
4720 vat_json_node_t node;
4722 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4723 vat_json_init_object (&node);
4724 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4726 vat_json_print (vam->ofp, &node);
4727 vat_json_free (&node);
4729 vam->retval = ntohl (mp->retval);
4730 vam->result_ready = 1;
4734 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4736 vat_main_t *vam = &vat_main;
4737 i32 retval = ntohl (mp->retval);
4741 print (vam->ofp, "%-20s%-16s",
4742 mp->status ? "enabled" : "disabled",
4743 mp->status ? (char *) mp->locator_set_name : "");
4746 vam->retval = retval;
4747 vam->result_ready = 1;
4751 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4753 vat_main_t *vam = &vat_main;
4754 vat_json_node_t node;
4757 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4758 vec_add1 (status, 0);
4760 vat_json_init_object (&node);
4761 vat_json_object_add_string_copy (&node, "status", status);
4764 vat_json_object_add_string_copy (&node, "locator_set",
4765 mp->locator_set_name);
4770 vat_json_print (vam->ofp, &node);
4771 vat_json_free (&node);
4773 vam->retval = ntohl (mp->retval);
4774 vam->result_ready = 1;
4778 format_policer_type (u8 * s, va_list * va)
4780 u32 i = va_arg (*va, u32);
4782 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4783 s = format (s, "1r2c");
4784 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4785 s = format (s, "1r3c");
4786 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4787 s = format (s, "2r3c-2698");
4788 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4789 s = format (s, "2r3c-4115");
4790 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4791 s = format (s, "2r3c-mef5cf1");
4793 s = format (s, "ILLEGAL");
4798 format_policer_rate_type (u8 * s, va_list * va)
4800 u32 i = va_arg (*va, u32);
4802 if (i == SSE2_QOS_RATE_KBPS)
4803 s = format (s, "kbps");
4804 else if (i == SSE2_QOS_RATE_PPS)
4805 s = format (s, "pps");
4807 s = format (s, "ILLEGAL");
4812 format_policer_round_type (u8 * s, va_list * va)
4814 u32 i = va_arg (*va, u32);
4816 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4817 s = format (s, "closest");
4818 else if (i == SSE2_QOS_ROUND_TO_UP)
4819 s = format (s, "up");
4820 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4821 s = format (s, "down");
4823 s = format (s, "ILLEGAL");
4828 format_policer_action_type (u8 * s, va_list * va)
4830 u32 i = va_arg (*va, u32);
4832 if (i == SSE2_QOS_ACTION_DROP)
4833 s = format (s, "drop");
4834 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4835 s = format (s, "transmit");
4836 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4837 s = format (s, "mark-and-transmit");
4839 s = format (s, "ILLEGAL");
4844 format_dscp (u8 * s, va_list * va)
4846 u32 i = va_arg (*va, u32);
4851 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4855 return format (s, "ILLEGAL");
4857 s = format (s, "%s", t);
4862 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4864 vat_main_t *vam = &vat_main;
4865 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4867 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4868 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4870 conform_dscp_str = format (0, "");
4872 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4873 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4875 exceed_dscp_str = format (0, "");
4877 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4878 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4880 violate_dscp_str = format (0, "");
4882 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4883 "rate type %U, round type %U, %s rate, %s color-aware, "
4884 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4885 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4886 "conform action %U%s, exceed action %U%s, violate action %U%s",
4888 format_policer_type, mp->type,
4891 clib_net_to_host_u64 (mp->cb),
4892 clib_net_to_host_u64 (mp->eb),
4893 format_policer_rate_type, mp->rate_type,
4894 format_policer_round_type, mp->round_type,
4895 mp->single_rate ? "single" : "dual",
4896 mp->color_aware ? "is" : "not",
4897 ntohl (mp->cir_tokens_per_period),
4898 ntohl (mp->pir_tokens_per_period),
4900 ntohl (mp->current_limit),
4901 ntohl (mp->current_bucket),
4902 ntohl (mp->extended_limit),
4903 ntohl (mp->extended_bucket),
4904 clib_net_to_host_u64 (mp->last_update_time),
4905 format_policer_action_type, mp->conform_action_type,
4907 format_policer_action_type, mp->exceed_action_type,
4909 format_policer_action_type, mp->violate_action_type,
4912 vec_free (conform_dscp_str);
4913 vec_free (exceed_dscp_str);
4914 vec_free (violate_dscp_str);
4917 static void vl_api_policer_details_t_handler_json
4918 (vl_api_policer_details_t * mp)
4920 vat_main_t *vam = &vat_main;
4921 vat_json_node_t *node;
4922 u8 *rate_type_str, *round_type_str, *type_str;
4923 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4925 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4927 format (0, "%U", format_policer_round_type, mp->round_type);
4928 type_str = format (0, "%U", format_policer_type, mp->type);
4929 conform_action_str = format (0, "%U", format_policer_action_type,
4930 mp->conform_action_type);
4931 exceed_action_str = format (0, "%U", format_policer_action_type,
4932 mp->exceed_action_type);
4933 violate_action_str = format (0, "%U", format_policer_action_type,
4934 mp->violate_action_type);
4936 if (VAT_JSON_ARRAY != vam->json_tree.type)
4938 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4939 vat_json_init_array (&vam->json_tree);
4941 node = vat_json_array_add (&vam->json_tree);
4943 vat_json_init_object (node);
4944 vat_json_object_add_string_copy (node, "name", mp->name);
4945 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4946 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4947 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4948 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4949 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4950 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4951 vat_json_object_add_string_copy (node, "type", type_str);
4952 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4953 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4954 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4955 vat_json_object_add_uint (node, "cir_tokens_per_period",
4956 ntohl (mp->cir_tokens_per_period));
4957 vat_json_object_add_uint (node, "eir_tokens_per_period",
4958 ntohl (mp->pir_tokens_per_period));
4959 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4960 vat_json_object_add_uint (node, "current_bucket",
4961 ntohl (mp->current_bucket));
4962 vat_json_object_add_uint (node, "extended_limit",
4963 ntohl (mp->extended_limit));
4964 vat_json_object_add_uint (node, "extended_bucket",
4965 ntohl (mp->extended_bucket));
4966 vat_json_object_add_uint (node, "last_update_time",
4967 ntohl (mp->last_update_time));
4968 vat_json_object_add_string_copy (node, "conform_action",
4969 conform_action_str);
4970 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4972 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4973 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4974 vec_free (dscp_str);
4976 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4977 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4979 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4980 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4981 vec_free (dscp_str);
4983 vat_json_object_add_string_copy (node, "violate_action",
4984 violate_action_str);
4985 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4987 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4988 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4989 vec_free (dscp_str);
4992 vec_free (rate_type_str);
4993 vec_free (round_type_str);
4994 vec_free (type_str);
4995 vec_free (conform_action_str);
4996 vec_free (exceed_action_str);
4997 vec_free (violate_action_str);
5001 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5004 vat_main_t *vam = &vat_main;
5005 int i, count = ntohl (mp->count);
5008 print (vam->ofp, "classify table ids (%d) : ", count);
5009 for (i = 0; i < count; i++)
5011 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5012 print (vam->ofp, (i < count - 1) ? "," : "");
5014 vam->retval = ntohl (mp->retval);
5015 vam->result_ready = 1;
5019 vl_api_classify_table_ids_reply_t_handler_json
5020 (vl_api_classify_table_ids_reply_t * mp)
5022 vat_main_t *vam = &vat_main;
5023 int i, count = ntohl (mp->count);
5027 vat_json_node_t node;
5029 vat_json_init_object (&node);
5030 for (i = 0; i < count; i++)
5032 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5034 vat_json_print (vam->ofp, &node);
5035 vat_json_free (&node);
5037 vam->retval = ntohl (mp->retval);
5038 vam->result_ready = 1;
5042 vl_api_classify_table_by_interface_reply_t_handler
5043 (vl_api_classify_table_by_interface_reply_t * mp)
5045 vat_main_t *vam = &vat_main;
5048 table_id = ntohl (mp->l2_table_id);
5050 print (vam->ofp, "l2 table id : %d", table_id);
5052 print (vam->ofp, "l2 table id : No input ACL tables configured");
5053 table_id = ntohl (mp->ip4_table_id);
5055 print (vam->ofp, "ip4 table id : %d", table_id);
5057 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5058 table_id = ntohl (mp->ip6_table_id);
5060 print (vam->ofp, "ip6 table id : %d", table_id);
5062 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5063 vam->retval = ntohl (mp->retval);
5064 vam->result_ready = 1;
5068 vl_api_classify_table_by_interface_reply_t_handler_json
5069 (vl_api_classify_table_by_interface_reply_t * mp)
5071 vat_main_t *vam = &vat_main;
5072 vat_json_node_t node;
5074 vat_json_init_object (&node);
5076 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5077 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5078 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5080 vat_json_print (vam->ofp, &node);
5081 vat_json_free (&node);
5083 vam->retval = ntohl (mp->retval);
5084 vam->result_ready = 1;
5087 static void vl_api_policer_add_del_reply_t_handler
5088 (vl_api_policer_add_del_reply_t * mp)
5090 vat_main_t *vam = &vat_main;
5091 i32 retval = ntohl (mp->retval);
5092 if (vam->async_mode)
5094 vam->async_errors += (retval < 0);
5098 vam->retval = retval;
5099 vam->result_ready = 1;
5100 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5102 * Note: this is just barely thread-safe, depends on
5103 * the main thread spinning waiting for an answer...
5105 errmsg ("policer index %d", ntohl (mp->policer_index));
5109 static void vl_api_policer_add_del_reply_t_handler_json
5110 (vl_api_policer_add_del_reply_t * mp)
5112 vat_main_t *vam = &vat_main;
5113 vat_json_node_t node;
5115 vat_json_init_object (&node);
5116 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5117 vat_json_object_add_uint (&node, "policer_index",
5118 ntohl (mp->policer_index));
5120 vat_json_print (vam->ofp, &node);
5121 vat_json_free (&node);
5123 vam->retval = ntohl (mp->retval);
5124 vam->result_ready = 1;
5127 /* Format hex dump. */
5129 format_hex_bytes (u8 * s, va_list * va)
5131 u8 *bytes = va_arg (*va, u8 *);
5132 int n_bytes = va_arg (*va, int);
5135 /* Print short or long form depending on byte count. */
5136 uword short_form = n_bytes <= 32;
5137 u32 indent = format_get_indent (s);
5142 for (i = 0; i < n_bytes; i++)
5144 if (!short_form && (i % 32) == 0)
5145 s = format (s, "%08x: ", i);
5146 s = format (s, "%02x", bytes[i]);
5147 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5148 s = format (s, "\n%U", format_white_space, indent);
5155 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5158 vat_main_t *vam = &vat_main;
5159 i32 retval = ntohl (mp->retval);
5162 print (vam->ofp, "classify table info :");
5163 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5164 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5165 ntohl (mp->miss_next_index));
5166 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5167 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5168 ntohl (mp->match_n_vectors));
5169 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5170 ntohl (mp->mask_length));
5172 vam->retval = retval;
5173 vam->result_ready = 1;
5177 vl_api_classify_table_info_reply_t_handler_json
5178 (vl_api_classify_table_info_reply_t * mp)
5180 vat_main_t *vam = &vat_main;
5181 vat_json_node_t node;
5183 i32 retval = ntohl (mp->retval);
5186 vat_json_init_object (&node);
5188 vat_json_object_add_int (&node, "sessions",
5189 ntohl (mp->active_sessions));
5190 vat_json_object_add_int (&node, "nexttbl",
5191 ntohl (mp->next_table_index));
5192 vat_json_object_add_int (&node, "nextnode",
5193 ntohl (mp->miss_next_index));
5194 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5195 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5196 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5197 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5198 ntohl (mp->mask_length), 0);
5199 vat_json_object_add_string_copy (&node, "mask", s);
5201 vat_json_print (vam->ofp, &node);
5202 vat_json_free (&node);
5204 vam->retval = ntohl (mp->retval);
5205 vam->result_ready = 1;
5209 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5212 vat_main_t *vam = &vat_main;
5214 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5215 ntohl (mp->hit_next_index), ntohl (mp->advance),
5216 ntohl (mp->opaque_index));
5217 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5218 ntohl (mp->match_length));
5222 vl_api_classify_session_details_t_handler_json
5223 (vl_api_classify_session_details_t * mp)
5225 vat_main_t *vam = &vat_main;
5226 vat_json_node_t *node = NULL;
5228 if (VAT_JSON_ARRAY != vam->json_tree.type)
5230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5231 vat_json_init_array (&vam->json_tree);
5233 node = vat_json_array_add (&vam->json_tree);
5235 vat_json_init_object (node);
5236 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5237 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5238 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5240 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5242 vat_json_object_add_string_copy (node, "match", s);
5245 static void vl_api_pg_create_interface_reply_t_handler
5246 (vl_api_pg_create_interface_reply_t * mp)
5248 vat_main_t *vam = &vat_main;
5250 vam->retval = ntohl (mp->retval);
5251 vam->result_ready = 1;
5254 static void vl_api_pg_create_interface_reply_t_handler_json
5255 (vl_api_pg_create_interface_reply_t * mp)
5257 vat_main_t *vam = &vat_main;
5258 vat_json_node_t node;
5260 i32 retval = ntohl (mp->retval);
5263 vat_json_init_object (&node);
5265 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5267 vat_json_print (vam->ofp, &node);
5268 vat_json_free (&node);
5270 vam->retval = ntohl (mp->retval);
5271 vam->result_ready = 1;
5274 static void vl_api_policer_classify_details_t_handler
5275 (vl_api_policer_classify_details_t * mp)
5277 vat_main_t *vam = &vat_main;
5279 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5280 ntohl (mp->table_index));
5283 static void vl_api_policer_classify_details_t_handler_json
5284 (vl_api_policer_classify_details_t * mp)
5286 vat_main_t *vam = &vat_main;
5287 vat_json_node_t *node;
5289 if (VAT_JSON_ARRAY != vam->json_tree.type)
5291 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5292 vat_json_init_array (&vam->json_tree);
5294 node = vat_json_array_add (&vam->json_tree);
5296 vat_json_init_object (node);
5297 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5298 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5301 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5302 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5304 vat_main_t *vam = &vat_main;
5305 i32 retval = ntohl (mp->retval);
5306 if (vam->async_mode)
5308 vam->async_errors += (retval < 0);
5312 vam->retval = retval;
5313 vam->sw_if_index = ntohl (mp->sw_if_index);
5314 vam->result_ready = 1;
5316 vam->regenerate_interface_table = 1;
5319 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5320 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5322 vat_main_t *vam = &vat_main;
5323 vat_json_node_t node;
5325 vat_json_init_object (&node);
5326 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5327 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5329 vat_json_print (vam->ofp, &node);
5330 vat_json_free (&node);
5332 vam->retval = ntohl (mp->retval);
5333 vam->result_ready = 1;
5336 static void vl_api_flow_classify_details_t_handler
5337 (vl_api_flow_classify_details_t * mp)
5339 vat_main_t *vam = &vat_main;
5341 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5342 ntohl (mp->table_index));
5345 static void vl_api_flow_classify_details_t_handler_json
5346 (vl_api_flow_classify_details_t * mp)
5348 vat_main_t *vam = &vat_main;
5349 vat_json_node_t *node;
5351 if (VAT_JSON_ARRAY != vam->json_tree.type)
5353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5354 vat_json_init_array (&vam->json_tree);
5356 node = vat_json_array_add (&vam->json_tree);
5358 vat_json_init_object (node);
5359 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5360 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5363 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5364 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5365 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5366 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5367 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5368 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5369 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5370 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5371 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5372 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5373 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5374 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5375 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5376 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5377 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5378 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5379 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5380 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5381 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5382 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5383 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5384 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5387 * Generate boilerplate reply handlers, which
5388 * dig the return value out of the xxx_reply_t API message,
5389 * stick it into vam->retval, and set vam->result_ready
5391 * Could also do this by pointing N message decode slots at
5392 * a single function, but that could break in subtle ways.
5395 #define foreach_standard_reply_retval_handler \
5396 _(sw_interface_set_flags_reply) \
5397 _(sw_interface_add_del_address_reply) \
5398 _(sw_interface_set_rx_mode_reply) \
5399 _(sw_interface_set_table_reply) \
5400 _(sw_interface_set_mpls_enable_reply) \
5401 _(sw_interface_set_vpath_reply) \
5402 _(sw_interface_set_vxlan_bypass_reply) \
5403 _(sw_interface_set_geneve_bypass_reply) \
5404 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5405 _(sw_interface_set_l2_bridge_reply) \
5406 _(bridge_domain_add_del_reply) \
5407 _(sw_interface_set_l2_xconnect_reply) \
5408 _(l2fib_add_del_reply) \
5409 _(l2fib_flush_int_reply) \
5410 _(l2fib_flush_bd_reply) \
5411 _(ip_add_del_route_reply) \
5412 _(ip_table_add_del_reply) \
5413 _(ip_mroute_add_del_reply) \
5414 _(mpls_route_add_del_reply) \
5415 _(mpls_table_add_del_reply) \
5416 _(mpls_ip_bind_unbind_reply) \
5417 _(bier_route_add_del_reply) \
5418 _(bier_table_add_del_reply) \
5419 _(proxy_arp_add_del_reply) \
5420 _(proxy_arp_intfc_enable_disable_reply) \
5421 _(sw_interface_set_unnumbered_reply) \
5422 _(ip_neighbor_add_del_reply) \
5423 _(oam_add_del_reply) \
5424 _(reset_fib_reply) \
5425 _(dhcp_proxy_config_reply) \
5426 _(dhcp_proxy_set_vss_reply) \
5427 _(dhcp_client_config_reply) \
5428 _(set_ip_flow_hash_reply) \
5429 _(sw_interface_ip6_enable_disable_reply) \
5430 _(sw_interface_ip6_set_link_local_address_reply) \
5431 _(ip6nd_proxy_add_del_reply) \
5432 _(sw_interface_ip6nd_ra_prefix_reply) \
5433 _(sw_interface_ip6nd_ra_config_reply) \
5434 _(set_arp_neighbor_limit_reply) \
5435 _(l2_patch_add_del_reply) \
5436 _(sr_policy_add_reply) \
5437 _(sr_policy_mod_reply) \
5438 _(sr_policy_del_reply) \
5439 _(sr_localsid_add_del_reply) \
5440 _(sr_steering_add_del_reply) \
5441 _(classify_add_del_session_reply) \
5442 _(classify_set_interface_ip_table_reply) \
5443 _(classify_set_interface_l2_tables_reply) \
5444 _(l2tpv3_set_tunnel_cookies_reply) \
5445 _(l2tpv3_interface_enable_disable_reply) \
5446 _(l2tpv3_set_lookup_key_reply) \
5447 _(l2_fib_clear_table_reply) \
5448 _(l2_interface_efp_filter_reply) \
5449 _(l2_interface_vlan_tag_rewrite_reply) \
5450 _(modify_vhost_user_if_reply) \
5451 _(delete_vhost_user_if_reply) \
5452 _(ip_probe_neighbor_reply) \
5453 _(want_ip4_arp_events_reply) \
5454 _(want_ip6_nd_events_reply) \
5455 _(want_l2_macs_events_reply) \
5456 _(input_acl_set_interface_reply) \
5457 _(ipsec_spd_add_del_reply) \
5458 _(ipsec_interface_add_del_spd_reply) \
5459 _(ipsec_spd_add_del_entry_reply) \
5460 _(ipsec_sad_add_del_entry_reply) \
5461 _(ipsec_sa_set_key_reply) \
5462 _(ipsec_tunnel_if_add_del_reply) \
5463 _(ipsec_tunnel_if_set_key_reply) \
5464 _(ipsec_tunnel_if_set_sa_reply) \
5465 _(ikev2_profile_add_del_reply) \
5466 _(ikev2_profile_set_auth_reply) \
5467 _(ikev2_profile_set_id_reply) \
5468 _(ikev2_profile_set_ts_reply) \
5469 _(ikev2_set_local_key_reply) \
5470 _(ikev2_set_responder_reply) \
5471 _(ikev2_set_ike_transforms_reply) \
5472 _(ikev2_set_esp_transforms_reply) \
5473 _(ikev2_set_sa_lifetime_reply) \
5474 _(ikev2_initiate_sa_init_reply) \
5475 _(ikev2_initiate_del_ike_sa_reply) \
5476 _(ikev2_initiate_del_child_sa_reply) \
5477 _(ikev2_initiate_rekey_child_sa_reply) \
5478 _(delete_loopback_reply) \
5479 _(bd_ip_mac_add_del_reply) \
5480 _(map_del_domain_reply) \
5481 _(map_add_del_rule_reply) \
5482 _(want_interface_events_reply) \
5483 _(want_stats_reply) \
5484 _(cop_interface_enable_disable_reply) \
5485 _(cop_whitelist_enable_disable_reply) \
5486 _(sw_interface_clear_stats_reply) \
5487 _(ioam_enable_reply) \
5488 _(ioam_disable_reply) \
5489 _(one_add_del_locator_reply) \
5490 _(one_add_del_local_eid_reply) \
5491 _(one_add_del_remote_mapping_reply) \
5492 _(one_add_del_adjacency_reply) \
5493 _(one_add_del_map_resolver_reply) \
5494 _(one_add_del_map_server_reply) \
5495 _(one_enable_disable_reply) \
5496 _(one_rloc_probe_enable_disable_reply) \
5497 _(one_map_register_enable_disable_reply) \
5498 _(one_map_register_set_ttl_reply) \
5499 _(one_set_transport_protocol_reply) \
5500 _(one_map_register_fallback_threshold_reply) \
5501 _(one_pitr_set_locator_set_reply) \
5502 _(one_map_request_mode_reply) \
5503 _(one_add_del_map_request_itr_rlocs_reply) \
5504 _(one_eid_table_add_del_map_reply) \
5505 _(one_use_petr_reply) \
5506 _(one_stats_enable_disable_reply) \
5507 _(one_add_del_l2_arp_entry_reply) \
5508 _(one_add_del_ndp_entry_reply) \
5509 _(one_stats_flush_reply) \
5510 _(one_enable_disable_xtr_mode_reply) \
5511 _(one_enable_disable_pitr_mode_reply) \
5512 _(one_enable_disable_petr_mode_reply) \
5513 _(gpe_enable_disable_reply) \
5514 _(gpe_set_encap_mode_reply) \
5515 _(gpe_add_del_iface_reply) \
5516 _(gpe_add_del_native_fwd_rpath_reply) \
5517 _(af_packet_delete_reply) \
5518 _(policer_classify_set_interface_reply) \
5519 _(netmap_create_reply) \
5520 _(netmap_delete_reply) \
5521 _(set_ipfix_exporter_reply) \
5522 _(set_ipfix_classify_stream_reply) \
5523 _(ipfix_classify_table_add_del_reply) \
5524 _(flow_classify_set_interface_reply) \
5525 _(sw_interface_span_enable_disable_reply) \
5526 _(pg_capture_reply) \
5527 _(pg_enable_disable_reply) \
5528 _(ip_source_and_port_range_check_add_del_reply) \
5529 _(ip_source_and_port_range_check_interface_add_del_reply)\
5530 _(delete_subif_reply) \
5531 _(l2_interface_pbb_tag_rewrite_reply) \
5533 _(feature_enable_disable_reply) \
5534 _(sw_interface_tag_add_del_reply) \
5535 _(sw_interface_set_mtu_reply) \
5536 _(p2p_ethernet_add_reply) \
5537 _(p2p_ethernet_del_reply) \
5538 _(lldp_config_reply) \
5539 _(sw_interface_set_lldp_reply) \
5540 _(tcp_configure_src_addresses_reply) \
5541 _(dns_enable_disable_reply) \
5542 _(dns_name_server_add_del_reply) \
5543 _(session_rule_add_del_reply) \
5544 _(ip_container_proxy_add_del_reply) \
5545 _(output_acl_set_interface_reply) \
5546 _(qos_record_enable_disable_reply)
5549 static void vl_api_##n##_t_handler \
5550 (vl_api_##n##_t * mp) \
5552 vat_main_t * vam = &vat_main; \
5553 i32 retval = ntohl(mp->retval); \
5554 if (vam->async_mode) { \
5555 vam->async_errors += (retval < 0); \
5557 vam->retval = retval; \
5558 vam->result_ready = 1; \
5561 foreach_standard_reply_retval_handler;
5565 static void vl_api_##n##_t_handler_json \
5566 (vl_api_##n##_t * mp) \
5568 vat_main_t * vam = &vat_main; \
5569 vat_json_node_t node; \
5570 vat_json_init_object(&node); \
5571 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5572 vat_json_print(vam->ofp, &node); \
5573 vam->retval = ntohl(mp->retval); \
5574 vam->result_ready = 1; \
5576 foreach_standard_reply_retval_handler;
5580 * Table of message reply handlers, must include boilerplate handlers
5584 #define foreach_vpe_api_reply_msg \
5585 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5586 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5587 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5588 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5589 _(CONTROL_PING_REPLY, control_ping_reply) \
5590 _(CLI_REPLY, cli_reply) \
5591 _(CLI_INBAND_REPLY, cli_inband_reply) \
5592 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5593 sw_interface_add_del_address_reply) \
5594 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5595 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5596 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5597 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5598 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5599 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5600 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5601 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5602 sw_interface_set_l2_xconnect_reply) \
5603 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5604 sw_interface_set_l2_bridge_reply) \
5605 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5606 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5607 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5608 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5609 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5610 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5611 _(L2_FLAGS_REPLY, l2_flags_reply) \
5612 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5613 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5614 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5615 _(TAP_DELETE_REPLY, tap_delete_reply) \
5616 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5617 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5618 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5619 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5620 _(BOND_CREATE_REPLY, bond_create_reply) \
5621 _(BOND_DELETE_REPLY, bond_delete_reply) \
5622 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5623 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5624 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5625 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5626 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5627 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5628 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5629 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5630 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5631 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5632 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5633 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5634 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5635 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5636 proxy_arp_intfc_enable_disable_reply) \
5637 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5638 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5639 sw_interface_set_unnumbered_reply) \
5640 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5641 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5642 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5643 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5644 _(RESET_FIB_REPLY, reset_fib_reply) \
5645 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5646 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5647 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5648 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5649 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5650 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5651 sw_interface_ip6_enable_disable_reply) \
5652 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5653 sw_interface_ip6_set_link_local_address_reply) \
5654 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5655 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5656 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5657 sw_interface_ip6nd_ra_prefix_reply) \
5658 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5659 sw_interface_ip6nd_ra_config_reply) \
5660 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5661 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5662 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5663 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5664 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5665 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5666 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5667 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5668 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5669 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5670 classify_set_interface_ip_table_reply) \
5671 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5672 classify_set_interface_l2_tables_reply) \
5673 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5674 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5675 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5676 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5677 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5678 l2tpv3_interface_enable_disable_reply) \
5679 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5680 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5681 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5682 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5683 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5684 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5685 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5686 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5687 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5688 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5689 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5690 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5691 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5692 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5693 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5694 _(SHOW_VERSION_REPLY, show_version_reply) \
5695 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5696 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5697 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5698 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5699 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5700 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5701 _(IP4_ARP_EVENT, ip4_arp_event) \
5702 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5703 _(IP6_ND_EVENT, ip6_nd_event) \
5704 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5705 _(L2_MACS_EVENT, l2_macs_event) \
5706 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5707 _(IP_ADDRESS_DETAILS, ip_address_details) \
5708 _(IP_DETAILS, ip_details) \
5709 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5710 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5711 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5712 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5713 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5714 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5715 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5716 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5717 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5718 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5719 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5720 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5721 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5722 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5723 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5724 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5725 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5726 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5727 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5728 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5729 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5730 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5731 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5732 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5733 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5734 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5735 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5736 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5737 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5738 _(MAP_RULE_DETAILS, map_rule_details) \
5739 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5740 _(WANT_STATS_REPLY, want_stats_reply) \
5741 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5742 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5743 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5744 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5745 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5746 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5747 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5748 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5749 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5750 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5751 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5752 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5753 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5754 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5755 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5756 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5757 one_map_register_enable_disable_reply) \
5758 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5759 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5760 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5761 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5762 one_map_register_fallback_threshold_reply) \
5763 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5764 one_rloc_probe_enable_disable_reply) \
5765 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5766 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5767 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5768 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5769 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5770 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5771 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5772 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5773 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5774 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5775 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5776 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5777 _(ONE_STATS_DETAILS, one_stats_details) \
5778 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5779 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5780 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5781 show_one_stats_enable_disable_reply) \
5782 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5783 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5784 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5785 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5786 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5787 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5788 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5789 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5790 one_enable_disable_pitr_mode_reply) \
5791 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5792 one_enable_disable_petr_mode_reply) \
5793 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5794 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5795 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5796 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5797 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5798 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5799 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5800 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5801 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5802 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5803 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5804 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5805 gpe_add_del_native_fwd_rpath_reply) \
5806 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5807 gpe_fwd_entry_path_details) \
5808 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5809 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5810 one_add_del_map_request_itr_rlocs_reply) \
5811 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5812 one_get_map_request_itr_rlocs_reply) \
5813 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5814 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5815 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5816 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5817 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5818 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5819 show_one_map_register_state_reply) \
5820 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5821 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5822 show_one_map_register_fallback_threshold_reply) \
5823 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5824 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5825 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5826 _(POLICER_DETAILS, policer_details) \
5827 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5828 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5829 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5830 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5831 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5832 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5833 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5834 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5835 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5836 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5837 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5838 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5839 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5840 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5841 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5842 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5843 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5844 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5845 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5846 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5847 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5848 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5849 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5850 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5851 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5852 ip_source_and_port_range_check_add_del_reply) \
5853 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5854 ip_source_and_port_range_check_interface_add_del_reply) \
5855 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5856 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5857 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5858 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5859 _(PUNT_REPLY, punt_reply) \
5860 _(IP_FIB_DETAILS, ip_fib_details) \
5861 _(IP6_FIB_DETAILS, ip6_fib_details) \
5862 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5863 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5864 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5865 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5866 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5867 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5868 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5869 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5870 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5871 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5872 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5873 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5874 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5875 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5876 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5877 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5878 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5879 _(SESSION_RULES_DETAILS, session_rules_details) \
5880 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5881 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5882 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5884 #define foreach_standalone_reply_msg \
5885 _(SW_INTERFACE_EVENT, sw_interface_event) \
5886 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5887 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5888 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5889 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5890 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5891 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5899 #define STR_VTR_OP_CASE(op) \
5900 case L2_VTR_ ## op: \
5904 str_vtr_op (u32 vtr_op)
5908 STR_VTR_OP_CASE (DISABLED);
5909 STR_VTR_OP_CASE (PUSH_1);
5910 STR_VTR_OP_CASE (PUSH_2);
5911 STR_VTR_OP_CASE (POP_1);
5912 STR_VTR_OP_CASE (POP_2);
5913 STR_VTR_OP_CASE (TRANSLATE_1_1);
5914 STR_VTR_OP_CASE (TRANSLATE_1_2);
5915 STR_VTR_OP_CASE (TRANSLATE_2_1);
5916 STR_VTR_OP_CASE (TRANSLATE_2_2);
5923 dump_sub_interface_table (vat_main_t * vam)
5925 const sw_interface_subif_t *sub = NULL;
5927 if (vam->json_output)
5930 ("JSON output supported only for VPE API calls and dump_stats_table");
5935 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5936 "Interface", "sw_if_index",
5937 "sub id", "dot1ad", "tags", "outer id",
5938 "inner id", "exact", "default", "outer any", "inner any");
5940 vec_foreach (sub, vam->sw_if_subif_table)
5943 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5944 sub->interface_name,
5946 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5947 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5948 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5949 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5950 if (sub->vtr_op != L2_VTR_DISABLED)
5953 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5954 "tag1: %d tag2: %d ]",
5955 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5956 sub->vtr_tag1, sub->vtr_tag2);
5964 name_sort_cmp (void *a1, void *a2)
5966 name_sort_t *n1 = a1;
5967 name_sort_t *n2 = a2;
5969 return strcmp ((char *) n1->name, (char *) n2->name);
5973 dump_interface_table (vat_main_t * vam)
5976 name_sort_t *nses = 0, *ns;
5978 if (vam->json_output)
5981 ("JSON output supported only for VPE API calls and dump_stats_table");
5986 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5988 vec_add2 (nses, ns, 1);
5989 ns->name = (u8 *)(p->key);
5990 ns->value = (u32) p->value[0];
5994 vec_sort_with_function (nses, name_sort_cmp);
5996 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5997 vec_foreach (ns, nses)
5999 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6006 dump_ip_table (vat_main_t * vam, int is_ipv6)
6008 const ip_details_t *det = NULL;
6009 const ip_address_details_t *address = NULL;
6012 print (vam->ofp, "%-12s", "sw_if_index");
6014 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6021 print (vam->ofp, "%-12d", i);
6022 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6027 vec_foreach (address, det->addr)
6031 is_ipv6 ? format_ip6_address : format_ip4_address,
6032 address->ip, address->prefix_length);
6040 dump_ipv4_table (vat_main_t * vam)
6042 if (vam->json_output)
6045 ("JSON output supported only for VPE API calls and dump_stats_table");
6049 return dump_ip_table (vam, 0);
6053 dump_ipv6_table (vat_main_t * vam)
6055 if (vam->json_output)
6058 ("JSON output supported only for VPE API calls and dump_stats_table");
6062 return dump_ip_table (vam, 1);
6066 counter_type_to_str (u8 counter_type, u8 is_combined)
6070 switch (counter_type)
6072 case VNET_INTERFACE_COUNTER_DROP:
6074 case VNET_INTERFACE_COUNTER_PUNT:
6076 case VNET_INTERFACE_COUNTER_IP4:
6078 case VNET_INTERFACE_COUNTER_IP6:
6080 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6082 case VNET_INTERFACE_COUNTER_RX_MISS:
6084 case VNET_INTERFACE_COUNTER_RX_ERROR:
6086 case VNET_INTERFACE_COUNTER_TX_ERROR:
6089 return "INVALID-COUNTER-TYPE";
6094 switch (counter_type)
6096 case VNET_INTERFACE_COUNTER_RX:
6098 case VNET_INTERFACE_COUNTER_TX:
6101 return "INVALID-COUNTER-TYPE";
6107 dump_stats_table (vat_main_t * vam)
6109 vat_json_node_t node;
6110 vat_json_node_t *msg_array;
6111 vat_json_node_t *msg;
6112 vat_json_node_t *counter_array;
6113 vat_json_node_t *counter;
6114 interface_counter_t c;
6116 ip4_fib_counter_t *c4;
6117 ip6_fib_counter_t *c6;
6118 ip4_nbr_counter_t *n4;
6119 ip6_nbr_counter_t *n6;
6122 if (!vam->json_output)
6124 clib_warning ("dump_stats_table supported only in JSON format");
6128 vat_json_init_object (&node);
6130 /* interface counters */
6131 msg_array = vat_json_object_add (&node, "interface_counters");
6132 vat_json_init_array (msg_array);
6133 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6135 msg = vat_json_array_add (msg_array);
6136 vat_json_init_object (msg);
6137 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6138 (u8 *) counter_type_to_str (i, 0));
6139 vat_json_object_add_int (msg, "is_combined", 0);
6140 counter_array = vat_json_object_add (msg, "data");
6141 vat_json_init_array (counter_array);
6142 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6144 packets = vam->simple_interface_counters[i][j];
6145 vat_json_array_add_uint (counter_array, packets);
6148 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6150 msg = vat_json_array_add (msg_array);
6151 vat_json_init_object (msg);
6152 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6153 (u8 *) counter_type_to_str (i, 1));
6154 vat_json_object_add_int (msg, "is_combined", 1);
6155 counter_array = vat_json_object_add (msg, "data");
6156 vat_json_init_array (counter_array);
6157 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6159 c = vam->combined_interface_counters[i][j];
6160 counter = vat_json_array_add (counter_array);
6161 vat_json_init_object (counter);
6162 vat_json_object_add_uint (counter, "packets", c.packets);
6163 vat_json_object_add_uint (counter, "bytes", c.bytes);
6167 /* ip4 fib counters */
6168 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6169 vat_json_init_array (msg_array);
6170 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6172 msg = vat_json_array_add (msg_array);
6173 vat_json_init_object (msg);
6174 vat_json_object_add_uint (msg, "vrf_id",
6175 vam->ip4_fib_counters_vrf_id_by_index[i]);
6176 counter_array = vat_json_object_add (msg, "c");
6177 vat_json_init_array (counter_array);
6178 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6180 counter = vat_json_array_add (counter_array);
6181 vat_json_init_object (counter);
6182 c4 = &vam->ip4_fib_counters[i][j];
6183 vat_json_object_add_ip4 (counter, "address", c4->address);
6184 vat_json_object_add_uint (counter, "address_length",
6185 c4->address_length);
6186 vat_json_object_add_uint (counter, "packets", c4->packets);
6187 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6191 /* ip6 fib counters */
6192 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6193 vat_json_init_array (msg_array);
6194 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6196 msg = vat_json_array_add (msg_array);
6197 vat_json_init_object (msg);
6198 vat_json_object_add_uint (msg, "vrf_id",
6199 vam->ip6_fib_counters_vrf_id_by_index[i]);
6200 counter_array = vat_json_object_add (msg, "c");
6201 vat_json_init_array (counter_array);
6202 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6204 counter = vat_json_array_add (counter_array);
6205 vat_json_init_object (counter);
6206 c6 = &vam->ip6_fib_counters[i][j];
6207 vat_json_object_add_ip6 (counter, "address", c6->address);
6208 vat_json_object_add_uint (counter, "address_length",
6209 c6->address_length);
6210 vat_json_object_add_uint (counter, "packets", c6->packets);
6211 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6215 /* ip4 nbr counters */
6216 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6217 vat_json_init_array (msg_array);
6218 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6220 msg = vat_json_array_add (msg_array);
6221 vat_json_init_object (msg);
6222 vat_json_object_add_uint (msg, "sw_if_index", i);
6223 counter_array = vat_json_object_add (msg, "c");
6224 vat_json_init_array (counter_array);
6225 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6227 counter = vat_json_array_add (counter_array);
6228 vat_json_init_object (counter);
6229 n4 = &vam->ip4_nbr_counters[i][j];
6230 vat_json_object_add_ip4 (counter, "address", n4->address);
6231 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6232 vat_json_object_add_uint (counter, "packets", n4->packets);
6233 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6237 /* ip6 nbr counters */
6238 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6239 vat_json_init_array (msg_array);
6240 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6242 msg = vat_json_array_add (msg_array);
6243 vat_json_init_object (msg);
6244 vat_json_object_add_uint (msg, "sw_if_index", i);
6245 counter_array = vat_json_object_add (msg, "c");
6246 vat_json_init_array (counter_array);
6247 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6249 counter = vat_json_array_add (counter_array);
6250 vat_json_init_object (counter);
6251 n6 = &vam->ip6_nbr_counters[i][j];
6252 vat_json_object_add_ip6 (counter, "address", n6->address);
6253 vat_json_object_add_uint (counter, "packets", n6->packets);
6254 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6258 vat_json_print (vam->ofp, &node);
6259 vat_json_free (&node);
6265 * Pass CLI buffers directly in the CLI_INBAND API message,
6266 * instead of an additional shared memory area.
6269 exec_inband (vat_main_t * vam)
6271 vl_api_cli_inband_t *mp;
6272 unformat_input_t *i = vam->input;
6275 if (vec_len (i->buffer) == 0)
6278 if (vam->exec_mode == 0 && unformat (i, "mode"))
6283 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6290 * In order for the CLI command to work, it
6291 * must be a vector ending in \n, not a C-string ending
6294 u32 len = vec_len (vam->input->buffer);
6295 M2 (CLI_INBAND, mp, len);
6296 clib_memcpy (mp->cmd, vam->input->buffer, len);
6297 mp->length = htonl (len);
6301 /* json responses may or may not include a useful reply... */
6302 if (vec_len (vam->cmd_reply))
6303 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6308 exec (vat_main_t * vam)
6310 return exec_inband (vam);
6314 api_create_loopback (vat_main_t * vam)
6316 unformat_input_t *i = vam->input;
6317 vl_api_create_loopback_t *mp;
6318 vl_api_create_loopback_instance_t *mp_lbi;
6321 u8 is_specified = 0;
6322 u32 user_instance = 0;
6325 memset (mac_address, 0, sizeof (mac_address));
6327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6329 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6331 if (unformat (i, "instance %d", &user_instance))
6339 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6340 mp_lbi->is_specified = is_specified;
6342 mp_lbi->user_instance = htonl (user_instance);
6344 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6349 /* Construct the API message */
6350 M (CREATE_LOOPBACK, mp);
6352 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6361 api_delete_loopback (vat_main_t * vam)
6363 unformat_input_t *i = vam->input;
6364 vl_api_delete_loopback_t *mp;
6365 u32 sw_if_index = ~0;
6368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6370 if (unformat (i, "sw_if_index %d", &sw_if_index))
6376 if (sw_if_index == ~0)
6378 errmsg ("missing sw_if_index");
6382 /* Construct the API message */
6383 M (DELETE_LOOPBACK, mp);
6384 mp->sw_if_index = ntohl (sw_if_index);
6392 api_want_stats (vat_main_t * vam)
6394 unformat_input_t *i = vam->input;
6395 vl_api_want_stats_t *mp;
6399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6401 if (unformat (i, "enable"))
6403 else if (unformat (i, "disable"))
6411 errmsg ("missing enable|disable");
6416 mp->enable_disable = enable;
6424 api_want_interface_events (vat_main_t * vam)
6426 unformat_input_t *i = vam->input;
6427 vl_api_want_interface_events_t *mp;
6431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6433 if (unformat (i, "enable"))
6435 else if (unformat (i, "disable"))
6443 errmsg ("missing enable|disable");
6447 M (WANT_INTERFACE_EVENTS, mp);
6448 mp->enable_disable = enable;
6450 vam->interface_event_display = enable;
6458 /* Note: non-static, called once to set up the initial intfc table */
6460 api_sw_interface_dump (vat_main_t * vam)
6462 vl_api_sw_interface_dump_t *mp;
6463 vl_api_control_ping_t *mp_ping;
6465 name_sort_t *nses = 0, *ns;
6466 sw_interface_subif_t *sub = NULL;
6469 /* Toss the old name table */
6471 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6473 vec_add2 (nses, ns, 1);
6474 ns->name = (u8 *)(p->key);
6475 ns->value = (u32) p->value[0];
6479 hash_free (vam->sw_if_index_by_interface_name);
6481 vec_foreach (ns, nses) vec_free (ns->name);
6485 vec_foreach (sub, vam->sw_if_subif_table)
6487 vec_free (sub->interface_name);
6489 vec_free (vam->sw_if_subif_table);
6491 /* recreate the interface name hash table */
6492 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6495 * Ask for all interface names. Otherwise, the epic catalog of
6496 * name filters becomes ridiculously long, and vat ends up needing
6497 * to be taught about new interface types.
6499 M (SW_INTERFACE_DUMP, mp);
6502 /* Use a control ping for synchronization */
6503 MPING (CONTROL_PING, mp_ping);
6511 api_sw_interface_set_flags (vat_main_t * vam)
6513 unformat_input_t *i = vam->input;
6514 vl_api_sw_interface_set_flags_t *mp;
6516 u8 sw_if_index_set = 0;
6520 /* Parse args required to build the message */
6521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6523 if (unformat (i, "admin-up"))
6525 else if (unformat (i, "admin-down"))
6528 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6529 sw_if_index_set = 1;
6530 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6531 sw_if_index_set = 1;
6536 if (sw_if_index_set == 0)
6538 errmsg ("missing interface name or sw_if_index");
6542 /* Construct the API message */
6543 M (SW_INTERFACE_SET_FLAGS, mp);
6544 mp->sw_if_index = ntohl (sw_if_index);
6545 mp->admin_up_down = admin_up;
6550 /* Wait for a reply, return the good/bad news... */
6556 api_sw_interface_set_rx_mode (vat_main_t * vam)
6558 unformat_input_t *i = vam->input;
6559 vl_api_sw_interface_set_rx_mode_t *mp;
6561 u8 sw_if_index_set = 0;
6563 u8 queue_id_valid = 0;
6565 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6567 /* Parse args required to build the message */
6568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6570 if (unformat (i, "queue %d", &queue_id))
6572 else if (unformat (i, "polling"))
6573 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6574 else if (unformat (i, "interrupt"))
6575 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6576 else if (unformat (i, "adaptive"))
6577 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6580 sw_if_index_set = 1;
6581 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6582 sw_if_index_set = 1;
6587 if (sw_if_index_set == 0)
6589 errmsg ("missing interface name or sw_if_index");
6592 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6594 errmsg ("missing rx-mode");
6598 /* Construct the API message */
6599 M (SW_INTERFACE_SET_RX_MODE, mp);
6600 mp->sw_if_index = ntohl (sw_if_index);
6602 mp->queue_id_valid = queue_id_valid;
6603 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6608 /* Wait for a reply, return the good/bad news... */
6614 api_sw_interface_clear_stats (vat_main_t * vam)
6616 unformat_input_t *i = vam->input;
6617 vl_api_sw_interface_clear_stats_t *mp;
6619 u8 sw_if_index_set = 0;
6622 /* Parse args required to build the message */
6623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6625 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6626 sw_if_index_set = 1;
6627 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6628 sw_if_index_set = 1;
6633 /* Construct the API message */
6634 M (SW_INTERFACE_CLEAR_STATS, mp);
6636 if (sw_if_index_set == 1)
6637 mp->sw_if_index = ntohl (sw_if_index);
6639 mp->sw_if_index = ~0;
6644 /* Wait for a reply, return the good/bad news... */
6650 api_sw_interface_add_del_address (vat_main_t * vam)
6652 unformat_input_t *i = vam->input;
6653 vl_api_sw_interface_add_del_address_t *mp;
6655 u8 sw_if_index_set = 0;
6656 u8 is_add = 1, del_all = 0;
6657 u32 address_length = 0;
6658 u8 v4_address_set = 0;
6659 u8 v6_address_set = 0;
6660 ip4_address_t v4address;
6661 ip6_address_t v6address;
6664 /* Parse args required to build the message */
6665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6667 if (unformat (i, "del-all"))
6669 else if (unformat (i, "del"))
6672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6673 sw_if_index_set = 1;
6674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6675 sw_if_index_set = 1;
6676 else if (unformat (i, "%U/%d",
6677 unformat_ip4_address, &v4address, &address_length))
6679 else if (unformat (i, "%U/%d",
6680 unformat_ip6_address, &v6address, &address_length))
6686 if (sw_if_index_set == 0)
6688 errmsg ("missing interface name or sw_if_index");
6691 if (v4_address_set && v6_address_set)
6693 errmsg ("both v4 and v6 addresses set");
6696 if (!v4_address_set && !v6_address_set && !del_all)
6698 errmsg ("no addresses set");
6702 /* Construct the API message */
6703 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6705 mp->sw_if_index = ntohl (sw_if_index);
6706 mp->is_add = is_add;
6707 mp->del_all = del_all;
6711 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6715 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6717 mp->address_length = address_length;
6722 /* Wait for a reply, return good/bad news */
6728 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6730 unformat_input_t *i = vam->input;
6731 vl_api_sw_interface_set_mpls_enable_t *mp;
6733 u8 sw_if_index_set = 0;
6737 /* Parse args required to build the message */
6738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6740 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6741 sw_if_index_set = 1;
6742 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6743 sw_if_index_set = 1;
6744 else if (unformat (i, "disable"))
6746 else if (unformat (i, "dis"))
6752 if (sw_if_index_set == 0)
6754 errmsg ("missing interface name or sw_if_index");
6758 /* Construct the API message */
6759 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6761 mp->sw_if_index = ntohl (sw_if_index);
6762 mp->enable = enable;
6767 /* Wait for a reply... */
6773 api_sw_interface_set_table (vat_main_t * vam)
6775 unformat_input_t *i = vam->input;
6776 vl_api_sw_interface_set_table_t *mp;
6777 u32 sw_if_index, vrf_id = 0;
6778 u8 sw_if_index_set = 0;
6782 /* Parse args required to build the message */
6783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6785 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6786 sw_if_index_set = 1;
6787 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6788 sw_if_index_set = 1;
6789 else if (unformat (i, "vrf %d", &vrf_id))
6791 else if (unformat (i, "ipv6"))
6797 if (sw_if_index_set == 0)
6799 errmsg ("missing interface name or sw_if_index");
6803 /* Construct the API message */
6804 M (SW_INTERFACE_SET_TABLE, mp);
6806 mp->sw_if_index = ntohl (sw_if_index);
6807 mp->is_ipv6 = is_ipv6;
6808 mp->vrf_id = ntohl (vrf_id);
6813 /* Wait for a reply... */
6818 static void vl_api_sw_interface_get_table_reply_t_handler
6819 (vl_api_sw_interface_get_table_reply_t * mp)
6821 vat_main_t *vam = &vat_main;
6823 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6825 vam->retval = ntohl (mp->retval);
6826 vam->result_ready = 1;
6830 static void vl_api_sw_interface_get_table_reply_t_handler_json
6831 (vl_api_sw_interface_get_table_reply_t * mp)
6833 vat_main_t *vam = &vat_main;
6834 vat_json_node_t node;
6836 vat_json_init_object (&node);
6837 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6838 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6840 vat_json_print (vam->ofp, &node);
6841 vat_json_free (&node);
6843 vam->retval = ntohl (mp->retval);
6844 vam->result_ready = 1;
6848 api_sw_interface_get_table (vat_main_t * vam)
6850 unformat_input_t *i = vam->input;
6851 vl_api_sw_interface_get_table_t *mp;
6853 u8 sw_if_index_set = 0;
6857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6860 sw_if_index_set = 1;
6861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6862 sw_if_index_set = 1;
6863 else if (unformat (i, "ipv6"))
6869 if (sw_if_index_set == 0)
6871 errmsg ("missing interface name or sw_if_index");
6875 M (SW_INTERFACE_GET_TABLE, mp);
6876 mp->sw_if_index = htonl (sw_if_index);
6877 mp->is_ipv6 = is_ipv6;
6885 api_sw_interface_set_vpath (vat_main_t * vam)
6887 unformat_input_t *i = vam->input;
6888 vl_api_sw_interface_set_vpath_t *mp;
6889 u32 sw_if_index = 0;
6890 u8 sw_if_index_set = 0;
6894 /* Parse args required to build the message */
6895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6897 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6898 sw_if_index_set = 1;
6899 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6900 sw_if_index_set = 1;
6901 else if (unformat (i, "enable"))
6903 else if (unformat (i, "disable"))
6909 if (sw_if_index_set == 0)
6911 errmsg ("missing interface name or sw_if_index");
6915 /* Construct the API message */
6916 M (SW_INTERFACE_SET_VPATH, mp);
6918 mp->sw_if_index = ntohl (sw_if_index);
6919 mp->enable = is_enable;
6924 /* Wait for a reply... */
6930 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6932 unformat_input_t *i = vam->input;
6933 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6934 u32 sw_if_index = 0;
6935 u8 sw_if_index_set = 0;
6940 /* Parse args required to build the message */
6941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6943 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6944 sw_if_index_set = 1;
6945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6946 sw_if_index_set = 1;
6947 else if (unformat (i, "enable"))
6949 else if (unformat (i, "disable"))
6951 else if (unformat (i, "ip4"))
6953 else if (unformat (i, "ip6"))
6959 if (sw_if_index_set == 0)
6961 errmsg ("missing interface name or sw_if_index");
6965 /* Construct the API message */
6966 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6968 mp->sw_if_index = ntohl (sw_if_index);
6969 mp->enable = is_enable;
6970 mp->is_ipv6 = is_ipv6;
6975 /* Wait for a reply... */
6981 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6983 unformat_input_t *i = vam->input;
6984 vl_api_sw_interface_set_geneve_bypass_t *mp;
6985 u32 sw_if_index = 0;
6986 u8 sw_if_index_set = 0;
6991 /* Parse args required to build the message */
6992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6995 sw_if_index_set = 1;
6996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6997 sw_if_index_set = 1;
6998 else if (unformat (i, "enable"))
7000 else if (unformat (i, "disable"))
7002 else if (unformat (i, "ip4"))
7004 else if (unformat (i, "ip6"))
7010 if (sw_if_index_set == 0)
7012 errmsg ("missing interface name or sw_if_index");
7016 /* Construct the API message */
7017 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7019 mp->sw_if_index = ntohl (sw_if_index);
7020 mp->enable = is_enable;
7021 mp->is_ipv6 = is_ipv6;
7026 /* Wait for a reply... */
7032 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7034 unformat_input_t *i = vam->input;
7035 vl_api_sw_interface_set_l2_xconnect_t *mp;
7037 u8 rx_sw_if_index_set = 0;
7039 u8 tx_sw_if_index_set = 0;
7043 /* Parse args required to build the message */
7044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7046 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7047 rx_sw_if_index_set = 1;
7048 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7049 tx_sw_if_index_set = 1;
7050 else if (unformat (i, "rx"))
7052 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7054 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7056 rx_sw_if_index_set = 1;
7061 else if (unformat (i, "tx"))
7063 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7065 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7067 tx_sw_if_index_set = 1;
7072 else if (unformat (i, "enable"))
7074 else if (unformat (i, "disable"))
7080 if (rx_sw_if_index_set == 0)
7082 errmsg ("missing rx interface name or rx_sw_if_index");
7086 if (enable && (tx_sw_if_index_set == 0))
7088 errmsg ("missing tx interface name or tx_sw_if_index");
7092 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7094 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7095 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7096 mp->enable = enable;
7104 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7106 unformat_input_t *i = vam->input;
7107 vl_api_sw_interface_set_l2_bridge_t *mp;
7109 u8 rx_sw_if_index_set = 0;
7117 /* Parse args required to build the message */
7118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7120 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7121 rx_sw_if_index_set = 1;
7122 else if (unformat (i, "bd_id %d", &bd_id))
7126 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7127 rx_sw_if_index_set = 1;
7128 else if (unformat (i, "shg %d", &shg))
7130 else if (unformat (i, "bvi"))
7132 else if (unformat (i, "enable"))
7134 else if (unformat (i, "disable"))
7140 if (rx_sw_if_index_set == 0)
7142 errmsg ("missing rx interface name or sw_if_index");
7146 if (enable && (bd_id_set == 0))
7148 errmsg ("missing bridge domain");
7152 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7154 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7155 mp->bd_id = ntohl (bd_id);
7158 mp->enable = enable;
7166 api_bridge_domain_dump (vat_main_t * vam)
7168 unformat_input_t *i = vam->input;
7169 vl_api_bridge_domain_dump_t *mp;
7170 vl_api_control_ping_t *mp_ping;
7174 /* Parse args required to build the message */
7175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7177 if (unformat (i, "bd_id %d", &bd_id))
7183 M (BRIDGE_DOMAIN_DUMP, mp);
7184 mp->bd_id = ntohl (bd_id);
7187 /* Use a control ping for synchronization */
7188 MPING (CONTROL_PING, mp_ping);
7196 api_bridge_domain_add_del (vat_main_t * vam)
7198 unformat_input_t *i = vam->input;
7199 vl_api_bridge_domain_add_del_t *mp;
7202 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7207 /* Parse args required to build the message */
7208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7210 if (unformat (i, "bd_id %d", &bd_id))
7212 else if (unformat (i, "flood %d", &flood))
7214 else if (unformat (i, "uu-flood %d", &uu_flood))
7216 else if (unformat (i, "forward %d", &forward))
7218 else if (unformat (i, "learn %d", &learn))
7220 else if (unformat (i, "arp-term %d", &arp_term))
7222 else if (unformat (i, "mac-age %d", &mac_age))
7224 else if (unformat (i, "bd-tag %s", &bd_tag))
7226 else if (unformat (i, "del"))
7229 flood = uu_flood = forward = learn = 0;
7237 errmsg ("missing bridge domain");
7244 errmsg ("mac age must be less than 256 ");
7249 if ((bd_tag) && (vec_len (bd_tag) > 63))
7251 errmsg ("bd-tag cannot be longer than 63");
7256 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7258 mp->bd_id = ntohl (bd_id);
7260 mp->uu_flood = uu_flood;
7261 mp->forward = forward;
7263 mp->arp_term = arp_term;
7264 mp->is_add = is_add;
7265 mp->mac_age = (u8) mac_age;
7268 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7269 mp->bd_tag[vec_len (bd_tag)] = 0;
7280 api_l2fib_flush_bd (vat_main_t * vam)
7282 unformat_input_t *i = vam->input;
7283 vl_api_l2fib_flush_bd_t *mp;
7287 /* Parse args required to build the message */
7288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7290 if (unformat (i, "bd_id %d", &bd_id));
7297 errmsg ("missing bridge domain");
7301 M (L2FIB_FLUSH_BD, mp);
7303 mp->bd_id = htonl (bd_id);
7311 api_l2fib_flush_int (vat_main_t * vam)
7313 unformat_input_t *i = vam->input;
7314 vl_api_l2fib_flush_int_t *mp;
7315 u32 sw_if_index = ~0;
7318 /* Parse args required to build the message */
7319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7321 if (unformat (i, "sw_if_index %d", &sw_if_index));
7323 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7328 if (sw_if_index == ~0)
7330 errmsg ("missing interface name or sw_if_index");
7334 M (L2FIB_FLUSH_INT, mp);
7336 mp->sw_if_index = ntohl (sw_if_index);
7344 api_l2fib_add_del (vat_main_t * vam)
7346 unformat_input_t *i = vam->input;
7347 vl_api_l2fib_add_del_t *mp;
7353 u32 sw_if_index = ~0;
7354 u8 sw_if_index_set = 0;
7363 /* Parse args required to build the message */
7364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7366 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7368 else if (unformat (i, "bd_id %d", &bd_id))
7370 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7371 sw_if_index_set = 1;
7372 else if (unformat (i, "sw_if"))
7374 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7377 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7378 sw_if_index_set = 1;
7383 else if (unformat (i, "static"))
7385 else if (unformat (i, "filter"))
7390 else if (unformat (i, "bvi"))
7395 else if (unformat (i, "del"))
7397 else if (unformat (i, "count %d", &count))
7405 errmsg ("missing mac address");
7411 errmsg ("missing bridge domain");
7415 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7417 errmsg ("missing interface name or sw_if_index");
7423 /* Turn on async mode */
7424 vam->async_mode = 1;
7425 vam->async_errors = 0;
7426 before = vat_time_now (vam);
7429 for (j = 0; j < count; j++)
7431 M (L2FIB_ADD_DEL, mp);
7433 clib_memcpy (mp->mac, mac, 6);
7434 mp->bd_id = ntohl (bd_id);
7435 mp->is_add = is_add;
7439 mp->sw_if_index = ntohl (sw_if_index);
7440 mp->static_mac = static_mac;
7441 mp->filter_mac = filter_mac;
7442 mp->bvi_mac = bvi_mac;
7444 increment_mac_address (mac);
7451 vl_api_control_ping_t *mp_ping;
7454 /* Shut off async mode */
7455 vam->async_mode = 0;
7457 MPING (CONTROL_PING, mp_ping);
7460 timeout = vat_time_now (vam) + 1.0;
7461 while (vat_time_now (vam) < timeout)
7462 if (vam->result_ready == 1)
7467 if (vam->retval == -99)
7470 if (vam->async_errors > 0)
7472 errmsg ("%d asynchronous errors", vam->async_errors);
7475 vam->async_errors = 0;
7476 after = vat_time_now (vam);
7478 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7479 count, after - before, count / (after - before));
7485 /* Wait for a reply... */
7489 /* Return the good/bad news */
7490 return (vam->retval);
7494 api_bridge_domain_set_mac_age (vat_main_t * vam)
7496 unformat_input_t *i = vam->input;
7497 vl_api_bridge_domain_set_mac_age_t *mp;
7502 /* Parse args required to build the message */
7503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7505 if (unformat (i, "bd_id %d", &bd_id));
7506 else if (unformat (i, "mac-age %d", &mac_age));
7513 errmsg ("missing bridge domain");
7519 errmsg ("mac age must be less than 256 ");
7523 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7525 mp->bd_id = htonl (bd_id);
7526 mp->mac_age = (u8) mac_age;
7534 api_l2_flags (vat_main_t * vam)
7536 unformat_input_t *i = vam->input;
7537 vl_api_l2_flags_t *mp;
7540 u8 sw_if_index_set = 0;
7544 /* Parse args required to build the message */
7545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7547 if (unformat (i, "sw_if_index %d", &sw_if_index))
7548 sw_if_index_set = 1;
7549 else if (unformat (i, "sw_if"))
7551 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7555 sw_if_index_set = 1;
7560 else if (unformat (i, "learn"))
7562 else if (unformat (i, "forward"))
7564 else if (unformat (i, "flood"))
7566 else if (unformat (i, "uu-flood"))
7567 flags |= L2_UU_FLOOD;
7568 else if (unformat (i, "arp-term"))
7569 flags |= L2_ARP_TERM;
7570 else if (unformat (i, "off"))
7572 else if (unformat (i, "disable"))
7578 if (sw_if_index_set == 0)
7580 errmsg ("missing interface name or sw_if_index");
7586 mp->sw_if_index = ntohl (sw_if_index);
7587 mp->feature_bitmap = ntohl (flags);
7588 mp->is_set = is_set;
7596 api_bridge_flags (vat_main_t * vam)
7598 unformat_input_t *i = vam->input;
7599 vl_api_bridge_flags_t *mp;
7606 /* Parse args required to build the message */
7607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7609 if (unformat (i, "bd_id %d", &bd_id))
7611 else if (unformat (i, "learn"))
7613 else if (unformat (i, "forward"))
7615 else if (unformat (i, "flood"))
7617 else if (unformat (i, "uu-flood"))
7618 flags |= L2_UU_FLOOD;
7619 else if (unformat (i, "arp-term"))
7620 flags |= L2_ARP_TERM;
7621 else if (unformat (i, "off"))
7623 else if (unformat (i, "disable"))
7631 errmsg ("missing bridge domain");
7635 M (BRIDGE_FLAGS, mp);
7637 mp->bd_id = ntohl (bd_id);
7638 mp->feature_bitmap = ntohl (flags);
7639 mp->is_set = is_set;
7647 api_bd_ip_mac_add_del (vat_main_t * vam)
7649 unformat_input_t *i = vam->input;
7650 vl_api_bd_ip_mac_add_del_t *mp;
7657 ip4_address_t v4addr;
7658 ip6_address_t v6addr;
7663 /* Parse args required to build the message */
7664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7666 if (unformat (i, "bd_id %d", &bd_id))
7670 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7674 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7679 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7683 else if (unformat (i, "del"))
7691 errmsg ("missing bridge domain");
7694 else if (ip_set == 0)
7696 errmsg ("missing IP address");
7699 else if (mac_set == 0)
7701 errmsg ("missing MAC address");
7705 M (BD_IP_MAC_ADD_DEL, mp);
7707 mp->bd_id = ntohl (bd_id);
7708 mp->is_ipv6 = is_ipv6;
7709 mp->is_add = is_add;
7711 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7713 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7714 clib_memcpy (mp->mac_address, macaddr, 6);
7721 api_tap_connect (vat_main_t * vam)
7723 unformat_input_t *i = vam->input;
7724 vl_api_tap_connect_t *mp;
7730 ip4_address_t ip4_address;
7732 int ip4_address_set = 0;
7733 ip6_address_t ip6_address;
7735 int ip6_address_set = 0;
7738 memset (mac_address, 0, sizeof (mac_address));
7740 /* Parse args required to build the message */
7741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7743 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7747 else if (unformat (i, "random-mac"))
7749 else if (unformat (i, "tapname %s", &tap_name))
7751 else if (unformat (i, "tag %s", &tag))
7753 else if (unformat (i, "address %U/%d",
7754 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7755 ip4_address_set = 1;
7756 else if (unformat (i, "address %U/%d",
7757 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7758 ip6_address_set = 1;
7765 errmsg ("missing tap name");
7768 if (vec_len (tap_name) > 63)
7770 errmsg ("tap name too long");
7773 vec_add1 (tap_name, 0);
7775 if (vec_len (tag) > 63)
7777 errmsg ("tag too long");
7781 /* Construct the API message */
7782 M (TAP_CONNECT, mp);
7784 mp->use_random_mac = random_mac;
7785 clib_memcpy (mp->mac_address, mac_address, 6);
7786 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7788 clib_memcpy (mp->tag, tag, vec_len (tag));
7790 if (ip4_address_set)
7792 mp->ip4_address_set = 1;
7793 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7794 mp->ip4_mask_width = ip4_mask_width;
7796 if (ip6_address_set)
7798 mp->ip6_address_set = 1;
7799 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7800 mp->ip6_mask_width = ip6_mask_width;
7803 vec_free (tap_name);
7809 /* Wait for a reply... */
7815 api_tap_modify (vat_main_t * vam)
7817 unformat_input_t *i = vam->input;
7818 vl_api_tap_modify_t *mp;
7823 u32 sw_if_index = ~0;
7824 u8 sw_if_index_set = 0;
7827 memset (mac_address, 0, sizeof (mac_address));
7829 /* Parse args required to build the message */
7830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7832 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7833 sw_if_index_set = 1;
7834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7835 sw_if_index_set = 1;
7836 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7840 else if (unformat (i, "random-mac"))
7842 else if (unformat (i, "tapname %s", &tap_name))
7848 if (sw_if_index_set == 0)
7850 errmsg ("missing vpp interface name");
7855 errmsg ("missing tap name");
7858 if (vec_len (tap_name) > 63)
7860 errmsg ("tap name too long");
7862 vec_add1 (tap_name, 0);
7864 /* Construct the API message */
7867 mp->use_random_mac = random_mac;
7868 mp->sw_if_index = ntohl (sw_if_index);
7869 clib_memcpy (mp->mac_address, mac_address, 6);
7870 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7871 vec_free (tap_name);
7876 /* Wait for a reply... */
7882 api_tap_delete (vat_main_t * vam)
7884 unformat_input_t *i = vam->input;
7885 vl_api_tap_delete_t *mp;
7886 u32 sw_if_index = ~0;
7887 u8 sw_if_index_set = 0;
7890 /* Parse args required to build the message */
7891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7893 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7894 sw_if_index_set = 1;
7895 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7896 sw_if_index_set = 1;
7901 if (sw_if_index_set == 0)
7903 errmsg ("missing vpp interface name");
7907 /* Construct the API message */
7910 mp->sw_if_index = ntohl (sw_if_index);
7915 /* Wait for a reply... */
7921 api_tap_create_v2 (vat_main_t * vam)
7923 unformat_input_t *i = vam->input;
7924 vl_api_tap_create_v2_t *mp;
7928 u8 *host_if_name = 0;
7930 u8 host_mac_addr[6];
7931 u8 host_mac_addr_set = 0;
7932 u8 *host_bridge = 0;
7933 ip4_address_t host_ip4_addr;
7934 ip4_address_t host_ip4_gw;
7935 u8 host_ip4_gw_set = 0;
7936 u32 host_ip4_prefix_len = 0;
7937 ip6_address_t host_ip6_addr;
7938 ip6_address_t host_ip6_gw;
7939 u8 host_ip6_gw_set = 0;
7940 u32 host_ip6_prefix_len = 0;
7942 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7944 memset (mac_address, 0, sizeof (mac_address));
7946 /* Parse args required to build the message */
7947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7949 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7953 else if (unformat (i, "id %u", &id))
7955 else if (unformat (i, "host-if-name %s", &host_if_name))
7957 else if (unformat (i, "host-ns %s", &host_ns))
7959 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7961 host_mac_addr_set = 1;
7962 else if (unformat (i, "host-bridge %s", &host_bridge))
7964 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7965 &host_ip4_addr, &host_ip4_prefix_len))
7967 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7968 &host_ip6_addr, &host_ip6_prefix_len))
7970 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7972 host_ip4_gw_set = 1;
7973 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7975 host_ip6_gw_set = 1;
7976 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7978 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7984 if (vec_len (host_if_name) > 63)
7986 errmsg ("tap name too long. ");
7989 if (vec_len (host_ns) > 63)
7991 errmsg ("host name space too long. ");
7994 if (vec_len (host_bridge) > 63)
7996 errmsg ("host bridge name too long. ");
7999 if (host_ip4_prefix_len > 32)
8001 errmsg ("host ip4 prefix length not valid. ");
8004 if (host_ip6_prefix_len > 128)
8006 errmsg ("host ip6 prefix length not valid. ");
8009 if (!is_pow2 (rx_ring_sz))
8011 errmsg ("rx ring size must be power of 2. ");
8014 if (rx_ring_sz > 32768)
8016 errmsg ("rx ring size must be 32768 or lower. ");
8019 if (!is_pow2 (tx_ring_sz))
8021 errmsg ("tx ring size must be power of 2. ");
8024 if (tx_ring_sz > 32768)
8026 errmsg ("tx ring size must be 32768 or lower. ");
8030 /* Construct the API message */
8031 M (TAP_CREATE_V2, mp);
8033 mp->use_random_mac = random_mac;
8035 mp->id = ntohl (id);
8036 mp->host_namespace_set = host_ns != 0;
8037 mp->host_bridge_set = host_bridge != 0;
8038 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8039 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8040 mp->rx_ring_sz = ntohs (rx_ring_sz);
8041 mp->tx_ring_sz = ntohs (tx_ring_sz);
8043 if (random_mac == 0)
8044 clib_memcpy (mp->mac_address, mac_address, 6);
8045 if (host_mac_addr_set)
8046 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8048 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8050 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8052 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8053 if (host_ip4_prefix_len)
8054 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8055 if (host_ip4_prefix_len)
8056 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8057 if (host_ip4_gw_set)
8058 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8059 if (host_ip6_gw_set)
8060 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8063 vec_free (host_if_name);
8064 vec_free (host_bridge);
8069 /* Wait for a reply... */
8075 api_tap_delete_v2 (vat_main_t * vam)
8077 unformat_input_t *i = vam->input;
8078 vl_api_tap_delete_v2_t *mp;
8079 u32 sw_if_index = ~0;
8080 u8 sw_if_index_set = 0;
8083 /* Parse args required to build the message */
8084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8086 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8087 sw_if_index_set = 1;
8088 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8089 sw_if_index_set = 1;
8094 if (sw_if_index_set == 0)
8096 errmsg ("missing vpp interface name. ");
8100 /* Construct the API message */
8101 M (TAP_DELETE_V2, mp);
8103 mp->sw_if_index = ntohl (sw_if_index);
8108 /* Wait for a reply... */
8114 api_bond_create (vat_main_t * vam)
8116 unformat_input_t *i = vam->input;
8117 vl_api_bond_create_t *mp;
8125 memset (mac_address, 0, sizeof (mac_address));
8128 /* Parse args required to build the message */
8129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8131 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8133 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8134 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8136 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8143 if (mode_is_set == 0)
8145 errmsg ("Missing bond mode. ");
8149 /* Construct the API message */
8150 M (BOND_CREATE, mp);
8152 mp->use_custom_mac = custom_mac;
8158 clib_memcpy (mp->mac_address, mac_address, 6);
8163 /* Wait for a reply... */
8169 api_bond_delete (vat_main_t * vam)
8171 unformat_input_t *i = vam->input;
8172 vl_api_bond_delete_t *mp;
8173 u32 sw_if_index = ~0;
8174 u8 sw_if_index_set = 0;
8177 /* Parse args required to build the message */
8178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8180 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8181 sw_if_index_set = 1;
8182 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8183 sw_if_index_set = 1;
8188 if (sw_if_index_set == 0)
8190 errmsg ("missing vpp interface name. ");
8194 /* Construct the API message */
8195 M (BOND_DELETE, mp);
8197 mp->sw_if_index = ntohl (sw_if_index);
8202 /* Wait for a reply... */
8208 api_bond_enslave (vat_main_t * vam)
8210 unformat_input_t *i = vam->input;
8211 vl_api_bond_enslave_t *mp;
8212 u32 bond_sw_if_index;
8216 u32 bond_sw_if_index_is_set = 0;
8218 u8 sw_if_index_is_set = 0;
8220 /* Parse args required to build the message */
8221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8223 if (unformat (i, "sw_if_index %d", &sw_if_index))
8224 sw_if_index_is_set = 1;
8225 else if (unformat (i, "bond %u", &bond_sw_if_index))
8226 bond_sw_if_index_is_set = 1;
8227 else if (unformat (i, "passive %d", &is_passive))
8229 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8235 if (bond_sw_if_index_is_set == 0)
8237 errmsg ("Missing bond sw_if_index. ");
8240 if (sw_if_index_is_set == 0)
8242 errmsg ("Missing slave sw_if_index. ");
8246 /* Construct the API message */
8247 M (BOND_ENSLAVE, mp);
8249 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8250 mp->sw_if_index = ntohl (sw_if_index);
8251 mp->is_long_timeout = is_long_timeout;
8252 mp->is_passive = is_passive;
8257 /* Wait for a reply... */
8263 api_bond_detach_slave (vat_main_t * vam)
8265 unformat_input_t *i = vam->input;
8266 vl_api_bond_detach_slave_t *mp;
8267 u32 sw_if_index = ~0;
8268 u8 sw_if_index_set = 0;
8271 /* Parse args required to build the message */
8272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8274 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8275 sw_if_index_set = 1;
8276 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8277 sw_if_index_set = 1;
8282 if (sw_if_index_set == 0)
8284 errmsg ("missing vpp interface name. ");
8288 /* Construct the API message */
8289 M (BOND_DETACH_SLAVE, mp);
8291 mp->sw_if_index = ntohl (sw_if_index);
8296 /* Wait for a reply... */
8302 api_ip_table_add_del (vat_main_t * vam)
8304 unformat_input_t *i = vam->input;
8305 vl_api_ip_table_add_del_t *mp;
8311 /* Parse args required to build the message */
8312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8314 if (unformat (i, "ipv6"))
8316 else if (unformat (i, "del"))
8318 else if (unformat (i, "add"))
8320 else if (unformat (i, "table %d", &table_id))
8324 clib_warning ("parse error '%U'", format_unformat_error, i);
8331 errmsg ("missing table-ID");
8335 /* Construct the API message */
8336 M (IP_TABLE_ADD_DEL, mp);
8338 mp->table_id = ntohl (table_id);
8339 mp->is_ipv6 = is_ipv6;
8340 mp->is_add = is_add;
8345 /* Wait for a reply... */
8352 api_ip_add_del_route (vat_main_t * vam)
8354 unformat_input_t *i = vam->input;
8355 vl_api_ip_add_del_route_t *mp;
8356 u32 sw_if_index = ~0, vrf_id = 0;
8358 u8 is_local = 0, is_drop = 0;
8359 u8 is_unreach = 0, is_prohibit = 0;
8361 u32 next_hop_weight = 1;
8362 u8 is_multipath = 0;
8364 u8 address_length_set = 0;
8365 u32 next_hop_table_id = 0;
8366 u32 resolve_attempts = 0;
8367 u32 dst_address_length = 0;
8368 u8 next_hop_set = 0;
8369 ip4_address_t v4_dst_address, v4_next_hop_address;
8370 ip6_address_t v6_dst_address, v6_next_hop_address;
8374 u32 random_add_del = 0;
8375 u32 *random_vector = 0;
8377 u32 random_seed = 0xdeaddabe;
8378 u32 classify_table_index = ~0;
8380 u8 resolve_host = 0, resolve_attached = 0;
8381 mpls_label_t *next_hop_out_label_stack = NULL;
8382 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8383 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8385 /* Parse args required to build the message */
8386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8392 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8397 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8402 else if (unformat (i, "/%d", &dst_address_length))
8404 address_length_set = 1;
8407 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8408 &v4_next_hop_address))
8412 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8413 &v6_next_hop_address))
8417 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8419 else if (unformat (i, "weight %d", &next_hop_weight))
8421 else if (unformat (i, "drop"))
8425 else if (unformat (i, "null-send-unreach"))
8429 else if (unformat (i, "null-send-prohibit"))
8433 else if (unformat (i, "local"))
8437 else if (unformat (i, "classify %d", &classify_table_index))
8441 else if (unformat (i, "del"))
8443 else if (unformat (i, "add"))
8445 else if (unformat (i, "resolve-via-host"))
8447 else if (unformat (i, "resolve-via-attached"))
8448 resolve_attached = 1;
8449 else if (unformat (i, "multipath"))
8451 else if (unformat (i, "vrf %d", &vrf_id))
8453 else if (unformat (i, "count %d", &count))
8455 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8457 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8459 else if (unformat (i, "out-label %d", &next_hop_out_label))
8460 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8461 else if (unformat (i, "via-label %d", &next_hop_via_label))
8463 else if (unformat (i, "random"))
8465 else if (unformat (i, "seed %d", &random_seed))
8469 clib_warning ("parse error '%U'", format_unformat_error, i);
8474 if (!next_hop_set && !is_drop && !is_local &&
8475 !is_classify && !is_unreach && !is_prohibit &&
8476 MPLS_LABEL_INVALID == next_hop_via_label)
8479 ("next hop / local / drop / unreach / prohibit / classify not set");
8483 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8485 errmsg ("next hop and next-hop via label set");
8488 if (address_set == 0)
8490 errmsg ("missing addresses");
8494 if (address_length_set == 0)
8496 errmsg ("missing address length");
8500 /* Generate a pile of unique, random routes */
8503 u32 this_random_address;
8504 random_hash = hash_create (count, sizeof (uword));
8506 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8507 for (j = 0; j <= count; j++)
8511 this_random_address = random_u32 (&random_seed);
8512 this_random_address =
8513 clib_host_to_net_u32 (this_random_address);
8515 while (hash_get (random_hash, this_random_address));
8516 vec_add1 (random_vector, this_random_address);
8517 hash_set (random_hash, this_random_address, 1);
8519 hash_free (random_hash);
8520 v4_dst_address.as_u32 = random_vector[0];
8525 /* Turn on async mode */
8526 vam->async_mode = 1;
8527 vam->async_errors = 0;
8528 before = vat_time_now (vam);
8531 for (j = 0; j < count; j++)
8533 /* Construct the API message */
8534 M2 (IP_ADD_DEL_ROUTE, mp,
8535 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8537 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8538 mp->table_id = ntohl (vrf_id);
8540 mp->is_add = is_add;
8541 mp->is_drop = is_drop;
8542 mp->is_unreach = is_unreach;
8543 mp->is_prohibit = is_prohibit;
8544 mp->is_ipv6 = is_ipv6;
8545 mp->is_local = is_local;
8546 mp->is_classify = is_classify;
8547 mp->is_multipath = is_multipath;
8548 mp->is_resolve_host = resolve_host;
8549 mp->is_resolve_attached = resolve_attached;
8550 mp->next_hop_weight = next_hop_weight;
8551 mp->dst_address_length = dst_address_length;
8552 mp->next_hop_table_id = ntohl (next_hop_table_id);
8553 mp->classify_table_index = ntohl (classify_table_index);
8554 mp->next_hop_via_label = ntohl (next_hop_via_label);
8555 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8556 if (0 != mp->next_hop_n_out_labels)
8558 memcpy (mp->next_hop_out_label_stack,
8559 next_hop_out_label_stack,
8560 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8561 vec_free (next_hop_out_label_stack);
8566 clib_memcpy (mp->dst_address, &v6_dst_address,
8567 sizeof (v6_dst_address));
8569 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8570 sizeof (v6_next_hop_address));
8571 increment_v6_address (&v6_dst_address);
8575 clib_memcpy (mp->dst_address, &v4_dst_address,
8576 sizeof (v4_dst_address));
8578 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8579 sizeof (v4_next_hop_address));
8581 v4_dst_address.as_u32 = random_vector[j + 1];
8583 increment_v4_address (&v4_dst_address);
8587 /* If we receive SIGTERM, stop now... */
8592 /* When testing multiple add/del ops, use a control-ping to sync */
8595 vl_api_control_ping_t *mp_ping;
8599 /* Shut off async mode */
8600 vam->async_mode = 0;
8602 MPING (CONTROL_PING, mp_ping);
8605 timeout = vat_time_now (vam) + 1.0;
8606 while (vat_time_now (vam) < timeout)
8607 if (vam->result_ready == 1)
8612 if (vam->retval == -99)
8615 if (vam->async_errors > 0)
8617 errmsg ("%d asynchronous errors", vam->async_errors);
8620 vam->async_errors = 0;
8621 after = vat_time_now (vam);
8623 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8627 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8628 count, after - before, count / (after - before));
8634 /* Wait for a reply... */
8639 /* Return the good/bad news */
8640 return (vam->retval);
8644 api_ip_mroute_add_del (vat_main_t * vam)
8646 unformat_input_t *i = vam->input;
8647 vl_api_ip_mroute_add_del_t *mp;
8648 u32 sw_if_index = ~0, vrf_id = 0;
8653 u32 grp_address_length = 0;
8654 ip4_address_t v4_grp_address, v4_src_address;
8655 ip6_address_t v6_grp_address, v6_src_address;
8656 mfib_itf_flags_t iflags = 0;
8657 mfib_entry_flags_t eflags = 0;
8660 /* Parse args required to build the message */
8661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8663 if (unformat (i, "sw_if_index %d", &sw_if_index))
8665 else if (unformat (i, "%U %U",
8666 unformat_ip4_address, &v4_src_address,
8667 unformat_ip4_address, &v4_grp_address))
8669 grp_address_length = 64;
8673 else if (unformat (i, "%U %U",
8674 unformat_ip6_address, &v6_src_address,
8675 unformat_ip6_address, &v6_grp_address))
8677 grp_address_length = 256;
8681 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8683 memset (&v4_src_address, 0, sizeof (v4_src_address));
8684 grp_address_length = 32;
8688 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8690 memset (&v6_src_address, 0, sizeof (v6_src_address));
8691 grp_address_length = 128;
8695 else if (unformat (i, "/%d", &grp_address_length))
8697 else if (unformat (i, "local"))
8701 else if (unformat (i, "del"))
8703 else if (unformat (i, "add"))
8705 else if (unformat (i, "vrf %d", &vrf_id))
8707 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8709 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8713 clib_warning ("parse error '%U'", format_unformat_error, i);
8718 if (address_set == 0)
8720 errmsg ("missing addresses\n");
8724 /* Construct the API message */
8725 M (IP_MROUTE_ADD_DEL, mp);
8727 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8728 mp->table_id = ntohl (vrf_id);
8730 mp->is_add = is_add;
8731 mp->is_ipv6 = is_ipv6;
8732 mp->is_local = is_local;
8733 mp->itf_flags = ntohl (iflags);
8734 mp->entry_flags = ntohl (eflags);
8735 mp->grp_address_length = grp_address_length;
8736 mp->grp_address_length = ntohs (mp->grp_address_length);
8740 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8741 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8745 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8746 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8752 /* Wait for a reply... */
8758 api_mpls_table_add_del (vat_main_t * vam)
8760 unformat_input_t *i = vam->input;
8761 vl_api_mpls_table_add_del_t *mp;
8766 /* Parse args required to build the message */
8767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8769 if (unformat (i, "table %d", &table_id))
8771 else if (unformat (i, "del"))
8773 else if (unformat (i, "add"))
8777 clib_warning ("parse error '%U'", format_unformat_error, i);
8784 errmsg ("missing table-ID");
8788 /* Construct the API message */
8789 M (MPLS_TABLE_ADD_DEL, mp);
8791 mp->mt_table_id = ntohl (table_id);
8792 mp->mt_is_add = is_add;
8797 /* Wait for a reply... */
8804 api_mpls_route_add_del (vat_main_t * vam)
8806 unformat_input_t *i = vam->input;
8807 vl_api_mpls_route_add_del_t *mp;
8808 u32 sw_if_index = ~0, table_id = 0;
8810 u32 next_hop_weight = 1;
8811 u8 is_multipath = 0;
8812 u32 next_hop_table_id = 0;
8813 u8 next_hop_set = 0;
8814 ip4_address_t v4_next_hop_address = {
8817 ip6_address_t v6_next_hop_address = { {0} };
8821 u32 classify_table_index = ~0;
8823 u8 resolve_host = 0, resolve_attached = 0;
8824 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8825 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8826 mpls_label_t *next_hop_out_label_stack = NULL;
8827 mpls_label_t local_label = MPLS_LABEL_INVALID;
8829 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8831 /* Parse args required to build the message */
8832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8834 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8836 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8838 else if (unformat (i, "%d", &local_label))
8840 else if (unformat (i, "eos"))
8842 else if (unformat (i, "non-eos"))
8844 else if (unformat (i, "via %U", unformat_ip4_address,
8845 &v4_next_hop_address))
8848 next_hop_proto = DPO_PROTO_IP4;
8850 else if (unformat (i, "via %U", unformat_ip6_address,
8851 &v6_next_hop_address))
8854 next_hop_proto = DPO_PROTO_IP6;
8856 else if (unformat (i, "weight %d", &next_hop_weight))
8858 else if (unformat (i, "classify %d", &classify_table_index))
8862 else if (unformat (i, "del"))
8864 else if (unformat (i, "add"))
8866 else if (unformat (i, "resolve-via-host"))
8868 else if (unformat (i, "resolve-via-attached"))
8869 resolve_attached = 1;
8870 else if (unformat (i, "multipath"))
8872 else if (unformat (i, "count %d", &count))
8874 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8877 next_hop_proto = DPO_PROTO_IP4;
8879 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8882 next_hop_proto = DPO_PROTO_IP6;
8884 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8886 else if (unformat (i, "via-label %d", &next_hop_via_label))
8888 else if (unformat (i, "out-label %d", &next_hop_out_label))
8889 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8892 clib_warning ("parse error '%U'", format_unformat_error, i);
8897 if (!next_hop_set && !is_classify)
8899 errmsg ("next hop / classify not set");
8903 if (MPLS_LABEL_INVALID == local_label)
8905 errmsg ("missing label");
8911 /* Turn on async mode */
8912 vam->async_mode = 1;
8913 vam->async_errors = 0;
8914 before = vat_time_now (vam);
8917 for (j = 0; j < count; j++)
8919 /* Construct the API message */
8920 M2 (MPLS_ROUTE_ADD_DEL, mp,
8921 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8923 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8924 mp->mr_table_id = ntohl (table_id);
8926 mp->mr_is_add = is_add;
8927 mp->mr_next_hop_proto = next_hop_proto;
8928 mp->mr_is_classify = is_classify;
8929 mp->mr_is_multipath = is_multipath;
8930 mp->mr_is_resolve_host = resolve_host;
8931 mp->mr_is_resolve_attached = resolve_attached;
8932 mp->mr_next_hop_weight = next_hop_weight;
8933 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8934 mp->mr_classify_table_index = ntohl (classify_table_index);
8935 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8936 mp->mr_label = ntohl (local_label);
8937 mp->mr_eos = is_eos;
8939 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8940 if (0 != mp->mr_next_hop_n_out_labels)
8942 memcpy (mp->mr_next_hop_out_label_stack,
8943 next_hop_out_label_stack,
8944 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8945 vec_free (next_hop_out_label_stack);
8950 if (DPO_PROTO_IP4 == next_hop_proto)
8952 clib_memcpy (mp->mr_next_hop,
8953 &v4_next_hop_address,
8954 sizeof (v4_next_hop_address));
8956 else if (DPO_PROTO_IP6 == next_hop_proto)
8959 clib_memcpy (mp->mr_next_hop,
8960 &v6_next_hop_address,
8961 sizeof (v6_next_hop_address));
8968 /* If we receive SIGTERM, stop now... */
8973 /* When testing multiple add/del ops, use a control-ping to sync */
8976 vl_api_control_ping_t *mp_ping;
8980 /* Shut off async mode */
8981 vam->async_mode = 0;
8983 MPING (CONTROL_PING, mp_ping);
8986 timeout = vat_time_now (vam) + 1.0;
8987 while (vat_time_now (vam) < timeout)
8988 if (vam->result_ready == 1)
8993 if (vam->retval == -99)
8996 if (vam->async_errors > 0)
8998 errmsg ("%d asynchronous errors", vam->async_errors);
9001 vam->async_errors = 0;
9002 after = vat_time_now (vam);
9004 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9008 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9009 count, after - before, count / (after - before));
9015 /* Wait for a reply... */
9020 /* Return the good/bad news */
9021 return (vam->retval);
9025 api_mpls_ip_bind_unbind (vat_main_t * vam)
9027 unformat_input_t *i = vam->input;
9028 vl_api_mpls_ip_bind_unbind_t *mp;
9029 u32 ip_table_id = 0;
9032 ip4_address_t v4_address;
9033 ip6_address_t v6_address;
9036 mpls_label_t local_label = MPLS_LABEL_INVALID;
9039 /* Parse args required to build the message */
9040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9042 if (unformat (i, "%U/%d", unformat_ip4_address,
9043 &v4_address, &address_length))
9048 else if (unformat (i, "%U/%d", unformat_ip6_address,
9049 &v6_address, &address_length))
9054 else if (unformat (i, "%d", &local_label))
9056 else if (unformat (i, "table-id %d", &ip_table_id))
9058 else if (unformat (i, "unbind"))
9060 else if (unformat (i, "bind"))
9064 clib_warning ("parse error '%U'", format_unformat_error, i);
9071 errmsg ("IP addres not set");
9075 if (MPLS_LABEL_INVALID == local_label)
9077 errmsg ("missing label");
9081 /* Construct the API message */
9082 M (MPLS_IP_BIND_UNBIND, mp);
9084 mp->mb_is_bind = is_bind;
9085 mp->mb_is_ip4 = is_ip4;
9086 mp->mb_ip_table_id = ntohl (ip_table_id);
9087 mp->mb_mpls_table_id = 0;
9088 mp->mb_label = ntohl (local_label);
9089 mp->mb_address_length = address_length;
9092 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9094 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9099 /* Wait for a reply... */
9105 api_bier_table_add_del (vat_main_t * vam)
9107 unformat_input_t *i = vam->input;
9108 vl_api_bier_table_add_del_t *mp;
9110 u32 set = 0, sub_domain = 0, hdr_len = 3;
9111 mpls_label_t local_label = MPLS_LABEL_INVALID;
9114 /* Parse args required to build the message */
9115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9117 if (unformat (i, "sub-domain %d", &sub_domain))
9119 else if (unformat (i, "set %d", &set))
9121 else if (unformat (i, "label %d", &local_label))
9123 else if (unformat (i, "hdr-len %d", &hdr_len))
9125 else if (unformat (i, "add"))
9127 else if (unformat (i, "del"))
9131 clib_warning ("parse error '%U'", format_unformat_error, i);
9136 if (MPLS_LABEL_INVALID == local_label)
9138 errmsg ("missing label\n");
9142 /* Construct the API message */
9143 M (BIER_TABLE_ADD_DEL, mp);
9145 mp->bt_is_add = is_add;
9146 mp->bt_label = ntohl (local_label);
9147 mp->bt_tbl_id.bt_set = set;
9148 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9149 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9154 /* Wait for a reply... */
9161 api_bier_route_add_del (vat_main_t * vam)
9163 unformat_input_t *i = vam->input;
9164 vl_api_bier_route_add_del_t *mp;
9166 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9167 ip4_address_t v4_next_hop_address;
9168 ip6_address_t v6_next_hop_address;
9169 u8 next_hop_set = 0;
9170 u8 next_hop_proto_is_ip4 = 1;
9171 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9174 /* Parse args required to build the message */
9175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9177 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9179 next_hop_proto_is_ip4 = 1;
9182 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9184 next_hop_proto_is_ip4 = 0;
9187 if (unformat (i, "sub-domain %d", &sub_domain))
9189 else if (unformat (i, "set %d", &set))
9191 else if (unformat (i, "hdr-len %d", &hdr_len))
9193 else if (unformat (i, "bp %d", &bp))
9195 else if (unformat (i, "add"))
9197 else if (unformat (i, "del"))
9199 else if (unformat (i, "out-label %d", &next_hop_out_label))
9203 clib_warning ("parse error '%U'", format_unformat_error, i);
9208 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9210 errmsg ("next hop / label set\n");
9215 errmsg ("bit=position not set\n");
9219 /* Construct the API message */
9220 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9222 mp->br_is_add = is_add;
9223 mp->br_tbl_id.bt_set = set;
9224 mp->br_tbl_id.bt_sub_domain = sub_domain;
9225 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9226 mp->br_bp = ntohs (bp);
9228 mp->br_paths[0].n_labels = 1;
9229 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9230 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9232 if (next_hop_proto_is_ip4)
9234 clib_memcpy (mp->br_paths[0].next_hop,
9235 &v4_next_hop_address, sizeof (v4_next_hop_address));
9239 clib_memcpy (mp->br_paths[0].next_hop,
9240 &v6_next_hop_address, sizeof (v6_next_hop_address));
9246 /* Wait for a reply... */
9253 api_proxy_arp_add_del (vat_main_t * vam)
9255 unformat_input_t *i = vam->input;
9256 vl_api_proxy_arp_add_del_t *mp;
9259 ip4_address_t lo, hi;
9263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9265 if (unformat (i, "vrf %d", &vrf_id))
9267 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9268 unformat_ip4_address, &hi))
9270 else if (unformat (i, "del"))
9274 clib_warning ("parse error '%U'", format_unformat_error, i);
9281 errmsg ("address range not set");
9285 M (PROXY_ARP_ADD_DEL, mp);
9287 mp->vrf_id = ntohl (vrf_id);
9288 mp->is_add = is_add;
9289 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
9290 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
9298 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9300 unformat_input_t *i = vam->input;
9301 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9304 u8 sw_if_index_set = 0;
9307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9309 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9310 sw_if_index_set = 1;
9311 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9312 sw_if_index_set = 1;
9313 else if (unformat (i, "enable"))
9315 else if (unformat (i, "disable"))
9319 clib_warning ("parse error '%U'", format_unformat_error, i);
9324 if (sw_if_index_set == 0)
9326 errmsg ("missing interface name or sw_if_index");
9330 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9332 mp->sw_if_index = ntohl (sw_if_index);
9333 mp->enable_disable = enable;
9341 api_mpls_tunnel_add_del (vat_main_t * vam)
9343 unformat_input_t *i = vam->input;
9344 vl_api_mpls_tunnel_add_del_t *mp;
9348 u32 sw_if_index = ~0;
9349 u32 next_hop_sw_if_index = ~0;
9350 u32 next_hop_proto_is_ip4 = 1;
9352 u32 next_hop_table_id = 0;
9353 ip4_address_t v4_next_hop_address = {
9356 ip6_address_t v6_next_hop_address = { {0} };
9357 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9362 if (unformat (i, "add"))
9364 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9366 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9368 else if (unformat (i, "via %U",
9369 unformat_ip4_address, &v4_next_hop_address))
9371 next_hop_proto_is_ip4 = 1;
9373 else if (unformat (i, "via %U",
9374 unformat_ip6_address, &v6_next_hop_address))
9376 next_hop_proto_is_ip4 = 0;
9378 else if (unformat (i, "l2-only"))
9380 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9382 else if (unformat (i, "out-label %d", &next_hop_out_label))
9383 vec_add1 (labels, ntohl (next_hop_out_label));
9386 clib_warning ("parse error '%U'", format_unformat_error, i);
9391 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9393 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9394 mp->mt_sw_if_index = ntohl (sw_if_index);
9395 mp->mt_is_add = is_add;
9396 mp->mt_l2_only = l2_only;
9397 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9398 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9400 mp->mt_next_hop_n_out_labels = vec_len (labels);
9402 if (0 != mp->mt_next_hop_n_out_labels)
9404 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9405 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9409 if (next_hop_proto_is_ip4)
9411 clib_memcpy (mp->mt_next_hop,
9412 &v4_next_hop_address, sizeof (v4_next_hop_address));
9416 clib_memcpy (mp->mt_next_hop,
9417 &v6_next_hop_address, sizeof (v6_next_hop_address));
9426 api_sw_interface_set_unnumbered (vat_main_t * vam)
9428 unformat_input_t *i = vam->input;
9429 vl_api_sw_interface_set_unnumbered_t *mp;
9431 u32 unnum_sw_index = ~0;
9433 u8 sw_if_index_set = 0;
9436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9438 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9439 sw_if_index_set = 1;
9440 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9441 sw_if_index_set = 1;
9442 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9444 else if (unformat (i, "del"))
9448 clib_warning ("parse error '%U'", format_unformat_error, i);
9453 if (sw_if_index_set == 0)
9455 errmsg ("missing interface name or sw_if_index");
9459 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9461 mp->sw_if_index = ntohl (sw_if_index);
9462 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9463 mp->is_add = is_add;
9471 api_ip_neighbor_add_del (vat_main_t * vam)
9473 unformat_input_t *i = vam->input;
9474 vl_api_ip_neighbor_add_del_t *mp;
9476 u8 sw_if_index_set = 0;
9479 u8 is_no_fib_entry = 0;
9482 u8 v4_address_set = 0;
9483 u8 v6_address_set = 0;
9484 ip4_address_t v4address;
9485 ip6_address_t v6address;
9488 memset (mac_address, 0, sizeof (mac_address));
9490 /* Parse args required to build the message */
9491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9493 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9497 else if (unformat (i, "del"))
9500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9501 sw_if_index_set = 1;
9502 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9503 sw_if_index_set = 1;
9504 else if (unformat (i, "is_static"))
9506 else if (unformat (i, "no-fib-entry"))
9507 is_no_fib_entry = 1;
9508 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9510 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9514 clib_warning ("parse error '%U'", format_unformat_error, i);
9519 if (sw_if_index_set == 0)
9521 errmsg ("missing interface name or sw_if_index");
9524 if (v4_address_set && v6_address_set)
9526 errmsg ("both v4 and v6 addresses set");
9529 if (!v4_address_set && !v6_address_set)
9531 errmsg ("no address set");
9535 /* Construct the API message */
9536 M (IP_NEIGHBOR_ADD_DEL, mp);
9538 mp->sw_if_index = ntohl (sw_if_index);
9539 mp->is_add = is_add;
9540 mp->is_static = is_static;
9541 mp->is_no_adj_fib = is_no_fib_entry;
9543 clib_memcpy (mp->mac_address, mac_address, 6);
9547 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9551 /* mp->is_ipv6 = 0; via memset in M macro above */
9552 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9558 /* Wait for a reply, return good/bad news */
9564 api_create_vlan_subif (vat_main_t * vam)
9566 unformat_input_t *i = vam->input;
9567 vl_api_create_vlan_subif_t *mp;
9569 u8 sw_if_index_set = 0;
9574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9576 if (unformat (i, "sw_if_index %d", &sw_if_index))
9577 sw_if_index_set = 1;
9579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9580 sw_if_index_set = 1;
9581 else if (unformat (i, "vlan %d", &vlan_id))
9585 clib_warning ("parse error '%U'", format_unformat_error, i);
9590 if (sw_if_index_set == 0)
9592 errmsg ("missing interface name or sw_if_index");
9596 if (vlan_id_set == 0)
9598 errmsg ("missing vlan_id");
9601 M (CREATE_VLAN_SUBIF, mp);
9603 mp->sw_if_index = ntohl (sw_if_index);
9604 mp->vlan_id = ntohl (vlan_id);
9611 #define foreach_create_subif_bit \
9618 _(outer_vlan_id_any) \
9619 _(inner_vlan_id_any)
9622 api_create_subif (vat_main_t * vam)
9624 unformat_input_t *i = vam->input;
9625 vl_api_create_subif_t *mp;
9627 u8 sw_if_index_set = 0;
9634 u32 exact_match = 0;
9635 u32 default_sub = 0;
9636 u32 outer_vlan_id_any = 0;
9637 u32 inner_vlan_id_any = 0;
9639 u16 outer_vlan_id = 0;
9640 u16 inner_vlan_id = 0;
9643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9645 if (unformat (i, "sw_if_index %d", &sw_if_index))
9646 sw_if_index_set = 1;
9648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9649 sw_if_index_set = 1;
9650 else if (unformat (i, "sub_id %d", &sub_id))
9652 else if (unformat (i, "outer_vlan_id %d", &tmp))
9653 outer_vlan_id = tmp;
9654 else if (unformat (i, "inner_vlan_id %d", &tmp))
9655 inner_vlan_id = tmp;
9657 #define _(a) else if (unformat (i, #a)) a = 1 ;
9658 foreach_create_subif_bit
9662 clib_warning ("parse error '%U'", format_unformat_error, i);
9667 if (sw_if_index_set == 0)
9669 errmsg ("missing interface name or sw_if_index");
9673 if (sub_id_set == 0)
9675 errmsg ("missing sub_id");
9678 M (CREATE_SUBIF, mp);
9680 mp->sw_if_index = ntohl (sw_if_index);
9681 mp->sub_id = ntohl (sub_id);
9683 #define _(a) mp->a = a;
9684 foreach_create_subif_bit;
9687 mp->outer_vlan_id = ntohs (outer_vlan_id);
9688 mp->inner_vlan_id = ntohs (inner_vlan_id);
9696 api_oam_add_del (vat_main_t * vam)
9698 unformat_input_t *i = vam->input;
9699 vl_api_oam_add_del_t *mp;
9702 ip4_address_t src, dst;
9707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9709 if (unformat (i, "vrf %d", &vrf_id))
9711 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9713 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9715 else if (unformat (i, "del"))
9719 clib_warning ("parse error '%U'", format_unformat_error, i);
9726 errmsg ("missing src addr");
9732 errmsg ("missing dst addr");
9736 M (OAM_ADD_DEL, mp);
9738 mp->vrf_id = ntohl (vrf_id);
9739 mp->is_add = is_add;
9740 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9741 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9749 api_reset_fib (vat_main_t * vam)
9751 unformat_input_t *i = vam->input;
9752 vl_api_reset_fib_t *mp;
9758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9760 if (unformat (i, "vrf %d", &vrf_id))
9762 else if (unformat (i, "ipv6"))
9766 clib_warning ("parse error '%U'", format_unformat_error, i);
9771 if (vrf_id_set == 0)
9773 errmsg ("missing vrf id");
9779 mp->vrf_id = ntohl (vrf_id);
9780 mp->is_ipv6 = is_ipv6;
9788 api_dhcp_proxy_config (vat_main_t * vam)
9790 unformat_input_t *i = vam->input;
9791 vl_api_dhcp_proxy_config_t *mp;
9793 u32 server_vrf_id = 0;
9795 u8 v4_address_set = 0;
9796 u8 v6_address_set = 0;
9797 ip4_address_t v4address;
9798 ip6_address_t v6address;
9799 u8 v4_src_address_set = 0;
9800 u8 v6_src_address_set = 0;
9801 ip4_address_t v4srcaddress;
9802 ip6_address_t v6srcaddress;
9805 /* Parse args required to build the message */
9806 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9808 if (unformat (i, "del"))
9810 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9812 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9814 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9816 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9818 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9819 v4_src_address_set = 1;
9820 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9821 v6_src_address_set = 1;
9826 if (v4_address_set && v6_address_set)
9828 errmsg ("both v4 and v6 server addresses set");
9831 if (!v4_address_set && !v6_address_set)
9833 errmsg ("no server addresses set");
9837 if (v4_src_address_set && v6_src_address_set)
9839 errmsg ("both v4 and v6 src addresses set");
9842 if (!v4_src_address_set && !v6_src_address_set)
9844 errmsg ("no src addresses set");
9848 if (!(v4_src_address_set && v4_address_set) &&
9849 !(v6_src_address_set && v6_address_set))
9851 errmsg ("no matching server and src addresses set");
9855 /* Construct the API message */
9856 M (DHCP_PROXY_CONFIG, mp);
9858 mp->is_add = is_add;
9859 mp->rx_vrf_id = ntohl (rx_vrf_id);
9860 mp->server_vrf_id = ntohl (server_vrf_id);
9864 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9865 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9869 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9870 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9876 /* Wait for a reply, return good/bad news */
9881 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9882 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9885 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9887 vat_main_t *vam = &vat_main;
9888 u32 i, count = mp->count;
9889 vl_api_dhcp_server_t *s;
9893 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9894 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9895 ntohl (mp->rx_vrf_id),
9896 format_ip6_address, mp->dhcp_src_address,
9897 mp->vss_type, mp->vss_vpn_ascii_id,
9898 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9901 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9902 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9903 ntohl (mp->rx_vrf_id),
9904 format_ip4_address, mp->dhcp_src_address,
9905 mp->vss_type, mp->vss_vpn_ascii_id,
9906 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9908 for (i = 0; i < count; i++)
9910 s = &mp->servers[i];
9914 " Server Table-ID %d, Server Address %U",
9915 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9918 " Server Table-ID %d, Server Address %U",
9919 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9923 static void vl_api_dhcp_proxy_details_t_handler_json
9924 (vl_api_dhcp_proxy_details_t * mp)
9926 vat_main_t *vam = &vat_main;
9927 vat_json_node_t *node = NULL;
9928 u32 i, count = mp->count;
9930 struct in6_addr ip6;
9931 vl_api_dhcp_server_t *s;
9933 if (VAT_JSON_ARRAY != vam->json_tree.type)
9935 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9936 vat_json_init_array (&vam->json_tree);
9938 node = vat_json_array_add (&vam->json_tree);
9940 vat_json_init_object (node);
9941 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9942 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9943 sizeof (mp->vss_type));
9944 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9945 mp->vss_vpn_ascii_id);
9946 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9947 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9951 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9952 vat_json_object_add_ip6 (node, "src_address", ip6);
9956 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9957 vat_json_object_add_ip4 (node, "src_address", ip4);
9960 for (i = 0; i < count; i++)
9962 s = &mp->servers[i];
9964 vat_json_object_add_uint (node, "server-table-id",
9965 ntohl (s->server_vrf_id));
9969 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9970 vat_json_object_add_ip4 (node, "src_address", ip4);
9974 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9975 vat_json_object_add_ip6 (node, "server_address", ip6);
9981 api_dhcp_proxy_dump (vat_main_t * vam)
9983 unformat_input_t *i = vam->input;
9984 vl_api_control_ping_t *mp_ping;
9985 vl_api_dhcp_proxy_dump_t *mp;
9989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9991 if (unformat (i, "ipv6"))
9995 clib_warning ("parse error '%U'", format_unformat_error, i);
10000 M (DHCP_PROXY_DUMP, mp);
10002 mp->is_ip6 = is_ipv6;
10005 /* Use a control ping for synchronization */
10006 MPING (CONTROL_PING, mp_ping);
10014 api_dhcp_proxy_set_vss (vat_main_t * vam)
10016 unformat_input_t *i = vam->input;
10017 vl_api_dhcp_proxy_set_vss_t *mp;
10021 u8 vss_type = VSS_TYPE_DEFAULT;
10022 u8 *vpn_ascii_id = 0;
10027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10029 if (unformat (i, "tbl_id %d", &tbl_id))
10031 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10032 vss_type = VSS_TYPE_ASCII;
10033 else if (unformat (i, "fib_id %d", &fib_id))
10034 vss_type = VSS_TYPE_VPN_ID;
10035 else if (unformat (i, "oui %d", &oui))
10036 vss_type = VSS_TYPE_VPN_ID;
10037 else if (unformat (i, "ipv6"))
10039 else if (unformat (i, "del"))
10047 errmsg ("missing tbl_id ");
10048 vec_free (vpn_ascii_id);
10052 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10054 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10055 vec_free (vpn_ascii_id);
10059 M (DHCP_PROXY_SET_VSS, mp);
10060 mp->tbl_id = ntohl (tbl_id);
10061 mp->vss_type = vss_type;
10064 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10065 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10067 mp->vpn_index = ntohl (fib_id);
10068 mp->oui = ntohl (oui);
10069 mp->is_ipv6 = is_ipv6;
10070 mp->is_add = is_add;
10075 vec_free (vpn_ascii_id);
10080 api_dhcp_client_config (vat_main_t * vam)
10082 unformat_input_t *i = vam->input;
10083 vl_api_dhcp_client_config_t *mp;
10085 u8 sw_if_index_set = 0;
10088 u8 disable_event = 0;
10091 /* Parse args required to build the message */
10092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10094 if (unformat (i, "del"))
10097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10098 sw_if_index_set = 1;
10099 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10100 sw_if_index_set = 1;
10101 else if (unformat (i, "hostname %s", &hostname))
10103 else if (unformat (i, "disable_event"))
10109 if (sw_if_index_set == 0)
10111 errmsg ("missing interface name or sw_if_index");
10115 if (vec_len (hostname) > 63)
10117 errmsg ("hostname too long");
10119 vec_add1 (hostname, 0);
10121 /* Construct the API message */
10122 M (DHCP_CLIENT_CONFIG, mp);
10124 mp->sw_if_index = htonl (sw_if_index);
10125 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
10126 vec_free (hostname);
10127 mp->is_add = is_add;
10128 mp->want_dhcp_event = disable_event ? 0 : 1;
10129 mp->pid = htonl (getpid ());
10134 /* Wait for a reply, return good/bad news */
10140 api_set_ip_flow_hash (vat_main_t * vam)
10142 unformat_input_t *i = vam->input;
10143 vl_api_set_ip_flow_hash_t *mp;
10155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10157 if (unformat (i, "vrf %d", &vrf_id))
10159 else if (unformat (i, "ipv6"))
10161 else if (unformat (i, "src"))
10163 else if (unformat (i, "dst"))
10165 else if (unformat (i, "sport"))
10167 else if (unformat (i, "dport"))
10169 else if (unformat (i, "proto"))
10171 else if (unformat (i, "reverse"))
10176 clib_warning ("parse error '%U'", format_unformat_error, i);
10181 if (vrf_id_set == 0)
10183 errmsg ("missing vrf id");
10187 M (SET_IP_FLOW_HASH, mp);
10193 mp->reverse = reverse;
10194 mp->vrf_id = ntohl (vrf_id);
10195 mp->is_ipv6 = is_ipv6;
10203 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10205 unformat_input_t *i = vam->input;
10206 vl_api_sw_interface_ip6_enable_disable_t *mp;
10208 u8 sw_if_index_set = 0;
10212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10215 sw_if_index_set = 1;
10216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10217 sw_if_index_set = 1;
10218 else if (unformat (i, "enable"))
10220 else if (unformat (i, "disable"))
10224 clib_warning ("parse error '%U'", format_unformat_error, i);
10229 if (sw_if_index_set == 0)
10231 errmsg ("missing interface name or sw_if_index");
10235 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10237 mp->sw_if_index = ntohl (sw_if_index);
10238 mp->enable = enable;
10246 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10248 unformat_input_t *i = vam->input;
10249 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10251 u8 sw_if_index_set = 0;
10252 u8 v6_address_set = 0;
10253 ip6_address_t v6address;
10256 /* Parse args required to build the message */
10257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10260 sw_if_index_set = 1;
10261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10262 sw_if_index_set = 1;
10263 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10264 v6_address_set = 1;
10269 if (sw_if_index_set == 0)
10271 errmsg ("missing interface name or sw_if_index");
10274 if (!v6_address_set)
10276 errmsg ("no address set");
10280 /* Construct the API message */
10281 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10283 mp->sw_if_index = ntohl (sw_if_index);
10284 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10289 /* Wait for a reply, return good/bad news */
10295 api_ip6nd_proxy_add_del (vat_main_t * vam)
10297 unformat_input_t *i = vam->input;
10298 vl_api_ip6nd_proxy_add_del_t *mp;
10299 u32 sw_if_index = ~0;
10300 u8 v6_address_set = 0;
10301 ip6_address_t v6address;
10305 /* Parse args required to build the message */
10306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10308 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10310 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10312 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10313 v6_address_set = 1;
10314 if (unformat (i, "del"))
10318 clib_warning ("parse error '%U'", format_unformat_error, i);
10323 if (sw_if_index == ~0)
10325 errmsg ("missing interface name or sw_if_index");
10328 if (!v6_address_set)
10330 errmsg ("no address set");
10334 /* Construct the API message */
10335 M (IP6ND_PROXY_ADD_DEL, mp);
10337 mp->is_del = is_del;
10338 mp->sw_if_index = ntohl (sw_if_index);
10339 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10344 /* Wait for a reply, return good/bad news */
10350 api_ip6nd_proxy_dump (vat_main_t * vam)
10352 vl_api_ip6nd_proxy_dump_t *mp;
10353 vl_api_control_ping_t *mp_ping;
10356 M (IP6ND_PROXY_DUMP, mp);
10360 /* Use a control ping for synchronization */
10361 MPING (CONTROL_PING, mp_ping);
10368 static void vl_api_ip6nd_proxy_details_t_handler
10369 (vl_api_ip6nd_proxy_details_t * mp)
10371 vat_main_t *vam = &vat_main;
10373 print (vam->ofp, "host %U sw_if_index %d",
10374 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10377 static void vl_api_ip6nd_proxy_details_t_handler_json
10378 (vl_api_ip6nd_proxy_details_t * mp)
10380 vat_main_t *vam = &vat_main;
10381 struct in6_addr ip6;
10382 vat_json_node_t *node = NULL;
10384 if (VAT_JSON_ARRAY != vam->json_tree.type)
10386 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10387 vat_json_init_array (&vam->json_tree);
10389 node = vat_json_array_add (&vam->json_tree);
10391 vat_json_init_object (node);
10392 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10394 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10395 vat_json_object_add_ip6 (node, "host", ip6);
10399 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10401 unformat_input_t *i = vam->input;
10402 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10404 u8 sw_if_index_set = 0;
10405 u32 address_length = 0;
10406 u8 v6_address_set = 0;
10407 ip6_address_t v6address;
10408 u8 use_default = 0;
10409 u8 no_advertise = 0;
10411 u8 no_autoconfig = 0;
10414 u32 val_lifetime = 0;
10415 u32 pref_lifetime = 0;
10418 /* Parse args required to build the message */
10419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10421 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10422 sw_if_index_set = 1;
10423 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10424 sw_if_index_set = 1;
10425 else if (unformat (i, "%U/%d",
10426 unformat_ip6_address, &v6address, &address_length))
10427 v6_address_set = 1;
10428 else if (unformat (i, "val_life %d", &val_lifetime))
10430 else if (unformat (i, "pref_life %d", &pref_lifetime))
10432 else if (unformat (i, "def"))
10434 else if (unformat (i, "noadv"))
10436 else if (unformat (i, "offl"))
10438 else if (unformat (i, "noauto"))
10440 else if (unformat (i, "nolink"))
10442 else if (unformat (i, "isno"))
10446 clib_warning ("parse error '%U'", format_unformat_error, i);
10451 if (sw_if_index_set == 0)
10453 errmsg ("missing interface name or sw_if_index");
10456 if (!v6_address_set)
10458 errmsg ("no address set");
10462 /* Construct the API message */
10463 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10465 mp->sw_if_index = ntohl (sw_if_index);
10466 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10467 mp->address_length = address_length;
10468 mp->use_default = use_default;
10469 mp->no_advertise = no_advertise;
10470 mp->off_link = off_link;
10471 mp->no_autoconfig = no_autoconfig;
10472 mp->no_onlink = no_onlink;
10474 mp->val_lifetime = ntohl (val_lifetime);
10475 mp->pref_lifetime = ntohl (pref_lifetime);
10480 /* Wait for a reply, return good/bad news */
10486 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10488 unformat_input_t *i = vam->input;
10489 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10491 u8 sw_if_index_set = 0;
10496 u8 send_unicast = 0;
10499 u8 default_router = 0;
10500 u32 max_interval = 0;
10501 u32 min_interval = 0;
10503 u32 initial_count = 0;
10504 u32 initial_interval = 0;
10508 /* Parse args required to build the message */
10509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10512 sw_if_index_set = 1;
10513 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10514 sw_if_index_set = 1;
10515 else if (unformat (i, "maxint %d", &max_interval))
10517 else if (unformat (i, "minint %d", &min_interval))
10519 else if (unformat (i, "life %d", &lifetime))
10521 else if (unformat (i, "count %d", &initial_count))
10523 else if (unformat (i, "interval %d", &initial_interval))
10525 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10527 else if (unformat (i, "managed"))
10529 else if (unformat (i, "other"))
10531 else if (unformat (i, "ll"))
10533 else if (unformat (i, "send"))
10535 else if (unformat (i, "cease"))
10537 else if (unformat (i, "isno"))
10539 else if (unformat (i, "def"))
10540 default_router = 1;
10543 clib_warning ("parse error '%U'", format_unformat_error, i);
10548 if (sw_if_index_set == 0)
10550 errmsg ("missing interface name or sw_if_index");
10554 /* Construct the API message */
10555 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10557 mp->sw_if_index = ntohl (sw_if_index);
10558 mp->max_interval = ntohl (max_interval);
10559 mp->min_interval = ntohl (min_interval);
10560 mp->lifetime = ntohl (lifetime);
10561 mp->initial_count = ntohl (initial_count);
10562 mp->initial_interval = ntohl (initial_interval);
10563 mp->suppress = suppress;
10564 mp->managed = managed;
10566 mp->ll_option = ll_option;
10567 mp->send_unicast = send_unicast;
10570 mp->default_router = default_router;
10575 /* Wait for a reply, return good/bad news */
10581 api_set_arp_neighbor_limit (vat_main_t * vam)
10583 unformat_input_t *i = vam->input;
10584 vl_api_set_arp_neighbor_limit_t *mp;
10590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10592 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10594 else if (unformat (i, "ipv6"))
10598 clib_warning ("parse error '%U'", format_unformat_error, i);
10603 if (limit_set == 0)
10605 errmsg ("missing limit value");
10609 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10611 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10612 mp->is_ipv6 = is_ipv6;
10620 api_l2_patch_add_del (vat_main_t * vam)
10622 unformat_input_t *i = vam->input;
10623 vl_api_l2_patch_add_del_t *mp;
10624 u32 rx_sw_if_index;
10625 u8 rx_sw_if_index_set = 0;
10626 u32 tx_sw_if_index;
10627 u8 tx_sw_if_index_set = 0;
10631 /* Parse args required to build the message */
10632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10634 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10635 rx_sw_if_index_set = 1;
10636 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10637 tx_sw_if_index_set = 1;
10638 else if (unformat (i, "rx"))
10640 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10642 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10644 rx_sw_if_index_set = 1;
10649 else if (unformat (i, "tx"))
10651 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10653 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10655 tx_sw_if_index_set = 1;
10660 else if (unformat (i, "del"))
10666 if (rx_sw_if_index_set == 0)
10668 errmsg ("missing rx interface name or rx_sw_if_index");
10672 if (tx_sw_if_index_set == 0)
10674 errmsg ("missing tx interface name or tx_sw_if_index");
10678 M (L2_PATCH_ADD_DEL, mp);
10680 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10681 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10682 mp->is_add = is_add;
10690 u8 localsid_addr[16];
10699 api_sr_localsid_add_del (vat_main_t * vam)
10701 unformat_input_t *i = vam->input;
10702 vl_api_sr_localsid_add_del_t *mp;
10705 ip6_address_t localsid;
10709 u32 fib_table = ~(u32) 0;
10710 ip6_address_t next_hop;
10712 bool nexthop_set = 0;
10716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10718 if (unformat (i, "del"))
10720 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10721 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10723 else if (unformat (i, "behavior %u", &behavior));
10724 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10725 else if (unformat (i, "fib-table %u", &fib_table));
10726 else if (unformat (i, "end.psp %u", &behavior));
10731 M (SR_LOCALSID_ADD_DEL, mp);
10733 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10735 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10736 mp->behavior = behavior;
10737 mp->sw_if_index = ntohl (sw_if_index);
10738 mp->fib_table = ntohl (fib_table);
10739 mp->end_psp = end_psp;
10740 mp->is_del = is_del;
10748 api_ioam_enable (vat_main_t * vam)
10750 unformat_input_t *input = vam->input;
10751 vl_api_ioam_enable_t *mp;
10753 int has_trace_option = 0;
10754 int has_pot_option = 0;
10755 int has_seqno_option = 0;
10756 int has_analyse_option = 0;
10759 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10761 if (unformat (input, "trace"))
10762 has_trace_option = 1;
10763 else if (unformat (input, "pot"))
10764 has_pot_option = 1;
10765 else if (unformat (input, "seqno"))
10766 has_seqno_option = 1;
10767 else if (unformat (input, "analyse"))
10768 has_analyse_option = 1;
10772 M (IOAM_ENABLE, mp);
10773 mp->id = htons (id);
10774 mp->seqno = has_seqno_option;
10775 mp->analyse = has_analyse_option;
10776 mp->pot_enable = has_pot_option;
10777 mp->trace_enable = has_trace_option;
10786 api_ioam_disable (vat_main_t * vam)
10788 vl_api_ioam_disable_t *mp;
10791 M (IOAM_DISABLE, mp);
10797 #define foreach_tcp_proto_field \
10801 #define foreach_udp_proto_field \
10805 #define foreach_ip4_proto_field \
10817 u16 src_port, dst_port;
10820 #if VPP_API_TEST_BUILTIN == 0
10822 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10824 u8 **maskp = va_arg (*args, u8 **);
10826 u8 found_something = 0;
10829 #define _(a) u8 a=0;
10830 foreach_tcp_proto_field;
10833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10836 #define _(a) else if (unformat (input, #a)) a=1;
10837 foreach_tcp_proto_field
10843 #define _(a) found_something += a;
10844 foreach_tcp_proto_field;
10847 if (found_something == 0)
10850 vec_validate (mask, sizeof (*tcp) - 1);
10852 tcp = (tcp_header_t *) mask;
10854 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10855 foreach_tcp_proto_field;
10863 unformat_udp_mask (unformat_input_t * input, va_list * args)
10865 u8 **maskp = va_arg (*args, u8 **);
10867 u8 found_something = 0;
10870 #define _(a) u8 a=0;
10871 foreach_udp_proto_field;
10874 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10877 #define _(a) else if (unformat (input, #a)) a=1;
10878 foreach_udp_proto_field
10884 #define _(a) found_something += a;
10885 foreach_udp_proto_field;
10888 if (found_something == 0)
10891 vec_validate (mask, sizeof (*udp) - 1);
10893 udp = (udp_header_t *) mask;
10895 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10896 foreach_udp_proto_field;
10904 unformat_l4_mask (unformat_input_t * input, va_list * args)
10906 u8 **maskp = va_arg (*args, u8 **);
10907 u16 src_port = 0, dst_port = 0;
10908 tcpudp_header_t *tcpudp;
10910 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10912 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10914 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10916 else if (unformat (input, "src_port"))
10918 else if (unformat (input, "dst_port"))
10924 if (!src_port && !dst_port)
10928 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10930 tcpudp = (tcpudp_header_t *) mask;
10931 tcpudp->src_port = src_port;
10932 tcpudp->dst_port = dst_port;
10940 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10942 u8 **maskp = va_arg (*args, u8 **);
10944 u8 found_something = 0;
10947 #define _(a) u8 a=0;
10948 foreach_ip4_proto_field;
10954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10956 if (unformat (input, "version"))
10958 else if (unformat (input, "hdr_length"))
10960 else if (unformat (input, "src"))
10962 else if (unformat (input, "dst"))
10964 else if (unformat (input, "proto"))
10967 #define _(a) else if (unformat (input, #a)) a=1;
10968 foreach_ip4_proto_field
10974 #define _(a) found_something += a;
10975 foreach_ip4_proto_field;
10978 if (found_something == 0)
10981 vec_validate (mask, sizeof (*ip) - 1);
10983 ip = (ip4_header_t *) mask;
10985 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10986 foreach_ip4_proto_field;
10989 ip->ip_version_and_header_length = 0;
10992 ip->ip_version_and_header_length |= 0xF0;
10995 ip->ip_version_and_header_length |= 0x0F;
11001 #define foreach_ip6_proto_field \
11004 _(payload_length) \
11009 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11011 u8 **maskp = va_arg (*args, u8 **);
11013 u8 found_something = 0;
11015 u32 ip_version_traffic_class_and_flow_label;
11017 #define _(a) u8 a=0;
11018 foreach_ip6_proto_field;
11021 u8 traffic_class = 0;
11024 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11026 if (unformat (input, "version"))
11028 else if (unformat (input, "traffic-class"))
11030 else if (unformat (input, "flow-label"))
11032 else if (unformat (input, "src"))
11034 else if (unformat (input, "dst"))
11036 else if (unformat (input, "proto"))
11039 #define _(a) else if (unformat (input, #a)) a=1;
11040 foreach_ip6_proto_field
11046 #define _(a) found_something += a;
11047 foreach_ip6_proto_field;
11050 if (found_something == 0)
11053 vec_validate (mask, sizeof (*ip) - 1);
11055 ip = (ip6_header_t *) mask;
11057 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11058 foreach_ip6_proto_field;
11061 ip_version_traffic_class_and_flow_label = 0;
11064 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11067 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11070 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11072 ip->ip_version_traffic_class_and_flow_label =
11073 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11080 unformat_l3_mask (unformat_input_t * input, va_list * args)
11082 u8 **maskp = va_arg (*args, u8 **);
11084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11086 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11088 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11097 unformat_l2_mask (unformat_input_t * input, va_list * args)
11099 u8 **maskp = va_arg (*args, u8 **);
11106 u8 ignore_tag1 = 0;
11107 u8 ignore_tag2 = 0;
11114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11116 if (unformat (input, "src"))
11118 else if (unformat (input, "dst"))
11120 else if (unformat (input, "proto"))
11122 else if (unformat (input, "tag1"))
11124 else if (unformat (input, "tag2"))
11126 else if (unformat (input, "ignore-tag1"))
11128 else if (unformat (input, "ignore-tag2"))
11130 else if (unformat (input, "cos1"))
11132 else if (unformat (input, "cos2"))
11134 else if (unformat (input, "dot1q"))
11136 else if (unformat (input, "dot1ad"))
11141 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11142 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11145 if (tag1 || ignore_tag1 || cos1 || dot1q)
11147 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11150 vec_validate (mask, len - 1);
11153 memset (mask, 0xff, 6);
11156 memset (mask + 6, 0xff, 6);
11158 if (tag2 || dot1ad)
11160 /* inner vlan tag */
11169 mask[21] = mask[20] = 0xff;
11190 mask[16] = mask[17] = 0xff;
11200 mask[12] = mask[13] = 0xff;
11207 unformat_classify_mask (unformat_input_t * input, va_list * args)
11209 u8 **maskp = va_arg (*args, u8 **);
11210 u32 *skipp = va_arg (*args, u32 *);
11211 u32 *matchp = va_arg (*args, u32 *);
11219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11221 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11223 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11225 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11227 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11241 if (mask || l2 || l3 || l4)
11243 if (l2 || l3 || l4)
11245 /* "With a free Ethernet header in every package" */
11247 vec_validate (l2, 13);
11251 vec_append (mask, l3);
11256 vec_append (mask, l4);
11261 /* Scan forward looking for the first significant mask octet */
11262 for (i = 0; i < vec_len (mask); i++)
11266 /* compute (skip, match) params */
11267 *skipp = i / sizeof (u32x4);
11268 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11270 /* Pad mask to an even multiple of the vector size */
11271 while (vec_len (mask) % sizeof (u32x4))
11272 vec_add1 (mask, 0);
11274 match = vec_len (mask) / sizeof (u32x4);
11276 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11278 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11279 if (*tmp || *(tmp + 1))
11284 clib_warning ("BUG: match 0");
11286 _vec_len (mask) = match * sizeof (u32x4);
11296 #endif /* VPP_API_TEST_BUILTIN */
11298 #define foreach_l2_next \
11300 _(ethernet, ETHERNET_INPUT) \
11301 _(ip4, IP4_INPUT) \
11305 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11307 u32 *miss_next_indexp = va_arg (*args, u32 *);
11308 u32 next_index = 0;
11312 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11316 if (unformat (input, "%d", &tmp))
11325 *miss_next_indexp = next_index;
11329 #define foreach_ip_next \
11332 _(rewrite, REWRITE)
11335 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11337 u32 *miss_next_indexp = va_arg (*args, u32 *);
11338 u32 next_index = 0;
11342 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11346 if (unformat (input, "%d", &tmp))
11355 *miss_next_indexp = next_index;
11359 #define foreach_acl_next \
11363 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11365 u32 *miss_next_indexp = va_arg (*args, u32 *);
11366 u32 next_index = 0;
11370 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11374 if (unformat (input, "permit"))
11379 else if (unformat (input, "%d", &tmp))
11388 *miss_next_indexp = next_index;
11393 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11395 u32 *r = va_arg (*args, u32 *);
11397 if (unformat (input, "conform-color"))
11398 *r = POLICE_CONFORM;
11399 else if (unformat (input, "exceed-color"))
11400 *r = POLICE_EXCEED;
11408 api_classify_add_del_table (vat_main_t * vam)
11410 unformat_input_t *i = vam->input;
11411 vl_api_classify_add_del_table_t *mp;
11418 u32 table_index = ~0;
11419 u32 next_table_index = ~0;
11420 u32 miss_next_index = ~0;
11421 u32 memory_size = 32 << 20;
11423 u32 current_data_flag = 0;
11424 int current_data_offset = 0;
11427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11429 if (unformat (i, "del"))
11431 else if (unformat (i, "del-chain"))
11436 else if (unformat (i, "buckets %d", &nbuckets))
11438 else if (unformat (i, "memory_size %d", &memory_size))
11440 else if (unformat (i, "skip %d", &skip))
11442 else if (unformat (i, "match %d", &match))
11444 else if (unformat (i, "table %d", &table_index))
11446 else if (unformat (i, "mask %U", unformat_classify_mask,
11447 &mask, &skip, &match))
11449 else if (unformat (i, "next-table %d", &next_table_index))
11451 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11454 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11457 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11460 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11462 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11468 if (is_add && mask == 0)
11470 errmsg ("Mask required");
11474 if (is_add && skip == ~0)
11476 errmsg ("skip count required");
11480 if (is_add && match == ~0)
11482 errmsg ("match count required");
11486 if (!is_add && table_index == ~0)
11488 errmsg ("table index required for delete");
11492 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11494 mp->is_add = is_add;
11495 mp->del_chain = del_chain;
11496 mp->table_index = ntohl (table_index);
11497 mp->nbuckets = ntohl (nbuckets);
11498 mp->memory_size = ntohl (memory_size);
11499 mp->skip_n_vectors = ntohl (skip);
11500 mp->match_n_vectors = ntohl (match);
11501 mp->next_table_index = ntohl (next_table_index);
11502 mp->miss_next_index = ntohl (miss_next_index);
11503 mp->current_data_flag = ntohl (current_data_flag);
11504 mp->current_data_offset = ntohl (current_data_offset);
11505 clib_memcpy (mp->mask, mask, vec_len (mask));
11514 #if VPP_API_TEST_BUILTIN == 0
11516 unformat_l4_match (unformat_input_t * input, va_list * args)
11518 u8 **matchp = va_arg (*args, u8 **);
11520 u8 *proto_header = 0;
11526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11528 if (unformat (input, "src_port %d", &src_port))
11530 else if (unformat (input, "dst_port %d", &dst_port))
11536 h.src_port = clib_host_to_net_u16 (src_port);
11537 h.dst_port = clib_host_to_net_u16 (dst_port);
11538 vec_validate (proto_header, sizeof (h) - 1);
11539 memcpy (proto_header, &h, sizeof (h));
11541 *matchp = proto_header;
11547 unformat_ip4_match (unformat_input_t * input, va_list * args)
11549 u8 **matchp = va_arg (*args, u8 **);
11554 int hdr_length = 0;
11555 u32 hdr_length_val;
11556 int src = 0, dst = 0;
11557 ip4_address_t src_val, dst_val;
11564 int fragment_id = 0;
11565 u32 fragment_id_val;
11571 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11573 if (unformat (input, "version %d", &version_val))
11575 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11577 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11579 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11581 else if (unformat (input, "proto %d", &proto_val))
11583 else if (unformat (input, "tos %d", &tos_val))
11585 else if (unformat (input, "length %d", &length_val))
11587 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11589 else if (unformat (input, "ttl %d", &ttl_val))
11591 else if (unformat (input, "checksum %d", &checksum_val))
11597 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11598 + ttl + checksum == 0)
11602 * Aligned because we use the real comparison functions
11604 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11606 ip = (ip4_header_t *) match;
11608 /* These are realistically matched in practice */
11610 ip->src_address.as_u32 = src_val.as_u32;
11613 ip->dst_address.as_u32 = dst_val.as_u32;
11616 ip->protocol = proto_val;
11619 /* These are not, but they're included for completeness */
11621 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11624 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11630 ip->length = clib_host_to_net_u16 (length_val);
11636 ip->checksum = clib_host_to_net_u16 (checksum_val);
11643 unformat_ip6_match (unformat_input_t * input, va_list * args)
11645 u8 **matchp = va_arg (*args, u8 **);
11650 u8 traffic_class = 0;
11651 u32 traffic_class_val = 0;
11654 int src = 0, dst = 0;
11655 ip6_address_t src_val, dst_val;
11658 int payload_length = 0;
11659 u32 payload_length_val;
11662 u32 ip_version_traffic_class_and_flow_label;
11664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11666 if (unformat (input, "version %d", &version_val))
11668 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11670 else if (unformat (input, "flow_label %d", &flow_label_val))
11672 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11674 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11676 else if (unformat (input, "proto %d", &proto_val))
11678 else if (unformat (input, "payload_length %d", &payload_length_val))
11679 payload_length = 1;
11680 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11686 if (version + traffic_class + flow_label + src + dst + proto +
11687 payload_length + hop_limit == 0)
11691 * Aligned because we use the real comparison functions
11693 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11695 ip = (ip6_header_t *) match;
11698 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11701 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11704 ip->protocol = proto_val;
11706 ip_version_traffic_class_and_flow_label = 0;
11709 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11712 ip_version_traffic_class_and_flow_label |=
11713 (traffic_class_val & 0xFF) << 20;
11716 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11718 ip->ip_version_traffic_class_and_flow_label =
11719 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11721 if (payload_length)
11722 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11725 ip->hop_limit = hop_limit_val;
11732 unformat_l3_match (unformat_input_t * input, va_list * args)
11734 u8 **matchp = va_arg (*args, u8 **);
11736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11738 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11740 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11749 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11751 u8 *tagp = va_arg (*args, u8 *);
11754 if (unformat (input, "%d", &tag))
11756 tagp[0] = (tag >> 8) & 0x0F;
11757 tagp[1] = tag & 0xFF;
11765 unformat_l2_match (unformat_input_t * input, va_list * args)
11767 u8 **matchp = va_arg (*args, u8 **);
11780 u8 ignore_tag1 = 0;
11781 u8 ignore_tag2 = 0;
11787 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11789 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11792 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11794 else if (unformat (input, "proto %U",
11795 unformat_ethernet_type_host_byte_order, &proto_val))
11797 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11799 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11801 else if (unformat (input, "ignore-tag1"))
11803 else if (unformat (input, "ignore-tag2"))
11805 else if (unformat (input, "cos1 %d", &cos1_val))
11807 else if (unformat (input, "cos2 %d", &cos2_val))
11812 if ((src + dst + proto + tag1 + tag2 +
11813 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11816 if (tag1 || ignore_tag1 || cos1)
11818 if (tag2 || ignore_tag2 || cos2)
11821 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11824 clib_memcpy (match, dst_val, 6);
11827 clib_memcpy (match + 6, src_val, 6);
11831 /* inner vlan tag */
11832 match[19] = tag2_val[1];
11833 match[18] = tag2_val[0];
11835 match[18] |= (cos2_val & 0x7) << 5;
11838 match[21] = proto_val & 0xff;
11839 match[20] = proto_val >> 8;
11843 match[15] = tag1_val[1];
11844 match[14] = tag1_val[0];
11847 match[14] |= (cos1_val & 0x7) << 5;
11853 match[15] = tag1_val[1];
11854 match[14] = tag1_val[0];
11857 match[17] = proto_val & 0xff;
11858 match[16] = proto_val >> 8;
11861 match[14] |= (cos1_val & 0x7) << 5;
11867 match[18] |= (cos2_val & 0x7) << 5;
11869 match[14] |= (cos1_val & 0x7) << 5;
11872 match[13] = proto_val & 0xff;
11873 match[12] = proto_val >> 8;
11881 unformat_qos_source (unformat_input_t * input, va_list * args)
11883 int *qs = va_arg (*args, int *);
11885 if (unformat (input, "ip"))
11886 *qs = QOS_SOURCE_IP;
11887 else if (unformat (input, "mpls"))
11888 *qs = QOS_SOURCE_MPLS;
11889 else if (unformat (input, "ext"))
11890 *qs = QOS_SOURCE_EXT;
11891 else if (unformat (input, "vlan"))
11892 *qs = QOS_SOURCE_VLAN;
11901 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11903 u8 **matchp = va_arg (*args, u8 **);
11904 u32 skip_n_vectors = va_arg (*args, u32);
11905 u32 match_n_vectors = va_arg (*args, u32);
11912 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11914 if (unformat (input, "hex %U", unformat_hex_string, &match))
11916 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11918 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11920 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11934 if (match || l2 || l3 || l4)
11936 if (l2 || l3 || l4)
11938 /* "Win a free Ethernet header in every packet" */
11940 vec_validate_aligned (l2, 13, sizeof (u32x4));
11944 vec_append_aligned (match, l3, sizeof (u32x4));
11949 vec_append_aligned (match, l4, sizeof (u32x4));
11954 /* Make sure the vector is big enough even if key is all 0's */
11955 vec_validate_aligned
11956 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11959 /* Set size, include skipped vectors */
11960 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11971 api_classify_add_del_session (vat_main_t * vam)
11973 unformat_input_t *i = vam->input;
11974 vl_api_classify_add_del_session_t *mp;
11976 u32 table_index = ~0;
11977 u32 hit_next_index = ~0;
11978 u32 opaque_index = ~0;
11981 u32 skip_n_vectors = 0;
11982 u32 match_n_vectors = 0;
11988 * Warning: you have to supply skip_n and match_n
11989 * because the API client cant simply look at the classify
11993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11995 if (unformat (i, "del"))
11997 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12000 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12003 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12006 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12008 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12010 else if (unformat (i, "opaque-index %d", &opaque_index))
12012 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12014 else if (unformat (i, "match_n %d", &match_n_vectors))
12016 else if (unformat (i, "match %U", api_unformat_classify_match,
12017 &match, skip_n_vectors, match_n_vectors))
12019 else if (unformat (i, "advance %d", &advance))
12021 else if (unformat (i, "table-index %d", &table_index))
12023 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12025 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12027 else if (unformat (i, "action %d", &action))
12029 else if (unformat (i, "metadata %d", &metadata))
12035 if (table_index == ~0)
12037 errmsg ("Table index required");
12041 if (is_add && match == 0)
12043 errmsg ("Match value required");
12047 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12049 mp->is_add = is_add;
12050 mp->table_index = ntohl (table_index);
12051 mp->hit_next_index = ntohl (hit_next_index);
12052 mp->opaque_index = ntohl (opaque_index);
12053 mp->advance = ntohl (advance);
12054 mp->action = action;
12055 mp->metadata = ntohl (metadata);
12056 clib_memcpy (mp->match, match, vec_len (match));
12065 api_classify_set_interface_ip_table (vat_main_t * vam)
12067 unformat_input_t *i = vam->input;
12068 vl_api_classify_set_interface_ip_table_t *mp;
12070 int sw_if_index_set;
12071 u32 table_index = ~0;
12075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12077 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12078 sw_if_index_set = 1;
12079 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12080 sw_if_index_set = 1;
12081 else if (unformat (i, "table %d", &table_index))
12085 clib_warning ("parse error '%U'", format_unformat_error, i);
12090 if (sw_if_index_set == 0)
12092 errmsg ("missing interface name or sw_if_index");
12097 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12099 mp->sw_if_index = ntohl (sw_if_index);
12100 mp->table_index = ntohl (table_index);
12101 mp->is_ipv6 = is_ipv6;
12109 api_classify_set_interface_l2_tables (vat_main_t * vam)
12111 unformat_input_t *i = vam->input;
12112 vl_api_classify_set_interface_l2_tables_t *mp;
12114 int sw_if_index_set;
12115 u32 ip4_table_index = ~0;
12116 u32 ip6_table_index = ~0;
12117 u32 other_table_index = ~0;
12121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12124 sw_if_index_set = 1;
12125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12126 sw_if_index_set = 1;
12127 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12129 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12131 else if (unformat (i, "other-table %d", &other_table_index))
12133 else if (unformat (i, "is-input %d", &is_input))
12137 clib_warning ("parse error '%U'", format_unformat_error, i);
12142 if (sw_if_index_set == 0)
12144 errmsg ("missing interface name or sw_if_index");
12149 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12151 mp->sw_if_index = ntohl (sw_if_index);
12152 mp->ip4_table_index = ntohl (ip4_table_index);
12153 mp->ip6_table_index = ntohl (ip6_table_index);
12154 mp->other_table_index = ntohl (other_table_index);
12155 mp->is_input = (u8) is_input;
12163 api_set_ipfix_exporter (vat_main_t * vam)
12165 unformat_input_t *i = vam->input;
12166 vl_api_set_ipfix_exporter_t *mp;
12167 ip4_address_t collector_address;
12168 u8 collector_address_set = 0;
12169 u32 collector_port = ~0;
12170 ip4_address_t src_address;
12171 u8 src_address_set = 0;
12174 u32 template_interval = ~0;
12175 u8 udp_checksum = 0;
12178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12180 if (unformat (i, "collector_address %U", unformat_ip4_address,
12181 &collector_address))
12182 collector_address_set = 1;
12183 else if (unformat (i, "collector_port %d", &collector_port))
12185 else if (unformat (i, "src_address %U", unformat_ip4_address,
12187 src_address_set = 1;
12188 else if (unformat (i, "vrf_id %d", &vrf_id))
12190 else if (unformat (i, "path_mtu %d", &path_mtu))
12192 else if (unformat (i, "template_interval %d", &template_interval))
12194 else if (unformat (i, "udp_checksum"))
12200 if (collector_address_set == 0)
12202 errmsg ("collector_address required");
12206 if (src_address_set == 0)
12208 errmsg ("src_address required");
12212 M (SET_IPFIX_EXPORTER, mp);
12214 memcpy (mp->collector_address, collector_address.data,
12215 sizeof (collector_address.data));
12216 mp->collector_port = htons ((u16) collector_port);
12217 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12218 mp->vrf_id = htonl (vrf_id);
12219 mp->path_mtu = htonl (path_mtu);
12220 mp->template_interval = htonl (template_interval);
12221 mp->udp_checksum = udp_checksum;
12229 api_set_ipfix_classify_stream (vat_main_t * vam)
12231 unformat_input_t *i = vam->input;
12232 vl_api_set_ipfix_classify_stream_t *mp;
12234 u32 src_port = UDP_DST_PORT_ipfix;
12237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12239 if (unformat (i, "domain %d", &domain_id))
12241 else if (unformat (i, "src_port %d", &src_port))
12245 errmsg ("unknown input `%U'", format_unformat_error, i);
12250 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12252 mp->domain_id = htonl (domain_id);
12253 mp->src_port = htons ((u16) src_port);
12261 api_ipfix_classify_table_add_del (vat_main_t * vam)
12263 unformat_input_t *i = vam->input;
12264 vl_api_ipfix_classify_table_add_del_t *mp;
12266 u32 classify_table_index = ~0;
12268 u8 transport_protocol = 255;
12271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12273 if (unformat (i, "add"))
12275 else if (unformat (i, "del"))
12277 else if (unformat (i, "table %d", &classify_table_index))
12279 else if (unformat (i, "ip4"))
12281 else if (unformat (i, "ip6"))
12283 else if (unformat (i, "tcp"))
12284 transport_protocol = 6;
12285 else if (unformat (i, "udp"))
12286 transport_protocol = 17;
12289 errmsg ("unknown input `%U'", format_unformat_error, i);
12296 errmsg ("expecting: add|del");
12299 if (classify_table_index == ~0)
12301 errmsg ("classifier table not specified");
12304 if (ip_version == 0)
12306 errmsg ("IP version not specified");
12310 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12312 mp->is_add = is_add;
12313 mp->table_id = htonl (classify_table_index);
12314 mp->ip_version = ip_version;
12315 mp->transport_protocol = transport_protocol;
12323 api_get_node_index (vat_main_t * vam)
12325 unformat_input_t *i = vam->input;
12326 vl_api_get_node_index_t *mp;
12330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12332 if (unformat (i, "node %s", &name))
12339 errmsg ("node name required");
12342 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12344 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12348 M (GET_NODE_INDEX, mp);
12349 clib_memcpy (mp->node_name, name, vec_len (name));
12358 api_get_next_index (vat_main_t * vam)
12360 unformat_input_t *i = vam->input;
12361 vl_api_get_next_index_t *mp;
12362 u8 *node_name = 0, *next_node_name = 0;
12365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12367 if (unformat (i, "node-name %s", &node_name))
12369 else if (unformat (i, "next-node-name %s", &next_node_name))
12373 if (node_name == 0)
12375 errmsg ("node name required");
12378 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12380 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12384 if (next_node_name == 0)
12386 errmsg ("next node name required");
12389 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12391 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12395 M (GET_NEXT_INDEX, mp);
12396 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12397 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12398 vec_free (node_name);
12399 vec_free (next_node_name);
12407 api_add_node_next (vat_main_t * vam)
12409 unformat_input_t *i = vam->input;
12410 vl_api_add_node_next_t *mp;
12415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12417 if (unformat (i, "node %s", &name))
12419 else if (unformat (i, "next %s", &next))
12426 errmsg ("node name required");
12429 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12431 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12436 errmsg ("next node required");
12439 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12441 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12445 M (ADD_NODE_NEXT, mp);
12446 clib_memcpy (mp->node_name, name, vec_len (name));
12447 clib_memcpy (mp->next_name, next, vec_len (next));
12457 api_l2tpv3_create_tunnel (vat_main_t * vam)
12459 unformat_input_t *i = vam->input;
12460 ip6_address_t client_address, our_address;
12461 int client_address_set = 0;
12462 int our_address_set = 0;
12463 u32 local_session_id = 0;
12464 u32 remote_session_id = 0;
12465 u64 local_cookie = 0;
12466 u64 remote_cookie = 0;
12467 u8 l2_sublayer_present = 0;
12468 vl_api_l2tpv3_create_tunnel_t *mp;
12471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12473 if (unformat (i, "client_address %U", unformat_ip6_address,
12475 client_address_set = 1;
12476 else if (unformat (i, "our_address %U", unformat_ip6_address,
12478 our_address_set = 1;
12479 else if (unformat (i, "local_session_id %d", &local_session_id))
12481 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12483 else if (unformat (i, "local_cookie %lld", &local_cookie))
12485 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12487 else if (unformat (i, "l2-sublayer-present"))
12488 l2_sublayer_present = 1;
12493 if (client_address_set == 0)
12495 errmsg ("client_address required");
12499 if (our_address_set == 0)
12501 errmsg ("our_address required");
12505 M (L2TPV3_CREATE_TUNNEL, mp);
12507 clib_memcpy (mp->client_address, client_address.as_u8,
12508 sizeof (mp->client_address));
12510 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12512 mp->local_session_id = ntohl (local_session_id);
12513 mp->remote_session_id = ntohl (remote_session_id);
12514 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12515 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12516 mp->l2_sublayer_present = l2_sublayer_present;
12525 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12527 unformat_input_t *i = vam->input;
12529 u8 sw_if_index_set = 0;
12530 u64 new_local_cookie = 0;
12531 u64 new_remote_cookie = 0;
12532 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12537 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12538 sw_if_index_set = 1;
12539 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12540 sw_if_index_set = 1;
12541 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12543 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12549 if (sw_if_index_set == 0)
12551 errmsg ("missing interface name or sw_if_index");
12555 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12557 mp->sw_if_index = ntohl (sw_if_index);
12558 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12559 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12567 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12569 unformat_input_t *i = vam->input;
12570 vl_api_l2tpv3_interface_enable_disable_t *mp;
12572 u8 sw_if_index_set = 0;
12573 u8 enable_disable = 1;
12576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12579 sw_if_index_set = 1;
12580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12581 sw_if_index_set = 1;
12582 else if (unformat (i, "enable"))
12583 enable_disable = 1;
12584 else if (unformat (i, "disable"))
12585 enable_disable = 0;
12590 if (sw_if_index_set == 0)
12592 errmsg ("missing interface name or sw_if_index");
12596 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12598 mp->sw_if_index = ntohl (sw_if_index);
12599 mp->enable_disable = enable_disable;
12607 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12609 unformat_input_t *i = vam->input;
12610 vl_api_l2tpv3_set_lookup_key_t *mp;
12614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12616 if (unformat (i, "lookup_v6_src"))
12617 key = L2T_LOOKUP_SRC_ADDRESS;
12618 else if (unformat (i, "lookup_v6_dst"))
12619 key = L2T_LOOKUP_DST_ADDRESS;
12620 else if (unformat (i, "lookup_session_id"))
12621 key = L2T_LOOKUP_SESSION_ID;
12626 if (key == (u8) ~ 0)
12628 errmsg ("l2tp session lookup key unset");
12632 M (L2TPV3_SET_LOOKUP_KEY, mp);
12641 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12642 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12644 vat_main_t *vam = &vat_main;
12646 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12647 format_ip6_address, mp->our_address,
12648 format_ip6_address, mp->client_address,
12649 clib_net_to_host_u32 (mp->sw_if_index));
12652 " local cookies %016llx %016llx remote cookie %016llx",
12653 clib_net_to_host_u64 (mp->local_cookie[0]),
12654 clib_net_to_host_u64 (mp->local_cookie[1]),
12655 clib_net_to_host_u64 (mp->remote_cookie));
12657 print (vam->ofp, " local session-id %d remote session-id %d",
12658 clib_net_to_host_u32 (mp->local_session_id),
12659 clib_net_to_host_u32 (mp->remote_session_id));
12661 print (vam->ofp, " l2 specific sublayer %s\n",
12662 mp->l2_sublayer_present ? "preset" : "absent");
12666 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12667 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12669 vat_main_t *vam = &vat_main;
12670 vat_json_node_t *node = NULL;
12671 struct in6_addr addr;
12673 if (VAT_JSON_ARRAY != vam->json_tree.type)
12675 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12676 vat_json_init_array (&vam->json_tree);
12678 node = vat_json_array_add (&vam->json_tree);
12680 vat_json_init_object (node);
12682 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12683 vat_json_object_add_ip6 (node, "our_address", addr);
12684 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12685 vat_json_object_add_ip6 (node, "client_address", addr);
12687 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12688 vat_json_init_array (lc);
12689 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12690 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12691 vat_json_object_add_uint (node, "remote_cookie",
12692 clib_net_to_host_u64 (mp->remote_cookie));
12694 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12695 vat_json_object_add_uint (node, "local_session_id",
12696 clib_net_to_host_u32 (mp->local_session_id));
12697 vat_json_object_add_uint (node, "remote_session_id",
12698 clib_net_to_host_u32 (mp->remote_session_id));
12699 vat_json_object_add_string_copy (node, "l2_sublayer",
12700 mp->l2_sublayer_present ? (u8 *) "present"
12701 : (u8 *) "absent");
12705 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12707 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12708 vl_api_control_ping_t *mp_ping;
12711 /* Get list of l2tpv3-tunnel interfaces */
12712 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12715 /* Use a control ping for synchronization */
12716 MPING (CONTROL_PING, mp_ping);
12724 static void vl_api_sw_interface_tap_details_t_handler
12725 (vl_api_sw_interface_tap_details_t * mp)
12727 vat_main_t *vam = &vat_main;
12729 print (vam->ofp, "%-16s %d",
12730 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12733 static void vl_api_sw_interface_tap_details_t_handler_json
12734 (vl_api_sw_interface_tap_details_t * mp)
12736 vat_main_t *vam = &vat_main;
12737 vat_json_node_t *node = NULL;
12739 if (VAT_JSON_ARRAY != vam->json_tree.type)
12741 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12742 vat_json_init_array (&vam->json_tree);
12744 node = vat_json_array_add (&vam->json_tree);
12746 vat_json_init_object (node);
12747 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12748 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12752 api_sw_interface_tap_dump (vat_main_t * vam)
12754 vl_api_sw_interface_tap_dump_t *mp;
12755 vl_api_control_ping_t *mp_ping;
12758 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12759 /* Get list of tap interfaces */
12760 M (SW_INTERFACE_TAP_DUMP, mp);
12763 /* Use a control ping for synchronization */
12764 MPING (CONTROL_PING, mp_ping);
12771 static void vl_api_sw_interface_tap_v2_details_t_handler
12772 (vl_api_sw_interface_tap_v2_details_t * mp)
12774 vat_main_t *vam = &vat_main;
12776 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12777 mp->host_ip4_prefix_len);
12778 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12779 mp->host_ip6_prefix_len);
12782 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12783 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12784 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12785 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12786 mp->host_bridge, ip4, ip6);
12792 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12793 (vl_api_sw_interface_tap_v2_details_t * mp)
12795 vat_main_t *vam = &vat_main;
12796 vat_json_node_t *node = NULL;
12798 if (VAT_JSON_ARRAY != vam->json_tree.type)
12800 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12801 vat_json_init_array (&vam->json_tree);
12803 node = vat_json_array_add (&vam->json_tree);
12805 vat_json_init_object (node);
12806 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12807 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12808 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12809 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12810 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12811 vat_json_object_add_string_copy (node, "host_mac_addr",
12812 format (0, "%U", format_ethernet_address,
12813 &mp->host_mac_addr));
12814 vat_json_object_add_string_copy (node, "host_namespace",
12815 mp->host_namespace);
12816 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12817 vat_json_object_add_string_copy (node, "host_ip4_addr",
12818 format (0, "%U/%d", format_ip4_address,
12820 mp->host_ip4_prefix_len));
12821 vat_json_object_add_string_copy (node, "host_ip6_addr",
12822 format (0, "%U/%d", format_ip6_address,
12824 mp->host_ip6_prefix_len));
12829 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12831 vl_api_sw_interface_tap_v2_dump_t *mp;
12832 vl_api_control_ping_t *mp_ping;
12836 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12837 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12838 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12841 /* Get list of tap interfaces */
12842 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12845 /* Use a control ping for synchronization */
12846 MPING (CONTROL_PING, mp_ping);
12853 static uword unformat_vxlan_decap_next
12854 (unformat_input_t * input, va_list * args)
12856 u32 *result = va_arg (*args, u32 *);
12859 if (unformat (input, "l2"))
12860 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12861 else if (unformat (input, "%d", &tmp))
12869 api_vxlan_add_del_tunnel (vat_main_t * vam)
12871 unformat_input_t *line_input = vam->input;
12872 vl_api_vxlan_add_del_tunnel_t *mp;
12873 ip46_address_t src, dst;
12875 u8 ipv4_set = 0, ipv6_set = 0;
12880 u32 mcast_sw_if_index = ~0;
12881 u32 encap_vrf_id = 0;
12882 u32 decap_next_index = ~0;
12886 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12887 memset (&src, 0, sizeof src);
12888 memset (&dst, 0, sizeof dst);
12890 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12892 if (unformat (line_input, "del"))
12894 else if (unformat (line_input, "instance %d", &instance))
12897 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12903 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12909 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12915 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12920 else if (unformat (line_input, "group %U %U",
12921 unformat_ip4_address, &dst.ip4,
12922 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12924 grp_set = dst_set = 1;
12927 else if (unformat (line_input, "group %U",
12928 unformat_ip4_address, &dst.ip4))
12930 grp_set = dst_set = 1;
12933 else if (unformat (line_input, "group %U %U",
12934 unformat_ip6_address, &dst.ip6,
12935 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12937 grp_set = dst_set = 1;
12940 else if (unformat (line_input, "group %U",
12941 unformat_ip6_address, &dst.ip6))
12943 grp_set = dst_set = 1;
12947 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12949 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12951 else if (unformat (line_input, "decap-next %U",
12952 unformat_vxlan_decap_next, &decap_next_index))
12954 else if (unformat (line_input, "vni %d", &vni))
12958 errmsg ("parse error '%U'", format_unformat_error, line_input);
12965 errmsg ("tunnel src address not specified");
12970 errmsg ("tunnel dst address not specified");
12974 if (grp_set && !ip46_address_is_multicast (&dst))
12976 errmsg ("tunnel group address not multicast");
12979 if (grp_set && mcast_sw_if_index == ~0)
12981 errmsg ("tunnel nonexistent multicast device");
12984 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12986 errmsg ("tunnel dst address must be unicast");
12991 if (ipv4_set && ipv6_set)
12993 errmsg ("both IPv4 and IPv6 addresses specified");
12997 if ((vni == 0) || (vni >> 24))
12999 errmsg ("vni not specified or out of range");
13003 M (VXLAN_ADD_DEL_TUNNEL, mp);
13007 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13008 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13012 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13013 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13016 mp->instance = htonl (instance);
13017 mp->encap_vrf_id = ntohl (encap_vrf_id);
13018 mp->decap_next_index = ntohl (decap_next_index);
13019 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13020 mp->vni = ntohl (vni);
13021 mp->is_add = is_add;
13022 mp->is_ipv6 = ipv6_set;
13029 static void vl_api_vxlan_tunnel_details_t_handler
13030 (vl_api_vxlan_tunnel_details_t * mp)
13032 vat_main_t *vam = &vat_main;
13033 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13034 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13036 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13037 ntohl (mp->sw_if_index),
13038 ntohl (mp->instance),
13039 format_ip46_address, &src, IP46_TYPE_ANY,
13040 format_ip46_address, &dst, IP46_TYPE_ANY,
13041 ntohl (mp->encap_vrf_id),
13042 ntohl (mp->decap_next_index), ntohl (mp->vni),
13043 ntohl (mp->mcast_sw_if_index));
13046 static void vl_api_vxlan_tunnel_details_t_handler_json
13047 (vl_api_vxlan_tunnel_details_t * mp)
13049 vat_main_t *vam = &vat_main;
13050 vat_json_node_t *node = NULL;
13052 if (VAT_JSON_ARRAY != vam->json_tree.type)
13054 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13055 vat_json_init_array (&vam->json_tree);
13057 node = vat_json_array_add (&vam->json_tree);
13059 vat_json_init_object (node);
13060 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13062 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13066 struct in6_addr ip6;
13068 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13069 vat_json_object_add_ip6 (node, "src_address", ip6);
13070 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13071 vat_json_object_add_ip6 (node, "dst_address", ip6);
13075 struct in_addr ip4;
13077 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13078 vat_json_object_add_ip4 (node, "src_address", ip4);
13079 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13080 vat_json_object_add_ip4 (node, "dst_address", ip4);
13082 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13083 vat_json_object_add_uint (node, "decap_next_index",
13084 ntohl (mp->decap_next_index));
13085 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13086 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13087 vat_json_object_add_uint (node, "mcast_sw_if_index",
13088 ntohl (mp->mcast_sw_if_index));
13092 api_vxlan_tunnel_dump (vat_main_t * vam)
13094 unformat_input_t *i = vam->input;
13095 vl_api_vxlan_tunnel_dump_t *mp;
13096 vl_api_control_ping_t *mp_ping;
13098 u8 sw_if_index_set = 0;
13101 /* Parse args required to build the message */
13102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13104 if (unformat (i, "sw_if_index %d", &sw_if_index))
13105 sw_if_index_set = 1;
13110 if (sw_if_index_set == 0)
13115 if (!vam->json_output)
13117 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13118 "sw_if_index", "instance", "src_address", "dst_address",
13119 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13122 /* Get list of vxlan-tunnel interfaces */
13123 M (VXLAN_TUNNEL_DUMP, mp);
13125 mp->sw_if_index = htonl (sw_if_index);
13129 /* Use a control ping for synchronization */
13130 MPING (CONTROL_PING, mp_ping);
13137 static uword unformat_geneve_decap_next
13138 (unformat_input_t * input, va_list * args)
13140 u32 *result = va_arg (*args, u32 *);
13143 if (unformat (input, "l2"))
13144 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13145 else if (unformat (input, "%d", &tmp))
13153 api_geneve_add_del_tunnel (vat_main_t * vam)
13155 unformat_input_t *line_input = vam->input;
13156 vl_api_geneve_add_del_tunnel_t *mp;
13157 ip46_address_t src, dst;
13159 u8 ipv4_set = 0, ipv6_set = 0;
13163 u32 mcast_sw_if_index = ~0;
13164 u32 encap_vrf_id = 0;
13165 u32 decap_next_index = ~0;
13169 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13170 memset (&src, 0, sizeof src);
13171 memset (&dst, 0, sizeof dst);
13173 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13175 if (unformat (line_input, "del"))
13178 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13184 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13190 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13196 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13201 else if (unformat (line_input, "group %U %U",
13202 unformat_ip4_address, &dst.ip4,
13203 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13205 grp_set = dst_set = 1;
13208 else if (unformat (line_input, "group %U",
13209 unformat_ip4_address, &dst.ip4))
13211 grp_set = dst_set = 1;
13214 else if (unformat (line_input, "group %U %U",
13215 unformat_ip6_address, &dst.ip6,
13216 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13218 grp_set = dst_set = 1;
13221 else if (unformat (line_input, "group %U",
13222 unformat_ip6_address, &dst.ip6))
13224 grp_set = dst_set = 1;
13228 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13230 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13232 else if (unformat (line_input, "decap-next %U",
13233 unformat_geneve_decap_next, &decap_next_index))
13235 else if (unformat (line_input, "vni %d", &vni))
13239 errmsg ("parse error '%U'", format_unformat_error, line_input);
13246 errmsg ("tunnel src address not specified");
13251 errmsg ("tunnel dst address not specified");
13255 if (grp_set && !ip46_address_is_multicast (&dst))
13257 errmsg ("tunnel group address not multicast");
13260 if (grp_set && mcast_sw_if_index == ~0)
13262 errmsg ("tunnel nonexistent multicast device");
13265 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13267 errmsg ("tunnel dst address must be unicast");
13272 if (ipv4_set && ipv6_set)
13274 errmsg ("both IPv4 and IPv6 addresses specified");
13278 if ((vni == 0) || (vni >> 24))
13280 errmsg ("vni not specified or out of range");
13284 M (GENEVE_ADD_DEL_TUNNEL, mp);
13288 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13289 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13293 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13294 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13296 mp->encap_vrf_id = ntohl (encap_vrf_id);
13297 mp->decap_next_index = ntohl (decap_next_index);
13298 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13299 mp->vni = ntohl (vni);
13300 mp->is_add = is_add;
13301 mp->is_ipv6 = ipv6_set;
13308 static void vl_api_geneve_tunnel_details_t_handler
13309 (vl_api_geneve_tunnel_details_t * mp)
13311 vat_main_t *vam = &vat_main;
13312 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13313 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13315 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13316 ntohl (mp->sw_if_index),
13317 format_ip46_address, &src, IP46_TYPE_ANY,
13318 format_ip46_address, &dst, IP46_TYPE_ANY,
13319 ntohl (mp->encap_vrf_id),
13320 ntohl (mp->decap_next_index), ntohl (mp->vni),
13321 ntohl (mp->mcast_sw_if_index));
13324 static void vl_api_geneve_tunnel_details_t_handler_json
13325 (vl_api_geneve_tunnel_details_t * mp)
13327 vat_main_t *vam = &vat_main;
13328 vat_json_node_t *node = NULL;
13330 if (VAT_JSON_ARRAY != vam->json_tree.type)
13332 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13333 vat_json_init_array (&vam->json_tree);
13335 node = vat_json_array_add (&vam->json_tree);
13337 vat_json_init_object (node);
13338 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13341 struct in6_addr ip6;
13343 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13344 vat_json_object_add_ip6 (node, "src_address", ip6);
13345 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13346 vat_json_object_add_ip6 (node, "dst_address", ip6);
13350 struct in_addr ip4;
13352 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13353 vat_json_object_add_ip4 (node, "src_address", ip4);
13354 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13355 vat_json_object_add_ip4 (node, "dst_address", ip4);
13357 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13358 vat_json_object_add_uint (node, "decap_next_index",
13359 ntohl (mp->decap_next_index));
13360 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13361 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13362 vat_json_object_add_uint (node, "mcast_sw_if_index",
13363 ntohl (mp->mcast_sw_if_index));
13367 api_geneve_tunnel_dump (vat_main_t * vam)
13369 unformat_input_t *i = vam->input;
13370 vl_api_geneve_tunnel_dump_t *mp;
13371 vl_api_control_ping_t *mp_ping;
13373 u8 sw_if_index_set = 0;
13376 /* Parse args required to build the message */
13377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13379 if (unformat (i, "sw_if_index %d", &sw_if_index))
13380 sw_if_index_set = 1;
13385 if (sw_if_index_set == 0)
13390 if (!vam->json_output)
13392 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13393 "sw_if_index", "local_address", "remote_address",
13394 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13397 /* Get list of geneve-tunnel interfaces */
13398 M (GENEVE_TUNNEL_DUMP, mp);
13400 mp->sw_if_index = htonl (sw_if_index);
13404 /* Use a control ping for synchronization */
13405 M (CONTROL_PING, mp_ping);
13413 api_gre_add_del_tunnel (vat_main_t * vam)
13415 unformat_input_t *line_input = vam->input;
13416 vl_api_gre_add_del_tunnel_t *mp;
13417 ip4_address_t src4, dst4;
13418 ip6_address_t src6, dst6;
13422 u8 t_type = GRE_TUNNEL_TYPE_L3;
13425 u32 outer_fib_id = 0;
13426 u32 session_id = 0;
13430 memset (&src4, 0, sizeof src4);
13431 memset (&dst4, 0, sizeof dst4);
13432 memset (&src6, 0, sizeof src6);
13433 memset (&dst6, 0, sizeof dst6);
13435 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13437 if (unformat (line_input, "del"))
13439 else if (unformat (line_input, "instance %d", &instance))
13441 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13446 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13451 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13456 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13461 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13463 else if (unformat (line_input, "teb"))
13464 t_type = GRE_TUNNEL_TYPE_TEB;
13465 else if (unformat (line_input, "erspan %d", &session_id))
13466 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13469 errmsg ("parse error '%U'", format_unformat_error, line_input);
13476 errmsg ("tunnel src address not specified");
13481 errmsg ("tunnel dst address not specified");
13484 if (ipv4_set && ipv6_set)
13486 errmsg ("both IPv4 and IPv6 addresses specified");
13491 M (GRE_ADD_DEL_TUNNEL, mp);
13495 clib_memcpy (&mp->src_address, &src4, 4);
13496 clib_memcpy (&mp->dst_address, &dst4, 4);
13500 clib_memcpy (&mp->src_address, &src6, 16);
13501 clib_memcpy (&mp->dst_address, &dst6, 16);
13503 mp->instance = htonl (instance);
13504 mp->outer_fib_id = htonl (outer_fib_id);
13505 mp->is_add = is_add;
13506 mp->session_id = htons ((u16) session_id);
13507 mp->tunnel_type = t_type;
13508 mp->is_ipv6 = ipv6_set;
13515 static void vl_api_gre_tunnel_details_t_handler
13516 (vl_api_gre_tunnel_details_t * mp)
13518 vat_main_t *vam = &vat_main;
13519 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13520 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13522 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13523 ntohl (mp->sw_if_index),
13524 ntohl (mp->instance),
13525 format_ip46_address, &src, IP46_TYPE_ANY,
13526 format_ip46_address, &dst, IP46_TYPE_ANY,
13527 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13530 static void vl_api_gre_tunnel_details_t_handler_json
13531 (vl_api_gre_tunnel_details_t * mp)
13533 vat_main_t *vam = &vat_main;
13534 vat_json_node_t *node = NULL;
13535 struct in_addr ip4;
13536 struct in6_addr ip6;
13538 if (VAT_JSON_ARRAY != vam->json_tree.type)
13540 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13541 vat_json_init_array (&vam->json_tree);
13543 node = vat_json_array_add (&vam->json_tree);
13545 vat_json_init_object (node);
13546 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13547 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13550 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13551 vat_json_object_add_ip4 (node, "src_address", ip4);
13552 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13553 vat_json_object_add_ip4 (node, "dst_address", ip4);
13557 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13558 vat_json_object_add_ip6 (node, "src_address", ip6);
13559 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13560 vat_json_object_add_ip6 (node, "dst_address", ip6);
13562 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13563 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13564 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13565 vat_json_object_add_uint (node, "session_id", mp->session_id);
13569 api_gre_tunnel_dump (vat_main_t * vam)
13571 unformat_input_t *i = vam->input;
13572 vl_api_gre_tunnel_dump_t *mp;
13573 vl_api_control_ping_t *mp_ping;
13575 u8 sw_if_index_set = 0;
13578 /* Parse args required to build the message */
13579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13581 if (unformat (i, "sw_if_index %d", &sw_if_index))
13582 sw_if_index_set = 1;
13587 if (sw_if_index_set == 0)
13592 if (!vam->json_output)
13594 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13595 "sw_if_index", "instance", "src_address", "dst_address",
13596 "tunnel_type", "outer_fib_id", "session_id");
13599 /* Get list of gre-tunnel interfaces */
13600 M (GRE_TUNNEL_DUMP, mp);
13602 mp->sw_if_index = htonl (sw_if_index);
13606 /* Use a control ping for synchronization */
13607 MPING (CONTROL_PING, mp_ping);
13615 api_l2_fib_clear_table (vat_main_t * vam)
13617 // unformat_input_t * i = vam->input;
13618 vl_api_l2_fib_clear_table_t *mp;
13621 M (L2_FIB_CLEAR_TABLE, mp);
13629 api_l2_interface_efp_filter (vat_main_t * vam)
13631 unformat_input_t *i = vam->input;
13632 vl_api_l2_interface_efp_filter_t *mp;
13635 u8 sw_if_index_set = 0;
13638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13640 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13641 sw_if_index_set = 1;
13642 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13643 sw_if_index_set = 1;
13644 else if (unformat (i, "enable"))
13646 else if (unformat (i, "disable"))
13650 clib_warning ("parse error '%U'", format_unformat_error, i);
13655 if (sw_if_index_set == 0)
13657 errmsg ("missing sw_if_index");
13661 M (L2_INTERFACE_EFP_FILTER, mp);
13663 mp->sw_if_index = ntohl (sw_if_index);
13664 mp->enable_disable = enable;
13671 #define foreach_vtr_op \
13672 _("disable", L2_VTR_DISABLED) \
13673 _("push-1", L2_VTR_PUSH_1) \
13674 _("push-2", L2_VTR_PUSH_2) \
13675 _("pop-1", L2_VTR_POP_1) \
13676 _("pop-2", L2_VTR_POP_2) \
13677 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13678 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13679 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13680 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13683 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13685 unformat_input_t *i = vam->input;
13686 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13688 u8 sw_if_index_set = 0;
13691 u32 push_dot1q = 1;
13696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13698 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13699 sw_if_index_set = 1;
13700 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13701 sw_if_index_set = 1;
13702 else if (unformat (i, "vtr_op %d", &vtr_op))
13704 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13707 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13709 else if (unformat (i, "tag1 %d", &tag1))
13711 else if (unformat (i, "tag2 %d", &tag2))
13715 clib_warning ("parse error '%U'", format_unformat_error, i);
13720 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13722 errmsg ("missing vtr operation or sw_if_index");
13726 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13727 mp->sw_if_index = ntohl (sw_if_index);
13728 mp->vtr_op = ntohl (vtr_op);
13729 mp->push_dot1q = ntohl (push_dot1q);
13730 mp->tag1 = ntohl (tag1);
13731 mp->tag2 = ntohl (tag2);
13739 api_create_vhost_user_if (vat_main_t * vam)
13741 unformat_input_t *i = vam->input;
13742 vl_api_create_vhost_user_if_t *mp;
13745 u8 file_name_set = 0;
13746 u32 custom_dev_instance = ~0;
13748 u8 use_custom_mac = 0;
13752 /* Shut up coverity */
13753 memset (hwaddr, 0, sizeof (hwaddr));
13755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13757 if (unformat (i, "socket %s", &file_name))
13761 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13763 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13764 use_custom_mac = 1;
13765 else if (unformat (i, "server"))
13767 else if (unformat (i, "tag %s", &tag))
13773 if (file_name_set == 0)
13775 errmsg ("missing socket file name");
13779 if (vec_len (file_name) > 255)
13781 errmsg ("socket file name too long");
13784 vec_add1 (file_name, 0);
13786 M (CREATE_VHOST_USER_IF, mp);
13788 mp->is_server = is_server;
13789 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13790 vec_free (file_name);
13791 if (custom_dev_instance != ~0)
13794 mp->custom_dev_instance = ntohl (custom_dev_instance);
13796 mp->use_custom_mac = use_custom_mac;
13797 clib_memcpy (mp->mac_address, hwaddr, 6);
13799 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13808 api_modify_vhost_user_if (vat_main_t * vam)
13810 unformat_input_t *i = vam->input;
13811 vl_api_modify_vhost_user_if_t *mp;
13814 u8 file_name_set = 0;
13815 u32 custom_dev_instance = ~0;
13816 u8 sw_if_index_set = 0;
13817 u32 sw_if_index = (u32) ~ 0;
13820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13823 sw_if_index_set = 1;
13824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13825 sw_if_index_set = 1;
13826 else if (unformat (i, "socket %s", &file_name))
13830 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13832 else if (unformat (i, "server"))
13838 if (sw_if_index_set == 0)
13840 errmsg ("missing sw_if_index or interface name");
13844 if (file_name_set == 0)
13846 errmsg ("missing socket file name");
13850 if (vec_len (file_name) > 255)
13852 errmsg ("socket file name too long");
13855 vec_add1 (file_name, 0);
13857 M (MODIFY_VHOST_USER_IF, mp);
13859 mp->sw_if_index = ntohl (sw_if_index);
13860 mp->is_server = is_server;
13861 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13862 vec_free (file_name);
13863 if (custom_dev_instance != ~0)
13866 mp->custom_dev_instance = ntohl (custom_dev_instance);
13875 api_delete_vhost_user_if (vat_main_t * vam)
13877 unformat_input_t *i = vam->input;
13878 vl_api_delete_vhost_user_if_t *mp;
13879 u32 sw_if_index = ~0;
13880 u8 sw_if_index_set = 0;
13883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13886 sw_if_index_set = 1;
13887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13888 sw_if_index_set = 1;
13893 if (sw_if_index_set == 0)
13895 errmsg ("missing sw_if_index or interface name");
13900 M (DELETE_VHOST_USER_IF, mp);
13902 mp->sw_if_index = ntohl (sw_if_index);
13909 static void vl_api_sw_interface_vhost_user_details_t_handler
13910 (vl_api_sw_interface_vhost_user_details_t * mp)
13912 vat_main_t *vam = &vat_main;
13914 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13915 (char *) mp->interface_name,
13916 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13917 clib_net_to_host_u64 (mp->features), mp->is_server,
13918 ntohl (mp->num_regions), (char *) mp->sock_filename);
13919 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13922 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13923 (vl_api_sw_interface_vhost_user_details_t * mp)
13925 vat_main_t *vam = &vat_main;
13926 vat_json_node_t *node = NULL;
13928 if (VAT_JSON_ARRAY != vam->json_tree.type)
13930 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13931 vat_json_init_array (&vam->json_tree);
13933 node = vat_json_array_add (&vam->json_tree);
13935 vat_json_init_object (node);
13936 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13937 vat_json_object_add_string_copy (node, "interface_name",
13938 mp->interface_name);
13939 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13940 ntohl (mp->virtio_net_hdr_sz));
13941 vat_json_object_add_uint (node, "features",
13942 clib_net_to_host_u64 (mp->features));
13943 vat_json_object_add_uint (node, "is_server", mp->is_server);
13944 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13945 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13946 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13950 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13952 vl_api_sw_interface_vhost_user_dump_t *mp;
13953 vl_api_control_ping_t *mp_ping;
13956 "Interface name idx hdr_sz features server regions filename");
13958 /* Get list of vhost-user interfaces */
13959 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13962 /* Use a control ping for synchronization */
13963 MPING (CONTROL_PING, mp_ping);
13971 api_show_version (vat_main_t * vam)
13973 vl_api_show_version_t *mp;
13976 M (SHOW_VERSION, mp);
13985 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13987 unformat_input_t *line_input = vam->input;
13988 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13989 ip4_address_t local4, remote4;
13990 ip6_address_t local6, remote6;
13992 u8 ipv4_set = 0, ipv6_set = 0;
13996 u32 mcast_sw_if_index = ~0;
13997 u32 encap_vrf_id = 0;
13998 u32 decap_vrf_id = 0;
14004 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14005 memset (&local4, 0, sizeof local4);
14006 memset (&remote4, 0, sizeof remote4);
14007 memset (&local6, 0, sizeof local6);
14008 memset (&remote6, 0, sizeof remote6);
14010 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14012 if (unformat (line_input, "del"))
14014 else if (unformat (line_input, "local %U",
14015 unformat_ip4_address, &local4))
14020 else if (unformat (line_input, "remote %U",
14021 unformat_ip4_address, &remote4))
14026 else if (unformat (line_input, "local %U",
14027 unformat_ip6_address, &local6))
14032 else if (unformat (line_input, "remote %U",
14033 unformat_ip6_address, &remote6))
14038 else if (unformat (line_input, "group %U %U",
14039 unformat_ip4_address, &remote4,
14040 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14042 grp_set = remote_set = 1;
14045 else if (unformat (line_input, "group %U",
14046 unformat_ip4_address, &remote4))
14048 grp_set = remote_set = 1;
14051 else if (unformat (line_input, "group %U %U",
14052 unformat_ip6_address, &remote6,
14053 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14055 grp_set = remote_set = 1;
14058 else if (unformat (line_input, "group %U",
14059 unformat_ip6_address, &remote6))
14061 grp_set = remote_set = 1;
14065 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14067 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14069 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14071 else if (unformat (line_input, "vni %d", &vni))
14073 else if (unformat (line_input, "next-ip4"))
14075 else if (unformat (line_input, "next-ip6"))
14077 else if (unformat (line_input, "next-ethernet"))
14079 else if (unformat (line_input, "next-nsh"))
14083 errmsg ("parse error '%U'", format_unformat_error, line_input);
14088 if (local_set == 0)
14090 errmsg ("tunnel local address not specified");
14093 if (remote_set == 0)
14095 errmsg ("tunnel remote address not specified");
14098 if (grp_set && mcast_sw_if_index == ~0)
14100 errmsg ("tunnel nonexistent multicast device");
14103 if (ipv4_set && ipv6_set)
14105 errmsg ("both IPv4 and IPv6 addresses specified");
14111 errmsg ("vni not specified");
14115 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14120 clib_memcpy (&mp->local, &local6, sizeof (local6));
14121 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14125 clib_memcpy (&mp->local, &local4, sizeof (local4));
14126 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14129 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14130 mp->encap_vrf_id = ntohl (encap_vrf_id);
14131 mp->decap_vrf_id = ntohl (decap_vrf_id);
14132 mp->protocol = protocol;
14133 mp->vni = ntohl (vni);
14134 mp->is_add = is_add;
14135 mp->is_ipv6 = ipv6_set;
14142 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14143 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14145 vat_main_t *vam = &vat_main;
14146 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14147 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14149 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14150 ntohl (mp->sw_if_index),
14151 format_ip46_address, &local, IP46_TYPE_ANY,
14152 format_ip46_address, &remote, IP46_TYPE_ANY,
14153 ntohl (mp->vni), mp->protocol,
14154 ntohl (mp->mcast_sw_if_index),
14155 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14159 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14160 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14162 vat_main_t *vam = &vat_main;
14163 vat_json_node_t *node = NULL;
14164 struct in_addr ip4;
14165 struct in6_addr ip6;
14167 if (VAT_JSON_ARRAY != vam->json_tree.type)
14169 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14170 vat_json_init_array (&vam->json_tree);
14172 node = vat_json_array_add (&vam->json_tree);
14174 vat_json_init_object (node);
14175 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14178 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14179 vat_json_object_add_ip6 (node, "local", ip6);
14180 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14181 vat_json_object_add_ip6 (node, "remote", ip6);
14185 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14186 vat_json_object_add_ip4 (node, "local", ip4);
14187 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14188 vat_json_object_add_ip4 (node, "remote", ip4);
14190 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14191 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14192 vat_json_object_add_uint (node, "mcast_sw_if_index",
14193 ntohl (mp->mcast_sw_if_index));
14194 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14195 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14196 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14200 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14202 unformat_input_t *i = vam->input;
14203 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14204 vl_api_control_ping_t *mp_ping;
14206 u8 sw_if_index_set = 0;
14209 /* Parse args required to build the message */
14210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14212 if (unformat (i, "sw_if_index %d", &sw_if_index))
14213 sw_if_index_set = 1;
14218 if (sw_if_index_set == 0)
14223 if (!vam->json_output)
14225 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14226 "sw_if_index", "local", "remote", "vni",
14227 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14230 /* Get list of vxlan-tunnel interfaces */
14231 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14233 mp->sw_if_index = htonl (sw_if_index);
14237 /* Use a control ping for synchronization */
14238 MPING (CONTROL_PING, mp_ping);
14245 static void vl_api_l2_fib_table_details_t_handler
14246 (vl_api_l2_fib_table_details_t * mp)
14248 vat_main_t *vam = &vat_main;
14250 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14252 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14253 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14257 static void vl_api_l2_fib_table_details_t_handler_json
14258 (vl_api_l2_fib_table_details_t * mp)
14260 vat_main_t *vam = &vat_main;
14261 vat_json_node_t *node = NULL;
14263 if (VAT_JSON_ARRAY != vam->json_tree.type)
14265 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14266 vat_json_init_array (&vam->json_tree);
14268 node = vat_json_array_add (&vam->json_tree);
14270 vat_json_init_object (node);
14271 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14272 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14273 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14274 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14275 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14276 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14280 api_l2_fib_table_dump (vat_main_t * vam)
14282 unformat_input_t *i = vam->input;
14283 vl_api_l2_fib_table_dump_t *mp;
14284 vl_api_control_ping_t *mp_ping;
14289 /* Parse args required to build the message */
14290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14292 if (unformat (i, "bd_id %d", &bd_id))
14298 if (bd_id_set == 0)
14300 errmsg ("missing bridge domain");
14304 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14306 /* Get list of l2 fib entries */
14307 M (L2_FIB_TABLE_DUMP, mp);
14309 mp->bd_id = ntohl (bd_id);
14312 /* Use a control ping for synchronization */
14313 MPING (CONTROL_PING, mp_ping);
14322 api_interface_name_renumber (vat_main_t * vam)
14324 unformat_input_t *line_input = vam->input;
14325 vl_api_interface_name_renumber_t *mp;
14326 u32 sw_if_index = ~0;
14327 u32 new_show_dev_instance = ~0;
14330 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14332 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14335 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14337 else if (unformat (line_input, "new_show_dev_instance %d",
14338 &new_show_dev_instance))
14344 if (sw_if_index == ~0)
14346 errmsg ("missing interface name or sw_if_index");
14350 if (new_show_dev_instance == ~0)
14352 errmsg ("missing new_show_dev_instance");
14356 M (INTERFACE_NAME_RENUMBER, mp);
14358 mp->sw_if_index = ntohl (sw_if_index);
14359 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14367 api_ip_probe_neighbor (vat_main_t * vam)
14369 unformat_input_t *i = vam->input;
14370 vl_api_ip_probe_neighbor_t *mp;
14378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14380 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14382 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14384 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14386 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14397 errmsg ("missing interface");
14403 errmsg ("missing addresses");
14407 M (IP_PROBE_NEIGHBOR, mp);
14409 mp->sw_if_index = ntohl (sw_if_index);
14410 mp->is_ipv6 = is_ipv6;
14411 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14419 api_want_ip4_arp_events (vat_main_t * vam)
14421 unformat_input_t *line_input = vam->input;
14422 vl_api_want_ip4_arp_events_t *mp;
14423 ip4_address_t address;
14424 int address_set = 0;
14425 u32 enable_disable = 1;
14428 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14430 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14432 else if (unformat (line_input, "del"))
14433 enable_disable = 0;
14438 if (address_set == 0)
14440 errmsg ("missing addresses");
14444 M (WANT_IP4_ARP_EVENTS, mp);
14445 mp->enable_disable = enable_disable;
14446 mp->pid = htonl (getpid ());
14447 mp->address = address.as_u32;
14455 api_want_ip6_nd_events (vat_main_t * vam)
14457 unformat_input_t *line_input = vam->input;
14458 vl_api_want_ip6_nd_events_t *mp;
14459 ip6_address_t address;
14460 int address_set = 0;
14461 u32 enable_disable = 1;
14464 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14466 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14468 else if (unformat (line_input, "del"))
14469 enable_disable = 0;
14474 if (address_set == 0)
14476 errmsg ("missing addresses");
14480 M (WANT_IP6_ND_EVENTS, mp);
14481 mp->enable_disable = enable_disable;
14482 mp->pid = htonl (getpid ());
14483 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14491 api_want_l2_macs_events (vat_main_t * vam)
14493 unformat_input_t *line_input = vam->input;
14494 vl_api_want_l2_macs_events_t *mp;
14495 u8 enable_disable = 1;
14496 u32 scan_delay = 0;
14497 u32 max_macs_in_event = 0;
14498 u32 learn_limit = 0;
14501 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14503 if (unformat (line_input, "learn-limit %d", &learn_limit))
14505 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14507 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14509 else if (unformat (line_input, "disable"))
14510 enable_disable = 0;
14515 M (WANT_L2_MACS_EVENTS, mp);
14516 mp->enable_disable = enable_disable;
14517 mp->pid = htonl (getpid ());
14518 mp->learn_limit = htonl (learn_limit);
14519 mp->scan_delay = (u8) scan_delay;
14520 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14527 api_input_acl_set_interface (vat_main_t * vam)
14529 unformat_input_t *i = vam->input;
14530 vl_api_input_acl_set_interface_t *mp;
14532 int sw_if_index_set;
14533 u32 ip4_table_index = ~0;
14534 u32 ip6_table_index = ~0;
14535 u32 l2_table_index = ~0;
14539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14542 sw_if_index_set = 1;
14543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14544 sw_if_index_set = 1;
14545 else if (unformat (i, "del"))
14547 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14549 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14551 else if (unformat (i, "l2-table %d", &l2_table_index))
14555 clib_warning ("parse error '%U'", format_unformat_error, i);
14560 if (sw_if_index_set == 0)
14562 errmsg ("missing interface name or sw_if_index");
14566 M (INPUT_ACL_SET_INTERFACE, mp);
14568 mp->sw_if_index = ntohl (sw_if_index);
14569 mp->ip4_table_index = ntohl (ip4_table_index);
14570 mp->ip6_table_index = ntohl (ip6_table_index);
14571 mp->l2_table_index = ntohl (l2_table_index);
14572 mp->is_add = is_add;
14580 api_output_acl_set_interface (vat_main_t * vam)
14582 unformat_input_t *i = vam->input;
14583 vl_api_output_acl_set_interface_t *mp;
14585 int sw_if_index_set;
14586 u32 ip4_table_index = ~0;
14587 u32 ip6_table_index = ~0;
14588 u32 l2_table_index = ~0;
14592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14595 sw_if_index_set = 1;
14596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14597 sw_if_index_set = 1;
14598 else if (unformat (i, "del"))
14600 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14602 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14604 else if (unformat (i, "l2-table %d", &l2_table_index))
14608 clib_warning ("parse error '%U'", format_unformat_error, i);
14613 if (sw_if_index_set == 0)
14615 errmsg ("missing interface name or sw_if_index");
14619 M (OUTPUT_ACL_SET_INTERFACE, mp);
14621 mp->sw_if_index = ntohl (sw_if_index);
14622 mp->ip4_table_index = ntohl (ip4_table_index);
14623 mp->ip6_table_index = ntohl (ip6_table_index);
14624 mp->l2_table_index = ntohl (l2_table_index);
14625 mp->is_add = is_add;
14633 api_ip_address_dump (vat_main_t * vam)
14635 unformat_input_t *i = vam->input;
14636 vl_api_ip_address_dump_t *mp;
14637 vl_api_control_ping_t *mp_ping;
14638 u32 sw_if_index = ~0;
14639 u8 sw_if_index_set = 0;
14644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14646 if (unformat (i, "sw_if_index %d", &sw_if_index))
14647 sw_if_index_set = 1;
14649 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14650 sw_if_index_set = 1;
14651 else if (unformat (i, "ipv4"))
14653 else if (unformat (i, "ipv6"))
14659 if (ipv4_set && ipv6_set)
14661 errmsg ("ipv4 and ipv6 flags cannot be both set");
14665 if ((!ipv4_set) && (!ipv6_set))
14667 errmsg ("no ipv4 nor ipv6 flag set");
14671 if (sw_if_index_set == 0)
14673 errmsg ("missing interface name or sw_if_index");
14677 vam->current_sw_if_index = sw_if_index;
14678 vam->is_ipv6 = ipv6_set;
14680 M (IP_ADDRESS_DUMP, mp);
14681 mp->sw_if_index = ntohl (sw_if_index);
14682 mp->is_ipv6 = ipv6_set;
14685 /* Use a control ping for synchronization */
14686 MPING (CONTROL_PING, mp_ping);
14694 api_ip_dump (vat_main_t * vam)
14696 vl_api_ip_dump_t *mp;
14697 vl_api_control_ping_t *mp_ping;
14698 unformat_input_t *in = vam->input;
14705 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14707 if (unformat (in, "ipv4"))
14709 else if (unformat (in, "ipv6"))
14715 if (ipv4_set && ipv6_set)
14717 errmsg ("ipv4 and ipv6 flags cannot be both set");
14721 if ((!ipv4_set) && (!ipv6_set))
14723 errmsg ("no ipv4 nor ipv6 flag set");
14727 is_ipv6 = ipv6_set;
14728 vam->is_ipv6 = is_ipv6;
14730 /* free old data */
14731 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14733 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14735 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14738 mp->is_ipv6 = ipv6_set;
14741 /* Use a control ping for synchronization */
14742 MPING (CONTROL_PING, mp_ping);
14750 api_ipsec_spd_add_del (vat_main_t * vam)
14752 unformat_input_t *i = vam->input;
14753 vl_api_ipsec_spd_add_del_t *mp;
14758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14760 if (unformat (i, "spd_id %d", &spd_id))
14762 else if (unformat (i, "del"))
14766 clib_warning ("parse error '%U'", format_unformat_error, i);
14772 errmsg ("spd_id must be set");
14776 M (IPSEC_SPD_ADD_DEL, mp);
14778 mp->spd_id = ntohl (spd_id);
14779 mp->is_add = is_add;
14787 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14789 unformat_input_t *i = vam->input;
14790 vl_api_ipsec_interface_add_del_spd_t *mp;
14792 u8 sw_if_index_set = 0;
14793 u32 spd_id = (u32) ~ 0;
14797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14799 if (unformat (i, "del"))
14801 else if (unformat (i, "spd_id %d", &spd_id))
14804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14805 sw_if_index_set = 1;
14806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14807 sw_if_index_set = 1;
14810 clib_warning ("parse error '%U'", format_unformat_error, i);
14816 if (spd_id == (u32) ~ 0)
14818 errmsg ("spd_id must be set");
14822 if (sw_if_index_set == 0)
14824 errmsg ("missing interface name or sw_if_index");
14828 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14830 mp->spd_id = ntohl (spd_id);
14831 mp->sw_if_index = ntohl (sw_if_index);
14832 mp->is_add = is_add;
14840 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14842 unformat_input_t *i = vam->input;
14843 vl_api_ipsec_spd_add_del_entry_t *mp;
14844 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14845 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14847 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14848 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14849 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14850 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14853 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14854 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14855 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14856 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14857 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14858 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14862 if (unformat (i, "del"))
14864 if (unformat (i, "outbound"))
14866 if (unformat (i, "inbound"))
14868 else if (unformat (i, "spd_id %d", &spd_id))
14870 else if (unformat (i, "sa_id %d", &sa_id))
14872 else if (unformat (i, "priority %d", &priority))
14874 else if (unformat (i, "protocol %d", &protocol))
14876 else if (unformat (i, "lport_start %d", &lport_start))
14878 else if (unformat (i, "lport_stop %d", &lport_stop))
14880 else if (unformat (i, "rport_start %d", &rport_start))
14882 else if (unformat (i, "rport_stop %d", &rport_stop))
14886 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14892 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14899 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14905 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14912 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14918 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14925 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14931 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14937 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14939 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14941 clib_warning ("unsupported action: 'resolve'");
14947 clib_warning ("parse error '%U'", format_unformat_error, i);
14953 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14955 mp->spd_id = ntohl (spd_id);
14956 mp->priority = ntohl (priority);
14957 mp->is_outbound = is_outbound;
14959 mp->is_ipv6 = is_ipv6;
14960 if (is_ipv6 || is_ip_any)
14962 clib_memcpy (mp->remote_address_start, &raddr6_start,
14963 sizeof (ip6_address_t));
14964 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14965 sizeof (ip6_address_t));
14966 clib_memcpy (mp->local_address_start, &laddr6_start,
14967 sizeof (ip6_address_t));
14968 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14969 sizeof (ip6_address_t));
14973 clib_memcpy (mp->remote_address_start, &raddr4_start,
14974 sizeof (ip4_address_t));
14975 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14976 sizeof (ip4_address_t));
14977 clib_memcpy (mp->local_address_start, &laddr4_start,
14978 sizeof (ip4_address_t));
14979 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14980 sizeof (ip4_address_t));
14982 mp->protocol = (u8) protocol;
14983 mp->local_port_start = ntohs ((u16) lport_start);
14984 mp->local_port_stop = ntohs ((u16) lport_stop);
14985 mp->remote_port_start = ntohs ((u16) rport_start);
14986 mp->remote_port_stop = ntohs ((u16) rport_stop);
14987 mp->policy = (u8) policy;
14988 mp->sa_id = ntohl (sa_id);
14989 mp->is_add = is_add;
14990 mp->is_ip_any = is_ip_any;
14997 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14999 unformat_input_t *i = vam->input;
15000 vl_api_ipsec_sad_add_del_entry_t *mp;
15001 u32 sad_id = 0, spi = 0;
15002 u8 *ck = 0, *ik = 0;
15005 u8 protocol = IPSEC_PROTOCOL_AH;
15006 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15007 u32 crypto_alg = 0, integ_alg = 0;
15008 ip4_address_t tun_src4;
15009 ip4_address_t tun_dst4;
15010 ip6_address_t tun_src6;
15011 ip6_address_t tun_dst6;
15014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15016 if (unformat (i, "del"))
15018 else if (unformat (i, "sad_id %d", &sad_id))
15020 else if (unformat (i, "spi %d", &spi))
15022 else if (unformat (i, "esp"))
15023 protocol = IPSEC_PROTOCOL_ESP;
15024 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15027 is_tunnel_ipv6 = 0;
15029 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15032 is_tunnel_ipv6 = 0;
15034 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15037 is_tunnel_ipv6 = 1;
15039 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15042 is_tunnel_ipv6 = 1;
15046 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15048 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15049 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15051 clib_warning ("unsupported crypto-alg: '%U'",
15052 format_ipsec_crypto_alg, crypto_alg);
15056 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15060 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15062 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15063 integ_alg >= IPSEC_INTEG_N_ALG)
15065 clib_warning ("unsupported integ-alg: '%U'",
15066 format_ipsec_integ_alg, integ_alg);
15070 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15074 clib_warning ("parse error '%U'", format_unformat_error, i);
15080 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15082 mp->sad_id = ntohl (sad_id);
15083 mp->is_add = is_add;
15084 mp->protocol = protocol;
15085 mp->spi = ntohl (spi);
15086 mp->is_tunnel = is_tunnel;
15087 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15088 mp->crypto_algorithm = crypto_alg;
15089 mp->integrity_algorithm = integ_alg;
15090 mp->crypto_key_length = vec_len (ck);
15091 mp->integrity_key_length = vec_len (ik);
15093 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15094 mp->crypto_key_length = sizeof (mp->crypto_key);
15096 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15097 mp->integrity_key_length = sizeof (mp->integrity_key);
15100 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15102 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15106 if (is_tunnel_ipv6)
15108 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15109 sizeof (ip6_address_t));
15110 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15111 sizeof (ip6_address_t));
15115 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15116 sizeof (ip4_address_t));
15117 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15118 sizeof (ip4_address_t));
15128 api_ipsec_sa_set_key (vat_main_t * vam)
15130 unformat_input_t *i = vam->input;
15131 vl_api_ipsec_sa_set_key_t *mp;
15133 u8 *ck = 0, *ik = 0;
15136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15138 if (unformat (i, "sa_id %d", &sa_id))
15140 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15142 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15146 clib_warning ("parse error '%U'", format_unformat_error, i);
15151 M (IPSEC_SA_SET_KEY, mp);
15153 mp->sa_id = ntohl (sa_id);
15154 mp->crypto_key_length = vec_len (ck);
15155 mp->integrity_key_length = vec_len (ik);
15157 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15158 mp->crypto_key_length = sizeof (mp->crypto_key);
15160 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15161 mp->integrity_key_length = sizeof (mp->integrity_key);
15164 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15166 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15174 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15176 unformat_input_t *i = vam->input;
15177 vl_api_ipsec_tunnel_if_add_del_t *mp;
15178 u32 local_spi = 0, remote_spi = 0;
15179 u32 crypto_alg = 0, integ_alg = 0;
15180 u8 *lck = NULL, *rck = NULL;
15181 u8 *lik = NULL, *rik = NULL;
15182 ip4_address_t local_ip = { {0} };
15183 ip4_address_t remote_ip = { {0} };
15186 u8 anti_replay = 0;
15191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15193 if (unformat (i, "del"))
15195 else if (unformat (i, "esn"))
15197 else if (unformat (i, "anti_replay"))
15199 else if (unformat (i, "local_spi %d", &local_spi))
15201 else if (unformat (i, "remote_spi %d", &remote_spi))
15203 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15205 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15207 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15210 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15212 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15214 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15218 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15220 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15221 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15223 errmsg ("unsupported crypto-alg: '%U'\n",
15224 format_ipsec_crypto_alg, crypto_alg);
15230 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15232 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15233 integ_alg >= IPSEC_INTEG_N_ALG)
15235 errmsg ("unsupported integ-alg: '%U'\n",
15236 format_ipsec_integ_alg, integ_alg);
15240 else if (unformat (i, "instance %u", &instance))
15244 errmsg ("parse error '%U'\n", format_unformat_error, i);
15249 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15251 mp->is_add = is_add;
15253 mp->anti_replay = anti_replay;
15255 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15256 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15258 mp->local_spi = htonl (local_spi);
15259 mp->remote_spi = htonl (remote_spi);
15260 mp->crypto_alg = (u8) crypto_alg;
15262 mp->local_crypto_key_len = 0;
15265 mp->local_crypto_key_len = vec_len (lck);
15266 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15267 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15268 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15271 mp->remote_crypto_key_len = 0;
15274 mp->remote_crypto_key_len = vec_len (rck);
15275 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15276 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15277 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15280 mp->integ_alg = (u8) integ_alg;
15282 mp->local_integ_key_len = 0;
15285 mp->local_integ_key_len = vec_len (lik);
15286 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15287 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15288 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15291 mp->remote_integ_key_len = 0;
15294 mp->remote_integ_key_len = vec_len (rik);
15295 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15296 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15297 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15302 mp->renumber = renumber;
15303 mp->show_instance = ntohl (instance);
15312 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15314 vat_main_t *vam = &vat_main;
15316 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15317 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15318 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15319 "tunnel_src_addr %U tunnel_dst_addr %U "
15320 "salt %u seq_outbound %lu last_seq_inbound %lu "
15321 "replay_window %lu total_data_size %lu\n",
15322 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15324 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15325 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15326 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15327 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15328 mp->tunnel_src_addr,
15329 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15330 mp->tunnel_dst_addr,
15332 clib_net_to_host_u64 (mp->seq_outbound),
15333 clib_net_to_host_u64 (mp->last_seq_inbound),
15334 clib_net_to_host_u64 (mp->replay_window),
15335 clib_net_to_host_u64 (mp->total_data_size));
15338 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15339 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15341 static void vl_api_ipsec_sa_details_t_handler_json
15342 (vl_api_ipsec_sa_details_t * mp)
15344 vat_main_t *vam = &vat_main;
15345 vat_json_node_t *node = NULL;
15346 struct in_addr src_ip4, dst_ip4;
15347 struct in6_addr src_ip6, dst_ip6;
15349 if (VAT_JSON_ARRAY != vam->json_tree.type)
15351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15352 vat_json_init_array (&vam->json_tree);
15354 node = vat_json_array_add (&vam->json_tree);
15356 vat_json_init_object (node);
15357 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15358 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15359 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15360 vat_json_object_add_uint (node, "proto", mp->protocol);
15361 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15362 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15363 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15364 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15365 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15366 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15367 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15368 mp->crypto_key_len);
15369 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15370 mp->integ_key_len);
15371 if (mp->is_tunnel_ip6)
15373 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15374 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15375 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15376 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15380 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15381 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15382 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15383 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15385 vat_json_object_add_uint (node, "replay_window",
15386 clib_net_to_host_u64 (mp->replay_window));
15387 vat_json_object_add_uint (node, "total_data_size",
15388 clib_net_to_host_u64 (mp->total_data_size));
15393 api_ipsec_sa_dump (vat_main_t * vam)
15395 unformat_input_t *i = vam->input;
15396 vl_api_ipsec_sa_dump_t *mp;
15397 vl_api_control_ping_t *mp_ping;
15401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15403 if (unformat (i, "sa_id %d", &sa_id))
15407 clib_warning ("parse error '%U'", format_unformat_error, i);
15412 M (IPSEC_SA_DUMP, mp);
15414 mp->sa_id = ntohl (sa_id);
15418 /* Use a control ping for synchronization */
15419 M (CONTROL_PING, mp_ping);
15427 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15429 unformat_input_t *i = vam->input;
15430 vl_api_ipsec_tunnel_if_set_key_t *mp;
15431 u32 sw_if_index = ~0;
15432 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15442 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15443 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15445 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15446 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15447 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15448 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15450 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15451 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15452 else if (unformat (i, "%U", unformat_hex_string, &key))
15456 clib_warning ("parse error '%U'", format_unformat_error, i);
15461 if (sw_if_index == ~0)
15463 errmsg ("interface must be specified");
15467 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15469 errmsg ("key type must be specified");
15475 errmsg ("algorithm must be specified");
15479 if (vec_len (key) == 0)
15481 errmsg ("key must be specified");
15485 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15487 mp->sw_if_index = htonl (sw_if_index);
15489 mp->key_type = key_type;
15490 mp->key_len = vec_len (key);
15491 clib_memcpy (mp->key, key, vec_len (key));
15500 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15502 unformat_input_t *i = vam->input;
15503 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15504 u32 sw_if_index = ~0;
15506 u8 is_outbound = (u8) ~ 0;
15509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15513 else if (unformat (i, "sa_id %d", &sa_id))
15515 else if (unformat (i, "outbound"))
15517 else if (unformat (i, "inbound"))
15521 clib_warning ("parse error '%U'", format_unformat_error, i);
15526 if (sw_if_index == ~0)
15528 errmsg ("interface must be specified");
15534 errmsg ("SA ID must be specified");
15538 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15540 mp->sw_if_index = htonl (sw_if_index);
15541 mp->sa_id = htonl (sa_id);
15542 mp->is_outbound = is_outbound;
15551 api_ikev2_profile_add_del (vat_main_t * vam)
15553 unformat_input_t *i = vam->input;
15554 vl_api_ikev2_profile_add_del_t *mp;
15559 const char *valid_chars = "a-zA-Z0-9_";
15561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15563 if (unformat (i, "del"))
15565 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15566 vec_add1 (name, 0);
15569 errmsg ("parse error '%U'", format_unformat_error, i);
15574 if (!vec_len (name))
15576 errmsg ("profile name must be specified");
15580 if (vec_len (name) > 64)
15582 errmsg ("profile name too long");
15586 M (IKEV2_PROFILE_ADD_DEL, mp);
15588 clib_memcpy (mp->name, name, vec_len (name));
15589 mp->is_add = is_add;
15598 api_ikev2_profile_set_auth (vat_main_t * vam)
15600 unformat_input_t *i = vam->input;
15601 vl_api_ikev2_profile_set_auth_t *mp;
15604 u32 auth_method = 0;
15608 const char *valid_chars = "a-zA-Z0-9_";
15610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15612 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15613 vec_add1 (name, 0);
15614 else if (unformat (i, "auth_method %U",
15615 unformat_ikev2_auth_method, &auth_method))
15617 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15619 else if (unformat (i, "auth_data %v", &data))
15623 errmsg ("parse error '%U'", format_unformat_error, i);
15628 if (!vec_len (name))
15630 errmsg ("profile name must be specified");
15634 if (vec_len (name) > 64)
15636 errmsg ("profile name too long");
15640 if (!vec_len (data))
15642 errmsg ("auth_data must be specified");
15648 errmsg ("auth_method must be specified");
15652 M (IKEV2_PROFILE_SET_AUTH, mp);
15654 mp->is_hex = is_hex;
15655 mp->auth_method = (u8) auth_method;
15656 mp->data_len = vec_len (data);
15657 clib_memcpy (mp->name, name, vec_len (name));
15658 clib_memcpy (mp->data, data, vec_len (data));
15668 api_ikev2_profile_set_id (vat_main_t * vam)
15670 unformat_input_t *i = vam->input;
15671 vl_api_ikev2_profile_set_id_t *mp;
15679 const char *valid_chars = "a-zA-Z0-9_";
15681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15683 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15684 vec_add1 (name, 0);
15685 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15687 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15689 data = vec_new (u8, 4);
15690 clib_memcpy (data, ip4.as_u8, 4);
15692 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15694 else if (unformat (i, "id_data %v", &data))
15696 else if (unformat (i, "local"))
15698 else if (unformat (i, "remote"))
15702 errmsg ("parse error '%U'", format_unformat_error, i);
15707 if (!vec_len (name))
15709 errmsg ("profile name must be specified");
15713 if (vec_len (name) > 64)
15715 errmsg ("profile name too long");
15719 if (!vec_len (data))
15721 errmsg ("id_data must be specified");
15727 errmsg ("id_type must be specified");
15731 M (IKEV2_PROFILE_SET_ID, mp);
15733 mp->is_local = is_local;
15734 mp->id_type = (u8) id_type;
15735 mp->data_len = vec_len (data);
15736 clib_memcpy (mp->name, name, vec_len (name));
15737 clib_memcpy (mp->data, data, vec_len (data));
15747 api_ikev2_profile_set_ts (vat_main_t * vam)
15749 unformat_input_t *i = vam->input;
15750 vl_api_ikev2_profile_set_ts_t *mp;
15753 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15754 ip4_address_t start_addr, end_addr;
15756 const char *valid_chars = "a-zA-Z0-9_";
15759 start_addr.as_u32 = 0;
15760 end_addr.as_u32 = (u32) ~ 0;
15762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15764 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15765 vec_add1 (name, 0);
15766 else if (unformat (i, "protocol %d", &proto))
15768 else if (unformat (i, "start_port %d", &start_port))
15770 else if (unformat (i, "end_port %d", &end_port))
15773 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15775 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15777 else if (unformat (i, "local"))
15779 else if (unformat (i, "remote"))
15783 errmsg ("parse error '%U'", format_unformat_error, i);
15788 if (!vec_len (name))
15790 errmsg ("profile name must be specified");
15794 if (vec_len (name) > 64)
15796 errmsg ("profile name too long");
15800 M (IKEV2_PROFILE_SET_TS, mp);
15802 mp->is_local = is_local;
15803 mp->proto = (u8) proto;
15804 mp->start_port = (u16) start_port;
15805 mp->end_port = (u16) end_port;
15806 mp->start_addr = start_addr.as_u32;
15807 mp->end_addr = end_addr.as_u32;
15808 clib_memcpy (mp->name, name, vec_len (name));
15817 api_ikev2_set_local_key (vat_main_t * vam)
15819 unformat_input_t *i = vam->input;
15820 vl_api_ikev2_set_local_key_t *mp;
15824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15826 if (unformat (i, "file %v", &file))
15827 vec_add1 (file, 0);
15830 errmsg ("parse error '%U'", format_unformat_error, i);
15835 if (!vec_len (file))
15837 errmsg ("RSA key file must be specified");
15841 if (vec_len (file) > 256)
15843 errmsg ("file name too long");
15847 M (IKEV2_SET_LOCAL_KEY, mp);
15849 clib_memcpy (mp->key_file, file, vec_len (file));
15858 api_ikev2_set_responder (vat_main_t * vam)
15860 unformat_input_t *i = vam->input;
15861 vl_api_ikev2_set_responder_t *mp;
15864 u32 sw_if_index = ~0;
15865 ip4_address_t address;
15867 const char *valid_chars = "a-zA-Z0-9_";
15869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15872 (i, "%U interface %d address %U", unformat_token, valid_chars,
15873 &name, &sw_if_index, unformat_ip4_address, &address))
15874 vec_add1 (name, 0);
15877 errmsg ("parse error '%U'", format_unformat_error, i);
15882 if (!vec_len (name))
15884 errmsg ("profile name must be specified");
15888 if (vec_len (name) > 64)
15890 errmsg ("profile name too long");
15894 M (IKEV2_SET_RESPONDER, mp);
15896 clib_memcpy (mp->name, name, vec_len (name));
15899 mp->sw_if_index = sw_if_index;
15900 clib_memcpy (mp->address, &address, sizeof (address));
15908 api_ikev2_set_ike_transforms (vat_main_t * vam)
15910 unformat_input_t *i = vam->input;
15911 vl_api_ikev2_set_ike_transforms_t *mp;
15914 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15916 const char *valid_chars = "a-zA-Z0-9_";
15918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15920 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15921 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15922 vec_add1 (name, 0);
15925 errmsg ("parse error '%U'", format_unformat_error, i);
15930 if (!vec_len (name))
15932 errmsg ("profile name must be specified");
15936 if (vec_len (name) > 64)
15938 errmsg ("profile name too long");
15942 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15944 clib_memcpy (mp->name, name, vec_len (name));
15946 mp->crypto_alg = crypto_alg;
15947 mp->crypto_key_size = crypto_key_size;
15948 mp->integ_alg = integ_alg;
15949 mp->dh_group = dh_group;
15958 api_ikev2_set_esp_transforms (vat_main_t * vam)
15960 unformat_input_t *i = vam->input;
15961 vl_api_ikev2_set_esp_transforms_t *mp;
15964 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15966 const char *valid_chars = "a-zA-Z0-9_";
15968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15970 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15971 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15972 vec_add1 (name, 0);
15975 errmsg ("parse error '%U'", format_unformat_error, i);
15980 if (!vec_len (name))
15982 errmsg ("profile name must be specified");
15986 if (vec_len (name) > 64)
15988 errmsg ("profile name too long");
15992 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15994 clib_memcpy (mp->name, name, vec_len (name));
15996 mp->crypto_alg = crypto_alg;
15997 mp->crypto_key_size = crypto_key_size;
15998 mp->integ_alg = integ_alg;
15999 mp->dh_group = dh_group;
16007 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16009 unformat_input_t *i = vam->input;
16010 vl_api_ikev2_set_sa_lifetime_t *mp;
16013 u64 lifetime, lifetime_maxdata;
16014 u32 lifetime_jitter, handover;
16016 const char *valid_chars = "a-zA-Z0-9_";
16018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16020 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16021 &lifetime, &lifetime_jitter, &handover,
16022 &lifetime_maxdata))
16023 vec_add1 (name, 0);
16026 errmsg ("parse error '%U'", format_unformat_error, i);
16031 if (!vec_len (name))
16033 errmsg ("profile name must be specified");
16037 if (vec_len (name) > 64)
16039 errmsg ("profile name too long");
16043 M (IKEV2_SET_SA_LIFETIME, mp);
16045 clib_memcpy (mp->name, name, vec_len (name));
16047 mp->lifetime = lifetime;
16048 mp->lifetime_jitter = lifetime_jitter;
16049 mp->handover = handover;
16050 mp->lifetime_maxdata = lifetime_maxdata;
16058 api_ikev2_initiate_sa_init (vat_main_t * vam)
16060 unformat_input_t *i = vam->input;
16061 vl_api_ikev2_initiate_sa_init_t *mp;
16065 const char *valid_chars = "a-zA-Z0-9_";
16067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16069 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16070 vec_add1 (name, 0);
16073 errmsg ("parse error '%U'", format_unformat_error, i);
16078 if (!vec_len (name))
16080 errmsg ("profile name must be specified");
16084 if (vec_len (name) > 64)
16086 errmsg ("profile name too long");
16090 M (IKEV2_INITIATE_SA_INIT, mp);
16092 clib_memcpy (mp->name, name, vec_len (name));
16101 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16103 unformat_input_t *i = vam->input;
16104 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16111 if (unformat (i, "%lx", &ispi))
16115 errmsg ("parse error '%U'", format_unformat_error, i);
16120 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16130 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16132 unformat_input_t *i = vam->input;
16133 vl_api_ikev2_initiate_del_child_sa_t *mp;
16138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16140 if (unformat (i, "%x", &ispi))
16144 errmsg ("parse error '%U'", format_unformat_error, i);
16149 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16159 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16161 unformat_input_t *i = vam->input;
16162 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16169 if (unformat (i, "%x", &ispi))
16173 errmsg ("parse error '%U'", format_unformat_error, i);
16178 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16191 api_map_add_domain (vat_main_t * vam)
16193 unformat_input_t *i = vam->input;
16194 vl_api_map_add_domain_t *mp;
16196 ip4_address_t ip4_prefix;
16197 ip6_address_t ip6_prefix;
16198 ip6_address_t ip6_src;
16199 u32 num_m_args = 0;
16200 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16201 0, psid_length = 0;
16202 u8 is_translation = 0;
16204 u32 ip6_src_len = 128;
16207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16209 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16210 &ip4_prefix, &ip4_prefix_len))
16212 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16213 &ip6_prefix, &ip6_prefix_len))
16217 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16220 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16222 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16224 else if (unformat (i, "psid-offset %d", &psid_offset))
16226 else if (unformat (i, "psid-len %d", &psid_length))
16228 else if (unformat (i, "mtu %d", &mtu))
16230 else if (unformat (i, "map-t"))
16231 is_translation = 1;
16234 clib_warning ("parse error '%U'", format_unformat_error, i);
16239 if (num_m_args < 3)
16241 errmsg ("mandatory argument(s) missing");
16245 /* Construct the API message */
16246 M (MAP_ADD_DOMAIN, mp);
16248 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16249 mp->ip4_prefix_len = ip4_prefix_len;
16251 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16252 mp->ip6_prefix_len = ip6_prefix_len;
16254 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16255 mp->ip6_src_prefix_len = ip6_src_len;
16257 mp->ea_bits_len = ea_bits_len;
16258 mp->psid_offset = psid_offset;
16259 mp->psid_length = psid_length;
16260 mp->is_translation = is_translation;
16261 mp->mtu = htons (mtu);
16266 /* Wait for a reply, return good/bad news */
16272 api_map_del_domain (vat_main_t * vam)
16274 unformat_input_t *i = vam->input;
16275 vl_api_map_del_domain_t *mp;
16277 u32 num_m_args = 0;
16281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16283 if (unformat (i, "index %d", &index))
16287 clib_warning ("parse error '%U'", format_unformat_error, i);
16292 if (num_m_args != 1)
16294 errmsg ("mandatory argument(s) missing");
16298 /* Construct the API message */
16299 M (MAP_DEL_DOMAIN, mp);
16301 mp->index = ntohl (index);
16306 /* Wait for a reply, return good/bad news */
16312 api_map_add_del_rule (vat_main_t * vam)
16314 unformat_input_t *i = vam->input;
16315 vl_api_map_add_del_rule_t *mp;
16317 ip6_address_t ip6_dst;
16318 u32 num_m_args = 0, index, psid = 0;
16321 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16323 if (unformat (i, "index %d", &index))
16325 else if (unformat (i, "psid %d", &psid))
16327 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16329 else if (unformat (i, "del"))
16335 clib_warning ("parse error '%U'", format_unformat_error, i);
16340 /* Construct the API message */
16341 M (MAP_ADD_DEL_RULE, mp);
16343 mp->index = ntohl (index);
16344 mp->is_add = is_add;
16345 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16346 mp->psid = ntohs (psid);
16351 /* Wait for a reply, return good/bad news */
16357 api_map_domain_dump (vat_main_t * vam)
16359 vl_api_map_domain_dump_t *mp;
16360 vl_api_control_ping_t *mp_ping;
16363 /* Construct the API message */
16364 M (MAP_DOMAIN_DUMP, mp);
16369 /* Use a control ping for synchronization */
16370 MPING (CONTROL_PING, mp_ping);
16378 api_map_rule_dump (vat_main_t * vam)
16380 unformat_input_t *i = vam->input;
16381 vl_api_map_rule_dump_t *mp;
16382 vl_api_control_ping_t *mp_ping;
16383 u32 domain_index = ~0;
16386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16388 if (unformat (i, "index %u", &domain_index))
16394 if (domain_index == ~0)
16396 clib_warning ("parse error: domain index expected");
16400 /* Construct the API message */
16401 M (MAP_RULE_DUMP, mp);
16403 mp->domain_index = htonl (domain_index);
16408 /* Use a control ping for synchronization */
16409 MPING (CONTROL_PING, mp_ping);
16416 static void vl_api_map_add_domain_reply_t_handler
16417 (vl_api_map_add_domain_reply_t * mp)
16419 vat_main_t *vam = &vat_main;
16420 i32 retval = ntohl (mp->retval);
16422 if (vam->async_mode)
16424 vam->async_errors += (retval < 0);
16428 vam->retval = retval;
16429 vam->result_ready = 1;
16433 static void vl_api_map_add_domain_reply_t_handler_json
16434 (vl_api_map_add_domain_reply_t * mp)
16436 vat_main_t *vam = &vat_main;
16437 vat_json_node_t node;
16439 vat_json_init_object (&node);
16440 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16441 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16443 vat_json_print (vam->ofp, &node);
16444 vat_json_free (&node);
16446 vam->retval = ntohl (mp->retval);
16447 vam->result_ready = 1;
16451 api_get_first_msg_id (vat_main_t * vam)
16453 vl_api_get_first_msg_id_t *mp;
16454 unformat_input_t *i = vam->input;
16459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16461 if (unformat (i, "client %s", &name))
16469 errmsg ("missing client name");
16472 vec_add1 (name, 0);
16474 if (vec_len (name) > 63)
16476 errmsg ("client name too long");
16480 M (GET_FIRST_MSG_ID, mp);
16481 clib_memcpy (mp->name, name, vec_len (name));
16488 api_cop_interface_enable_disable (vat_main_t * vam)
16490 unformat_input_t *line_input = vam->input;
16491 vl_api_cop_interface_enable_disable_t *mp;
16492 u32 sw_if_index = ~0;
16493 u8 enable_disable = 1;
16496 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16498 if (unformat (line_input, "disable"))
16499 enable_disable = 0;
16500 if (unformat (line_input, "enable"))
16501 enable_disable = 1;
16502 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16503 vam, &sw_if_index))
16505 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16511 if (sw_if_index == ~0)
16513 errmsg ("missing interface name or sw_if_index");
16517 /* Construct the API message */
16518 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16519 mp->sw_if_index = ntohl (sw_if_index);
16520 mp->enable_disable = enable_disable;
16524 /* Wait for the reply */
16530 api_cop_whitelist_enable_disable (vat_main_t * vam)
16532 unformat_input_t *line_input = vam->input;
16533 vl_api_cop_whitelist_enable_disable_t *mp;
16534 u32 sw_if_index = ~0;
16535 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16539 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16541 if (unformat (line_input, "ip4"))
16543 else if (unformat (line_input, "ip6"))
16545 else if (unformat (line_input, "default"))
16547 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16548 vam, &sw_if_index))
16550 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16552 else if (unformat (line_input, "fib-id %d", &fib_id))
16558 if (sw_if_index == ~0)
16560 errmsg ("missing interface name or sw_if_index");
16564 /* Construct the API message */
16565 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16566 mp->sw_if_index = ntohl (sw_if_index);
16567 mp->fib_id = ntohl (fib_id);
16570 mp->default_cop = default_cop;
16574 /* Wait for the reply */
16580 api_get_node_graph (vat_main_t * vam)
16582 vl_api_get_node_graph_t *mp;
16585 M (GET_NODE_GRAPH, mp);
16589 /* Wait for the reply */
16595 /** Used for parsing LISP eids */
16596 typedef CLIB_PACKED(struct{
16597 u8 addr[16]; /**< eid address */
16598 u32 len; /**< prefix length if IP */
16599 u8 type; /**< type of eid */
16604 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16606 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16608 memset (a, 0, sizeof (a[0]));
16610 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16612 a->type = 0; /* ipv4 type */
16614 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16616 a->type = 1; /* ipv6 type */
16618 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16620 a->type = 2; /* mac type */
16622 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16624 a->type = 3; /* NSH type */
16625 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16626 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16633 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16642 lisp_eid_size_vat (u8 type)
16659 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16661 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16665 api_one_add_del_locator_set (vat_main_t * vam)
16667 unformat_input_t *input = vam->input;
16668 vl_api_one_add_del_locator_set_t *mp;
16670 u8 *locator_set_name = NULL;
16671 u8 locator_set_name_set = 0;
16672 vl_api_local_locator_t locator, *locators = 0;
16673 u32 sw_if_index, priority, weight;
16677 /* Parse args required to build the message */
16678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16680 if (unformat (input, "del"))
16684 else if (unformat (input, "locator-set %s", &locator_set_name))
16686 locator_set_name_set = 1;
16688 else if (unformat (input, "sw_if_index %u p %u w %u",
16689 &sw_if_index, &priority, &weight))
16691 locator.sw_if_index = htonl (sw_if_index);
16692 locator.priority = priority;
16693 locator.weight = weight;
16694 vec_add1 (locators, locator);
16698 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16699 &sw_if_index, &priority, &weight))
16701 locator.sw_if_index = htonl (sw_if_index);
16702 locator.priority = priority;
16703 locator.weight = weight;
16704 vec_add1 (locators, locator);
16710 if (locator_set_name_set == 0)
16712 errmsg ("missing locator-set name");
16713 vec_free (locators);
16717 if (vec_len (locator_set_name) > 64)
16719 errmsg ("locator-set name too long");
16720 vec_free (locator_set_name);
16721 vec_free (locators);
16724 vec_add1 (locator_set_name, 0);
16726 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16728 /* Construct the API message */
16729 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16731 mp->is_add = is_add;
16732 clib_memcpy (mp->locator_set_name, locator_set_name,
16733 vec_len (locator_set_name));
16734 vec_free (locator_set_name);
16736 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16738 clib_memcpy (mp->locators, locators, data_len);
16739 vec_free (locators);
16744 /* Wait for a reply... */
16749 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16752 api_one_add_del_locator (vat_main_t * vam)
16754 unformat_input_t *input = vam->input;
16755 vl_api_one_add_del_locator_t *mp;
16756 u32 tmp_if_index = ~0;
16757 u32 sw_if_index = ~0;
16758 u8 sw_if_index_set = 0;
16759 u8 sw_if_index_if_name_set = 0;
16761 u8 priority_set = 0;
16765 u8 *locator_set_name = NULL;
16766 u8 locator_set_name_set = 0;
16769 /* Parse args required to build the message */
16770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16772 if (unformat (input, "del"))
16776 else if (unformat (input, "locator-set %s", &locator_set_name))
16778 locator_set_name_set = 1;
16780 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16783 sw_if_index_if_name_set = 1;
16784 sw_if_index = tmp_if_index;
16786 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16788 sw_if_index_set = 1;
16789 sw_if_index = tmp_if_index;
16791 else if (unformat (input, "p %d", &priority))
16795 else if (unformat (input, "w %d", &weight))
16803 if (locator_set_name_set == 0)
16805 errmsg ("missing locator-set name");
16809 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16811 errmsg ("missing sw_if_index");
16812 vec_free (locator_set_name);
16816 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16818 errmsg ("cannot use both params interface name and sw_if_index");
16819 vec_free (locator_set_name);
16823 if (priority_set == 0)
16825 errmsg ("missing locator-set priority");
16826 vec_free (locator_set_name);
16830 if (weight_set == 0)
16832 errmsg ("missing locator-set weight");
16833 vec_free (locator_set_name);
16837 if (vec_len (locator_set_name) > 64)
16839 errmsg ("locator-set name too long");
16840 vec_free (locator_set_name);
16843 vec_add1 (locator_set_name, 0);
16845 /* Construct the API message */
16846 M (ONE_ADD_DEL_LOCATOR, mp);
16848 mp->is_add = is_add;
16849 mp->sw_if_index = ntohl (sw_if_index);
16850 mp->priority = priority;
16851 mp->weight = weight;
16852 clib_memcpy (mp->locator_set_name, locator_set_name,
16853 vec_len (locator_set_name));
16854 vec_free (locator_set_name);
16859 /* Wait for a reply... */
16864 #define api_lisp_add_del_locator api_one_add_del_locator
16867 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16869 u32 *key_id = va_arg (*args, u32 *);
16872 if (unformat (input, "%s", &s))
16874 if (!strcmp ((char *) s, "sha1"))
16875 key_id[0] = HMAC_SHA_1_96;
16876 else if (!strcmp ((char *) s, "sha256"))
16877 key_id[0] = HMAC_SHA_256_128;
16880 clib_warning ("invalid key_id: '%s'", s);
16881 key_id[0] = HMAC_NO_KEY;
16892 api_one_add_del_local_eid (vat_main_t * vam)
16894 unformat_input_t *input = vam->input;
16895 vl_api_one_add_del_local_eid_t *mp;
16898 lisp_eid_vat_t _eid, *eid = &_eid;
16899 u8 *locator_set_name = 0;
16900 u8 locator_set_name_set = 0;
16906 /* Parse args required to build the message */
16907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16909 if (unformat (input, "del"))
16913 else if (unformat (input, "vni %d", &vni))
16917 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16921 else if (unformat (input, "locator-set %s", &locator_set_name))
16923 locator_set_name_set = 1;
16925 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16927 else if (unformat (input, "secret-key %_%v%_", &key))
16933 if (locator_set_name_set == 0)
16935 errmsg ("missing locator-set name");
16941 errmsg ("EID address not set!");
16942 vec_free (locator_set_name);
16946 if (key && (0 == key_id))
16948 errmsg ("invalid key_id!");
16952 if (vec_len (key) > 64)
16954 errmsg ("key too long");
16959 if (vec_len (locator_set_name) > 64)
16961 errmsg ("locator-set name too long");
16962 vec_free (locator_set_name);
16965 vec_add1 (locator_set_name, 0);
16967 /* Construct the API message */
16968 M (ONE_ADD_DEL_LOCAL_EID, mp);
16970 mp->is_add = is_add;
16971 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16972 mp->eid_type = eid->type;
16973 mp->prefix_len = eid->len;
16974 mp->vni = clib_host_to_net_u32 (vni);
16975 mp->key_id = clib_host_to_net_u16 (key_id);
16976 clib_memcpy (mp->locator_set_name, locator_set_name,
16977 vec_len (locator_set_name));
16978 clib_memcpy (mp->key, key, vec_len (key));
16980 vec_free (locator_set_name);
16986 /* Wait for a reply... */
16991 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16994 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16996 u32 dp_table = 0, vni = 0;;
16997 unformat_input_t *input = vam->input;
16998 vl_api_gpe_add_del_fwd_entry_t *mp;
17000 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17001 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17002 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17003 u32 action = ~0, w;
17004 ip4_address_t rmt_rloc4, lcl_rloc4;
17005 ip6_address_t rmt_rloc6, lcl_rloc6;
17006 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17009 memset (&rloc, 0, sizeof (rloc));
17011 /* Parse args required to build the message */
17012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17014 if (unformat (input, "del"))
17016 else if (unformat (input, "add"))
17018 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17022 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17026 else if (unformat (input, "vrf %d", &dp_table))
17028 else if (unformat (input, "bd %d", &dp_table))
17030 else if (unformat (input, "vni %d", &vni))
17032 else if (unformat (input, "w %d", &w))
17036 errmsg ("No RLOC configured for setting priority/weight!");
17039 curr_rloc->weight = w;
17041 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17042 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17046 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17048 vec_add1 (lcl_locs, rloc);
17050 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17051 vec_add1 (rmt_locs, rloc);
17052 /* weight saved in rmt loc */
17053 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17055 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17056 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17059 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17061 vec_add1 (lcl_locs, rloc);
17063 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17064 vec_add1 (rmt_locs, rloc);
17065 /* weight saved in rmt loc */
17066 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17068 else if (unformat (input, "action %d", &action))
17074 clib_warning ("parse error '%U'", format_unformat_error, input);
17081 errmsg ("remote eid addresses not set");
17085 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17087 errmsg ("eid types don't match");
17091 if (0 == rmt_locs && (u32) ~ 0 == action)
17093 errmsg ("action not set for negative mapping");
17097 /* Construct the API message */
17098 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17099 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17101 mp->is_add = is_add;
17102 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17103 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17104 mp->eid_type = rmt_eid->type;
17105 mp->dp_table = clib_host_to_net_u32 (dp_table);
17106 mp->vni = clib_host_to_net_u32 (vni);
17107 mp->rmt_len = rmt_eid->len;
17108 mp->lcl_len = lcl_eid->len;
17109 mp->action = action;
17111 if (0 != rmt_locs && 0 != lcl_locs)
17113 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17114 clib_memcpy (mp->locs, lcl_locs,
17115 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17117 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17118 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17119 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17121 vec_free (lcl_locs);
17122 vec_free (rmt_locs);
17127 /* Wait for a reply... */
17133 api_one_add_del_map_server (vat_main_t * vam)
17135 unformat_input_t *input = vam->input;
17136 vl_api_one_add_del_map_server_t *mp;
17140 ip4_address_t ipv4;
17141 ip6_address_t ipv6;
17144 /* Parse args required to build the message */
17145 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17147 if (unformat (input, "del"))
17151 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17155 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17163 if (ipv4_set && ipv6_set)
17165 errmsg ("both eid v4 and v6 addresses set");
17169 if (!ipv4_set && !ipv6_set)
17171 errmsg ("eid addresses not set");
17175 /* Construct the API message */
17176 M (ONE_ADD_DEL_MAP_SERVER, mp);
17178 mp->is_add = is_add;
17182 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17187 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17193 /* Wait for a reply... */
17198 #define api_lisp_add_del_map_server api_one_add_del_map_server
17201 api_one_add_del_map_resolver (vat_main_t * vam)
17203 unformat_input_t *input = vam->input;
17204 vl_api_one_add_del_map_resolver_t *mp;
17208 ip4_address_t ipv4;
17209 ip6_address_t ipv6;
17212 /* Parse args required to build the message */
17213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17215 if (unformat (input, "del"))
17219 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17223 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17231 if (ipv4_set && ipv6_set)
17233 errmsg ("both eid v4 and v6 addresses set");
17237 if (!ipv4_set && !ipv6_set)
17239 errmsg ("eid addresses not set");
17243 /* Construct the API message */
17244 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17246 mp->is_add = is_add;
17250 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17255 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17261 /* Wait for a reply... */
17266 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17269 api_lisp_gpe_enable_disable (vat_main_t * vam)
17271 unformat_input_t *input = vam->input;
17272 vl_api_gpe_enable_disable_t *mp;
17277 /* Parse args required to build the message */
17278 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17280 if (unformat (input, "enable"))
17285 else if (unformat (input, "disable"))
17296 errmsg ("Value not set");
17300 /* Construct the API message */
17301 M (GPE_ENABLE_DISABLE, mp);
17308 /* Wait for a reply... */
17314 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17316 unformat_input_t *input = vam->input;
17317 vl_api_one_rloc_probe_enable_disable_t *mp;
17322 /* Parse args required to build the message */
17323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17325 if (unformat (input, "enable"))
17330 else if (unformat (input, "disable"))
17338 errmsg ("Value not set");
17342 /* Construct the API message */
17343 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17345 mp->is_enabled = is_en;
17350 /* Wait for a reply... */
17355 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17358 api_one_map_register_enable_disable (vat_main_t * vam)
17360 unformat_input_t *input = vam->input;
17361 vl_api_one_map_register_enable_disable_t *mp;
17366 /* Parse args required to build the message */
17367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17369 if (unformat (input, "enable"))
17374 else if (unformat (input, "disable"))
17382 errmsg ("Value not set");
17386 /* Construct the API message */
17387 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17389 mp->is_enabled = is_en;
17394 /* Wait for a reply... */
17399 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17402 api_one_enable_disable (vat_main_t * vam)
17404 unformat_input_t *input = vam->input;
17405 vl_api_one_enable_disable_t *mp;
17410 /* Parse args required to build the message */
17411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17413 if (unformat (input, "enable"))
17418 else if (unformat (input, "disable"))
17428 errmsg ("Value not set");
17432 /* Construct the API message */
17433 M (ONE_ENABLE_DISABLE, mp);
17440 /* Wait for a reply... */
17445 #define api_lisp_enable_disable api_one_enable_disable
17448 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17450 unformat_input_t *input = vam->input;
17451 vl_api_one_enable_disable_xtr_mode_t *mp;
17456 /* Parse args required to build the message */
17457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17459 if (unformat (input, "enable"))
17464 else if (unformat (input, "disable"))
17474 errmsg ("Value not set");
17478 /* Construct the API message */
17479 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17486 /* Wait for a reply... */
17492 api_one_show_xtr_mode (vat_main_t * vam)
17494 vl_api_one_show_xtr_mode_t *mp;
17497 /* Construct the API message */
17498 M (ONE_SHOW_XTR_MODE, mp);
17503 /* Wait for a reply... */
17509 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17511 unformat_input_t *input = vam->input;
17512 vl_api_one_enable_disable_pitr_mode_t *mp;
17517 /* Parse args required to build the message */
17518 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17520 if (unformat (input, "enable"))
17525 else if (unformat (input, "disable"))
17535 errmsg ("Value not set");
17539 /* Construct the API message */
17540 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17547 /* Wait for a reply... */
17553 api_one_show_pitr_mode (vat_main_t * vam)
17555 vl_api_one_show_pitr_mode_t *mp;
17558 /* Construct the API message */
17559 M (ONE_SHOW_PITR_MODE, mp);
17564 /* Wait for a reply... */
17570 api_one_enable_disable_petr_mode (vat_main_t * vam)
17572 unformat_input_t *input = vam->input;
17573 vl_api_one_enable_disable_petr_mode_t *mp;
17578 /* Parse args required to build the message */
17579 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17581 if (unformat (input, "enable"))
17586 else if (unformat (input, "disable"))
17596 errmsg ("Value not set");
17600 /* Construct the API message */
17601 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17608 /* Wait for a reply... */
17614 api_one_show_petr_mode (vat_main_t * vam)
17616 vl_api_one_show_petr_mode_t *mp;
17619 /* Construct the API message */
17620 M (ONE_SHOW_PETR_MODE, mp);
17625 /* Wait for a reply... */
17631 api_show_one_map_register_state (vat_main_t * vam)
17633 vl_api_show_one_map_register_state_t *mp;
17636 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17641 /* wait for reply */
17646 #define api_show_lisp_map_register_state api_show_one_map_register_state
17649 api_show_one_rloc_probe_state (vat_main_t * vam)
17651 vl_api_show_one_rloc_probe_state_t *mp;
17654 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17659 /* wait for reply */
17664 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17667 api_one_add_del_ndp_entry (vat_main_t * vam)
17669 vl_api_one_add_del_ndp_entry_t *mp;
17670 unformat_input_t *input = vam->input;
17675 u8 mac[6] = { 0, };
17676 u8 ip6[16] = { 0, };
17680 /* Parse args required to build the message */
17681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17683 if (unformat (input, "del"))
17685 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17687 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17689 else if (unformat (input, "bd %d", &bd))
17693 errmsg ("parse error '%U'", format_unformat_error, input);
17698 if (!bd_set || !ip_set || (!mac_set && is_add))
17700 errmsg ("Missing BD, IP or MAC!");
17704 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17705 mp->is_add = is_add;
17706 clib_memcpy (mp->mac, mac, 6);
17707 mp->bd = clib_host_to_net_u32 (bd);
17708 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17713 /* wait for reply */
17719 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17721 vl_api_one_add_del_l2_arp_entry_t *mp;
17722 unformat_input_t *input = vam->input;
17727 u8 mac[6] = { 0, };
17728 u32 ip4 = 0, bd = ~0;
17731 /* Parse args required to build the message */
17732 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17734 if (unformat (input, "del"))
17736 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17738 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17740 else if (unformat (input, "bd %d", &bd))
17744 errmsg ("parse error '%U'", format_unformat_error, input);
17749 if (!bd_set || !ip_set || (!mac_set && is_add))
17751 errmsg ("Missing BD, IP or MAC!");
17755 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17756 mp->is_add = is_add;
17757 clib_memcpy (mp->mac, mac, 6);
17758 mp->bd = clib_host_to_net_u32 (bd);
17764 /* wait for reply */
17770 api_one_ndp_bd_get (vat_main_t * vam)
17772 vl_api_one_ndp_bd_get_t *mp;
17775 M (ONE_NDP_BD_GET, mp);
17780 /* wait for reply */
17786 api_one_ndp_entries_get (vat_main_t * vam)
17788 vl_api_one_ndp_entries_get_t *mp;
17789 unformat_input_t *input = vam->input;
17794 /* Parse args required to build the message */
17795 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17797 if (unformat (input, "bd %d", &bd))
17801 errmsg ("parse error '%U'", format_unformat_error, input);
17808 errmsg ("Expected bridge domain!");
17812 M (ONE_NDP_ENTRIES_GET, mp);
17813 mp->bd = clib_host_to_net_u32 (bd);
17818 /* wait for reply */
17824 api_one_l2_arp_bd_get (vat_main_t * vam)
17826 vl_api_one_l2_arp_bd_get_t *mp;
17829 M (ONE_L2_ARP_BD_GET, mp);
17834 /* wait for reply */
17840 api_one_l2_arp_entries_get (vat_main_t * vam)
17842 vl_api_one_l2_arp_entries_get_t *mp;
17843 unformat_input_t *input = vam->input;
17848 /* Parse args required to build the message */
17849 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17851 if (unformat (input, "bd %d", &bd))
17855 errmsg ("parse error '%U'", format_unformat_error, input);
17862 errmsg ("Expected bridge domain!");
17866 M (ONE_L2_ARP_ENTRIES_GET, mp);
17867 mp->bd = clib_host_to_net_u32 (bd);
17872 /* wait for reply */
17878 api_one_stats_enable_disable (vat_main_t * vam)
17880 vl_api_one_stats_enable_disable_t *mp;
17881 unformat_input_t *input = vam->input;
17886 /* Parse args required to build the message */
17887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17889 if (unformat (input, "enable"))
17894 else if (unformat (input, "disable"))
17904 errmsg ("Value not set");
17908 M (ONE_STATS_ENABLE_DISABLE, mp);
17914 /* wait for reply */
17920 api_show_one_stats_enable_disable (vat_main_t * vam)
17922 vl_api_show_one_stats_enable_disable_t *mp;
17925 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17930 /* wait for reply */
17936 api_show_one_map_request_mode (vat_main_t * vam)
17938 vl_api_show_one_map_request_mode_t *mp;
17941 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17946 /* wait for reply */
17951 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17954 api_one_map_request_mode (vat_main_t * vam)
17956 unformat_input_t *input = vam->input;
17957 vl_api_one_map_request_mode_t *mp;
17961 /* Parse args required to build the message */
17962 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17964 if (unformat (input, "dst-only"))
17966 else if (unformat (input, "src-dst"))
17970 errmsg ("parse error '%U'", format_unformat_error, input);
17975 M (ONE_MAP_REQUEST_MODE, mp);
17982 /* wait for reply */
17987 #define api_lisp_map_request_mode api_one_map_request_mode
17990 * Enable/disable ONE proxy ITR.
17992 * @param vam vpp API test context
17993 * @return return code
17996 api_one_pitr_set_locator_set (vat_main_t * vam)
17998 u8 ls_name_set = 0;
17999 unformat_input_t *input = vam->input;
18000 vl_api_one_pitr_set_locator_set_t *mp;
18005 /* Parse args required to build the message */
18006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18008 if (unformat (input, "del"))
18010 else if (unformat (input, "locator-set %s", &ls_name))
18014 errmsg ("parse error '%U'", format_unformat_error, input);
18021 errmsg ("locator-set name not set!");
18025 M (ONE_PITR_SET_LOCATOR_SET, mp);
18027 mp->is_add = is_add;
18028 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18029 vec_free (ls_name);
18034 /* wait for reply */
18039 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18042 api_one_nsh_set_locator_set (vat_main_t * vam)
18044 u8 ls_name_set = 0;
18045 unformat_input_t *input = vam->input;
18046 vl_api_one_nsh_set_locator_set_t *mp;
18051 /* Parse args required to build the message */
18052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18054 if (unformat (input, "del"))
18056 else if (unformat (input, "ls %s", &ls_name))
18060 errmsg ("parse error '%U'", format_unformat_error, input);
18065 if (!ls_name_set && is_add)
18067 errmsg ("locator-set name not set!");
18071 M (ONE_NSH_SET_LOCATOR_SET, mp);
18073 mp->is_add = is_add;
18074 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18075 vec_free (ls_name);
18080 /* wait for reply */
18086 api_show_one_pitr (vat_main_t * vam)
18088 vl_api_show_one_pitr_t *mp;
18091 if (!vam->json_output)
18093 print (vam->ofp, "%=20s", "lisp status:");
18096 M (SHOW_ONE_PITR, mp);
18100 /* Wait for a reply... */
18105 #define api_show_lisp_pitr api_show_one_pitr
18108 api_one_use_petr (vat_main_t * vam)
18110 unformat_input_t *input = vam->input;
18111 vl_api_one_use_petr_t *mp;
18116 memset (&ip, 0, sizeof (ip));
18118 /* Parse args required to build the message */
18119 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18121 if (unformat (input, "disable"))
18124 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18127 ip_addr_version (&ip) = IP4;
18130 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18133 ip_addr_version (&ip) = IP6;
18137 errmsg ("parse error '%U'", format_unformat_error, input);
18142 M (ONE_USE_PETR, mp);
18144 mp->is_add = is_add;
18147 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18149 clib_memcpy (mp->address, &ip, 4);
18151 clib_memcpy (mp->address, &ip, 16);
18157 /* wait for reply */
18162 #define api_lisp_use_petr api_one_use_petr
18165 api_show_one_nsh_mapping (vat_main_t * vam)
18167 vl_api_show_one_use_petr_t *mp;
18170 if (!vam->json_output)
18172 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18175 M (SHOW_ONE_NSH_MAPPING, mp);
18179 /* Wait for a reply... */
18185 api_show_one_use_petr (vat_main_t * vam)
18187 vl_api_show_one_use_petr_t *mp;
18190 if (!vam->json_output)
18192 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18195 M (SHOW_ONE_USE_PETR, mp);
18199 /* Wait for a reply... */
18204 #define api_show_lisp_use_petr api_show_one_use_petr
18207 * Add/delete mapping between vni and vrf
18210 api_one_eid_table_add_del_map (vat_main_t * vam)
18212 unformat_input_t *input = vam->input;
18213 vl_api_one_eid_table_add_del_map_t *mp;
18214 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18215 u32 vni, vrf, bd_index;
18218 /* Parse args required to build the message */
18219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18221 if (unformat (input, "del"))
18223 else if (unformat (input, "vrf %d", &vrf))
18225 else if (unformat (input, "bd_index %d", &bd_index))
18227 else if (unformat (input, "vni %d", &vni))
18233 if (!vni_set || (!vrf_set && !bd_index_set))
18235 errmsg ("missing arguments!");
18239 if (vrf_set && bd_index_set)
18241 errmsg ("error: both vrf and bd entered!");
18245 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18247 mp->is_add = is_add;
18248 mp->vni = htonl (vni);
18249 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18250 mp->is_l2 = bd_index_set;
18255 /* wait for reply */
18260 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18263 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18265 u32 *action = va_arg (*args, u32 *);
18268 if (unformat (input, "%s", &s))
18270 if (!strcmp ((char *) s, "no-action"))
18272 else if (!strcmp ((char *) s, "natively-forward"))
18274 else if (!strcmp ((char *) s, "send-map-request"))
18276 else if (!strcmp ((char *) s, "drop"))
18280 clib_warning ("invalid action: '%s'", s);
18292 * Add/del remote mapping to/from ONE control plane
18294 * @param vam vpp API test context
18295 * @return return code
18298 api_one_add_del_remote_mapping (vat_main_t * vam)
18300 unformat_input_t *input = vam->input;
18301 vl_api_one_add_del_remote_mapping_t *mp;
18303 lisp_eid_vat_t _eid, *eid = &_eid;
18304 lisp_eid_vat_t _seid, *seid = &_seid;
18305 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18306 u32 action = ~0, p, w, data_len;
18307 ip4_address_t rloc4;
18308 ip6_address_t rloc6;
18309 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18312 memset (&rloc, 0, sizeof (rloc));
18314 /* Parse args required to build the message */
18315 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18317 if (unformat (input, "del-all"))
18321 else if (unformat (input, "del"))
18325 else if (unformat (input, "add"))
18329 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18333 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18337 else if (unformat (input, "vni %d", &vni))
18341 else if (unformat (input, "p %d w %d", &p, &w))
18345 errmsg ("No RLOC configured for setting priority/weight!");
18348 curr_rloc->priority = p;
18349 curr_rloc->weight = w;
18351 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18354 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18355 vec_add1 (rlocs, rloc);
18356 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18358 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18361 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18362 vec_add1 (rlocs, rloc);
18363 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18365 else if (unformat (input, "action %U",
18366 unformat_negative_mapping_action, &action))
18372 clib_warning ("parse error '%U'", format_unformat_error, input);
18379 errmsg ("missing params!");
18383 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18385 errmsg ("no action set for negative map-reply!");
18389 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18391 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18392 mp->is_add = is_add;
18393 mp->vni = htonl (vni);
18394 mp->action = (u8) action;
18395 mp->is_src_dst = seid_set;
18396 mp->eid_len = eid->len;
18397 mp->seid_len = seid->len;
18398 mp->del_all = del_all;
18399 mp->eid_type = eid->type;
18400 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18401 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18403 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18404 clib_memcpy (mp->rlocs, rlocs, data_len);
18410 /* Wait for a reply... */
18415 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18418 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18419 * forwarding entries in data-plane accordingly.
18421 * @param vam vpp API test context
18422 * @return return code
18425 api_one_add_del_adjacency (vat_main_t * vam)
18427 unformat_input_t *input = vam->input;
18428 vl_api_one_add_del_adjacency_t *mp;
18430 ip4_address_t leid4, reid4;
18431 ip6_address_t leid6, reid6;
18432 u8 reid_mac[6] = { 0 };
18433 u8 leid_mac[6] = { 0 };
18434 u8 reid_type, leid_type;
18435 u32 leid_len = 0, reid_len = 0, len;
18439 leid_type = reid_type = (u8) ~ 0;
18441 /* Parse args required to build the message */
18442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18444 if (unformat (input, "del"))
18448 else if (unformat (input, "add"))
18452 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18455 reid_type = 0; /* ipv4 */
18458 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18461 reid_type = 1; /* ipv6 */
18464 else if (unformat (input, "reid %U", unformat_ethernet_address,
18467 reid_type = 2; /* mac */
18469 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18472 leid_type = 0; /* ipv4 */
18475 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18478 leid_type = 1; /* ipv6 */
18481 else if (unformat (input, "leid %U", unformat_ethernet_address,
18484 leid_type = 2; /* mac */
18486 else if (unformat (input, "vni %d", &vni))
18492 errmsg ("parse error '%U'", format_unformat_error, input);
18497 if ((u8) ~ 0 == reid_type)
18499 errmsg ("missing params!");
18503 if (leid_type != reid_type)
18505 errmsg ("remote and local EIDs are of different types!");
18509 M (ONE_ADD_DEL_ADJACENCY, mp);
18510 mp->is_add = is_add;
18511 mp->vni = htonl (vni);
18512 mp->leid_len = leid_len;
18513 mp->reid_len = reid_len;
18514 mp->eid_type = reid_type;
18516 switch (mp->eid_type)
18519 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18520 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18523 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18524 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18527 clib_memcpy (mp->leid, leid_mac, 6);
18528 clib_memcpy (mp->reid, reid_mac, 6);
18531 errmsg ("unknown EID type %d!", mp->eid_type);
18538 /* Wait for a reply... */
18543 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18546 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18548 u32 *mode = va_arg (*args, u32 *);
18550 if (unformat (input, "lisp"))
18552 else if (unformat (input, "vxlan"))
18561 api_gpe_get_encap_mode (vat_main_t * vam)
18563 vl_api_gpe_get_encap_mode_t *mp;
18566 /* Construct the API message */
18567 M (GPE_GET_ENCAP_MODE, mp);
18572 /* Wait for a reply... */
18578 api_gpe_set_encap_mode (vat_main_t * vam)
18580 unformat_input_t *input = vam->input;
18581 vl_api_gpe_set_encap_mode_t *mp;
18585 /* Parse args required to build the message */
18586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18588 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18594 /* Construct the API message */
18595 M (GPE_SET_ENCAP_MODE, mp);
18602 /* Wait for a reply... */
18608 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18610 unformat_input_t *input = vam->input;
18611 vl_api_gpe_add_del_iface_t *mp;
18612 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18613 u32 dp_table = 0, vni = 0;
18616 /* Parse args required to build the message */
18617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18619 if (unformat (input, "up"))
18624 else if (unformat (input, "down"))
18629 else if (unformat (input, "table_id %d", &dp_table))
18633 else if (unformat (input, "bd_id %d", &dp_table))
18638 else if (unformat (input, "vni %d", &vni))
18646 if (action_set == 0)
18648 errmsg ("Action not set");
18651 if (dp_table_set == 0 || vni_set == 0)
18653 errmsg ("vni and dp_table must be set");
18657 /* Construct the API message */
18658 M (GPE_ADD_DEL_IFACE, mp);
18660 mp->is_add = is_add;
18661 mp->dp_table = clib_host_to_net_u32 (dp_table);
18663 mp->vni = clib_host_to_net_u32 (vni);
18668 /* Wait for a reply... */
18674 api_one_map_register_fallback_threshold (vat_main_t * vam)
18676 unformat_input_t *input = vam->input;
18677 vl_api_one_map_register_fallback_threshold_t *mp;
18682 /* Parse args required to build the message */
18683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18685 if (unformat (input, "%u", &value))
18689 clib_warning ("parse error '%U'", format_unformat_error, input);
18696 errmsg ("fallback threshold value is missing!");
18700 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18701 mp->value = clib_host_to_net_u32 (value);
18706 /* Wait for a reply... */
18712 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18714 vl_api_show_one_map_register_fallback_threshold_t *mp;
18717 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18722 /* Wait for a reply... */
18728 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18730 u32 *proto = va_arg (*args, u32 *);
18732 if (unformat (input, "udp"))
18734 else if (unformat (input, "api"))
18743 api_one_set_transport_protocol (vat_main_t * vam)
18745 unformat_input_t *input = vam->input;
18746 vl_api_one_set_transport_protocol_t *mp;
18751 /* Parse args required to build the message */
18752 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18754 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18758 clib_warning ("parse error '%U'", format_unformat_error, input);
18765 errmsg ("Transport protocol missing!");
18769 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18770 mp->protocol = (u8) protocol;
18775 /* Wait for a reply... */
18781 api_one_get_transport_protocol (vat_main_t * vam)
18783 vl_api_one_get_transport_protocol_t *mp;
18786 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18791 /* Wait for a reply... */
18797 api_one_map_register_set_ttl (vat_main_t * vam)
18799 unformat_input_t *input = vam->input;
18800 vl_api_one_map_register_set_ttl_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", &ttl))
18812 clib_warning ("parse error '%U'", format_unformat_error, input);
18819 errmsg ("TTL value missing!");
18823 M (ONE_MAP_REGISTER_SET_TTL, mp);
18824 mp->ttl = clib_host_to_net_u32 (ttl);
18829 /* Wait for a reply... */
18835 api_show_one_map_register_ttl (vat_main_t * vam)
18837 vl_api_show_one_map_register_ttl_t *mp;
18840 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18845 /* Wait for a reply... */
18851 * Add/del map request itr rlocs from ONE control plane and updates
18853 * @param vam vpp API test context
18854 * @return return code
18857 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18859 unformat_input_t *input = vam->input;
18860 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18861 u8 *locator_set_name = 0;
18862 u8 locator_set_name_set = 0;
18866 /* Parse args required to build the message */
18867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18869 if (unformat (input, "del"))
18873 else if (unformat (input, "%_%v%_", &locator_set_name))
18875 locator_set_name_set = 1;
18879 clib_warning ("parse error '%U'", format_unformat_error, input);
18884 if (is_add && !locator_set_name_set)
18886 errmsg ("itr-rloc is not set!");
18890 if (is_add && vec_len (locator_set_name) > 64)
18892 errmsg ("itr-rloc locator-set name too long");
18893 vec_free (locator_set_name);
18897 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18898 mp->is_add = is_add;
18901 clib_memcpy (mp->locator_set_name, locator_set_name,
18902 vec_len (locator_set_name));
18906 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18908 vec_free (locator_set_name);
18913 /* Wait for a reply... */
18918 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18921 api_one_locator_dump (vat_main_t * vam)
18923 unformat_input_t *input = vam->input;
18924 vl_api_one_locator_dump_t *mp;
18925 vl_api_control_ping_t *mp_ping;
18926 u8 is_index_set = 0, is_name_set = 0;
18931 /* Parse args required to build the message */
18932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18934 if (unformat (input, "ls_name %_%v%_", &ls_name))
18938 else if (unformat (input, "ls_index %d", &ls_index))
18944 errmsg ("parse error '%U'", format_unformat_error, input);
18949 if (!is_index_set && !is_name_set)
18951 errmsg ("error: expected one of index or name!");
18955 if (is_index_set && is_name_set)
18957 errmsg ("error: only one param expected!");
18961 if (vec_len (ls_name) > 62)
18963 errmsg ("error: locator set name too long!");
18967 if (!vam->json_output)
18969 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18972 M (ONE_LOCATOR_DUMP, mp);
18973 mp->is_index_set = is_index_set;
18976 mp->ls_index = clib_host_to_net_u32 (ls_index);
18979 vec_add1 (ls_name, 0);
18980 strncpy ((char *) mp->ls_name, (char *) ls_name,
18981 sizeof (mp->ls_name) - 1);
18987 /* Use a control ping for synchronization */
18988 MPING (CONTROL_PING, mp_ping);
18991 /* Wait for a reply... */
18996 #define api_lisp_locator_dump api_one_locator_dump
18999 api_one_locator_set_dump (vat_main_t * vam)
19001 vl_api_one_locator_set_dump_t *mp;
19002 vl_api_control_ping_t *mp_ping;
19003 unformat_input_t *input = vam->input;
19007 /* Parse args required to build the message */
19008 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19010 if (unformat (input, "local"))
19014 else if (unformat (input, "remote"))
19020 errmsg ("parse error '%U'", format_unformat_error, input);
19025 if (!vam->json_output)
19027 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19030 M (ONE_LOCATOR_SET_DUMP, mp);
19032 mp->filter = filter;
19037 /* Use a control ping for synchronization */
19038 MPING (CONTROL_PING, mp_ping);
19041 /* Wait for a reply... */
19046 #define api_lisp_locator_set_dump api_one_locator_set_dump
19049 api_one_eid_table_map_dump (vat_main_t * vam)
19053 unformat_input_t *input = vam->input;
19054 vl_api_one_eid_table_map_dump_t *mp;
19055 vl_api_control_ping_t *mp_ping;
19058 /* Parse args required to build the message */
19059 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19061 if (unformat (input, "l2"))
19066 else if (unformat (input, "l3"))
19073 errmsg ("parse error '%U'", format_unformat_error, input);
19080 errmsg ("expected one of 'l2' or 'l3' parameter!");
19084 if (!vam->json_output)
19086 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19089 M (ONE_EID_TABLE_MAP_DUMP, mp);
19095 /* Use a control ping for synchronization */
19096 MPING (CONTROL_PING, mp_ping);
19099 /* Wait for a reply... */
19104 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19107 api_one_eid_table_vni_dump (vat_main_t * vam)
19109 vl_api_one_eid_table_vni_dump_t *mp;
19110 vl_api_control_ping_t *mp_ping;
19113 if (!vam->json_output)
19115 print (vam->ofp, "VNI");
19118 M (ONE_EID_TABLE_VNI_DUMP, mp);
19123 /* Use a control ping for synchronization */
19124 MPING (CONTROL_PING, mp_ping);
19127 /* Wait for a reply... */
19132 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19135 api_one_eid_table_dump (vat_main_t * vam)
19137 unformat_input_t *i = vam->input;
19138 vl_api_one_eid_table_dump_t *mp;
19139 vl_api_control_ping_t *mp_ping;
19140 struct in_addr ip4;
19141 struct in6_addr ip6;
19143 u8 eid_type = ~0, eid_set = 0;
19144 u32 prefix_length = ~0, t, vni = 0;
19147 lisp_nsh_api_t nsh;
19149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19151 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19157 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19163 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19168 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19173 else if (unformat (i, "vni %d", &t))
19177 else if (unformat (i, "local"))
19181 else if (unformat (i, "remote"))
19187 errmsg ("parse error '%U'", format_unformat_error, i);
19192 if (!vam->json_output)
19194 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19195 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19198 M (ONE_EID_TABLE_DUMP, mp);
19200 mp->filter = filter;
19204 mp->vni = htonl (vni);
19205 mp->eid_type = eid_type;
19209 mp->prefix_length = prefix_length;
19210 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19213 mp->prefix_length = prefix_length;
19214 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19217 clib_memcpy (mp->eid, mac, sizeof (mac));
19220 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19223 errmsg ("unknown EID type %d!", eid_type);
19231 /* Use a control ping for synchronization */
19232 MPING (CONTROL_PING, mp_ping);
19235 /* Wait for a reply... */
19240 #define api_lisp_eid_table_dump api_one_eid_table_dump
19243 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19245 unformat_input_t *i = vam->input;
19246 vl_api_gpe_fwd_entries_get_t *mp;
19251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19253 if (unformat (i, "vni %d", &vni))
19259 errmsg ("parse error '%U'", format_unformat_error, i);
19266 errmsg ("vni not set!");
19270 if (!vam->json_output)
19272 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19276 M (GPE_FWD_ENTRIES_GET, mp);
19277 mp->vni = clib_host_to_net_u32 (vni);
19282 /* Wait for a reply... */
19287 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19288 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19289 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19290 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19291 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19292 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19293 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19294 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19297 api_one_adjacencies_get (vat_main_t * vam)
19299 unformat_input_t *i = vam->input;
19300 vl_api_one_adjacencies_get_t *mp;
19305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19307 if (unformat (i, "vni %d", &vni))
19313 errmsg ("parse error '%U'", format_unformat_error, i);
19320 errmsg ("vni not set!");
19324 if (!vam->json_output)
19326 print (vam->ofp, "%s %40s", "leid", "reid");
19329 M (ONE_ADJACENCIES_GET, mp);
19330 mp->vni = clib_host_to_net_u32 (vni);
19335 /* Wait for a reply... */
19340 #define api_lisp_adjacencies_get api_one_adjacencies_get
19343 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19345 unformat_input_t *i = vam->input;
19346 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19348 u8 ip_family_set = 0, is_ip4 = 1;
19350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19352 if (unformat (i, "ip4"))
19357 else if (unformat (i, "ip6"))
19364 errmsg ("parse error '%U'", format_unformat_error, i);
19369 if (!ip_family_set)
19371 errmsg ("ip family not set!");
19375 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19376 mp->is_ip4 = is_ip4;
19381 /* Wait for a reply... */
19387 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19389 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19392 if (!vam->json_output)
19394 print (vam->ofp, "VNIs");
19397 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19402 /* Wait for a reply... */
19408 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19410 unformat_input_t *i = vam->input;
19411 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19413 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19414 struct in_addr ip4;
19415 struct in6_addr ip6;
19416 u32 table_id = 0, nh_sw_if_index = ~0;
19418 memset (&ip4, 0, sizeof (ip4));
19419 memset (&ip6, 0, sizeof (ip6));
19421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19423 if (unformat (i, "del"))
19425 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19426 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19431 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19432 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19437 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19441 nh_sw_if_index = ~0;
19443 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19447 nh_sw_if_index = ~0;
19449 else if (unformat (i, "table %d", &table_id))
19453 errmsg ("parse error '%U'", format_unformat_error, i);
19460 errmsg ("nh addr not set!");
19464 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19465 mp->is_add = is_add;
19466 mp->table_id = clib_host_to_net_u32 (table_id);
19467 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19468 mp->is_ip4 = is_ip4;
19470 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19472 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19477 /* Wait for a reply... */
19483 api_one_map_server_dump (vat_main_t * vam)
19485 vl_api_one_map_server_dump_t *mp;
19486 vl_api_control_ping_t *mp_ping;
19489 if (!vam->json_output)
19491 print (vam->ofp, "%=20s", "Map server");
19494 M (ONE_MAP_SERVER_DUMP, mp);
19498 /* Use a control ping for synchronization */
19499 MPING (CONTROL_PING, mp_ping);
19502 /* Wait for a reply... */
19507 #define api_lisp_map_server_dump api_one_map_server_dump
19510 api_one_map_resolver_dump (vat_main_t * vam)
19512 vl_api_one_map_resolver_dump_t *mp;
19513 vl_api_control_ping_t *mp_ping;
19516 if (!vam->json_output)
19518 print (vam->ofp, "%=20s", "Map resolver");
19521 M (ONE_MAP_RESOLVER_DUMP, mp);
19525 /* Use a control ping for synchronization */
19526 MPING (CONTROL_PING, mp_ping);
19529 /* Wait for a reply... */
19534 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19537 api_one_stats_flush (vat_main_t * vam)
19539 vl_api_one_stats_flush_t *mp;
19542 M (ONE_STATS_FLUSH, mp);
19549 api_one_stats_dump (vat_main_t * vam)
19551 vl_api_one_stats_dump_t *mp;
19552 vl_api_control_ping_t *mp_ping;
19555 M (ONE_STATS_DUMP, mp);
19559 /* Use a control ping for synchronization */
19560 MPING (CONTROL_PING, mp_ping);
19563 /* Wait for a reply... */
19569 api_show_one_status (vat_main_t * vam)
19571 vl_api_show_one_status_t *mp;
19574 if (!vam->json_output)
19576 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19579 M (SHOW_ONE_STATUS, mp);
19582 /* Wait for a reply... */
19587 #define api_show_lisp_status api_show_one_status
19590 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19592 vl_api_gpe_fwd_entry_path_dump_t *mp;
19593 vl_api_control_ping_t *mp_ping;
19594 unformat_input_t *i = vam->input;
19595 u32 fwd_entry_index = ~0;
19598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19600 if (unformat (i, "index %d", &fwd_entry_index))
19606 if (~0 == fwd_entry_index)
19608 errmsg ("no index specified!");
19612 if (!vam->json_output)
19614 print (vam->ofp, "first line");
19617 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19621 /* Use a control ping for synchronization */
19622 MPING (CONTROL_PING, mp_ping);
19625 /* Wait for a reply... */
19631 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19633 vl_api_one_get_map_request_itr_rlocs_t *mp;
19636 if (!vam->json_output)
19638 print (vam->ofp, "%=20s", "itr-rlocs:");
19641 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19644 /* Wait for a reply... */
19649 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19652 api_af_packet_create (vat_main_t * vam)
19654 unformat_input_t *i = vam->input;
19655 vl_api_af_packet_create_t *mp;
19656 u8 *host_if_name = 0;
19658 u8 random_hw_addr = 1;
19661 memset (hw_addr, 0, sizeof (hw_addr));
19663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19665 if (unformat (i, "name %s", &host_if_name))
19666 vec_add1 (host_if_name, 0);
19667 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19668 random_hw_addr = 0;
19673 if (!vec_len (host_if_name))
19675 errmsg ("host-interface name must be specified");
19679 if (vec_len (host_if_name) > 64)
19681 errmsg ("host-interface name too long");
19685 M (AF_PACKET_CREATE, mp);
19687 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19688 clib_memcpy (mp->hw_addr, hw_addr, 6);
19689 mp->use_random_hw_addr = random_hw_addr;
19690 vec_free (host_if_name);
19698 fprintf (vam->ofp ? vam->ofp : stderr,
19699 " new sw_if_index = %d\n", vam->sw_if_index);
19706 api_af_packet_delete (vat_main_t * vam)
19708 unformat_input_t *i = vam->input;
19709 vl_api_af_packet_delete_t *mp;
19710 u8 *host_if_name = 0;
19713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19715 if (unformat (i, "name %s", &host_if_name))
19716 vec_add1 (host_if_name, 0);
19721 if (!vec_len (host_if_name))
19723 errmsg ("host-interface name must be specified");
19727 if (vec_len (host_if_name) > 64)
19729 errmsg ("host-interface name too long");
19733 M (AF_PACKET_DELETE, mp);
19735 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19736 vec_free (host_if_name);
19744 api_policer_add_del (vat_main_t * vam)
19746 unformat_input_t *i = vam->input;
19747 vl_api_policer_add_del_t *mp;
19757 u8 color_aware = 0;
19758 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19761 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19762 conform_action.dscp = 0;
19763 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19764 exceed_action.dscp = 0;
19765 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19766 violate_action.dscp = 0;
19768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19770 if (unformat (i, "del"))
19772 else if (unformat (i, "name %s", &name))
19773 vec_add1 (name, 0);
19774 else if (unformat (i, "cir %u", &cir))
19776 else if (unformat (i, "eir %u", &eir))
19778 else if (unformat (i, "cb %u", &cb))
19780 else if (unformat (i, "eb %u", &eb))
19782 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19785 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19788 else if (unformat (i, "type %U", unformat_policer_type, &type))
19790 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19793 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19796 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19799 else if (unformat (i, "color-aware"))
19805 if (!vec_len (name))
19807 errmsg ("policer name must be specified");
19811 if (vec_len (name) > 64)
19813 errmsg ("policer name too long");
19817 M (POLICER_ADD_DEL, mp);
19819 clib_memcpy (mp->name, name, vec_len (name));
19821 mp->is_add = is_add;
19822 mp->cir = ntohl (cir);
19823 mp->eir = ntohl (eir);
19824 mp->cb = clib_net_to_host_u64 (cb);
19825 mp->eb = clib_net_to_host_u64 (eb);
19826 mp->rate_type = rate_type;
19827 mp->round_type = round_type;
19829 mp->conform_action_type = conform_action.action_type;
19830 mp->conform_dscp = conform_action.dscp;
19831 mp->exceed_action_type = exceed_action.action_type;
19832 mp->exceed_dscp = exceed_action.dscp;
19833 mp->violate_action_type = violate_action.action_type;
19834 mp->violate_dscp = violate_action.dscp;
19835 mp->color_aware = color_aware;
19843 api_policer_dump (vat_main_t * vam)
19845 unformat_input_t *i = vam->input;
19846 vl_api_policer_dump_t *mp;
19847 vl_api_control_ping_t *mp_ping;
19848 u8 *match_name = 0;
19849 u8 match_name_valid = 0;
19852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19854 if (unformat (i, "name %s", &match_name))
19856 vec_add1 (match_name, 0);
19857 match_name_valid = 1;
19863 M (POLICER_DUMP, mp);
19864 mp->match_name_valid = match_name_valid;
19865 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19866 vec_free (match_name);
19870 /* Use a control ping for synchronization */
19871 MPING (CONTROL_PING, mp_ping);
19874 /* Wait for a reply... */
19880 api_policer_classify_set_interface (vat_main_t * vam)
19882 unformat_input_t *i = vam->input;
19883 vl_api_policer_classify_set_interface_t *mp;
19885 int sw_if_index_set;
19886 u32 ip4_table_index = ~0;
19887 u32 ip6_table_index = ~0;
19888 u32 l2_table_index = ~0;
19892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19894 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19895 sw_if_index_set = 1;
19896 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19897 sw_if_index_set = 1;
19898 else if (unformat (i, "del"))
19900 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19902 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19904 else if (unformat (i, "l2-table %d", &l2_table_index))
19908 clib_warning ("parse error '%U'", format_unformat_error, i);
19913 if (sw_if_index_set == 0)
19915 errmsg ("missing interface name or sw_if_index");
19919 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19921 mp->sw_if_index = ntohl (sw_if_index);
19922 mp->ip4_table_index = ntohl (ip4_table_index);
19923 mp->ip6_table_index = ntohl (ip6_table_index);
19924 mp->l2_table_index = ntohl (l2_table_index);
19925 mp->is_add = is_add;
19933 api_policer_classify_dump (vat_main_t * vam)
19935 unformat_input_t *i = vam->input;
19936 vl_api_policer_classify_dump_t *mp;
19937 vl_api_control_ping_t *mp_ping;
19938 u8 type = POLICER_CLASSIFY_N_TABLES;
19941 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19945 errmsg ("classify table type must be specified");
19949 if (!vam->json_output)
19951 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19954 M (POLICER_CLASSIFY_DUMP, mp);
19959 /* Use a control ping for synchronization */
19960 MPING (CONTROL_PING, mp_ping);
19963 /* Wait for a reply... */
19969 api_netmap_create (vat_main_t * vam)
19971 unformat_input_t *i = vam->input;
19972 vl_api_netmap_create_t *mp;
19975 u8 random_hw_addr = 1;
19980 memset (hw_addr, 0, sizeof (hw_addr));
19982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19984 if (unformat (i, "name %s", &if_name))
19985 vec_add1 (if_name, 0);
19986 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19987 random_hw_addr = 0;
19988 else if (unformat (i, "pipe"))
19990 else if (unformat (i, "master"))
19992 else if (unformat (i, "slave"))
19998 if (!vec_len (if_name))
20000 errmsg ("interface name must be specified");
20004 if (vec_len (if_name) > 64)
20006 errmsg ("interface name too long");
20010 M (NETMAP_CREATE, mp);
20012 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20013 clib_memcpy (mp->hw_addr, hw_addr, 6);
20014 mp->use_random_hw_addr = random_hw_addr;
20015 mp->is_pipe = is_pipe;
20016 mp->is_master = is_master;
20017 vec_free (if_name);
20025 api_netmap_delete (vat_main_t * vam)
20027 unformat_input_t *i = vam->input;
20028 vl_api_netmap_delete_t *mp;
20032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20034 if (unformat (i, "name %s", &if_name))
20035 vec_add1 (if_name, 0);
20040 if (!vec_len (if_name))
20042 errmsg ("interface name must be specified");
20046 if (vec_len (if_name) > 64)
20048 errmsg ("interface name too long");
20052 M (NETMAP_DELETE, mp);
20054 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20055 vec_free (if_name);
20063 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20065 if (fp->afi == IP46_TYPE_IP6)
20067 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20068 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20069 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20070 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20071 format_ip6_address, fp->next_hop);
20072 else if (fp->afi == IP46_TYPE_IP4)
20074 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20075 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20076 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20077 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20078 format_ip4_address, fp->next_hop);
20082 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20083 vl_api_fib_path_t * fp)
20085 struct in_addr ip4;
20086 struct in6_addr ip6;
20088 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20089 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20090 vat_json_object_add_uint (node, "is_local", fp->is_local);
20091 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20092 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20093 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20094 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20095 if (fp->afi == IP46_TYPE_IP4)
20097 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20098 vat_json_object_add_ip4 (node, "next_hop", ip4);
20100 else if (fp->afi == IP46_TYPE_IP6)
20102 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20103 vat_json_object_add_ip6 (node, "next_hop", ip6);
20108 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20110 vat_main_t *vam = &vat_main;
20111 int count = ntohl (mp->mt_count);
20112 vl_api_fib_path_t *fp;
20115 print (vam->ofp, "[%d]: sw_if_index %d via:",
20116 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20118 for (i = 0; i < count; i++)
20120 vl_api_mpls_fib_path_print (vam, fp);
20124 print (vam->ofp, "");
20127 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20128 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20131 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20133 vat_main_t *vam = &vat_main;
20134 vat_json_node_t *node = NULL;
20135 int count = ntohl (mp->mt_count);
20136 vl_api_fib_path_t *fp;
20139 if (VAT_JSON_ARRAY != vam->json_tree.type)
20141 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20142 vat_json_init_array (&vam->json_tree);
20144 node = vat_json_array_add (&vam->json_tree);
20146 vat_json_init_object (node);
20147 vat_json_object_add_uint (node, "tunnel_index",
20148 ntohl (mp->mt_tunnel_index));
20149 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20151 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20154 for (i = 0; i < count; i++)
20156 vl_api_mpls_fib_path_json_print (node, fp);
20162 api_mpls_tunnel_dump (vat_main_t * vam)
20164 vl_api_mpls_tunnel_dump_t *mp;
20165 vl_api_control_ping_t *mp_ping;
20169 /* Parse args required to build the message */
20170 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20172 if (!unformat (vam->input, "tunnel_index %d", &index))
20179 print (vam->ofp, " tunnel_index %d", index);
20181 M (MPLS_TUNNEL_DUMP, mp);
20182 mp->tunnel_index = htonl (index);
20185 /* Use a control ping for synchronization */
20186 MPING (CONTROL_PING, mp_ping);
20193 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20194 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20198 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20200 vat_main_t *vam = &vat_main;
20201 int count = ntohl (mp->count);
20202 vl_api_fib_path_t *fp;
20206 "table-id %d, label %u, ess_bit %u",
20207 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20209 for (i = 0; i < count; i++)
20211 vl_api_mpls_fib_path_print (vam, fp);
20216 static void vl_api_mpls_fib_details_t_handler_json
20217 (vl_api_mpls_fib_details_t * mp)
20219 vat_main_t *vam = &vat_main;
20220 int count = ntohl (mp->count);
20221 vat_json_node_t *node = NULL;
20222 vl_api_fib_path_t *fp;
20225 if (VAT_JSON_ARRAY != vam->json_tree.type)
20227 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20228 vat_json_init_array (&vam->json_tree);
20230 node = vat_json_array_add (&vam->json_tree);
20232 vat_json_init_object (node);
20233 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20234 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20235 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20236 vat_json_object_add_uint (node, "path_count", count);
20238 for (i = 0; i < count; i++)
20240 vl_api_mpls_fib_path_json_print (node, fp);
20246 api_mpls_fib_dump (vat_main_t * vam)
20248 vl_api_mpls_fib_dump_t *mp;
20249 vl_api_control_ping_t *mp_ping;
20252 M (MPLS_FIB_DUMP, mp);
20255 /* Use a control ping for synchronization */
20256 MPING (CONTROL_PING, mp_ping);
20263 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20264 #define vl_api_ip_fib_details_t_print vl_noop_handler
20267 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20269 vat_main_t *vam = &vat_main;
20270 int count = ntohl (mp->count);
20271 vl_api_fib_path_t *fp;
20275 "table-id %d, prefix %U/%d",
20276 ntohl (mp->table_id), format_ip4_address, mp->address,
20277 mp->address_length);
20279 for (i = 0; i < count; i++)
20281 if (fp->afi == IP46_TYPE_IP6)
20283 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20284 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20285 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20286 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20287 format_ip6_address, fp->next_hop);
20288 else if (fp->afi == IP46_TYPE_IP4)
20290 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20291 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20292 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20293 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20294 format_ip4_address, fp->next_hop);
20299 static void vl_api_ip_fib_details_t_handler_json
20300 (vl_api_ip_fib_details_t * mp)
20302 vat_main_t *vam = &vat_main;
20303 int count = ntohl (mp->count);
20304 vat_json_node_t *node = NULL;
20305 struct in_addr ip4;
20306 struct in6_addr ip6;
20307 vl_api_fib_path_t *fp;
20310 if (VAT_JSON_ARRAY != vam->json_tree.type)
20312 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20313 vat_json_init_array (&vam->json_tree);
20315 node = vat_json_array_add (&vam->json_tree);
20317 vat_json_init_object (node);
20318 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20319 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20320 vat_json_object_add_ip4 (node, "prefix", ip4);
20321 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20322 vat_json_object_add_uint (node, "path_count", count);
20324 for (i = 0; i < count; i++)
20326 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20327 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20328 vat_json_object_add_uint (node, "is_local", fp->is_local);
20329 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20330 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20331 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20332 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20333 if (fp->afi == IP46_TYPE_IP4)
20335 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20336 vat_json_object_add_ip4 (node, "next_hop", ip4);
20338 else if (fp->afi == IP46_TYPE_IP6)
20340 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20341 vat_json_object_add_ip6 (node, "next_hop", ip6);
20347 api_ip_fib_dump (vat_main_t * vam)
20349 vl_api_ip_fib_dump_t *mp;
20350 vl_api_control_ping_t *mp_ping;
20353 M (IP_FIB_DUMP, mp);
20356 /* Use a control ping for synchronization */
20357 MPING (CONTROL_PING, mp_ping);
20365 api_ip_mfib_dump (vat_main_t * vam)
20367 vl_api_ip_mfib_dump_t *mp;
20368 vl_api_control_ping_t *mp_ping;
20371 M (IP_MFIB_DUMP, mp);
20374 /* Use a control ping for synchronization */
20375 MPING (CONTROL_PING, mp_ping);
20382 static void vl_api_ip_neighbor_details_t_handler
20383 (vl_api_ip_neighbor_details_t * mp)
20385 vat_main_t *vam = &vat_main;
20387 print (vam->ofp, "%c %U %U",
20388 (mp->is_static) ? 'S' : 'D',
20389 format_ethernet_address, &mp->mac_address,
20390 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20394 static void vl_api_ip_neighbor_details_t_handler_json
20395 (vl_api_ip_neighbor_details_t * mp)
20398 vat_main_t *vam = &vat_main;
20399 vat_json_node_t *node;
20400 struct in_addr ip4;
20401 struct in6_addr ip6;
20403 if (VAT_JSON_ARRAY != vam->json_tree.type)
20405 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20406 vat_json_init_array (&vam->json_tree);
20408 node = vat_json_array_add (&vam->json_tree);
20410 vat_json_init_object (node);
20411 vat_json_object_add_string_copy (node, "flag",
20412 (mp->is_static) ? (u8 *) "static" : (u8 *)
20415 vat_json_object_add_string_copy (node, "link_layer",
20416 format (0, "%U", format_ethernet_address,
20417 &mp->mac_address));
20421 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20422 vat_json_object_add_ip6 (node, "ip_address", ip6);
20426 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20427 vat_json_object_add_ip4 (node, "ip_address", ip4);
20432 api_ip_neighbor_dump (vat_main_t * vam)
20434 unformat_input_t *i = vam->input;
20435 vl_api_ip_neighbor_dump_t *mp;
20436 vl_api_control_ping_t *mp_ping;
20438 u32 sw_if_index = ~0;
20441 /* Parse args required to build the message */
20442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20444 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20446 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20448 else if (unformat (i, "ip6"))
20454 if (sw_if_index == ~0)
20456 errmsg ("missing interface name or sw_if_index");
20460 M (IP_NEIGHBOR_DUMP, mp);
20461 mp->is_ipv6 = (u8) is_ipv6;
20462 mp->sw_if_index = ntohl (sw_if_index);
20465 /* Use a control ping for synchronization */
20466 MPING (CONTROL_PING, mp_ping);
20473 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20474 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20477 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20479 vat_main_t *vam = &vat_main;
20480 int count = ntohl (mp->count);
20481 vl_api_fib_path_t *fp;
20485 "table-id %d, prefix %U/%d",
20486 ntohl (mp->table_id), format_ip6_address, mp->address,
20487 mp->address_length);
20489 for (i = 0; i < count; i++)
20491 if (fp->afi == IP46_TYPE_IP6)
20493 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20494 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20495 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20496 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20497 format_ip6_address, fp->next_hop);
20498 else if (fp->afi == IP46_TYPE_IP4)
20500 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20501 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20502 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20503 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20504 format_ip4_address, fp->next_hop);
20509 static void vl_api_ip6_fib_details_t_handler_json
20510 (vl_api_ip6_fib_details_t * mp)
20512 vat_main_t *vam = &vat_main;
20513 int count = ntohl (mp->count);
20514 vat_json_node_t *node = NULL;
20515 struct in_addr ip4;
20516 struct in6_addr ip6;
20517 vl_api_fib_path_t *fp;
20520 if (VAT_JSON_ARRAY != vam->json_tree.type)
20522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20523 vat_json_init_array (&vam->json_tree);
20525 node = vat_json_array_add (&vam->json_tree);
20527 vat_json_init_object (node);
20528 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20529 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20530 vat_json_object_add_ip6 (node, "prefix", ip6);
20531 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20532 vat_json_object_add_uint (node, "path_count", count);
20534 for (i = 0; i < count; i++)
20536 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20537 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20538 vat_json_object_add_uint (node, "is_local", fp->is_local);
20539 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20540 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20541 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20542 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20543 if (fp->afi == IP46_TYPE_IP4)
20545 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20546 vat_json_object_add_ip4 (node, "next_hop", ip4);
20548 else if (fp->afi == IP46_TYPE_IP6)
20550 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20551 vat_json_object_add_ip6 (node, "next_hop", ip6);
20557 api_ip6_fib_dump (vat_main_t * vam)
20559 vl_api_ip6_fib_dump_t *mp;
20560 vl_api_control_ping_t *mp_ping;
20563 M (IP6_FIB_DUMP, mp);
20566 /* Use a control ping for synchronization */
20567 MPING (CONTROL_PING, mp_ping);
20575 api_ip6_mfib_dump (vat_main_t * vam)
20577 vl_api_ip6_mfib_dump_t *mp;
20578 vl_api_control_ping_t *mp_ping;
20581 M (IP6_MFIB_DUMP, mp);
20584 /* Use a control ping for synchronization */
20585 MPING (CONTROL_PING, mp_ping);
20593 api_classify_table_ids (vat_main_t * vam)
20595 vl_api_classify_table_ids_t *mp;
20598 /* Construct the API message */
20599 M (CLASSIFY_TABLE_IDS, mp);
20608 api_classify_table_by_interface (vat_main_t * vam)
20610 unformat_input_t *input = vam->input;
20611 vl_api_classify_table_by_interface_t *mp;
20613 u32 sw_if_index = ~0;
20615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20617 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20619 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20624 if (sw_if_index == ~0)
20626 errmsg ("missing interface name or sw_if_index");
20630 /* Construct the API message */
20631 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20633 mp->sw_if_index = ntohl (sw_if_index);
20641 api_classify_table_info (vat_main_t * vam)
20643 unformat_input_t *input = vam->input;
20644 vl_api_classify_table_info_t *mp;
20648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20650 if (unformat (input, "table_id %d", &table_id))
20655 if (table_id == ~0)
20657 errmsg ("missing table id");
20661 /* Construct the API message */
20662 M (CLASSIFY_TABLE_INFO, mp);
20664 mp->table_id = ntohl (table_id);
20672 api_classify_session_dump (vat_main_t * vam)
20674 unformat_input_t *input = vam->input;
20675 vl_api_classify_session_dump_t *mp;
20676 vl_api_control_ping_t *mp_ping;
20680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20682 if (unformat (input, "table_id %d", &table_id))
20687 if (table_id == ~0)
20689 errmsg ("missing table id");
20693 /* Construct the API message */
20694 M (CLASSIFY_SESSION_DUMP, mp);
20696 mp->table_id = ntohl (table_id);
20699 /* Use a control ping for synchronization */
20700 MPING (CONTROL_PING, mp_ping);
20708 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20710 vat_main_t *vam = &vat_main;
20712 print (vam->ofp, "collector_address %U, collector_port %d, "
20713 "src_address %U, vrf_id %d, path_mtu %u, "
20714 "template_interval %u, udp_checksum %d",
20715 format_ip4_address, mp->collector_address,
20716 ntohs (mp->collector_port),
20717 format_ip4_address, mp->src_address,
20718 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20719 ntohl (mp->template_interval), mp->udp_checksum);
20722 vam->result_ready = 1;
20726 vl_api_ipfix_exporter_details_t_handler_json
20727 (vl_api_ipfix_exporter_details_t * mp)
20729 vat_main_t *vam = &vat_main;
20730 vat_json_node_t node;
20731 struct in_addr collector_address;
20732 struct in_addr src_address;
20734 vat_json_init_object (&node);
20735 clib_memcpy (&collector_address, &mp->collector_address,
20736 sizeof (collector_address));
20737 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20738 vat_json_object_add_uint (&node, "collector_port",
20739 ntohs (mp->collector_port));
20740 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20741 vat_json_object_add_ip4 (&node, "src_address", src_address);
20742 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20743 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20744 vat_json_object_add_uint (&node, "template_interval",
20745 ntohl (mp->template_interval));
20746 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20748 vat_json_print (vam->ofp, &node);
20749 vat_json_free (&node);
20751 vam->result_ready = 1;
20755 api_ipfix_exporter_dump (vat_main_t * vam)
20757 vl_api_ipfix_exporter_dump_t *mp;
20760 /* Construct the API message */
20761 M (IPFIX_EXPORTER_DUMP, mp);
20770 api_ipfix_classify_stream_dump (vat_main_t * vam)
20772 vl_api_ipfix_classify_stream_dump_t *mp;
20775 /* Construct the API message */
20776 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20787 vl_api_ipfix_classify_stream_details_t_handler
20788 (vl_api_ipfix_classify_stream_details_t * mp)
20790 vat_main_t *vam = &vat_main;
20791 print (vam->ofp, "domain_id %d, src_port %d",
20792 ntohl (mp->domain_id), ntohs (mp->src_port));
20794 vam->result_ready = 1;
20798 vl_api_ipfix_classify_stream_details_t_handler_json
20799 (vl_api_ipfix_classify_stream_details_t * mp)
20801 vat_main_t *vam = &vat_main;
20802 vat_json_node_t node;
20804 vat_json_init_object (&node);
20805 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20806 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20808 vat_json_print (vam->ofp, &node);
20809 vat_json_free (&node);
20811 vam->result_ready = 1;
20815 api_ipfix_classify_table_dump (vat_main_t * vam)
20817 vl_api_ipfix_classify_table_dump_t *mp;
20818 vl_api_control_ping_t *mp_ping;
20821 if (!vam->json_output)
20823 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20824 "transport_protocol");
20827 /* Construct the API message */
20828 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20833 /* Use a control ping for synchronization */
20834 MPING (CONTROL_PING, mp_ping);
20842 vl_api_ipfix_classify_table_details_t_handler
20843 (vl_api_ipfix_classify_table_details_t * mp)
20845 vat_main_t *vam = &vat_main;
20846 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20847 mp->transport_protocol);
20851 vl_api_ipfix_classify_table_details_t_handler_json
20852 (vl_api_ipfix_classify_table_details_t * mp)
20854 vat_json_node_t *node = NULL;
20855 vat_main_t *vam = &vat_main;
20857 if (VAT_JSON_ARRAY != vam->json_tree.type)
20859 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20860 vat_json_init_array (&vam->json_tree);
20863 node = vat_json_array_add (&vam->json_tree);
20864 vat_json_init_object (node);
20866 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20867 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20868 vat_json_object_add_uint (node, "transport_protocol",
20869 mp->transport_protocol);
20873 api_sw_interface_span_enable_disable (vat_main_t * vam)
20875 unformat_input_t *i = vam->input;
20876 vl_api_sw_interface_span_enable_disable_t *mp;
20877 u32 src_sw_if_index = ~0;
20878 u32 dst_sw_if_index = ~0;
20883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20886 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20888 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20892 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20894 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20896 else if (unformat (i, "disable"))
20898 else if (unformat (i, "rx"))
20900 else if (unformat (i, "tx"))
20902 else if (unformat (i, "both"))
20904 else if (unformat (i, "l2"))
20910 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20912 mp->sw_if_index_from = htonl (src_sw_if_index);
20913 mp->sw_if_index_to = htonl (dst_sw_if_index);
20923 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20926 vat_main_t *vam = &vat_main;
20927 u8 *sw_if_from_name = 0;
20928 u8 *sw_if_to_name = 0;
20929 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20930 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20931 char *states[] = { "none", "rx", "tx", "both" };
20935 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20937 if ((u32) p->value[0] == sw_if_index_from)
20939 sw_if_from_name = (u8 *)(p->key);
20943 if ((u32) p->value[0] == sw_if_index_to)
20945 sw_if_to_name = (u8 *)(p->key);
20946 if (sw_if_from_name)
20951 print (vam->ofp, "%20s => %20s (%s) %s",
20952 sw_if_from_name, sw_if_to_name, states[mp->state],
20953 mp->is_l2 ? "l2" : "device");
20957 vl_api_sw_interface_span_details_t_handler_json
20958 (vl_api_sw_interface_span_details_t * mp)
20960 vat_main_t *vam = &vat_main;
20961 vat_json_node_t *node = NULL;
20962 u8 *sw_if_from_name = 0;
20963 u8 *sw_if_to_name = 0;
20964 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20965 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20969 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20971 if ((u32) p->value[0] == sw_if_index_from)
20973 sw_if_from_name = (u8 *)(p->key);
20977 if ((u32) p->value[0] == sw_if_index_to)
20979 sw_if_to_name = (u8 *)(p->key);
20980 if (sw_if_from_name)
20986 if (VAT_JSON_ARRAY != vam->json_tree.type)
20988 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20989 vat_json_init_array (&vam->json_tree);
20991 node = vat_json_array_add (&vam->json_tree);
20993 vat_json_init_object (node);
20994 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20995 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20996 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20997 if (0 != sw_if_to_name)
20999 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21001 vat_json_object_add_uint (node, "state", mp->state);
21002 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21006 api_sw_interface_span_dump (vat_main_t * vam)
21008 unformat_input_t *input = vam->input;
21009 vl_api_sw_interface_span_dump_t *mp;
21010 vl_api_control_ping_t *mp_ping;
21014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21016 if (unformat (input, "l2"))
21022 M (SW_INTERFACE_SPAN_DUMP, mp);
21026 /* Use a control ping for synchronization */
21027 MPING (CONTROL_PING, mp_ping);
21035 api_pg_create_interface (vat_main_t * vam)
21037 unformat_input_t *input = vam->input;
21038 vl_api_pg_create_interface_t *mp;
21042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21044 if (unformat (input, "if_id %d", &if_id))
21051 errmsg ("missing pg interface index");
21055 /* Construct the API message */
21056 M (PG_CREATE_INTERFACE, mp);
21058 mp->interface_id = ntohl (if_id);
21066 api_pg_capture (vat_main_t * vam)
21068 unformat_input_t *input = vam->input;
21069 vl_api_pg_capture_t *mp;
21074 u8 pcap_file_set = 0;
21077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21079 if (unformat (input, "if_id %d", &if_id))
21081 else if (unformat (input, "pcap %s", &pcap_file))
21083 else if (unformat (input, "count %d", &count))
21085 else if (unformat (input, "disable"))
21092 errmsg ("missing pg interface index");
21095 if (pcap_file_set > 0)
21097 if (vec_len (pcap_file) > 255)
21099 errmsg ("pcap file name is too long");
21104 u32 name_len = vec_len (pcap_file);
21105 /* Construct the API message */
21106 M (PG_CAPTURE, mp);
21108 mp->interface_id = ntohl (if_id);
21109 mp->is_enabled = enable;
21110 mp->count = ntohl (count);
21111 mp->pcap_name_length = ntohl (name_len);
21112 if (pcap_file_set != 0)
21114 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21116 vec_free (pcap_file);
21124 api_pg_enable_disable (vat_main_t * vam)
21126 unformat_input_t *input = vam->input;
21127 vl_api_pg_enable_disable_t *mp;
21130 u8 stream_name_set = 0;
21131 u8 *stream_name = 0;
21133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21135 if (unformat (input, "stream %s", &stream_name))
21136 stream_name_set = 1;
21137 else if (unformat (input, "disable"))
21143 if (stream_name_set > 0)
21145 if (vec_len (stream_name) > 255)
21147 errmsg ("stream name too long");
21152 u32 name_len = vec_len (stream_name);
21153 /* Construct the API message */
21154 M (PG_ENABLE_DISABLE, mp);
21156 mp->is_enabled = enable;
21157 if (stream_name_set != 0)
21159 mp->stream_name_length = ntohl (name_len);
21160 clib_memcpy (mp->stream_name, stream_name, name_len);
21162 vec_free (stream_name);
21170 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21172 unformat_input_t *input = vam->input;
21173 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21175 u16 *low_ports = 0;
21176 u16 *high_ports = 0;
21179 ip4_address_t ip4_addr;
21180 ip6_address_t ip6_addr;
21189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21191 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21197 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21202 else if (unformat (input, "vrf %d", &vrf_id))
21204 else if (unformat (input, "del"))
21206 else if (unformat (input, "port %d", &tmp))
21208 if (tmp == 0 || tmp > 65535)
21210 errmsg ("port %d out of range", tmp);
21214 this_hi = this_low + 1;
21215 vec_add1 (low_ports, this_low);
21216 vec_add1 (high_ports, this_hi);
21218 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21220 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21222 errmsg ("incorrect range parameters");
21226 /* Note: in debug CLI +1 is added to high before
21227 passing to real fn that does "the work"
21228 (ip_source_and_port_range_check_add_del).
21229 This fn is a wrapper around the binary API fn a
21230 control plane will call, which expects this increment
21231 to have occurred. Hence letting the binary API control
21232 plane fn do the increment for consistency between VAT
21233 and other control planes.
21236 vec_add1 (low_ports, this_low);
21237 vec_add1 (high_ports, this_hi);
21243 if (prefix_set == 0)
21245 errmsg ("<address>/<mask> not specified");
21251 errmsg ("VRF ID required, not specified");
21258 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21262 if (vec_len (low_ports) == 0)
21264 errmsg ("At least one port or port range required");
21268 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21270 mp->is_add = is_add;
21275 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21280 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21283 mp->mask_length = length;
21284 mp->number_of_ranges = vec_len (low_ports);
21286 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21287 vec_free (low_ports);
21289 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21290 vec_free (high_ports);
21292 mp->vrf_id = ntohl (vrf_id);
21300 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21302 unformat_input_t *input = vam->input;
21303 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21304 u32 sw_if_index = ~0;
21306 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21307 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21311 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21313 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21315 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21317 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21319 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21321 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21323 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21325 else if (unformat (input, "del"))
21331 if (sw_if_index == ~0)
21333 errmsg ("Interface required but not specified");
21339 errmsg ("VRF ID required but not specified");
21343 if (tcp_out_vrf_id == 0
21344 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21347 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21351 /* Construct the API message */
21352 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21354 mp->sw_if_index = ntohl (sw_if_index);
21355 mp->is_add = is_add;
21356 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21357 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21358 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21359 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21364 /* Wait for a reply... */
21370 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21372 unformat_input_t *i = vam->input;
21373 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21374 u32 local_sa_id = 0;
21375 u32 remote_sa_id = 0;
21376 ip4_address_t src_address;
21377 ip4_address_t dst_address;
21381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21383 if (unformat (i, "local_sa %d", &local_sa_id))
21385 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21387 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21389 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21391 else if (unformat (i, "del"))
21395 clib_warning ("parse error '%U'", format_unformat_error, i);
21400 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21402 mp->local_sa_id = ntohl (local_sa_id);
21403 mp->remote_sa_id = ntohl (remote_sa_id);
21404 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21405 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21406 mp->is_add = is_add;
21414 api_punt (vat_main_t * vam)
21416 unformat_input_t *i = vam->input;
21424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21426 if (unformat (i, "ip %d", &ipv))
21428 else if (unformat (i, "protocol %d", &protocol))
21430 else if (unformat (i, "port %d", &port))
21432 else if (unformat (i, "del"))
21436 clib_warning ("parse error '%U'", format_unformat_error, i);
21443 mp->is_add = (u8) is_add;
21444 mp->ipv = (u8) ipv;
21445 mp->l4_protocol = (u8) protocol;
21446 mp->l4_port = htons ((u16) port);
21453 static void vl_api_ipsec_gre_tunnel_details_t_handler
21454 (vl_api_ipsec_gre_tunnel_details_t * mp)
21456 vat_main_t *vam = &vat_main;
21458 print (vam->ofp, "%11d%15U%15U%14d%14d",
21459 ntohl (mp->sw_if_index),
21460 format_ip4_address, &mp->src_address,
21461 format_ip4_address, &mp->dst_address,
21462 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21465 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21466 (vl_api_ipsec_gre_tunnel_details_t * mp)
21468 vat_main_t *vam = &vat_main;
21469 vat_json_node_t *node = NULL;
21470 struct in_addr ip4;
21472 if (VAT_JSON_ARRAY != vam->json_tree.type)
21474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21475 vat_json_init_array (&vam->json_tree);
21477 node = vat_json_array_add (&vam->json_tree);
21479 vat_json_init_object (node);
21480 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21481 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21482 vat_json_object_add_ip4 (node, "src_address", ip4);
21483 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21484 vat_json_object_add_ip4 (node, "dst_address", ip4);
21485 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21486 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21490 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21492 unformat_input_t *i = vam->input;
21493 vl_api_ipsec_gre_tunnel_dump_t *mp;
21494 vl_api_control_ping_t *mp_ping;
21496 u8 sw_if_index_set = 0;
21499 /* Parse args required to build the message */
21500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21502 if (unformat (i, "sw_if_index %d", &sw_if_index))
21503 sw_if_index_set = 1;
21508 if (sw_if_index_set == 0)
21513 if (!vam->json_output)
21515 print (vam->ofp, "%11s%15s%15s%14s%14s",
21516 "sw_if_index", "src_address", "dst_address",
21517 "local_sa_id", "remote_sa_id");
21520 /* Get list of gre-tunnel interfaces */
21521 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21523 mp->sw_if_index = htonl (sw_if_index);
21527 /* Use a control ping for synchronization */
21528 MPING (CONTROL_PING, mp_ping);
21536 api_delete_subif (vat_main_t * vam)
21538 unformat_input_t *i = vam->input;
21539 vl_api_delete_subif_t *mp;
21540 u32 sw_if_index = ~0;
21543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21545 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21547 if (unformat (i, "sw_if_index %d", &sw_if_index))
21553 if (sw_if_index == ~0)
21555 errmsg ("missing sw_if_index");
21559 /* Construct the API message */
21560 M (DELETE_SUBIF, mp);
21561 mp->sw_if_index = ntohl (sw_if_index);
21568 #define foreach_pbb_vtr_op \
21569 _("disable", L2_VTR_DISABLED) \
21570 _("pop", L2_VTR_POP_2) \
21571 _("push", L2_VTR_PUSH_2)
21574 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21576 unformat_input_t *i = vam->input;
21577 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21578 u32 sw_if_index = ~0, vtr_op = ~0;
21579 u16 outer_tag = ~0;
21580 u8 dmac[6], smac[6];
21581 u8 dmac_set = 0, smac_set = 0;
21587 /* Shut up coverity */
21588 memset (dmac, 0, sizeof (dmac));
21589 memset (smac, 0, sizeof (smac));
21591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21597 else if (unformat (i, "vtr_op %d", &vtr_op))
21599 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21602 else if (unformat (i, "translate_pbb_stag"))
21604 if (unformat (i, "%d", &tmp))
21606 vtr_op = L2_VTR_TRANSLATE_2_1;
21612 ("translate_pbb_stag operation requires outer tag definition");
21616 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21618 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21620 else if (unformat (i, "sid %d", &sid))
21622 else if (unformat (i, "vlanid %d", &tmp))
21626 clib_warning ("parse error '%U'", format_unformat_error, i);
21631 if ((sw_if_index == ~0) || (vtr_op == ~0))
21633 errmsg ("missing sw_if_index or vtr operation");
21636 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21637 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21640 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21644 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21645 mp->sw_if_index = ntohl (sw_if_index);
21646 mp->vtr_op = ntohl (vtr_op);
21647 mp->outer_tag = ntohs (outer_tag);
21648 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21649 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21650 mp->b_vlanid = ntohs (vlanid);
21651 mp->i_sid = ntohl (sid);
21659 api_flow_classify_set_interface (vat_main_t * vam)
21661 unformat_input_t *i = vam->input;
21662 vl_api_flow_classify_set_interface_t *mp;
21664 int sw_if_index_set;
21665 u32 ip4_table_index = ~0;
21666 u32 ip6_table_index = ~0;
21670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21673 sw_if_index_set = 1;
21674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21675 sw_if_index_set = 1;
21676 else if (unformat (i, "del"))
21678 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21680 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21684 clib_warning ("parse error '%U'", format_unformat_error, i);
21689 if (sw_if_index_set == 0)
21691 errmsg ("missing interface name or sw_if_index");
21695 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21697 mp->sw_if_index = ntohl (sw_if_index);
21698 mp->ip4_table_index = ntohl (ip4_table_index);
21699 mp->ip6_table_index = ntohl (ip6_table_index);
21700 mp->is_add = is_add;
21708 api_flow_classify_dump (vat_main_t * vam)
21710 unformat_input_t *i = vam->input;
21711 vl_api_flow_classify_dump_t *mp;
21712 vl_api_control_ping_t *mp_ping;
21713 u8 type = FLOW_CLASSIFY_N_TABLES;
21716 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21720 errmsg ("classify table type must be specified");
21724 if (!vam->json_output)
21726 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21729 M (FLOW_CLASSIFY_DUMP, mp);
21734 /* Use a control ping for synchronization */
21735 MPING (CONTROL_PING, mp_ping);
21738 /* Wait for a reply... */
21744 api_feature_enable_disable (vat_main_t * vam)
21746 unformat_input_t *i = vam->input;
21747 vl_api_feature_enable_disable_t *mp;
21749 u8 *feature_name = 0;
21750 u32 sw_if_index = ~0;
21754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21756 if (unformat (i, "arc_name %s", &arc_name))
21758 else if (unformat (i, "feature_name %s", &feature_name))
21761 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21763 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21765 else if (unformat (i, "disable"))
21773 errmsg ("missing arc name");
21776 if (vec_len (arc_name) > 63)
21778 errmsg ("arc name too long");
21781 if (feature_name == 0)
21783 errmsg ("missing feature name");
21786 if (vec_len (feature_name) > 63)
21788 errmsg ("feature name too long");
21791 if (sw_if_index == ~0)
21793 errmsg ("missing interface name or sw_if_index");
21797 /* Construct the API message */
21798 M (FEATURE_ENABLE_DISABLE, mp);
21799 mp->sw_if_index = ntohl (sw_if_index);
21800 mp->enable = enable;
21801 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21802 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21803 vec_free (arc_name);
21804 vec_free (feature_name);
21812 api_sw_interface_tag_add_del (vat_main_t * vam)
21814 unformat_input_t *i = vam->input;
21815 vl_api_sw_interface_tag_add_del_t *mp;
21816 u32 sw_if_index = ~0;
21821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21823 if (unformat (i, "tag %s", &tag))
21825 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21827 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21829 else if (unformat (i, "del"))
21835 if (sw_if_index == ~0)
21837 errmsg ("missing interface name or sw_if_index");
21841 if (enable && (tag == 0))
21843 errmsg ("no tag specified");
21847 /* Construct the API message */
21848 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21849 mp->sw_if_index = ntohl (sw_if_index);
21850 mp->is_add = enable;
21852 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21860 static void vl_api_l2_xconnect_details_t_handler
21861 (vl_api_l2_xconnect_details_t * mp)
21863 vat_main_t *vam = &vat_main;
21865 print (vam->ofp, "%15d%15d",
21866 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21869 static void vl_api_l2_xconnect_details_t_handler_json
21870 (vl_api_l2_xconnect_details_t * mp)
21872 vat_main_t *vam = &vat_main;
21873 vat_json_node_t *node = NULL;
21875 if (VAT_JSON_ARRAY != vam->json_tree.type)
21877 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21878 vat_json_init_array (&vam->json_tree);
21880 node = vat_json_array_add (&vam->json_tree);
21882 vat_json_init_object (node);
21883 vat_json_object_add_uint (node, "rx_sw_if_index",
21884 ntohl (mp->rx_sw_if_index));
21885 vat_json_object_add_uint (node, "tx_sw_if_index",
21886 ntohl (mp->tx_sw_if_index));
21890 api_l2_xconnect_dump (vat_main_t * vam)
21892 vl_api_l2_xconnect_dump_t *mp;
21893 vl_api_control_ping_t *mp_ping;
21896 if (!vam->json_output)
21898 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21901 M (L2_XCONNECT_DUMP, mp);
21905 /* Use a control ping for synchronization */
21906 MPING (CONTROL_PING, mp_ping);
21914 api_sw_interface_set_mtu (vat_main_t * vam)
21916 unformat_input_t *i = vam->input;
21917 vl_api_sw_interface_set_mtu_t *mp;
21918 u32 sw_if_index = ~0;
21922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21924 if (unformat (i, "mtu %d", &mtu))
21926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21934 if (sw_if_index == ~0)
21936 errmsg ("missing interface name or sw_if_index");
21942 errmsg ("no mtu specified");
21946 /* Construct the API message */
21947 M (SW_INTERFACE_SET_MTU, mp);
21948 mp->sw_if_index = ntohl (sw_if_index);
21949 mp->mtu = ntohs ((u16) mtu);
21957 api_p2p_ethernet_add (vat_main_t * vam)
21959 unformat_input_t *i = vam->input;
21960 vl_api_p2p_ethernet_add_t *mp;
21961 u32 parent_if_index = ~0;
21967 memset (remote_mac, 0, sizeof (remote_mac));
21968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21970 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21972 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21976 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21978 else if (unformat (i, "sub_id %d", &sub_id))
21982 clib_warning ("parse error '%U'", format_unformat_error, i);
21987 if (parent_if_index == ~0)
21989 errmsg ("missing interface name or sw_if_index");
21994 errmsg ("missing remote mac address");
21999 errmsg ("missing sub-interface id");
22003 M (P2P_ETHERNET_ADD, mp);
22004 mp->parent_if_index = ntohl (parent_if_index);
22005 mp->subif_id = ntohl (sub_id);
22006 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22014 api_p2p_ethernet_del (vat_main_t * vam)
22016 unformat_input_t *i = vam->input;
22017 vl_api_p2p_ethernet_del_t *mp;
22018 u32 parent_if_index = ~0;
22023 memset (remote_mac, 0, sizeof (remote_mac));
22024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22028 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22032 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22036 clib_warning ("parse error '%U'", format_unformat_error, i);
22041 if (parent_if_index == ~0)
22043 errmsg ("missing interface name or sw_if_index");
22048 errmsg ("missing remote mac address");
22052 M (P2P_ETHERNET_DEL, mp);
22053 mp->parent_if_index = ntohl (parent_if_index);
22054 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22062 api_lldp_config (vat_main_t * vam)
22064 unformat_input_t *i = vam->input;
22065 vl_api_lldp_config_t *mp;
22067 int tx_interval = 0;
22068 u8 *sys_name = NULL;
22071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22073 if (unformat (i, "system-name %s", &sys_name))
22075 else if (unformat (i, "tx-hold %d", &tx_hold))
22077 else if (unformat (i, "tx-interval %d", &tx_interval))
22081 clib_warning ("parse error '%U'", format_unformat_error, i);
22086 vec_add1 (sys_name, 0);
22088 M (LLDP_CONFIG, mp);
22089 mp->tx_hold = htonl (tx_hold);
22090 mp->tx_interval = htonl (tx_interval);
22091 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22092 vec_free (sys_name);
22100 api_sw_interface_set_lldp (vat_main_t * vam)
22102 unformat_input_t *i = vam->input;
22103 vl_api_sw_interface_set_lldp_t *mp;
22104 u32 sw_if_index = ~0;
22106 u8 *port_desc = NULL, *mgmt_oid = NULL;
22107 ip4_address_t ip4_addr;
22108 ip6_address_t ip6_addr;
22111 memset (&ip4_addr, 0, sizeof (ip4_addr));
22112 memset (&ip6_addr, 0, sizeof (ip6_addr));
22114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22116 if (unformat (i, "disable"))
22119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22123 else if (unformat (i, "port-desc %s", &port_desc))
22125 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22127 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22129 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22135 if (sw_if_index == ~0)
22137 errmsg ("missing interface name or sw_if_index");
22141 /* Construct the API message */
22142 vec_add1 (port_desc, 0);
22143 vec_add1 (mgmt_oid, 0);
22144 M (SW_INTERFACE_SET_LLDP, mp);
22145 mp->sw_if_index = ntohl (sw_if_index);
22146 mp->enable = enable;
22147 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22148 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22149 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22150 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22151 vec_free (port_desc);
22152 vec_free (mgmt_oid);
22160 api_tcp_configure_src_addresses (vat_main_t * vam)
22162 vl_api_tcp_configure_src_addresses_t *mp;
22163 unformat_input_t *i = vam->input;
22164 ip4_address_t v4first, v4last;
22165 ip6_address_t v6first, v6last;
22170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22172 if (unformat (i, "%U - %U",
22173 unformat_ip4_address, &v4first,
22174 unformat_ip4_address, &v4last))
22178 errmsg ("one range per message (range already set)");
22183 else if (unformat (i, "%U - %U",
22184 unformat_ip6_address, &v6first,
22185 unformat_ip6_address, &v6last))
22189 errmsg ("one range per message (range already set)");
22194 else if (unformat (i, "vrf %d", &vrf_id))
22200 if (range_set == 0)
22202 errmsg ("address range not set");
22206 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22207 mp->vrf_id = ntohl (vrf_id);
22209 if (range_set == 2)
22212 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22213 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22218 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22219 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22226 static void vl_api_app_namespace_add_del_reply_t_handler
22227 (vl_api_app_namespace_add_del_reply_t * mp)
22229 vat_main_t *vam = &vat_main;
22230 i32 retval = ntohl (mp->retval);
22231 if (vam->async_mode)
22233 vam->async_errors += (retval < 0);
22237 vam->retval = retval;
22239 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22240 vam->result_ready = 1;
22244 static void vl_api_app_namespace_add_del_reply_t_handler_json
22245 (vl_api_app_namespace_add_del_reply_t * mp)
22247 vat_main_t *vam = &vat_main;
22248 vat_json_node_t node;
22250 vat_json_init_object (&node);
22251 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22252 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22254 vat_json_print (vam->ofp, &node);
22255 vat_json_free (&node);
22257 vam->retval = ntohl (mp->retval);
22258 vam->result_ready = 1;
22262 api_app_namespace_add_del (vat_main_t * vam)
22264 vl_api_app_namespace_add_del_t *mp;
22265 unformat_input_t *i = vam->input;
22266 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22267 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22273 if (unformat (i, "id %_%v%_", &ns_id))
22275 else if (unformat (i, "secret %lu", &secret))
22277 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22278 sw_if_index_set = 1;
22279 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22281 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22286 if (!ns_id || !secret_set || !sw_if_index_set)
22288 errmsg ("namespace id, secret and sw_if_index must be set");
22291 if (vec_len (ns_id) > 64)
22293 errmsg ("namespace id too long");
22296 M (APP_NAMESPACE_ADD_DEL, mp);
22298 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22299 mp->namespace_id_len = vec_len (ns_id);
22300 mp->secret = clib_host_to_net_u64 (secret);
22301 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22302 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22303 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22311 api_sock_init_shm (vat_main_t * vam)
22313 #if VPP_API_TEST_BUILTIN == 0
22314 unformat_input_t *i = vam->input;
22315 vl_api_shm_elem_config_t *config = 0;
22316 u64 size = 64 << 20;
22319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22321 if (unformat (i, "size %U", unformat_memory_size, &size))
22328 * Canned custom ring allocator config.
22329 * Should probably parse all of this
22331 vec_validate (config, 6);
22332 config[0].type = VL_API_VLIB_RING;
22333 config[0].size = 256;
22334 config[0].count = 32;
22336 config[1].type = VL_API_VLIB_RING;
22337 config[1].size = 1024;
22338 config[1].count = 16;
22340 config[2].type = VL_API_VLIB_RING;
22341 config[2].size = 4096;
22342 config[2].count = 2;
22344 config[3].type = VL_API_CLIENT_RING;
22345 config[3].size = 256;
22346 config[3].count = 32;
22348 config[4].type = VL_API_CLIENT_RING;
22349 config[4].size = 1024;
22350 config[4].count = 16;
22352 config[5].type = VL_API_CLIENT_RING;
22353 config[5].size = 4096;
22354 config[5].count = 2;
22356 config[6].type = VL_API_QUEUE;
22357 config[6].count = 128;
22358 config[6].size = sizeof (uword);
22360 rv = vl_socket_client_init_shm (config);
22362 vam->client_index_invalid = 1;
22370 api_dns_enable_disable (vat_main_t * vam)
22372 unformat_input_t *line_input = vam->input;
22373 vl_api_dns_enable_disable_t *mp;
22374 u8 enable_disable = 1;
22377 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22379 if (unformat (line_input, "disable"))
22380 enable_disable = 0;
22381 if (unformat (line_input, "enable"))
22382 enable_disable = 1;
22387 /* Construct the API message */
22388 M (DNS_ENABLE_DISABLE, mp);
22389 mp->enable = enable_disable;
22393 /* Wait for the reply */
22399 api_dns_resolve_name (vat_main_t * vam)
22401 unformat_input_t *line_input = vam->input;
22402 vl_api_dns_resolve_name_t *mp;
22406 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22408 if (unformat (line_input, "%s", &name))
22414 if (vec_len (name) > 127)
22416 errmsg ("name too long");
22420 /* Construct the API message */
22421 M (DNS_RESOLVE_NAME, mp);
22422 memcpy (mp->name, name, vec_len (name));
22427 /* Wait for the reply */
22433 api_dns_resolve_ip (vat_main_t * vam)
22435 unformat_input_t *line_input = vam->input;
22436 vl_api_dns_resolve_ip_t *mp;
22438 ip4_address_t addr4;
22439 ip6_address_t addr6;
22442 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22444 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22446 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22454 errmsg ("missing address");
22458 /* Construct the API message */
22459 M (DNS_RESOLVE_IP, mp);
22460 mp->is_ip6 = is_ip6;
22462 memcpy (mp->address, &addr6, sizeof (addr6));
22464 memcpy (mp->address, &addr4, sizeof (addr4));
22468 /* Wait for the reply */
22474 api_dns_name_server_add_del (vat_main_t * vam)
22476 unformat_input_t *i = vam->input;
22477 vl_api_dns_name_server_add_del_t *mp;
22479 ip6_address_t ip6_server;
22480 ip4_address_t ip4_server;
22485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22487 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22489 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22491 else if (unformat (i, "del"))
22495 clib_warning ("parse error '%U'", format_unformat_error, i);
22500 if (ip4_set && ip6_set)
22502 errmsg ("Only one server address allowed per message");
22505 if ((ip4_set + ip6_set) == 0)
22507 errmsg ("Server address required");
22511 /* Construct the API message */
22512 M (DNS_NAME_SERVER_ADD_DEL, mp);
22516 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22521 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22525 mp->is_add = is_add;
22530 /* Wait for a reply, return good/bad news */
22536 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22538 vat_main_t *vam = &vat_main;
22543 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22544 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22545 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22546 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22547 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22548 clib_net_to_host_u32 (mp->action_index), mp->tag);
22553 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22554 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22555 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22556 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22557 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22558 clib_net_to_host_u32 (mp->action_index), mp->tag);
22563 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22566 vat_main_t *vam = &vat_main;
22567 vat_json_node_t *node = NULL;
22568 struct in6_addr ip6;
22569 struct in_addr ip4;
22571 if (VAT_JSON_ARRAY != vam->json_tree.type)
22573 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22574 vat_json_init_array (&vam->json_tree);
22576 node = vat_json_array_add (&vam->json_tree);
22577 vat_json_init_object (node);
22579 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22580 vat_json_object_add_uint (node, "appns_index",
22581 clib_net_to_host_u32 (mp->appns_index));
22582 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22583 vat_json_object_add_uint (node, "scope", mp->scope);
22584 vat_json_object_add_uint (node, "action_index",
22585 clib_net_to_host_u32 (mp->action_index));
22586 vat_json_object_add_uint (node, "lcl_port",
22587 clib_net_to_host_u16 (mp->lcl_port));
22588 vat_json_object_add_uint (node, "rmt_port",
22589 clib_net_to_host_u16 (mp->rmt_port));
22590 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22591 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22592 vat_json_object_add_string_copy (node, "tag", mp->tag);
22595 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22596 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22597 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22598 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22602 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22603 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22604 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22605 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22610 api_session_rule_add_del (vat_main_t * vam)
22612 vl_api_session_rule_add_del_t *mp;
22613 unformat_input_t *i = vam->input;
22614 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22615 u32 appns_index = 0, scope = 0;
22616 ip4_address_t lcl_ip4, rmt_ip4;
22617 ip6_address_t lcl_ip6, rmt_ip6;
22618 u8 is_ip4 = 1, conn_set = 0;
22619 u8 is_add = 1, *tag = 0;
22622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22624 if (unformat (i, "del"))
22626 else if (unformat (i, "add"))
22628 else if (unformat (i, "proto tcp"))
22630 else if (unformat (i, "proto udp"))
22632 else if (unformat (i, "appns %d", &appns_index))
22634 else if (unformat (i, "scope %d", &scope))
22636 else if (unformat (i, "tag %_%v%_", &tag))
22640 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22641 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22649 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22650 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22656 else if (unformat (i, "action %d", &action))
22661 if (proto == ~0 || !conn_set || action == ~0)
22663 errmsg ("transport proto, connection and action must be set");
22669 errmsg ("scope should be 0-3");
22673 M (SESSION_RULE_ADD_DEL, mp);
22675 mp->is_ip4 = is_ip4;
22676 mp->transport_proto = proto;
22677 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22678 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22679 mp->lcl_plen = lcl_plen;
22680 mp->rmt_plen = rmt_plen;
22681 mp->action_index = clib_host_to_net_u32 (action);
22682 mp->appns_index = clib_host_to_net_u32 (appns_index);
22684 mp->is_add = is_add;
22687 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22688 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22692 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22693 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22697 clib_memcpy (mp->tag, tag, vec_len (tag));
22707 api_session_rules_dump (vat_main_t * vam)
22709 vl_api_session_rules_dump_t *mp;
22710 vl_api_control_ping_t *mp_ping;
22713 if (!vam->json_output)
22715 print (vam->ofp, "%=20s", "Session Rules");
22718 M (SESSION_RULES_DUMP, mp);
22722 /* Use a control ping for synchronization */
22723 MPING (CONTROL_PING, mp_ping);
22726 /* Wait for a reply... */
22732 api_ip_container_proxy_add_del (vat_main_t * vam)
22734 vl_api_ip_container_proxy_add_del_t *mp;
22735 unformat_input_t *i = vam->input;
22736 u32 plen = ~0, sw_if_index = ~0;
22743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22745 if (unformat (i, "del"))
22747 else if (unformat (i, "add"))
22749 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22754 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22759 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22764 if (sw_if_index == ~0 || plen == ~0)
22766 errmsg ("address and sw_if_index must be set");
22770 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22772 mp->is_ip4 = is_ip4;
22773 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22775 mp->is_add = is_add;
22777 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22779 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22787 api_qos_record_enable_disable (vat_main_t * vam)
22789 unformat_input_t *i = vam->input;
22790 vl_api_qos_record_enable_disable_t *mp;
22791 u32 sw_if_index, qs = 0xff;
22792 u8 sw_if_index_set = 0;
22796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22798 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22799 sw_if_index_set = 1;
22800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22801 sw_if_index_set = 1;
22802 else if (unformat (i, "%U", unformat_qos_source, &qs))
22804 else if (unformat (i, "disable"))
22808 clib_warning ("parse error '%U'", format_unformat_error, i);
22813 if (sw_if_index_set == 0)
22815 errmsg ("missing interface name or sw_if_index");
22820 errmsg ("input location must be specified");
22824 M (QOS_RECORD_ENABLE_DISABLE, mp);
22826 mp->sw_if_index = ntohl (sw_if_index);
22827 mp->input_source = qs;
22828 mp->enable = enable;
22836 q_or_quit (vat_main_t * vam)
22838 #if VPP_API_TEST_BUILTIN == 0
22839 longjmp (vam->jump_buf, 1);
22841 return 0; /* not so much */
22845 q (vat_main_t * vam)
22847 return q_or_quit (vam);
22851 quit (vat_main_t * vam)
22853 return q_or_quit (vam);
22857 comment (vat_main_t * vam)
22863 cmd_cmp (void *a1, void *a2)
22868 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22872 help (vat_main_t * vam)
22877 unformat_input_t *i = vam->input;
22880 if (unformat (i, "%s", &name))
22884 vec_add1 (name, 0);
22886 hs = hash_get_mem (vam->help_by_name, name);
22888 print (vam->ofp, "usage: %s %s", name, hs[0]);
22890 print (vam->ofp, "No such msg / command '%s'", name);
22895 print (vam->ofp, "Help is available for the following:");
22898 hash_foreach_pair (p, vam->function_by_name,
22900 vec_add1 (cmds, (u8 *)(p->key));
22904 vec_sort_with_function (cmds, cmd_cmp);
22906 for (j = 0; j < vec_len (cmds); j++)
22907 print (vam->ofp, "%s", cmds[j]);
22914 set (vat_main_t * vam)
22916 u8 *name = 0, *value = 0;
22917 unformat_input_t *i = vam->input;
22919 if (unformat (i, "%s", &name))
22921 /* The input buffer is a vector, not a string. */
22922 value = vec_dup (i->buffer);
22923 vec_delete (value, i->index, 0);
22924 /* Almost certainly has a trailing newline */
22925 if (value[vec_len (value) - 1] == '\n')
22926 value[vec_len (value) - 1] = 0;
22927 /* Make sure it's a proper string, one way or the other */
22928 vec_add1 (value, 0);
22929 (void) clib_macro_set_value (&vam->macro_main,
22930 (char *) name, (char *) value);
22933 errmsg ("usage: set <name> <value>");
22941 unset (vat_main_t * vam)
22945 if (unformat (vam->input, "%s", &name))
22946 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22947 errmsg ("unset: %s wasn't set", name);
22960 macro_sort_cmp (void *a1, void *a2)
22962 macro_sort_t *s1 = a1;
22963 macro_sort_t *s2 = a2;
22965 return strcmp ((char *) (s1->name), (char *) (s2->name));
22969 dump_macro_table (vat_main_t * vam)
22971 macro_sort_t *sort_me = 0, *sm;
22976 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22978 vec_add2 (sort_me, sm, 1);
22979 sm->name = (u8 *)(p->key);
22980 sm->value = (u8 *) (p->value[0]);
22984 vec_sort_with_function (sort_me, macro_sort_cmp);
22986 if (vec_len (sort_me))
22987 print (vam->ofp, "%-15s%s", "Name", "Value");
22989 print (vam->ofp, "The macro table is empty...");
22991 for (i = 0; i < vec_len (sort_me); i++)
22992 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22997 dump_node_table (vat_main_t * vam)
23000 vlib_node_t *node, *next_node;
23002 if (vec_len (vam->graph_nodes) == 0)
23004 print (vam->ofp, "Node table empty, issue get_node_graph...");
23008 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23010 node = vam->graph_nodes[i];
23011 print (vam->ofp, "[%d] %s", i, node->name);
23012 for (j = 0; j < vec_len (node->next_nodes); j++)
23014 if (node->next_nodes[j] != ~0)
23016 next_node = vam->graph_nodes[node->next_nodes[j]];
23017 print (vam->ofp, " [%d] %s", j, next_node->name);
23025 value_sort_cmp (void *a1, void *a2)
23027 name_sort_t *n1 = a1;
23028 name_sort_t *n2 = a2;
23030 if (n1->value < n2->value)
23032 if (n1->value > n2->value)
23039 dump_msg_api_table (vat_main_t * vam)
23041 api_main_t *am = &api_main;
23042 name_sort_t *nses = 0, *ns;
23047 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23049 vec_add2 (nses, ns, 1);
23050 ns->name = (u8 *)(hp->key);
23051 ns->value = (u32) hp->value[0];
23055 vec_sort_with_function (nses, value_sort_cmp);
23057 for (i = 0; i < vec_len (nses); i++)
23058 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23064 get_msg_id (vat_main_t * vam)
23069 if (unformat (vam->input, "%s", &name_and_crc))
23071 message_index = vl_msg_api_get_msg_index (name_and_crc);
23072 if (message_index == ~0)
23074 print (vam->ofp, " '%s' not found", name_and_crc);
23077 print (vam->ofp, " '%s' has message index %d",
23078 name_and_crc, message_index);
23081 errmsg ("name_and_crc required...");
23086 search_node_table (vat_main_t * vam)
23088 unformat_input_t *line_input = vam->input;
23091 vlib_node_t *node, *next_node;
23094 if (vam->graph_node_index_by_name == 0)
23096 print (vam->ofp, "Node table empty, issue get_node_graph...");
23100 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23102 if (unformat (line_input, "%s", &node_to_find))
23104 vec_add1 (node_to_find, 0);
23105 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23108 print (vam->ofp, "%s not found...", node_to_find);
23111 node = vam->graph_nodes[p[0]];
23112 print (vam->ofp, "[%d] %s", p[0], node->name);
23113 for (j = 0; j < vec_len (node->next_nodes); j++)
23115 if (node->next_nodes[j] != ~0)
23117 next_node = vam->graph_nodes[node->next_nodes[j]];
23118 print (vam->ofp, " [%d] %s", j, next_node->name);
23125 clib_warning ("parse error '%U'", format_unformat_error,
23131 vec_free (node_to_find);
23140 script (vat_main_t * vam)
23142 #if (VPP_API_TEST_BUILTIN==0)
23144 char *save_current_file;
23145 unformat_input_t save_input;
23146 jmp_buf save_jump_buf;
23147 u32 save_line_number;
23149 FILE *new_fp, *save_ifp;
23151 if (unformat (vam->input, "%s", &s))
23153 new_fp = fopen ((char *) s, "r");
23156 errmsg ("Couldn't open script file %s", s);
23163 errmsg ("Missing script name");
23167 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23168 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23169 save_ifp = vam->ifp;
23170 save_line_number = vam->input_line_number;
23171 save_current_file = (char *) vam->current_file;
23173 vam->input_line_number = 0;
23175 vam->current_file = s;
23178 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
23179 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23180 vam->ifp = save_ifp;
23181 vam->input_line_number = save_line_number;
23182 vam->current_file = (u8 *) save_current_file;
23187 clib_warning ("use the exec command...");
23193 echo (vat_main_t * vam)
23195 print (vam->ofp, "%v", vam->input->buffer);
23199 /* List of API message constructors, CLI names map to api_xxx */
23200 #define foreach_vpe_api_msg \
23201 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23202 _(sw_interface_dump,"") \
23203 _(sw_interface_set_flags, \
23204 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23205 _(sw_interface_add_del_address, \
23206 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23207 _(sw_interface_set_rx_mode, \
23208 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23209 _(sw_interface_set_table, \
23210 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23211 _(sw_interface_set_mpls_enable, \
23212 "<intfc> | sw_if_index [disable | dis]") \
23213 _(sw_interface_set_vpath, \
23214 "<intfc> | sw_if_index <id> enable | disable") \
23215 _(sw_interface_set_vxlan_bypass, \
23216 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23217 _(sw_interface_set_geneve_bypass, \
23218 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23219 _(sw_interface_set_l2_xconnect, \
23220 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23221 "enable | disable") \
23222 _(sw_interface_set_l2_bridge, \
23223 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23224 "[shg <split-horizon-group>] [bvi]\n" \
23225 "enable | disable") \
23226 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23227 _(bridge_domain_add_del, \
23228 "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") \
23229 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23231 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23232 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23233 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23235 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23237 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23239 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23241 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23243 "<vpp-if-name> | sw_if_index <id>") \
23244 _(sw_interface_tap_dump, "") \
23246 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23248 "<vpp-if-name> | sw_if_index <id>") \
23249 _(sw_interface_tap_v2_dump, "") \
23251 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23252 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23254 "<vpp-if-name> | sw_if_index <id>") \
23256 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23257 _(bond_detach_slave, \
23258 "sw_if_index <n>") \
23259 _(sw_interface_bond_dump, "") \
23260 _(sw_interface_slave_dump, \
23261 "<vpp-if-name> | sw_if_index <id>") \
23262 _(ip_table_add_del, \
23263 "table-id <n> [ipv6]\n") \
23264 _(ip_add_del_route, \
23265 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23266 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23267 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23268 "[multipath] [count <n>]") \
23269 _(ip_mroute_add_del, \
23270 "<src> <grp>/<mask> [table-id <n>]\n" \
23271 "[<intfc> | sw_if_index <id>] [local] [del]") \
23272 _(mpls_table_add_del, \
23273 "table-id <n>\n") \
23274 _(mpls_route_add_del, \
23275 "<label> <eos> via <addr> [table-id <n>]\n" \
23276 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23277 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23278 "[multipath] [count <n>]") \
23279 _(mpls_ip_bind_unbind, \
23280 "<label> <addr/len>") \
23281 _(mpls_tunnel_add_del, \
23282 " via <addr> [table-id <n>]\n" \
23283 "sw_if_index <id>] [l2] [del]") \
23284 _(bier_table_add_del, \
23285 "<label> <sub-domain> <set> <bsl> [del]") \
23286 _(bier_route_add_del, \
23287 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23288 "[<intfc> | sw_if_index <id>]" \
23289 "[weight <n>] [del] [multipath]") \
23290 _(proxy_arp_add_del, \
23291 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23292 _(proxy_arp_intfc_enable_disable, \
23293 "<intfc> | sw_if_index <id> enable | disable") \
23294 _(sw_interface_set_unnumbered, \
23295 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23296 _(ip_neighbor_add_del, \
23297 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23298 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23299 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23300 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23301 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23302 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23303 "[outer_vlan_id_any][inner_vlan_id_any]") \
23304 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23305 _(reset_fib, "vrf <n> [ipv6]") \
23306 _(dhcp_proxy_config, \
23307 "svr <v46-address> src <v46-address>\n" \
23308 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23309 _(dhcp_proxy_set_vss, \
23310 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23311 _(dhcp_proxy_dump, "ip6") \
23312 _(dhcp_client_config, \
23313 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23314 _(set_ip_flow_hash, \
23315 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23316 _(sw_interface_ip6_enable_disable, \
23317 "<intfc> | sw_if_index <id> enable | disable") \
23318 _(sw_interface_ip6_set_link_local_address, \
23319 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23320 _(ip6nd_proxy_add_del, \
23321 "<intfc> | sw_if_index <id> <ip6-address>") \
23322 _(ip6nd_proxy_dump, "") \
23323 _(sw_interface_ip6nd_ra_prefix, \
23324 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23325 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23326 "[nolink] [isno]") \
23327 _(sw_interface_ip6nd_ra_config, \
23328 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23329 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23330 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23331 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23332 _(l2_patch_add_del, \
23333 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23334 "enable | disable") \
23335 _(sr_localsid_add_del, \
23336 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23337 "fib-table <num> (end.psp) sw_if_index <num>") \
23338 _(classify_add_del_table, \
23339 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23340 " [del] [del-chain] mask <mask-value>\n" \
23341 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23342 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23343 _(classify_add_del_session, \
23344 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23345 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23346 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23347 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23348 _(classify_set_interface_ip_table, \
23349 "<intfc> | sw_if_index <nn> table <nn>") \
23350 _(classify_set_interface_l2_tables, \
23351 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23352 " [other-table <nn>]") \
23353 _(get_node_index, "node <node-name") \
23354 _(add_node_next, "node <node-name> next <next-node-name>") \
23355 _(l2tpv3_create_tunnel, \
23356 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23357 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23358 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23359 _(l2tpv3_set_tunnel_cookies, \
23360 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23361 "[new_remote_cookie <nn>]\n") \
23362 _(l2tpv3_interface_enable_disable, \
23363 "<intfc> | sw_if_index <nn> enable | disable") \
23364 _(l2tpv3_set_lookup_key, \
23365 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23366 _(sw_if_l2tpv3_tunnel_dump, "") \
23367 _(vxlan_add_del_tunnel, \
23368 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23369 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23370 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23371 _(geneve_add_del_tunnel, \
23372 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23373 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23374 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23375 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23376 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23377 _(gre_add_del_tunnel, \
23378 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23379 "[teb | erspan <session-id>] [del]") \
23380 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23381 _(l2_fib_clear_table, "") \
23382 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23383 _(l2_interface_vlan_tag_rewrite, \
23384 "<intfc> | sw_if_index <nn> \n" \
23385 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23386 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23387 _(create_vhost_user_if, \
23388 "socket <filename> [server] [renumber <dev_instance>] " \
23389 "[mac <mac_address>]") \
23390 _(modify_vhost_user_if, \
23391 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23392 "[server] [renumber <dev_instance>]") \
23393 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23394 _(sw_interface_vhost_user_dump, "") \
23395 _(show_version, "") \
23396 _(vxlan_gpe_add_del_tunnel, \
23397 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23398 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23399 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23400 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23401 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23402 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23403 _(interface_name_renumber, \
23404 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23405 _(input_acl_set_interface, \
23406 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23407 " [l2-table <nn>] [del]") \
23408 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23409 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23410 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23411 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23412 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23413 _(ip_dump, "ipv4 | ipv6") \
23414 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23415 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23417 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23418 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23419 " integ_alg <alg> integ_key <hex>") \
23420 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23421 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23422 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23423 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23424 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23425 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23426 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23427 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23428 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23429 " [instance <n>]") \
23430 _(ipsec_sa_dump, "[sa_id <n>]") \
23431 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23432 " <alg> <hex>\n") \
23433 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23434 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23435 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23436 "(auth_data 0x<data> | auth_data <data>)") \
23437 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23438 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23439 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23440 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23441 "(local|remote)") \
23442 _(ikev2_set_local_key, "file <absolute_file_path>") \
23443 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23444 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23445 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23446 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23447 _(ikev2_initiate_sa_init, "<profile_name>") \
23448 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23449 _(ikev2_initiate_del_child_sa, "<ispi>") \
23450 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23451 _(delete_loopback,"sw_if_index <nn>") \
23452 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23453 _(map_add_domain, \
23454 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23455 "ip6-src <ip6addr> " \
23456 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23457 _(map_del_domain, "index <n>") \
23458 _(map_add_del_rule, \
23459 "index <n> psid <n> dst <ip6addr> [del]") \
23460 _(map_domain_dump, "") \
23461 _(map_rule_dump, "index <map-domain>") \
23462 _(want_interface_events, "enable|disable") \
23463 _(want_stats,"enable|disable") \
23464 _(get_first_msg_id, "client <name>") \
23465 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23466 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23467 "fib-id <nn> [ip4][ip6][default]") \
23468 _(get_node_graph, " ") \
23469 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23470 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23471 _(ioam_disable, "") \
23472 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23473 " sw_if_index <sw_if_index> p <priority> " \
23474 "w <weight>] [del]") \
23475 _(one_add_del_locator, "locator-set <locator_name> " \
23476 "iface <intf> | sw_if_index <sw_if_index> " \
23477 "p <priority> w <weight> [del]") \
23478 _(one_add_del_local_eid,"vni <vni> eid " \
23479 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23480 "locator-set <locator_name> [del]" \
23481 "[key-id sha1|sha256 secret-key <secret-key>]")\
23482 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23483 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23484 _(one_enable_disable, "enable|disable") \
23485 _(one_map_register_enable_disable, "enable|disable") \
23486 _(one_map_register_fallback_threshold, "<value>") \
23487 _(one_rloc_probe_enable_disable, "enable|disable") \
23488 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23490 "rloc <locator> p <prio> " \
23491 "w <weight> [rloc <loc> ... ] " \
23492 "action <action> [del-all]") \
23493 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23495 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23496 _(one_use_petr, "ip-address> | disable") \
23497 _(one_map_request_mode, "src-dst|dst-only") \
23498 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23499 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23500 _(one_locator_set_dump, "[local | remote]") \
23501 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23502 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23503 "[local] | [remote]") \
23504 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23505 _(one_ndp_bd_get, "") \
23506 _(one_ndp_entries_get, "bd <bridge-domain>") \
23507 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23508 _(one_l2_arp_bd_get, "") \
23509 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23510 _(one_stats_enable_disable, "enable|disalbe") \
23511 _(show_one_stats_enable_disable, "") \
23512 _(one_eid_table_vni_dump, "") \
23513 _(one_eid_table_map_dump, "l2|l3") \
23514 _(one_map_resolver_dump, "") \
23515 _(one_map_server_dump, "") \
23516 _(one_adjacencies_get, "vni <vni>") \
23517 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23518 _(show_one_rloc_probe_state, "") \
23519 _(show_one_map_register_state, "") \
23520 _(show_one_status, "") \
23521 _(one_stats_dump, "") \
23522 _(one_stats_flush, "") \
23523 _(one_get_map_request_itr_rlocs, "") \
23524 _(one_map_register_set_ttl, "<ttl>") \
23525 _(one_set_transport_protocol, "udp|api") \
23526 _(one_get_transport_protocol, "") \
23527 _(one_enable_disable_xtr_mode, "enable|disable") \
23528 _(one_show_xtr_mode, "") \
23529 _(one_enable_disable_pitr_mode, "enable|disable") \
23530 _(one_show_pitr_mode, "") \
23531 _(one_enable_disable_petr_mode, "enable|disable") \
23532 _(one_show_petr_mode, "") \
23533 _(show_one_nsh_mapping, "") \
23534 _(show_one_pitr, "") \
23535 _(show_one_use_petr, "") \
23536 _(show_one_map_request_mode, "") \
23537 _(show_one_map_register_ttl, "") \
23538 _(show_one_map_register_fallback_threshold, "") \
23539 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23540 " sw_if_index <sw_if_index> p <priority> " \
23541 "w <weight>] [del]") \
23542 _(lisp_add_del_locator, "locator-set <locator_name> " \
23543 "iface <intf> | sw_if_index <sw_if_index> " \
23544 "p <priority> w <weight> [del]") \
23545 _(lisp_add_del_local_eid,"vni <vni> eid " \
23546 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23547 "locator-set <locator_name> [del]" \
23548 "[key-id sha1|sha256 secret-key <secret-key>]") \
23549 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23550 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23551 _(lisp_enable_disable, "enable|disable") \
23552 _(lisp_map_register_enable_disable, "enable|disable") \
23553 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23554 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23556 "rloc <locator> p <prio> " \
23557 "w <weight> [rloc <loc> ... ] " \
23558 "action <action> [del-all]") \
23559 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23561 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23562 _(lisp_use_petr, "<ip-address> | disable") \
23563 _(lisp_map_request_mode, "src-dst|dst-only") \
23564 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23565 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23566 _(lisp_locator_set_dump, "[local | remote]") \
23567 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23568 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23569 "[local] | [remote]") \
23570 _(lisp_eid_table_vni_dump, "") \
23571 _(lisp_eid_table_map_dump, "l2|l3") \
23572 _(lisp_map_resolver_dump, "") \
23573 _(lisp_map_server_dump, "") \
23574 _(lisp_adjacencies_get, "vni <vni>") \
23575 _(gpe_fwd_entry_vnis_get, "") \
23576 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23577 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23578 "[table <table-id>]") \
23579 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23580 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23581 _(gpe_set_encap_mode, "lisp|vxlan") \
23582 _(gpe_get_encap_mode, "") \
23583 _(lisp_gpe_add_del_iface, "up|down") \
23584 _(lisp_gpe_enable_disable, "enable|disable") \
23585 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23586 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23587 _(show_lisp_rloc_probe_state, "") \
23588 _(show_lisp_map_register_state, "") \
23589 _(show_lisp_status, "") \
23590 _(lisp_get_map_request_itr_rlocs, "") \
23591 _(show_lisp_pitr, "") \
23592 _(show_lisp_use_petr, "") \
23593 _(show_lisp_map_request_mode, "") \
23594 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23595 _(af_packet_delete, "name <host interface name>") \
23596 _(policer_add_del, "name <policer name> <params> [del]") \
23597 _(policer_dump, "[name <policer name>]") \
23598 _(policer_classify_set_interface, \
23599 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23600 " [l2-table <nn>] [del]") \
23601 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23602 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23603 "[master|slave]") \
23604 _(netmap_delete, "name <interface name>") \
23605 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23606 _(mpls_fib_dump, "") \
23607 _(classify_table_ids, "") \
23608 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23609 _(classify_table_info, "table_id <nn>") \
23610 _(classify_session_dump, "table_id <nn>") \
23611 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23612 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23613 "[template_interval <nn>] [udp_checksum]") \
23614 _(ipfix_exporter_dump, "") \
23615 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23616 _(ipfix_classify_stream_dump, "") \
23617 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23618 _(ipfix_classify_table_dump, "") \
23619 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23620 _(sw_interface_span_dump, "[l2]") \
23621 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23622 _(pg_create_interface, "if_id <nn>") \
23623 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23624 _(pg_enable_disable, "[stream <id>] disable") \
23625 _(ip_source_and_port_range_check_add_del, \
23626 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23627 _(ip_source_and_port_range_check_interface_add_del, \
23628 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23629 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23630 _(ipsec_gre_add_del_tunnel, \
23631 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23632 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23633 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23634 _(l2_interface_pbb_tag_rewrite, \
23635 "<intfc> | sw_if_index <nn> \n" \
23636 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23637 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23638 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23639 _(flow_classify_set_interface, \
23640 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23641 _(flow_classify_dump, "type [ip4|ip6]") \
23642 _(ip_fib_dump, "") \
23643 _(ip_mfib_dump, "") \
23644 _(ip6_fib_dump, "") \
23645 _(ip6_mfib_dump, "") \
23646 _(feature_enable_disable, "arc_name <arc_name> " \
23647 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23648 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23650 _(l2_xconnect_dump, "") \
23651 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23652 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23653 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23654 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23655 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23656 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23657 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23658 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23659 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23660 _(sock_init_shm, "size <nnn>") \
23661 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23662 _(dns_enable_disable, "[enable][disable]") \
23663 _(dns_name_server_add_del, "<ip-address> [del]") \
23664 _(dns_resolve_name, "<hostname>") \
23665 _(dns_resolve_ip, "<ip4|ip6>") \
23666 _(dns_name_server_add_del, "<ip-address> [del]") \
23667 _(dns_resolve_name, "<hostname>") \
23668 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23669 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23670 _(session_rules_dump, "") \
23671 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23672 _(output_acl_set_interface, \
23673 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23674 " [l2-table <nn>] [del]") \
23675 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23677 /* List of command functions, CLI names map directly to functions */
23678 #define foreach_cli_function \
23679 _(comment, "usage: comment <ignore-rest-of-line>") \
23680 _(dump_interface_table, "usage: dump_interface_table") \
23681 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23682 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23683 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23684 _(dump_stats_table, "usage: dump_stats_table") \
23685 _(dump_macro_table, "usage: dump_macro_table ") \
23686 _(dump_node_table, "usage: dump_node_table") \
23687 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23688 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23689 _(echo, "usage: echo <message>") \
23690 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23691 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23692 _(help, "usage: help") \
23693 _(q, "usage: quit") \
23694 _(quit, "usage: quit") \
23695 _(search_node_table, "usage: search_node_table <name>...") \
23696 _(set, "usage: set <variable-name> <value>") \
23697 _(script, "usage: script <file-name>") \
23698 _(unset, "usage: unset <variable-name>")
23700 static void vl_api_##n##_t_handler_uni \
23701 (vl_api_##n##_t * mp) \
23703 vat_main_t * vam = &vat_main; \
23704 if (vam->json_output) { \
23705 vl_api_##n##_t_handler_json(mp); \
23707 vl_api_##n##_t_handler(mp); \
23710 foreach_vpe_api_reply_msg;
23711 #if VPP_API_TEST_BUILTIN == 0
23712 foreach_standalone_reply_msg;
23717 vat_api_hookup (vat_main_t * vam)
23720 vl_msg_api_set_handlers(VL_API_##N, #n, \
23721 vl_api_##n##_t_handler_uni, \
23723 vl_api_##n##_t_endian, \
23724 vl_api_##n##_t_print, \
23725 sizeof(vl_api_##n##_t), 1);
23726 foreach_vpe_api_reply_msg;
23727 #if VPP_API_TEST_BUILTIN == 0
23728 foreach_standalone_reply_msg;
23732 #if (VPP_API_TEST_BUILTIN==0)
23733 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23735 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23737 vam->function_by_name = hash_create_string (0, sizeof (uword));
23739 vam->help_by_name = hash_create_string (0, sizeof (uword));
23742 /* API messages we can send */
23743 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23744 foreach_vpe_api_msg;
23748 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23749 foreach_vpe_api_msg;
23752 /* CLI functions */
23753 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23754 foreach_cli_function;
23758 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23759 foreach_cli_function;
23763 #if VPP_API_TEST_BUILTIN
23764 static clib_error_t *
23765 vat_api_hookup_shim (vlib_main_t * vm)
23767 vat_api_hookup (&vat_main);
23771 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23775 * fd.io coding-style-patch-verification: ON
23778 * eval: (c-set-style "gnu")