tls_hooks.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "tls_hooks.h"
  26. #include "tls_hooks_init.h"
  27. #include "globals.h"
  28. #ifdef TLS_HOOKS
  29. struct tls_hooks tls_hook= {0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 };
  30. static int tls_hooks_loaded=0;
  31. int register_tls_hooks(struct tls_hooks* h)
  32. {
  33. if (!tls_disable){
  34. tls_hook=*h;
  35. tls_hooks_loaded++;
  36. return 0;
  37. }
  38. return -1;
  39. }
  40. int tls_init(struct socket_info* si)
  41. {
  42. if (tls_hook.init_si)
  43. return tls_hook.init_si(si);
  44. return -1;
  45. }
  46. int tls_has_init_si()
  47. {
  48. return (tls_hook.init_si!=0);
  49. }
  50. int init_tls()
  51. {
  52. if (tls_hook.init)
  53. return tls_hook.init();
  54. return 0;
  55. }
  56. void destroy_tls()
  57. {
  58. if (tls_hook.destroy)
  59. tls_hook.destroy();
  60. }
  61. int tls_loaded()
  62. {
  63. return tls_hooks_loaded;
  64. }
  65. #endif /* TLS_HOOKS */