ld_con.h 2.5 KB

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