import from HEAD:
[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 #include "conffile.h"
11
12 typedef int (*packetmethod)(void *instance, REQUEST *request);
13
14 enum {
15   RLM_COMPONENT_AUTH = 0,
16   RLM_COMPONENT_AUTZ,           /* 1 */
17   RLM_COMPONENT_PREACCT,        /* 2 */
18   RLM_COMPONENT_ACCT,           /* 3 */
19   RLM_COMPONENT_SESS,           /* 4 */
20   RLM_COMPONENT_PRE_PROXY,      /* 5 */
21   RLM_COMPONENT_POST_PROXY,     /* 6 */
22   RLM_COMPONENT_POST_AUTH,      /* 7 */
23   RLM_COMPONENT_COUNT           /* 8: How many components are there */
24 };
25
26 #define RLM_TYPE_THREAD_SAFE    (0 << 0)
27 #define RLM_TYPE_THREAD_UNSAFE  (1 << 0)
28
29 typedef struct module_t {
30         const char      *name;
31         int     type;                   /* reserved */
32         int     (*init)(void);
33         int     (*instantiate)(CONF_SECTION *mod_cs, void **instance);
34         packetmethod    methods[RLM_COMPONENT_COUNT];
35         int     (*detach)(void *instance);
36         int     (*destroy)(void);
37 } module_t;
38
39 extern const char *component_names[RLM_COMPONENT_COUNT];
40
41 enum {
42         RLM_MODULE_REJECT,      /* immediately reject the request */
43         RLM_MODULE_FAIL,        /* module failed, don't reply */
44         RLM_MODULE_OK,          /* the module is OK, continue */
45         RLM_MODULE_HANDLED,     /* the module handled the request, so stop. */
46         RLM_MODULE_INVALID,     /* the module considers the request invalid. */
47         RLM_MODULE_USERLOCK,    /* reject the request (user is locked out) */
48         RLM_MODULE_NOTFOUND,    /* user not found */
49         RLM_MODULE_NOOP,        /* module succeeded without doing anything */
50         RLM_MODULE_UPDATED,     /* OK (pairs modified) */
51         RLM_MODULE_NUMCODES     /* How many return codes there are */
52 };
53
54 int setup_modules(void);
55 int detach_modules(void);
56 int module_authorize(int type, REQUEST *request);
57 int module_authenticate(int type, REQUEST *request);
58 int module_preacct(REQUEST *request);
59 int module_accounting(int type, REQUEST *request);
60 int module_checksimul(int type, REQUEST *request, int maxsimul);
61 int module_pre_proxy(int type, REQUEST *request);
62 int module_post_proxy(int type, REQUEST *request);
63 int module_post_auth(int type, REQUEST *request);
64
65 #endif /* RADIUS_MODULES_H */