/src/freeradius-server/src/freeradius-devel/server/module_rlm.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: 0af9a033699276b8fc4f1121535e41fd7e1e6cbf $ |
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 | | */ |
26 | | RCSIDH(module_rlm_h, "$Id: 0af9a033699276b8fc4f1121535e41fd7e1e6cbf $") |
27 | | |
28 | | #ifdef __cplusplus |
29 | | extern "C" { |
30 | | #endif |
31 | | |
32 | | typedef struct module_rlm_s module_rlm_t; |
33 | | typedef struct module_rlm_instance_s module_rlm_instance_t; |
34 | | |
35 | | #include <freeradius-devel/server/module.h> |
36 | | #include <freeradius-devel/server/virtual_servers.h> |
37 | | |
38 | | struct module_rlm_s { |
39 | | module_t common; //!< Common fields presented by all modules. |
40 | | module_method_group_t method_group; //!< named methods |
41 | | }; |
42 | | |
43 | | struct module_rlm_instance_s { |
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 | | */ |
52 | | typedef 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. |
56 | | } module_rlm_xlat_t; |
57 | | |
58 | | /** The output of module_rlm_by_name_and_method |
59 | | * |
60 | | * Everything needed to call a module method. |
61 | | */ |
62 | | typedef 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. |
72 | | } module_method_call_t; |
73 | | |
74 | | static inline module_rlm_t *module_rlm_from_module(module_t *module) |
75 | 0 | { |
76 | 0 | return (module_rlm_t *)module; |
77 | 0 | } Unexecuted instantiation: json.c:module_rlm_from_module Unexecuted instantiation: jpath.c:module_rlm_from_module Unexecuted instantiation: base.c:module_rlm_from_module Unexecuted instantiation: cache.c:module_rlm_from_module Unexecuted instantiation: conf.c:module_rlm_from_module Unexecuted instantiation: virtual_server.c:module_rlm_from_module Unexecuted instantiation: auth.c:module_rlm_from_module Unexecuted instantiation: cf_file.c:module_rlm_from_module Unexecuted instantiation: cf_parse.c:module_rlm_from_module Unexecuted instantiation: client.c:module_rlm_from_module Unexecuted instantiation: main_config.c:module_rlm_from_module Unexecuted instantiation: map_proc.c:module_rlm_from_module Unexecuted instantiation: module.c:module_rlm_from_module Unexecuted instantiation: module_method.c:module_rlm_from_module Unexecuted instantiation: module_rlm.c:module_rlm_from_module Unexecuted instantiation: state.c:module_rlm_from_module Unexecuted instantiation: tmpl_tokenize.c:module_rlm_from_module Unexecuted instantiation: util.c:module_rlm_from_module Unexecuted instantiation: virtual_servers.c:module_rlm_from_module Unexecuted instantiation: call.c:module_rlm_from_module Unexecuted instantiation: caller.c:module_rlm_from_module Unexecuted instantiation: catch.c:module_rlm_from_module Unexecuted instantiation: child_request.c:module_rlm_from_module Unexecuted instantiation: compile.c:module_rlm_from_module Unexecuted instantiation: condition.c:module_rlm_from_module Unexecuted instantiation: detach.c:module_rlm_from_module Unexecuted instantiation: edit.c:module_rlm_from_module Unexecuted instantiation: finally.c:module_rlm_from_module Unexecuted instantiation: foreach.c:module_rlm_from_module Unexecuted instantiation: function.c:module_rlm_from_module Unexecuted instantiation: group.c:module_rlm_from_module Unexecuted instantiation: interpret.c:module_rlm_from_module Unexecuted instantiation: interpret_synchronous.c:module_rlm_from_module Unexecuted instantiation: io.c:module_rlm_from_module Unexecuted instantiation: limit.c:module_rlm_from_module Unexecuted instantiation: load_balance.c:module_rlm_from_module Unexecuted instantiation: map.c:module_rlm_from_module Unexecuted instantiation: map_builtin.c:module_rlm_from_module Unexecuted instantiation: parallel.c:module_rlm_from_module Unexecuted instantiation: return.c:module_rlm_from_module Unexecuted instantiation: subrequest.c:module_rlm_from_module Unexecuted instantiation: switch.c:module_rlm_from_module Unexecuted instantiation: timeout.c:module_rlm_from_module Unexecuted instantiation: tmpl.c:module_rlm_from_module Unexecuted instantiation: try.c:module_rlm_from_module Unexecuted instantiation: transaction.c:module_rlm_from_module Unexecuted instantiation: xlat.c:module_rlm_from_module Unexecuted instantiation: xlat_alloc.c:module_rlm_from_module Unexecuted instantiation: xlat_builtin.c:module_rlm_from_module Unexecuted instantiation: xlat_eval.c:module_rlm_from_module Unexecuted instantiation: xlat_expr.c:module_rlm_from_module Unexecuted instantiation: xlat_func.c:module_rlm_from_module Unexecuted instantiation: xlat_inst.c:module_rlm_from_module Unexecuted instantiation: xlat_purify.c:module_rlm_from_module Unexecuted instantiation: xlat_redundant.c:module_rlm_from_module Unexecuted instantiation: app_io.c:module_rlm_from_module Unexecuted instantiation: coord.c:module_rlm_from_module Unexecuted instantiation: coord_pair.c:module_rlm_from_module Unexecuted instantiation: master.c:module_rlm_from_module Unexecuted instantiation: network.c:module_rlm_from_module Unexecuted instantiation: thread.c:module_rlm_from_module Unexecuted instantiation: worker.c:module_rlm_from_module |
78 | | |
79 | | /** @name Debug functions |
80 | | * @{ |
81 | | */ |
82 | | void 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 | | */ |
89 | | xlat_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 | | |
93 | | fr_pool_t *module_rlm_connection_pool_init(CONF_SECTION *module, |
94 | | void *opaque, |
95 | | fr_pool_connection_create_t c, |
96 | | fr_pool_connection_alive_t a, |
97 | | char const *log_prefix, |
98 | | char const *trigger_prefix, |
99 | | fr_pair_list_t *trigger_args); |
100 | | |
101 | | exfile_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 | | */ |
115 | | bool 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 | | */ |
123 | | fr_slen_t module_rlm_by_name_and_method(TALLOC_CTX *ctx, module_method_call_t *mmc_out, |
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 | | |
127 | | module_instance_t *module_rlm_dynamic_by_name(module_instance_t const *parent, char const *name); |
128 | | |
129 | | module_instance_t *module_rlm_static_by_name(module_instance_t const *parent, char const *name); |
130 | | |
131 | | CONF_SECTION *module_rlm_virtual_by_name(char const *name); |
132 | | /** @} */ |
133 | | |
134 | | /** @name Support functions |
135 | | * |
136 | | * @{ |
137 | | */ |
138 | | int module_rlm_submodule_parse(TALLOC_CTX *ctx, void *out, void *parent, |
139 | | CONF_ITEM *ci, conf_parser_t const *rule); |
140 | | /** @} */ |
141 | | |
142 | | /** @name Module and module thread initialisation and instantiation |
143 | | * |
144 | | * @{ |
145 | | */ |
146 | | void modules_rlm_thread_detach(void); |
147 | | |
148 | | int modules_rlm_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el) CC_HINT(nonnull(2)); |
149 | | |
150 | | int modules_rlm_coord_attach(fr_event_list_t *el) CC_HINT(nonnull); |
151 | | |
152 | | int modules_rlm_instantiate(void); |
153 | | |
154 | | int modules_rlm_bootstrap(CONF_SECTION *root) CC_HINT(nonnull); |
155 | | /** @} */ |
156 | | |
157 | | /** @name Global initialisation and free functions |
158 | | * |
159 | | * @{ |
160 | | */ |
161 | | int modules_rlm_free(void); |
162 | | |
163 | | int modules_rlm_init(void); |
164 | | /** @} */ |
165 | | |
166 | | #ifdef __cplusplus |
167 | | } |
168 | | #endif |