32b7ab0f3bdf5ffda0951d6520cd4e41e710681b
[freeradius.git] / src / include / modules.h
1 /*
2  * module.h     Interface to the RADIUS module system.
3  *
4  * Version:     $Id$
5  *
6  */
7
8 /*
9  *      The types of the functions which are supported by each module.
10  *      The functional parameters are defined here, so we don't have to
11  *      edit each and every module when we decide to add another type
12  *      of request handler.
13  */
14 typedef int (*RLM_AUTHORIZE_FUNCP)(REQUEST *request, 
15                                    VALUE_PAIR **check_items,
16                                    VALUE_PAIR **reply_items);
17 typedef int (*RLM_AUTHENTICATE_FUNCP)(REQUEST *request);
18 typedef int (*RLM_POST_AUTHENTICATE_FUNCP)(REQUEST *request);
19 typedef int (*RLM_PRE_ACCOUNTING_FUNCP)(REQUEST *request);
20 typedef int (*RLM_ACCOUNTING_FUNCP)(REQUEST *request);
21
22 typedef struct module_t {
23         const char      *name;
24         int     type;                   /* reserved */
25         int     (*init)(int argc, char **argv);
26         int     (*authorize)(REQUEST *request, 
27                         VALUE_PAIR **check_items, VALUE_PAIR **reply_items);
28         int     (*authenticate)(REQUEST *request);
29         int     (*preaccounting)(REQUEST *request);
30         int     (*accounting)(REQUEST *request);
31         int     (*detach)(void);
32 } module_t;
33
34 enum {
35         RLM_MODULE_REJECT = -2, /* reject the request */
36         RLM_MODULE_FAIL = -1,   /* module failed, don't reply */
37         RLM_MODULE_OK = 0,      /* the module is OK, continue */
38         RLM_MODULE_HANDLED = 1  /* the module handled the request, so stop. */
39 };
40
41 int read_modules_file(char *filename);
42 int module_authorize(REQUEST *request, 
43         VALUE_PAIR **check_items, VALUE_PAIR **reply_items);
44 int module_authenticate(int type, REQUEST *request);
45 int module_preacct(REQUEST *request);
46 int module_accounting(REQUEST *request);
47