From: Arran Cudbard-Bell Date: Wed, 2 Mar 2022 21:18:50 +0000 (-0600) Subject: Use module_t as the common set of fields in loadable modules X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afab96b658bb7952da2d7a58e513ffa32ab4c911;p=thirdparty%2Ffreeradius-server.git Use module_t as the common set of fields in loadable modules --- diff --git a/src/lib/eap/submodule.h b/src/lib/eap/submodule.h index b1bd7e30bca..0e4e04b4ab0 100644 --- a/src/lib/eap/submodule.h +++ b/src/lib/eap/submodule.h @@ -47,9 +47,7 @@ typedef eap_type_t (*eap_type_identity_t)(void *inst, char const *id, size_t id_ * */ typedef struct { - DL_MODULE_COMMON; //!< Common fields to all loadable modules. - FR_MODULE_COMMON; //!< Common fields for all instantiated modules. - FR_MODULE_THREADED_COMMON; //!< Common fields for threaded modules. + module_t common; //!< Common fields provided by all modules. eap_type_t provides[MAX_PROVIDED_METHODS]; //!< Allow the module to register itself for more ///< than one EAP-Method. diff --git a/src/lib/io/master.c b/src/lib/io/master.c index a92848cab40..0a5c8401f77 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -3045,7 +3045,7 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t * fr_app_io_t fr_master_app_io = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "radius_master_io", .bootstrap = mod_bootstrap, diff --git a/src/lib/server/dl_module.h b/src/lib/server/dl_module.h index def61141a63..c67ecaa8015 100644 --- a/src/lib/server/dl_module.h +++ b/src/lib/server/dl_module.h @@ -62,7 +62,7 @@ typedef struct dl_module_instance_s dl_module_inst_t; /** Stop people using different module/library/server versions together * */ -#define RLM_MODULE_INIT RADIUSD_MAGIC_NUMBER +#define MODULE_MAGIC_INIT RADIUSD_MAGIC_NUMBER typedef enum { DL_MODULE_TYPE_MODULE = 0, //!< Standard loadable module. diff --git a/src/lib/server/module.c b/src/lib/server/module.c index 907cf05f9f0..2c5a7cf0da6 100644 --- a/src/lib/server/module.c +++ b/src/lib/server/module.c @@ -535,7 +535,7 @@ int module_instantiate(void *instance) * * If it isn't, we create a mutex. */ - if ((mi->module->type & RLM_TYPE_THREAD_UNSAFE) != 0) { + if ((mi->module->type & MODULE_TYPE_THREAD_UNSAFE) != 0) { mi->mutex = talloc_zero(mi, pthread_mutex_t); /* diff --git a/src/lib/server/module.h b/src/lib/server/module.h index e4db1181b0e..0c0d6e67240 100644 --- a/src/lib/server/module.h +++ b/src/lib/server/module.h @@ -41,13 +41,13 @@ typedef struct module_method_names_s module_method_names_t; typedef struct module_instance_s module_instance_t; typedef struct module_thread_instance_s module_thread_instance_t; -#define RLM_TYPE_THREAD_SAFE (0 << 0) //!< Module is threadsafe. -#define RLM_TYPE_THREAD_UNSAFE (1 << 0) //!< Module is not threadsafe. - //!< Server will protect calls - //!< with mutex. -#define RLM_TYPE_RESUMABLE (1 << 2) //!< does yield / resume +#define MODULE_TYPE_THREAD_SAFE (0 << 0) //!< Module is threadsafe. +#define MODULE_TYPE_THREAD_UNSAFE (1 << 0) //!< Module is not threadsafe. + //!< Server will protect calls + //!< with mutex. +#define MODULE_TYPE_RESUMABLE (1 << 2) //!< does yield / resume -#define RLM_TYPE_RETRY (1 << 3) //!< can handle retries +#define MODULE_TYPE_RETRY (1 << 3) //!< can handle retries /** Module section callback * @@ -97,24 +97,6 @@ typedef int (*module_thread_instantiate_t)(module_thread_inst_ctx_t const *mctx) */ typedef int (*module_thread_detach_t)(module_thread_inst_ctx_t const *mctx); -#define FR_MODULE_COMMON \ - struct { \ - module_instantiate_t bootstrap; \ - module_instantiate_t instantiate; \ - int type; /* flags */ \ - } - -/** Common fields for the interface struct modules export - * - */ -#define FR_MODULE_THREADED_COMMON \ - struct { \ - module_thread_instantiate_t thread_instantiate; \ - module_thread_detach_t thread_detach; \ - char const *thread_inst_type; \ - size_t thread_inst_size; \ - } - #ifdef __cplusplus } #endif @@ -132,18 +114,6 @@ typedef int (*module_thread_detach_t)(module_thread_inst_ctx_t const *mctx); extern "C" { #endif -/** Common fields for submodules - * - * This should either be the first field in the structure exported from - * the submodule or the submodule should export an identical set of fields - * in the same order, preferably using the macros above. - */ -struct submodule_s { - DL_MODULE_COMMON; //!< Common fields for all loadable modules. - FR_MODULE_COMMON; //!< Common fields for all instantiated modules. - FR_MODULE_THREADED_COMMON; //!< Common fields for threaded modules. -}; - /** Named methods exported by a module * */ @@ -162,13 +132,15 @@ struct module_method_names_s { * within the module to different sections. */ struct module_s { - DL_MODULE_COMMON; //!< Common fields for all loadable modules. - FR_MODULE_COMMON; //!< Common fields for all instantiated modules. - FR_MODULE_THREADED_COMMON; //!< Common fields for threaded modules. - - module_method_t methods[MOD_COUNT]; //!< Pointers to the various section callbacks. - module_method_names_t const *method_names; //!< named methods - fr_dict_t const **dict; //!< pointer to local fr_dict_t* + DL_MODULE_COMMON; //!< Common fields for all loadable modules. + + module_instantiate_t bootstrap; + module_instantiate_t instantiate; + int type; /* flags */ + module_thread_instantiate_t thread_instantiate; + module_thread_detach_t thread_detach; + char const *thread_inst_type; + size_t thread_inst_size; }; /** Per instance data diff --git a/src/lib/server/module_rlm.c b/src/lib/server/module_rlm.c index ea891e28fad..8b2559d73a0 100644 --- a/src/lib/server/module_rlm.c +++ b/src/lib/server/module_rlm.c @@ -432,6 +432,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co module_instance_t *mi; module_method_names_t const *methods; char const *method_name1, *method_name2; + module_rlm_t const *mrlm; if (method) *method = NULL; @@ -451,23 +452,25 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co */ mi = module_by_name(NULL, name); if (mi) { - virtual_server_method_t const *allowed_list; + virtual_server_method_t const *allowed_list; if (!method) return mi; + mrlm = module_rlm_from_module(mi->module); + /* * We're not searching for a named method, OR the * module has no named methods. Try to return a * method based on the component. */ - if (!method_name1 || !mi->module->method_names) goto return_component; + if (!method_name1 || !mrlm->method_names) goto return_component; /* * Walk through the module, finding a matching * method. */ - for (j = 0; mi->module->method_names[j].name1 != NULL; j++) { - methods = &mi->module->method_names[j]; + for (j = 0; mrlm->method_names[j].name1 != NULL; j++) { + methods = &mrlm->method_names[j]; /* * Wildcard match name1, we're @@ -538,8 +541,8 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co int k; virtual_server_method_t const *allowed = &allowed_list[j]; - for (k = 0; mi->module->method_names[k].name1 != NULL; k++) { - methods = &mi->module->method_names[k]; + for (k = 0; mrlm->method_names[k].name1 != NULL; k++) { + methods = &mrlm->method_names[k]; fr_assert(methods->name1 != CF_IDENT_ANY); /* should have been caught above */ @@ -574,8 +577,8 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co * No matching method. Just return a method * based on the component. */ - if (component && mi->module->methods[*component]) { - *method = mi->module->methods[*component]; + if (component && mrlm->methods[*component]) { + *method = mrlm->methods[*component]; } /* @@ -625,6 +628,8 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co return NULL; } + mrlm = module_rlm_from_module(mi->module); + /* * We have a module, but the caller doesn't care about * method or names, so just return the module. @@ -655,7 +660,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co */ if (component) { *component = i; - if (method) *method = mi->module->methods[*component]; + if (method) *method = mrlm->methods[*component]; } /* @@ -673,7 +678,7 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co /* * We've found the module, but it has no named methods. */ - if (!mi->module->method_names) { + if (!mrlm->method_names) { *name1 = name + (p - inst_name); *name2 = NULL; talloc_free(inst_name); @@ -686,8 +691,8 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co * matches anything else. */ if (!q) { - for (j = 0; mi->module->method_names[j].name1 != NULL; j++) { - methods = &mi->module->method_names[j]; + for (j = 0; mrlm->method_names[j].name1 != NULL; j++) { + methods = &mrlm->method_names[j]; /* * If we do not have the second $method, then ignore it! @@ -743,8 +748,8 @@ module_instance_t *module_rlm_by_name_and_method(module_method_t *method, rlm_co * * Loop over the method names, seeing if we have a match. */ - for (j = 0; mi->module->method_names[j].name1 != NULL; j++) { - methods = &mi->module->method_names[j]; + for (j = 0; mrlm->method_names[j].name1 != NULL; j++) { + methods = &mrlm->method_names[j]; /* * If name1 doesn't match, skip it. @@ -1011,7 +1016,7 @@ int modules_rlm_bootstrap(CONF_SECTION *root) * Compile the default "actions" subsection, which includes retries. */ actions = cf_section_find(subcs, "actions", NULL); - if (actions && unlang_compile_actions(&mi->actions, actions, (mi->module->type & RLM_TYPE_RETRY) != 0)) { + if (actions && unlang_compile_actions(&mi->actions, actions, (mi->module->type & MODULE_TYPE_RETRY) != 0)) { talloc_free(mi); return -1; } diff --git a/src/lib/server/module_rlm.h b/src/lib/server/module_rlm.h index 620914c94d8..5a3a9de4ef9 100644 --- a/src/lib/server/module_rlm.h +++ b/src/lib/server/module_rlm.h @@ -33,6 +33,22 @@ extern "C" { extern char const *section_type_value[MOD_COUNT]; +typedef struct { + module_t common; //!< Common fields presented by all modules. + + module_method_t methods[MOD_COUNT]; //!< Pointers to the various section callbacks. + module_method_names_t const *method_names; //!< named methods + fr_dict_t const **dict; //!< pointer to local fr_dict_t* +} module_rlm_t; + +/** Cast a module_t to a module_rlm_t + * + */ +static inline module_rlm_t const *module_rlm_from_module(module_t const *module) +{ + return (module_rlm_t const *)module; +} + /** @name Convenience wrappers around other internal APIs to make them easier to instantiate with modules * * @{ diff --git a/src/lib/server/process.h b/src/lib/server/process.h index d44127ccbe3..955bf68709b 100644 --- a/src/lib/server/process.h +++ b/src/lib/server/process.h @@ -53,7 +53,9 @@ extern "C" { */ typedef struct fr_process_module_s { DL_MODULE_COMMON; //!< Common fields for all loadable modules. - FR_MODULE_COMMON; //!< bootstrap, instantiate + module_instantiate_t bootstrap; + module_instantiate_t instantiate; + int type; /* flags */ module_method_t process; //!< Process packets virtual_server_compile_t const *compile_list; //!< list of processing sections diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 1875c559335..5e129c7a3e6 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -3978,18 +3978,19 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx, CONF_ITEM *ci, module_instance_t *inst, module_method_t method, char const *realname) { + module_rlm_t const *mrlm = module_rlm_from_module(inst->module); unlang_t *c; unlang_module_t *single; /* * Can't use "chap" in "dhcp". */ - if (inst->module->dict && *inst->module->dict && unlang_ctx->rules && unlang_ctx->rules->attr.dict_def && + if (mrlm->dict && *mrlm->dict && unlang_ctx->rules && unlang_ctx->rules->attr.dict_def && (unlang_ctx->rules->attr.dict_def != fr_dict_internal()) && - (*(inst->module->dict) != unlang_ctx->rules->attr.dict_def)) { + (*(mrlm->dict) != unlang_ctx->rules->attr.dict_def)) { cf_log_err(ci, "The \"%s\" module can only used with 'namespace = %s'. It cannot be used with 'namespace = %s'.", inst->module->name, - fr_dict_root(*inst->module->dict)->name, + fr_dict_root(*mrlm->dict)->name, fr_dict_root(unlang_ctx->rules->attr.dict_def)->name); return NULL; } @@ -4045,7 +4046,7 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx, */ if (cf_item_is_section(ci) && !unlang_compile_actions(&c->actions, cf_item_to_section(ci), - (inst->module->type & RLM_TYPE_RETRY) != 0)) { + (inst->module->type & MODULE_TYPE_RETRY) != 0)) { talloc_free(c); return NULL; } @@ -4255,8 +4256,8 @@ check_for_module: */ UPDATE_CTX2; inst = module_rlm_by_name_and_method(&method, &unlang_ctx2.component, - &unlang_ctx2.section_name1, &unlang_ctx2.section_name2, - realname); + &unlang_ctx2.section_name1, &unlang_ctx2.section_name2, + realname); if (inst) { c = compile_module(parent, &unlang_ctx2, ci, inst, method, realname); goto allocate_number; diff --git a/src/listen/arp/proto_arp.c b/src/listen/arp/proto_arp.c index eff412c78b2..e45679e5ee1 100644 --- a/src/listen/arp/proto_arp.c +++ b/src/listen/arp/proto_arp.c @@ -300,7 +300,7 @@ static void mod_unload(void) } fr_app_t proto_arp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "arp", .config = proto_arp_config, .inst_size = sizeof(proto_arp_t), diff --git a/src/listen/arp/proto_arp_ethernet.c b/src/listen/arp/proto_arp_ethernet.c index 954cfda1339..0fdf6cbfef2 100644 --- a/src/listen/arp/proto_arp_ethernet.c +++ b/src/listen/arp/proto_arp_ethernet.c @@ -227,7 +227,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) fr_app_io_t proto_arp_ethernet = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "arp_ethernet", .config = arp_listen_config, .inst_size = sizeof(proto_arp_ethernet_t), diff --git a/src/listen/control/proto_control.c b/src/listen/control/proto_control.c index 2f5b2cdc045..7a4fe131904 100644 --- a/src/listen/control/proto_control.c +++ b/src/listen/control/proto_control.c @@ -218,7 +218,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) } fr_app_t proto_control = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "control", .config = proto_control_config, .inst_size = sizeof(proto_control_t), diff --git a/src/listen/control/proto_control_unix.c b/src/listen/control/proto_control_unix.c index e6cea08281c..e562b06064a 100644 --- a/src/listen/control/proto_control_unix.c +++ b/src/listen/control/proto_control_unix.c @@ -1179,7 +1179,7 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipa extern fr_app_io_t proto_control_unix; fr_app_io_t proto_control_unix = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "control_unix", .config = unix_listen_config, .inst_size = sizeof(proto_control_unix_t), diff --git a/src/listen/cron/proto_cron.c b/src/listen/cron/proto_cron.c index a2d139bff9f..0cee760d30c 100644 --- a/src/listen/cron/proto_cron.c +++ b/src/listen/cron/proto_cron.c @@ -322,7 +322,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) fr_app_t proto_cron = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "cron", .config = proto_cron_config, .inst_size = sizeof(proto_cron_t), diff --git a/src/listen/cron/proto_cron_crontab.c b/src/listen/cron/proto_cron_crontab.c index 5fc6e70f8a4..3709d368f02 100644 --- a/src/listen/cron/proto_cron_crontab.c +++ b/src/listen/cron/proto_cron_crontab.c @@ -752,7 +752,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs) } fr_app_io_t proto_cron_crontab = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "cron_crontab", .config = crontab_listen_config, .inst_size = sizeof(proto_cron_crontab_t), diff --git a/src/listen/detail/proto_detail.c b/src/listen/detail/proto_detail.c index 090e06c5dbf..84c4eebcefb 100644 --- a/src/listen/detail/proto_detail.c +++ b/src/listen/detail/proto_detail.c @@ -570,7 +570,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) fr_app_t proto_detail = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "detail", .config = proto_detail_config, .inst_size = sizeof(proto_detail_t), diff --git a/src/listen/detail/proto_detail_file.c b/src/listen/detail/proto_detail_file.c index 2f544e7f668..3dec2c463df 100644 --- a/src/listen/detail/proto_detail_file.c +++ b/src/listen/detail/proto_detail_file.c @@ -740,7 +740,7 @@ static int mod_close(fr_listen_t *li) */ extern fr_app_io_t proto_detail_file; fr_app_io_t proto_detail_file = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "detail_file", .config = file_listen_config, .inst_size = sizeof(proto_detail_file_t), diff --git a/src/listen/detail/proto_detail_work.c b/src/listen/detail/proto_detail_work.c index ba8a64aeebb..3e9f7acdc5c 100644 --- a/src/listen/detail/proto_detail_work.c +++ b/src/listen/detail/proto_detail_work.c @@ -882,7 +882,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) */ extern fr_app_io_t proto_detail_work; fr_app_io_t proto_detail_work = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "detail_work", .config = file_listen_config, .inst_size = sizeof(proto_detail_work_t), diff --git a/src/listen/dhcpv4/proto_dhcpv4.c b/src/listen/dhcpv4/proto_dhcpv4.c index e30411bebca..8682e33342e 100644 --- a/src/listen/dhcpv4/proto_dhcpv4.c +++ b/src/listen/dhcpv4/proto_dhcpv4.c @@ -499,7 +499,7 @@ static void mod_unload(void) } fr_app_t proto_dhcpv4 = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "dhcpv4", .config = proto_dhcpv4_config, .inst_size = sizeof(proto_dhcpv4_t), diff --git a/src/listen/dhcpv4/proto_dhcpv4_udp.c b/src/listen/dhcpv4/proto_dhcpv4_udp.c index 5eb49fe21fc..36a620fd297 100644 --- a/src/listen/dhcpv4/proto_dhcpv4_udp.c +++ b/src/listen/dhcpv4/proto_dhcpv4_udp.c @@ -801,7 +801,7 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in } fr_app_io_t proto_dhcpv4_udp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "dhcpv4_udp", .config = udp_listen_config, .inst_size = sizeof(proto_dhcpv4_udp_t), diff --git a/src/listen/dhcpv6/proto_dhcpv6.c b/src/listen/dhcpv6/proto_dhcpv6.c index 8f76a82c7a2..51c0a00c1a2 100644 --- a/src/listen/dhcpv6/proto_dhcpv6.c +++ b/src/listen/dhcpv6/proto_dhcpv6.c @@ -496,7 +496,7 @@ static void mod_unload(void) } fr_app_t proto_dhcpv6 = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "dhcpv6", .config = proto_dhcpv6_config, .inst_size = sizeof(proto_dhcpv6_t), diff --git a/src/listen/dhcpv6/proto_dhcpv6_udp.c b/src/listen/dhcpv6/proto_dhcpv6_udp.c index a894c88f88f..3a02949cf24 100644 --- a/src/listen/dhcpv6/proto_dhcpv6_udp.c +++ b/src/listen/dhcpv6/proto_dhcpv6_udp.c @@ -649,7 +649,7 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in } fr_app_io_t proto_dhcpv6_udp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "dhcpv6_udp", .config = udp_listen_config, .inst_size = sizeof(proto_dhcpv6_udp_t), diff --git a/src/listen/dns/proto_dns.c b/src/listen/dns/proto_dns.c index 7978174f8b3..42c1a70236f 100644 --- a/src/listen/dns/proto_dns.c +++ b/src/listen/dns/proto_dns.c @@ -441,7 +441,7 @@ static void mod_unload(void) } fr_app_t proto_dns = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "dns", .config = proto_dns_config, .inst_size = sizeof(proto_dns_t), diff --git a/src/listen/dns/proto_dns_udp.c b/src/listen/dns/proto_dns_udp.c index 17fe82441f3..3b15303eb4e 100644 --- a/src/listen/dns/proto_dns_udp.c +++ b/src/listen/dns/proto_dns_udp.c @@ -444,7 +444,7 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in } fr_app_io_t proto_dns_udp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "dns_udp", .config = udp_listen_config, .inst_size = sizeof(proto_dns_udp_t), diff --git a/src/listen/load/proto_load.c b/src/listen/load/proto_load.c index e54a2b18e82..75f1e4cbd71 100644 --- a/src/listen/load/proto_load.c +++ b/src/listen/load/proto_load.c @@ -324,7 +324,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) fr_app_t proto_load = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "load", .config = proto_load_config, .inst_size = sizeof(proto_load_t), diff --git a/src/listen/load/proto_load_step.c b/src/listen/load/proto_load_step.c index 588b5da38f4..2e47bfd1d69 100644 --- a/src/listen/load/proto_load_step.c +++ b/src/listen/load/proto_load_step.c @@ -435,7 +435,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs) } fr_app_io_t proto_load_step = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "load_step", .config = load_listen_config, .inst_size = sizeof(proto_load_step_t), diff --git a/src/listen/radius/proto_radius.c b/src/listen/radius/proto_radius.c index 425c10cf1ff..0af6899bd98 100644 --- a/src/listen/radius/proto_radius.c +++ b/src/listen/radius/proto_radius.c @@ -582,7 +582,7 @@ static void mod_unload(void) } fr_app_t proto_radius = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "radius", .config = proto_radius_config, .inst_size = sizeof(proto_radius_t), diff --git a/src/listen/radius/proto_radius_tcp.c b/src/listen/radius/proto_radius_tcp.c index 9b5a1e90be8..25043961ad4 100644 --- a/src/listen/radius/proto_radius_tcp.c +++ b/src/listen/radius/proto_radius_tcp.c @@ -578,7 +578,7 @@ static RADCLIENT *mod_client_find(UNUSED fr_listen_t *li, fr_ipaddr_t const *ipa } fr_app_io_t proto_radius_tcp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "radius_tcp", .config = tcp_listen_config, .inst_size = sizeof(proto_radius_tcp_t), diff --git a/src/listen/radius/proto_radius_udp.c b/src/listen/radius/proto_radius_udp.c index 0cbe701415d..883b14188fd 100644 --- a/src/listen/radius/proto_radius_udp.c +++ b/src/listen/radius/proto_radius_udp.c @@ -685,7 +685,7 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in } fr_app_io_t proto_radius_udp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "radius_udp", .config = udp_listen_config, .inst_size = sizeof(proto_radius_udp_t), diff --git a/src/listen/tacacs/proto_tacacs.c b/src/listen/tacacs/proto_tacacs.c index 63ea2cd6bbb..f41bc32c7e8 100644 --- a/src/listen/tacacs/proto_tacacs.c +++ b/src/listen/tacacs/proto_tacacs.c @@ -554,7 +554,7 @@ static void mod_unload(void) } fr_app_t proto_tacacs = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "tacacs", .config = proto_tacacs_config, .inst_size = sizeof(proto_tacacs_t), diff --git a/src/listen/tacacs/proto_tacacs_tcp.c b/src/listen/tacacs/proto_tacacs_tcp.c index a70f8877e67..e73f2c7a9ea 100644 --- a/src/listen/tacacs/proto_tacacs_tcp.c +++ b/src/listen/tacacs/proto_tacacs_tcp.c @@ -469,7 +469,7 @@ static RADCLIENT *mod_client_find(UNUSED fr_listen_t *li, fr_ipaddr_t const *ipa } fr_app_io_t proto_tacacs_tcp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "tacacs_tcp", .config = tcp_listen_config, .inst_size = sizeof(proto_tacacs_tcp_t), diff --git a/src/listen/vmps/proto_vmps.c b/src/listen/vmps/proto_vmps.c index bb87aaa4704..8eb02c65f27 100644 --- a/src/listen/vmps/proto_vmps.c +++ b/src/listen/vmps/proto_vmps.c @@ -467,7 +467,7 @@ static void mod_unload(void) } fr_app_t proto_vmps = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "vmps", .config = proto_vmps_config, .inst_size = sizeof(proto_vmps_t), diff --git a/src/listen/vmps/proto_vmps_udp.c b/src/listen/vmps/proto_vmps_udp.c index 72f643c40ac..fed2f6e1fa5 100644 --- a/src/listen/vmps/proto_vmps_udp.c +++ b/src/listen/vmps/proto_vmps_udp.c @@ -502,7 +502,7 @@ static char const *mod_name(fr_listen_t *li) } fr_app_io_t proto_vmps_udp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "vmps_udp", .config = udp_listen_config, .inst_size = sizeof(proto_vmps_udp_t), diff --git a/src/modules/proto_bfd/proto_bfd.c b/src/modules/proto_bfd/proto_bfd.c index d4af1e640d1..24b655391eb 100644 --- a/src/modules/proto_bfd/proto_bfd.c +++ b/src/modules/proto_bfd/proto_bfd.c @@ -1840,7 +1840,7 @@ static int bfd_socket_compile(CONF_SECTION *server_cs, UNUSED CONF_SECTION *list extern rad_protocol_t proto_bfd; rad_protocol_t proto_bfd = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "bfd", .inst_size = sizeof(bfd_socket_t), .transports = TRANSPORT_UDP, diff --git a/src/modules/proto_ldap_sync/proto_ldap_sync.c b/src/modules/proto_ldap_sync/proto_ldap_sync.c index 808d80a7758..3b7db335289 100644 --- a/src/modules/proto_ldap_sync/proto_ldap_sync.c +++ b/src/modules/proto_ldap_sync/proto_ldap_sync.c @@ -1263,7 +1263,7 @@ static void proto_ldap_unload(void) extern rad_protocol_t proto_ldap_sync; rad_protocol_t proto_ldap_sync = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "ldap_sync", .inst_size = sizeof(proto_ldap_inst_t), .transports = TRANSPORT_NONE, diff --git a/src/modules/rlm_always/rlm_always.c b/src/modules/rlm_always/rlm_always.c index a3c47cf59bb..7964948fc11 100644 --- a/src/modules/rlm_always/rlm_always.c +++ b/src/modules/rlm_always/rlm_always.c @@ -158,14 +158,16 @@ static unlang_action_t CC_HINT(nonnull) mod_always_return(rlm_rcode_t *p_result, RETURN_MODULE_RCODE(inst->rcode); } -extern module_t rlm_always; -module_t rlm_always = { - .magic = RLM_MODULE_INIT, - .name = "always", - .inst_size = sizeof(rlm_always_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_always; +module_rlm_t rlm_always = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "always", + .inst_size = sizeof(rlm_always_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + }, .methods = { [MOD_AUTHENTICATE] = mod_always_return, [MOD_AUTHORIZE] = mod_always_return, diff --git a/src/modules/rlm_attr_filter/rlm_attr_filter.c b/src/modules/rlm_attr_filter/rlm_attr_filter.c index 64d6d8ac4ab..10f54784713 100644 --- a/src/modules/rlm_attr_filter/rlm_attr_filter.c +++ b/src/modules/rlm_attr_filter/rlm_attr_filter.c @@ -367,13 +367,15 @@ RLM_AF_FUNC(preacct, packet, request) RLM_AF_FUNC(accounting, reply, reply) /* globally exported name */ -extern module_t rlm_attr_filter; -module_t rlm_attr_filter = { - .magic = RLM_MODULE_INIT, - .name = "attr_filter", - .inst_size = sizeof(rlm_attr_filter_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_attr_filter; +module_rlm_t rlm_attr_filter = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "attr_filter", + .inst_size = sizeof(rlm_attr_filter_t), + .config = module_config, + .instantiate = mod_instantiate, + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_PREACCT] = mod_preacct, diff --git a/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c b/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c index 432a846c660..787646016f7 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c @@ -316,13 +316,15 @@ static int mod_conn_reconnect(void **handle, UNUSED rlm_cache_config_t const *co extern rlm_cache_driver_t rlm_cache_memcached; rlm_cache_driver_t rlm_cache_memcached = { - .name = "rlm_cache_memcached", - .magic = RLM_MODULE_INIT, - .inst_size = sizeof(rlm_cache_memcached_t), - .config = driver_config, - - .onload = mod_load, - .instantiate = mod_instantiate, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_cache_memcached", + .inst_size = sizeof(rlm_cache_memcached_t), + .config = driver_config, + + .onload = mod_load, + .instantiate = mod_instantiate + }, .free = cache_entry_free, diff --git a/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c b/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c index 6cc4c7f91e7..4701ecd019d 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c @@ -333,12 +333,14 @@ static void cache_release(UNUSED rlm_cache_config_t const *config, void *instanc extern rlm_cache_driver_t rlm_cache_rbtree; rlm_cache_driver_t rlm_cache_rbtree = { - .name = "rlm_cache_rbtree", - .magic = RLM_MODULE_INIT, - .instantiate = mod_instantiate, - .detach = mod_detach, - .inst_size = sizeof(rlm_cache_rbtree_t), - .inst_type = "rlm_cache_rbtree_t", + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_cache_rbtree", + .instantiate = mod_instantiate, + .detach = mod_detach, + .inst_size = sizeof(rlm_cache_rbtree_t), + .inst_type = "rlm_cache_rbtree_t", + }, .alloc = cache_entry_alloc, .find = cache_entry_find, diff --git a/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c b/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c index 7b328873154..29dd1cfc67b 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c @@ -471,14 +471,15 @@ static cache_status_t cache_entry_expire(UNUSED rlm_cache_config_t const *config extern rlm_cache_driver_t rlm_cache_redis; rlm_cache_driver_t rlm_cache_redis = { - .name = "rlm_cache_redis", - .magic = RLM_MODULE_INIT, - .onload = mod_load, - .instantiate = mod_instantiate, - .inst_size = sizeof(rlm_cache_redis_t), - .config = driver_config, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_cache_redis", + .onload = mod_load, + .instantiate = mod_instantiate, + .inst_size = sizeof(rlm_cache_redis_t), + .config = driver_config, + }, .free = cache_entry_free, - .find = cache_entry_find, .insert = cache_entry_insert, .expire = cache_entry_expire, diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index ef093674f0e..9bac5e9bd4c 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -33,7 +33,7 @@ RCSID("$Id$") #include "rlm_cache.h" -extern module_t rlm_cache; +extern module_rlm_t rlm_cache; static const CONF_PARSER module_config[] = { { FR_CONF_OFFSET("driver", FR_TYPE_STRING, rlm_cache_config_t, driver_name), .dflt = "rlm_cache_rbtree" }, @@ -997,7 +997,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) /* * Non optional fields and callbacks */ - fr_assert(inst->driver->name); + fr_assert(inst->driver->common.name); fr_assert(inst->driver->find); fr_assert(inst->driver->insert); fr_assert(inst->driver->expire); @@ -1397,18 +1397,20 @@ finish: * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -module_t rlm_cache = { - .magic = RLM_MODULE_INIT, - .name = "cache", - .inst_size = sizeof(rlm_cache_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - .detach = mod_detach, +module_rlm_t rlm_cache = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "cache", + .inst_size = sizeof(rlm_cache_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHORIZE] = mod_cache_it, [MOD_PREACCT] = mod_cache_it, diff --git a/src/modules/rlm_cache/rlm_cache.h b/src/modules/rlm_cache/rlm_cache.h index 90f067a71db..082f8e8adf5 100644 --- a/src/modules/rlm_cache/rlm_cache.h +++ b/src/modules/rlm_cache/rlm_cache.h @@ -263,9 +263,7 @@ typedef int (*cache_reconnect_t)(rlm_cache_handle_t **handle, rlm_cache_config_ void *instance, request_t *request); struct rlm_cache_driver_s { - DL_MODULE_COMMON; //!< Common fields for all loadable modules. - FR_MODULE_COMMON; //!< Common fields for all instantiated modules. - FR_MODULE_THREADED_COMMON; //!< Common fields for threaded modules. + module_t common; //!< Common fields for all loadable modules. cache_entry_alloc_t alloc; //!< (optional) Allocate a new entry. cache_entry_free_t free; //!< (optional) Free memory used by an entry. diff --git a/src/modules/rlm_chap/rlm_chap.c b/src/modules/rlm_chap/rlm_chap.c index 34a1a1d0630..e0541bc91e3 100644 --- a/src/modules/rlm_chap/rlm_chap.c +++ b/src/modules/rlm_chap/rlm_chap.c @@ -309,18 +309,20 @@ static void mod_unload(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_chap; -module_t rlm_chap = { - .magic = RLM_MODULE_INIT, - .name = "chap", - .inst_size = sizeof(rlm_chap_t), - .onload = mod_load, - .unload = mod_unload, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_chap; +module_rlm_t rlm_chap = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "chap", + .inst_size = sizeof(rlm_chap_t), + .onload = mod_load, + .unload = mod_unload, + .instantiate = mod_instantiate + }, .dict = &dict_radius, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, diff --git a/src/modules/rlm_cipher/rlm_cipher.c b/src/modules/rlm_cipher/rlm_cipher.c index 347b6b6fcad..b02049c81c2 100644 --- a/src/modules/rlm_cipher/rlm_cipher.c +++ b/src/modules/rlm_cipher/rlm_cipher.c @@ -1375,18 +1375,20 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_cipher; -module_t rlm_cipher = { - .magic = RLM_MODULE_INIT, - .name = "cipher", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_cipher_t), - .thread_inst_size = sizeof(rlm_cipher_rsa_thread_inst_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .thread_instantiate = mod_thread_instantiate, +extern module_rlm_t rlm_cipher; +module_rlm_t rlm_cipher = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "cipher", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_cipher_t), + .thread_inst_size = sizeof(rlm_cipher_rsa_thread_inst_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .thread_instantiate = mod_thread_instantiate + } }; diff --git a/src/modules/rlm_client/rlm_client.c b/src/modules/rlm_client/rlm_client.c index b66592729ac..8266f9f47de 100644 --- a/src/modules/rlm_client/rlm_client.c +++ b/src/modules/rlm_client/rlm_client.c @@ -371,17 +371,19 @@ static void mod_unload(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_client; -module_t rlm_client = { - .magic = RLM_MODULE_INIT, - .name = "dynamic_clients", - .type = RLM_TYPE_THREAD_SAFE, /* type */ - .onload = mod_load, - .unload = mod_unload, +extern module_rlm_t rlm_client; +module_rlm_t rlm_client = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "dynamic_clients", + .type = MODULE_TYPE_THREAD_SAFE, /* type */ + .onload = mod_load, + .unload = mod_unload + }, .methods = { [MOD_AUTHORIZE] = mod_authorize }, diff --git a/src/modules/rlm_couchbase/rlm_couchbase.c b/src/modules/rlm_couchbase/rlm_couchbase.c index 8ae4ee915b4..9abf2451518 100644 --- a/src/modules/rlm_couchbase/rlm_couchbase.c +++ b/src/modules/rlm_couchbase/rlm_couchbase.c @@ -545,16 +545,18 @@ static int mod_load(void) /* * Hook into the FreeRADIUS module system. */ -extern module_t rlm_couchbase; -module_t rlm_couchbase = { - .magic = RLM_MODULE_INIT, - .name = "couchbase", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_couchbase_t), - .config = module_config, - .onload = mod_load, - .instantiate = mod_instantiate, - .detach = mod_detach, +extern module_rlm_t rlm_couchbase; +module_rlm_t rlm_couchbase = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "couchbase", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_couchbase_t), + .config = module_config, + .onload = mod_load, + .instantiate = mod_instantiate, + .detach = mod_detach + } .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_ACCOUNTING] = mod_accounting, diff --git a/src/modules/rlm_csv/rlm_csv.c b/src/modules/rlm_csv/rlm_csv.c index 65f6543fbbb..adb5bb9dcf2 100644 --- a/src/modules/rlm_csv/rlm_csv.c +++ b/src/modules/rlm_csv/rlm_csv.c @@ -1045,16 +1045,17 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul RETURN_MODULE_RCODE(rcode); } -extern module_t rlm_csv; -module_t rlm_csv = { - .magic = RLM_MODULE_INIT, - .name = "csv", - .type = 0, - .inst_size = sizeof(rlm_csv_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - +extern module_rlm_t rlm_csv; +module_rlm_t rlm_csv = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "csv", + .type = 0, + .inst_size = sizeof(rlm_csv_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + }, .method_names = (module_method_names_t[]){ { .name1 = CF_IDENT_ANY, .name2 = CF_IDENT_ANY, .method = mod_process }, diff --git a/src/modules/rlm_date/rlm_date.c b/src/modules/rlm_date/rlm_date.c index 6d9adf35a60..4186b4ad2d4 100644 --- a/src/modules/rlm_date/rlm_date.c +++ b/src/modules/rlm_date/rlm_date.c @@ -230,12 +230,14 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) return 0; } -extern module_t rlm_date; -module_t rlm_date = { - .magic = RLM_MODULE_INIT, - .name = "date", - .inst_size = sizeof(rlm_date_t), - .config = module_config, - .bootstrap = mod_bootstrap +extern module_rlm_t rlm_date; +module_rlm_t rlm_date = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "date", + .inst_size = sizeof(rlm_date_t), + .config = module_config, + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_delay/rlm_delay.c b/src/modules/rlm_delay/rlm_delay.c index a4c72c384e6..18664a4da23 100644 --- a/src/modules/rlm_delay/rlm_delay.c +++ b/src/modules/rlm_delay/rlm_delay.c @@ -270,14 +270,16 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) return 0; } -extern module_t rlm_delay; -module_t rlm_delay = { - .magic = RLM_MODULE_INIT, - .name = "delay", - .type = 0, - .inst_size = sizeof(rlm_delay_t), - .config = module_config, - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_delay; +module_rlm_t rlm_delay = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "delay", + .type = 0, + .inst_size = sizeof(rlm_delay_t), + .config = module_config, + .bootstrap = mod_bootstrap + }, .methods = { [MOD_PREACCT] = mod_delay, [MOD_AUTHORIZE] = mod_delay, diff --git a/src/modules/rlm_detail/rlm_detail.c b/src/modules/rlm_detail/rlm_detail.c index 2d4cd84895a..14790dc8270 100644 --- a/src/modules/rlm_detail/rlm_detail.c +++ b/src/modules/rlm_detail/rlm_detail.c @@ -464,13 +464,15 @@ static unlang_action_t CC_HINT(nonnull) mod_post_auth(rlm_rcode_t *p_result, mod /* globally exported name */ -extern module_t rlm_detail; -module_t rlm_detail = { - .magic = RLM_MODULE_INIT, - .name = "detail", - .inst_size = sizeof(rlm_detail_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_detail; +module_rlm_t rlm_detail = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "detail", + .inst_size = sizeof(rlm_detail_t), + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_PREACCT] = mod_accounting, diff --git a/src/modules/rlm_dhcpv4/rlm_dhcpv4.c b/src/modules/rlm_dhcpv4/rlm_dhcpv4.c index 05cfd0e9b96..70712eea040 100644 --- a/src/modules/rlm_dhcpv4/rlm_dhcpv4.c +++ b/src/modules/rlm_dhcpv4/rlm_dhcpv4.c @@ -314,19 +314,20 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul return unlang_module_yield(request, dhcpv4_resume, NULL, d); } -extern module_t rlm_dhcpv4; -module_t rlm_dhcpv4 = { - .magic = RLM_MODULE_INIT, - .name = "dhcpv4", - .inst_size = sizeof(rlm_dhcpv4_t), - .bootstrap = mod_bootstrap, - - .config = module_config, - - .thread_inst_size = sizeof(rlm_dhcpv4_thread_t), - .thread_inst_type = "rlm_dhcpv4_thread_t", - .thread_instantiate = mod_thread_instantiate, - +extern module_rlm_t rlm_dhcpv4; +module_rlm_t rlm_dhcpv4 = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "dhcpv4", + .inst_size = sizeof(rlm_dhcpv4_t), + .bootstrap = mod_bootstrap, + + .config = module_config, + + .thread_inst_size = sizeof(rlm_dhcpv4_thread_t), + .thread_inst_type = "rlm_dhcpv4_thread_t", + .thread_instantiate = mod_thread_instantiate + }, .methods = { [MOD_AUTHORIZE] = mod_process, [MOD_POST_AUTH] = mod_process, diff --git a/src/modules/rlm_dict/rlm_dict.c b/src/modules/rlm_dict/rlm_dict.c index e7853739444..5a5e5377f36 100644 --- a/src/modules/rlm_dict/rlm_dict.c +++ b/src/modules/rlm_dict/rlm_dict.c @@ -252,9 +252,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) return 0; } -extern module_t rlm_dict; -module_t rlm_dict = { - .magic = RLM_MODULE_INIT, - .name = "dict", - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_dict; +module_rlm_t rlm_dict = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "dict", + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_digest/rlm_digest.c b/src/modules/rlm_digest/rlm_digest.c index c6c7eb805dd..649aafb1976 100644 --- a/src/modules/rlm_digest/rlm_digest.c +++ b/src/modules/rlm_digest/rlm_digest.c @@ -468,16 +468,18 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_digest; -module_t rlm_digest = { - .magic = RLM_MODULE_INIT, - .name = "digest", - .inst_size = sizeof(rlm_digest_t), - .instantiate = mod_instantiate, +extern module_rlm_t rlm_digest; +module_rlm_t rlm_digest = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "digest", + .inst_size = sizeof(rlm_digest_t), + .instantiate = mod_instantiate, + }, .dict = &dict_radius, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, diff --git a/src/modules/rlm_eap/rlm_eap.c b/src/modules/rlm_eap/rlm_eap.c index 71fe2869254..d4977e768cb 100644 --- a/src/modules/rlm_eap/rlm_eap.c +++ b/src/modules/rlm_eap/rlm_eap.c @@ -36,7 +36,7 @@ RCSID("$Id$") #include #include "rlm_eap.h" -extern module_t rlm_eap; +extern module_rlm_t rlm_eap; /** Resume context for calling a submodule * @@ -776,7 +776,7 @@ static unlang_action_t eap_method_select(rlm_rcode_t *p_result, module_ctx_t con method = &inst->methods[eap_session->type]; - RDEBUG2("Calling submodule %s", method->submodule->name); + RDEBUG2("Calling submodule %s", method->submodule->common.name); /* * Allocate a new subrequest @@ -1205,15 +1205,17 @@ static void mod_unload(void) * The module name should be the only globally exported symbol. * That is, everything else should be 'static'. */ -module_t rlm_eap = { - .magic = RLM_MODULE_INIT, - .name = "eap", - .inst_size = sizeof(rlm_eap_t), - .config = module_config, - .onload = mod_load, - .unload = mod_unload, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +module_rlm_t rlm_eap = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap", + .inst_size = sizeof(rlm_eap_t), + .config = module_config, + .onload = mod_load, + .unload = mod_unload, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_eap/types/rlm_eap_aka/rlm_eap_aka.c b/src/modules/rlm_eap/types/rlm_eap_aka/rlm_eap_aka.c index 329789fb9ba..4cb59c83ee7 100644 --- a/src/modules/rlm_eap/types/rlm_eap_aka/rlm_eap_aka.c +++ b/src/modules/rlm_eap/types/rlm_eap_aka/rlm_eap_aka.c @@ -117,20 +117,20 @@ static void mod_unload(void) * That is, everything else should be 'static'. */ rlm_eap_submodule_t rlm_eap_aka = { - .name = "eap_aka", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_aka", - .provides = { FR_EAP_METHOD_AKA }, - - .inst_size = sizeof(eap_aka_sim_module_conf_t), - .inst_type = "eap_aka_sim_module_conf_t", - .config = submodule_config, + .inst_size = sizeof(eap_aka_sim_module_conf_t), + .inst_type = "eap_aka_sim_module_conf_t", + .config = submodule_config, - .onload = mod_load, - .unload = mod_unload, - - .instantiate = mod_instantiate, + .onload = mod_load, + .unload = mod_unload, + .instantiate = mod_instantiate, + }, + .provides = { FR_EAP_METHOD_AKA }, .type_identity = mod_type_identity, .session_init = mod_session_init, .namespace = &dict_eap_aka_sim diff --git a/src/modules/rlm_eap/types/rlm_eap_aka_prime/rlm_eap_aka_prime.c b/src/modules/rlm_eap/types/rlm_eap_aka_prime/rlm_eap_aka_prime.c index 9ae92d6cb5b..2bcf4865b55 100644 --- a/src/modules/rlm_eap/types/rlm_eap_aka_prime/rlm_eap_aka_prime.c +++ b/src/modules/rlm_eap/types/rlm_eap_aka_prime/rlm_eap_aka_prime.c @@ -95,20 +95,20 @@ static void mod_unload(void) * That is, everything else should be 'static'. */ rlm_eap_submodule_t rlm_eap_aka_prime = { - .name = "eap_aka_prime", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_aka_prime", - .provides = { FR_EAP_METHOD_AKA_PRIME }, - - .inst_size = sizeof(eap_aka_sim_module_conf_t), - .inst_type = "eap_aka_sim_module_conf_t", - .config = submodule_config, + .inst_size = sizeof(eap_aka_sim_module_conf_t), + .inst_type = "eap_aka_sim_module_conf_t", + .config = submodule_config, - .onload = mod_load, - .unload = mod_unload, - - .instantiate = mod_instantiate, + .onload = mod_load, + .unload = mod_unload, + .instantiate = mod_instantiate, + }, + .provides = { FR_EAP_METHOD_AKA_PRIME }, .type_identity = mod_type_identity, .session_init = mod_session_init, .namespace = &dict_eap_aka_sim diff --git a/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c b/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c index cda9f7897f5..fe36844a252 100644 --- a/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c +++ b/src/modules/rlm_eap/types/rlm_eap_fast/rlm_eap_fast.c @@ -686,17 +686,18 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) */ extern rlm_eap_submodule_t rlm_eap_fast; rlm_eap_submodule_t rlm_eap_fast = { - .name = "eap_fast", - .magic = RLM_MODULE_INIT, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_fast", + + .inst_size = sizeof(rlm_eap_fast_t), + .config = submodule_config, + .instantiate = mod_instantiate, /* Create new submodule instance */ + + .thread_inst_size = sizeof(rlm_eap_fast_thread_t), + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .provides = { FR_EAP_METHOD_FAST }, - .inst_size = sizeof(rlm_eap_fast_t), - .config = submodule_config, - .instantiate = mod_instantiate, /* Create new submodule instance */ - - .thread_inst_size = sizeof(rlm_eap_fast_thread_t), - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - .session_init = mod_session_init, /* Initialise a new EAP session */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c b/src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c index 8797c6da643..bc95429f7f7 100644 --- a/src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c +++ b/src/modules/rlm_eap/types/rlm_eap_gtc/rlm_eap_gtc.c @@ -237,14 +237,13 @@ static unlang_action_t mod_session_init(rlm_rcode_t *p_result, module_ctx_t cons */ extern rlm_eap_submodule_t rlm_eap_gtc; rlm_eap_submodule_t rlm_eap_gtc = { - .name = "eap_gtc", - .magic = RLM_MODULE_INIT, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_gtc", + .inst_size = sizeof(rlm_eap_gtc_t), + .config = submodule_config, + }, .provides = { FR_EAP_METHOD_GTC }, - .inst_size = sizeof(rlm_eap_gtc_t), - .config = submodule_config, - .session_init = mod_session_init, /* Initialise a new EAP session */ - .clone_parent_lists = true /* HACK */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c b/src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c index 62aaf1870e3..8aff65ee19d 100644 --- a/src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c +++ b/src/modules/rlm_eap/types/rlm_eap_md5/rlm_eap_md5.c @@ -172,9 +172,10 @@ static unlang_action_t mod_session_init(rlm_rcode_t *p_result, UNUSED module_ctx */ extern rlm_eap_submodule_t rlm_eap_md5; rlm_eap_submodule_t rlm_eap_md5 = { - .name = "eap_md5", - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_md5" + }, .provides = { FR_EAP_METHOD_MD5 }, - .magic = RLM_MODULE_INIT, .session_init = mod_session_init, /* Initialise a new EAP session */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c b/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c index be6db1a9ae0..2dba7271035 100644 --- a/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c +++ b/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c @@ -893,14 +893,14 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) */ extern rlm_eap_submodule_t rlm_eap_mschapv2; rlm_eap_submodule_t rlm_eap_mschapv2 = { - .name = "eap_mschapv2", - .magic = RLM_MODULE_INIT, - + .common = { + .name = "eap_mschapv2", + .magic = MODULE_MAGIC_INIT, + .inst_size = sizeof(rlm_eap_mschapv2_t), + .config = submodule_config, + .instantiate = mod_instantiate, /* Create new submodule instance */ + }, .provides = { FR_EAP_METHOD_MSCHAPV2 }, - .inst_size = sizeof(rlm_eap_mschapv2_t), - .config = submodule_config, - .instantiate = mod_instantiate, /* Create new submodule instance */ - .session_init = mod_session_init, /* Initialise a new EAP session */ .clone_parent_lists = false /* HACK */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c index a34a42b6d0d..3ca0a6633b7 100644 --- a/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c +++ b/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c @@ -419,19 +419,19 @@ static void mod_unload(void) */ extern rlm_eap_submodule_t rlm_eap_peap; rlm_eap_submodule_t rlm_eap_peap = { - .name = "eap_peap", - .magic = RLM_MODULE_INIT, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_peap", + .inst_size = sizeof(rlm_eap_peap_t), + .config = submodule_config, + .onload = mod_load, + .unload = mod_unload, + .instantiate = mod_instantiate, + + .thread_inst_size = sizeof(rlm_eap_peap_thread_t), + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .provides = { FR_EAP_METHOD_PEAP }, - .inst_size = sizeof(rlm_eap_peap_t), - .config = submodule_config, - .onload = mod_load, - .unload = mod_unload, - .instantiate = mod_instantiate, - - .thread_inst_size = sizeof(rlm_eap_peap_thread_t), - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - .session_init = mod_session_init, /* Initialise a new EAP session */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c b/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c index 433c241bafd..87a8c584e91 100644 --- a/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c +++ b/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c @@ -585,15 +585,15 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) extern rlm_eap_submodule_t rlm_eap_pwd; rlm_eap_submodule_t rlm_eap_pwd = { - .name = "eap_pwd", - .magic = RLM_MODULE_INIT, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_pwd", + .inst_size = sizeof(rlm_eap_pwd_t), + .config = submodule_config, + .instantiate = mod_instantiate, /* Create new submodule instance */ + .detach = mod_detach + }, .provides = { FR_EAP_METHOD_PWD }, - .inst_size = sizeof(rlm_eap_pwd_t), - .config = submodule_config, - .instantiate = mod_instantiate, /* Create new submodule instance */ - .detach = mod_detach, - .session_init = mod_session_init, /* Create the initial request */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c b/src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c index 1bc60593cef..e6cfca7839b 100644 --- a/src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c +++ b/src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c @@ -94,20 +94,19 @@ static void mod_unload(void) * That is, everything else should be 'static'. */ rlm_eap_submodule_t rlm_eap_sim = { - .name = "eap_sim", - .magic = RLM_MODULE_INIT, - + .common = { + .name = "eap_sim", + .magic = MODULE_MAGIC_INIT, + .inst_size = sizeof(eap_aka_sim_module_conf_t), + .inst_type = "eap_aka_sim_module_conf_t", + .config = submodule_config, + + .onload = mod_load, + .unload = mod_unload, + + .instantiate = mod_instantiate + }, .provides = { FR_EAP_METHOD_SIM }, - - .inst_size = sizeof(eap_aka_sim_module_conf_t), - .inst_type = "eap_aka_sim_module_conf_t", - .config = submodule_config, - - .onload = mod_load, - .unload = mod_unload, - - .instantiate = mod_instantiate, - .type_identity = mod_type_identity, .session_init = mod_session_init, /* Initialise a new EAP session */ .namespace = &dict_eap_aka_sim diff --git a/src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c b/src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c index 989d9d155df..729340e5cfe 100644 --- a/src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c +++ b/src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c @@ -278,17 +278,17 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) */ extern rlm_eap_submodule_t rlm_eap_tls; rlm_eap_submodule_t rlm_eap_tls = { - .name = "eap_tls", - .magic = RLM_MODULE_INIT, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_tls", + .inst_size = sizeof(rlm_eap_tls_t), + .config = submodule_config, + .instantiate = mod_instantiate, /* Create new submodule instance */ + + .thread_inst_size = sizeof(rlm_eap_tls_thread_t), + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .provides = { FR_EAP_METHOD_TLS }, - .inst_size = sizeof(rlm_eap_tls_t), - .config = submodule_config, - .instantiate = mod_instantiate, /* Create new submodule instance */ - - .thread_inst_size = sizeof(rlm_eap_tls_thread_t), - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - .session_init = mod_session_init, /* Initialise a new EAP session */ }; diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/rlm_eap_ttls.c b/src/modules/rlm_eap/types/rlm_eap_ttls/rlm_eap_ttls.c index d091792cf54..ebee17a273d 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/rlm_eap_ttls.c +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/rlm_eap_ttls.c @@ -382,17 +382,18 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) */ extern rlm_eap_submodule_t rlm_eap_ttls; rlm_eap_submodule_t rlm_eap_ttls = { - .name = "eap_ttls", - .magic = RLM_MODULE_INIT, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "eap_ttls", + + .inst_size = sizeof(rlm_eap_ttls_t), + .config = submodule_config, + .instantiate = mod_instantiate, /* Create new submodule instance */ + + .thread_inst_size = sizeof(rlm_eap_ttls_thread_t), + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .provides = { FR_EAP_METHOD_TTLS }, - .inst_size = sizeof(rlm_eap_ttls_t), - .config = submodule_config, - .instantiate = mod_instantiate, /* Create new submodule instance */ - - .thread_inst_size = sizeof(rlm_eap_ttls_thread_t), - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - .session_init = mod_session_init, /* Initialise a new EAP session */ }; diff --git a/src/modules/rlm_escape/rlm_escape.c b/src/modules/rlm_escape/rlm_escape.c index 5f9fa1dfe77..6d5fe3da71a 100644 --- a/src/modules/rlm_escape/rlm_escape.c +++ b/src/modules/rlm_escape/rlm_escape.c @@ -204,15 +204,17 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_escape; -module_t rlm_escape = { - .magic = RLM_MODULE_INIT, - .name = "escape", - .inst_size = sizeof(rlm_escape_t), - .config = module_config, - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_escape; +module_rlm_t rlm_escape = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "escape", + .inst_size = sizeof(rlm_escape_t), + .config = module_config, + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_exec/rlm_exec.c b/src/modules/rlm_exec/rlm_exec.c index 4e6c14ed4e7..e22687fe14c 100644 --- a/src/modules/rlm_exec/rlm_exec.c +++ b/src/modules/rlm_exec/rlm_exec.c @@ -466,19 +466,21 @@ static unlang_action_t CC_HINT(nonnull) mod_exec_dispatch(rlm_rcode_t *p_result, * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_exec; -module_t rlm_exec = { - .magic = RLM_MODULE_INIT, - .name = "exec", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_exec_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_exec; +module_rlm_t rlm_exec = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "exec", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_exec_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHENTICATE] = mod_exec_dispatch, [MOD_AUTHORIZE] = mod_exec_dispatch, diff --git a/src/modules/rlm_expr/rlm_expr.c b/src/modules/rlm_expr/rlm_expr.c index 66f3306a76e..f869c9c3ac6 100644 --- a/src/modules/rlm_expr/rlm_expr.c +++ b/src/modules/rlm_expr/rlm_expr.c @@ -615,13 +615,15 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_expr; -module_t rlm_expr = { - .magic = RLM_MODULE_INIT, - .name = "expr", - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_expr; +module_rlm_t rlm_expr = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "expr", + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index 36fddea4ed0..726f4e11854 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -670,13 +670,15 @@ static unlang_action_t CC_HINT(nonnull) mod_post_auth(rlm_rcode_t *p_result, mod /* globally exported name */ -extern module_t rlm_files; -module_t rlm_files = { - .magic = RLM_MODULE_INIT, - .name = "files", - .inst_size = sizeof(rlm_files_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_files; +module_rlm_t rlm_files = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "files", + .inst_size = sizeof(rlm_files_t), + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index 824f4514fa8..16e6cbece67 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -542,21 +542,22 @@ static int mod_thread_detach(module_thread_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_icmp; -module_t rlm_icmp = { - .magic = RLM_MODULE_INIT, - .name = "icmp", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_icmp_t), - .config = module_config, - .bootstrap = mod_bootstrap, - - .thread_inst_size = sizeof(rlm_icmp_thread_t), - .thread_inst_type = "rlm_icmp_thread_t", - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_icmp; +module_rlm_t rlm_icmp = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "icmp", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_icmp_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .thread_inst_size = sizeof(rlm_icmp_thread_t), + .thread_inst_type = "rlm_icmp_thread_t", + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + } }; diff --git a/src/modules/rlm_idn/rlm_idn.c b/src/modules/rlm_idn/rlm_idn.c index 42f2479ba01..99936efa093 100644 --- a/src/modules/rlm_idn/rlm_idn.c +++ b/src/modules/rlm_idn/rlm_idn.c @@ -155,12 +155,14 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) return 0; } -extern module_t rlm_idn; -module_t rlm_idn = { - .magic = RLM_MODULE_INIT, - .name = "idn", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_idn_t), - .config = mod_config, - .bootstrap = mod_bootstrap +extern module_rlm_t rlm_idn; +module_rlm_t rlm_idn = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "idn", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_idn_t), + .config = mod_config, + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_imap/rlm_imap.c b/src/modules/rlm_imap/rlm_imap.c index 097a359ddab..e03958d2083 100644 --- a/src/modules/rlm_imap/rlm_imap.c +++ b/src/modules/rlm_imap/rlm_imap.c @@ -212,23 +212,24 @@ static int mod_thread_detach(module_thread_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_imap; -module_t rlm_imap = { - .magic = RLM_MODULE_INIT, - .name = "imap", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_imap_t), - .thread_inst_size = sizeof(rlm_imap_thread_t), - .config = module_config, - .onload = mod_load, - .unload = mod_unload, - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - +extern module_rlm_t rlm_imap; +module_rlm_t rlm_imap = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "imap", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_imap_t), + .thread_inst_size = sizeof(rlm_imap_thread_t), + .config = module_config, + .onload = mod_load, + .unload = mod_unload, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, }, diff --git a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c index 69ba7cd20af..a43c8e7cd74 100644 --- a/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c +++ b/src/modules/rlm_isc_dhcp/rlm_isc_dhcp.c @@ -2234,14 +2234,15 @@ static unlang_action_t CC_HINT(nonnull) mod_post_auth(rlm_rcode_t *p_result, mod RETURN_MODULE_OK; } -extern module_t rlm_isc_dhcp; -module_t rlm_isc_dhcp = { - .magic = RLM_MODULE_INIT, - .name = "isc_dhcp", - .type = 0, - .inst_size = sizeof(rlm_isc_dhcp_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_isc_dhcp; +module_rlm_t rlm_isc_dhcp = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "isc_dhcp", + .inst_size = sizeof(rlm_isc_dhcp_t), + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_json/rlm_json.c b/src/modules/rlm_json/rlm_json.c index 03a28c302da..56d1f4a58eb 100644 --- a/src/modules/rlm_json/rlm_json.c +++ b/src/modules/rlm_json/rlm_json.c @@ -563,17 +563,19 @@ static int mod_load(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_json; -module_t rlm_json = { - .magic = RLM_MODULE_INIT, - .name = "json", - .type = RLM_TYPE_THREAD_SAFE, - .onload = mod_load, - .config = module_config, - .inst_size = sizeof(rlm_json_t), - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_json; +module_rlm_t rlm_json = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "json", + .type = MODULE_TYPE_THREAD_SAFE, + .onload = mod_load, + .config = module_config, + .inst_size = sizeof(rlm_json_t), + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_krb5/rlm_krb5.c b/src/modules/rlm_krb5/rlm_krb5.c index 0c0ea469bfc..16cc5ef1a0c 100644 --- a/src/modules/rlm_krb5/rlm_krb5.c +++ b/src/modules/rlm_krb5/rlm_krb5.c @@ -488,17 +488,21 @@ cleanup: #endif /* MIT_KRB5 */ -extern module_t rlm_krb5; -module_t rlm_krb5 = { - .magic = RLM_MODULE_INIT, - .name = "krb5", +extern module_rlm_t rlm_krb5; +module_rlm_t rlm_krb5 = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "krb5", #ifdef KRB5_IS_THREAD_SAFE - .type = RLM_TYPE_THREAD_SAFE, + .type = MODULE_TYPE_THREAD_SAFE, +#else + .type = MODULE_TYPE_THREAD_UNSAFE, #endif - .inst_size = sizeof(rlm_krb5_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, + .inst_size = sizeof(rlm_krb5_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate }, diff --git a/src/modules/rlm_ldap/rlm_ldap.c b/src/modules/rlm_ldap/rlm_ldap.c index 4d5606372e3..6f069e226eb 100644 --- a/src/modules/rlm_ldap/rlm_ldap.c +++ b/src/modules/rlm_ldap/rlm_ldap.c @@ -2354,22 +2354,24 @@ static void mod_unload(void) } /* globally exported name */ -extern module_t rlm_ldap; -module_t rlm_ldap = { - .magic = RLM_MODULE_INIT, - .name = "ldap", - .type = 0, - .inst_size = sizeof(rlm_ldap_t), - .config = module_config, - .onload = mod_load, - .unload = mod_unload, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - .detach = mod_detach, - .thread_inst_size = sizeof(fr_ldap_thread_t), - .thread_inst_type = "fr_ldap_thread_t", - .thread_instantiate = mod_thread_instatiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_ldap; +module_rlm_t rlm_ldap = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "ldap", + .type = 0, + .inst_size = sizeof(rlm_ldap_t), + .config = module_config, + .onload = mod_load, + .unload = mod_unload, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + .detach = mod_detach, + .thread_inst_size = sizeof(fr_ldap_thread_t), + .thread_inst_type = "fr_ldap_thread_t", + .thread_instantiate = mod_thread_instatiate, + .thread_detach = mod_thread_detach, + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c index 014af20092c..d7471e89e0d 100644 --- a/src/modules/rlm_linelog/rlm_linelog.c +++ b/src/modules/rlm_linelog/rlm_linelog.c @@ -790,14 +790,16 @@ finish: /* * Externally visible module definition. */ -extern module_t rlm_linelog; -module_t rlm_linelog = { - .magic = RLM_MODULE_INIT, - .name = "linelog", - .inst_size = sizeof(rlm_linelog_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, +extern module_rlm_t rlm_linelog; +module_rlm_t rlm_linelog = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "linelog", + .inst_size = sizeof(rlm_linelog_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_do_linelog, [MOD_AUTHORIZE] = mod_do_linelog, diff --git a/src/modules/rlm_logintime/rlm_logintime.c b/src/modules/rlm_logintime/rlm_logintime.c index f250462bdcd..b6f907dd7d5 100644 --- a/src/modules/rlm_logintime/rlm_logintime.c +++ b/src/modules/rlm_logintime/rlm_logintime.c @@ -256,17 +256,19 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_logintime; -module_t rlm_logintime = { - .magic = RLM_MODULE_INIT, - .name = "logintime", - .inst_size = sizeof(rlm_logintime_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_logintime; +module_rlm_t rlm_logintime = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "logintime", + .inst_size = sizeof(rlm_logintime_t), + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_POST_AUTH] = mod_authorize diff --git a/src/modules/rlm_logtee/rlm_logtee.c b/src/modules/rlm_logtee/rlm_logtee.c index df624f3fe5a..84e2a5e27e9 100644 --- a/src/modules/rlm_logtee/rlm_logtee.c +++ b/src/modules/rlm_logtee/rlm_logtee.c @@ -652,16 +652,17 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) /* * Externally visible module definition. */ -extern module_t rlm_logtee; -module_t rlm_logtee = { - .magic = RLM_MODULE_INIT, - .name = "logtee", - .inst_size = sizeof(rlm_logtee_t), - .thread_inst_size = sizeof(rlm_logtee_thread_t), - .config = module_config, - .instantiate = mod_instantiate, - .thread_instantiate = mod_thread_instantiate, - +extern module_rlm_t rlm_logtee; +module_rlm_t rlm_logtee = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "logtee", + .inst_size = sizeof(rlm_logtee_t), + .thread_inst_size = sizeof(rlm_logtee_thread_t), + .config = module_config, + .instantiate = mod_instantiate, + .thread_instantiate = mod_thread_instantiate, + }, .methods = { [MOD_AUTHENTICATE] = mod_insert_logtee, [MOD_AUTHORIZE] = mod_insert_logtee, diff --git a/src/modules/rlm_lua/rlm_lua.c b/src/modules/rlm_lua/rlm_lua.c index f88a9ddfb56..8d274aeb30a 100644 --- a/src/modules/rlm_lua/rlm_lua.c +++ b/src/modules/rlm_lua/rlm_lua.c @@ -160,26 +160,27 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_lua; -module_t rlm_lua = { - .magic = RLM_MODULE_INIT, - .name = "lua", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_lua_t), - - .thread_inst_size = sizeof(rlm_lua_thread_t), - - .config = module_config, - .instantiate = mod_instantiate, - .thread_instantiate = mod_thread_instantiate, - - .detach = mod_detach, - .thread_detach = mod_thread_detach, - +extern module_rlm_t rlm_lua; +module_rlm_t rlm_lua = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "lua", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_lua_t), + + .thread_inst_size = sizeof(rlm_lua_thread_t), + + .config = module_config, + .instantiate = mod_instantiate, + .thread_instantiate = mod_thread_instantiate, + + .detach = mod_detach, + .thread_detach = mod_thread_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_mruby/rlm_mruby.c b/src/modules/rlm_mruby/rlm_mruby.c index 3ff93b904b4..ac7591959ea 100644 --- a/src/modules/rlm_mruby/rlm_mruby.c +++ b/src/modules/rlm_mruby/rlm_mruby.c @@ -503,19 +503,21 @@ static int mod_detach(module_detach_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_mruby; -module_t rlm_mruby = { - .magic = RLM_MODULE_INIT, - .name = "mruby", - .type = RLM_TYPE_THREAD_UNSAFE, /* Not sure */ - .inst_size = sizeof(rlm_mruby_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, +extern module_rlm_t rlm_mruby; +module_rlm_t rlm_mruby = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "mruby", + .type = MODULE_TYPE_THREAD_UNSAFE, /* Not sure */ + .inst_size = sizeof(rlm_mruby_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach, + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_mschap/rlm_mschap.c b/src/modules/rlm_mschap/rlm_mschap.c index 1216a01a353..5fb455c7b5b 100644 --- a/src/modules/rlm_mschap/rlm_mschap.c +++ b/src/modules/rlm_mschap/rlm_mschap.c @@ -2302,16 +2302,17 @@ static int mod_detach( } -extern module_t rlm_mschap; -module_t rlm_mschap = { - .magic = RLM_MODULE_INIT, - .name = "mschap", - .type = 0, - .inst_size = sizeof(rlm_mschap_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - .detach = mod_detach, +extern module_rlm_t rlm_mschap; +module_rlm_t rlm_mschap = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "mschap", + .inst_size = sizeof(rlm_mschap_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize diff --git a/src/modules/rlm_opendirectory/rlm_opendirectory.c b/src/modules/rlm_opendirectory/rlm_opendirectory.c index 7929a35d336..bb168ac7e1a 100644 --- a/src/modules/rlm_opendirectory/rlm_opendirectory.c +++ b/src/modules/rlm_opendirectory/rlm_opendirectory.c @@ -528,13 +528,15 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) } /* globally exported name */ -extern module_t rlm_opendirectory; -module_t rlm_opendirectory = { - .magic = RLM_MODULE_INIT, - .name = "opendirectory", - .inst_size = sizeof(rlm_opendirectory_t), - .type = RLM_TYPE_THREAD_SAFE, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_opendirectory; +module_rlm_t rlm_opendirectory = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "opendirectory", + .inst_size = sizeof(rlm_opendirectory_t), + .type = MODULE_TYPE_THREAD_SAFE, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize diff --git a/src/modules/rlm_pam/rlm_pam.c b/src/modules/rlm_pam/rlm_pam.c index 2da807c0ea9..cd20b255654 100644 --- a/src/modules/rlm_pam/rlm_pam.c +++ b/src/modules/rlm_pam/rlm_pam.c @@ -267,14 +267,16 @@ static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, RETURN_MODULE_OK; } -extern module_t rlm_pam; -module_t rlm_pam = { - .magic = RLM_MODULE_INIT, - .name = "pam", - .type = RLM_TYPE_THREAD_UNSAFE, /* The PAM libraries are not thread-safe */ - .inst_size = sizeof(rlm_pam_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_pam; +module_rlm_t rlm_pam = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "pam", + .type = MODULE_TYPE_THREAD_UNSAFE, /* The PAM libraries are not thread-safe */ + .inst_size = sizeof(rlm_pam_t), + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate }, diff --git a/src/modules/rlm_pap/rlm_pap.c b/src/modules/rlm_pap/rlm_pap.c index 12e40a16cb3..ecdb98fe9f9 100644 --- a/src/modules/rlm_pap/rlm_pap.c +++ b/src/modules/rlm_pap/rlm_pap.c @@ -1067,19 +1067,21 @@ static void mod_unload(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_pap; -module_t rlm_pap = { - .magic = RLM_MODULE_INIT, - .name = "pap", - .inst_size = sizeof(rlm_pap_t), - .onload = mod_load, - .unload = mod_unload, - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_pap; +module_rlm_t rlm_pap = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "pap", + .inst_size = sizeof(rlm_pap_t), + .onload = mod_load, + .unload = mod_unload, + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize diff --git a/src/modules/rlm_passwd/rlm_passwd.c b/src/modules/rlm_passwd/rlm_passwd.c index df2f76bff7c..06ce2695e2e 100644 --- a/src/modules/rlm_passwd/rlm_passwd.c +++ b/src/modules/rlm_passwd/rlm_passwd.c @@ -608,14 +608,16 @@ static unlang_action_t CC_HINT(nonnull) mod_passwd_map(rlm_rcode_t *p_result, mo RETURN_MODULE_OK; } -extern module_t rlm_passwd; -module_t rlm_passwd = { - .magic = RLM_MODULE_INIT, - .name = "passwd", - .inst_size = sizeof(rlm_passwd_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, +extern module_rlm_t rlm_passwd; +module_rlm_t rlm_passwd = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "passwd", + .inst_size = sizeof(rlm_passwd_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHORIZE] = mod_passwd_map, [MOD_ACCOUNTING] = mod_passwd_map, diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index 61f8dfa28df..c4cedb4ed83 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -1230,28 +1230,29 @@ static void mod_unload(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_perl; -module_t rlm_perl = { - .magic = RLM_MODULE_INIT, - .name = "perl", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_perl_t), - - .config = module_config, - .onload = mod_load, - .unload = mod_unload, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - .detach = mod_detach, - - .thread_inst_size = sizeof(rlm_perl_thread_t), - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - +extern module_rlm_t rlm_perl; +module_rlm_t rlm_perl = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "perl", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_perl_t), + + .config = module_config, + .onload = mod_load, + .unload = mod_unload, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + .detach = mod_detach, + + .thread_inst_size = sizeof(rlm_perl_thread_t), + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 97c0e174704..db677d86860 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -1152,29 +1152,30 @@ static void mod_unload(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_python; -module_t rlm_python = { - .magic = RLM_MODULE_INIT, - .name = "python", - .type = RLM_TYPE_THREAD_SAFE, +extern module_rlm_t rlm_python; +module_rlm_t rlm_python = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "python", + .type = MODULE_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_python_t), - .thread_inst_size = sizeof(rlm_python_thread_t), + .inst_size = sizeof(rlm_python_t), + .thread_inst_size = sizeof(rlm_python_thread_t), - .config = module_config, - .onload = mod_load, - .unload = mod_unload, + .config = module_config, + .onload = mod_load, + .unload = mod_unload, - .instantiate = mod_instantiate, - .detach = mod_detach, - - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, + .instantiate = mod_instantiate, + .detach = mod_detach, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_radius/rlm_radius.h b/src/modules/rlm_radius/rlm_radius.h index 42df44d7b39..ad49fc0f6e2 100644 --- a/src/modules/rlm_radius/rlm_radius.h +++ b/src/modules/rlm_radius/rlm_radius.h @@ -36,23 +36,13 @@ typedef struct rlm_radius_s rlm_radius_t; typedef struct rlm_radius_io_s rlm_radius_io_t; -/** Per-thread instance data - * - * Contains buffers and connection handles specific to the thread. - */ -typedef struct { - void *io_thread; //!< thread context for the IO submodule -} rlm_radius_thread_t; - /* * Define a structure for our module configuration. */ struct rlm_radius_s { char const *name; - dl_module_inst_t *io_submodule; //!< As provided by the transport_parse - rlm_radius_io_t const *io; //!< Easy access to the IO handle - void *io_instance; //!< Easy access to the IO instance - CONF_SECTION *io_conf; //!< Easy access to the IO config section + module_instance_t *io_submodule; + rlm_radius_io_t const *io; //!< Public symbol exported by the submodule. fr_time_delta_t response_window; fr_time_delta_t zombie_period; @@ -89,11 +79,8 @@ typedef unlang_action_t (*rlm_radius_io_enqueue_t)(rlm_rcode_t *p_result, void * * This structure is exported by client I/O modules e.g. rlm_radius_udp. */ struct rlm_radius_io_s { - DL_MODULE_COMMON; //!< Common fields to all loadable modules. - FR_MODULE_COMMON; - FR_MODULE_THREADED_COMMON; - - rlm_radius_io_enqueue_t enqueue; //!< Enqueue a request_t with an IO submodule. - unlang_module_signal_t signal; //!< Send a signal to an IO module. - unlang_module_resume_t resume; //!< Resume a request, and get rcode. + module_t common; //!< Common fields to all loadable modules. + rlm_radius_io_enqueue_t enqueue; //!< Enqueue a request_t with an IO submodule. + unlang_module_signal_t signal; //!< Send a signal to an IO module. + unlang_module_resume_t resume; //!< Resume a request, and get rcode. }; diff --git a/src/modules/rlm_radius/rlm_radius_udp.c b/src/modules/rlm_radius/rlm_radius_udp.c index d1e141edc9f..ef33dcfe5cb 100644 --- a/src/modules/rlm_radius/rlm_radius_udp.c +++ b/src/modules/rlm_radius/rlm_radius_udp.c @@ -2954,17 +2954,18 @@ static int mod_instantiate(module_inst_ctx_t const *mctx) extern rlm_radius_io_t rlm_radius_udp; rlm_radius_io_t rlm_radius_udp = { - .magic = RLM_MODULE_INIT, - .name = "radius_udp", - .inst_size = sizeof(rlm_radius_udp_t), - - .thread_inst_size = sizeof(udp_thread_t), - .thread_inst_type = "udp_thread_t", - - .config = module_config, - .instantiate = mod_instantiate, - .thread_instantiate = mod_thread_instantiate, - + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "radius_udp", + .inst_size = sizeof(rlm_radius_udp_t), + + .thread_inst_size = sizeof(udp_thread_t), + .thread_inst_type = "udp_thread_t", + + .config = module_config, + .instantiate = mod_instantiate, + .thread_instantiate = mod_thread_instantiate, + }, .enqueue = mod_enqueue, .signal = mod_signal, .resume = mod_resume, diff --git a/src/modules/rlm_radutmp/rlm_radutmp.c b/src/modules/rlm_radutmp/rlm_radutmp.c index 9f99bcec6af..f6add71f4d8 100644 --- a/src/modules/rlm_radutmp/rlm_radutmp.c +++ b/src/modules/rlm_radutmp/rlm_radutmp.c @@ -557,13 +557,15 @@ static unlang_action_t CC_HINT(nonnull) mod_accounting(rlm_rcode_t *p_result, mo } /* globally exported name */ -extern module_t rlm_radutmp; -module_t rlm_radutmp = { - .magic = RLM_MODULE_INIT, - .name = "radutmp", - .type = RLM_TYPE_THREAD_UNSAFE, - .inst_size = sizeof(rlm_radutmp_t), - .config = module_config, +extern module_rlm_t rlm_radutmp; +module_rlm_t rlm_radutmp = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "radutmp", + .type = MODULE_TYPE_THREAD_UNSAFE, + .inst_size = sizeof(rlm_radutmp_t), + .config = module_config + }, .methods = { [MOD_ACCOUNTING] = mod_accounting, }, diff --git a/src/modules/rlm_redis/rlm_redis.c b/src/modules/rlm_redis/rlm_redis.c index e28e63e2a58..4c16ac44b0b 100644 --- a/src/modules/rlm_redis/rlm_redis.c +++ b/src/modules/rlm_redis/rlm_redis.c @@ -488,14 +488,16 @@ static int mod_load(void) return 0; } -extern module_t rlm_redis; -module_t rlm_redis = { - .magic = RLM_MODULE_INIT, - .name = "redis", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_redis_t), - .config = module_config, - .onload = mod_load, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_redis; +module_rlm_t rlm_redis = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "redis", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_redis_t), + .config = module_config, + .onload = mod_load, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate + } }; diff --git a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c index e66d947d19a..bb7cc8531d5 100644 --- a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c +++ b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c @@ -1427,15 +1427,17 @@ static int mod_load(void) return 0; } -extern module_t rlm_redis_ippool; -module_t rlm_redis_ippool = { - .magic = RLM_MODULE_INIT, - .name = "redis", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_redis_ippool_t), - .config = module_config, - .onload = mod_load, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_redis_ippool; +module_rlm_t rlm_redis_ippool = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "redis", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_redis_ippool_t), + .config = module_config, + .onload = mod_load, + .instantiate = mod_instantiate + }, .methods = { [MOD_ACCOUNTING] = mod_accounting, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_rediswho/rlm_rediswho.c b/src/modules/rlm_rediswho/rlm_rediswho.c index e73c8148f6e..6b159bb49e4 100644 --- a/src/modules/rlm_rediswho/rlm_rediswho.c +++ b/src/modules/rlm_rediswho/rlm_rediswho.c @@ -247,15 +247,17 @@ static int mod_load(void) return 0; } -extern module_t rlm_rediswho; -module_t rlm_rediswho = { - .magic = RLM_MODULE_INIT, - .name = "rediswho", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_rediswho_t), - .config = module_config, - .onload = mod_load, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_rediswho; +module_rlm_t rlm_rediswho = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rediswho", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_rediswho_t), + .config = module_config, + .onload = mod_load, + .instantiate = mod_instantiate + }, .methods = { [MOD_ACCOUNTING] = mod_accounting }, diff --git a/src/modules/rlm_rest/rlm_rest.c b/src/modules/rlm_rest/rlm_rest.c index 1cc70c12a08..13c38b38923 100644 --- a/src/modules/rlm_rest/rlm_rest.c +++ b/src/modules/rlm_rest/rlm_rest.c @@ -1231,24 +1231,26 @@ static void mod_unload(void) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_rest; -module_t rlm_rest = { - .magic = RLM_MODULE_INIT, - .name = "rest", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_rest_t), - .thread_inst_size = sizeof(rlm_rest_thread_t), - .config = module_config, - .onload = mod_load, - .unload = mod_unload, - .bootstrap = mod_bootstrap, - .instantiate = instantiate, - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_rest; +module_rlm_t rlm_rest = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rest", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_rest_t), + .thread_inst_size = sizeof(rlm_rest_thread_t), + .config = module_config, + .onload = mod_load, + .unload = mod_unload, + .bootstrap = mod_bootstrap, + .instantiate = instantiate, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_securid/rlm_securid.c b/src/modules/rlm_securid/rlm_securid.c index f5a635fb78e..4bb6791fdfa 100644 --- a/src/modules/rlm_securid/rlm_securid.c +++ b/src/modules/rlm_securid/rlm_securid.c @@ -546,18 +546,20 @@ static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_securid; -module_t rlm_securid = { - .magic = RLM_MODULE_INIT, - .name = "securid", - .inst_size = sizeof(rlm_securid_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, +extern module_rlm_t rlm_securid; +module_rlm_t rlm_securid = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "securid", + .inst_size = sizeof(rlm_securid_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate }, diff --git a/src/modules/rlm_sigtran/rlm_sigtran.c b/src/modules/rlm_sigtran/rlm_sigtran.c index b98b777936c..6b5bb793404 100644 --- a/src/modules/rlm_sigtran/rlm_sigtran.c +++ b/src/modules/rlm_sigtran/rlm_sigtran.c @@ -417,22 +417,24 @@ static int mod_detach(module_detach_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_sigtran; -module_t rlm_sigtran = { - .magic = RLM_MODULE_INIT, - .name = "sigtran", - .type = RLM_TYPE_THREAD_SAFE | RLM_TYPE_RESUMABLE, - .inst_size = sizeof(rlm_sigtran_t), - .thread_inst_size = sizeof(rlm_sigtran_thread_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_sigtran; +module_rlm_t rlm_sigtran = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "sigtran", + .type = MODULE_TYPE_THREAD_SAFE | MODULE_TYPE_RESUMABLE, + .inst_size = sizeof(rlm_sigtran_t), + .thread_inst_size = sizeof(rlm_sigtran_thread_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, } diff --git a/src/modules/rlm_smtp/rlm_smtp.c b/src/modules/rlm_smtp/rlm_smtp.c index c93b0435ce3..692476c780a 100644 --- a/src/modules/rlm_smtp/rlm_smtp.c +++ b/src/modules/rlm_smtp/rlm_smtp.c @@ -1104,25 +1104,26 @@ static int mod_thread_detach(module_thread_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_smtp; -module_t rlm_smtp = { - .magic = RLM_MODULE_INIT, - .name = "smtp", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_smtp_t), - .thread_inst_size = sizeof(rlm_smtp_thread_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - .onload = mod_load, - .unload = mod_unload, - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, - +extern module_rlm_t rlm_smtp; +module_rlm_t rlm_smtp = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "smtp", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_smtp_t), + .thread_inst_size = sizeof(rlm_smtp_thread_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + .onload = mod_load, + .unload = mod_unload, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach, + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_soh/rlm_soh.c b/src/modules/rlm_soh/rlm_soh.c index 0d5d73a0540..99d90055de9 100644 --- a/src/modules/rlm_soh/rlm_soh.c +++ b/src/modules/rlm_soh/rlm_soh.c @@ -291,16 +291,18 @@ static void mod_unload(void) fr_soh_free(); } -extern module_t rlm_soh; -module_t rlm_soh = { - .magic = RLM_MODULE_INIT, - .name = "soh", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_soh_t), - .config = module_config, - .onload = mod_load, - .unload = mod_unload, - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_soh; +module_rlm_t rlm_soh = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "soh", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_soh_t), + .config = module_config, + .onload = mod_load, + .unload = mod_unload, + .bootstrap = mod_bootstrap + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_POST_AUTH] = mod_post_auth diff --git a/src/modules/rlm_sometimes/rlm_sometimes.c b/src/modules/rlm_sometimes/rlm_sometimes.c index 7ca69d91af3..135a6fd6830 100644 --- a/src/modules/rlm_sometimes/rlm_sometimes.c +++ b/src/modules/rlm_sometimes/rlm_sometimes.c @@ -153,13 +153,15 @@ static unlang_action_t CC_HINT(nonnull) mod_sometimes_reply(rlm_rcode_t *p_resul return sometimes_return(p_result, mctx, request, request->reply, NULL); } -extern module_t rlm_sometimes; -module_t rlm_sometimes = { - .magic = RLM_MODULE_INIT, - .name = "sometimes", - .inst_size = sizeof(rlm_sometimes_t), - .config = module_config, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_sometimes; +module_rlm_t rlm_sometimes = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "sometimes", + .inst_size = sizeof(rlm_sometimes_t), + .config = module_config, + .instantiate = mod_instantiate + }, .methods = { [MOD_AUTHENTICATE] = mod_sometimes_packet, [MOD_AUTHORIZE] = mod_sometimes_packet, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_cassandra/rlm_sql_cassandra.c b/src/modules/rlm_sql/drivers/rlm_sql_cassandra/rlm_sql_cassandra.c index 4c85da631e5..fd9364889cb 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_cassandra/rlm_sql_cassandra.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_cassandra/rlm_sql_cassandra.c @@ -719,13 +719,14 @@ static int mod_detach(module_detach_ctx_t const *mctx) return 0; } -static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_SECTION *cs) +static int mod_instantiate(module_inst_ctx_t const *mctx) { - bool do_tls = false; - bool do_latency_aware_routing = false; - rlm_sql_cassandra_t *inst = talloc_get_type_abort(instance, rlm_sql_cassandra_t); - - CassCluster *cluster; + rlm_sql_t const *parent = talloc_get_type_abort(mctx->inst->parent->data, rlm_sql_t); + rlm_sql_config_t const *config = &parent->config; + rlm_sql_cassandra_t *inst = talloc_get_type_abort(mctx->inst, rlm_sql_cassandra_t); + bool do_tls = false; + bool do_latency_aware_routing = false; + CassCluster *cluster; #define DO_CASS_OPTION(_opt, _x) \ do {\ @@ -746,8 +747,8 @@ do {\ * This has to be done before we call cf_section_parse * as it sets default values, and creates the section. */ - if (cf_section_find(cs, "tls", NULL)) do_tls = true; - if (cf_section_find(cs, "latency_aware_routing", NULL)) do_latency_aware_routing = true; + if (cf_section_find(mctx->inst->conf, "tls", NULL)) do_tls = true; + if (cf_section_find(mctx->inst->conf, "latency_aware_routing", NULL)) do_latency_aware_routing = true; DEBUG4("Configuring CassCluster structure"); cluster = inst->cluster = cass_cluster_new(); diff --git a/src/modules/rlm_sql/drivers/rlm_sql_db2/rlm_sql_db2.c b/src/modules/rlm_sql/drivers/rlm_sql_db2/rlm_sql_db2.c index 8243307c5d4..381da7ea92b 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_db2/rlm_sql_db2.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_db2/rlm_sql_db2.c @@ -287,8 +287,10 @@ static int sql_affected_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t c /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_db2; rlm_sql_driver_t rlm_sql_db2 = { - .name = "rlm_sql_db2", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_sql_db2", + }, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_firebird/rlm_sql_firebird.c b/src/modules/rlm_sql/drivers/rlm_sql_firebird/rlm_sql_firebird.c index 669abe22ab7..be6ef061024 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_firebird/rlm_sql_firebird.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_firebird/rlm_sql_firebird.c @@ -293,8 +293,10 @@ static int sql_affected_rows(rlm_sql_handle_t *handle, UNUSED rlm_sql_config_t c /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_firebird; rlm_sql_driver_t rlm_sql_firebird = { - .name = "rlm_sql_firebird", - .magic = RLM_MODULE_INIT, + .common = { + .name = "rlm_sql_firebird", + .magic = MODULE_MAGIC_INIT + }, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_freetds/rlm_sql_freetds.c b/src/modules/rlm_sql/drivers/rlm_sql_freetds/rlm_sql_freetds.c index 905745ac539..e33f82b715f 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_freetds/rlm_sql_freetds.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_freetds/rlm_sql_freetds.c @@ -803,8 +803,10 @@ error: /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_freetds; rlm_sql_driver_t rlm_sql_freetds = { - .name = "rlm_sql_freetds", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_sql_freetds" + }, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c b/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c index e2b9abc40f5..b75eee19b2b 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c @@ -167,9 +167,9 @@ static int _sql_socket_destructor(rlm_sql_mysql_conn_t *conn) return 0; } -static int mod_instantiate(UNUSED rlm_sql_config_t const *config, void *instance, UNUSED CONF_SECTION *cs) +static int mod_instantiate(module_inst_ctx_t const *mctx) { - rlm_sql_mysql_t *inst = talloc_get_type_abort(instance, rlm_sql_mysql_t); + rlm_sql_mysql_t *inst = talloc_get_type_abort(mctx->inst->data, rlm_sql_mysql_t); int warnings; warnings = fr_table_value_by_str(server_warnings_table, inst->warnings_str, -1); @@ -843,14 +843,16 @@ static size_t sql_escape_func(UNUSED request_t *request, char *out, size_t outle /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_mysql; rlm_sql_driver_t rlm_sql_mysql = { - .name = "rlm_sql_mysql", - .magic = RLM_MODULE_INIT, + .common = { + .name = "rlm_sql_mysql", + .magic = MODULE_MAGIC_INIT, + .inst_size = sizeof(rlm_sql_mysql_t), + .onload = mod_load, + .unload = mod_unload, + .config = driver_config, + .instantiate = mod_instantiate + }, .flags = RLM_SQL_RCODE_FLAGS_ALT_QUERY, - .inst_size = sizeof(rlm_sql_mysql_t), - .onload = mod_load, - .unload = mod_unload, - .config = driver_config, - .instantiate = mod_instantiate, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_null/rlm_sql_null.c b/src/modules/rlm_sql/drivers/rlm_sql_null/rlm_sql_null.c index 1afa8a69af6..7e15b0854da 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_null/rlm_sql_null.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_null/rlm_sql_null.c @@ -98,8 +98,10 @@ static int sql_affected_rows(UNUSED rlm_sql_handle_t * handle, UNUSED rlm_sql_co /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_null; rlm_sql_driver_t rlm_sql_null = { - .name = "rlm_sql_null", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_sql_null" + }, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_oracle/rlm_sql_oracle.c b/src/modules/rlm_sql/drivers/rlm_sql_oracle/rlm_sql_oracle.c index 016f295b068..27d1762eccb 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_oracle/rlm_sql_oracle.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_oracle/rlm_sql_oracle.c @@ -153,16 +153,18 @@ static int mod_detach(module_detach_ctx_t const *mctx) return 0; } -static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_SECTION *conf) +static int mod_instantiate(module_inst_ctx_t const *mctx) { - char errbuff[512]; - sb4 errcode = 0; - rlm_sql_oracle_t *inst = talloc_get_type_abort(instance, rlm_sql_oracle_t); - OraText *sql_password = NULL; - OraText *sql_login = NULL; - - if (!cf_section_find(conf, "spool", NULL)) { - ERROR("Couldn't load configuration of session pool(\"spool\" section in driver config)"); + rlm_sql_t const *parent = talloc_get_type_abort(mctx->inst->parent->data, rlm_sql_t); + rlm_sql_config_t const *config = &parent->config; + rlm_sql_oracle_t *inst = talloc_get_type_abort(mctx->inst, rlm_sql_oracle_t); + char errbuff[512]; + sb4 errcode = 0; + OraText *sql_password = NULL; + OraText *sql_login = NULL; + + if (!cf_section_find(mctx->inst->conf, "spool", NULL)) { + ERROR("Couldn't load mctx->configuration of session pool(\"spool\" section in driver mctx->config)"); return RLM_SQL_ERROR; } @@ -202,12 +204,12 @@ static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_ memcpy(&sql_password, config->sql_password, sizeof(sql_password)); if (OCISessionPoolCreate((dvoid *)inst->env, (dvoid *)inst->error, (dvoid *)inst->pool, - (OraText**)&inst->pool_name, (ub4*)&inst->pool_name_len, - (CONST OraText *)config->sql_db, strlen(config->sql_db), - inst->spool_min, inst->spool_max, inst->spool_inc, - sql_login, strlen(config->sql_login), - sql_password, strlen(config->sql_password), - OCI_SPC_STMTCACHE | OCI_SPC_HOMOGENEOUS)) { + (OraText**)&inst->pool_name, (ub4*)&inst->pool_name_len, + (CONST OraText *)config->sql_db, strlen(config->sql_db), + inst->spool_min, inst->spool_max, inst->spool_inc, + sql_login, strlen(config->sql_login), + sql_password, strlen(config->sql_password), + OCI_SPC_STMTCACHE | OCI_SPC_HOMOGENEOUS)) { errbuff[0] = '\0'; OCIErrorGet((dvoid *) inst->error, 1, (OraText *) NULL, &errcode, (OraText *) errbuff, @@ -610,12 +612,14 @@ static int sql_affected_rows(rlm_sql_handle_t *handle, rlm_sql_config_t const *c /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_oracle; rlm_sql_driver_t rlm_sql_oracle = { - .name = "rlm_sql_oracle", - .magic = RLM_MODULE_INIT, - .inst_size = sizeof(rlm_sql_oracle_t), - .config = driver_config, - .instantiate = mod_instantiate, - .detach = mod_detach, + .common = { + .name = "rlm_sql_oracle", + .magic = MODULE_MAGIC_INIT, + .inst_size = sizeof(rlm_sql_oracle_t), + .config = driver_config, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c index 99dd9e90c0b..334f7d968a9 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_postgresql/rlm_sql_postgresql.c @@ -544,9 +544,11 @@ static size_t sql_escape_func(request_t *request, char *out, size_t outlen, char return ret; } -static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_SECTION *conf) +static int mod_instantiate(module_inst_ctx_t const *mctx) { - rlm_sql_postgresql_t *inst = talloc_get_type_abort(instance, rlm_sql_postgresql_t); + rlm_sql_t const *parent = talloc_get_type_abort(mctx->inst->parent->data, rlm_sql_t); + rlm_sql_config_t const *config = &parent->config; + rlm_sql_postgresql_t *inst = talloc_get_type_abort(mctx->inst, rlm_sql_postgresql_t); char application_name[NAMEDATALEN]; char *db_string; @@ -557,7 +559,7 @@ static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_ CONF_SECTION *cs; char const *name; - cs = cf_item_to_section(cf_parent(conf)); + cs = cf_item_to_section(cf_parent(mctx->inst->conf)); name = cf_section_name2(cs); if (!name) name = cf_section_name1(cs); @@ -645,7 +647,7 @@ static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_ { CONF_SECTION *cs; - cs = cf_section_find(conf, "states", NULL); + cs = cf_section_find(mctx->inst->conf, "states", NULL); if (cs && (sql_state_entries_from_cs(inst->states, cs) < 0)) return -1; } @@ -667,13 +669,15 @@ static int mod_load(void) /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_postgresql; rlm_sql_driver_t rlm_sql_postgresql = { - .name = "rlm_sql_postgresql", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_sql_postgresql", + .inst_size = sizeof(rlm_sql_postgresql_t), + .onload = mod_load, + .config = driver_config, + .instantiate = mod_instantiate + }, .flags = RLM_SQL_RCODE_FLAGS_ALT_QUERY, - .inst_size = sizeof(rlm_sql_postgresql_t), - .onload = mod_load, - .config = driver_config, - .instantiate = mod_instantiate, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_sqlite/rlm_sql_sqlite.c b/src/modules/rlm_sql/drivers/rlm_sql_sqlite/rlm_sql_sqlite.c index 84c358e7dbd..78b3b1b033a 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_sqlite/rlm_sql_sqlite.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_sqlite/rlm_sql_sqlite.c @@ -683,10 +683,12 @@ static int sql_affected_rows(rlm_sql_handle_t *handle, return -1; } -static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_SECTION *cs) +static int mod_instantiate(module_inst_ctx_t const *mctx) { + rlm_sql_t const *parent = talloc_get_type_abort(mctx->inst->parent->data, rlm_sql_t); + rlm_sql_config_t const *config = &parent->config; + rlm_sql_sqlite_t *inst = talloc_get_type_abort(mctx->inst, rlm_sql_sqlite_t); bool exists; - rlm_sql_sqlite_t *inst = talloc_get_type_abort(instance, rlm_sql_sqlite_t); struct stat buf; if (!inst->filename) { @@ -703,7 +705,7 @@ static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_ return -1; } - if (cf_pair_find(cs, "bootstrap")) { + if (cf_pair_find(mctx->inst->conf, "bootstrap")) { inst->bootstrap = true; } @@ -722,10 +724,10 @@ static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_ if (p) { size_t len = (p - inst->filename) + 1; - buff = talloc_array(cs, char, len); + buff = talloc_array(mctx->inst->conf, char, len); strlcpy(buff, inst->filename, len); } else { - MEM(buff = talloc_typed_strdup(cs, inst->filename)); + MEM(buff = talloc_typed_strdup(mctx->inst->conf, inst->filename)); } ret = fr_mkdir(NULL, buff, -1, 0700, NULL, NULL); @@ -758,13 +760,13 @@ static int mod_instantiate(rlm_sql_config_t const *config, void *instance, CONF_ /* * Execute multiple bootstrap SQL files in order */ - for (cp = cf_pair_find(cs, "bootstrap"); + for (cp = cf_pair_find(mctx->inst->conf, "bootstrap"); cp; - cp = cf_pair_find_next(cs, cp, "bootstrap")) { + cp = cf_pair_find_next(mctx->inst->conf, cp, "bootstrap")) { p = cf_pair_value(cp); if (!p) continue; - ret = sql_loadfile(cs, db, p); + ret = sql_loadfile(mctx->inst->conf, db, p); if (ret < 0) goto unlink; } @@ -812,13 +814,15 @@ static int mod_load(void) /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_sqlite; rlm_sql_driver_t rlm_sql_sqlite = { - .name = "rlm_sql_sqlite", - .magic = RLM_MODULE_INIT, + .common = { + .name = "rlm_sql_sqlite", + .magic = MODULE_MAGIC_INIT, + .inst_size = sizeof(rlm_sql_sqlite_t), + .config = driver_config, + .onload = mod_load, + .instantiate = mod_instantiate + }, .flags = RLM_SQL_RCODE_FLAGS_ALT_QUERY, - .inst_size = sizeof(rlm_sql_sqlite_t), - .config = driver_config, - .onload = mod_load, - .instantiate = mod_instantiate, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/drivers/rlm_sql_unixodbc/rlm_sql_unixodbc.c b/src/modules/rlm_sql/drivers/rlm_sql_unixodbc/rlm_sql_unixodbc.c index ab5d2e276e3..855a9b850a2 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_unixodbc/rlm_sql_unixodbc.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_unixodbc/rlm_sql_unixodbc.c @@ -389,8 +389,10 @@ static int sql_affected_rows(rlm_sql_handle_t *handle, rlm_sql_config_t const *c /* Exported to rlm_sql */ extern rlm_sql_driver_t rlm_sql_unixodbc; rlm_sql_driver_t rlm_sql_unixodbc = { - .name = "rlm_sql_unixodbc", - .magic = RLM_MODULE_INIT, + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "rlm_sql_unixodbc" + }, .sql_socket_init = sql_socket_init, .sql_query = sql_query, .sql_select_query = sql_select_query, diff --git a/src/modules/rlm_sql/rlm_sql.c b/src/modules/rlm_sql/rlm_sql.c index 0b8d8fb89be..b93c429b6d8 100644 --- a/src/modules/rlm_sql/rlm_sql.c +++ b/src/modules/rlm_sql/rlm_sql.c @@ -42,7 +42,7 @@ RCSID("$Id$") #include "rlm_sql.h" -extern module_t rlm_sql; +extern module_rlm_t rlm_sql; /* * So we can do pass2 xlat checks on the queries. @@ -1051,7 +1051,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) } inst->driver = (rlm_sql_driver_t const *)inst->driver_inst->module->common; - fr_assert(!inst->driver->inst_size || inst->driver_inst->data); + fr_assert(!inst->driver->common.inst_size || inst->driver_inst->data); /* * Call the driver's instantiate function (if set) @@ -1664,15 +1664,17 @@ static unlang_action_t CC_HINT(nonnull) mod_post_auth(rlm_rcode_t *p_result, mod /* globally exported name */ -module_t rlm_sql = { - .magic = RLM_MODULE_INIT, - .name = "sql", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_sql_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, - .detach = mod_detach, +module_rlm_t rlm_sql = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "sql", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_sql_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + .detach = mod_detach + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_ACCOUNTING] = mod_accounting, diff --git a/src/modules/rlm_sql/rlm_sql.h b/src/modules/rlm_sql/rlm_sql.h index c9c24d5ad94..427020f8513 100644 --- a/src/modules/rlm_sql/rlm_sql.h +++ b/src/modules/rlm_sql/rlm_sql.h @@ -185,7 +185,7 @@ typedef size_t (*sql_error_t)(TALLOC_CTX *ctx, sql_log_entry_t out[], size_t out rlm_sql_config_t const *config); typedef struct { - DL_MODULE_COMMON; //!< Common fields to all loadable modules. + module_t common; //!< Common fields for all loadable modules. int flags; diff --git a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c index b5140d58593..c68632c8d26 100644 --- a/src/modules/rlm_sqlcounter/rlm_sqlcounter.c +++ b/src/modules/rlm_sqlcounter/rlm_sqlcounter.c @@ -626,19 +626,21 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_sqlcounter; -module_t rlm_sqlcounter = { - .magic = RLM_MODULE_INIT, - .name = "sqlcounter", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_sqlcounter_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_sqlcounter; +module_rlm_t rlm_sqlcounter = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "sqlcounter", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_sqlcounter_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, + }, .methods = { [MOD_AUTHORIZE] = mod_authorize }, diff --git a/src/modules/rlm_sqlippool/rlm_sqlippool.c b/src/modules/rlm_sqlippool/rlm_sqlippool.c index a6f886b3a72..87375e6db48 100644 --- a/src/modules/rlm_sqlippool/rlm_sqlippool.c +++ b/src/modules/rlm_sqlippool/rlm_sqlippool.c @@ -850,19 +850,21 @@ static unlang_action_t CC_HINT(nonnull) mod_accounting(rlm_rcode_t *p_result, mo * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_sqlippool; -module_t rlm_sqlippool = { - .magic = RLM_MODULE_INIT, - .name = "sqlippool", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_sqlippool_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_sqlippool; +module_rlm_t rlm_sqlippool = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "sqlippool", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_sqlippool_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate + }, .methods = { [MOD_ACCOUNTING] = mod_accounting, [MOD_POST_AUTH] = mod_alloc diff --git a/src/modules/rlm_stats/rlm_stats.c b/src/modules/rlm_stats/rlm_stats.c index 97fabc2af0b..7ce02a23d4c 100644 --- a/src/modules/rlm_stats/rlm_stats.c +++ b/src/modules/rlm_stats/rlm_stats.c @@ -427,22 +427,24 @@ static int mod_detach(module_detach_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_stats; - -module_t rlm_stats = { - .magic = RLM_MODULE_INIT, - .name = "stats", - .inst_size = sizeof(rlm_stats_t), - .thread_inst_size = sizeof(rlm_stats_thread_t), - .config = module_config, - .instantiate = mod_instantiate, - .detach = mod_detach, - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_stats; + +module_rlm_t rlm_stats = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "stats", + .inst_size = sizeof(rlm_stats_t), + .thread_inst_size = sizeof(rlm_stats_thread_t), + .config = module_config, + .instantiate = mod_instantiate, + .detach = mod_detach, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + }, .methods = { [MOD_AUTHORIZE] = mod_stats, /* @mod_stats_query */ [MOD_POST_AUTH] = mod_stats, diff --git a/src/modules/rlm_test/rlm_test.c b/src/modules/rlm_test/rlm_test.c index ae0e48d9437..1469db485a7 100644 --- a/src/modules/rlm_test/rlm_test.c +++ b/src/modules/rlm_test/rlm_test.c @@ -502,21 +502,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_test; -module_t rlm_test = { - .magic = RLM_MODULE_INIT, - .name = "test", - .type = RLM_TYPE_THREAD_SAFE | RLM_TYPE_RETRY, - .inst_size = sizeof(rlm_test_t), - .thread_inst_size = sizeof(rlm_test_thread_t), - .config = module_config, - .bootstrap = mod_bootstrap, - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_test; +module_rlm_t rlm_test = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "test", + .type = MODULE_TYPE_THREAD_SAFE | MODULE_TYPE_RETRY, + .inst_size = sizeof(rlm_test_t), + .thread_inst_size = sizeof(rlm_test_thread_t), + .config = module_config, + .bootstrap = mod_bootstrap, + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_totp/rlm_totp.c b/src/modules/rlm_totp/rlm_totp.c index 5d645ba1545..0c652162bb0 100644 --- a/src/modules/rlm_totp/rlm_totp.c +++ b/src/modules/rlm_totp/rlm_totp.c @@ -282,15 +282,17 @@ static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_totp; -module_t rlm_totp = { - .magic = RLM_MODULE_INIT, - .name = "totp", - .type = RLM_TYPE_THREAD_SAFE, +extern module_rlm_t rlm_totp; +module_rlm_t rlm_totp = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "totp", + .type = MODULE_TYPE_THREAD_SAFE + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, }, diff --git a/src/modules/rlm_unbound/rlm_unbound.c b/src/modules/rlm_unbound/rlm_unbound.c index f58320cafd8..b0a218bc64c 100644 --- a/src/modules/rlm_unbound/rlm_unbound.c +++ b/src/modules/rlm_unbound/rlm_unbound.c @@ -495,17 +495,19 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) return 0; } -extern module_t rlm_unbound; -module_t rlm_unbound = { - .magic = RLM_MODULE_INIT, - .name = "unbound", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_unbound_t), - .config = module_config, - .bootstrap = mod_bootstrap, - - .thread_inst_size = sizeof(rlm_unbound_thread_t), - .thread_inst_type = "rlm_unbound_thread_t", - .thread_instantiate = mod_thread_instantiate, - .thread_detach = mod_thread_detach, +extern module_rlm_t rlm_unbound; +module_rlm_t rlm_unbound = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "unbound", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_unbound_t), + .config = module_config, + .bootstrap = mod_bootstrap, + + .thread_inst_size = sizeof(rlm_unbound_thread_t), + .thread_inst_type = "rlm_unbound_thread_t", + .thread_instantiate = mod_thread_instantiate, + .thread_detach = mod_thread_detach + } }; diff --git a/src/modules/rlm_unix/rlm_unix.c b/src/modules/rlm_unix/rlm_unix.c index fef21550ef6..8771c4d8d05 100644 --- a/src/modules/rlm_unix/rlm_unix.c +++ b/src/modules/rlm_unix/rlm_unix.c @@ -506,14 +506,16 @@ static unlang_action_t CC_HINT(nonnull) mod_accounting(rlm_rcode_t *p_result, mo } /* globally exported name */ -extern module_t rlm_unix; -module_t rlm_unix = { - .magic = RLM_MODULE_INIT, - .name = "unix", - .type = RLM_TYPE_THREAD_UNSAFE, - .inst_size = sizeof(rlm_unix_t), - .config = module_config, - .bootstrap = mod_bootstrap, +extern module_rlm_t rlm_unix; +module_rlm_t rlm_unix = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "unix", + .type = MODULE_TYPE_THREAD_UNSAFE, + .inst_size = sizeof(rlm_unix_t), + .config = module_config, + .bootstrap = mod_bootstrap + }, .methods = { [MOD_AUTHORIZE] = mod_authorize, [MOD_ACCOUNTING] = mod_accounting diff --git a/src/modules/rlm_unpack/rlm_unpack.c b/src/modules/rlm_unpack/rlm_unpack.c index ab9906cd9e2..adc6b7fe263 100644 --- a/src/modules/rlm_unpack/rlm_unpack.c +++ b/src/modules/rlm_unpack/rlm_unpack.c @@ -144,14 +144,16 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_unpack; -module_t rlm_unpack = { - .magic = RLM_MODULE_INIT, - .name = "unpack", - .type = RLM_TYPE_THREAD_SAFE, - .bootstrap = mod_bootstrap +extern module_rlm_t rlm_unpack; +module_rlm_t rlm_unpack = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "unpack", + .type = MODULE_TYPE_THREAD_SAFE, + .bootstrap = mod_bootstrap + } }; diff --git a/src/modules/rlm_utf8/rlm_utf8.c b/src/modules/rlm_utf8/rlm_utf8.c index 9538e0381f4..87056ca4b8d 100644 --- a/src/modules/rlm_utf8/rlm_utf8.c +++ b/src/modules/rlm_utf8/rlm_utf8.c @@ -53,15 +53,17 @@ static unlang_action_t CC_HINT(nonnull) mod_utf8_clean(rlm_rcode_t *p_result, UN * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_utf8; -module_t rlm_utf8 = { - .magic = RLM_MODULE_INIT, - .name = "utf8", - .type = RLM_TYPE_THREAD_SAFE, +extern module_rlm_t rlm_utf8; +module_rlm_t rlm_utf8 = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "utf8", + .type = MODULE_TYPE_THREAD_SAFE + }, .methods = { [MOD_AUTHORIZE] = mod_utf8_clean, [MOD_PREACCT] = mod_utf8_clean, diff --git a/src/modules/rlm_wimax/rlm_wimax.c b/src/modules/rlm_wimax/rlm_wimax.c index dd5197772b4..5e4feb8d285 100644 --- a/src/modules/rlm_wimax/rlm_wimax.c +++ b/src/modules/rlm_wimax/rlm_wimax.c @@ -449,17 +449,19 @@ static unlang_action_t CC_HINT(nonnull) mod_post_auth(rlm_rcode_t *p_result, mod * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_wimax; -module_t rlm_wimax = { - .magic = RLM_MODULE_INIT, - .name = "wimax", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_wimax_t), - .config = module_config, +extern module_rlm_t rlm_wimax; +module_rlm_t rlm_wimax = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "wimax", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_wimax_t), + .config = module_config, + }, .dict = &dict_radius, .methods = { [MOD_AUTHORIZE] = mod_authorize, diff --git a/src/modules/rlm_winbind/rlm_winbind.c b/src/modules/rlm_winbind/rlm_winbind.c index f86979d38ac..104cfbb76d5 100644 --- a/src/modules/rlm_winbind/rlm_winbind.c +++ b/src/modules/rlm_winbind/rlm_winbind.c @@ -550,19 +550,21 @@ static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_winbind; -module_t rlm_winbind = { - .magic = RLM_MODULE_INIT, - .name = "winbind", - .inst_size = sizeof(rlm_winbind_t), - .config = module_config, - .instantiate = mod_instantiate, - .bootstrap = mod_bootstrap, - .detach = mod_detach, +extern module_rlm_t rlm_winbind; +module_rlm_t rlm_winbind = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "winbind", + .inst_size = sizeof(rlm_winbind_t), + .config = module_config, + .instantiate = mod_instantiate, + .bootstrap = mod_bootstrap, + .detach = mod_detach + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize diff --git a/src/modules/rlm_yubikey/rlm_yubikey.c b/src/modules/rlm_yubikey/rlm_yubikey.c index 5aa567d0421..5b388015307 100644 --- a/src/modules/rlm_yubikey/rlm_yubikey.c +++ b/src/modules/rlm_yubikey/rlm_yubikey.c @@ -450,24 +450,26 @@ static unlang_action_t CC_HINT(nonnull) mod_authenticate(rlm_rcode_t *p_result, * That is, everything else should be 'static'. * * If the module needs to temporarily modify it's instantiation - * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE. + * data, the type should be changed to MODULE_TYPE_THREAD_UNSAFE. * The server will then take care of ensuring that the module * is single-threaded. */ -extern module_t rlm_yubikey; -module_t rlm_yubikey = { - .magic = RLM_MODULE_INIT, - .name = "yubikey", - .type = RLM_TYPE_THREAD_SAFE, - .inst_size = sizeof(rlm_yubikey_t), - .onload = mod_load, - .unload = mod_unload, - .config = module_config, - .bootstrap = mod_bootstrap, - .instantiate = mod_instantiate, +extern module_rlm_t rlm_yubikey; +module_rlm_t rlm_yubikey = { + .common = { + .magic = MODULE_MAGIC_INIT, + .name = "yubikey", + .type = MODULE_TYPE_THREAD_SAFE, + .inst_size = sizeof(rlm_yubikey_t), + .onload = mod_load, + .unload = mod_unload, + .config = module_config, + .bootstrap = mod_bootstrap, + .instantiate = mod_instantiate, #ifdef HAVE_YKCLIENT - .detach = mod_detach, + .detach = mod_detach, #endif + }, .methods = { [MOD_AUTHENTICATE] = mod_authenticate, [MOD_AUTHORIZE] = mod_authorize diff --git a/src/process/arp/base.c b/src/process/arp/base.c index 49782421ec1..f84bf757c8e 100644 --- a/src/process/arp/base.c +++ b/src/process/arp/base.c @@ -242,7 +242,7 @@ static const virtual_server_compile_t compile_list[] = { extern fr_process_module_t process_arp; fr_process_module_t process_arp = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_arp", .inst_size = sizeof(process_arp_t), .process = mod_process, diff --git a/src/process/control/base.c b/src/process/control/base.c index 80e245c58c5..b75181b8086 100644 --- a/src/process/control/base.c +++ b/src/process/control/base.c @@ -51,7 +51,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, UNUSED module_ctx_t co extern fr_process_module_t process_control; fr_process_module_t process_control = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_control", .process = mod_process, .dict = &dict_freeradius, diff --git a/src/process/dhcpv4/base.c b/src/process/dhcpv4/base.c index 56692448f28..9a989e673ff 100644 --- a/src/process/dhcpv4/base.c +++ b/src/process/dhcpv4/base.c @@ -451,7 +451,7 @@ static const virtual_server_compile_t compile_list[] = { extern fr_process_module_t process_dhcpv4; fr_process_module_t process_dhcpv4 = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_dhcpv4", .inst_size = sizeof(process_dhcpv4_t), .process = mod_process, diff --git a/src/process/dhcpv6/base.c b/src/process/dhcpv6/base.c index be83a985b5f..84d3e62daf9 100644 --- a/src/process/dhcpv6/base.c +++ b/src/process/dhcpv6/base.c @@ -1231,7 +1231,7 @@ static fr_process_state_t const process_state[] = { extern fr_process_module_t process_dhcpv6; fr_process_module_t process_dhcpv6 = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_dhcpv6", .config = dhcpv6_process_config, .inst_size = sizeof(process_dhcpv6_t), diff --git a/src/process/dns/base.c b/src/process/dns/base.c index c8f8d14406d..9734bbb9f23 100644 --- a/src/process/dns/base.c +++ b/src/process/dns/base.c @@ -190,7 +190,7 @@ static const virtual_server_compile_t compile_list[] = { extern fr_process_module_t process_dns; fr_process_module_t process_dns = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_dns", .inst_size = sizeof(process_dns_t), .process = mod_process, diff --git a/src/process/eap_aka/base.c b/src/process/eap_aka/base.c index 1a4831bc326..275c128a200 100644 --- a/src/process/eap_aka/base.c +++ b/src/process/eap_aka/base.c @@ -265,7 +265,7 @@ static void mod_unload(void) extern fr_process_module_t process_eap_aka; fr_process_module_t process_eap_aka = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_eap_aka", .onload = mod_load, .unload = mod_unload, diff --git a/src/process/eap_aka_prime/base.c b/src/process/eap_aka_prime/base.c index d80c344c632..30551213240 100644 --- a/src/process/eap_aka_prime/base.c +++ b/src/process/eap_aka_prime/base.c @@ -266,7 +266,7 @@ static void mod_unload(void) extern fr_process_module_t process_eap_aka_prime; fr_process_module_t process_eap_aka_prime = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_eap_aka_prime", .onload = mod_load, .unload = mod_unload, diff --git a/src/process/eap_sim/base.c b/src/process/eap_sim/base.c index d77042d4e31..a05a6c9a93e 100644 --- a/src/process/eap_sim/base.c +++ b/src/process/eap_sim/base.c @@ -253,7 +253,7 @@ static void mod_unload(void) extern fr_process_module_t process_eap_sim; fr_process_module_t process_eap_sim = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_eap_sim", .onload = mod_load, .unload = mod_unload, diff --git a/src/process/radius/base.c b/src/process/radius/base.c index 14cf41b04a3..2cff7ce9196 100644 --- a/src/process/radius/base.c +++ b/src/process/radius/base.c @@ -1125,7 +1125,7 @@ static virtual_server_compile_t const compile_list[] = { extern fr_process_module_t process_radius; fr_process_module_t process_radius = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_radius", .config = config, .inst_size = sizeof(process_radius_t), diff --git a/src/process/tacacs/base.c b/src/process/tacacs/base.c index 68f8371b790..07886e95f6d 100644 --- a/src/process/tacacs/base.c +++ b/src/process/tacacs/base.c @@ -705,7 +705,7 @@ static virtual_server_compile_t compile_list[] = { extern fr_process_module_t process_tacacs; fr_process_module_t process_tacacs = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_tacacs", .config = config, .inst_size = sizeof(process_tacacs_t), diff --git a/src/process/tls/base.c b/src/process/tls/base.c index e47774d57ae..d18b62d0def 100644 --- a/src/process/tls/base.c +++ b/src/process/tls/base.c @@ -181,7 +181,7 @@ static const virtual_server_compile_t compile_list[] = { extern fr_process_module_t process_tls; fr_process_module_t process_tls = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_tls", .inst_size = sizeof(process_tls_t), .process = mod_process, diff --git a/src/process/ttls/base.c b/src/process/ttls/base.c index 6d3863773ce..13e3123afeb 100644 --- a/src/process/ttls/base.c +++ b/src/process/ttls/base.c @@ -819,7 +819,7 @@ static virtual_server_compile_t const compile_list[] = { extern fr_process_module_t process_ttls; fr_process_module_t process_ttls = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_ttls", .config = config, .inst_size = sizeof(process_ttls_t), diff --git a/src/process/vmps/base.c b/src/process/vmps/base.c index dc80e9396b4..c613c73ae84 100644 --- a/src/process/vmps/base.c +++ b/src/process/vmps/base.c @@ -259,7 +259,7 @@ static const virtual_server_compile_t compile_list[] = { extern fr_process_module_t process_vmps; fr_process_module_t process_vmps = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "process_vmps", .inst_size = sizeof(process_vmps_t), diff --git a/src/protocols/ethernet/ethernet.c b/src/protocols/ethernet/ethernet.c index 193b1eefe7e..6bc1bca75d3 100644 --- a/src/protocols/ethernet/ethernet.c +++ b/src/protocols/ethernet/ethernet.c @@ -401,7 +401,7 @@ static int fr_ethernet_set_option(void *proto_ctx, fr_proto_opt_group_t group, i extern fr_proto_lib_t const libfreeradius_ethernet; fr_proto_lib_t const libfreeradius_ethernet = { - .magic = RLM_MODULE_INIT, + .magic = MODULE_MAGIC_INIT, .name = "ethernet", .inst_size = sizeof(fr_ethernet_proto_ctx_t),