* - -1 on failure.
*/
static int mod_instantiate(module_inst_ctx_t const *mctx)
-{
- proto_arp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_arp_t);
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- return 0;
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
{
proto_arp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_arp_t);
CONF_SECTION *conf = mctx->mi->conf;
inst->server_cs = cf_item_to_section(cf_parent(conf));
inst->cs = conf;
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
return 0;
}
.inst_size = sizeof(proto_arp_t),
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_arp,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_arp_ethernet_t *inst = talloc_get_type_abort(mctx->mi->data, proto_arp_ethernet_t);
return 0;
}
-
fr_app_io_t proto_arp_ethernet = {
.common = {
.magic = MODULE_MAGIC_INIT,
.config = arp_listen_config,
.inst_size = sizeof(proto_arp_ethernet_t),
.thread_inst_size = sizeof(proto_arp_ethernet_thread_t),
- .bootstrap = mod_bootstrap,
+ .bootstrap = mod_instantiate
},
.default_message_size = FR_ARP_PACKET_SIZE,
inst->max_packet_size, inst->num_messages);
}
-/** Instantiate the application
- *
- * Instantiate I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_instantiate(module_inst_ctx_t const *mctx)
-{
- proto_bfd_t *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_t);
-
- /*
- * No IO module, it's an empty listener.
- */
- if (!inst->io.submodule) return 0;
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
/** Bootstrap the application
*
* Bootstrap I/O and type submodules.
* - 0 on success.
* - -1 on failure.
*/
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_bfd_t *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_t);
CONF_SECTION *server;
}
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
+ */
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
static int mod_load(void)
.inst_size = sizeof(proto_bfd_t),
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_bfd,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_bfd_udp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_udp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = udp_listen_config,
.inst_size = sizeof(proto_bfd_udp_t),
.thread_inst_size = sizeof(proto_bfd_udp_thread_t),
- .bootstrap = mod_bootstrap
+ .instantiate = mod_instantiate
},
.default_message_size = FR_BFD_HEADER_LENGTH + 64, /* enough for some auth packets */
.track_duplicates = false,
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_control_t *inst = talloc_get_type_abort(mctx->mi->data, proto_control_t);
-
- fr_assert(inst->io.submodule != NULL);
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_control_t *inst = talloc_get_type_abort(mctx->mi->data, proto_control_t);
CONF_SECTION *conf = mctx->mi->conf;
/*
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
+ */
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
fr_app_t proto_control = {
.name = "control",
.config = proto_control_config,
.inst_size = sizeof(proto_control_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.open = mod_open,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_control_unix_t *inst = talloc_get_type_abort(mctx->mi->data, proto_control_unix_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = unix_listen_config,
.inst_size = sizeof(proto_control_unix_t),
.thread_inst_size = sizeof(proto_control_unix_thread_t),
- .bootstrap = mod_bootstrap,
+ .instantiate = mod_instantiate
},
.default_message_size = 4096,
FILE *fp;
bool done;
+ /*
+ * The listener is inside of a virtual server.
+ */
+ inst->server_cs = cf_item_to_section(cf_parent(conf));
+ inst->cs = conf;
+ inst->self = &proto_cron;
+
+ virtual_server_dict_set(inst->server_cs, inst->dict, false);
+
FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
return 0;
}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @param[in] instance Ctx data for this application.
- * @param[in] conf Listen section parsed to give us instance.
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(void *instance, CONF_SECTION *conf)
-{
- proto_cron_t *inst = talloc_get_type_abort(instance, proto_cron_t);
-
- /*
- * The listener is inside of a virtual server.
- */
- inst->server_cs = cf_item_to_section(cf_parent(conf));
- inst->cs = conf;
- inst->self = &proto_cron;
-
- virtual_server_dict_set(inst->server_cs, inst->dict, false);
-
- return 0;
-}
-
fr_app_t proto_cron = {
.magic = RLM_MODULE_INIT,
.name = "cron",
.config = proto_cron_config,
.inst_size = sizeof(proto_cron_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate,
.open = mod_open,
};
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_cron_t *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_t);
-
- fr_assert(inst->io.submodule);
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_cron_t *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_t);
CONF_SECTION *conf = mctx->mi->conf;
/*
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
-}
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
+ */
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
+}
fr_app_t proto_cron = {
.common = {
.name = "cron",
.config = proto_cron_config,
.inst_size = sizeof(proto_cron_t),
-
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.open = mod_open,
return thread->name;
}
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_cron_crontab_t *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_crontab_t);
-
- inst->parent = talloc_get_type_abort(mctx->mi->parent->data, proto_cron_t);
- inst->cs = mctx->mi->conf;
-
- return 0;
-}
-
static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
{
proto_cron_crontab_t const *inst = talloc_get_type_abort_const(li->app_io_instance, proto_cron_crontab_t);
return inst->client;
}
-
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_cron_crontab_t *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_crontab_t);
FILE *fp;
bool done = false;
+ inst->parent = talloc_get_type_abort(mctx->mi->parent->data, proto_cron_t);
+ inst->cs = mctx->mi->conf;
+
fr_pair_list_init(&inst->pair_list);
inst->client = client = talloc_zero(inst, fr_client_t);
if (!inst->client) return 0;
.config = crontab_listen_config,
.inst_size = sizeof(proto_cron_crontab_t),
.thread_inst_size = sizeof(proto_cron_crontab_thread_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.default_message_size = 4096,
#include "lib/server/module.h"
extern fr_app_t proto_detail;
+
static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
+static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
#if 0
/*
{ FR_CONF_OFFSET_TYPE_FLAGS("type", FR_TYPE_VOID, CONF_FLAG_NOT_EMPTY | CONF_FLAG_REQUIRED, proto_detail_t,
type), .func = type_parse },
{ FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_detail_t, io_submodule),
- .func = virtual_sever_listen_transport_parse, .dflt = "file" },
+ .func = transport_parse, .dflt = "file" },
/*
* Add this as a synonym so normal humans can understand it.
return 0;
}
+static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
+{
+ proto_detail_t *inst = talloc_get_type_abort(parent, proto_detail_t);
+
+ if (unlikely(virtual_sever_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
+ return -1;
+ }
+
+ /*
+ * If we're not loading the work submodule directly, then try to load it here.
+ */
+ if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
+ CONF_SECTION *transport_cs;
+ module_instance_t *parent_inst;
+
+ inst->work_submodule = NULL;
+
+ transport_cs = cf_section_find(inst->cs, "work", NULL);
+ parent_inst = cf_data_value(cf_data_find(inst->cs, module_instance_t, "proto_detail"));
+ fr_assert(parent_inst);
+
+ if (!transport_cs) {
+ transport_cs = cf_section_dup(inst->cs, inst->cs, inst->app_io_conf,
+ "work", NULL, false);
+ if (!transport_cs) {
+ cf_log_err(inst->cs, "Failed to create configuration for worker");
+ return -1;
+ }
+ }
+
+ /*
+ * This *should* get bootstrapped at some point after this module
+ * as it's inserted into the three the caller is iterating over.
+ *
+ * We might want to revisit this, and use a linked list of modules
+ * to iterate over instead of a tree, so we can add this to the end
+ * of that list.
+ */
+ inst->work_submodule = module_instance_alloc(parent_inst->ml, parent_inst, DL_MODULE_TYPE_SUBMODULE,
+ "work", module_instance_name_from_conf(transport_cs), 0);
+ if (inst->work_submodule == NULL) {
+ error:
+ cf_log_perr(inst->cs, "Failed to load proto_detail_work");
+ TALLOC_FREE(inst->work_submodule);
+ return -1;
+ }
+
+ if (module_instance_conf_parse(inst->work_submodule, transport_cs) < 0) goto error;
+
+ inst->work_io = (fr_app_io_t const *) inst->work_submodule->exported;
+ inst->work_io_instance = inst->work_submodule->data;
+ inst->work_io_conf = inst->work_submodule->conf;
+ }
+
+ return 0;
+}
+
/** Decode the packet, and set the request->process function
*
*/
proto_detail_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_t);
CONF_SECTION *conf = mctx->mi->conf;
- /*
- * Instantiate the I/O module. But DON'T instantiate the
- * work submodule. We leave that until later.
- */
- if (inst->app_io->common.instantiate &&
- (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
- cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
- return -1;
- }
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size) inst->max_packet_size = inst->app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 2;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 2);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
-
- if (!inst->priority) inst->priority = PRIORITY_NORMAL;
-
- /*
- * If the IO is "file" and not the worker, instantiate the worker now.
- */
- if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
- if (inst->work_io->common.instantiate &&
- (inst->work_io->common.instantiate(MODULE_INST_CTX(inst->work_submodule)) < 0)) {
- cf_log_err(inst->work_io_conf, "Instantiation failed for \"%s\"", inst->work_io->common.name);
- return -1;
- }
- }
-
- return 0;
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_detail_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_t);
- CONF_SECTION *conf = mctx->mi->conf;
-
/*
* The listener is inside of a virtual server.
*/
inst->app_io_conf = inst->io_submodule->conf;
/*
- * If we're not loading the work submodule directly, then try to load it here.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
- CONF_SECTION *transport_cs;
- module_instance_t *parent_inst;
-
- inst->work_submodule = NULL;
-
- transport_cs = cf_section_find(inst->cs, "work", NULL);
- parent_inst = cf_data_value(cf_data_find(inst->cs, module_instance_t, "proto_detail"));
- fr_assert(parent_inst);
+ if (!inst->max_packet_size) inst->max_packet_size = inst->app_io->default_message_size;
- if (!transport_cs) {
- transport_cs = cf_section_dup(inst->cs, inst->cs, inst->app_io_conf,
- "work", NULL, false);
- if (!transport_cs) {
- cf_log_err(inst->cs, "Failed to create configuration for worker");
- return -1;
- }
- }
+ if (!inst->num_messages) inst->num_messages = 2;
- /*
- * This *should* get bootstrapped at some point after this module
- * as it's inserted into the three the caller is iterating over.
- *
- * We might want to revisit this, and use a linked list of modules
- * to iterate over instead of a tree, so we can add this to the end
- * of that list.
- */
- inst->work_submodule = module_instance_alloc(parent_inst->ml, parent_inst, DL_MODULE_TYPE_SUBMODULE,
- "work", module_instance_name_from_conf(transport_cs), 0);
- if (inst->work_submodule == NULL) {
- error:
- cf_log_perr(inst->cs, "Failed to load proto_detail_work");
- TALLOC_FREE(inst->work_submodule);
- return -1;
- }
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 2);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
- if (module_instance_conf_parse(inst->work_submodule, transport_cs) < 0) goto error;
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
- inst->work_io = (fr_app_io_t const *) inst->work_submodule->exported;
- inst->work_io_instance = inst->work_submodule->data;
- inst->work_io_conf = inst->work_submodule->conf;
- }
+ if (!inst->priority) inst->priority = PRIORITY_NORMAL;
return 0;
}
-
fr_app_t proto_detail = {
.common = {
.magic = MODULE_MAGIC_INIT,
.config = proto_detail_config,
.inst_size = sizeof(proto_detail_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate,
},
.open = mod_open,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static fr_rb_tree_t *detail_file_tree = NULL;
+static pthread_mutex_t detail_file_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/** Compare two thread instances based on node pointer
+ *
+ * @param[in] one First thread specific xlat expansion instance.
+ * @param[in] two Second thread specific xlat expansion instance.
+ * @return CMP(one, two)
+ */
+static int8_t _detail_file_cmp(void const *one, void const *two)
+{
+ proto_detail_file_t const *a = one, *b = two;
+
+ return CMP(strcmp(a->filename, b->filename), 0);
+}
+
+/*
+ * Check for multiple readers on the same set of files.
+ */
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_detail_file_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_file_t);
CONF_SECTION *conf = mctx->mi->conf;
+
module_instance_t const *mi;
char *p;
inst->parent->exit_when_done = false;
}
- return 0;
-}
-
-static fr_rb_tree_t *detail_file_tree = NULL;
-static pthread_mutex_t detail_file_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/** Compare two thread instances based on node pointer
- *
- * @param[in] one First thread specific xlat expansion instance.
- * @param[in] two Second thread specific xlat expansion instance.
- * @return CMP(one, two)
- */
-static int8_t _detail_file_cmp(void const *one, void const *two)
-{
- proto_detail_file_t const *a = one, *b = two;
-
- return CMP(strcmp(a->filename, b->filename), 0);
-}
-
-/*
- * Check for multiple readers on the same set of files.
- */
-static int mod_instantiate(module_inst_ctx_t const *mctx)
-{
- proto_detail_file_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_file_t);
- CONF_SECTION *conf = mctx->mi->conf;
-
pthread_mutex_lock(&detail_file_mutex);
if (!detail_file_tree) {
detail_file_tree = fr_rb_inline_talloc_alloc(conf, proto_detail_file_t, filename_node, _detail_file_cmp, NULL);
.config = file_listen_config,
.inst_size = sizeof(proto_detail_file_t),
.thread_inst_size = sizeof(proto_detail_file_thread_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate,
},
.default_message_size = 65536,
{
proto_detail_work_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_work_t);
fr_client_t *client;
-
- client = inst->client = talloc_zero(inst, fr_client_t);
- if (!inst->client) return 0;
-
- client->ipaddr.af = AF_INET;
- client->ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
- client->src_ipaddr = client->ipaddr;
-
- client->longname = client->shortname = client->secret = inst->filename;
- client->nas_type = talloc_strdup(client, "other");
-
- return 0;
-}
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_detail_work_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_work_t);
CONF_SECTION *cs = mctx->mi->conf;
module_instance_t const *mi = mctx->mi;
FR_INTEGER_BOUND_CHECK("limit.max_outstanding", inst->max_outstanding, >=, 1);
+ client = inst->client = talloc_zero(inst, fr_client_t);
+ if (!inst->client) return 0;
+
+ client->ipaddr.af = AF_INET;
+ client->ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
+ client->src_ipaddr = client->ipaddr;
+
+ client->longname = client->shortname = client->secret = inst->filename;
+ client->nas_type = talloc_strdup(client, "other");
+
return 0;
}
-
/** Private interface for use by proto_detail_file
*
*/
.config = file_listen_config,
.inst_size = sizeof(proto_detail_work_t),
.thread_inst_size = sizeof(proto_detail_work_thread_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.default_message_size = 65536,
proto_dhcpv4_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv4_t);
/*
- * No IO module, it's an empty listener.
+ * Ensure that the server CONF_SECTION is always set.
*/
- if (!inst->io.submodule) return 0;
+ inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
+
+ fr_assert(dict_dhcpv4 != NULL);
+ fr_assert(attr_message_type != NULL);
/*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
+ * No IO module, it's an empty listener.
*/
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+ if (!inst->io.submodule) return 0;
/*
- * Instantiate the master io submodule
+ * Tell the master handler about the main protocol instance.
*/
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_dhcpv4_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv4_t);
+ inst->io.app = &proto_dhcpv4;
+ inst->io.app_instance = inst;
/*
- * Ensure that the server CONF_SECTION is always set.
+ * We will need this for dynamic clients and connected sockets.
*/
- inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
-
- fr_assert(dict_dhcpv4 != NULL);
- fr_assert(attr_message_type != NULL);
+ inst->io.mi = mctx->mi;
/*
- * No IO module, it's an empty listener.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- if (!inst->io.submodule) return 0;
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
/*
* These timers are usually protocol specific.
FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, <=, fr_time_delta_from_sec(30));
FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, >, fr_time_delta_from_sec(0));
- /*
- * Tell the master handler about the main protocol instance.
- */
- inst->io.app = &proto_dhcpv4;
- inst->io.app_instance = inst;
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
- /*
- * We will need this for dynamic clients and connected sockets.
- */
- inst->io.mi = mctx->mi;
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
/*
- * Bootstrap the master IO handler.
+ * Instantiate the master io submodule
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
static int mod_load(void)
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_dhcpv4,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_dhcpv4_udp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv4_udp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = udp_listen_config,
.inst_size = sizeof(proto_dhcpv4_udp_t),
.thread_inst_size = sizeof(proto_dhcpv4_udp_thread_t),
- .bootstrap = mod_bootstrap,
+ .instantiate = mod_instantiate,
},
.default_message_size = 4096,
.track_duplicates = true,
{
proto_dhcpv6_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_t);
- /*
- * No IO module, it's an empty listener.
- */
- if (!inst->io.submodule) return 0;
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_dhcpv6_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_t);
-
/*
* Ensure that the server CONF_SECTION is always set.
*/
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
+ */
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
static int mod_load(void)
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_dhcpv6,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_dhcpv6_udp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_udp_t);
size_t num;
.config = udp_listen_config,
.inst_size = sizeof(proto_dhcpv6_udp_t),
.thread_inst_size = sizeof(proto_dhcpv6_udp_thread_t),
- .bootstrap = mod_bootstrap
+ .instantiate = mod_instantiate
},
.default_message_size = 4096,
.track_duplicates = true,
{
proto_dns_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dns_t);
- /*
- * No IO module, it's an empty listener.
- */
- if (!inst->io.submodule) return 0;
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 64);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_dns_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dns_t);
-
/*
* Ensure that the server CONF_SECTION is always set.
*/
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 64);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
+ */
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
static int mod_load(void)
.onload = mod_load,
.unload = mod_unload,
-
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_dns,
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_dns_udp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_dns_udp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = udp_listen_config,
.inst_size = sizeof(proto_dns_udp_t),
.thread_inst_size = sizeof(proto_dns_udp_thread_t),
- .bootstrap = mod_bootstrap
+ .instantiate = mod_instantiate
},
.default_message_size = 576,
.track_duplicates = false,
}
};
- /*
- * Instantiate the I/O module.
- */
- if (inst->app_io->common.instantiate &&
- (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
- cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
+ inst->server_cs = cf_item_to_section(cf_parent(conf));
+ inst->cs = conf;
+ inst->self = &proto_ldap_sync;
+
+ if (!inst->io_submodule) {
+ cf_log_err(conf, "Virtual server for LDAP sync requires a 'transport' configuration");
return -1;
}
+ /*
+ * Bootstrap the I/O module
+ */
+ inst->app_io = (fr_app_io_t const *) inst->io_submodule->exported;
+ inst->app_io_instance = inst->io_submodule->data;
+ inst->app_io_conf = inst->io_submodule->conf;
+
/*
* These configuration items are not printed by default,
* because normal people shouldn't be touching them.
return 0;
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_ldap_sync_t *inst = talloc_get_type_abort(mctx->mi->data, proto_ldap_sync_t);
- CONF_SECTION *conf = mctx->mi->conf;
-
- inst->server_cs = cf_item_to_section(cf_parent(conf));
- inst->cs = conf;
- inst->self = &proto_ldap_sync;
-
- if (!inst->io_submodule) {
- cf_log_err(conf, "Virtual server for LDAP sync requires a 'transport' configuration");
- return -1;
- }
-
- /*
- * Bootstrap the I/O module
- */
- inst->app_io = (fr_app_io_t const *) inst->io_submodule->exported;
- inst->app_io_instance = inst->io_submodule->data;
- inst->app_io_conf = inst->io_submodule->conf;
-
- return 0;
-}
-
fr_app_t proto_ldap_sync = {
.common = {
.magic = MODULE_MAGIC_INIT,
.name = "ldap_sync",
.config = proto_ldap_sync_config,
.inst_size = sizeof(proto_ldap_sync_t),
-
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
*/
fr_assert(inst->server);
+ inst->parent = talloc_get_type_abort(mctx->mi->parent->data, proto_ldap_sync_t);
+ inst->cs = conf;
+
+ if (inst->recv_buff_is_set) {
+ FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
+ FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
+ }
+
server = inst->server;
inst->handle_config.server = talloc_strdup(inst, "");
return 0;
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_ldap_sync_ldap_t *inst = talloc_get_type_abort(mctx->mi->data, proto_ldap_sync_ldap_t);
- CONF_SECTION *conf = mctx->mi->conf;
- module_instance_t const *mi = mctx->mi;
-
- inst->parent = talloc_get_type_abort(mi->parent->data, proto_ldap_sync_t);
- inst->cs = conf;
-
- if (inst->recv_buff_is_set) {
- FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
- FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
- }
-
- return 0;
-}
-
fr_app_io_t proto_ldap_sync_child = {
.common = {
.magic = MODULE_MAGIC_INIT,
.config = proto_ldap_sync_ldap_config,
.inst_size = sizeof(proto_ldap_sync_ldap_t),
.thread_inst_size = sizeof(proto_ldap_sync_ldap_thread_t),
-
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_load_t *inst = talloc_get_type_abort(mctx->mi->data, proto_load_t);
-
- fr_assert(inst->io.submodule);
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_load_t *inst = talloc_get_type_abort(mctx->mi->data, proto_load_t);
CONF_SECTION *conf = mctx->mi->conf;
/*
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
-}
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
+ */
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
+}
fr_app_t proto_load = {
.common = {
.config = proto_load_config,
.inst_size = sizeof(proto_load_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.open = mod_open,
return thread->name;
}
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_load_step_t *inst = talloc_get_type_abort(mctx->mi->data, proto_load_step_t);
- CONF_SECTION *conf = mctx->mi->conf;
- module_instance_t const *mi = mctx->mi;
-
- inst->parent = talloc_get_type_abort(mi->parent->data, proto_load_t);
- inst->cs = conf;
-
- FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, >=, 10);
- FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, <, 400000);
-
- FR_INTEGER_BOUND_CHECK("step", inst->load.step, >=, 1);
- FR_INTEGER_BOUND_CHECK("step", inst->load.step, <, 100000);
-
- if (inst->load.max_pps > 0) FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, >, inst->load.start_pps);
- FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, <, 100000);
-
- FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, >=, fr_time_delta_from_sec(1));
- FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, <, fr_time_delta_from_sec(10000));
-
-
- FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, >=, 1);
- FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, <, 1000);
-
- FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, >=, 1);
- FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, <, 100000);
-
- return 0;
-}
-
-static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
-{
- proto_load_step_t const *inst = talloc_get_type_abort_const(li->app_io_instance, proto_load_step_t);
-
- return inst->client;
-}
-
-
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_load_step_t *inst = talloc_get_type_abort(mctx->mi->data, proto_load_step_t);
CONF_SECTION *conf = mctx->mi->conf;
fr_client_t *client;
fr_pair_t *vp;
+ module_instance_t const *mi = mctx->mi;
fr_pair_list_init(&inst->pair_list);
inst->client = client = talloc_zero(inst, fr_client_t);
vp = fr_pair_find_by_da(&inst->pair_list, NULL, inst->parent->attr_packet_type);
if (vp) inst->code = vp->vp_uint32;
+ inst->parent = talloc_get_type_abort(mi->parent->data, proto_load_t);
+ inst->cs = conf;
+
+ FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, >=, 10);
+ FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, <, 400000);
+
+ FR_INTEGER_BOUND_CHECK("step", inst->load.step, >=, 1);
+ FR_INTEGER_BOUND_CHECK("step", inst->load.step, <, 100000);
+
+ if (inst->load.max_pps > 0) FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, >, inst->load.start_pps);
+ FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, <, 100000);
+
+ FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, >=, fr_time_delta_from_sec(1));
+ FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, <, fr_time_delta_from_sec(10000));
+
+
+ FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, >=, 1);
+ FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, <, 1000);
+
+ FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, >=, 1);
+ FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, <, 100000);
+
return 0;
}
+static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
+{
+ proto_load_step_t const *inst = talloc_get_type_abort_const(li->app_io_instance, proto_load_step_t);
+
+ return inst->client;
+}
+
fr_app_io_t proto_load_step = {
.common = {
.magic = MODULE_MAGIC_INIT,
.config = load_listen_config,
.inst_size = sizeof(proto_load_step_t),
.thread_inst_size = sizeof(proto_load_step_thread_t),
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.default_message_size = 4096,
{
proto_radius_t *inst = talloc_get_type_abort(instance, proto_radius_t);
- inst->io.app = &proto_radius;
- inst->io.app_instance = instance;
-
/*
* io.app_io should already be set
*/
*/
if (!inst->io.submodule) return 0;
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_radius_t *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_t);
-
- /*
- * Ensure that the server CONF_SECTION is always set.
- */
- inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
-
- /*
- * No IO module, it's an empty listener.
- */
- if (!inst->io.submodule) return 0;
-
/*
* These timers are usually protocol specific.
*/
}
#endif
+ /*
+ * Ensure that the server CONF_SECTION is always set.
+ */
+ inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
+
+ /*
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
+ */
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
/*
* Tell the master handler about the main protocol instance.
*/
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * Instantiate the master io submodule
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
/** Get the authentication vector.
.inst_size = sizeof(proto_radius_t),
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_radius,
return thread->name;
}
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_radius_tcp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_tcp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = tcp_listen_config,
.inst_size = sizeof(proto_radius_tcp_t),
.thread_inst_size = sizeof(proto_radius_tcp_thread_t),
- .bootstrap = mod_bootstrap,
+ .instantiate = mod_instantiate,
},
.default_message_size = 4096,
bool dynamic_clients; //!< whether we have dynamic clients
bool dedup_authenticator; //!< dedup using the request authenticator
- fr_client_list_t *clients; //!< local clients
+ fr_client_list_t *clients; //!< local clients
fr_trie_t *trie; //!< for parsed networks
fr_ipaddr_t *allow; //!< allowed networks for dynamic clients
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_radius_udp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_udp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = udp_listen_config,
.inst_size = sizeof(proto_radius_udp_t),
.thread_inst_size = sizeof(proto_radius_udp_thread_t),
- .bootstrap = mod_bootstrap
+ .instantiate = mod_instantiate
},
.default_message_size = 4096,
.track_duplicates = true,
{
proto_tacacs_t *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_t);
- /*
- * No IO module, it's an empty listener.
- */
- if (!inst->io.submodule) return 0;
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_tacacs_t *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_t);
-
/*
* Ensure that the server CONF_SECTION is always set.
*/
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
+ */
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
static int mod_load(void)
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_tacacs,
return thread->name;
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_tacacs_tcp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_tcp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = tcp_listen_config,
.inst_size = sizeof(proto_tacacs_tcp_t),
.thread_inst_size = sizeof(proto_tacacs_tcp_thread_t),
- .bootstrap = mod_bootstrap,
+ .instantiate = mod_instantiate,
},
.default_message_size = 4096,
.track_duplicates = false,
static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_vmps_t *inst = talloc_get_type_abort(mctx->mi->data, proto_vmps_t);
-
- /*
- * No IO module, it's an empty listener.
- */
- if (!inst->io.submodule) return 0;
-
- /*
- * These configuration items are not printed by default,
- * because normal people shouldn't be touching them.
- */
- if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
- if (!inst->num_messages) inst->num_messages = 256;
-
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
- FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
- FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
- /*
- * Instantiate the master io submodule
- */
- return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- * - 0 on success.
- * - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
- proto_vmps_t *inst = talloc_get_type_abort(mctx->mi->data, proto_vmps_t);
CONF_SECTION *conf = mctx->mi->conf;
/*
inst->io.mi = mctx->mi;
/*
- * Bootstrap the master IO handler.
+ * These configuration items are not printed by default,
+ * because normal people shouldn't be touching them.
*/
- return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+ if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+ if (!inst->num_messages) inst->num_messages = 256;
+
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+ FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+ FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+ /*
+ * Instantiate the master io submodule
+ */
+ return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
}
static int mod_load(void)
.onload = mod_load,
.unload = mod_unload,
- .bootstrap = mod_bootstrap,
.instantiate = mod_instantiate
},
.dict = &dict_vmps,
return (a->opcode < b->opcode) - (a->opcode > b->opcode);
}
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
{
proto_vmps_udp_t *inst = talloc_get_type_abort(mctx->mi->data, proto_vmps_udp_t);
CONF_SECTION *conf = mctx->mi->conf;
.config = udp_listen_config,
.inst_size = sizeof(proto_vmps_udp_t),
.thread_inst_size = sizeof(proto_vmps_udp_thread_t),
- .bootstrap = mod_bootstrap,
+ .instantiate = mod_instantiate,
},
.default_message_size = 4096,
.track_duplicates = true,