Make the 5 packet methods into an array within module_t - now calling them
[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 #define RLM_COMPONENT_AUTH 0
15 #define RLM_COMPONENT_AUTZ 1
16 #define RLM_COMPONENT_PREACCT 2
17 #define RLM_COMPONENT_ACCT 3
18 #define RLM_COMPONENT_SESS 4
19 #define RLM_COMPONENT_COUNT 5 /* How many components are there */
20
21 #define RLM_TYPE_THREAD_SAFE    (0 << 0)
22 #define RLM_TYPE_THREAD_UNSAFE  (1 << 0)
23
24 typedef struct module_t {
25         const char      *name;
26         int     type;                   /* reserved */
27         int     (*init)(void);
28         int     (*instantiate)(CONF_SECTION *mod_cs, void **instance);
29         packetmethod    methods[RLM_COMPONENT_COUNT];
30         int     (*detach)(void *instance);
31         int     (*destroy)(void);
32 } module_t;
33
34 extern const char *component_names[RLM_COMPONENT_COUNT];
35
36 enum {
37         RLM_MODULE_REJECT,      /* immediately reject the request */
38         RLM_MODULE_FAIL,        /* module failed, don't reply */
39         RLM_MODULE_OK,          /* the module is OK, continue */
40         RLM_MODULE_HANDLED,     /* the module handled the request, so stop. */
41         RLM_MODULE_INVALID,     /* the module considers the request invalid. */
42         RLM_MODULE_USERLOCK,    /* reject the request (user is locked out) */
43         RLM_MODULE_NOTFOUND,    /* user not found */
44         RLM_MODULE_NOOP,        /* module succeeded without doing anything */
45         RLM_MODULE_UPDATED,     /* OK (pairs modified) */
46         RLM_MODULE_NUMCODES     /* How many return codes there are */
47 };
48
49 int setup_modules(void);
50 int module_authorize(REQUEST *request);
51 int module_authenticate(int type, REQUEST *request);
52 int module_preacct(REQUEST *request);
53 int module_accounting(REQUEST *request);
54 int module_checksimul(REQUEST *request, int maxsimul);
55
56 #endif /* RADIUS_MODULES_H */