api.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Kamailio LDAP Module
  3. *
  4. * Copyright (C) 2007 University of North Carolina
  5. *
  6. * Original author: Christian Schlatter, [email protected]
  7. *
  8. *
  9. * This file is part of Kamailio, a free SIP server.
  10. *
  11. * Kamailio is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * Kamailio is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. */
  26. #ifndef LDAP_API_H
  27. #define LDAP_API_H
  28. #include <ldap.h>
  29. #include "../../str.h"
  30. #include "../../sr_module.h"
  31. /*
  32. * LDAP API function types
  33. */
  34. typedef int (*ldap_params_search_t)(
  35. int* _ld_result_count,
  36. char* _lds_name,
  37. char* _dn,
  38. int _scope,
  39. char** _attrs,
  40. char* _filter,
  41. ...);
  42. typedef int (*ldap_url_search_t)(
  43. char* _ldap_url,
  44. int* _result_count);
  45. typedef int (*ldap_result_attr_vals_t)(
  46. str* _attr_name,
  47. struct berval ***_vals);
  48. typedef void (*ldap_value_free_len_t)(struct berval **_vals);
  49. typedef int (*ldap_result_next_t)(void);
  50. typedef int (*ldap_str2scope_t)(char* scope_str);
  51. typedef int (*get_ldap_handle_t)(char* _lds_name, LDAP** _ldap_handle);
  52. typedef void (*get_last_ldap_result_t)(
  53. LDAP** _last_ldap_handle,
  54. LDAPMessage** _last_ldap_result);
  55. typedef int (*ldap_rfc4515_escape_t)(str *sin, str *sout, int url_encode);
  56. /*
  57. * LDAP module API
  58. */
  59. typedef struct ldap_api {
  60. ldap_params_search_t ldap_params_search;
  61. ldap_url_search_t ldap_url_search;
  62. ldap_result_attr_vals_t ldap_result_attr_vals;
  63. ldap_value_free_len_t ldap_value_free_len;
  64. ldap_result_next_t ldap_result_next;
  65. ldap_str2scope_t ldap_str2scope;
  66. ldap_rfc4515_escape_t ldap_rfc4515_escape;
  67. get_ldap_handle_t get_ldap_handle;
  68. get_last_ldap_result_t get_last_ldap_result;
  69. } ldap_api_t;
  70. typedef int (*load_ldap_t)(ldap_api_t *api);
  71. int load_ldap(ldap_api_t *api);
  72. static inline int load_ldap_api(ldap_api_t *api)
  73. {
  74. load_ldap_t load_ldap;
  75. if (!(load_ldap = (load_ldap_t) find_export("load_ldap", 0, 0)))
  76. {
  77. LM_ERR("can't import load_ldap\n");
  78. return -1;
  79. }
  80. if (load_ldap(api) == -1)
  81. {
  82. return -1;
  83. }
  84. return 0;
  85. }
  86. #endif /* LDAP_API_H */