855a2010ce22751871e565ff567a821da5c767b5
[freeradius.git] / src / modules / rlm_redis / rlm_redis.h
1 /*
2  * rlm_redis.h
3  *
4  * Version:     $Id$
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * Copyright 2000,2006  The FreeRADIUS server project
21  * Copyright 2011  TekSavvy Solutions <gabe@teksavvy.com>
22  */
23
24 #ifndef RLM_REDIS_H
25 #define RLM_REDIS_H
26
27 #include <freeradius-devel/ident.h>
28 RCSIDH(rlm_redis_h, "$Id$")
29
30 #ifdef HAVE_PTHREAD_H
31 #include <pthread.h>
32 #endif
33
34 #include <freeradius-devel/modpriv.h>
35 #include <hiredis/hiredis.h>
36
37 typedef struct redis_socket_t {
38         redisContext    *conn;
39         redisReply      *reply;
40 } REDISSOCK;
41
42 typedef struct rlm_redis_t REDIS_INST;
43
44 typedef struct rlm_redis_t {
45         char            *xlat_name;
46
47         char            *hostname;
48         int             port;
49         int             database;
50         char            *password;
51         fr_connection_pool_t *pool;
52
53         int (*redis_query)(REDISSOCK **dissocket_p, REDIS_INST *inst, char *query);
54         int (*redis_finish_query)(REDISSOCK *dissocket);
55         size_t (*redis_escape_func)(REQUEST *request, char *out, size_t outlen, const char *in, void *);
56
57 } rlm_redis_t;
58
59 #define MAX_QUERY_LEN                   4096
60
61 int rlm_redis_query(REDISSOCK **dissocket_p, REDIS_INST *inst, char *query);
62 int rlm_redis_finish_query(REDISSOCK *dissocket);
63
64 #endif  /* RLM_REDIS_H */
65