2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 *------------------------------------------------------------------
17 * vxlan_gpe_ioam_export_test.c - test harness plugin
18 *------------------------------------------------------------------
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vppinfra/error.h>
26 #define __plugin_msg_base export_test_main.msg_id_base
27 #include <vlibapi/vat_helper_macros.h>
29 /* Declare message IDs */
30 #include <ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api_enum.h>
31 #include <ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api_types.h>
33 /* instantiate all the print functions we know about */
34 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
36 #define vl_endianfun /* define message structures */
38 #define vl_api_version(n,v) static u32 api_version=(v);
39 #include <ioam/export-vxlan-gpe/vxlan_gpe_ioam_export.api.h>
46 /* API message ID base */
51 static export_test_main_t export_test_main;
53 #define foreach_standard_reply_retval_handler \
54 _(vxlan_gpe_ioam_export_enable_disable_reply)
57 static void vl_api_##n##_t_handler \
58 (vl_api_##n##_t * mp) \
60 vat_main_t * vam = export_test_main.vat_main; \
61 i32 retval = ntohl(mp->retval); \
62 if (vam->async_mode) { \
63 vam->async_errors += (retval < 0); \
65 vam->retval = retval; \
66 vam->result_ready = 1; \
69 foreach_standard_reply_retval_handler;
73 * Table of message reply handlers, must include boilerplate handlers
76 #define foreach_vpe_api_reply_msg \
77 _(VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE_REPLY, vxlan_gpe_ioam_export_enable_disable_reply)
80 api_vxlan_gpe_ioam_export_enable_disable (vat_main_t * vam)
82 unformat_input_t *i = vam->input;
84 vl_api_vxlan_gpe_ioam_export_enable_disable_t *mp;
87 /* Parse args required to build the message */
88 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
90 if (unformat (i, "disable"))
96 /* Construct the API message */
97 M (VXLAN_GPE_IOAM_EXPORT_ENABLE_DISABLE, mp);
98 mp->is_disable = is_disable;
103 /* Wait for a reply... */
109 * List of messages that the api test plugin sends,
110 * and that the data plane plugin processes
112 #define foreach_vpe_api_msg \
113 _(vxlan_gpe_ioam_export_enable_disable, "<intfc> [disable]")
116 vxlan_gpe_ioam_vat_api_hookup (vat_main_t * vam)
118 export_test_main_t *sm = &export_test_main;
119 /* Hook up handlers for replies from the data plane plug-in */
121 vl_msg_api_set_handlers((VL_API_##N + sm->msg_id_base), \
123 vl_api_##n##_t_handler, \
125 vl_api_##n##_t_endian, \
126 vl_api_##n##_t_print, \
127 sizeof(vl_api_##n##_t), 1);
128 foreach_vpe_api_reply_msg;
131 /* API messages we can send */
132 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
137 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
143 vxlan_gpe_ioam_export_vat_plugin_register (vat_main_t * vam)
145 export_test_main_t *sm = &export_test_main;
150 name = format (0, "vxlan_gpe_ioam_export_%08x%c", api_version, 0);
151 sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
153 if (sm->msg_id_base != (u16) ~ 0)
154 vxlan_gpe_ioam_vat_api_hookup (vam);
162 * fd.io coding-style-patch-verification: ON
165 * eval: (c-set-style "gnu")