tls_hooks.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2007 iptelorg GmbH
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * @file
  18. * @brief Kamailio TLS support :: TLS hooks for modules
  19. * @ingroup tls
  20. * Module: @ref tls
  21. */
  22. #include "tls_hooks.h"
  23. #include "tls_hooks_init.h"
  24. #include "globals.h"
  25. #ifdef TLS_HOOKS
  26. struct tls_hooks tls_hook= {0,0,0,0,0,0,0,0};
  27. static int tls_hooks_loaded=0;
  28. int register_tls_hooks(struct tls_hooks* h)
  29. {
  30. if (!tls_disable){
  31. tls_hook=*h;
  32. tls_hooks_loaded++;
  33. return 0;
  34. }
  35. return -1;
  36. }
  37. int tls_init(struct socket_info* si)
  38. {
  39. if (tls_hook.init_si)
  40. return tls_hook.init_si(si);
  41. return -1;
  42. }
  43. int tls_has_init_si()
  44. {
  45. return (tls_hook.init_si!=0);
  46. }
  47. int init_tls()
  48. {
  49. if (tls_hook.init)
  50. return tls_hook.init();
  51. return 0;
  52. }
  53. int pre_init_tls()
  54. {
  55. if (tls_hook.pre_init)
  56. return tls_hook.pre_init();
  57. return 0;
  58. }
  59. void destroy_tls()
  60. {
  61. if (tls_hook.destroy)
  62. tls_hook.destroy();
  63. }
  64. int tls_loaded()
  65. {
  66. return tls_hooks_loaded;
  67. }
  68. #endif /* TLS_HOOKS */