All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
modpriv.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15  */
16 #ifndef _FR_MODPRIV_H
17 #define _FR_MODPRIV_H
18 /**
19  * $Id: f038780c36f1977aa541c9898c06449a192ff1d1 $
20  *
21  * @file modpriv.h
22  * @brief Stuff needed by both modules.c and modcall.c, but should not be
23  * accessed from anywhere else.
24  *
25  * @copyright 2015 The FreeRADIUS server project
26  */
27 RCSIDH(modpriv_h, "$Id: f038780c36f1977aa541c9898c06449a192ff1d1 $")
28 
29 #include <freeradius-devel/radiusd.h>
30 #include <freeradius-devel/modules.h>
31 
32 #ifndef HAVE_DLFCN_H
33 #error FreeRADIUS needs either libltdl, or a working dlopen()
34 #else
35 #include <dlfcn.h>
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 typedef void *lt_dlhandle;
43 
44 lt_dlhandle lt_dlopenext(char const *name);
45 void *lt_dlsym(lt_dlhandle handle, char const *symbol);
46 int lt_dlclose(lt_dlhandle handle);
47 char const *lt_dlerror(void);
48 
49 /*
50  * Keep track of which modules we've loaded.
51  */
52 typedef struct module_entry_t {
53  char const *name;
54  module_t const *module;
55  lt_dlhandle handle;
57 
59 
60 /*
61  * Per-instance data structure, to correlate the modules
62  * with the instance names (may NOT be the module names!),
63  * and the per-instance data structures.
64  */
65 typedef struct module_instance_t {
66  char const *name;
68  void *insthandle;
69 #ifdef HAVE_PTHREAD_H
70  pthread_mutex_t *mutex;
71 #endif
73  time_t last_hup;
75  bool force;
79 
80 module_instance_t *module_instantiate(CONF_SECTION *modules, char const *askedname);
81 module_instance_t *module_instantiate_method(CONF_SECTION *modules, char const *askedname, rlm_components_t *method);
82 module_instance_t *module_find(CONF_SECTION *modules, char const *askedname);
83 int module_sibling_section_find(CONF_SECTION **out, CONF_SECTION *module, char const *name);
84 int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif /* _FR_MODPRIV_H */
#define RCSIDH(h, id)
Definition: build.h:136
module_entry_t * entry
Definition: modpriv.h:67
char const * name
Definition: modpriv.h:66
Metadata exported by the module.
Definition: modules.h:134
lt_dlhandle lt_dlopenext(char const *name)
Definition: modules.c:151
module_t const * module
Definition: modpriv.h:54
static char const * name
module_instance_t * module_find(CONF_SECTION *modules, char const *askedname)
Find an existing module instance.
Definition: modules.c:623
CONF_SECTION * cs
Definition: modpriv.h:72
module_instance_t * module_instantiate(CONF_SECTION *modules, char const *askedname)
Load a module, and instantiate it.
Definition: modules.c:644
void * lt_dlsym(lt_dlhandle handle, char const *symbol)
Definition: modules.c:269
int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when)
Definition: modules.c:1624
bool instantiated
Definition: modpriv.h:74
char const * name
Definition: modpriv.h:53
fr_module_hup_t * mh
Definition: modpriv.h:77
time_t last_hup
Definition: modpriv.h:73
struct module_instance_t module_instance_t
int lt_dlclose(lt_dlhandle handle)
Definition: modules.c:274
module_instance_t * module_instantiate_method(CONF_SECTION *modules, char const *askedname, rlm_components_t *method)
Definition: modules.c:712
struct module_entry_t module_entry_t
rlm_rcode_t code
Definition: modpriv.h:76
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
char const * lt_dlerror(void)
Definition: modules.c:281
int module_sibling_section_find(CONF_SECTION **out, CONF_SECTION *module, char const *name)
Resolve polymorphic item's from a module's CONF_SECTION to a subsection in another module...
Definition: modules.c:788
void * lt_dlhandle
Definition: modpriv.h:42
void * insthandle
Definition: modpriv.h:68
enum rlm_components rlm_components_t
The different section components of the server.
lt_dlhandle handle
Definition: modpriv.h:55
Definition: modpriv.h:52