blob: aae0ecf5a516384fd437c1daa72fb1f3ed336295 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file debug.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker83ded912010-03-21 17:46:26 +00004 * Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakker77b385e2009-07-28 17:23:11 +00005 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00006 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000020 */
21#ifndef SSL_DEBUG_H
22#define SSL_DEBUG_H
23
Paul Bakker8e831ed2009-01-03 21:24:11 +000024#include "polarssl/config.h"
25#include "polarssl/ssl.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000026
Paul Bakker40e46942009-01-03 21:51:57 +000027#if defined(POLARSSL_DEBUG_MSG)
Paul Bakker5121ce52009-01-03 21:22:43 +000028
29#define SSL_DEBUG_MSG( level, args ) \
30 debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
31
32#define SSL_DEBUG_RET( level, text, ret ) \
33 debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
34
35#define SSL_DEBUG_BUF( level, text, buf, len ) \
36 debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
37
38#define SSL_DEBUG_MPI( level, text, X ) \
39 debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
40
41#define SSL_DEBUG_CRT( level, text, crt ) \
42 debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
43
44#else
45
46#define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
47#define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
48#define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
49#define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
50#define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
51
52#endif
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58char *debug_fmt( const char *format, ... );
59
Paul Bakkerff60ee62010-03-16 21:09:09 +000060void debug_print_msg( const ssl_context *ssl, int level,
61 const char *file, int line, const char *text );
Paul Bakker5121ce52009-01-03 21:22:43 +000062
Paul Bakkerff60ee62010-03-16 21:09:09 +000063void debug_print_ret( const ssl_context *ssl, int level,
64 const char *file, int line,
65 const char *text, int ret );
Paul Bakker5121ce52009-01-03 21:22:43 +000066
Paul Bakkerff60ee62010-03-16 21:09:09 +000067void debug_print_buf( const ssl_context *ssl, int level,
68 const char *file, int line, const char *text,
Paul Bakker5121ce52009-01-03 21:22:43 +000069 unsigned char *buf, int len );
70
Paul Bakkerff60ee62010-03-16 21:09:09 +000071void debug_print_mpi( const ssl_context *ssl, int level,
72 const char *file, int line,
73 const char *text, const mpi *X );
Paul Bakker5121ce52009-01-03 21:22:43 +000074
Paul Bakkerff60ee62010-03-16 21:09:09 +000075void debug_print_crt( const ssl_context *ssl, int level,
76 const char *file, int line,
77 const char *text, const x509_cert *crt );
Paul Bakker5121ce52009-01-03 21:22:43 +000078
79#ifdef __cplusplus
80}
81#endif
82
83#endif /* debug.h */