*
*/
-#include "conffile.h"
+#ifndef RADIUS_MODULES_H
+#define RADIUS_MODULES_H
-/*
- * The types of the functions which are supported by each module.
- * The functional parameters are defined here, so we don't have to
- * edit each and every module when we decide to add another type
- * of request handler.
- */
-typedef int (*RLM_AUTHORIZE_FUNCP)(REQUEST *request,
- VALUE_PAIR **check_items,
- VALUE_PAIR **reply_items);
-typedef int (*RLM_AUTHENTICATE_FUNCP)(REQUEST *request);
-typedef int (*RLM_POST_AUTHENTICATE_FUNCP)(REQUEST *request);
-typedef int (*RLM_PRE_ACCOUNTING_FUNCP)(REQUEST *request);
-typedef int (*RLM_ACCOUNTING_FUNCP)(REQUEST *request);
-
-/* Shouldn't need these anymore */
-#define RLM_COMPONENT_AUTZ 0
-#define RLM_COMPONENT_AUTH 1
-#define RLM_COMPONENT_PREACCT 2
-#define RLM_COMPONENT_ACCT 3
-#define RLM_COMPONENT_COUNT 4 /* How many components are there */
+#include <freeradius-devel/ident.h>
+RCSIDH(modules_h, "$Id$")
+
+#include <freeradius-devel/conffile.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int (*packetmethod)(void *instance, REQUEST *request);
+
+enum {
+ RLM_COMPONENT_AUTH = 0,
+ RLM_COMPONENT_AUTZ, /* 1 */
+ RLM_COMPONENT_PREACCT, /* 2 */
+ RLM_COMPONENT_ACCT, /* 3 */
+ RLM_COMPONENT_SESS, /* 4 */
+ RLM_COMPONENT_PRE_PROXY, /* 5 */
+ RLM_COMPONENT_POST_PROXY, /* 6 */
+ RLM_COMPONENT_POST_AUTH, /* 7 */
+#ifdef WITH_COA
+ RLM_COMPONENT_RECV_COA, /* 8 */
+ RLM_COMPONENT_SEND_COA, /* 9 */
+#endif
+ RLM_COMPONENT_COUNT /* 8 / 10: How many components are there */
+};
+
+#define RLM_TYPE_THREAD_SAFE (0 << 0)
+#define RLM_TYPE_THREAD_UNSAFE (1 << 0)
+#define RLM_TYPE_CHECK_CONFIG_SAFE (1 << 1)
+#define RLM_TYPE_HUP_SAFE (1 << 2)
+
+#define RLM_MODULE_MAGIC_NUMBER ((uint32_t) (0xf4ee4ad3))
+#define RLM_MODULE_INIT RLM_MODULE_MAGIC_NUMBER
typedef struct module_t {
+ uint32_t magic; /* may later be opaque struct */
const char *name;
- int type; /* reserved */
- int (*init)(void);
- int (*instantiate)(CONF_SECTION *mod_cs, void **instance);
- int (*authorize)(void *instance, REQUEST *request,
- VALUE_PAIR **check_items, VALUE_PAIR **reply_items);
- int (*authenticate)(void *instance, REQUEST *request);
- int (*preaccounting)(void *instance, REQUEST *request);
- int (*accounting)(void *instance, REQUEST *request);
- int (*detach)(void *instance);
- int (*destroy)(void);
+ int type;
+ int (*instantiate)(CONF_SECTION *mod_cs, void **instance);
+ int (*detach)(void *instance);
+ packetmethod methods[RLM_COMPONENT_COUNT];
} module_t;
enum {
- RLM_MODULE_REJECT = -2, /* reject the request */
- RLM_MODULE_FAIL = -1, /* module failed, don't reply */
- RLM_MODULE_OK = 0, /* the module is OK, continue */
- RLM_MODULE_HANDLED = 1 /* the module handled the request, so stop. */
+ RLM_MODULE_REJECT, /* immediately reject the request */
+ RLM_MODULE_FAIL, /* module failed, don't reply */
+ RLM_MODULE_OK, /* the module is OK, continue */
+ RLM_MODULE_HANDLED, /* the module handled the request, so stop. */
+ RLM_MODULE_INVALID, /* the module considers the request invalid. */
+ RLM_MODULE_USERLOCK, /* reject the request (user is locked out) */
+ RLM_MODULE_NOTFOUND, /* user not found */
+ RLM_MODULE_NOOP, /* module succeeded without doing anything */
+ RLM_MODULE_UPDATED, /* OK (pairs modified) */
+ RLM_MODULE_NUMCODES /* How many return codes there are */
};
-int setup_modules(void);
-int module_authorize(REQUEST *request,
- VALUE_PAIR **check_items, VALUE_PAIR **reply_items);
+int setup_modules(int, CONF_SECTION *);
+int detach_modules(void);
+int module_hup(CONF_SECTION *modules);
+int module_authorize(int type, REQUEST *request);
int module_authenticate(int type, REQUEST *request);
int module_preacct(REQUEST *request);
-int module_accounting(REQUEST *request);
+int module_accounting(int type, REQUEST *request);
+int module_checksimul(int type, REQUEST *request, int maxsimul);
+int module_pre_proxy(int type, REQUEST *request);
+int module_post_proxy(int type, REQUEST *request);
+int module_post_auth(int type, REQUEST *request);
+#ifdef WITH_COA
+int module_recv_coa(int type, REQUEST *request);
+int module_send_coa(int type, REQUEST *request);
+#define MODULE_NULL_COA_FUNCS ,NULL,NULL
+#else
+#define MODULE_NULL_COA_FUNCS
+#endif
+int indexed_modcall(int comp, int idx, REQUEST *request);
+
+/*
+ * For now, these are strongly tied together.
+ */
+int virtual_servers_load(CONF_SECTION *config);
+void virtual_servers_free(time_t when);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* RADIUS_MODULES_H */