return 0;
}
+static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+{
+ proto_radius_t *inst = instance;
+
+ /*
+ * Bootstrap the protocol agnostic IO handler.
+ */
+ inst->io.server_cs = cf_item_to_section(cf_parent(cs));
+
+ /*
+ * We will need this for dynamic clients and connected sockets.
+ */
+ inst->io.dl_inst = dl_instance_find(inst);
+ rad_assert(inst != NULL);
+
+ /*
+ * Find and bootstrap the application IO handler.
+ */
+ inst->io.app_io = (fr_app_io_t const *) inst->io.submodule->module->common;
+
+ inst->io.app_io_instance = inst->io.submodule->data;
+ inst->io.app_io_conf = inst->io.submodule->conf;
+
+ if (inst->io.app_io->bootstrap && (inst->io.app_io->bootstrap(inst->io.app_io_instance,
+ inst->io.app_io_conf) < 0)) {
+ cf_log_err(inst->io.app_io_conf, "Bootstrap failed for \"%s\"", inst->io.app_io->name);
+ return -1;
+ }
+
+ /*
+ * @todo - move these to public APIs
+ */
+ inst->app_io_private = inst->io.app_io->private;
+ rad_assert(inst->app_io_private != NULL);
+
+ /*
+ * Get various information after bootstrapping the
+ * application IO module.
+ */
+ inst->app_io_private->network_get(inst->io.app_io_instance, &inst->io.ipproto, &inst->io.dynamic_clients, &inst->io.networks);
+
+ return 0;
+}
fr_app_io_t proto_radius_master_io = {
.magic = RLM_MODULE_INIT,
.name = "radius_master_io",
.detach = mod_detach,
-// .bootstrap = mod_bootstrap,
+ .bootstrap = mod_bootstrap,
// .instantiate = mod_instantiate,
.default_message_size = 4096,
static CONF_PARSER const proto_radius_config[] = {
{ FR_CONF_OFFSET("type", FR_TYPE_VOID | FR_TYPE_MULTI | FR_TYPE_NOT_EMPTY, proto_radius_t,
type_submodule), .func = type_parse },
- { FR_CONF_OFFSET("transport", FR_TYPE_VOID, proto_radius_t, io_submodule),
+ { FR_CONF_OFFSET("transport", FR_TYPE_VOID, proto_radius_t, io.submodule),
.func = transport_parse },
/*
/*
* No IO module, it's an empty listener.
*/
- if (!inst->io_submodule) return 0;
+ if (!inst->io.submodule) return 0;
/*
- * Bootstrap the protocol agnostic IO handler.
+ * Tell the master handler about the main protocol instance.
*/
- inst->io.server_cs = cf_item_to_section(cf_parent(conf));
inst->io.app = &proto_radius;
inst->io.app_instance = inst;
/*
- * We will need this for dynamic clients and connected sockets.
+ * Bootstrap the master IO handler.
*/
- inst->io.dl_inst = dl_instance_find(inst);
- rad_assert(inst != NULL);
-
- /*
- * Bootstrap the application IO handler.
- */
- inst->io.app_io = (fr_app_io_t const *) inst->io_submodule->module->common;
-
- inst->io.app_io_instance = inst->io_submodule->data;
- inst->io.app_io_conf = inst->io_submodule->conf;
-
- inst->app_io_private = inst->io.app_io->private;
- rad_assert(inst->app_io_private != NULL);
-
- if (inst->io.app_io->bootstrap && (inst->io.app_io->bootstrap(inst->io.app_io_instance,
- inst->io.app_io_conf) < 0)) {
- cf_log_err(inst->io.app_io_conf, "Bootstrap failed for \"%s\"", inst->io.app_io->name);
+ if (proto_radius_master_io.bootstrap(inst, conf) < 0) {
return -1;
}
- /*
- * Get various information after bootstrapping the
- * application IO module.
- */
- inst->app_io_private->network_get(inst->io.app_io_instance, &inst->io.ipproto, &inst->io.dynamic_clients, &inst->io.networks);
-
/*
* Load proto_radius_dynamic_client
*/
CONF_SECTION *server_cs; //!< server CS for this listener
+ dl_instance_t *submodule; //!< As provided by the transport_parse
+ ///< callback. Broken out into the
+ ///< app_io_* fields below for convenience.
+
fr_app_t *app; //!< main protocol handler
void *app_instance; //!< instance data for main protocol handler
fr_io_instance_t io; //!< wrapper for IO abstraction
dl_instance_t const *dl_inst; //!< our dl_inst
- dl_instance_t *io_submodule; //!< As provided by the transport_parse
- ///< callback. Broken out into the
- ///< app_io_* fields below for convenience.
proto_radius_app_io_t *app_io_private; //!< Internal interface for proto_radius.