The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: c0d00984ebc7cc1959e036ae89c057e104683e80 $
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: c0d00984ebc7cc1959e036ae89c057e104683e80 $")
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 char const *trigger_prefix,
107 fr_pair_list_t *trigger_args);
108/** @} */
109
110/** @name Helper functions
111 *
112 * @{
113 */
114bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_da,
115 fr_dict_enum_value_t const *enumv);
116/** @} */
117
118/** @name Module and module thread lookup
119 *
120 * @{
121 */
123 virtual_server_t const *vs, section_name_t const *section, fr_sbuff_t *name,
124 tmpl_rules_t const *t_rules) CC_HINT(nonnull(5));
125
127
129
131/** @} */
132
133/** @name Support functions
134 *
135 * @{
136 */
137int module_rlm_submodule_parse(TALLOC_CTX *ctx, void *out, void *parent,
138 CONF_ITEM *ci, conf_parser_t const *rule);
139/** @} */
140
141/** @name Module and module thread initialisation and instantiation
142 *
143 * @{
144 */
146
147int modules_rlm_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el) CC_HINT(nonnull(2));
148
150
151int modules_rlm_bootstrap(CONF_SECTION *root) CC_HINT(nonnull);
152/** @} */
153
154/** @name Global initialisation and free functions
155 *
156 * @{
157 */
158int modules_rlm_free(void);
159
160int modules_rlm_init(void);
161/** @} */
162
163#ifdef __cplusplus
164}
165#endif
#define RCSIDH(h, id)
Definition build.h:484
Defines a CONF_PAIR to C data type mapping.
Definition cf_parse.h:579
Common header for all CONF_* types.
Definition cf_priv.h:49
A section grouping multiple CONF_PAIR.
Definition cf_priv.h:101
Value of an enumerated attribute.
Definition dict.h:227
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:411
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:963
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
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:569
void module_rlm_list_debug(void)
Print information on all loaded modules.
Definition module_rlm.c:96
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:976
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
exfile_t * module_rlm_exfile_init(TALLOC_CTX *ctx, CONF_SECTION *module, uint32_t max_entries, fr_time_delta_t max_idle, bool locking, char const *trigger_prefix, fr_pair_list_t *trigger_args)
Initialise a module specific exfile handle.
Definition module_rlm.c:116
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:950
CONF_SECTION * module_rlm_virtual_by_name(char const *name)
Definition module_rlm.c:810
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
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:427
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:308
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:823
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:828
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:257
int modules_rlm_instantiate(void)
Performs the instantiation phase for all backend modules.
Definition module_rlm.c:987
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:87
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
static char const * name
Section name identifier.
Definition section.h:44
Module instance data.
Definition module.h:265
Named methods exported by a module.
Definition module.h:173
A group of methods exported by a module or added as an overlay.
Definition module.h:163
Struct exported by a rlm_* module.
Definition module.h:195
Optional arguments passed to vp_tmpl functions.
Definition tmpl.h:341
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:230
static fr_slen_t parent
Definition pair.h:851
int nonnull(2, 5))
static size_t char ** out
Definition value.h:997