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 22struct module_ctx; 23 24struct 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 /* User-Password Attribute is encrypted if the module has the secret */ 39 40 void (*request_decoration)(void *ctx, u_int query_id, const u_char *pkt, 41 size_t pktlen); 42 43 void (*response_decoration)(void *ctx, u_int query_id, 44 const u_char *req, size_t reqlen, const u_char *res, size_t reslen); 45}; 46 47#define SYNTAX_ASSERT(_cond, _msg) \ 48 do { \ 49 if (!(_cond)) { \ 50 errmsg = (_msg); \ 51 goto syntax_error; \ 52 } \ 53 } while (0 /* CONSTCOND */) 54 55__BEGIN_DECLS 56 57struct module_base *module_create(int, void *, struct module_handlers *); 58void module_start(struct module_base *); 59void module_stop(struct module_base *); 60int module_run(struct module_base *); 61void module_destroy(struct module_base *); 62void module_load(struct module_base *); 63void module_drop_privilege(struct module_base *, int); 64int module_notify_secret(struct module_base *, 65 const char *); 66int module_send_message(struct module_base *, uint32_t, 67 const char *, ...) 68 __attribute__((__format__ (__printf__, 3, 4))); 69int module_userpass_ok(struct module_base *, u_int, 70 const char *); 71int module_userpass_fail(struct module_base *, u_int, 72 const char *); 73int module_accsreq_answer(struct module_base *, u_int, 74 const u_char *, size_t); 75int module_accsreq_aborted(struct module_base *, u_int); 76int module_reqdeco_done(struct module_base *, u_int, 77 const u_char *, size_t); 78int module_resdeco_done(struct module_base *, u_int, 79 const u_char *, size_t); 80 81__END_DECLS 82 83#endif 84