1 #ifndef _RADIUS_MODULE_H 2 #define _RADIUS_MODULE_H 3 4 /* 5 * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@ysauoka.net> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #include "radiusd.h" 21 22 struct module_ctx; 23 24 struct module_handlers { 25 /* Should send IMSG_OK or IMSG_NG */ 26 void (*config_set)(void *ctx, const char *paramname, int paramvalc, 27 char * const * paramvalv); 28 29 void (*start)(void *ctx); 30 31 void (*stop)(void *ctx); 32 33 void (*userpass)(void *ctx, u_int query_id, const char *user, 34 const char *pass); 35 36 void (*access_request)(void *ctx, u_int query_id, const u_char *pkt, 37 size_t pktlen); 38 39 /* User-Password Attribute is encrypted if the module has the secret */ 40 }; 41 42 #define SYNTAX_ASSERT(_cond, _msg) \ 43 do { \ 44 if (!(_cond)) { \ 45 errmsg = (_msg); \ 46 goto syntax_error; \ 47 } \ 48 } while (0 /* CONSTCOND */) 49 50 __BEGIN_DECLS 51 52 struct module_base *module_create(int, void *, struct module_handlers *); 53 void module_start(struct module_base *); 54 int module_run(struct module_base *); 55 void module_destroy(struct module_base *); 56 void module_load(struct module_base *); 57 void module_drop_privilege(struct module_base *); 58 int module_notify_secret(struct module_base *, 59 const char *); 60 int module_send_message(struct module_base *, uint32_t, 61 const char *, ...) 62 __attribute__((__format__ (__printf__, 3, 4))); 63 int module_userpass_ok(struct module_base *, u_int, 64 const char *); 65 int module_userpass_fail(struct module_base *, u_int, 66 const char *); 67 int module_accsreq_answer(struct module_base *, u_int, 68 const u_char *, size_t); 69 int module_accsreq_aborted(struct module_base *, u_int); 70 71 __END_DECLS 72 73 #endif 74