]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use the standard instantiate bootstrap callbacks for proto and proc modules
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 7 Apr 2022 19:34:27 +0000 (14:34 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 7 Apr 2022 20:07:01 +0000 (15:07 -0500)
30 files changed:
src/lib/io/app_io.c
src/lib/io/app_io.h
src/lib/io/application.h
src/lib/io/master.c
src/lib/io/network.c
src/lib/server/virtual_servers.c
src/listen/arp/proto_arp.c
src/listen/arp/proto_arp_ethernet.c
src/listen/control/proto_control.c
src/listen/control/proto_control_unix.c
src/listen/cron/proto_cron.c
src/listen/cron/proto_cron_crontab.c
src/listen/detail/proto_detail.c
src/listen/detail/proto_detail_file.c
src/listen/detail/proto_detail_work.c
src/listen/dhcpv4/proto_dhcpv4.c
src/listen/dhcpv4/proto_dhcpv4_udp.c
src/listen/dhcpv6/proto_dhcpv6.c
src/listen/dhcpv6/proto_dhcpv6_udp.c
src/listen/dns/proto_dns.c
src/listen/dns/proto_dns_udp.c
src/listen/load/proto_load.c
src/listen/load/proto_load_step.c
src/listen/radius/proto_radius.c
src/listen/radius/proto_radius_tcp.c
src/listen/radius/proto_radius_udp.c
src/listen/tacacs/proto_tacacs.c
src/listen/tacacs/proto_tacacs_tcp.c
src/listen/vmps/proto_vmps.c
src/listen/vmps/proto_vmps_udp.c

index e36d8724fc985d67fc5fa587da7f13304afe9a8d..5ea8727e96b38f631c68090e4657608a5a77ab36 100644 (file)
@@ -53,20 +53,20 @@ char const *fr_app_io_socket_name(TALLOC_CTX *ctx, fr_app_io_t const *app_io,
        if (!interface) {
                if (!src_ipaddr) {
                        return talloc_typed_asprintf(ctx, "%s server %s port %u",
-                                                    app_io->name, dst_buf, dst_port);
+                                                    app_io->common.name, dst_buf, dst_port);
                }
 
 
                return talloc_typed_asprintf(ctx, "%s from client %s port %u to server %s port %u",
-                                            app_io->name, src_buf, src_port, dst_buf, dst_port);
+                                            app_io->common.name, src_buf, src_port, dst_buf, dst_port);
        }
 
        if (!src_ipaddr) {
                return talloc_typed_asprintf(ctx, "%s server %s port %u on interface %s",
-                                            app_io->name, dst_buf, dst_port, interface);
+                                            app_io->common.name, dst_buf, dst_port, interface);
                }
 
 
                return talloc_typed_asprintf(ctx, "%s from client %s port %u to server %s port %u on interface %s",
-                                            app_io->name, src_buf, src_port, dst_buf, dst_port, interface);
+                                            app_io->common.name, src_buf, src_port, dst_buf, dst_port, interface);
 }
index f57db729c0420ca27f87b49938501139a0600493..16d0a9c7908acf98ba574962ecf79249fde23316 100644 (file)
  * This structure is exported by I/O modules e.g. proto_radius_udp.
  */
 typedef struct {
-       DL_MODULE_COMMON;                               //!< Common fields to all loadable modules.
+       module_t                        common;         //!< Common fields to all loadable modules.
 
-       fr_app_bootstrap_t              bootstrap;
-       fr_app_instantiate_t            instantiate;
        fr_app_event_list_set_t         event_list_set; //!< Called by the network thread to pass an event list
                                                        //!< for use by the app_io_t.
 
        size_t                          default_message_size;   //!< Usually maximum message size
        size_t                          default_reply_size;     //!< same for replies
-       size_t                          thread_inst_size;       //!< thread-specific socket information size
        bool                            track_duplicates;       //!< track duplicate packets
 
        fr_io_open_t                    open;           //!< Open a new socket for listening, or accept/connect a new
index 6cffaf498415a685c6f8788ed940ac67649f6cdc..2af80794111f17e16cafd9631a2eb22709d43eba 100644 (file)
  */
 typedef struct fr_schedule_s fr_schedule_t;
 
-/** Bootstrap the #fr_app_t
- *
- * Primarily used to allow the #fr_app_t to load its submodules.
- *
- * @param[in] instance of the #fr_app_t.
- * @param[in] cs       of the listen section that created this #fr_app_t.
- * @return
- *     - 0 on success.
- *     - <0 on failure.
- */
-typedef int (*fr_app_bootstrap_t)( void *instance, CONF_SECTION *cs);
-
-/** Instantiate the #fr_app_t
- *
- * Primarily used to allow the #fr_app_t to validate its config
- * and to allow its submodules to validate their configurations.
- *
- * @param[in] instance of the #fr_app_t.
- * @param[in] cs       of the listen section that created this #fr_app_t.
- * @return
- *     - 0 on success.
- *     - <0 on failure.
- */
-typedef int (*fr_app_instantiate_t)(void *instance, CONF_SECTION *cs);
-
 /** Open a new socket or other packet source
  *
  * @param[in] instance  of the #fr_app_t.
@@ -94,16 +69,10 @@ typedef void (*fr_app_event_list_set_t)(fr_listen_t *li, fr_event_list_t *el, vo
  * How the fr_app_t operates is specific to each protocol.
  */
 typedef struct {
-       DL_MODULE_COMMON;                               //!< Common fields to all loadable modules.
+       module_t                        common;         //!< Common fields provided by all modules.
 
        fr_dict_t const                 **dict;         //!< default dictionary for this application.
 
-       fr_app_bootstrap_t              bootstrap;      //!< Bootstrap function to allow the fr_app_t to load the
-                                                       ///< various submodules it requires.
-
-       fr_app_instantiate_t            instantiate;    //!< Instantiate function to perform config validation and
-                                                       ///< massaging.
-
        fr_app_open_t                   open;           //!< Callback to allow the #fr_app_t to build an #fr_listen_t
                                                        ///< and register it with the scheduler so we can receive
                                                        ///< data.
@@ -127,10 +96,7 @@ typedef struct {
  * the packet after its been decoded.
  */
 typedef struct {
-       DL_MODULE_COMMON;                               //!< Common fields to all loadable modules.
-
-       fr_app_bootstrap_t              bootstrap;
-       fr_app_instantiate_t            instantiate;
+       module_t                        common;         //!< Common fields to all loadable modules.
        module_method_t                 entry_point;    //!< Entry point into the protocol subtype's state machine.
        virtual_server_compile_t const  *compile_list;  //!< list of processing sections
 } fr_app_worker_t;
index e802e5f3ac276fa827831d33a66b80cef681d463..47e0150b67ac57ae6661730c63c68954e67e8c8a 100644 (file)
@@ -496,7 +496,7 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                }
 
                if (dl_module_instance(NULL, &dl_inst, NULL, inst->dl_inst, inst->transport, DL_MODULE_TYPE_SUBMODULE) < 0) {
-                       DEBUG("Failed to find proto_%s_%s", inst->app->name, inst->transport);
+                       DEBUG("Failed to find proto_%s_%s", inst->app->common.name, inst->transport);
                        return NULL;
                }
 
@@ -636,10 +636,10 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                 *      Create writable thread instance data.
                 */
                connection->child->thread_instance = talloc_zero_array(NULL, uint8_t,
-                                                                      inst->app_io->thread_inst_size);
+                                                                      inst->app_io->common.thread_inst_size);
                talloc_set_destructor(connection->child, fr_io_listen_free);
                talloc_set_name(connection->child->thread_instance, "proto_%s_thread_t",
-                               inst->app_io->name);
+                               inst->app_io->common.name);
 
                /*
                 *      This is "const", and the user can't
@@ -721,7 +721,7 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                 *      Set the new FD, and get the module to set it's connection name.
                 */
                if (inst->app_io->fd_set(connection->child, fd) < 0) {
-                       DEBUG3("Failed setting FD to %s", inst->app_io->name);
+                       DEBUG3("Failed setting FD to %s", inst->app_io->common.name);
                        close(fd);
                        return NULL;
                }
@@ -731,7 +731,7 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                if (!inst->app_io->get_name) {
                        connection->name = fr_asprintf(connection, "proto_%s from client %pV port "
                                                       "%u to server %pV port %u",
-                                                      inst->app_io->name,
+                                                      inst->app_io->common.name,
                                                       fr_box_ipaddr(connection->address->socket.inet.src_ipaddr),
                                                       connection->address->socket.inet.src_port,
                                                       fr_box_ipaddr(connection->address->socket.inet.dst_ipaddr),
@@ -761,7 +761,7 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                if (!ret) {
                        ERROR("proto_%s - Failed inserting connection into tracking table.  "
                              "Closing it, and discarding all packets for connection %s.",
-                             inst->app_io->name, connection->name);
+                             inst->app_io->common.name, connection->name);
                        goto cleanup;
                }
        }
@@ -777,12 +777,12 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                return connection;
        }
 
-       DEBUG("proto_%s - starting connection %s", inst->app_io->name, connection->name);
+       DEBUG("proto_%s - starting connection %s", inst->app_io->common.name, connection->name);
        connection->nr = fr_schedule_listen_add(thread->sc, connection->listen);
        if (!connection->nr) {
                ERROR("proto_%s - Failed inserting connection into scheduler.  "
                      "Closing it, and diuscarding all packets for connection %s.",
-                     inst->app_io->name, connection->name);
+                     inst->app_io->common.name, connection->name);
                pthread_mutex_lock(&client->mutex);
                (void) fr_hash_table_delete(client->ht, connection);
                pthread_mutex_unlock(&client->mutex);
@@ -1231,7 +1231,7 @@ redo:
                 */
                if (accept_fd < 0) {
                        DEBUG("proto_%s_%s - failed to accept new socket: %s",
-                             inst->app->name, inst->transport, fr_syserror(errno));
+                             inst->app->common.name, inst->transport, fr_syserror(errno));
                        return 0;
                }
 
@@ -1307,7 +1307,7 @@ do_read:
                                 *      listener?
                                 */
                                DEBUG2("proto_%s - ignoring packet from IP %pV. It is not configured as 'type = ...'",
-                                      inst->app_io->name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
+                                      inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
                                return 0;
                        }
                        *priority = value;
@@ -1390,11 +1390,11 @@ do_read:
                                if (accept_fd < 0) {
                                        DEBUG("proto_%s - ignoring packet from client IP address %pV - "
                                              "too many dynamic clients are defined",
-                                             inst->app_io->name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
+                                             inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
                                } else {
                                        DEBUG("proto_%s - ignoring connection attempt from client IP address %pV "
                                              "- too many dynamic clients are defined",
-                                             inst->app_io->name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
+                                             inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
                                        close(accept_fd);
                                }
                                return 0;
@@ -1423,10 +1423,10 @@ do_read:
                ignore:
                        if (accept_fd < 0) {
                                DEBUG("proto_%s - ignoring packet from unknown client IP address %pV",
-                                     inst->app_io->name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
+                                     inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
                        } else {
                                DEBUG("proto_%s - ignoring connection attempt from unknown client IP address %pV",
-                                     inst->app_io->name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
+                                     inst->app_io->common.name, fr_box_ipaddr(address.socket.inet.src_ipaddr));
                                close(accept_fd);
                        }
                        return 0;
@@ -1498,7 +1498,7 @@ do_read:
                 */
                if (fr_trie_insert_by_key(thread->trie, &client->src_ipaddr.addr, client->src_ipaddr.prefix, client)) {
                        ERROR("proto_%s - Failed inserting client %s into tracking table.  Discarding client, and all packets for it.",
-                             inst->app_io->name, client->radclient->shortname);
+                             inst->app_io->common.name, client->radclient->shortname);
                        talloc_free(client);
                        if (accept_fd >= 0) close(accept_fd);
                        return -1;
@@ -1814,7 +1814,7 @@ static int mod_open(fr_listen_t *li)
         *      Set the name of the socket.
         */
        if (!li->app_io->get_name) {
-               li->name = li->app_io->name;
+               li->name = li->app_io->common.name;
        } else {
                li->name = li->app_io->get_name(li);
        }
@@ -2032,9 +2032,9 @@ idle_timeout:
                 */
                if (client->ready_to_delete) {
                        if (connection) {
-                               DEBUG("proto_%s - idle timeout for connection %s", inst->app_io->name, connection->name);
+                               DEBUG("proto_%s - idle timeout for connection %s", inst->app_io->common.name, connection->name);
                        } else {
-                               DEBUG("proto_%s - idle timeout for client %s", inst->app_io->name, client->radclient->shortname);
+                               DEBUG("proto_%s - idle timeout for client %s", inst->app_io->common.name, client->radclient->shortname);
                        }
                        goto delete_client;
                }
@@ -2064,7 +2064,7 @@ reset_timer:
        if (fr_event_timer_in(client, el, &client->ev,
                              delay, client_expiry_timer, client) < 0) {
                ERROR("proto_%s - Failed adding timeout for dynamic client %s.  It will be permanent!",
-                     inst->app_io->name, client->radclient->shortname);
+                     inst->app_io->common.name, client->radclient->shortname);
                return;
        }
 
@@ -2099,13 +2099,13 @@ static void packet_expiry_timer(fr_event_list_t *el, fr_time_t now, void *uctx)
                 */
                if (fr_event_timer_at(track, el, &track->ev,
                                      track->expires, packet_expiry_timer, track) == 0) {
-                       DEBUG("proto_%s - cleaning up request in %.6fs", inst->app_io->name,
+                       DEBUG("proto_%s - cleaning up request in %.6fs", inst->app_io->common.name,
                              fr_time_delta_unwrap(inst->cleanup_delay) / (double)NSEC);
                        return;
                }
 
                DEBUG("proto_%s - Failed adding cleanup_delay for packet.  Discarding packet immediately",
-                     inst->app_io->name);
+                     inst->app_io->common.name);
        }
 
        /*
@@ -2113,9 +2113,9 @@ static void packet_expiry_timer(fr_event_list_t *el, fr_time_t now, void *uctx)
         *      timeout ones.
         */
        if (fr_time_neq(now, fr_time_wrap(0))) {
-               DEBUG2("TIMER - proto_%s - cleanup delay", inst->app_io->name);
+               DEBUG2("TIMER - proto_%s - cleanup delay", inst->app_io->common.name);
        } else {
-               DEBUG2("proto_%s - cleaning up", inst->app_io->name);
+               DEBUG2("proto_%s - cleaning up", inst->app_io->common.name);
        }
 
        /*
@@ -2439,7 +2439,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->name, inst->transport);
+                     inst->app_io->common.name, inst->transport);
                goto error;
        }
 
@@ -2550,9 +2550,10 @@ static int mod_close(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       fr_io_instance_t *inst = instance;
+       fr_io_instance_t *inst = mctx->inst->data;
+       CONF_SECTION *conf = mctx->inst->conf;
 
        /*
         *      Find and bootstrap the application IO handler.
@@ -2580,9 +2581,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                }
        }
 
-       if (inst->app_io->bootstrap && (inst->app_io->bootstrap(inst->app_io_instance,
-                                                               inst->app_io_conf) < 0)) {
-               cf_log_err(inst->app_io_conf, "Bootstrap failed for proto_%s", inst->app_io->name);
+       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->submodule)) < 0)) {
+               cf_log_err(inst->app_io_conf, "Bootstrap failed for proto_%s", inst->app_io->common.name);
                return -1;
        }
 
@@ -2601,9 +2601,9 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                /*
                 *      Load proto_dhcpv4_dynamic_client
                 */
-               if (dl_module_instance(cs, &inst->dynamic_submodule,
-                               cs, inst->dl_inst, "dynamic_client", DL_MODULE_TYPE_SUBMODULE) < 0) {
-                       cf_log_err(cs, "Failed finding proto_%s_dynamic_client", inst->app->name);
+               if (dl_module_instance(conf, &inst->dynamic_submodule,
+                                      conf, inst->dl_inst, "dynamic_client", DL_MODULE_TYPE_SUBMODULE) < 0) {
+                       cf_log_err(conf, "Failed finding proto_%s_dynamic_client", inst->app->common.name);
                        return -1;
                }
 
@@ -2624,7 +2624,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        }
 
        if (inst->ipproto && !inst->app_io->connection_set) {
-               cf_log_err(inst->app_io_conf, "Cannot set TCP for proto_%s - internal set error", inst->app_io->name);
+               cf_log_err(inst->app_io_conf, "Cannot set TCP for proto_%s - internal set error", inst->app_io->common.name);
                return -1;
        }
 
@@ -2646,16 +2646,16 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       fr_io_instance_t *inst = instance;
+       fr_io_instance_t        *inst = mctx->inst->data;
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        fr_assert(inst->app_io != NULL);
 
-       if (inst->app_io->instantiate &&
-           (inst->app_io->instantiate(inst->app_io_instance,
-                                      inst->app_io_conf) < 0)) {
-               cf_log_err(conf, "Instantiation failed for \"proto_%s\"", inst->app_io->name);
+       if (inst->app_io->common.instantiate &&
+           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->submodule)) < 0)) {
+               cf_log_err(conf, "Instantiation failed for \"proto_%s\"", inst->app_io->common.name);
                return -1;
        }
 
@@ -2666,7 +2666,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
                fr_app_worker_t const   *app_process;
 
                if (!inst->dynamic_submodule) {
-                       cf_log_err(conf, "Instantiation failed for \"proto_%s\" - there is no way to define dynamic clients", inst->app_io->name);
+                       cf_log_err(conf, "Instantiation failed for \"proto_%s\" - there is no way to define dynamic clients", inst->app_io->common.name);
                        return -1;
                }
 
@@ -2692,8 +2692,8 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
                        };
                }
 
-               if (app_process->instantiate && (app_process->instantiate(inst->dynamic_submodule->data, conf) < 0)) {
-                       cf_log_err(conf, "Instantiation failed for \"%s\"", app_process->name);
+               if (app_process->common.instantiate && (app_process->common.instantiate(MODULE_INST_CTX(inst->dynamic_submodule)) < 0)) {
+                       cf_log_err(conf, "Instantiation failed for \"%s\"", app_process->common.name);
                        return -1;
                }
        }
@@ -2904,7 +2904,7 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *
                return 0;
        }
 
-       if (!inst->app_io->thread_inst_size) {
+       if (!inst->app_io->common.thread_inst_size) {
                fr_strerror_const("IO modules MUST set 'thread_inst_size' when using the master IO handler.");
                return -1;
        }
@@ -2982,13 +2982,13 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *
        child->app_io = inst->app_io;
        child->track_duplicates = inst->app_io->track_duplicates;
 
-       if (child->app_io->thread_inst_size > 0) {
+       if (child->app_io->common.thread_inst_size > 0) {
                child->thread_instance = talloc_zero_array(NULL, uint8_t,
-                                                          inst->app_io->thread_inst_size);
+                                                          inst->app_io->common.thread_inst_size);
                talloc_set_destructor(child, fr_io_listen_free);
 
                talloc_set_name(child->thread_instance, "proto_%s_thread_t",
-                               inst->app_io->name);
+                               inst->app_io->common.name);
 
                /*
                 *      This is "const", and the user can't
@@ -3008,7 +3008,7 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *
         *      socket for us.
         */
        if (inst->app_io->open(child) < 0) {
-               cf_log_err(inst->app_io_conf, "Failed opening %s interface", inst->app_io->name);
+               cf_log_err(inst->app_io_conf, "Failed opening %s interface", inst->app_io->common.name);
                talloc_free(li);
                return -1;
        }
@@ -3016,7 +3016,7 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *
        li->fd = child->fd;     /* copy this back up */
 
        if (!child->app_io->get_name) {
-               child->name = child->app_io->name;
+               child->name = child->app_io->common.name;
        } else {
                child->name = child->app_io->get_name(child);
        }
@@ -3056,12 +3056,13 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *
 
 
 fr_app_io_t fr_master_app_io = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "radius_master_io",
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "radius_master_io",
 
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate,
+       },
        .default_message_size   = 4096,
        .track_duplicates       = true,
 
index 657d9bd2fa66d184b16eaf370ae233141d0d0644..271d9686b3db5687d12b3d51947c7365cec5f232 100644 (file)
@@ -1876,7 +1876,7 @@ static int cmd_socket_list(FILE *fp, UNUSED FILE *fp_err, void *ctx, UNUSED fr_c
             socket;
             socket = fr_rb_iter_next_inorder(&iter)) {
                if (!socket->listen->app_io->get_name) {
-                       fprintf(fp, "%s\n", socket->listen->app_io->name);
+                       fprintf(fp, "%s\n", socket->listen->app_io->common.name);
                } else {
                        fprintf(fp, "%d\t%s\n", socket->number, socket->listen->app_io->get_name(socket->listen));
                }
index 823c1778a92ef413f00bfd111f27d5a63de143a2..abebb7420140a5907ed180d69bbc0333a866ceac 100644 (file)
@@ -802,8 +802,8 @@ int virtual_servers_instantiate(void)
                        fr_assert(listen->proto_module != NULL);
                        fr_assert(listen->app != NULL);
 
-                       if (listen->app->instantiate &&
-                           listen->app->instantiate(listen->proto_module->data, listen->proto_module->conf) < 0) {
+                       if (listen->app->common.instantiate &&
+                           listen->app->common.instantiate(MODULE_INST_CTX(listen->proto_module)) < 0) {
                                cf_log_err(listen->proto_module->conf, "Could not load virtual server \"%s\".",
                                            cf_section_name2(server_cs));
                                return -1;
@@ -982,8 +982,8 @@ int virtual_servers_bootstrap(CONF_SECTION *config)
                        talloc_get_type_abort(listen->proto_module, dl_module_inst_t);
                        listen->app = (fr_app_t const *)listen->proto_module->module->common;
 
-                       if (listen->app->bootstrap &&
-                           listen->app->bootstrap(listen->proto_module->data, listen->proto_module->conf) < 0) {
+                       if (listen->app->common.bootstrap &&
+                           listen->app->common.bootstrap(MODULE_INST_CTX(listen->proto_module)) < 0) {
                                cf_log_err(listen->proto_module->conf, "Bootstrap failed");
                                return -1;
                        }
@@ -1046,8 +1046,8 @@ int virtual_servers_open(fr_schedule_t *sc)
                         */
                        if (listen->app->open &&
                            listen->app->open(listen->proto_module->data, sc, listen->proto_module->conf) < 0) {
-                               cf_log_err(listen->proto_module->conf, "Opening %s I/O interface failed",
-                                          listen->app->name);
+                               cf_log_perr(listen->proto_module->conf, "Opening %s I/O interface failed",
+                                           listen->app->common.name);
                                return -1;
                        }
 
@@ -1055,7 +1055,7 @@ int virtual_servers_open(fr_schedule_t *sc)
                         *      Socket information is printed out by
                         *      the socket handlers.  e.g. proto_radius_udp
                         */
-                       DEBUG3("Opened listener for %s", listen->app->name);
+                       DEBUG3("Opened listener for %s", listen->app->common.name);
                }
        }
 
index c77ba5c7e1427beaee767517443b5b7cdbf1f4ce..03327e7a7d328597386ea40ee413e682666df4b0 100644 (file)
@@ -175,9 +175,9 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
 
        li->app_io = inst->app_io;
        li->app_io_instance = inst->app_io_instance;
-       if (li->app_io->thread_inst_size) {
-               li->thread_instance = talloc_zero_array(NULL, uint8_t, li->app_io->thread_inst_size);
-               talloc_set_name(li->thread_instance, "proto_%s_thread_t", inst->app_io->name);
+       if (li->app_io->common.thread_inst_size) {
+               li->thread_instance = talloc_zero_array(NULL, uint8_t, li->app_io->common.thread_inst_size);
+               talloc_set_name(li->thread_instance, "proto_%s_thread_t", inst->app_io->common.name);
        }
 
        /*
@@ -209,24 +209,21 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_arp_t             *inst = talloc_get_type_abort(instance, proto_arp_t);
-
+       proto_arp_t             *inst = talloc_get_type_abort(mctx->inst->data, proto_arp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        /*
         *      Instantiate the I/O module. But DON'T instantiate the
         *      work submodule.  We leave that until later.
         */
-       if (inst->app_io->instantiate &&
-           (inst->app_io->instantiate(inst->app_io_instance,
-                                      inst->app_io_conf) < 0)) {
-               cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->name);
+       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;
        }
 
@@ -243,15 +240,14 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_arp_t             *inst = talloc_get_type_abort(instance, proto_arp_t);
+       proto_arp_t             *inst = talloc_get_type_abort(mctx->inst->data, proto_arp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        dl_module_inst_t        *parent_inst;
 
        /*
@@ -281,9 +277,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        inst->app_io_instance = inst->io_submodule->data;
        inst->app_io_conf = conf;
 
-       if (inst->app_io->bootstrap && (inst->app_io->bootstrap(inst->app_io_instance,
-                                                               inst->app_io_conf) < 0)) {
-               cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->name);
+       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+               cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
 
@@ -305,16 +300,17 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_arp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "arp",
-       .config                 = proto_arp_config,
-       .inst_size              = sizeof(proto_arp_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "arp",
+               .config                 = proto_arp_config,
+               .inst_size              = sizeof(proto_arp_t),
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_arp,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 0fdf6cbfef212edc605e316f193c31b9cb055634..312bab4d731f38d4553c03ba1a682ed158921643 100644 (file)
@@ -216,24 +216,25 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_arp_ethernet_t    *inst = talloc_get_type_abort(instance, proto_arp_ethernet_t);
+       proto_arp_ethernet_t    *inst = talloc_get_type_abort(mctx->inst->data, proto_arp_ethernet_t);
 
-       inst->cs = cs;
+       inst->cs = mctx->inst->conf;
 
        return 0;
 }
 
 
 fr_app_io_t proto_arp_ethernet = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "arp_ethernet",
-       .config                 = arp_listen_config,
-       .inst_size              = sizeof(proto_arp_ethernet_t),
-       .thread_inst_size       = sizeof(proto_arp_ethernet_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "arp_ethernet",
+               .config                 = arp_listen_config,
+               .inst_size              = sizeof(proto_arp_ethernet_t),
+               .thread_inst_size       = sizeof(proto_arp_ethernet_thread_t),
+               .bootstrap              = mod_bootstrap,
+       },
        .default_message_size   = FR_ARP_PACKET_SIZE,
 
        .open                   = mod_open,
index 2bbba2ddadc614acaa6bd68e5c069dace16a04a7..9021f8e65fd5a5419095c1a211189bf9ef97a435 100644 (file)
@@ -138,15 +138,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_control_t         *inst = talloc_get_type_abort(instance, proto_control_t);
+       proto_control_t         *inst = talloc_get_type_abort(mctx->inst->data, proto_control_t);
 
        fr_assert(inst->io.submodule != NULL);
 
@@ -167,7 +165,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
@@ -175,15 +173,14 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_control_t                 *inst = talloc_get_type_abort(instance, proto_control_t);
+       proto_control_t                 *inst = talloc_get_type_abort(mctx->inst->data, proto_control_t);
+       CONF_SECTION                    *conf = mctx->inst->conf;
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
@@ -222,16 +219,17 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 fr_app_t proto_control = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "control",
-       .config                 = proto_control_config,
-       .inst_size              = sizeof(proto_control_t),
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "control",
+               .config                 = proto_control_config,
+               .inst_size              = sizeof(proto_control_t),
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .open                   = mod_open,
 };
index e562b06064aa3f9a0477df3d17d6023fe16e8c61..f1091f5a445a58121fac51e86edd469d2d0db6c9 100644 (file)
@@ -1105,11 +1105,12 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_control_unix_t    *inst = talloc_get_type_abort(instance, proto_control_unix_t);
+       proto_control_unix_t    *inst = talloc_get_type_abort(mctx->inst->data, proto_control_unix_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        if (inst->recv_buff_is_set) {
                FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
@@ -1126,7 +1127,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (inst->uid_name) {
                struct passwd *pwd;
 
-               if (fr_perm_getpwnam(cs, &pwd, inst->uid_name) < 0) {
+               if (fr_perm_getpwnam(conf, &pwd, inst->uid_name) < 0) {
                        PERROR("Failed getting uid for %s", inst->uid_name);
                        return -1;
                }
@@ -1137,7 +1138,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        }
 
        if (inst->gid_name) {
-               if (fr_perm_gid_from_str(cs, &inst->gid, inst->gid_name) < 0) {
+               if (fr_perm_gid_from_str(conf, &inst->gid, inst->gid_name) < 0) {
                        PERROR("Failed getting gid for %s", inst->gid_name);
                        return -1;
                }
@@ -1179,13 +1180,14 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipa
 
 extern fr_app_io_t proto_control_unix;
 fr_app_io_t proto_control_unix = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "control_unix",
-       .config                 = unix_listen_config,
-       .inst_size              = sizeof(proto_control_unix_t),
-       .thread_inst_size       = sizeof(proto_control_unix_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "control_unix",
+               .config                 = unix_listen_config,
+               .inst_size              = sizeof(proto_control_unix_t),
+               .thread_inst_size       = sizeof(proto_control_unix_thread_t),
+               .bootstrap              = mod_bootstrap,
+       },
        .default_message_size   = 4096,
 
        .open                   = mod_open,
index af48499a9652fe8c6adfa33c0790bbc5171c50cc..d14a3d4c88b06c9b1443e5b26ee4c5a6d7abf960 100644 (file)
@@ -244,15 +244,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate I/O and type submodules.
  *
- * @param[in] instance Ctx data for this application.
- * @param[in] conf     Listen section parsed to give us isntance.
  * @return
  *     - 0 on success.
  *     - -1 on failure.
  */
-static int mod_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_cron_t            *inst = talloc_get_type_abort(instance, proto_cron_t);
+       proto_cron_t            *inst = talloc_get_type_abort(mctx->inst->data, proto_cron_t);
 
        fr_assert(inst->io.submodule);
 
@@ -273,22 +271,21 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 /** 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_cron_t            *inst = talloc_get_type_abort(instance, proto_cron_t);
+       proto_cron_t            *inst = talloc_get_type_abort(mctx->inst->data, proto_cron_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
@@ -325,18 +322,20 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
 fr_app_t proto_cron = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "cron",
-       .config                 = proto_cron_config,
-       .inst_size              = sizeof(proto_cron_t),
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "cron",
+               .config                 = proto_cron_config,
+               .inst_size              = sizeof(proto_cron_t),
+
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 3709d368f025c8a48050f372673cf96837d20d72..5acdee47404b615782ecaeec78fe5e84ab012d2e 100644 (file)
@@ -682,9 +682,10 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_cron_crontab_t    *inst = talloc_get_type_abort(instance, proto_cron_crontab_t);
+       proto_cron_crontab_t    *inst = talloc_get_type_abort(mctx->inst->data, proto_cron_crontab_t);
+       CONF_SECTION            *conf = mctx->inst->data;
        dl_module_inst_t const  *dl_inst;
 
        /*
@@ -692,12 +693,12 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         *      so we can find out what the parent of our instance
         *      was.
         */
-       dl_inst = dl_module_instance_by_data(instance);
+       dl_inst = dl_module_instance_by_data(inst);
        fr_assert(dl_inst);
 
        inst->parent = talloc_get_type_abort(dl_inst->parent->data, proto_cron_t);
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        return 0;
 }
@@ -710,9 +711,10 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipa
 }
 
 
-static int mod_instantiate(void *instance, CONF_SECTION *cs)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_cron_crontab_t    *inst = talloc_get_type_abort(instance, proto_cron_crontab_t);
+       proto_cron_crontab_t    *inst = talloc_get_type_abort(mctx->inst->data, proto_cron_crontab_t);
+       CONF_SECTION            *conf = mctx->inst->data;
        RADCLIENT               *client;
        fr_pair_t               *vp;
        FILE                    *fp;
@@ -732,13 +734,13 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs)
 
        fp = fopen(inst->filename, "r");
        if (!fp) {
-               cf_log_err(cs, "Failed opening %s - %s",
+               cf_log_err(conf, "Failed opening %s - %s",
                           inst->filename, fr_syserror(errno));
                return -1;
        }
 
        if (fr_pair_list_afrom_file(inst, inst->parent->dict, &inst->pair_list, fp, &done) < 0) {
-               cf_log_perr(cs, "Failed reading %s", inst->filename);
+               cf_log_perr(conf, "Failed reading %s", inst->filename);
                fclose(fp);
                return -1;
        }
@@ -752,14 +754,15 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs)
 }
 
 fr_app_io_t proto_cron_crontab = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "cron_crontab",
-       .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,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "cron_crontab",
+               .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,
        .track_duplicates       = false,
 
index 4151e130f36466a254ca27facd1db66acf9894ed..085e37354780c032bd52429085dea7be0082ea0b 100644 (file)
@@ -373,8 +373,8 @@ static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
        talloc_set_destructor(li, fr_io_listen_free);
 
        li->app_io = inst->app_io;
-       li->thread_instance = talloc_zero_array(NULL, uint8_t, li->app_io->thread_inst_size);
-       talloc_set_name(li->thread_instance, "proto_%s_thread_t", inst->app_io->name);
+       li->thread_instance = talloc_zero_array(NULL, uint8_t, li->app_io->common.thread_inst_size);
+       talloc_set_name(li->thread_instance, "proto_%s_thread_t", inst->app_io->common.name);
        li->app_io_instance = inst->app_io_instance;
 
        li->app = &proto_detail;
@@ -391,7 +391,7 @@ static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
         *      Open the file.
         */
        if (inst->app_io->open(li) < 0) {
-               cf_log_err(conf, "Failed opening %s file", inst->app_io->name);
+               cf_log_err(conf, "Failed opening %s file", inst->app_io->common.name);
                talloc_free(li);
                return -1;
        }
@@ -435,24 +435,22 @@ static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf)
  *
  * Instantiate I/O and type submodules.
  *
- * @param[in] instance Ctx data for this application.
- * @param[in] conf     Listen section parsed to give us isntance.
  * @return
  *     - 0 on success.
  *     - -1 on failure.
  */
-static int mod_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_detail_t          *inst = talloc_get_type_abort(instance, proto_detail_t);
+       proto_detail_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_detail_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        /*
         *      Instantiate the I/O module. But DON'T instantiate the
         *      work submodule.  We leave that until later.
         */
-       if (inst->app_io->instantiate &&
-           (inst->app_io->instantiate(inst->app_io_instance,
-                                      inst->app_io_conf) < 0)) {
-               cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->name);
+       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;
        }
 
@@ -476,9 +474,9 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
         *      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->instantiate && (inst->work_io->instantiate(inst->work_io_instance,
-                                                                             inst->work_io_conf) < 0)) {
-                       cf_log_err(inst->work_io_conf, "Instantiation failed for \"%s\"", inst->work_io->name);
+               if (inst->work_io->common.instantiate &&
+                   (inst->work_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+                       cf_log_err(inst->work_io_conf, "Instantiation failed for \"%s\"", inst->work_io->common.name);
                        return -1;
                }
        }
@@ -490,15 +488,14 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_detail_t          *inst = talloc_get_type_abort(instance, proto_detail_t);
+       proto_detail_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_detail_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        /*
         *      The listener is inside of a virtual server.
@@ -507,8 +504,6 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        inst->cs = conf;
        inst->self = &proto_detail;
 
-       virtual_server_dict_set(inst->server_cs, inst->dict, false);
-
        /*
         *      No IO module, it's an empty listener.  That's not
         *      allowed for the detail file reader.
@@ -525,9 +520,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        inst->app_io_instance = inst->io_submodule->data;
        inst->app_io_conf = inst->io_submodule->conf;
 
-       if (inst->app_io->bootstrap && (inst->app_io->bootstrap(inst->app_io_instance,
-                                                               inst->app_io_conf) < 0)) {
-               cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->name);
+       if (inst->app_io->common.bootstrap && (inst->app_io->common.bootstrap(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
+               cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->common.name);
                return -1;
        }
 
@@ -571,9 +565,9 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
                inst->work_io_instance = inst->work_submodule->data;
                inst->work_io_conf = inst->work_submodule->conf;
 
-               if (inst->work_io->bootstrap && (inst->work_io->bootstrap(inst->work_io_instance,
-                                                                         inst->work_io_conf) < 0)) {
-                       cf_log_err(inst->work_io_conf, "Bootstrap failed for \"%s\"", inst->work_io->name);
+               if (inst->work_io->common.bootstrap &&
+                   (inst->work_io->common.bootstrap(MODULE_INST_CTX(inst->work_submodule)) < 0)) {
+                       cf_log_err(inst->work_io_conf, "Bootstrap failed for \"%s\"", inst->work_io->common.name);
                        TALLOC_FREE(inst->work_submodule);
                        return -1;
                }
@@ -584,13 +578,15 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 
 
 fr_app_t proto_detail = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "detail",
-       .config                 = proto_detail_config,
-       .inst_size              = sizeof(proto_detail_t),
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "detail",
+               .config                 = proto_detail_config,
+               .inst_size              = sizeof(proto_detail_t),
+
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate,
+       },
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 3dec2c463df9bf34726c963ebb119a7cc91fc957..5759839d8f853f90c28f0ddf1b0c9db2fd54cb23 100644 (file)
@@ -379,7 +379,7 @@ static int work_exists(proto_detail_file_thread_t *thread, int fd)
         *      Open the detail.work file.
         */
        if (li->app_io->open(li) < 0) {
-               ERROR("Failed opening %s", li->app_io->name);
+               ERROR("Failed opening %s", li->app_io->common.name);
                goto error;
        }
        opened = true;
@@ -584,9 +584,10 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_detail_file_t     *inst = talloc_get_type_abort(instance, proto_detail_file_t);
+       proto_detail_file_t     *inst = talloc_get_type_abort(mctx->inst->data, proto_detail_file_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        dl_module_inst_t const  *dl_inst;
        char                    *p;
 
@@ -617,7 +618,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         *      so we can find out what the parent of our instance
         *      was.
         */
-       dl_inst = dl_module_instance_by_data(instance);
+       dl_inst = dl_module_instance_by_data(mctx->inst->data);
        fr_assert(dl_inst);
 
 #ifndef __linux__
@@ -629,13 +630,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        FR_INTEGER_BOUND_CHECK("poll_interval", inst->poll_interval, <=, 3600);
 
        inst->parent = talloc_get_type_abort(dl_inst->parent->data, proto_detail_t);
-       inst->cs = cs;
+       inst->cs = conf;
 
        inst->directory = p = talloc_strdup(inst, inst->filename);
 
        p = strrchr(p, '/');
        if (!p) {
-               cf_log_err(cs, "Filename must contain '/'");
+               cf_log_err(conf, "Filename must contain '/'");
                return -1;
        }
 
@@ -672,16 +673,17 @@ static int8_t _detail_file_cmp(void const *one, void const *two)
 /*
  *     Check for multiple readers on the same set of files.
  */
-static int mod_instantiate(void *instance, CONF_SECTION *cs)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_detail_file_t *inst = talloc_get_type_abort(instance, proto_detail_file_t);
+       proto_detail_file_t     *inst = talloc_get_type_abort(mctx->inst->data, proto_detail_file_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        pthread_mutex_lock(&detail_file_mutex);
        if (!detail_file_tree) {
-               detail_file_tree = fr_rb_inline_talloc_alloc(cs, proto_detail_file_t, filename_node, _detail_file_cmp, NULL);
+               detail_file_tree = fr_rb_inline_talloc_alloc(conf, proto_detail_file_t, filename_node, _detail_file_cmp, NULL);
                if (!detail_file_tree) {
                        pthread_mutex_unlock(&detail_file_mutex);
-                       cf_log_err(cs, "Failed initializing detail_file");
+                       cf_log_err(conf, "Failed initializing detail_file");
                        return -1;
                }
        }
@@ -693,8 +695,8 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs)
                fr_assert(old);
 
                pthread_mutex_unlock(&detail_file_mutex);
-               cf_log_err(cs, "Duplicate detail listener %s", inst->filename);
-               cf_log_err(cs, "Original detail listener is in virtual server %s", cf_section_name2(old->parent->server_cs));
+               cf_log_err(conf, "Duplicate detail listener %s", inst->filename);
+               cf_log_err(conf, "Original detail listener is in virtual server %s", cf_section_name2(old->parent->server_cs));
                return -1;
        }
        pthread_mutex_unlock(&detail_file_mutex);
@@ -740,14 +742,15 @@ static int mod_close(fr_listen_t *li)
  */
 extern fr_app_io_t proto_detail_file;
 fr_app_io_t proto_detail_file = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "detail_file",
-       .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,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "detail_file",
+               .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,
        .default_reply_size     = 32,
 
index 3e9f7acdc5c48fe48612850b1c9bf3d84551c790..f85d1609d94bab6a4fdee614a2f7bcb0ca72c93d 100644 (file)
@@ -814,9 +814,9 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
-static int mod_instantiate(void *instance, UNUSED CONF_SECTION *cs)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_detail_work_t *inst = talloc_get_type_abort(instance, proto_detail_work_t);
+       proto_detail_work_t *inst = talloc_get_type_abort(mctx->inst->data, proto_detail_work_t);
        RADCLIENT *client;
 
        client = inst->client = talloc_zero(inst, RADCLIENT);
@@ -832,9 +832,10 @@ static int mod_instantiate(void *instance, UNUSED CONF_SECTION *cs)
        return 0;
 }
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_detail_work_t     *inst = talloc_get_type_abort(instance, proto_detail_work_t);
+       proto_detail_work_t     *inst = talloc_get_type_abort(mctx->inst->data, proto_detail_work_t);
+       CONF_SECTION            *cs = mctx->inst->conf;
        dl_module_inst_t const  *dl_inst;
 
        /*
@@ -842,7 +843,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         *      so we can find out what the parent of our instance
         *      was.
         */
-       dl_inst = dl_module_instance_by_data(instance);
+       dl_inst = dl_module_instance_by_data(mctx->inst->data);
        fr_assert(dl_inst);
 
        inst->parent = talloc_get_type_abort(dl_inst->parent->data, proto_detail_t);
@@ -882,14 +883,15 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
  */
 extern fr_app_io_t proto_detail_work;
 fr_app_io_t proto_detail_work = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "detail_work",
-       .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,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "detail_work",
+               .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,
        .default_reply_size     = 32,
 
index b7fc0ed9ade54ba9762154ad1c2d4c6cf184e7bb..305b35a96628404e2fde4e680a780e6007e72f13 100644 (file)
@@ -398,15 +398,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_dhcpv4_t          *inst = talloc_get_type_abort(instance, proto_dhcpv4_t);
+       proto_dhcpv4_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv4_t);
 
        /*
         *      No IO module, it's an empty listener.
@@ -430,7 +428,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
@@ -438,20 +436,18 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_dhcpv4_t          *inst = talloc_get_type_abort(instance, proto_dhcpv4_t);
+       proto_dhcpv4_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv4_t);
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(conf));
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->conf));
 
        fr_assert(dict_dhcpv4 != NULL);
        fr_assert(attr_message_type != NULL);
@@ -488,7 +484,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 static int mod_load(void)
@@ -507,17 +503,19 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_dhcpv4 = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "dhcpv4",
-       .config                 = proto_dhcpv4_config,
-       .inst_size              = sizeof(proto_dhcpv4_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "dhcpv4",
+               .config                 = proto_dhcpv4_config,
+               .inst_size              = sizeof(proto_dhcpv4_t),
+
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_dhcpv4,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 36a620fd297e692b7a7b9178f4854b87802e7153..06d1df097eadd5678515398b16c4f258df8da84f 100644 (file)
@@ -653,26 +653,27 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_dhcpv4_udp_t      *inst = talloc_get_type_abort(instance, proto_dhcpv4_udp_t);
+       proto_dhcpv4_udp_t      *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv4_udp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  num;
        CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
        RADCLIENT               *client;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
-               cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
+               cf_log_err(conf, "No 'ipaddr' was specified in the 'udp' section");
                return -1;
        }
 
        if (inst->ipaddr.af != AF_INET) {
-               cf_log_err(cs, "DHCPv4 transport cannot use IPv6 for 'ipaddr'");
+               cf_log_err(conf, "DHCPv4 transport cannot use IPv6 for 'ipaddr'");
                return -1;
        }
 
@@ -681,7 +682,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         */
        if ((inst->src_ipaddr.af != AF_UNSPEC) &&
            (inst->src_ipaddr.af != inst->ipaddr.af)) {
-               cf_log_err(cs, "Both 'ipaddr' and 'src_ipaddr' must be from the same address family");
+               cf_log_err(conf, "Both 'ipaddr' and 'src_ipaddr' must be from the same address family");
                return -1;
        }
 
@@ -705,13 +706,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                struct servent *s;
 
                if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'udp' section");
+                       cf_log_err(conf, "No 'port' was specified in the 'udp' section");
                        return -1;
                }
 
                s = getservbyname(inst->port_name, "udp");
                if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
                        return -1;
                }
 
@@ -723,8 +724,8 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         *      If we're listening for broadcast requests, we MUST
         */
        if (inst->broadcast && !inst->interface) {
-               cf_log_warn(cs, "You SHOULD set 'interface' if you have set 'broadcast = yes'.");
-               cf_log_warn(cs, "All replies will be broadcast, as ARP updates require 'interface' to be set.");
+               cf_log_warn(conf, "You SHOULD set 'interface' if you have set 'broadcast = yes'.");
+               cf_log_warn(conf, "All replies will be broadcast, as ARP updates require 'interface' to be set.");
        }
 #endif
 
@@ -735,13 +736,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        num = talloc_array_length(inst->allow);
        if (!num) {
                if (inst->dynamic_clients) {
-                       cf_log_err(cs, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
+                       cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
                        return -1;
                }
        } else {
                inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
                if (!inst->trie) {
-                       cf_log_perr(cs, "Failed creating list of networks");
+                       cf_log_perr(conf, "Failed creating list of networks");
                        return -1;
                }
        }
@@ -762,7 +763,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
                inst->clients = client_list_parse_section(server_cs, IPPROTO_UDP, false);
                if (!inst->clients) {
-                       cf_log_err(cs, "Failed creating local clients");
+                       cf_log_err(conf, "Failed creating local clients");
                        return -1;
                }
        }
@@ -801,13 +802,14 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in
 }
 
 fr_app_io_t proto_dhcpv4_udp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "dhcpv4_udp",
-       .config                 = udp_listen_config,
-       .inst_size              = sizeof(proto_dhcpv4_udp_t),
-       .thread_inst_size       = sizeof(proto_dhcpv4_udp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "dhcpv4_udp",
+               .config                 = udp_listen_config,
+               .inst_size              = sizeof(proto_dhcpv4_udp_t),
+               .thread_inst_size       = sizeof(proto_dhcpv4_udp_thread_t),
+               .bootstrap              = mod_bootstrap,
+       },
        .default_message_size   = 4096,
        .track_duplicates       = true,
 
index dc4c0da563c03ea53a11d60c168d2ba88c6f042a..5f35c47d93dfdb658f0b52c8c919689e1c9e35ba 100644 (file)
@@ -396,15 +396,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_dhcpv6_t          *inst = talloc_get_type_abort(instance, proto_dhcpv6_t);
+       proto_dhcpv6_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv6_t);
 
        /*
         *      No IO module, it's an empty listener.
@@ -428,27 +426,25 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 /** 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_dhcpv6_t          *inst = talloc_get_type_abort(instance, proto_dhcpv6_t);
+       proto_dhcpv6_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv6_t);
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(conf));
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->data));
 
        fr_assert(dict_dhcpv6 != NULL);
        fr_assert(attr_packet_type != NULL);
@@ -485,7 +481,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 static int mod_load(void)
@@ -504,17 +500,18 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_dhcpv6 = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "dhcpv6",
-       .config                 = proto_dhcpv6_config,
-       .inst_size              = sizeof(proto_dhcpv6_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "dhcpv6",
+               .config                 = proto_dhcpv6_config,
+               .inst_size              = sizeof(proto_dhcpv6_t),
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_dhcpv6,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 3a02949cf24d172275e8ae7ba69051edb4c2057a..50808ef32e8dc5d10f4e7e6f28d21d2b1d671dd5 100644 (file)
@@ -453,22 +453,23 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_dhcpv6_udp_t      *inst = talloc_get_type_abort(instance, proto_dhcpv6_udp_t);
+       proto_dhcpv6_udp_t      *inst = talloc_get_type_abort(mctx->inst->data, proto_dhcpv6_udp_t);
        size_t                  num;
        CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
        RADCLIENT               *client;
+       CONF_SECTION            *conf = mctx->inst->conf;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
                if (!inst->interface) {
-                       cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
+                       cf_log_err(conf, "No 'ipaddr' was specified in the 'udp' section");
                        return -1;
                }
 
@@ -479,14 +480,14 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                 */
                if (inst->interface &&
                    (fr_interface_to_ipaddr(inst->interface, &inst->ipaddr, AF_INET6, true) < 0)) {
-                       cf_log_err(cs, "No 'ipaddr' specified, and we cannot determine one for interface '%s'",
+                       cf_log_err(conf, "No 'ipaddr' specified, and we cannot determine one for interface '%s'",
                                   inst->interface);
                                return -1;
                }
        }
 
        if (inst->ipaddr.af != AF_INET6) {
-               cf_log_err(cs, "DHCPv6 cannot use IPv4 for 'ipaddr'");
+               cf_log_err(conf, "DHCPv6 cannot use IPv4 for 'ipaddr'");
                return -1;
        }
 
@@ -512,7 +513,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                                inst->interface = fr_ipaddr_to_interface(inst, &inst->ipaddr);
                                if (!inst->interface) {
                                interface_fail:
-                                       cf_log_err(cs, "No 'interface' specified, and we cannot "
+                                       cf_log_err(conf, "No 'interface' specified, and we cannot "
                                                   "determine one for 'ipaddr = %pV'",
                                                   fr_box_ipaddr(inst->ipaddr));
                                        return -1;
@@ -526,7 +527,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        if (!inst->interface) goto interface_fail;
 
                        if (fr_interface_to_ipaddr(inst->interface, &inst->src_ipaddr, AF_INET6, true) < 0) {
-                               cf_log_err(cs, "No 'src_ipaddr' specified, and we cannot determine "
+                               cf_log_err(conf, "No 'src_ipaddr' specified, and we cannot determine "
                                           "one for 'ipaddr = %pV and interface '%s'",
                                           fr_box_ipaddr(inst->ipaddr), inst->interface);
                                return -1;
@@ -538,7 +539,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         *      src_ipaddr must be of the same address family as "ipaddr"
         */
        if (inst->src_ipaddr.af != inst->ipaddr.af) {
-               cf_log_err(cs, "Both 'ipaddr' and 'src_ipaddr' must be from the same address family");
+               cf_log_err(conf, "Both 'ipaddr' and 'src_ipaddr' must be from the same address family");
                return -1;
        }
 
@@ -560,13 +561,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                struct servent *s;
 
                if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'udp' section");
+                       cf_log_err(conf, "No 'port' was specified in the 'udp' section");
                        return -1;
                }
 
                s = getservbyname(inst->port_name, "udp");
                if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
                        return -1;
                }
 
@@ -580,14 +581,14 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        num = talloc_array_length(inst->allow);
        if (!num) {
                if (inst->dynamic_clients) {
-                       cf_log_err(cs, "The 'allow' subsection MUST contain at least one 'network' entry when "
+                       cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when "
                                   "'dynamic_clients = true'.");
                        return -1;
                }
        } else {
                inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
                if (!inst->trie) {
-                       cf_log_perr(cs, "Failed creating list of networks");
+                       cf_log_perr(conf, "Failed creating list of networks");
                        return -1;
                }
        }
@@ -608,7 +609,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
                inst->clients = client_list_parse_section(server_cs, IPPROTO_UDP, false);
                if (!inst->clients) {
-                       cf_log_err(cs, "Failed creating local clients");
+                       cf_log_err(conf, "Failed creating local clients");
                        return -1;
                }
        }
@@ -649,13 +650,14 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in
 }
 
 fr_app_io_t proto_dhcpv6_udp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "dhcpv6_udp",
-       .config                 = udp_listen_config,
-       .inst_size              = sizeof(proto_dhcpv6_udp_t),
-       .thread_inst_size       = sizeof(proto_dhcpv6_udp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "dhcpv6_udp",
+               .config                 = udp_listen_config,
+               .inst_size              = sizeof(proto_dhcpv6_udp_t),
+               .thread_inst_size       = sizeof(proto_dhcpv6_udp_thread_t),
+               .bootstrap              = mod_bootstrap
+       },
        .default_message_size   = 4096,
        .track_duplicates       = true,
 
index 780799698809fdeae6fa8f162624db9123ce3ce9..94f19a6645bb852fdd7ae034d146a2e0cf494150 100644 (file)
@@ -347,15 +347,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_dns_t             *inst = talloc_get_type_abort(instance, proto_dns_t);
+       proto_dns_t             *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_t);
 
        /*
         *      No IO module, it's an empty listener.
@@ -379,27 +377,25 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 /** 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_dns_t             *inst = talloc_get_type_abort(instance, proto_dns_t);
+       proto_dns_t             *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_t);
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(conf));
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->data));
 
        fr_assert(dict_dns != NULL);
        fr_assert(attr_packet_type != NULL);
@@ -430,7 +426,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 static int mod_load(void)
@@ -449,17 +445,19 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_dns = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "dns",
-       .config                 = proto_dns_config,
-       .inst_size              = sizeof(proto_dns_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "dns",
+               .config                 = proto_dns_config,
+               .inst_size              = sizeof(proto_dns_t),
+
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_dns,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 3b15303eb4ed77518e9ab668817c298b827dc3e1..13c75758e136469e24d9aebf68206d47847623ee 100644 (file)
@@ -334,22 +334,23 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_dns_udp_t *inst = talloc_get_type_abort(instance, proto_dns_udp_t);
+       proto_dns_udp_t         *inst = talloc_get_type_abort(mctx->inst->data, proto_dns_udp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  num;
        CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
        RADCLIENT               *client;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
                if (!inst->interface) {
-                       cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
+                       cf_log_err(conf, "No 'ipaddr' was specified in the 'udp' section");
                        return -1;
                }
 
@@ -360,7 +361,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                 */
                if (inst->interface &&
                    (fr_interface_to_ipaddr(inst->interface, &inst->ipaddr, AF_INET, true) < 0)) {
-                       cf_log_err(cs, "No 'ipaddr' specified, and we cannot determine one for interface '%s'",
+                       cf_log_err(conf, "No 'ipaddr' specified, and we cannot determine one for interface '%s'",
                                   inst->interface);
                                return -1;
                }
@@ -382,7 +383,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (num) {
                inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
                if (!inst->trie) {
-                       cf_log_perr(cs, "Failed creating list of networks");
+                       cf_log_perr(conf, "Failed creating list of networks");
                        return -1;
                }
        }
@@ -403,7 +404,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
                inst->clients = client_list_parse_section(server_cs, IPPROTO_UDP, false);
                if (!inst->clients) {
-                       cf_log_err(cs, "Failed creating local clients");
+                       cf_log_err(conf, "Failed creating local clients");
                        return -1;
                }
        }
@@ -444,13 +445,14 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in
 }
 
 fr_app_io_t proto_dns_udp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "dns_udp",
-       .config                 = udp_listen_config,
-       .inst_size              = sizeof(proto_dns_udp_t),
-       .thread_inst_size       = sizeof(proto_dns_udp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "dns_udp",
+               .config                 = udp_listen_config,
+               .inst_size              = sizeof(proto_dns_udp_t),
+               .thread_inst_size       = sizeof(proto_dns_udp_thread_t),
+               .bootstrap              = mod_bootstrap
+       },
        .default_message_size   = 576,
        .track_duplicates       = false,
 
index 1de8c442832404047891d5629ddba38ff837e6d9..481e77f8209ad31223f6b711d516d6b8a5a819c6 100644 (file)
@@ -244,15 +244,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate I/O and type submodules.
  *
- * @param[in] instance Ctx data for this application.
- * @param[in] conf     Listen section parsed to give us isntance.
  * @return
  *     - 0 on success.
  *     - -1 on failure.
  */
-static int mod_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_load_t            *inst = talloc_get_type_abort(instance, proto_load_t);
+       proto_load_t            *inst = talloc_get_type_abort(mctx->inst->data, proto_load_t);
 
        fr_assert(inst->io.submodule);
 
@@ -273,22 +271,21 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 /** 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_load_t            *inst = talloc_get_type_abort(instance, proto_load_t);
+       proto_load_t            *inst = talloc_get_type_abort(mctx->inst->data, proto_load_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
@@ -316,7 +313,6 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        inst->cs = conf;
        inst->self = &proto_load;
 
-       virtual_server_dict_set(inst->server_cs, inst->dict, false);
 
        /*
         *      We will need this for dynamic clients and connected sockets.
@@ -327,18 +323,20 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
 fr_app_t proto_load = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "load",
-       .config                 = proto_load_config,
-       .inst_size              = sizeof(proto_load_t),
-
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "load",
+               .config                 = proto_load_config,
+               .inst_size              = sizeof(proto_load_t),
+
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 2e47bfd1d6918437f82c1ea3809d6749fe88c335..cbbcb93dbc391cdcdf8c64a1d102c1bd92924c48 100644 (file)
@@ -343,9 +343,10 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_load_step_t       *inst = talloc_get_type_abort(instance, proto_load_step_t);
+       proto_load_step_t       *inst = talloc_get_type_abort(mctx->inst->data, proto_load_step_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        dl_module_inst_t const  *dl_inst;
 
        /*
@@ -353,12 +354,11 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
         *      so we can find out what the parent of our instance
         *      was.
         */
-       dl_inst = dl_module_instance_by_data(instance);
+       dl_inst = dl_module_instance_by_data(inst);
        fr_assert(dl_inst);
 
        inst->parent = talloc_get_type_abort(dl_inst->parent->data, proto_load_t);
-
-       inst->cs = cs;
+       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);
@@ -390,9 +390,10 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipa
 }
 
 
-static int mod_instantiate(void *instance, CONF_SECTION *cs)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_load_step_t       *inst = talloc_get_type_abort(instance, proto_load_step_t);
+       proto_load_step_t       *inst = talloc_get_type_abort(mctx->inst->data, proto_load_step_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        RADCLIENT               *client;
        fr_pair_t               *vp;
 
@@ -414,13 +415,13 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs)
 
                fp = fopen(inst->filename, "r");
                if (!fp) {
-                       cf_log_err(cs, "Failed opening %s - %s",
+                       cf_log_err(conf, "Failed opening %s - %s",
                                   inst->filename, fr_syserror(errno));
                        return -1;
                }
 
                if (fr_pair_list_afrom_file(inst, inst->parent->dict, &inst->pair_list, fp, &done) < 0) {
-                       cf_log_perr(cs, "Failed reading %s", inst->filename);
+                       cf_log_perr(conf, "Failed reading %s", inst->filename);
                        fclose(fp);
                        return -1;
                }
@@ -435,14 +436,15 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs)
 }
 
 fr_app_io_t proto_load_step = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "load_step",
-       .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,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "load_step",
+               .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,
        .track_duplicates       = false,
 
index b9b34a1e63fcf3b7181fb6a3abe28aa5733c7149..c1e36a7a281dee9612ff65cd309cbcf1b1609051 100644 (file)
@@ -476,15 +476,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_radius_t          *inst = talloc_get_type_abort(instance, proto_radius_t);
+       proto_radius_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_radius_t);
 
        /*
         *      No IO module, it's an empty listener.
@@ -508,7 +506,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
@@ -516,20 +514,18 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_radius_t          *inst = talloc_get_type_abort(instance, proto_radius_t);
+       proto_radius_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_radius_t);
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(conf));
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->conf));
 
        /*
         *      No IO module, it's an empty listener.
@@ -572,7 +568,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 static int mod_load(void)
@@ -590,16 +586,17 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_radius = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "radius",
-       .config                 = proto_radius_config,
-       .inst_size              = sizeof(proto_radius_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "radius",
+               .config                 = proto_radius_config,
+               .inst_size              = sizeof(proto_radius_t),
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_radius,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index 25043961ad483af55ff5bbdedae76577e51754c7..a9f6c6400a39351d6931fdadb4817c9f57083b5f 100644 (file)
@@ -381,18 +381,19 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_radius_tcp_t      *inst = talloc_get_type_abort(instance, proto_radius_tcp_t);
+       proto_radius_tcp_t      *inst = talloc_get_type_abort(mctx->inst->data, proto_radius_tcp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  i, num;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
-               cf_log_err(cs, "No 'ipaddr' was specified in the 'tcp' section");
+               cf_log_err(conf, "No 'ipaddr' was specified in the 'tcp' section");
                return -1;
        }
 
@@ -408,13 +409,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                struct servent *s;
 
                if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'tcp' section");
+                       cf_log_err(conf, "No 'port' was specified in the 'tcp' section");
                        return -1;
                }
 
                s = getservbyname(inst->port_name, "tcp");
                if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
                        return -1;
                }
 
@@ -432,7 +433,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        num = talloc_array_length(inst->allow);
        if (!num) {
                if (inst->dynamic_clients) {
-                       cf_log_err(cs, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
+                       cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
                        return -1;
                }
        } else {
@@ -445,7 +446,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                         *      Can't add v4 networks to a v6 socket, or vice versa.
                         */
                        if (inst->allow[i].af != inst->ipaddr.af) {
-                               cf_log_err(cs, "Address family in entry %zd - 'allow = %pV' does not match 'ipaddr'",
+                               cf_log_err(conf, "Address family in entry %zd - 'allow = %pV' does not match 'ipaddr'",
                                           i + 1, fr_box_ipaddr(inst->allow[i]));
                                return -1;
                        }
@@ -456,7 +457,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        network = fr_trie_match_by_key(inst->trie,
                                                &inst->allow[i].addr, inst->allow[i].prefix);
                        if (network) {
-                               cf_log_err(cs, "Cannot add duplicate entry 'allow = %pV'",
+                               cf_log_err(conf, "Cannot add duplicate entry 'allow = %pV'",
                                           fr_box_ipaddr(inst->allow[i]));
                                return -1;
                        }
@@ -475,9 +476,9 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        network = fr_trie_lookup_by_key(inst->trie,
                                                 &inst->allow[i].addr, inst->allow[i].prefix);
                        if (network && (network->prefix <= inst->allow[i].prefix)) {
-                               cf_log_err(cs, "Cannot add overlapping entry 'allow = %pV'",
+                               cf_log_err(conf, "Cannot add overlapping entry 'allow = %pV'",
                                           fr_box_ipaddr(inst->allow[i]));
-                               cf_log_err(cs, "Entry is completely enclosed inside of a previously defined network");
+                               cf_log_err(conf, "Entry is completely enclosed inside of a previously defined network");
                                return -1;
                        }
 
@@ -489,7 +490,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        if (fr_trie_insert_by_key(inst->trie,
                                           &inst->allow[i].addr, inst->allow[i].prefix,
                                           &inst->allow[i]) < 0) {
-                               cf_log_err(cs, "Failed adding 'allow = %pV' to tracking table",
+                               cf_log_err(conf, "Failed adding 'allow = %pV' to tracking table",
                                           fr_box_ipaddr(inst->allow[i]));
                                return -1;
                        }
@@ -512,7 +513,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                         *      Can't add v4 networks to a v6 socket, or vice versa.
                         */
                        if (inst->deny[i].af != inst->ipaddr.af) {
-                               cf_log_err(cs, "Address family in entry %zd - 'deny = %pV' does not match 'ipaddr'",
+                               cf_log_err(conf, "Address family in entry %zd - 'deny = %pV' does not match 'ipaddr'",
                                           i + 1, fr_box_ipaddr(inst->deny[i]));
                                return -1;
                        }
@@ -523,7 +524,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        network = fr_trie_match_by_key(inst->trie,
                                                &inst->deny[i].addr, inst->deny[i].prefix);
                        if (network) {
-                               cf_log_err(cs, "Cannot add duplicate entry 'deny = %pV'", fr_box_ipaddr(inst->deny[i]));
+                               cf_log_err(conf, "Cannot add duplicate entry 'deny = %pV'", fr_box_ipaddr(inst->deny[i]));
                                return -1;
                        }
 
@@ -533,7 +534,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        network = fr_trie_lookup_by_key(inst->trie,
                                                &inst->deny[i].addr, inst->deny[i].prefix);
                        if (!network) {
-                               cf_log_err(cs, "The network in entry %zd - 'deny = %pV' is not contained "
+                               cf_log_err(conf, "The network in entry %zd - 'deny = %pV' is not contained "
                                           "within a previous 'allow'", i + 1, fr_box_ipaddr(inst->deny[i]));
                                return -1;
                        }
@@ -544,7 +545,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                         *      adding a "deny" inside of a "deny".
                         */
                        if (network->af != inst->ipaddr.af) {
-                               cf_log_err(cs, "The network in entry %zd - 'deny = %pV' overlaps with "
+                               cf_log_err(conf, "The network in entry %zd - 'deny = %pV' overlaps with "
                                           "another 'deny' rule", i + 1, fr_box_ipaddr(inst->deny[i]));
                                return -1;
                        }
@@ -557,7 +558,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                        if (fr_trie_insert_by_key(inst->trie,
                                           &inst->deny[i].addr, inst->deny[i].prefix,
                                           &inst->deny[i]) < 0) {
-                               cf_log_err(cs, "Failed adding 'deny = %pV' to tracking table",
+                               cf_log_err(conf, "Failed adding 'deny = %pV' to tracking table",
                                           fr_box_ipaddr(inst->deny[i]));
                                return -1;
                        }
@@ -578,13 +579,14 @@ static RADCLIENT *mod_client_find(UNUSED fr_listen_t *li, fr_ipaddr_t const *ipa
 }
 
 fr_app_io_t proto_radius_tcp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "radius_tcp",
-       .config                 = tcp_listen_config,
-       .inst_size              = sizeof(proto_radius_tcp_t),
-       .thread_inst_size       = sizeof(proto_radius_tcp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "radius_tcp",
+               .config                 = tcp_listen_config,
+               .inst_size              = sizeof(proto_radius_tcp_t),
+               .thread_inst_size       = sizeof(proto_radius_tcp_thread_t),
+               .bootstrap              = mod_bootstrap,
+       },
        .default_message_size   = 4096,
 
        .open                   = mod_open,
index 883b14188fd7adb7498af7beac88aabb7d5b8e42..0169d414025ed1932ed5d39d9391406757641295 100644 (file)
@@ -579,20 +579,21 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_radius_udp_t      *inst = talloc_get_type_abort(instance, proto_radius_udp_t);
+       proto_radius_udp_t      *inst = talloc_get_type_abort(mctx->inst->data, proto_radius_udp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  num;
        CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
-               cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
+               cf_log_err(conf, "No 'ipaddr' was specified in the 'udp' section");
                return -1;
        }
 
@@ -613,13 +614,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                struct servent *s;
 
                if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'udp' section");
+                       cf_log_err(conf, "No 'port' was specified in the 'udp' section");
                        return -1;
                }
 
                s = getservbyname(inst->port_name, "udp");
                if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
                        return -1;
                }
 
@@ -633,13 +634,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        num = talloc_array_length(inst->allow);
        if (!num) {
                if (inst->dynamic_clients) {
-                       cf_log_err(cs, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
+                       cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
                        return -1;
                }
        } else {
                inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
                if (!inst->trie) {
-                       cf_log_perr(cs, "Failed creating list of networks");
+                       cf_log_perr(conf, "Failed creating list of networks");
                        return -1;
                }
        }
@@ -660,7 +661,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
                inst->clients = client_list_parse_section(server_cs, IPPROTO_UDP, false);
                if (!inst->clients) {
-                       cf_log_err(cs, "Failed creating local clients");
+                       cf_log_err(conf, "Failed creating local clients");
                        return -1;
                }
        }
@@ -685,13 +686,14 @@ static RADCLIENT *mod_client_find(fr_listen_t *li, fr_ipaddr_t const *ipaddr, in
 }
 
 fr_app_io_t proto_radius_udp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "radius_udp",
-       .config                 = udp_listen_config,
-       .inst_size              = sizeof(proto_radius_udp_t),
-       .thread_inst_size       = sizeof(proto_radius_udp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "radius_udp",
+               .config                 = udp_listen_config,
+               .inst_size              = sizeof(proto_radius_udp_t),
+               .thread_inst_size       = sizeof(proto_radius_udp_thread_t),
+               .bootstrap              = mod_bootstrap
+       },
        .default_message_size   = 4096,
        .track_duplicates       = true,
 
index 3c926a4775da74909c4ae77191d4a962b02505eb..2cf64ea61731c23e8740341cc12dfa603bb92f14 100644 (file)
@@ -457,15 +457,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_tacacs_t          *inst = talloc_get_type_abort(instance, proto_tacacs_t);
+       proto_tacacs_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_tacacs_t);
 
        /*
         *      No IO module, it's an empty listener.
@@ -489,7 +487,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
@@ -497,20 +495,18 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_tacacs_t          *inst = talloc_get_type_abort(instance, proto_tacacs_t);
+       proto_tacacs_t          *inst = talloc_get_type_abort(mctx->inst->data, proto_tacacs_t);
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(conf));
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->inst->conf));
 
        fr_assert(dict_tacacs != NULL);
 
@@ -543,7 +539,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 static int mod_load(void)
@@ -562,16 +558,18 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_tacacs = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "tacacs",
-       .config                 = proto_tacacs_config,
-       .inst_size              = sizeof(proto_tacacs_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "tacacs",
+               .config                 = proto_tacacs_config,
+               .inst_size              = sizeof(proto_tacacs_t),
+
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_tacacs,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index e73f2c7a9eaed3ad9be9ec829cef9e55a55294fc..a0a62ebcf6bfd26d1d81f13049fc9cb882e6c6a2 100644 (file)
@@ -379,20 +379,21 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_tacacs_tcp_t      *inst = talloc_get_type_abort(instance, proto_tacacs_tcp_t);
+       proto_tacacs_tcp_t      *inst = talloc_get_type_abort(mctx->inst->data, proto_tacacs_tcp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  num;
        CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
-               cf_log_err(cs, "No 'ipaddr' was specified in the 'tcp' section");
+               cf_log_err(conf, "No 'ipaddr' was specified in the 'tcp' section");
                return -1;
        }
 
@@ -408,13 +409,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                struct servent *s;
 
                if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'tcp' section");
+                       cf_log_err(conf, "No 'port' was specified in the 'tcp' section");
                        return -1;
                }
 
                s = getservbyname(inst->port_name, "tcp");
                if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
                        return -1;
                }
 
@@ -428,13 +429,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        num = talloc_array_length(inst->allow);
        if (!num) {
                if (inst->dynamic_clients) {
-                       cf_log_err(cs, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
+                       cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
                        return -1;
                }
        } else {
                inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
                if (!inst->trie) {
-                       cf_log_perr(cs, "Failed creating list of networks");
+                       cf_log_perr(conf, "Failed creating list of networks");
                        return -1;
                }
        }
@@ -455,7 +456,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
                inst->clients = client_list_parse_section(server_cs, IPPROTO_TCP, false);
                if (!inst->clients) {
-                       cf_log_err(cs, "Failed creating local clients");
+                       cf_log_err(conf, "Failed creating local clients");
                        return -1;
                }
        }
@@ -469,13 +470,14 @@ static RADCLIENT *mod_client_find(UNUSED fr_listen_t *li, fr_ipaddr_t const *ipa
 }
 
 fr_app_io_t proto_tacacs_tcp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "tacacs_tcp",
-       .config                 = tcp_listen_config,
-       .inst_size              = sizeof(proto_tacacs_tcp_t),
-       .thread_inst_size       = sizeof(proto_tacacs_tcp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "tacacs_tcp",
+               .config                 = tcp_listen_config,
+               .inst_size              = sizeof(proto_tacacs_tcp_t),
+               .thread_inst_size       = sizeof(proto_tacacs_tcp_thread_t),
+               .bootstrap              = mod_bootstrap,
+       },
        .default_message_size   = 4096,
        .track_duplicates       = true,
 
index 250894cf4e1fcaf78f27a7fe17978c4b6eeae3d2..5f88ecf4524e77fd751eb0fd36871819dc250af0 100644 (file)
@@ -369,15 +369,13 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *
  * Instantiate 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_instantiate(void *instance, CONF_SECTION *conf)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
-       proto_vmps_t            *inst = talloc_get_type_abort(instance, proto_vmps_t);
+       proto_vmps_t            *inst = talloc_get_type_abort(mctx->inst->data, proto_vmps_t);
 
        /*
         *      No IO module, it's an empty listener.
@@ -401,7 +399,7 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        /*
         *      Instantiate the master io submodule
         */
-       return fr_master_app_io.instantiate(&inst->io, conf);
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 
@@ -409,15 +407,14 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
  *
  * 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)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_vmps_t            *inst = talloc_get_type_abort(instance, proto_vmps_t);
+       proto_vmps_t            *inst = talloc_get_type_abort(mctx->inst->data, proto_vmps_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
 
        /*
         *      Ensure that the server CONF_SECTION is always set.
@@ -456,7 +453,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
        /*
         *      Bootstrap the master IO handler.
         */
-       return fr_master_app_io.bootstrap(&inst->io, conf);
+       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.dl_inst));
 }
 
 static int mod_load(void)
@@ -475,16 +472,18 @@ static void mod_unload(void)
 }
 
 fr_app_t proto_vmps = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "vmps",
-       .config                 = proto_vmps_config,
-       .inst_size              = sizeof(proto_vmps_t),
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "vmps",
+               .config                 = proto_vmps_config,
+               .inst_size              = sizeof(proto_vmps_t),
+
+               .onload                 = mod_load,
+               .unload                 = mod_unload,
+               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
+       },
        .dict                   = &dict_vmps,
-
-       .onload                 = mod_load,
-       .unload                 = mod_unload,
-       .bootstrap              = mod_bootstrap,
-       .instantiate            = mod_instantiate,
        .open                   = mod_open,
        .decode                 = mod_decode,
        .encode                 = mod_encode,
index fed2f6e1fa5c5824e0500dedee574e7218fe7f29..62ee49832612f533980de203fcdb72afc9ceadee 100644 (file)
@@ -387,20 +387,21 @@ static int mod_track_compare(UNUSED void const *instance, UNUSED void *thread_in
        return (a->opcode < b->opcode) - (a->opcode > b->opcode);
 }
 
-static int mod_bootstrap(void *instance, CONF_SECTION *cs)
+static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
-       proto_vmps_udp_t        *inst = talloc_get_type_abort(instance, proto_vmps_udp_t);
+       proto_vmps_udp_t        *inst = talloc_get_type_abort(mctx->inst->data, proto_vmps_udp_t);
+       CONF_SECTION            *conf = mctx->inst->conf;
        size_t                  num;
        CONF_ITEM               *ci;
        CONF_SECTION            *server_cs;
 
-       inst->cs = cs;
+       inst->cs = conf;
 
        /*
         *      Complain if no "ipaddr" is set.
         */
        if (inst->ipaddr.af == AF_UNSPEC) {
-               cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
+               cf_log_err(conf, "No 'ipaddr' was specified in the 'udp' section");
                return -1;
        }
 
@@ -416,13 +417,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                struct servent *s;
 
                if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'udp' section");
+                       cf_log_err(conf, "No 'port' was specified in the 'udp' section");
                        return -1;
                }
 
                s = getservbyname(inst->port_name, "udp");
                if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       cf_log_err(conf, "Unknown value for 'port_name = %s", inst->port_name);
                        return -1;
                }
 
@@ -440,13 +441,13 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        num = talloc_array_length(inst->allow);
        if (!num) {
                if (inst->dynamic_clients) {
-                       cf_log_err(cs, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
+                       cf_log_err(conf, "The 'allow' subsection MUST contain at least one 'network' entry when 'dynamic_clients = true'.");
                        return -1;
                }
        } else {
                inst->trie = fr_master_io_network(inst, inst->ipaddr.af, inst->allow, inst->deny);
                if (!inst->trie) {
-                       cf_log_perr(cs, "Failed creating list of networks");
+                       cf_log_perr(conf, "Failed creating list of networks");
                        return -1;
                }
        }
@@ -467,7 +468,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
        if (cf_section_find_next(server_cs, NULL, "client", CF_IDENT_ANY)) {
                inst->clients = client_list_parse_section(server_cs, IPPROTO_UDP, false);
                if (!inst->clients) {
-                       cf_log_err(cs, "Failed creating local clients");
+                       cf_log_err(conf, "Failed creating local clients");
                        return -1;
                }
        }
@@ -502,13 +503,14 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 fr_app_io_t proto_vmps_udp = {
-       .magic                  = MODULE_MAGIC_INIT,
-       .name                   = "vmps_udp",
-       .config                 = udp_listen_config,
-       .inst_size              = sizeof(proto_vmps_udp_t),
-       .thread_inst_size       = sizeof(proto_vmps_udp_thread_t),
-       .bootstrap              = mod_bootstrap,
-
+       .common = {
+               .magic                  = MODULE_MAGIC_INIT,
+               .name                   = "vmps_udp",
+               .config                 = udp_listen_config,
+               .inst_size              = sizeof(proto_vmps_udp_t),
+               .thread_inst_size       = sizeof(proto_vmps_udp_thread_t),
+               .bootstrap              = mod_bootstrap,
+       },
        .default_message_size   = 4096,
        .track_duplicates       = true,