]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use transport parsing callback
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 7 May 2024 04:17:32 +0000 (22:17 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 9 May 2024 17:27:18 +0000 (11:27 -0600)
18 files changed:
src/lib/io/master.c
src/lib/io/master.h
src/listen/arp/proto_arp.c
src/listen/arp/proto_arp.h
src/listen/bfd/proto_bfd.c
src/listen/control/proto_control.c
src/listen/cron/proto_cron.c
src/listen/detail/proto_detail.c
src/listen/detail/proto_detail.h
src/listen/dhcpv4/proto_dhcpv4.c
src/listen/dhcpv6/proto_dhcpv6.c
src/listen/dns/proto_dns.c
src/listen/ldap_sync/proto_ldap_sync.c
src/listen/ldap_sync/proto_ldap_sync.h
src/listen/load/proto_load.c
src/listen/radius/proto_radius.c
src/listen/tacacs/proto_tacacs.c
src/listen/vmps/proto_vmps.c

index df78db39dc9e6a28a002cf2e1d9754a8850e09dd..08e9fba44e4bcab01f96400e941fc47bda26b9da 100644 (file)
@@ -2499,7 +2499,7 @@ static ssize_t mod_write(fr_listen_t *li, void *packet_ctx, fr_time_t request_ti
         */
        if (radclient->use_connected && !inst->app_io->connection_set) {
                DEBUG("proto_%s - cannot use connected sockets as underlying 'transport = %s' does not support it.",
-                     inst->app_io->common.name, inst->transport);
+                     inst->app_io->common.name, inst->submodule->dl_inst->module->common->name);
                goto error;
        }
 
@@ -2633,10 +2633,10 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        /*
         *      Find and bootstrap the application IO handler.
         */
-       inst->app_io = (fr_app_io_t const *) inst->submodule->module->common;
+       inst->app_io = (fr_app_io_t const *) inst->submodule->dl_inst->module->common;
 
-       inst->app_io_conf = inst->submodule->conf;
-       inst->app_io_instance = inst->submodule->data;
+       inst->app_io_conf = inst->submodule->dl_inst->conf;
+       inst->app_io_instance = inst->submodule->dl_inst->data;
 
        /*
         *      If we're not tracking duplicates then we don't need a
@@ -2656,7 +2656,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
                }
        }
 
-       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->submodule)) < 0)) {
+       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->submodule->dl_inst)) < 0)) {
                cf_log_err(inst->app_io_conf, "Bootstrap failed for proto_%s", inst->app_io->common.name);
                return -1;
        }
@@ -2723,7 +2723,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        fr_assert(inst->app_io != NULL);
 
        if (inst->app_io->common.instantiate &&
-           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->submodule)) < 0)) {
+           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->submodule->dl_inst)) < 0)) {
                cf_log_err(conf, "Instantiation failed for \"proto_%s\"", inst->app_io->common.name);
                return -1;
        }
index 43a83604ab6bd6ad442dfee5f1c0194dada07465..ad0cd325d34377471adf328331ff445140f51215 100644 (file)
@@ -85,7 +85,7 @@ typedef struct {
 
        CONF_SECTION                    *server_cs;                     //!< server CS for this listener
 
-       dl_module_inst_t                *submodule;                     //!< As provided by the transport_parse
+       module_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
@@ -96,8 +96,6 @@ typedef struct {
        CONF_SECTION                    *app_io_conf;                   //!< Easy access to the app_io's config section.
 
        int                             ipproto;                        //!< IP proto by number
-       char const                      *transport;                     //!< transport, typically name of IP proto
-
        fr_trie_t const                 *networks;                      //!< trie of allowed networks
 } fr_io_instance_t;
 
index 12a7b9fad664d01f9e79ae7db9c49bf650f44241..eafd71b6d7432fe3dd135e21ac8fc58b10204535 100644 (file)
@@ -230,7 +230,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
         *      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)) {
+           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule->dl_inst)) < 0)) {
                cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
@@ -267,14 +267,14 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        parent_inst = cf_data_value(cf_data_find(inst->cs, dl_module_inst_t, "proto_arp"));
        fr_assert(parent_inst);
 
-       if (dl_module_instance(inst->cs, &inst->io_submodule,
+       if (dl_module_instance(inst->cs, &inst->io_submodule->dl_inst,
                               parent_inst,
                               DL_MODULE_TYPE_SUBMODULE, "ethernet", dl_module_inst_name_from_conf(inst->cs)) < 0) {
                cf_log_perr(inst->cs, "Failed to load proto_arp_ethernet");
                return -1;
        }
 
-       if (dl_module_conf_parse(inst->io_submodule, inst->cs) < 0) {
+       if (dl_module_conf_parse(inst->io_submodule->dl_inst, inst->cs) < 0) {
                TALLOC_FREE(inst->io_submodule);
                return -1;
        }
@@ -282,11 +282,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        /*
         *      Bootstrap the I/O module
         */
-       inst->app_io = (fr_app_io_t const *) inst->io_submodule->module->common;
-       inst->app_io_instance = inst->io_submodule->data;
+       inst->app_io = (fr_app_io_t const *) inst->io_submodule->dl_inst->module->common;
+       inst->app_io_instance = inst->io_submodule->dl_inst->data;
        inst->app_io_conf = conf;
 
-       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule->dl_inst)) < 0)) {
                cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
index 77017c010111d2de41e4cdc0515d33dc3a11512a..9d84fadc6a109e61f282b5e3bb8333b2118e5659 100644 (file)
@@ -30,7 +30,7 @@ typedef struct {
        CONF_SECTION                    *server_cs;                     //!< server CS for this listener
        CONF_SECTION                    *cs;                            //!< my configuration
 
-       dl_module_inst_t                *io_submodule;                  //!< As provided by the transport_parse
+       module_instance_t               *io_submodule;                  //!< As provided by the transport_parse
                                                                        ///< callback.  Broken out into the
                                                                        ///< app_io_* fields below for convenience.
 
@@ -52,5 +52,3 @@ typedef struct {
        fr_listen_t                     *listen;                        //!< The listener structure which describes
                                                                        //!< the I/O path.
 } proto_arp_t;
-
-
index 4c394e4251781396e7de9c865f7a2f1ac933915e..c3983cc776ef5c48e6c2749287ee7d68b9c2c5f1 100644 (file)
@@ -30,7 +30,6 @@
 
 extern fr_app_t proto_bfd;
 
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 static int auth_type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 /** How to parse a BFD listen section
@@ -38,7 +37,7 @@ static int auth_type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF
  */
 static conf_parser_t const proto_bfd_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_bfd_t, io.submodule),
-         .func = transport_parse },
+         .func = virtual_sever_listen_transport_parse },
 
        CONF_PARSER_TERMINATOR
 };
@@ -94,58 +93,6 @@ static int8_t client_cmp(void const *one, void const *two)
        return fr_ipaddr_cmp(&a->ipaddr, &b->ipaddr);
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_bfd).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_bfd_t             *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_bfd"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_bfd_t);
-       inst->io.transport = name;
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) {
-               transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-               inst->io.app_io_conf = transport_cs;
-       }
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Parse auth_type
  *
  * @param[in] ctx      to allocate data in (instance of proto_bfd).
index 42644eff2d460f5b67eb615c260158e51dfc4001..f53ad59e69a7fbaaf9ae288d6d4d4f0fcf8302a5 100644 (file)
@@ -27,7 +27,6 @@
 #include "proto_control.h"
 
 extern fr_app_t proto_control;
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 static conf_parser_t const limit_config[] = {
        { FR_CONF_OFFSET("idle_timeout", proto_control_t, io.idle_timeout), .dflt = "30.0" } ,
@@ -51,7 +50,7 @@ static conf_parser_t const limit_config[] = {
  */
 static conf_parser_t const proto_control_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_control_t, io.submodule),
-         .func = transport_parse },
+         .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
        CONF_PARSER_TERMINATOR
@@ -65,56 +64,6 @@ fr_dict_autoload_t proto_control_dict[] = {
        { NULL }
 };
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_control).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_control_t         *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_control"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_control_t);
-       inst->io.transport = name;
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
-
 /** Open listen sockets/connect to external event source
  *
  * @param[in] instance Ctx data for this application.
index 5e6dc7d741570df9432e6e477dbc72b22ca2cdbf..c0cc546f34674b4eb67a825bed86a131e4d0237b 100644 (file)
@@ -31,7 +31,6 @@
 
 extern fr_app_t proto_cron;
 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, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 /** How to parse a Load listen section
  *
@@ -40,7 +39,7 @@ static conf_parser_t const proto_cron_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("type", FR_TYPE_VOID, CONF_FLAG_NOT_EMPTY | CONF_FLAG_REQUIRED, proto_cron_t,
                          type), .func = type_parse },
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_cron_t, io.submodule),
-         .func = transport_parse, .dflt = "crontab" },
+         .func = virtual_sever_listen_transport_parse, .dflt = "crontab" },
 
        /*
         *      Add this as a synonym so normal humans can understand it.
@@ -105,48 +104,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_cron).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_cron"));
-       fr_assert(parent_inst);
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet, and set the request->process function
  *
  */
index 35600925791b9762b8468c22bf7c595ec1afebd0..1d4d040d757e31e3c4a7f8010bbaa591ba81282c 100644 (file)
@@ -32,7 +32,6 @@
 
 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, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 #if 0
 /*
@@ -51,7 +50,7 @@ static conf_parser_t const proto_detail_config[] = {
        { 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 = transport_parse, .dflt = "file" },
+         .func = virtual_sever_listen_transport_parse, .dflt = "file" },
 
        /*
         *      Add this as a synonym so normal humans can understand it.
@@ -146,48 +145,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_detail).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_detail"));
-       fr_assert(parent_inst);
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet, and set the request->process function
  *
  */
@@ -450,7 +407,7 @@ static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
         *      Testing: allow it to read a "detail.work" file
         *      directly.
         */
-       if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") == 0) {
+       if (strcmp(inst->io_submodule->dl_inst->module->dl->name, "proto_detail_work") == 0) {
                if (!fr_schedule_listen_add(sc, li)) {
                        talloc_free(li);
                        return -1;
@@ -506,7 +463,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
         *      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)) {
+           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule->dl_inst)) < 0)) {
                cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
@@ -530,7 +487,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        /*
         *      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 (strcmp(inst->io_submodule->dl_inst->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);
@@ -573,11 +530,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        /*
         *      Bootstrap the I/O module
         */
-       inst->app_io = (fr_app_io_t const *) inst->io_submodule->module->common;
-       inst->app_io_instance = inst->io_submodule->data;
-       inst->app_io_conf = inst->io_submodule->conf;
+       inst->app_io = (fr_app_io_t const *) inst->io_submodule->dl_inst->module->common;
+       inst->app_io_instance = inst->io_submodule->dl_inst->data;
+       inst->app_io_conf = inst->io_submodule->dl_inst->conf;
 
-       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule->dl_inst)) < 0)) {
                cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
@@ -585,7 +542,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        /*
         *      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) {
+       if (strcmp(inst->io_submodule->dl_inst->module->dl->name, "proto_detail_work") != 0) {
                CONF_SECTION *transport_cs;
                dl_module_inst_t *parent_inst;
 
index 45fe0214b2efb02147bf93d88c8c4ecd61ceca7a..795e1f8de71e53ab627c307caa39a388c677ab6f 100644 (file)
@@ -40,7 +40,7 @@ typedef struct {
        fr_app_t                        *self;                          //!< child / parent linking issues
        char const                      *type;                          //!< packet type name
 
-       dl_module_inst_t                *io_submodule;                  //!< As provided by the transport_parse
+       module_instance_t               *io_submodule;                  //!< As provided by the transport_parse
                                                                        ///< callback.  Broken out into the
                                                                        ///< app_io_* fields below for convenience.
 
index 2190d978b194ad2dbf847e359ee6e5be65b851fe..0d5f5af81366e2155011f933225403e74f93c9b9 100644 (file)
@@ -31,7 +31,6 @@
 
 extern fr_app_t proto_dhcpv4;
 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 static const conf_parser_t priority_config[] = {
        { FR_CONF_OFFSET("Discover", proto_dhcpv4_t, priorities[FR_DHCP_DISCOVER]),
@@ -75,7 +74,8 @@ static conf_parser_t const limit_config[] = {
  */
 static conf_parser_t const proto_dhcpv4_config[] = {
        { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_dhcpv4_t, allowed_types), .func = type_parse },
-       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dhcpv4_t, io.submodule), .func = transport_parse },
+       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dhcpv4_t, io.submodule),
+         .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
 
@@ -135,56 +135,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_dhcpv4).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_dhcpv4_t          *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_dhcpv4"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_dhcpv4_t);
-       inst->io.transport = name;
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet
  *
  */
index f3a36783f1ec5d6bdaa48d11b09b74aca66a3229..701c9e288998e1e7efe9e08f384f124bcda98a7b 100644 (file)
@@ -30,7 +30,6 @@
 
 extern fr_app_t proto_dhcpv6;
 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 static const conf_parser_t priority_config[] = {
        { FR_CONF_OFFSET("Solicit", proto_dhcpv6_t, priorities[FR_DHCPV6_SOLICIT]),
@@ -76,7 +75,8 @@ static conf_parser_t const limit_config[] = {
  */
 static conf_parser_t const proto_dhcpv6_config[] = {
        { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_dhcpv6_t, allowed_types), .func = type_parse },
-       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dhcpv6_t, io.submodule), .func = transport_parse },
+       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dhcpv6_t, io.submodule),
+         .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
 
@@ -135,56 +135,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_dhcpv6).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_dhcpv6_t          *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_dhcpv6"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_dhcpv6_t);
-       inst->io.transport = name;
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet
  *
  */
index 3dacf56f5ada77aaa9960207f4b0cb0b754a257a..cc232fbd3182be2beea55a3805b9b89b64634932 100644 (file)
@@ -30,7 +30,6 @@
 
 extern fr_app_t proto_dns;
 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 static const conf_parser_t priority_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("query", FR_TYPE_VOID, 0, proto_dns_t, priorities[FR_DNS_QUERY]),
@@ -60,7 +59,7 @@ static conf_parser_t const limit_config[] = {
 static conf_parser_t const proto_dns_config[] = {
        { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_dns_t, allowed_types), .func = type_parse },
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_dns_t, io.submodule),
-         .func = transport_parse },
+         .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
 
@@ -117,56 +116,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_dns).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_dns_t             *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_dns"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_dns_t);
-       inst->io.transport = name;
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet
  *
  */
index 809c26d3763dfe3663acef7a8349accc4b1cb7c8..f55987cb5bd3a5db3e47869b4bb8a36e0e05ddb5 100644 (file)
@@ -35,8 +35,6 @@ static fr_internal_encode_ctx_t       encode_ctx = { .allow_name_only = true };
 
 extern fr_app_t proto_ldap_sync;
 
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
-
 static conf_parser_t const ldap_sync_search_config[] = {
        { FR_CONF_OFFSET("base_dn", sync_config_t, base_dn), .dflt = "", .quote = T_SINGLE_QUOTED_STRING },
 
@@ -51,7 +49,7 @@ static conf_parser_t const ldap_sync_search_config[] = {
 
 static conf_parser_t const proto_ldap_sync_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_ldap_sync_t, io_submodule),
-         .func = transport_parse },
+         .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_OFFSET("max_packet_size", proto_ldap_sync_t, max_packet_size) },
        { FR_CONF_OFFSET("num_messages", proto_ldap_sync_t, num_messages) },
@@ -95,47 +93,6 @@ fr_dict_attr_autoload_t proto_ldap_sync_dict_attr[] = {
        { NULL }
 };
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_dns).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_ldap_sync"));
-       fr_assert(parent_inst);
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst, DL_MODULE_TYPE_SUBMODULE, name,
-                              dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-       return 0;
-}
-
 /** Check if an attribute is in the config list and add if not present
  *
  * @param[in,out] config       to check for attribute.
@@ -300,7 +257,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
         *      Instantiate the I/O module.
         */
        if (inst->app_io->common.instantiate &&
-           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule->dl_inst)) < 0)) {
                cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
@@ -425,12 +382,12 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        /*
         *      Bootstrap the I/O module
         */
-       inst->app_io = (fr_app_io_t const *) inst->io_submodule->module->common;
-       inst->app_io_instance = inst->io_submodule->data;
-       inst->app_io_conf = inst->io_submodule->conf;
+       inst->app_io = (fr_app_io_t const *) inst->io_submodule->dl_inst->module->common;
+       inst->app_io_instance = inst->io_submodule->dl_inst->data;
+       inst->app_io_conf = inst->io_submodule->dl_inst->conf;
 
        if (inst->app_io->common.bootstrap &&
-           (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+           (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule->dl_inst)) < 0)) {
                cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
index 97d2b5f0ab7a34d6f542238504d98ee0a1eee47a..ce7baf701f4799ddef4329ddb7d9ad5b5d368303 100644 (file)
@@ -40,7 +40,7 @@ typedef struct {
 
        fr_app_t                *self;                          //!< child / parent linking issues
 
-       dl_module_inst_t        *io_submodule;                  //!< As provided by the transport_parse
+       module_instance_t       *io_submodule;                  //!< As provided by the transport_parse
                                                                //!< callback.  Broken out into the
                                                                //!< app_io_* fields below for convenience.
 
index 7577be3941a4cc14baaf1d18c481f7b65c2b6b57..6147687c054bafc148299e3688bba401181bcd44 100644 (file)
@@ -31,7 +31,6 @@
 
 extern fr_app_t proto_load;
 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, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 /** How to parse a Load listen section
  *
@@ -40,7 +39,7 @@ static conf_parser_t const proto_load_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("type", FR_TYPE_VOID, CONF_FLAG_NOT_EMPTY | CONF_FLAG_REQUIRED, proto_load_t,
                          type), .func = type_parse },
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_load_t, io.submodule),
-         .func = transport_parse, .dflt = "step" },
+         .func = virtual_sever_listen_transport_parse, .dflt = "step" },
 
        /*
         *      Add this as a synonym so normal humans can understand it.
@@ -105,48 +104,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_load).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_load"));
-       fr_assert(parent_inst);
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet, and set the request->process function
  *
  */
index 11f39a3f5f82c6bf83acf60e96ec0ca4693f9396..623d9a1af3f8dbd5badb5f111ea9fedcf097d2c8 100644 (file)
@@ -31,7 +31,6 @@
 extern fr_app_t proto_radius;
 
 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, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 static conf_parser_t const limit_config[] = {
        { FR_CONF_OFFSET("cleanup_delay", proto_radius_t, io.cleanup_delay), .dflt = "5.0" } ,
@@ -72,7 +71,7 @@ static const conf_parser_t priority_config[] = {
 static conf_parser_t const proto_radius_config[] = {
        { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_radius_t, allowed_types), .func = type_parse },
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_radius_t, io.submodule),
-         .func = transport_parse },
+         .func = virtual_sever_listen_transport_parse },
 
        /*
         *      Check whether or not the *trailing* bits of a
@@ -142,58 +141,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_radius).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_radius_t          *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_radius"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_radius_t);
-       inst->io.transport = name;
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) {
-               transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-               inst->io.app_io_conf = transport_cs;
-       }
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet
  *
  */
index dc789dcfebdafb05eff6da881877e4b75891e583..ee67b111b4eb7696bfe76c1e84d38115945fa952 100644 (file)
@@ -34,7 +34,6 @@
 extern fr_app_t proto_tacacs;
 
 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule);
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 static conf_parser_t const limit_config[] = {
        { FR_CONF_OFFSET("idle_timeout", proto_tacacs_t, io.idle_timeout), .dflt = "30.0" } ,
@@ -65,7 +64,7 @@ static const conf_parser_t priority_config[] = {
 
 static const conf_parser_t proto_tacacs_config[] = {
        { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_tacacs_t, allowed_types), .func = type_parse },
-       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_tacacs_t, io.submodule), .func = transport_parse },
+       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_tacacs_t, io.submodule), .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
        { FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
@@ -128,58 +127,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_tacacs).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_tacacs_t          *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_tacacs"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_tacacs_t);
-       inst->io.transport = name;
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) {
-               transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-               inst->io.app_io_conf = transport_cs;
-       }
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet
  *
  */
index 4aefa021d373bde5bc5c451c22b2db594d54eb6a..b4a865d46f891a840e2da261f965e5a09ceecdf9 100644 (file)
@@ -32,8 +32,6 @@
 extern fr_app_t proto_vmps;
 static int type_parse(TALLOC_CTX *ctx, void *out, void *parent,
                      CONF_ITEM *ci, conf_parser_t const *rule);
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, conf_parser_t const *rule);
 
 static const conf_parser_t priority_config[] = {
        { FR_CONF_OFFSET("Join-Request", proto_vmps_t, priorities[FR_PACKET_TYPE_VALUE_JOIN_REQUEST]),
@@ -66,7 +64,7 @@ static conf_parser_t const limit_config[] = {
  */
 static conf_parser_t const proto_vmps_config[] = {
        { FR_CONF_OFFSET_FLAGS("type", CONF_FLAG_NOT_EMPTY, proto_vmps_t, allowed_types), .func = type_parse },
-       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_vmps_t, io.submodule), .func = transport_parse },
+       { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_vmps_t, io.submodule), .func = virtual_sever_listen_transport_parse },
 
        { FR_CONF_POINTER("limit", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) limit_config },
        { FR_CONF_POINTER("priority", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) priority_config },
@@ -123,56 +121,6 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
        return 0;
 }
 
-/** Wrapper around dl_instance
- *
- * @param[in] ctx      to allocate data in (instance of proto_vmps).
- * @param[out] out     Where to write a dl_module_inst_t containing the module handle and instance.
- * @param[in] parent   Base structure address.
- * @param[in] ci       #CONF_PAIR specifying the name of the type module.
- * @param[in] rule     unused.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                          CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
-{
-       char const              *name = cf_pair_value(cf_item_to_pair(ci));
-       dl_module_inst_t        *parent_inst;
-       proto_vmps_t            *inst;
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(ci));
-       CONF_SECTION            *transport_cs;
-       dl_module_inst_t        *dl_mod_inst;
-
-       transport_cs = cf_section_find(listen_cs, name, NULL);
-
-       /*
-        *      Allocate an empty section if one doesn't exist
-        *      this is so defaults get parsed.
-        */
-       if (!transport_cs) transport_cs = cf_section_alloc(listen_cs, listen_cs, name, NULL);
-
-       parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_vmps"));
-       fr_assert(parent_inst);
-
-       /*
-        *      Set the allowed codes so that we can compile them as
-        *      necessary.
-        */
-       inst = talloc_get_type_abort(parent_inst->data, proto_vmps_t);
-       inst->io.transport = name;
-
-       if (dl_module_instance(ctx, &dl_mod_inst, parent_inst,
-                              DL_MODULE_TYPE_SUBMODULE, name, dl_module_inst_name_from_conf(transport_cs)) < 0) return -1;
-       if (dl_module_conf_parse(dl_mod_inst, transport_cs) < 0) {
-               talloc_free(dl_mod_inst);
-               return -1;
-       }
-       *((dl_module_inst_t **)out) = dl_mod_inst;
-
-       return 0;
-}
-
 /** Decode the packet
  *
  */