Create the request->reply data structure as soon as the request
[freeradius.git] / src / include / modules.h
1 /*
2  * module.h     Interface to the RADIUS module system.
3  *
4  * Version:     $Id$
5  *
6  */
7
8 #include "conffile.h"
9
10 /*
11  *      The types of the functions which are supported by each module.
12  *      The functional parameters are defined here, so we don't have to
13  *      edit each and every module when we decide to add another type
14  *      of request handler.
15  */
16 typedef int (*RLM_AUTHORIZE_FUNCP)(REQUEST *request, 
17                                    VALUE_PAIR **check_items,
18                                    VALUE_PAIR **reply_items);
19 typedef int (*RLM_AUTHENTICATE_FUNCP)(REQUEST *request,
20                                    VALUE_PAIR **check_items,
21                                    VALUE_PAIR **reply_items);
22 typedef int (*RLM_POST_AUTHENTICATE_FUNCP)(REQUEST *request);
23 typedef int (*RLM_PRE_ACCOUNTING_FUNCP)(REQUEST *request);
24 typedef int (*RLM_ACCOUNTING_FUNCP)(REQUEST *request);
25
26 /* Shouldn't need these anymore */
27 #define RLM_COMPONENT_AUTZ 0
28 #define RLM_COMPONENT_AUTH 1
29 #define RLM_COMPONENT_PREACCT 2
30 #define RLM_COMPONENT_ACCT 3
31 #define RLM_COMPONENT_COUNT 4 /* How many components are there */
32
33 typedef struct module_t {
34         const char      *name;
35         int     type;                   /* reserved */
36         int     (*init)(void);
37         int     (*instantiate)(CONF_SECTION *mod_cs, void **instance);
38         int     (*authorize)(void *instance, REQUEST *request, 
39                         VALUE_PAIR **check_items, VALUE_PAIR **reply_items);
40         int     (*authenticate)(void *instance, REQUEST *request, 
41                         VALUE_PAIR **check_items, VALUE_PAIR **reply_items);
42         int     (*preaccounting)(void *instance, REQUEST *request);
43         int     (*accounting)(void *instance, REQUEST *request);
44         int     (*detach)(void *instance);
45         int     (*destroy)(void);
46 } module_t;
47
48 enum {
49         RLM_MODULE_REJECT = -2, /* reject the request */
50         RLM_MODULE_FAIL = -1,   /* module failed, don't reply */
51         RLM_MODULE_OK = 0,      /* the module is OK, continue */
52         RLM_MODULE_HANDLED = 1  /* the module handled the request, so stop. */
53 };
54
55 int setup_modules(void);
56 int module_authorize(REQUEST *request);
57 int module_authenticate(int type, REQUEST *request);
58 int module_preacct(REQUEST *request);
59 int module_accounting(REQUEST *request);
60