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 | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 4 | * Copyright (C) 2006-2010, Brainspark B.V. |
| 5 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 6 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 7 | * |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 21 | */ |
| 22 | #ifndef SSL_DEBUG_H |
| 23 | #define SSL_DEBUG_H |
| 24 | |
Paul Bakker | 8e831ed | 2009-01-03 21:24:11 +0000 | [diff] [blame] | 25 | #include "polarssl/config.h" |
| 26 | #include "polarssl/ssl.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 27 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 28 | #if defined(POLARSSL_DEBUG_MSG) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 | |
| 30 | #define SSL_DEBUG_MSG( level, args ) \ |
| 31 | debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args ); |
| 32 | |
| 33 | #define SSL_DEBUG_RET( level, text, ret ) \ |
| 34 | debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ); |
| 35 | |
| 36 | #define SSL_DEBUG_BUF( level, text, buf, len ) \ |
| 37 | debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ); |
| 38 | |
| 39 | #define SSL_DEBUG_MPI( level, text, X ) \ |
| 40 | debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ); |
| 41 | |
| 42 | #define SSL_DEBUG_CRT( level, text, crt ) \ |
| 43 | debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ); |
| 44 | |
| 45 | #else |
| 46 | |
| 47 | #define SSL_DEBUG_MSG( level, args ) do { } while( 0 ) |
| 48 | #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) |
| 49 | #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) |
| 50 | #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) |
| 51 | #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) |
| 52 | |
| 53 | #endif |
| 54 | |
| 55 | #ifdef __cplusplus |
| 56 | extern "C" { |
| 57 | #endif |
| 58 | |
| 59 | char *debug_fmt( const char *format, ... ); |
| 60 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 61 | void debug_print_msg( const ssl_context *ssl, int level, |
| 62 | const char *file, int line, const char *text ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 63 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 64 | void debug_print_ret( const ssl_context *ssl, int level, |
| 65 | const char *file, int line, |
| 66 | const char *text, int ret ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 67 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 68 | void debug_print_buf( const ssl_context *ssl, int level, |
| 69 | const char *file, int line, const char *text, |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 70 | unsigned char *buf, int len ); |
| 71 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 72 | void debug_print_mpi( const ssl_context *ssl, int level, |
| 73 | const char *file, int line, |
| 74 | const char *text, const mpi *X ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 75 | |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 76 | void debug_print_crt( const ssl_context *ssl, int level, |
| 77 | const char *file, int line, |
| 78 | const char *text, const x509_cert *crt ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 79 | |
| 80 | #ifdef __cplusplus |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | #endif /* debug.h */ |