blob: d87690a699cdb0495b281ec396b3884c423ff216 [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 Bakker530927b2015-02-13 14:24:10 +01006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
Manuel Pégourié-Gonnarde12abf92015-01-28 17:13:45 +00008 * This file is part of mbed TLS (https://polarssl.org)
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00009 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000023 */
Paul Bakkercce9d772011-11-18 14:26:47 +000024#ifndef POLARSSL_DEBUG_H
25#define POLARSSL_DEBUG_H
Paul Bakker5121ce52009-01-03 21:22:43 +000026
Paul Bakker314052f2011-08-15 09:07:52 +000027#include "config.h"
28#include "ssl.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000029
Paul Bakker1504af52012-02-11 16:17:43 +000030#if defined(POLARSSL_DEBUG_C)
Paul Bakker5121ce52009-01-03 21:22:43 +000031
32#define SSL_DEBUG_MSG( level, args ) \
Manuel Pégourié-Gonnard26d88cf2015-06-27 11:48:01 +020033 debug_print_msg_free( ssl, level, __FILE__, __LINE__, debug_fmt args );
Paul Bakker5121ce52009-01-03 21:22:43 +000034
35#define SSL_DEBUG_RET( level, text, ret ) \
36 debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
37
38#define SSL_DEBUG_BUF( level, text, buf, len ) \
39 debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
40
41#define SSL_DEBUG_MPI( level, text, X ) \
42 debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
43
44#define SSL_DEBUG_CRT( level, text, crt ) \
45 debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
46
47#else
48
49#define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
50#define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
51#define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
52#define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
53#define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
54
55#endif
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61char *debug_fmt( const char *format, ... );
62
Manuel Pégourié-Gonnard26d88cf2015-06-27 11:48:01 +020063void debug_print_msg_free( const ssl_context *ssl, int level,
64 const char *file, int line, char *text );
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 */