tls_util.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * TLS module - common functions
00005  *
00006  * Copyright (C) 2001-2003 FhG FOKUS
00007  * Copyright (C) 2004,2005 Free Software Foundation, Inc.
00008  * COpyright (C) 2005 iptelorg GmbH
00009  *
00010  * This file is part of sip-router, a free SIP server.
00011  *
00012  * sip-router is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version
00016  *
00017  * For a license to use the sip-router software under conditions
00018  * other than those described here, or to purchase support for this
00019  * software, please contact iptel.org by e-mail at the following addresses:
00020  *    info@iptel.org
00021  *
00022  * ser is distributed in the hope that it will be useful,
00023  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025  * GNU General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU General Public License
00028  * along with this program; if not, write to the Free Software
00029  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030  */
00039 #ifndef _TLS_UTIL_H
00040 #define _TLS_UTIL_H
00041 
00042 #include <openssl/err.h>
00043 #include "../../dprint.h"
00044 #include "../../str.h"
00045 #include "tls_domain.h"
00046 
00047 
00048 #define TLS_ERR_RET(r, s)                               \
00049 do {                                                    \
00050         long err;                                       \
00051         (r) = 0;                                        \
00052         if ((*tls_domains_cfg)->srv_default->ctx &&         \
00053             (*tls_domains_cfg)->srv_default->ctx[0]) {      \
00054                 while((err = ERR_get_error())) {        \
00055                         (r) = 1;                        \
00056                         ERR("%s%s\n", ((s)) ? (s) : "", \
00057                             ERR_error_string(err, 0));  \
00058                 }                                       \
00059         }                                               \
00060 } while(0)
00061 
00062 
00063 #define TLS_ERR(s)           \
00064 do {                         \
00065         int ret;             \
00066         TLS_ERR_RET(ret, s); \
00067 } while(0)
00068 
00069 
00070 /*
00071  * Make a shared memory copy of ASCII zero terminated string
00072  * Return value: -1 on error
00073  *                0 on success
00074  */
00075 int shm_asciiz_dup(char** dest, char* val);
00076 
00077 
00078 /*
00079  * Delete old TLS configuration that is not needed anymore
00080  */
00081 void collect_garbage(void);
00082 
00083 #endif /* _TLS_UTIL_H */