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