ld_fld.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_FLD_H
  25. #define _LD_FLD_H
  26. /** \addtogroup ldap
  27. * @{
  28. */
  29. /** \file
  30. * Implementation of ld_fld data structure representing LDAP fields and
  31. * related functions.
  32. */
  33. #include "ld_cfg.h"
  34. struct ld_cfg;
  35. #include "../../lib/srdb2/db_gen.h"
  36. #include "../../lib/srdb2/db_fld.h"
  37. #include "../../lib/srdb2/db_cmd.h"
  38. #include <ldap.h>
  39. enum ld_syntax {
  40. LD_SYNTAX_STRING = 0,
  41. LD_SYNTAX_GENTIME,
  42. LD_SYNTAX_INT,
  43. LD_SYNTAX_BIT,
  44. LD_SYNTAX_BOOL,
  45. LD_SYNTAX_BIN,
  46. LD_SYNTAX_FLOAT
  47. };
  48. struct ld_fld {
  49. db_drv_t gen;
  50. str attr; /**< Name of corresponding LDAP attribute */
  51. enum ld_syntax syntax; /**< LDAP attribute syntax */
  52. struct berval** values; /**< Values retrieved from the LDAP result */
  53. unsigned int valuesnum;
  54. unsigned int index;
  55. db_fld_t** filter; /**< filter applied on the field pointing to db_cmd_t.match[] */
  56. int client_side_filtering; /**< do not pass filter to LDAP server but filter result set */
  57. };
  58. /** Creates a new LDAP specific payload.
  59. * This function creates a new LDAP specific payload structure and
  60. * attaches the structure to the generic db_fld structure.
  61. * @param fld A generic db_fld structure to be exended.
  62. * @param table Name of the table on the server.
  63. * @retval 0 on success.
  64. * @retval A negative number on error.
  65. */
  66. int ld_fld(db_fld_t* fld, char* table);
  67. int ld_resolve_fld(db_fld_t* fld, struct ld_cfg* cfg);
  68. int ld_prepare_ldap_filter(char** filter, db_cmd_t* cmd, str* add);
  69. int ld_incindex(db_fld_t* fld);
  70. int ld_ldap2fldinit(db_fld_t* fld, LDAP* ldap, LDAPMessage* msg);
  71. int ld_ldap2fld(db_fld_t* fld, LDAP* ldap, LDAPMessage* msg);
  72. int ld_ldap2fldex(db_fld_t* fld, LDAP* ldap, LDAPMessage* msg, int init);
  73. /** @} */
  74. #endif /* _LD_FLD_H */