Add "extern C {...} to header files for C++ builds.
[freeradius.git] / src / include / modules.h
1 /*
2  * module.h     Interface to the RADIUS module system.
3  *
4  * Version:     $Id$
5  *
6  */
7
8 #ifndef RADIUS_MODULES_H
9 #define RADIUS_MODULES_H
10
11 #include <freeradius-devel/ident.h>
12 RCSIDH(modules_h, "$Id$")
13
14 #include <freeradius-devel/conffile.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 typedef int (*packetmethod)(void *instance, REQUEST *request);
21
22 enum {
23   RLM_COMPONENT_AUTH = 0,
24   RLM_COMPONENT_AUTZ,           /* 1 */
25   RLM_COMPONENT_PREACCT,        /* 2 */
26   RLM_COMPONENT_ACCT,           /* 3 */
27   RLM_COMPONENT_SESS,           /* 4 */
28   RLM_COMPONENT_PRE_PROXY,      /* 5 */
29   RLM_COMPONENT_POST_PROXY,     /* 6 */
30   RLM_COMPONENT_POST_AUTH,      /* 7 */
31 #ifdef WITH_COA
32   RLM_COMPONENT_RECV_COA,       /* 8 */
33   RLM_COMPONENT_SEND_COA,       /* 9 */
34 #endif
35   RLM_COMPONENT_COUNT           /* 8 / 10: How many components are there */
36 };
37
38 #define RLM_TYPE_THREAD_SAFE            (0 << 0)
39 #define RLM_TYPE_THREAD_UNSAFE          (1 << 0)
40 #define RLM_TYPE_CHECK_CONFIG_SAFE      (1 << 1)
41 #define RLM_TYPE_HUP_SAFE               (1 << 2)
42
43 #define RLM_MODULE_MAGIC_NUMBER ((uint32_t) (0xf4ee4ad3))
44 #define RLM_MODULE_INIT RLM_MODULE_MAGIC_NUMBER
45
46 typedef struct module_t {
47         uint32_t        magic;  /* may later be opaque struct */
48         const char      *name;
49         int             type;
50         int             (*instantiate)(CONF_SECTION *mod_cs, void **instance);
51         int             (*detach)(void *instance);
52         packetmethod    methods[RLM_COMPONENT_COUNT];
53 } module_t;
54
55 enum {
56         RLM_MODULE_REJECT,      /* immediately reject the request */
57         RLM_MODULE_FAIL,        /* module failed, don't reply */
58         RLM_MODULE_OK,          /* the module is OK, continue */
59         RLM_MODULE_HANDLED,     /* the module handled the request, so stop. */
60         RLM_MODULE_INVALID,     /* the module considers the request invalid. */
61         RLM_MODULE_USERLOCK,    /* reject the request (user is locked out) */
62         RLM_MODULE_NOTFOUND,    /* user not found */
63         RLM_MODULE_NOOP,        /* module succeeded without doing anything */
64         RLM_MODULE_UPDATED,     /* OK (pairs modified) */
65         RLM_MODULE_NUMCODES     /* How many return codes there are */
66 };
67
68 int setup_modules(int, CONF_SECTION *);
69 int detach_modules(void);
70 int module_hup(CONF_SECTION *modules);
71 int module_authorize(int type, REQUEST *request);
72 int module_authenticate(int type, REQUEST *request);
73 int module_preacct(REQUEST *request);
74 int module_accounting(int type, REQUEST *request);
75 int module_checksimul(int type, REQUEST *request, int maxsimul);
76 int module_pre_proxy(int type, REQUEST *request);
77 int module_post_proxy(int type, REQUEST *request);
78 int module_post_auth(int type, REQUEST *request);
79 #ifdef WITH_COA
80 int module_recv_coa(int type, REQUEST *request);
81 int module_send_coa(int type, REQUEST *request);
82 #define MODULE_NULL_COA_FUNCS ,NULL,NULL
83 #else
84 #define MODULE_NULL_COA_FUNCS
85 #endif
86 int indexed_modcall(int comp, int idx, REQUEST *request);
87
88 /*
89  *      For now, these are strongly tied together.
90  */
91 int virtual_servers_load(CONF_SECTION *config);
92 void virtual_servers_free(time_t when);
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* RADIUS_MODULES_H */