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