tls_hooks.c 1.6 KB

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