mbed TLS library

Dependents:   HTTPClient-SSL WS_SERVER

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

Go to the documentation of this file.
00001 /**
00002  * \file debug.h
00003  *
00004  * \brief Debug functions
00005  *
00006  *  Copyright (C) 2006-2011, ARM Limited, All Rights Reserved
00007  *
00008  *  This file is part of mbed TLS (https://tls.mbed.org)
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License along
00021  *  with this program; if not, write to the Free Software Foundation, Inc.,
00022  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00023  */
00024 #ifndef POLARSSL_DEBUG_H
00025 #define POLARSSL_DEBUG_H
00026 
00027 #if !defined(POLARSSL_CONFIG_FILE)
00028 #include "config.h"
00029 #else
00030 #include POLARSSL_CONFIG_FILE
00031 #endif
00032 
00033 #include "ssl.h"
00034 
00035 #if defined(POLARSSL_ECP_C)
00036 #include "ecp.h"
00037 #endif
00038 
00039 #if defined(POLARSSL_DEBUG_C)
00040 
00041 #define POLARSSL_DEBUG_LOG_FULL         0 /**< Include file:line in log lines */
00042 #define POLARSSL_DEBUG_LOG_RAW          1 /**< Only log raw debug lines */
00043 
00044 /**
00045  * \name SECTION: Module settings
00046  *
00047  * The configuration options you can set for this module are in this section.
00048  * Either change them in config.h or define them on the compiler command line.
00049  * \{
00050  */
00051 
00052 #if !defined(POLARSSL_DEBUG_DFL_MODE)
00053 #define POLARSSL_DEBUG_DFL_MODE POLARSSL_DEBUG_LOG_FULL /**< Default log: Full or Raw */
00054 #endif
00055 
00056 /* \} name SECTION: Module settings */
00057 
00058 
00059 #define SSL_DEBUG_MSG( level, args )                    \
00060     debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
00061 
00062 #define SSL_DEBUG_RET( level, text, ret )                \
00063     debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
00064 
00065 #define SSL_DEBUG_BUF( level, text, buf, len )           \
00066     debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
00067 
00068 #if defined(POLARSSL_BIGNUM_C)
00069 #define SSL_DEBUG_MPI( level, text, X )                  \
00070     debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
00071 #endif
00072 
00073 #if defined(POLARSSL_ECP_C)
00074 #define SSL_DEBUG_ECP( level, text, X )                  \
00075     debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X );
00076 #endif
00077 
00078 #if defined(POLARSSL_X509_CRT_PARSE_C)
00079 #define SSL_DEBUG_CRT( level, text, crt )                \
00080     debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
00081 #endif
00082 
00083 #else /* POLARSSL_DEBUG_C */
00084 
00085 #define SSL_DEBUG_MSG( level, args )            do { } while( 0 )
00086 #define SSL_DEBUG_RET( level, text, ret )       do { } while( 0 )
00087 #define SSL_DEBUG_BUF( level, text, buf, len )  do { } while( 0 )
00088 #define SSL_DEBUG_MPI( level, text, X )         do { } while( 0 )
00089 #define SSL_DEBUG_ECP( level, text, X )         do { } while( 0 )
00090 #define SSL_DEBUG_CRT( level, text, crt )       do { } while( 0 )
00091 
00092 #endif /* POLARSSL_DEBUG_C */
00093 
00094 #ifdef __cplusplus
00095 extern "C" {
00096 #endif
00097 
00098 /**
00099  * \brief   Set the log mode for the debug functions globally
00100  *          (Default value: POLARSSL_DEBUG_DFL_MODE)
00101  *
00102  * \param log_mode      The log mode to use (POLARSSL_DEBUG_LOG_FULL or
00103  *                                           POLARSSL_DEBUG_LOG_RAW)
00104  */
00105 void debug_set_log_mode( int log_mode );
00106 
00107 /**
00108  * \brief   Set the level threshold to handle globally. Messages that have a
00109  *          level over the threshold value are ignored.
00110  *          (Default value: 0 (No debug))
00111  *
00112  * \param threshold     maximum level of messages to pass on
00113  */
00114 void debug_set_threshold( int threshold );
00115 
00116 char *debug_fmt( const char *format, ... );
00117 
00118 void debug_print_msg( const ssl_context *ssl, int level,
00119                       const char *file, int line, const char *text );
00120 
00121 void debug_print_ret( const ssl_context *ssl, int level,
00122                       const char *file, int line,
00123                       const char *text, int ret );
00124 
00125 void debug_print_buf( const ssl_context *ssl, int level,
00126                       const char *file, int line, const char *text,
00127                       unsigned char *buf, size_t len );
00128 
00129 #if defined(POLARSSL_BIGNUM_C)
00130 void debug_print_mpi( const ssl_context *ssl, int level,
00131                       const char *file, int line,
00132                       const char *text, const mpi *X );
00133 #endif
00134 
00135 #if defined(POLARSSL_ECP_C)
00136 void debug_print_ecp( const ssl_context *ssl, int level,
00137                       const char *file, int line,
00138                       const char *text, const ecp_point *X );
00139 #endif
00140 
00141 #if defined(POLARSSL_X509_CRT_PARSE_C)
00142 void debug_print_crt( const ssl_context *ssl, int level,
00143                       const char *file, int line,
00144                       const char *text, const x509_crt *crt );
00145 #endif
00146 
00147 #ifdef __cplusplus
00148 }
00149 #endif
00150 
00151 #endif /* debug.h */
00152