The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
module_rlm.h
Go to the documentation of this file.
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: 7a49a8b283c6768de273a811f00eff9cb0f2227f $
20 *
21 * @file src/lib/server/module_rlm.h
22 * @brief Defines functions for rlm module (re-)initialisation.
23 *
24 * @copyright 2022,2024 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25 */
26RCSIDH(module_rlm_h, "$Id: 7a49a8b283c6768de273a811f00eff9cb0f2227f $")
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
34
35#include <freeradius-devel/server/module.h>
36#include <freeradius-devel/server/virtual_servers.h>
37
39 module_t common; //!< Common fields presented by all modules.
41};
42
44 fr_dlist_head_t xlats; //!< xlats registered to this module instance.
45 ///< This is used by the redundant/loadbalance
46 ///< xlats to register versions of the xlats
47 ///< exported by the module instances.
48};
49
50/** An xlat function registered to a module
51 */
52typedef struct {
53 xlat_t const *xlat; //!< The xlat function.
54 module_instance_t *mi; //!< The module instance that registered the xlat.
55 fr_dlist_t entry; //!< Entry in a linked list of registered xlats.
57
58/** The output of module_rlm_by_name_and_method
59 *
60 * Everything needed to call a module method.
61 */
62typedef struct {
63 module_instance_t *mi; //!< The process modules also push module calls
64 ///< onto the stack for execution. So we need
65 ///< to use the common type here.
66 module_rlm_t const *rlm; //!< Cached module_rlm_t.
67 section_name_t asked; //!< The actual <name1>.<name2> used for the module call.
68 ///< This was either the override the user specified,
69 ///< or the name of the section.
70 module_method_binding_t mmb; //!< Method we're calling.
71 tmpl_t *key; //!< Dynamic key, only set for dynamic modules.
73
75{
76 return (module_rlm_t *)module;
77}
78
79/** @name Debug functions
80 * @{
81 */
82void module_rlm_list_debug(void);
83/** @} */
84
85/** @name Convenience wrappers around other internal APIs to make them easier to instantiate with modules
86 *
87 * @{
88 */
89xlat_t *module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx,
90 char const *name, xlat_func_t func, fr_type_t return_type)
91 CC_HINT(nonnull(2,4));
92
94 void *opaque,
97 char const *log_prefix,
98 char const *trigger_prefix,
99 fr_pair_list_t *trigger_args);
100
101exfile_t *module_rlm_exfile_init(TALLOC_CTX *ctx,
102 CONF_SECTION *module,
103 uint32_t max_entries,
104 fr_time_delta_t max_idle,
105 bool locking,
106 bool triggers,
107 char const *trigger_prefix,
108 fr_pair_list_t *trigger_args);
109/** @} */
110
111/** @name Helper functions
112 *
113 * @{
114 */
115bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_da,
116 fr_dict_enum_value_t const *enumv);
117/** @} */
118
119/** @name Module and module thread lookup
120 *
121 * @{
122 */
124 virtual_server_t const *vs, section_name_t const *section, fr_sbuff_t *name,
125 tmpl_rules_t const *t_rules) CC_HINT(nonnull(5));
126
128
130
132
135/** @} */
136
137/** @name Support functions
138 *
139 * @{
140 */
141int module_rlm_submodule_parse(TALLOC_CTX *ctx, void *out, void *parent,
142 CONF_ITEM *ci, conf_parser_t const *rule);
143/** @} */
144
145/** @name Module and module thread initialisation and instantiation
146 *
147 * @{
148 */
150
151int modules_rlm_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el) CC_HINT(nonnull(2));
152
154
156
157int modules_rlm_bootstrap(CONF_SECTION *root) CC_HINT(nonnull);
158/** @} */
159
160/** @name Global initialisation and free functions
161 *
162 * @{
163 */
164int modules_rlm_free(void);
165
166int modules_rlm_init(void);
167/** @} */
168
169#ifdef __cplusplus
170}
171#endif
#define RCSIDH(h, id)
Definition build.h:513
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:606
Common header for all CONF_* types.
Definition cf_priv.h:54
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:106
Value of an enumerated attribute.
Definition dict.h:253
Head of a doubly linked list.
Definition dlist.h:51
Entry in a doubly linked list.
Definition dlist.h:41
Stores all information relating to an event list.
Definition event.c:377
fr_type_t
unsigned int uint32_t
ssize_t fr_slen_t
Temporary structure to hold arguments for instantiation calls.
Definition module_ctx.h:50
void modules_rlm_thread_detach(void)
Frees thread-specific data for all registered backend modules.
Definition module_rlm.c:970
CONF_SECTION * module_rlm_virtual_iter_init(fr_rb_iter_inorder_t *iter)
Iterate over the virtual modules.
int modules_rlm_bootstrap(CONF_SECTION *root)
Bootstrap modules and virtual modules.
module_method_group_t method_group
named methods
Definition module_rlm.h:40
exfile_t * module_rlm_exfile_init(TALLOC_CTX *ctx, CONF_SECTION *module, uint32_t max_entries, fr_time_delta_t max_idle, bool locking, bool triggers, char const *trigger_prefix, fr_pair_list_t *trigger_args)
Initialise a module specific exfile handle.
Definition module_rlm.c:105
module_instance_t * mi
The module instance that registered the xlat.
Definition module_rlm.h:54
fr_dlist_t entry
Entry in a linked list of registered xlats.
Definition module_rlm.h:55
fr_slen_t module_rlm_by_name_and_method(TALLOC_CTX *ctx, module_method_call_t *mmc_out, virtual_server_t const *vs, section_name_t const *section, fr_sbuff_t *name, tmpl_rules_t const *t_rules))
Find an existing module instance and verify it implements the specified method.
Definition module_rlm.c:550
void module_rlm_list_debug(void)
Print information on all loaded modules.
Definition module_rlm.c:84
fr_dlist_head_t xlats
xlats registered to this module instance.
Definition module_rlm.h:44
int modules_rlm_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el))
Allocates thread-specific data for all registered backend modules.
Definition module_rlm.c:983
CONF_SECTION * module_rlm_virtual_iter_next(fr_rb_iter_inorder_t *iter)
module_instance_t * mi
The process modules also push module calls onto the stack for execution.
Definition module_rlm.h:63
xlat_t const * xlat
The xlat function.
Definition module_rlm.h:53
int module_rlm_submodule_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic conf_parser_t func for loading drivers.
Definition module_rlm.c:957
CONF_SECTION * module_rlm_virtual_by_name(char const *name)
Definition module_rlm.c:799
tmpl_t * key
Dynamic key, only set for dynamic modules.
Definition module_rlm.h:71
section_name_t asked
The actual <name1>.
Definition module_rlm.h:67
int modules_rlm_coord_attach(fr_event_list_t *el)
Runs the coord_attach method of all registered backend modules.
Definition module_rlm.c:995
module_t common
Common fields presented by all modules.
Definition module_rlm.h:39
bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_da, fr_dict_enum_value_t const *enumv)
Set the next section type if it's not already set.
Definition module_rlm.c:405
fr_pool_t * module_rlm_connection_pool_init(CONF_SECTION *module, void *opaque, fr_pool_connection_create_t c, fr_pool_connection_alive_t a, char const *log_prefix, char const *trigger_prefix, fr_pair_list_t *trigger_args)
Initialise a module specific connection pool.
Definition module_rlm.c:285
module_method_binding_t mmb
Method we're calling.
Definition module_rlm.h:70
module_instance_t * module_rlm_dynamic_by_name(module_instance_t const *parent, char const *name)
Definition module_rlm.c:812
int modules_rlm_free(void)
Cleanup all global structures.
module_instance_t * module_rlm_static_by_name(module_instance_t const *parent, char const *name)
Definition module_rlm.c:817
xlat_t * module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type))
Definition module_rlm.c:234
int modules_rlm_instantiate(void)
Performs the instantiation phase for all backend modules.
int modules_rlm_init(void)
Initialise the module list structure.
module_rlm_t const * rlm
Cached module_rlm_t.
Definition module_rlm.h:66
static module_rlm_t * module_rlm_from_module(module_t *module)
Definition module_rlm.h:74
The output of module_rlm_by_name_and_method.
Definition module_rlm.h:62
An xlat function registered to a module.
Definition module_rlm.h:52
A connection pool.
Definition pool.c:85
void *(* fr_pool_connection_create_t)(TALLOC_CTX *ctx, void *opaque, fr_time_delta_t timeout)
Create a new connection handle.
Definition pool.h:111
int(* fr_pool_connection_alive_t)(void *opaque, void *connection)
Check a connection handle is still viable.
Definition pool.h:126
Iterator structure for in-order traversal of an rbtree.
Definition rb.h:319
static char const * name
Section name identifier.
Definition section.h:43
Module instance data.
Definition module.h:287
Named methods exported by a module.
Definition module.h:174
A group of methods exported by a module or added as an overlay.
Definition module.h:164
Struct exported by a rlm_* module.
Definition module.h:203
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:336
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
static fr_event_list_t * el
xlat_action_t(* xlat_func_t)(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
xlat callback function
Definition xlat.h:232
static fr_slen_t parent
Definition pair.h:858
int nonnull(2, 5))
static size_t char ** out
Definition value.h:1030