From b922f16ba532d09f920776a04117e41f173dec8e Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Fri, 27 Sep 2019 09:07:51 +0200 Subject: dns: remove api boilerplate Type: refactor Signed-off-by: Ole Troan Change-Id: Ifffa86b45dd1f213ba974a296ab64202b672a6df --- src/plugins/dns/dns_test.c | 97 ++-------------------------------------------- 1 file changed, 3 insertions(+), 94 deletions(-) (limited to 'src/plugins/dns/dns_test.c') diff --git a/src/plugins/dns/dns_test.c b/src/plugins/dns/dns_test.c index 6b0b371dca1..9d5be8fcc1b 100644 --- a/src/plugins/dns/dns_test.c +++ b/src/plugins/dns/dns_test.c @@ -24,29 +24,8 @@ uword unformat_sw_if_index (unformat_input_t * input, va_list * args); /* Declare message IDs */ -#include - -/* define message structures */ -#define vl_typedefs -#include -#undef vl_typedefs - -/* declare message handlers for each api */ - -#define vl_endianfun /* define message structures */ -#include -#undef vl_endianfun - -/* instantiate all the print functions we know about */ -#define vl_print(handle, ...) -#define vl_printfun -#include -#undef vl_printfun - -/* Get the API version number. */ -#define vl_api_version(n,v) static u32 api_version=(v); -#include -#undef vl_api_version +#include +#include typedef struct { @@ -60,26 +39,6 @@ dns_test_main_t dns_test_main; #define __plugin_msg_base dns_test_main.msg_id_base #include -#define foreach_standard_reply_retval_handler \ -_(dns_enable_disable_reply) \ -_(dns_name_server_add_del_reply) - -#define _(n) \ - static void vl_api_##n##_t_handler \ - (vl_api_##n##_t * mp) \ - { \ - vat_main_t * vam = dns_test_main.vat_main; \ - i32 retval = (i32) clib_net_to_host_u32(mp->retval); \ - if (vam->async_mode) { \ - vam->async_errors += (retval < 0); \ - } else { \ - vam->retval = retval; \ - vam->result_ready = 1; \ - } \ - } -foreach_standard_reply_retval_handler; -#undef _ - static void vl_api_dns_resolve_name_reply_t_handler (vl_api_dns_resolve_name_reply_t * mp) { @@ -117,16 +76,6 @@ static void vl_api_dns_resolve_ip_reply_t_handler } } -/* - * Table of message reply handlers, must include boilerplate handlers - * we just generated - */ -#define foreach_vpe_api_reply_msg \ -_(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \ -_(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \ -_(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \ -_(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) - static int api_dns_enable_disable (vat_main_t * vam) { @@ -158,18 +107,6 @@ api_dns_enable_disable (vat_main_t * vam) return ret; } -/* - * List of messages that the api test plugin sends, - * and that the data plane plugin processes - */ -#define foreach_vpe_api_msg \ -_(dns_enable_disable, "[enable][disable]") \ -_(dns_name_server_add_del, " [del]") \ -_(dns_resolve_name, "") \ -_(dns_resolve_ip, "") \ -_(dns_name_server_add_del, " [del]") \ -_(dns_resolve_name, "") - static int api_dns_resolve_name (vat_main_t * vam) { @@ -307,35 +244,7 @@ api_dns_name_server_add_del (vat_main_t * vam) return ret; } -static void -dns_api_hookup (vat_main_t * vam) -{ - dns_test_main_t *dtmp = &dns_test_main; - /* Hook up handlers for replies from the data plane plug-in */ -#define _(N,n) \ - vl_msg_api_set_handlers((VL_API_##N + dtmp->msg_id_base), \ - #n, \ - vl_api_##n##_t_handler, \ - vl_noop_handler, \ - vl_api_##n##_t_endian, \ - vl_api_##n##_t_print, \ - sizeof(vl_api_##n##_t), 1); - foreach_vpe_api_reply_msg; -#undef _ - - /* API messages we can send */ -#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); - foreach_vpe_api_msg; -#undef _ - - /* Help strings */ -#define _(n,h) hash_set_mem (vam->help_by_name, #n, h); - foreach_vpe_api_msg; -#undef _ -} - -VAT_PLUGIN_REGISTER (dns); - +#include /* * fd.io coding-style-patch-verification: ON -- cgit 1.2.3-korg