return 0;
}
+int fr_app_process_bootstrap(dl_instance_t **type_submodule, CONF_SECTION *conf, CONF_SECTION *server_cs)
+{
+ int i = 0;
+ CONF_PAIR *cp = NULL;
+
+ /*
+ * Bootstrap the process modules
+ */
+ while ((cp = cf_pair_find_next(conf, cp, "type"))) {
+ char const *value;
+ dl_t const *module = talloc_get_type_abort_const(type_submodule[i]->module, dl_t);
+ fr_app_worker_t const *app_process = (fr_app_worker_t const *)module->common;
+
+ if (app_process->bootstrap && (app_process->bootstrap(type_submodule[i]->data,
+ type_submodule[i]->conf) < 0)) {
+ cf_log_err(conf, "Bootstrap failed for \"%s\"", app_process->name);
+ return -1;
+ }
+
+ value = cf_pair_value(cp);
+
+ /*
+ * Add handlers for the virtual server calls.
+ * This is so that when one virtual server wants
+ * to call another, it just looks up the data
+ * here by packet name, and doesn't need to trawl
+ * through all of the listeners.
+ */
+ if (!cf_data_find(server_cs, fr_io_process_t, value)) {
+ fr_io_process_t *process_p;
+
+ process_p = talloc(server_cs, fr_io_process_t);
+ *process_p = app_process->entry_point;
+
+ (void) cf_data_add(server_cs, process_p, value, NULL);
+ }
+
+ i++;
+ }
+
+ return 0;
+}
+
fr_app_io_t fr_master_app_io = {
.magic = RLM_MODULE_INIT,
fr_trie_t *fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny);
int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *io, fr_schedule_t *sc,
size_t default_message_size, size_t num_messages) CC_HINT(nonnull);
+int fr_app_process_bootstrap(dl_instance_t **type_submodule, CONF_SECTION *conf, CONF_SECTION *server_cs);
#ifdef __cplusplus
}
static int mod_bootstrap(void *instance, CONF_SECTION *conf)
{
proto_control_t *inst = talloc_get_type_abort(instance, proto_control_t);
- size_t i = 0;
- CONF_PAIR *cp = NULL;
/*
* Ensure that the server CONF_SECTION is always set.
inst->io.server_cs = cf_item_to_section(cf_parent(conf));
/*
- * Bootstrap the process modules
+ * Bootstrap the app_process modules.
*/
- while ((cp = cf_pair_find_next(conf, cp, "type"))) {
- char const *value;
- dl_t const *module = talloc_get_type_abort_const(inst->type_submodule[i]->module, dl_t);
- fr_app_worker_t const *app_process = (fr_app_worker_t const *)module->common;
-
- if (app_process->bootstrap && (app_process->bootstrap(inst->type_submodule[i]->data,
- inst->type_submodule[i]->conf) < 0)) {
- cf_log_err(conf, "Bootstrap failed for \"%s\"", app_process->name);
- return -1;
- }
-
- value = cf_pair_value(cp);
-
- /*
- * Add handlers for the virtual server calls.
- * This is so that when one virtual server wants
- * to call another, it just looks up the data
- * here by packet name, and doesn't need to troll
- * through all of the listeners.
- */
- if (!cf_data_find(inst->io.server_cs, fr_io_process_t, value)) {
- fr_io_process_t *process_p;
-
- rad_assert(inst->io.server_cs); /* Ensure we don't leak memory */
-
- process_p = talloc(inst->io.server_cs, fr_io_process_t);
- *process_p = app_process->entry_point;
-
- (void) cf_data_add(inst->io.server_cs, process_p, value, NULL);
- }
-
- i++;
- }
+ if (fr_app_process_bootstrap(inst->type_submodule, conf, inst->io.server_cs) < 0) return -1;
/*
* No IO module, it's an empty listener.
static int mod_bootstrap(void *instance, CONF_SECTION *conf)
{
proto_dhcpv4_t *inst = talloc_get_type_abort(instance, proto_dhcpv4_t);
- size_t i = 0;
- CONF_PAIR *cp = NULL;
/*
* Ensure that the server CONF_SECTION is always set.
rad_assert(attr_message_type != NULL);
/*
- * Bootstrap the process modules
+ * Bootstrap the app_process modules.
*/
- while ((cp = cf_pair_find_next(conf, cp, "type"))) {
- char const *value;
- dl_t const *module = talloc_get_type_abort_const(inst->type_submodule[i]->module, dl_t);
- fr_app_worker_t const *app_process = (fr_app_worker_t const *)module->common;
-
- if (app_process->bootstrap && (app_process->bootstrap(inst->type_submodule[i]->data,
- inst->type_submodule[i]->conf) < 0)) {
- cf_log_err(conf, "Bootstrap failed for \"%s\"", app_process->name);
- return -1;
- }
-
- value = cf_pair_value(cp);
-
- /*
- * Add handlers for the virtual server calls.
- * This is so that when one virtual server wants
- * to call another, it just looks up the data
- * here by packet name, and doesn't need to troll
- * through all of the listeners.
- */
- if (!cf_data_find(inst->io.server_cs, fr_io_process_t, value)) {
- fr_io_process_t *process_p;
-
- rad_assert(inst->io.server_cs); /* Ensure we don't leak memory */
-
- process_p = talloc(inst->io.server_cs, fr_io_process_t);
- *process_p = app_process->entry_point;
-
- (void) cf_data_add(inst->io.server_cs, process_p, value, NULL);
- }
-
- i++;
- }
+ if (fr_app_process_bootstrap(inst->type_submodule, conf, inst->io.server_cs) < 0) return -1;
/*
* No IO module, it's an empty listener.
static int mod_bootstrap(void *instance, CONF_SECTION *conf)
{
proto_radius_t *inst = talloc_get_type_abort(instance, proto_radius_t);
- size_t i = 0;
- CONF_PAIR *cp = NULL;
/*
* Ensure that the server CONF_SECTION is always set.
inst->io.server_cs = cf_item_to_section(cf_parent(conf));
/*
- * Bootstrap the process modules
+ * Bootstrap the app_process modules.
*/
- while ((cp = cf_pair_find_next(conf, cp, "type"))) {
- char const *value;
- dl_t const *module = talloc_get_type_abort_const(inst->type_submodule[i]->module, dl_t);
- fr_app_worker_t const *app_process = (fr_app_worker_t const *)module->common;
-
- if (app_process->bootstrap && (app_process->bootstrap(inst->type_submodule[i]->data,
- inst->type_submodule[i]->conf) < 0)) {
- cf_log_err(conf, "Bootstrap failed for \"%s\"", app_process->name);
- return -1;
- }
-
- value = cf_pair_value(cp);
-
- /*
- * Add handlers for the virtual server calls.
- * This is so that when one virtual server wants
- * to call another, it just looks up the data
- * here by packet name, and doesn't need to trawl
- * through all of the listeners.
- */
- if (!cf_data_find(inst->io.server_cs, fr_io_process_t, value)) {
- fr_io_process_t *process_p;
-
- rad_assert(inst->io.server_cs); /* Ensure we don't leak memory */
-
- process_p = talloc(inst->io.server_cs, fr_io_process_t);
- *process_p = app_process->entry_point;
-
- (void) cf_data_add(inst->io.server_cs, process_p, value, NULL);
- }
-
- i++;
- }
+ if (fr_app_process_bootstrap(inst->type_submodule, conf, inst->io.server_cs) < 0) return -1;
/*
* No IO module, it's an empty listener.
static int mod_bootstrap(void *instance, CONF_SECTION *conf)
{
proto_vmps_t *inst = talloc_get_type_abort(instance, proto_vmps_t);
- size_t i = 0;
- CONF_PAIR *cp = NULL;
/*
* Ensure that the server CONF_SECTION is always set.
rad_assert(attr_vmps_packet_type != NULL);
/*
- * Bootstrap the process modules
+ * Bootstrap the app_process modules.
*/
- while ((cp = cf_pair_find_next(conf, cp, "type"))) {
- char const *value;
- dl_t const *module = talloc_get_type_abort_const(inst->type_submodule[i]->module, dl_t);
- fr_app_worker_t const *app_process = (fr_app_worker_t const *)module->common;
-
- if (app_process->bootstrap && (app_process->bootstrap(inst->type_submodule[i]->data,
- inst->type_submodule[i]->conf) < 0)) {
- cf_log_err(conf, "Bootstrap failed for \"%s\"", app_process->name);
- return -1;
- }
-
- value = cf_pair_value(cp);
-
- /*
- * Add handlers for the virtual server calls.
- * This is so that when one virtual server wants
- * to call another, it just looks up the data
- * here by packet name, and doesn't need to troll
- * through all of the listeners.
- */
- if (!cf_data_find(inst->io.server_cs, fr_io_process_t, value)) {
- fr_io_process_t *process_p;
-
- rad_assert(inst->io.server_cs); /* Ensure we don't leak memory */
-
- process_p = talloc(inst->io.server_cs, fr_io_process_t);
- *process_p = app_process->entry_point;
-
- (void) cf_data_add(inst->io.server_cs, process_p, value, NULL);
- }
-
- i++;
- }
+ if (fr_app_process_bootstrap(inst->type_submodule, conf, inst->io.server_cs) < 0) return -1;
/*
* No IO module, it's an empty listener.