Coverage Report

Created: 2026-08-08 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/freeradius-server/src/freeradius-devel/server/module.h
Line
Count
Source
1
#pragma once
2
/*
3
 *  This program is free software; you can redistribute it and/or modify
4
 *  it under the terms of the GNU General Public License as published by
5
 *  the Free Software Foundation; either version 2 of the License, or
6
 *  (at your option) any later version.
7
 *
8
 *  This program is distributed in the hope that it will be useful,
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 *  GNU General Public License for more details.
12
 *
13
 *  You should have received a copy of the GNU General Public License
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16
 */
17
18
/**
19
 * $Id: b08300dbc87c7b56eb93626f33b8404877e47a26 $
20
 *
21
 * @file lib/server/module.h
22
 * @brief Interface to the FreeRADIUS module system.
23
 *
24
 * @copyright 2022 Arran Cudbard-Bell <a.cudbardb@freeradius.org>
25
 * @copyright 2013 The FreeRADIUS server project
26
 */
27
RCSIDH(modules_h, "$Id: b08300dbc87c7b56eb93626f33b8404877e47a26 $")
28
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
33
typedef struct module_s       module_t;
34
typedef struct module_state_func_table_s  module_state_func_table_t;
35
typedef struct module_method_group_s    module_method_group_t;
36
typedef struct module_method_binding_s    module_method_binding_t;
37
typedef struct module_instance_s    module_instance_t;
38
typedef struct module_thread_instance_s   module_thread_instance_t;
39
typedef struct module_list_type_s   module_list_type_t;
40
typedef struct module_list_s      module_list_t;
41
42
#include <freeradius-devel/server/module_ctx.h>
43
#include <freeradius-devel/server/rcode.h>
44
#include <freeradius-devel/server/request.h>
45
#include <freeradius-devel/unlang/interpret.h>
46
47
DIAG_OFF(attributes)
48
typedef enum CC_HINT(flag_enum) {
49
  MODULE_TYPE_THREAD_UNSAFE = (1 << 0),   //!< Module is not threadsafe.
50
              //!< Server will protect calls with mutex.
51
  MODULE_TYPE_RETRY   = (1 << 2),   //!< can handle retries
52
53
  MODULE_TYPE_DYNAMIC_UNSAFE  = (1 << 3)  //!< Instances of this module cannot be
54
              ///< created at runtime.
55
} module_flags_t;
56
DIAG_ON(attributes)
57
58
/** Module section callback
59
 *
60
 * Is called when the module is listed in a particular section of a virtual
61
 * server, and the request has reached the module call.
62
 *
63
 * @param[out] p_result   Result code of the module method.
64
 * @param[in] mctx    Holds global instance data, thread instance
65
 *        data and call specific instance data.
66
 * @param[in] request   to process.
67
 * @return the appropriate rcode.
68
 */
69
typedef unlang_action_t (*module_method_t)(unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request);
70
71
/** Module instantiation callback
72
 *
73
 * Is called once per module instance. Is not called when new threads are
74
 * spawned. See module_thread_instantiate_t for that.
75
 *
76
 * @param[in] mctx    Holds global instance data.
77
 * @return
78
 *  - 0 on success.
79
 *  - -1 if instantiation failed.
80
 */
81
typedef int (*module_instantiate_t)(module_inst_ctx_t const *mctx);
82
83
/** Module detach callback
84
 *
85
 * Is called just before the server exits, and after re-instantiation on HUP,
86
 * to free the old module instance.
87
 *
88
 * Detach should close all handles associated with the module instance, and
89
 * free any memory allocated during instantiate.
90
 *
91
 * @param[in] inst to free.
92
 * @return
93
 *  - 0 on success.
94
 *  - -1 if detach failed.
95
 */
96
typedef int (*module_detach_t)(module_detach_ctx_t const *inst);
97
98
/** Module thread creation callback
99
 *
100
 * Called whenever a new thread is created.
101
 *
102
 * @param[in] mctx    Holds global instance data, thread instance
103
 *        data, and the thread-specific event list.
104
 * @return
105
 *  - 0 on success.
106
 *  - -1 if instantiation failed.
107
 */
108
typedef int (*module_thread_instantiate_t)(module_thread_inst_ctx_t const *mctx);
109
110
/** Module thread destruction callback
111
 *
112
 * Destroy a module/thread instance.
113
 *
114
 * @param[in] mctx    Holds global instance data, thread instance
115
 *        data, and the thread-specific event list.
116
 * @return
117
 *  - 0 on success.
118
 *  - -1 if instantiation failed.
119
 */
120
typedef int (*module_thread_detach_t)(module_thread_inst_ctx_t const *mctx);
121
122
#ifdef __cplusplus
123
}
124
#endif
125
126
#include <freeradius-devel/features.h>
127
#include <freeradius-devel/io/schedule.h>
128
129
#include <freeradius-devel/server/cf_util.h>
130
#include <freeradius-devel/server/dl_module.h>
131
#include <freeradius-devel/server/exfile.h>
132
#include <freeradius-devel/server/pool.h>
133
#include <freeradius-devel/server/request.h>
134
#include <freeradius-devel/server/section.h>
135
136
#include <freeradius-devel/unlang/action.h>
137
#include <freeradius-devel/unlang/call_env.h>
138
#include <freeradius-devel/unlang/mod_action.h>
139
140
#include <freeradius-devel/util/event.h>
141
142
#ifdef __cplusplus
143
extern "C" {
144
#endif
145
146
/** The maximum size of a module instance
147
 */
148
0
#define MODULE_INSTANCE_LEN_MAX 256
149
150
/** Terminate a module binding list
151
 */
152
#define MODULE_BINDING_TERMINATOR { .section = NULL }
153
154
/** A group of methods exported by a module or added as an overlay
155
 *
156
 * Module method groups are organised into a linked list, with each group
157
 * containing a list of named methods.  This allows common collections of
158
 * methods to be added to a module.
159
 *
160
 * One common use case is adding the `instantiate`, `exists`, and `detach`
161
 * methods which are added to dynamic modules, and allow dynamic module
162
 * instances to be created and destroyed at runtime.
163
 */
164
struct module_method_group_s {
165
  module_method_binding_t     *bindings;    //!< named methods
166
167
  bool          validated;    //!< Set to true by #module_method_group_validate.
168
  module_method_group_t     *next;      //!< Next group in the list.
169
};
170
171
/** Named methods exported by a module
172
 *
173
 */
174
struct module_method_binding_s {
175
  section_name_t const      *section;   //!< Identifier for a section.
176
177
  module_method_t       method;     //!< Module method to call
178
  call_env_method_t const     *method_env;    //!< Method specific call_env.
179
180
  size_t          rctx_size;    //!< If set, this overrides the module_t rctx_size.
181
                  ///< Instructs the module instruction to pre-allocate
182
                  ///< an rctx (available in mctx->rctx) before the module
183
                  ///< method is called.
184
  char const        *rctx_type;   //!< If rctx_size is used from the mmb, this sets the
185
                  ///< type of the rctx.
186
187
  fr_dlist_head_t       same_name1;   //!< List of bindings with the same name1.  Only initialised
188
                  ///< for the first name1 binding.
189
                  ///< DO NOT INITIALISE IN THE MODULE.
190
  fr_dlist_t        entry;      //!< Linked list of bindings with the same name1.
191
                  ///< Allows us to more quickly iterate over all
192
                  ///< name2 entries after finding a matching name1.
193
                  ///< This is also temporarily used to verify the ordering
194
                  ///< of name bindings.
195
                  ///< DO NOT INITIALISE IN THE MODULE.
196
};
197
198
/** Struct exported by a rlm_* module
199
 *
200
 * Determines the capabilities of the module, and maps internal functions
201
 * within the module to different sections.
202
 */
203
struct module_s {
204
  DL_MODULE_COMMON;         //!< Common fields for all loadable modules.
205
206
  conf_parser_t const   *config;    //!< How to convert a CONF_SECTION to a module instance.
207
  fr_dict_t const     **dict;     //!< _required_ dictionary for this module.
208
209
  size_t        boot_size;    //!< Size of the module's bootstrap data.
210
  char const      *boot_type;   //!< talloc type to assign to bootstrap data.
211
212
  size_t        inst_size;    //!< Size of the module's instance data.
213
  char const      *inst_type;   //!< talloc type to assign to instance data.
214
215
  module_instantiate_t    bootstrap;    //!< Callback to allow the module to register any global
216
                ///< resources like xlat functions and attributes.
217
                ///< Instance data is read only during the bootstrap phase
218
                ///< and MUST NOT be modified.
219
                ///< Any attributes added during this phase that the module
220
                ///< need to be re-resolved during the instantiation phase
221
                ///< so that dynamic modules (which don't run bootstrap)
222
                ///< work correctly.
223
                ///< @note Not modifying the instance data is not just a
224
                ///< suggestion, if you try, you'll generate a SIGBUS
225
                ///< or SIGSEGV and it won't be obvious why.
226
227
  module_instantiate_t    instantiate;    //!< Callback to allow the module to register any
228
                ///< per-instance resources like sockets and file handles.
229
                ///< After instantiate completes the module instance data
230
                ///< is mprotected to prevent modification.
231
232
  module_detach_t     detach;     //!< Clean up module resources from the instantiation phases.
233
234
  module_detach_t     unstrap;    //!< Clean up module resources from both the bootstrap phase.
235
236
  module_flags_t      flags;      //!< Flags that control how a module starts up and how
237
                ///< a module is called.
238
239
  module_thread_instantiate_t thread_instantiate; //!< Callback to populate a new module thread instance data.
240
                ///< Called once per thread.
241
  module_thread_detach_t    thread_detach;    //!< Callback to free thread-specific resources associated
242
                ///!< with a module.
243
244
  module_thread_instantiate_t coord_attach;   //!< Callback to attach a worker to a coordinator.
245
246
  size_t        thread_inst_size; //!< Size of the module's thread-specific instance data.
247
  char const      *thread_inst_type;  //!< talloc type to assign to thread instance data.
248
249
  size_t        rctx_size;    //!< Size of the module's thread-specific data.
250
  char const      *rctx_type;   //!< talloc type to assign to thread instance data.
251
};
252
253
#define TALLOCED_TYPE(_field, _ctype) \
254
  ._field##_size = sizeof(_ctype), ._field##_type = #_ctype
255
256
#define MODULE_BOOT(_ctype) TALLOCED_TYPE(boot, _ctype)
257
#define MODULE_INST(_ctype) TALLOCED_TYPE(inst, _ctype)
258
#define MODULE_THREAD_INST(_ctype) TALLOCED_TYPE(thread_inst, _ctype)
259
#define MODULE_RCTX(_ctype) TALLOCED_TYPE(rctx, _ctype)
260
261
/** What state the module instance is currently in
262
 *
263
 */
264
DIAG_OFF(attributes)
265
typedef enum CC_HINT(flag_enum) {
266
  MODULE_INSTANCE_BOOTSTRAPPED    = (1 << 1), //!< Module instance has been bootstrapped, but not
267
                ///< yet instantiated.
268
  MODULE_INSTANCE_INSTANTIATED    = (1 << 2), //!< Module instance has been bootstrapped and
269
                ///< instantiated.
270
  MODULE_INSTANCE_NO_THREAD_INSTANTIATE = (1 << 3)  //!< Not set internally, but can be used to prevent
271
                ///< thread instantiation for certain modules.
272
} module_instance_state_t;
273
DIAG_ON(attributes)
274
275
typedef struct {
276
  TALLOC_CTX      *ctx;   //!< ctx data is allocated in.
277
  void        *start;   //!< Start address which may be passed to mprotect.
278
  size_t        len;    //!< How much data we need mprotect to protect.
279
} module_data_pool_t;
280
281
/** Module instance data
282
 *
283
 * Per-module-instance data structure to correlate the modules with the
284
 * instance names (may NOT be the module names!), and the per-instance
285
 * data structures.
286
 */
287
struct module_instance_s {
288
       /** @name Fields that are most frequently accessed at runtime
289
  *
290
  * Putting them first gives us the greatest chance of the pointers being prefetched.
291
  * @{
292
  */
293
  void        *data;    //!< Module's instance data.  This is most
294
              ///< frequently accessed, so comes first.
295
296
  void        *boot;    //!< Data allocated during the boostrap phase
297
298
  module_t      *exported;  //!< Public module structure.  Cached for convenience.
299
              ///< This exports module methods, i.e. the functions
300
              ///< which allow the module to perform actions.
301
              ///< This is an identical address to module->common,
302
              ///< but with a different type, containing additional
303
              ///< instance callbacks to make it easier to use.
304
305
  pthread_mutex_t     mutex;    //!< Used prevent multiple threads entering a thread
306
              ///< unsafe module simultaneously.
307
308
  dl_module_t     *module;  //!< Dynamic loader handle.  Contains the module's
309
              ///< dlhandle, and the functions it exports.
310
              ///< The dl_module is reference counted so that it
311
              ///< can be freed automatically when the last instance
312
              ///< is freed.  This will also (usually) unload the
313
              ///< .so or .dylib.
314
  /** @} */
315
316
  /** @name Return code overrides
317
   * @{
318
   */
319
  bool        force;    //!< Force the module to return a specific code.
320
              //!< Usually set via an administrative interface.
321
322
  rlm_rcode_t     code;   //!< Code module will return when 'force' has
323
              //!< has been set to true.
324
325
  unlang_mod_actions_t        actions;  //!< default actions and retries.
326
  /** @} */
327
328
       /** @name Allow module instance data to be resolved by name or data, and to get back to the module list
329
  * @{
330
  */
331
  module_list_t     *ml;    //!< Module list this instance belongs to.
332
  fr_rb_node_t      name_node;  //!< Entry in the name tree.
333
  fr_rb_node_t      data_node;  //!< Entry in the data tree.
334
  uint32_t      number;   //!< Unique module number.  Used to assign a stable
335
              ///< number to each module instance.
336
  /** @} */
337
338
       /** @name These structures allow mprotect to protect/unprotest bootstrap and instance data
339
  * @{
340
  */
341
  module_data_pool_t    inst_pool;  //!< Data to allow mprotect state toggling
342
              ///< for instance data.
343
  module_data_pool_t    boot_pool;  //!< Data to allow mprotect state toggling
344
              ///< for bootstrap data.
345
  /** @} */
346
347
       /** @name Module instance state
348
  * @{
349
  */
350
  module_instance_state_t   state;    //!< What's been done with this module so far.
351
  CONF_SECTION      *conf;    //!< Module's instance configuration.
352
  /** @} */
353
354
       /** @name Misc fields
355
  * @{
356
  */
357
  char const      *name;    //!< Instance name e.g. user_database.
358
359
  module_instance_t const   *parent;  //!< Parent module's instance (if any).
360
361
  void        *uctx;    //!< Extra data passed to module_instance_alloc.
362
  /** @} */
363
};
364
365
/** Per thread per instance data
366
 *
367
 * Stores module and thread specific data.
368
 */
369
struct module_thread_instance_s {
370
  fr_heap_index_t     inst_idx; //!< Entry in the thread-specific bootstrap heap.
371
              ///< Should be an identical value to the global
372
              ///< instance data for the same module.
373
374
  void        *data;    //!< Thread specific instance data.
375
376
  fr_event_list_t     *el;    //!< Event list associated with this thread.
377
378
  module_instance_t   *mi;    //!< As opposed to the thread local inst.
379
380
  uint64_t      total_calls;  //! total number of times we've been called
381
  uint64_t      active_callers; //! number of active callers.  i.e. number of current yields
382
};
383
384
/** Callback to retrieve thread-local data for a module
385
 *
386
 * This is public for performance reasons, and should be called through
387
 * #module_thread.
388
 *
389
 * @param[in] mi  to add data to (use mi->ml for the module list).
390
 * @return
391
 *  - NULL if no data exists.
392
 *  - Pointer to the data on success.
393
 */
394
typedef module_thread_instance_t *(*module_list_thread_data_get_t)(module_instance_t const *mi);
395
396
/** A list of modules
397
 *
398
 * This used to be a global structure, but was move to a struct.
399
 *
400
 * Module lists allow collections of modules to be created.  The module lists themselves can be configured
401
 * to be thread-local or global, with optional runtime write protection.
402
 *
403
 * Thread-local module lists are used for dynamic modules, i.e. those created at runtime, where as the
404
 * global module lists are used for backend modules, listeners, and process state machines.
405
 */
406
struct module_list_s
407
{
408
  char const      *name;      //!< Friendly list identifier.
409
  module_instance_state_t   mask;     //!< Prevent phases from being executed.
410
411
  uint32_t      last_number;    //!< Last identifier assigned to a module instance.
412
  fr_rb_tree_t      *name_tree;   //!< Modules indexed by name.
413
  fr_rb_tree_t      *data_tree;   //!< Modules indexed by data.
414
  fr_heap_t     *inst_heap;   //!< Heap of module instances.
415
416
  bool        write_protect;    //!< If true, pages containing module boot or
417
                ///< instance data will be write protected after
418
                ///< bootstrapping and instantiation is complete,
419
                ///< to prevent accidental modification.
420
421
  /** @name Callbacks to manage thread-specific data
422
   *
423
   * In "child" lists, which are only operating in a single thread, we don't need
424
   * to use true thread-local data, because the module list itself is thread-local.
425
   *
426
   * In that case these callbacks hang memory off of the list itself.
427
   *
428
   * In the main module list, which is shared between threads, these callbacks
429
   * do use true thread-local data, to manage the module_thread_instance_t
430
   * on a per thread-basis.
431
   *
432
   * @{
433
   */
434
  module_list_type_t const  *type;      //!< Type of module list.
435
  module_list_thread_data_get_t thread_data_get;  //!< Callback to get thread-specific data.
436
                ///< Copy of type->thread_data_get.
437
  /** @} */
438
};
439
440
/** Map string values to module state method
441
 *
442
 */
443
struct module_state_func_table_s {
444
  char const      *name;      //!< String identifier for state.
445
  module_method_t     func;     //!< State function.
446
};
447
448
/** @name Callbacks for the conf_parser_t
449
 *
450
 * @{
451
 */
452
int     module_submodule_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent,
453
                 CONF_ITEM *ci, UNUSED conf_parser_t const *rule) CC_HINT(warn_unused_result);
454
/** @} */
455
456
/** @name Debugging functions
457
 *
458
 * @{
459
 */
460
void module_instance_debug(module_instance_t const *mi) CC_HINT(nonnull);
461
462
void module_list_debug(module_list_t const *ml) CC_HINT(nonnull);
463
 /** @} */
464
465
/** @name Toggle protection on module instance data
466
 *
467
 * This is used for module lists which implement additional instantiation phases
468
 * (like li->open).  It should NOT be used by modules to hack around instance
469
 * data being read-only after instantiation completes.
470
 *
471
 * @{
472
 */
473
int     module_instance_data_protect(module_instance_t *mi);
474
475
int     module_instance_data_unprotect(module_instance_t *mi);
476
 /** @} */
477
478
/** @name Module and module thread lookup
479
 *
480
 * @{
481
 */
482
fr_slen_t   module_instance_name_from_conf(char const **name, CONF_SECTION *conf);
483
484
int       module_instance_conf_parse(module_instance_t *mi, CONF_SECTION *conf);
485
486
char const    *module_instance_root_prefix_str(module_instance_t const *mi) CC_HINT(nonnull) CC_HINT(warn_unused_result);
487
488
module_instance_t *module_instance_root(module_instance_t const *child) CC_HINT(warn_unused_result);
489
490
module_instance_t *module_instance_by_name(module_list_t const *ml, module_instance_t const *parent, char const *asked_name)
491
      CC_HINT(nonnull(1,3)) CC_HINT(warn_unused_result);
492
493
module_instance_t *module_instance_by_data(module_list_t const *ml, void const *data) CC_HINT(warn_unused_result);
494
495
/** Retrieve module/thread specific instance for a module
496
 *
497
 * @param[in] mi  to find thread specific data for.
498
 * @return
499
 *  - Thread specific instance data on success.
500
 *  - NULL if module has no thread instance data.
501
 */
502
static inline CC_HINT(warn_unused_result) CC_HINT(always_inline)
503
module_thread_instance_t *module_thread(module_instance_t const *mi)
504
0
{
505
0
  return mi->ml->thread_data_get(mi);
506
0
}
Unexecuted instantiation: fuzzer_cf.c:module_thread
Unexecuted instantiation: fuzzer_xlat.c:module_thread
Unexecuted instantiation: fuzzer_tmpl.c:module_thread
Unexecuted instantiation: base.c:module_thread
Unexecuted instantiation: cache.c:module_thread
Unexecuted instantiation: conf.c:module_thread
Unexecuted instantiation: ctx.c:module_thread
Unexecuted instantiation: engine.c:module_thread
Unexecuted instantiation: log.c:module_thread
Unexecuted instantiation: pairs.c:module_thread
Unexecuted instantiation: session.c:module_thread
Unexecuted instantiation: strerror.c:module_thread
Unexecuted instantiation: verify.c:module_thread
Unexecuted instantiation: virtual_server.c:module_thread
Unexecuted instantiation: auth.c:module_thread
Unexecuted instantiation: cf_file.c:module_thread
Unexecuted instantiation: cf_parse.c:module_thread
Unexecuted instantiation: client.c:module_thread
Unexecuted instantiation: connection.c:module_thread
Unexecuted instantiation: exec.c:module_thread
Unexecuted instantiation: exfile.c:module_thread
Unexecuted instantiation: global_lib.c:module_thread
Unexecuted instantiation: main_config.c:module_thread
Unexecuted instantiation: main_loop.c:module_thread
Unexecuted instantiation: map.c:module_thread
Unexecuted instantiation: map_proc.c:module_thread
Unexecuted instantiation: module.c:module_thread
Unexecuted instantiation: module_method.c:module_thread
Unexecuted instantiation: module_rlm.c:module_thread
Unexecuted instantiation: paircmp.c:module_thread
Unexecuted instantiation: pairmove.c:module_thread
Unexecuted instantiation: pool.c:module_thread
Unexecuted instantiation: state.c:module_thread
Unexecuted instantiation: tmpl_dcursor.c:module_thread
Unexecuted instantiation: tmpl_eval.c:module_thread
Unexecuted instantiation: tmpl_tokenize.c:module_thread
Unexecuted instantiation: trigger.c:module_thread
Unexecuted instantiation: trunk.c:module_thread
Unexecuted instantiation: users_file.c:module_thread
Unexecuted instantiation: util.c:module_thread
Unexecuted instantiation: virtual_servers.c:module_thread
Unexecuted instantiation: call.c:module_thread
Unexecuted instantiation: call_env.c:module_thread
Unexecuted instantiation: caller.c:module_thread
Unexecuted instantiation: catch.c:module_thread
Unexecuted instantiation: child_request.c:module_thread
Unexecuted instantiation: compile.c:module_thread
Unexecuted instantiation: condition.c:module_thread
Unexecuted instantiation: detach.c:module_thread
Unexecuted instantiation: edit.c:module_thread
Unexecuted instantiation: finally.c:module_thread
Unexecuted instantiation: foreach.c:module_thread
Unexecuted instantiation: function.c:module_thread
Unexecuted instantiation: group.c:module_thread
Unexecuted instantiation: interpret.c:module_thread
Unexecuted instantiation: interpret_synchronous.c:module_thread
Unexecuted instantiation: io.c:module_thread
Unexecuted instantiation: limit.c:module_thread
Unexecuted instantiation: load_balance.c:module_thread
Unexecuted instantiation: map_builtin.c:module_thread
Unexecuted instantiation: parallel.c:module_thread
Unexecuted instantiation: return.c:module_thread
Unexecuted instantiation: subrequest.c:module_thread
Unexecuted instantiation: switch.c:module_thread
Unexecuted instantiation: timeout.c:module_thread
Unexecuted instantiation: tmpl.c:module_thread
Unexecuted instantiation: try.c:module_thread
Unexecuted instantiation: transaction.c:module_thread
Unexecuted instantiation: xlat.c:module_thread
Unexecuted instantiation: xlat_alloc.c:module_thread
Unexecuted instantiation: xlat_builtin.c:module_thread
Unexecuted instantiation: xlat_eval.c:module_thread
Unexecuted instantiation: xlat_expr.c:module_thread
Unexecuted instantiation: xlat_func.c:module_thread
Unexecuted instantiation: xlat_inst.c:module_thread
Unexecuted instantiation: xlat_pair.c:module_thread
Unexecuted instantiation: xlat_purify.c:module_thread
Unexecuted instantiation: xlat_redundant.c:module_thread
Unexecuted instantiation: xlat_tokenize.c:module_thread
Unexecuted instantiation: json.c:module_thread
Unexecuted instantiation: jpath.c:module_thread
Unexecuted instantiation: app_io.c:module_thread
Unexecuted instantiation: coord.c:module_thread
Unexecuted instantiation: coord_pair.c:module_thread
Unexecuted instantiation: master.c:module_thread
Unexecuted instantiation: network.c:module_thread
Unexecuted instantiation: schedule.c:module_thread
Unexecuted instantiation: thread.c:module_thread
Unexecuted instantiation: worker.c:module_thread
507
508
module_thread_instance_t *module_thread_by_data(module_list_t const *ml, void const *data) CC_HINT(warn_unused_result);
509
/** @} */
510
511
/** @name Module and module thread initialisation and instantiation
512
 *
513
 * @{
514
 */
515
void      modules_thread_detach(module_list_t *ml);
516
517
int       module_thread_instantiate(TALLOC_CTX *ctx, module_instance_t *mi, fr_event_list_t *el)
518
      CC_HINT(nonnull) CC_HINT(warn_unused_result);
519
520
int     modules_thread_instantiate(TALLOC_CTX *ctx, module_list_t const *ml, fr_event_list_t *el)
521
      CC_HINT(nonnull) CC_HINT(warn_unused_result);
522
523
int     modules_coord_attach(module_list_t const *ml, fr_event_list_t *el)
524
      CC_HINT(nonnull) CC_HINT(warn_unused_result);
525
526
int     module_instantiate(module_instance_t *mi) CC_HINT(nonnull) CC_HINT(warn_unused_result);
527
528
int     modules_instantiate(module_list_t const *ml) CC_HINT(nonnull) CC_HINT(warn_unused_result);
529
530
int     module_bootstrap(module_instance_t *mi) CC_HINT(nonnull) CC_HINT(warn_unused_result);
531
532
int     modules_bootstrap(module_list_t const *ml) CC_HINT(nonnull) CC_HINT(warn_unused_result);
533
534
extern bool const module_instance_allowed_chars[SBUFF_CHAR_CLASS];
535
536
fr_slen_t   module_instance_name_valid(char const *inst_name) CC_HINT(nonnull);
537
538
module_instance_t *module_instance_copy(module_list_t *dst, module_instance_t const *src, char const *inst_name)
539
      CC_HINT(nonnull(1,2)) CC_HINT(warn_unused_result);
540
541
module_instance_t *module_instance_alloc(module_list_t *ml,
542
                 module_instance_t const *parent,
543
                 dl_module_type_t type, char const *mod_name, char const *inst_name,
544
                 module_instance_state_t init_state)
545
                 CC_HINT(nonnull(1)) CC_HINT(warn_unused_result);
546
547
void      module_instance_uctx_set(module_instance_t *mi, void *uctx);
548
549
/** @name Module list variants
550
 *
551
 * These are passed to the module_list_alloc function to allocate lists of different types
552
 *
553
 * Global module lists are used for backend modules, listeners, and process state machines.
554
 *
555
 * Thread-local lists are usually runtime instantiated variants of modules, or modules that represent client connections.
556
 *
557
 * One major difference (from the module's perspective) is that bootstrap is not called for thread-local modules.
558
 *
559
 * @{
560
 */
561
extern module_list_type_t const module_list_type_global;  //!< Initialise a global module, with thread-specific data.
562
extern module_list_type_t const module_list_type_thread_local;  //!< Initialise a thread-local module, which is only used in a single thread.
563
/** @} */
564
565
/** @name Control which phases are skipped (if any)
566
 * @{
567
 */
568
bool      module_instance_skip_bootstrap(module_instance_t *mi);
569
570
bool      module_instance_skip_instantiate(module_instance_t *mi);
571
572
bool      module_instance_skip_thread_instantiate(module_instance_t *mi);
573
574
void      module_list_mask_set(module_list_t *ml, module_instance_state_t mask);
575
/** @} */
576
577
module_list_t     *module_list_alloc(TALLOC_CTX *ctx, module_list_type_t const *type,
578
             char const *name, bool write_protect)
579
             CC_HINT(nonnull(2,3)) CC_HINT(warn_unused_result);
580
581
void      modules_init(char const *lib_dir);
582
/** @} */
583
584
#ifdef __cplusplus
585
}
586
#endif