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