Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file debug.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
Paul Bakker | 37ca75d | 2011-01-06 12:28:03 +0000 | [diff] [blame] | 4 | * \brief Debug functions |
| 5 | * |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 6 | * Copyright (C) 2006-2011, Brainspark B.V. |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
Paul Bakker | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 10 | * |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 11 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 12 | * |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 13 | * 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 Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 26 | */ |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 27 | #ifndef POLARSSL_DEBUG_H |
| 28 | #define POLARSSL_DEBUG_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 | |
Paul Bakker | 314052f | 2011-08-15 09:07:52 +0000 | [diff] [blame] | 30 | #include "config.h" |
| 31 | #include "ssl.h" |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 32 | #if defined(POLARSSL_ECP_C) |
| 33 | #include "ecp.h" |
| 34 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 35 | |
Paul Bakker | 1504af5 | 2012-02-11 16:17:43 +0000 | [diff] [blame] | 36 | #if defined(POLARSSL_DEBUG_C) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 37 | |
| 38 | #define SSL_DEBUG_MSG( level, args ) \ |
| 39 | debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args ); |
| 40 | |
| 41 | #define SSL_DEBUG_RET( level, text, ret ) \ |
| 42 | debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ); |
| 43 | |
| 44 | #define SSL_DEBUG_BUF( level, text, buf, len ) \ |
| 45 | debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ); |
| 46 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 47 | #if defined(POLARSSL_BIGNUM_C) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 48 | #define SSL_DEBUG_MPI( level, text, X ) \ |
| 49 | debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 50 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 51 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 52 | #if defined(POLARSSL_ECP_C) |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 53 | #define SSL_DEBUG_ECP( level, text, X ) \ |
| 54 | debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X ); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 55 | #endif |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 56 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 57 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 58 | #define SSL_DEBUG_CRT( level, text, crt ) \ |
| 59 | debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 60 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 61 | |
| 62 | #else |
| 63 | |
| 64 | #define SSL_DEBUG_MSG( level, args ) do { } while( 0 ) |
| 65 | #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) |
| 66 | #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) |
| 67 | #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 68 | #define SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 69 | #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) |
| 70 | |
| 71 | #endif |
| 72 | |
| 73 | #ifdef __cplusplus |
| 74 | extern "C" { |
| 75 | #endif |
| 76 | |
| 77 | char *debug_fmt( const char *format, ... ); |
| 78 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 79 | void debug_print_msg( const ssl_context *ssl, int level, |
| 80 | const char *file, int line, const char *text ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 81 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 82 | void debug_print_ret( const ssl_context *ssl, int level, |
| 83 | const char *file, int line, |
| 84 | const char *text, int ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 85 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 86 | void debug_print_buf( const ssl_context *ssl, int level, |
| 87 | const char *file, int line, const char *text, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 88 | unsigned char *buf, size_t len ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 89 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 90 | #if defined(POLARSSL_BIGNUM_C) |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 91 | void debug_print_mpi( const ssl_context *ssl, int level, |
| 92 | const char *file, int line, |
| 93 | const char *text, const mpi *X ); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 94 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 95 | |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 96 | #if defined(POLARSSL_ECP_C) |
| 97 | void debug_print_ecp( const ssl_context *ssl, int level, |
| 98 | const char *file, int line, |
| 99 | const char *text, const ecp_point *X ); |
| 100 | #endif |
| 101 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 102 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 103 | void debug_print_crt( const ssl_context *ssl, int level, |
| 104 | const char *file, int line, |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 105 | const char *text, const x509_crt *crt ); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 106 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 107 | |
| 108 | #ifdef __cplusplus |
| 109 | } |
| 110 | #endif |
| 111 | |
| 112 | #endif /* debug.h */ |