tls_util.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * $Id$
  3. *
  4. * TLS module - common functions
  5. *
  6. * Copyright (C) 2001-2003 FhG FOKUS
  7. * Copyright (C) 2004,2005 Free Software Foundation, Inc.
  8. * COpyright (C) 2005 iptelorg GmbH
  9. *
  10. * This file is part of sip-router, a free SIP server.
  11. *
  12. * sip-router is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version
  16. *
  17. * For a license to use the sip-router software under conditions
  18. * other than those described here, or to purchase support for this
  19. * software, please contact iptel.org by e-mail at the following addresses:
  20. * [email protected]
  21. *
  22. * ser is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  30. */
  31. /*!
  32. * \file
  33. * \brief SIP-router TLS support :: Common functions
  34. * \ingroup tls
  35. * Module: \ref tls
  36. */
  37. #ifndef _TLS_UTIL_H
  38. #define _TLS_UTIL_H
  39. #include <openssl/err.h>
  40. #include "../../dprint.h"
  41. #include "../../str.h"
  42. #include "tls_domain.h"
  43. #define TLS_ERR_RET(r, s) \
  44. do { \
  45. long err; \
  46. (r) = 0; \
  47. if ((*tls_domains_cfg)->srv_default->ctx && \
  48. (*tls_domains_cfg)->srv_default->ctx[0]) { \
  49. while((err = ERR_get_error())) { \
  50. (r) = 1; \
  51. ERR("%s%s\n", ((s)) ? (s) : "", \
  52. ERR_error_string(err, 0)); \
  53. } \
  54. } \
  55. } while(0)
  56. #define TLS_ERR(s) \
  57. do { \
  58. int ret; \
  59. TLS_ERR_RET(ret, s); \
  60. } while(0)
  61. /*
  62. * Make a shared memory copy of ASCII zero terminated string
  63. * Return value: -1 on error
  64. * 0 on success
  65. */
  66. int shm_asciiz_dup(char** dest, char* val);
  67. /*
  68. * Delete old TLS configuration that is not needed anymore
  69. */
  70. void collect_garbage(void);
  71. #endif /* _TLS_UTIL_H */