1 /* 2 * BDB Database Driver for Kamailio 3 * 4 * Copyright (C) 2008 iptelorg GmbH 5 * 6 * This file is part of Kamailio, a free SIP server. 7 * 8 * Kamailio is free software; you can redistribute it and/or modify it under the 9 * terms of the GNU General Public License as published by the Free Software 10 * Foundation; either version 2 of the License, or (at your option) any later 11 * version. 12 * 13 * Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY 14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 * details. 17 * 18 * You should have received a copy of the GNU General Public License along 19 * with this program; if not, write to the Free Software Foundation, Inc., 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 */ 22 23 #ifndef _BDB_CON_H_ 24 #define _BDB_CON_H_ 25 26 /** \addtogroup bdb 27 * @{ 28 */ 29 30 /*! \file 31 * Berkeley DB : Implementation of BDB per-connection related data structures and functions. 32 * 33 * \ingroup database 34 */ 35 36 #include <time.h> 37 #include <db.h> 38 39 #include "../../lib/srdb2/db_pool.h" 40 #include "../../lib/srdb2/db_con.h" 41 #include "../../lib/srdb2/db_uri.h" 42 43 #include "bdb_lib.h" 44 45 /** 46 * Per-connection flags for BDB connections. 47 */ 48 enum bdb_con_flags 49 { 50 BDB_CONNECTED = 51 (1 << 0), /**< The connection has been connected successfully */ 52 }; 53 54 55 /** A structure representing a connection to a BDB. 56 * This structure represents connections to BDB. It contains 57 * BDB specific per-connection data, 58 */ 59 60 typedef struct _bdb_con 61 { 62 db_pool_entry_t gen; /**< Generic part of the structure */ 63 bdb_db_t *dbp; /**< DB structure handle */ 64 unsigned int flags; /**< Flags */ 65 } bdb_con_t, *bdb_con_p; 66 67 /** Create a new bdb_con structure. 68 * This function creates a new bdb_con structure and attachs the structure to 69 * the generic db_con structure in the parameter. 70 * @param con A generic db_con structure to be extended with BDB payload 71 * @retval 0 on success 72 * @retval A negative number on error 73 */ 74 int bdb_con(db_con_t *con); 75 76 77 /** Establish a new connection to server. 78 * This function is called when a SER module calls db_connect to establish a 79 * new connection to the database server. 80 * @param con A structure representing database connection. 81 * @retval 0 on success. 82 * @retval A negative number on error. 83 */ 84 int bdb_con_connect(db_con_t *con); 85 86 87 /** Disconnected from BDB. 88 * Disconnects a previously connected connection to BDB. 89 * @param con A structure representing the connection to be disconnected. 90 */ 91 void bdb_con_disconnect(db_con_t *con); 92 93 /** @} */ 94 95 #endif /* _BDB_CON_H_ */ 96