* Load the module shared library, allocate instance data for it,
* parse the module configuration, and call the modules "bootstrap" method.
*
+ * @param[in] type What type of module we're loading. Determines the prefix
+ * added to the library name. Should be one of:
+ * - DL_MODULE_TYPE_MODULE - Standard backend module.
+ * - DL_MODULE_TYPE_SUBMODULE - Usually a driver for a backend module.
+ * - DL_MODULE_TYPE_PROCESS - Protocol state machine bound to a virtual server.
* @param[in] parent of the module being bootstrapped, if this is a submodule.
* If this is not a submodule parent must be NULL.
* @param[in] cs containing the configuration for this module or submodule.
* and private instance data.
* - NULL on error.
*/
-module_instance_t *module_bootstrap(module_instance_t const *parent, CONF_SECTION *cs)
+module_instance_t *module_bootstrap(dl_module_type_t type, module_instance_t const *parent, CONF_SECTION *cs)
{
char *inst_name = NULL;
module_instance_t *mi;
char const *name1 = cf_section_name1(cs);
+ fr_assert((type == DL_MODULE_TYPE_MODULE) ||
+ (parent && (type == DL_MODULE_TYPE_SUBMODULE)) ||
+ (type == DL_MODULE_TYPE_PROCESS));
+
module_instance_name(NULL, &inst_name, parent, cs);
/*
talloc_set_destructor(mi, _module_instance_free);
if (dl_module_instance(mi, &mi->dl_inst, cs,
- parent ? parent->dl_inst : NULL,
- name1,
- parent ? DL_MODULE_TYPE_SUBMODULE : DL_MODULE_TYPE_MODULE) < 0) {
+ parent ? parent->dl_inst : NULL,
+ name1,
+ type) < 0) {
error:
mi->name = inst_name; /* Assigned purely for debug log output when mi is freed */
talloc_free(mi);
int modules_instantiate(CONF_SECTION *root) CC_HINT(nonnull);
-module_instance_t *module_bootstrap(module_instance_t const *parent, CONF_SECTION *cs) CC_HINT(nonnull(2));
+module_instance_t *module_bootstrap(dl_module_type_t type, module_instance_t const *parent, CONF_SECTION *cs)
+ CC_HINT(nonnull(3));
int modules_rlm_bootstrap(CONF_SECTION *root) CC_HINT(nonnull);
/** @} */
/*
* Load the appropriate driver for our backend
*/
- inst->driver_inst = module_bootstrap(module_by_data(inst), driver_cs);
+ inst->driver_inst = module_bootstrap(DL_MODULE_TYPE_SUBMODULE, module_by_data(inst), driver_cs);
if (!inst->driver_inst) {
cf_log_err(driver_cs, "Failed loading driver");
return -1;
if (!submodule_cs) continue; /* Skipped as we don't have SSL support */
- submodule_inst = module_bootstrap(module_by_data(inst), submodule_cs);
+ submodule_inst = module_bootstrap(DL_MODULE_TYPE_SUBMODULE, module_by_data(inst), submodule_cs);
if (!submodule_inst) return -1;
submodule = (rlm_eap_submodule_t const *)submodule_inst->dl_inst->module->common;