1 /* modpriv.h: Stuff needed by both modules.c and modcall.c, but should not be
2  * accessed from anywhere else.
3  *
4  * Version: $Id: f69b47c35bd1aab0fbe590d792a186a1f06a530e $ */
5 #ifndef FR_MODPRIV_H
6 #define FR_MODPRIV_H
7 
8 #include <freeradius-devel/radiusd.h>
9 #include <freeradius-devel/modules.h>
10 
11 #ifndef HAVE_DLFCN_H
12 #error FreeRADIUS needs either libltdl, or a working dlopen()
13 #else
14 #include <dlfcn.h>
15 #endif
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef void *fr_dlhandle;
22 
23 fr_dlhandle fr_dlopenext(char const *name);
24 void *fr_dlsym(fr_dlhandle handle, char const *symbol);
25 int fr_dlclose(fr_dlhandle handle);
26 char const *fr_dlerror(void);
27 
28 /*
29  *	Keep track of which modules we've loaded.
30  */
31 typedef struct module_entry_t {
32 	char			name[MAX_STRING_LEN];
33 	module_t const		*module;
34 	fr_dlhandle		handle;
35 } module_entry_t;
36 
37 typedef struct fr_module_hup_t fr_module_hup_t;
38 
39 /*
40  *	Per-instance data structure, to correlate the modules
41  *	with the instance names (may NOT be the module names!),
42  *	and the per-instance data structures.
43  */
44 typedef struct module_instance_t {
45 	char			name[MAX_STRING_LEN];
46 	module_entry_t		*entry;
47 	void			*insthandle;
48 #ifdef HAVE_PTHREAD_H
49 	pthread_mutex_t		*mutex;
50 #endif
51 	CONF_SECTION		*cs;
52 	time_t			last_hup;
53 	bool			instantiated;
54 	bool			force;
55 	rlm_rcode_t		code;
56 	fr_module_hup_t	       	*mh;
57 } module_instance_t;
58 
59 module_instance_t	*module_instantiate(CONF_SECTION *modules, char const *askedname);
60 module_instance_t	*module_instantiate_method(CONF_SECTION *modules, char const *askedname, rlm_components_t *method);
61 module_instance_t	*module_find(CONF_SECTION *modules, char const *askedname);
62 int			find_module_sibling_section(CONF_SECTION **out, CONF_SECTION *module, char const *name);
63 int			module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif	/* FR_MODPRIV_H */
70