From 5b4884a855bf244830ec2a6363e0c3ff5d303d23 Mon Sep 17 00:00:00 2001 From: Roger Light Date: Wed, 30 Sep 2020 10:26:17 +0100 Subject: [PATCH] Callback struct padding for future use. --- src/mosquitto_broker.h | 22 ++++++++++++++++++++++ src/plugin.c | 17 +++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/mosquitto_broker.h b/src/mosquitto_broker.h index 288b763c..6663bd38 100644 --- a/src/mosquitto_broker.h +++ b/src/mosquitto_broker.h @@ -45,6 +45,7 @@ enum mosquitto_protocol { * * ========================================================================= */ +/* Callback events */ enum mosquitto_plugin_event { MOSQ_EVT_RELOAD = 1, MOSQ_EVT_ACL_CHECK = 2, @@ -56,12 +57,17 @@ enum mosquitto_plugin_event { MOSQ_EVT_PSK_KEY = 8, }; +/* Data for the MOSQ_EVT_RELOAD event */ struct mosquitto_evt_reload { + void *future; struct mosquitto_opt *options; int option_count; + void *future2[4]; }; +/* Data for the MOSQ_EVT_ACL_CHECK event */ struct mosquitto_evt_acl_check { + void *future; struct mosquitto *client; int access; const char *topic; @@ -70,31 +76,43 @@ struct mosquitto_evt_acl_check { int qos; bool retain; mosquitto_property *properties; + void *future2[4]; }; +/* Data for the MOSQ_EVT_BASIC_AUTH event */ struct mosquitto_evt_basic_auth { + void *future; struct mosquitto *client; char *username; char *password; + void *future2[4]; }; +/* Data for the MOSQ_EVT_PSK_KEY event */ struct mosquitto_evt_psk_key { + void *future; struct mosquitto *client; const char *hint; const char *identity; char *key; int max_key_len; + void *future2[4]; }; +/* Data for the MOSQ_EVT_EXTENDED_AUTH event */ struct mosquitto_evt_extended_auth { + void *future; struct mosquitto *client; const void *data_in; void *data_out; uint16_t data_in_len; uint16_t data_out_len; + void *future2[4]; }; +/* Data for the MOSQ_EVT_CONTROL event */ struct mosquitto_evt_control { + void *future; struct mosquitto *client; const char *topic; const void *payload; @@ -104,9 +122,12 @@ struct mosquitto_evt_control { int qos; uint8_t reason_code; bool retain; + void *future2[4]; }; +/* Data for the MOSQ_EVT_MESSAGE event */ struct mosquitto_evt_message { + void *future; struct mosquitto *client; char *topic; void *payload; @@ -116,6 +137,7 @@ struct mosquitto_evt_message { int qos; uint8_t reason_code; bool retain; + void *future2[4]; }; diff --git a/src/plugin.c b/src/plugin.c index d05cc4a3..7abcc443 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -150,7 +150,12 @@ int plugin__handle_message(struct mosquitto_db *db, struct mosquitto *context, s } -int mosquitto_callback_register(mosquitto_plugin_id_t *identifier, int event, MOSQ_FUNC_generic_callback cb_func, const void *data, void *userdata) +int mosquitto_callback_register( + mosquitto_plugin_id_t *identifier, + int event, + MOSQ_FUNC_generic_callback cb_func, + const void *event_data, + void *userdata) { struct mosquitto_db *db; struct mosquitto__callback **cb_base = NULL, *cb_new; @@ -185,7 +190,7 @@ int mosquitto_callback_register(mosquitto_plugin_id_t *identifier, int event, MO cb_base = &security_options->plugin_callbacks.ext_auth_continue; break; case MOSQ_EVT_CONTROL: - return control__register_callback(db, security_options, cb_func, data, userdata); + return control__register_callback(db, security_options, cb_func, event_data, userdata); break; case MOSQ_EVT_MESSAGE: cb_base = &security_options->plugin_callbacks.message; @@ -211,7 +216,11 @@ int mosquitto_callback_register(mosquitto_plugin_id_t *identifier, int event, MO } -int mosquitto_callback_unregister(mosquitto_plugin_id_t *identifier, int event, MOSQ_FUNC_generic_callback cb_func, const void *data) +int mosquitto_callback_unregister( + mosquitto_plugin_id_t *identifier, + int event, + MOSQ_FUNC_generic_callback cb_func, + const void *event_data) { struct mosquitto_db *db; struct mosquitto__callback **cb_base = NULL; @@ -245,7 +254,7 @@ int mosquitto_callback_unregister(mosquitto_plugin_id_t *identifier, int event, cb_base = &security_options->plugin_callbacks.ext_auth_continue; break; case MOSQ_EVT_CONTROL: - return control__unregister_callback(db, security_options, cb_func, data); + return control__unregister_callback(db, security_options, cb_func, event_data); break; case MOSQ_EVT_MESSAGE: cb_base = &security_options->plugin_callbacks.message;