The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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: bc6487c43fafb70cca2675812562f2163931c392 $
20  *
21  * @file src/lib/server/module_rlm.h
22  * @brief Defines functions for rlm module (re-)initialisation.
23  *
24  * @copyright 2022 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25  */
26 RCSIDH(module_rlm_h, "$Id: bc6487c43fafb70cca2675812562f2163931c392 $")
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <freeradius-devel/server/module.h>
33 
34 extern char const *section_type_value[MOD_COUNT];
35 
36 typedef struct {
37  module_t common; //!< Common fields presented by all modules.
38  module_method_name_t const *method_names; //!< named methods
39  fr_dict_t const **dict; //!< pointer to local fr_dict_t*
40 } module_rlm_t;
41 
42 /** Cast a module_t to a module_rlm_t
43  *
44  */
45 static inline module_rlm_t const *module_rlm_from_module(module_t const *module)
46 {
47  return (module_rlm_t const *)module;
48 }
49 
50 /** @name Convenience wrappers around other internal APIs to make them easier to instantiate with modules
51  *
52  * @{
53  */
55  void *opaque,
58  char const *log_prefix,
59  char const *trigger_prefix,
60  fr_pair_list_t *trigger_args);
61 exfile_t *module_rlm_exfile_init(TALLOC_CTX *ctx,
62  CONF_SECTION *module,
63  uint32_t max_entries,
64  fr_time_delta_t max_idle,
65  bool locking,
66  char const *trigger_prefix,
67  fr_pair_list_t *trigger_args);
68 /** @} */
69 
70 /** @name Helper functions
71  *
72  * @{
73  */
75  char const *name, module_method_t def);
76 
78  module_method_t method, char const *def);
79 
80 bool module_rlm_section_type_set(request_t *request, fr_dict_attr_t const *type_da, fr_dict_enum_value_t const *enumv);
81 /** @} */
82 
83 /** @name Module and module thread lookup
84  *
85  * @{
86  */
88  char const **name1, char const **name2,
89  char const *asked_name);
90 
92 
93 module_instance_t *module_rlm_by_name(module_instance_t const *parent, char const *asked_name);
94 
95 CONF_SECTION *module_rlm_by_name_virtual(char const *asked_name);
96 
97 /** @} */
98 
99 /** @name Support functions
100  *
101  * @{
102  */
103 int module_rlm_submodule_parse(TALLOC_CTX *ctx, void *out, void *parent,
104  CONF_ITEM *ci, conf_parser_t const *rule);
105 /** @} */
106 
107 /** @name Module and module thread initialisation and instantiation
108  *
109  * @{
110  */
111 void modules_rlm_thread_detach(void);
112 
113 int modules_rlm_thread_instantiate(TALLOC_CTX *ctx, fr_event_list_t *el) CC_HINT(nonnull(2));
114 
115 int modules_rlm_instantiate(void);
116 
117 int modules_rlm_bootstrap(CONF_SECTION *root) CC_HINT(nonnull);
118 /** @} */
119 
120 /** @name Global initialisation and free functions
121  *
122  * @{
123  */
124 int modules_rlm_free(void);
125 
126 int modules_rlm_init(void);
127 /** @} */
128 
129 #ifdef __cplusplus
130 }
131 #endif
#define RCSIDH(h, id)
Definition: build.h:445
Defines a CONF_PAIR to C data type mapping.
Definition: cf_parse.h:563
Common header for all CONF_* types.
Definition: cf_priv.h:49
A section grouping multiple CONF_PAIR.
Definition: cf_priv.h:89
@ MOD_COUNT
10 how many components there are.
Definition: components.h:38
Value of an enumerated attribute.
Definition: dict.h:209
Stores all information relating to an event list.
Definition: event.c:411
unsigned int uint32_t
Definition: merged_model.c:33
Specifies a module method identifier.
Definition: module_method.c:36
char const * module_rlm_state_method_to_str(module_state_func_table_t const *table, module_method_t method, char const *def)
Definition: module_rlm.c:381
module_instance_t * module_rlm_by_name(module_instance_t const *parent, char const *asked_name)
Definition: module_rlm.c:785
void modules_rlm_thread_detach(void)
Frees thread-specific data for all registered backend modules.
Definition: module_rlm.c:926
int modules_rlm_bootstrap(CONF_SECTION *root)
Bootstrap modules and virtual modules.
Definition: module_rlm.c:964
CONF_SECTION * module_rlm_by_name_virtual(char const *asked_name)
Definition: module_rlm.c:767
module_method_name_t const * method_names
named methods
Definition: module_rlm.h:38
module_t common
Common fields presented by all modules.
Definition: module_rlm.h:37
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:939
module_instance_t * module_rlm_by_name_and_method(module_method_t *method, call_env_method_t const **method_env, char const **name1, char const **name2, char const *asked_name)
Find an existing module instance and verify it implements the specified method.
Definition: module_rlm.c:433
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:92
static module_rlm_t const * module_rlm_from_module(module_t const *module)
Cast a module_t to a module_rlm_t.
Definition: module_rlm.h:45
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:913
fr_dict_t const ** dict
pointer to local fr_dict_t*
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:397
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:248
module_method_t module_rlm_state_str_to_method(module_state_func_table_t const *table, char const *name, module_method_t def)
Definition: module_rlm.c:364
int modules_rlm_free(void)
Cleanup all global structures.
Definition: module_rlm.c:1138
module_thread_instance_t * module_rlm_thread_by_data(void const *data)
Definition: module_rlm.c:780
int modules_rlm_instantiate(void)
Performs the instantiation phase for all backend modules.
Definition: module_rlm.c:950
int modules_rlm_init(void)
Initialise the module list structure.
Definition: module_rlm.c:1156
char const * section_type_value[MOD_COUNT]
Definition: module_rlm.c:64
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
static const call_env_method_t method_env
Definition: rlm_detail.c:489
static char const * name
unlang_action_t(* module_method_t)(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
Definition: module.h:69
Per instance data.
Definition: module.h:169
Struct exported by a rlm_* module.
Definition: module.h:142
Map string values to module state method.
Definition: module.h:245
Per thread per instance data.
Definition: module.h:215
A time delta, a difference in time measured in nanoseconds.
Definition: time.h:80
static fr_event_list_t * el
static fr_slen_t parent
Definition: pair.h:844
static fr_slen_t data
Definition: value.h:1259
int nonnull(2, 5))
static size_t char ** out
Definition: value.h:984