Add connection pool API
[freeradius.git] / src / include / connection.h
1 #ifndef FR_CONNECTION_H
2 #define FR_CONNECTION_H
3 /**
4  * @file connection.h
5  * @brief       Structures, prototypes and global variables
6  *              for server connection pools.
7  *
8  * Version:     $Id$
9  *
10  *   This program is free software; you can redistribute it and/or modify
11  *   it under the terms of the GNU General Public License as published by
12  *   the Free Software Foundation; either version 2 of the License, or
13  *   (at your option) any later version.
14  *
15  *   This program is distributed in the hope that it will be useful,
16  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *   GNU General Public License for more details.
19  *
20  *   You should have received a copy of the GNU General Public License
21  *   along with this program; if not, write to the Free Software
22  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23  *
24  * Copyright 1999,2000,2002,2003,2004,2005,2006,2007,2008  The FreeRADIUS server project
25  *
26  */
27
28 #include <freeradius-devel/ident.h>
29 RCSIDH(connection_h, "$Id$")
30
31 #include <freeradius-devel/radiusd.h>
32 #include <freeradius-devel/conffile.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef struct fr_connection_pool_t fr_connection_pool_t;
39
40 typedef void *(*fr_connection_create_t)(void *ctx);
41 typedef int (*fr_connection_alive_t)(void *ctx, void *connection);
42 typedef int (*fr_connection_delete_t)(void *ctx, void *connection);
43
44 fr_connection_pool_t *fr_connection_pool_init(CONF_SECTION *cs,
45                                               void *ctx,
46                                               fr_connection_create_t c,
47                                               fr_connection_alive_t a,
48                                               fr_connection_delete_t d);
49 void fr_connection_pool_delete(fr_connection_pool_t *fc);
50
51 int fr_connection_check(fr_connection_pool_t *fc, void *conn);
52 void *fr_connection_get(fr_connection_pool_t *fc);
53 void fr_connection_release(fr_connection_pool_t *fc, void *conn);
54 void *fr_connection_reconnect(fr_connection_pool_t *fc, void *conn);
55
56 #ifdef __cplusplus
57 }
58 #endif
59
60 #endif /* FR_CONNECTION_H*/