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 | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 6 | * Copyright (C) 2006-2010, 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 | */ |
| 27 | #ifndef SSL_DEBUG_H |
| 28 | #define SSL_DEBUG_H |
| 29 | |
Paul Bakker | 8e831ed | 2009-01-03 21:24:11 +0000 | [diff] [blame] | 30 | #include "polarssl/config.h" |
| 31 | #include "polarssl/ssl.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 32 | |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame^] | 33 | #if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 34 | |
| 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 |
| 61 | extern "C" { |
| 62 | #endif |
| 63 | |
| 64 | char *debug_fmt( const char *format, ... ); |
| 65 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 66 | void debug_print_msg( const ssl_context *ssl, int level, |
| 67 | const char *file, int line, const char *text ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 68 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 69 | void debug_print_ret( const ssl_context *ssl, int level, |
| 70 | const char *file, int line, |
| 71 | const char *text, int ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 72 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 73 | void debug_print_buf( const ssl_context *ssl, int level, |
| 74 | const char *file, int line, const char *text, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 75 | unsigned char *buf, size_t len ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 76 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 77 | void debug_print_mpi( const ssl_context *ssl, int level, |
| 78 | const char *file, int line, |
| 79 | const char *text, const mpi *X ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 80 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 81 | void debug_print_crt( const ssl_context *ssl, int level, |
| 82 | const char *file, int line, |
| 83 | const char *text, const x509_cert *crt ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 84 | |
| 85 | #ifdef __cplusplus |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | #endif /* debug.h */ |