2 * builtinurl.c - skeleton vpp-api-test plug-in
4 * Copyright (c) 2019 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vlibapi/api.h>
19 #include <vlibmemory/api.h>
20 #include <vppinfra/error.h>
23 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
25 /* Declare message IDs */
26 #include <builtinurl/builtinurl_msg_enum.h>
28 /* define message structures */
30 #include <builtinurl/builtinurl_all_api_h.h>
33 /* declare message handlers for each api */
35 #define vl_endianfun /* define message structures */
36 #include <builtinurl/builtinurl_all_api_h.h>
39 /* instantiate all the print functions we know about */
40 #define vl_print(handle, ...)
42 #include <builtinurl/builtinurl_all_api_h.h>
45 /* Get the API version number. */
46 #define vl_api_version(n,v) static u32 api_version=(v);
47 #include <builtinurl/builtinurl_all_api_h.h>
53 /* API message ID base */
56 } builtinurl_test_main_t;
58 builtinurl_test_main_t builtinurl_test_main;
60 #define __plugin_msg_base builtinurl_test_main.msg_id_base
61 #include <vlibapi/vat_helper_macros.h>
63 #define foreach_standard_reply_retval_handler \
64 _(builtinurl_enable_reply)
67 static void vl_api_##n##_t_handler \
68 (vl_api_##n##_t * mp) \
70 vat_main_t * vam = builtinurl_test_main.vat_main; \
71 i32 retval = ntohl(mp->retval); \
72 if (vam->async_mode) { \
73 vam->async_errors += (retval < 0); \
75 vam->retval = retval; \
76 vam->result_ready = 1; \
79 foreach_standard_reply_retval_handler;
83 * Table of message reply handlers, must include boilerplate handlers
86 #define foreach_vpe_api_reply_msg \
87 _(BUILTINURL_ENABLE_REPLY, builtinurl_enable_reply)
91 api_builtinurl_enable_disable (vat_main_t * vam)
93 vl_api_builtinurl_enable_t *mp;
96 /* Construct the API message */
97 M (BUILTINURL_ENABLE, mp);
102 /* Wait for a reply... */
108 * List of messages that the api test plugin sends,
109 * and that the data plane plugin processes
111 #define foreach_vpe_api_msg \
112 _(builtinurl_enable_disable, "")
115 builtinurl_api_hookup (vat_main_t * vam)
117 builtinurl_test_main_t *btmp = &builtinurl_test_main;
118 /* Hook up handlers for replies from the data plane plug-in */
120 vl_msg_api_set_handlers((VL_API_##N + btmp->msg_id_base), \
122 vl_api_##n##_t_handler, \
124 vl_api_##n##_t_endian, \
125 vl_api_##n##_t_print, \
126 sizeof(vl_api_##n##_t), 1);
127 foreach_vpe_api_reply_msg;
130 /* API messages we can send */
131 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
136 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
141 VAT_PLUGIN_REGISTER (builtinurl);
144 * fd.io coding-style-patch-verification: ON
147 * eval: (c-set-style "gnu")