mbed TLS library
Dependents: HTTPClient-SSL WS_SERVER
include/polarssl/debug.h@0:137634ff4186, 2015-06-11 (annotated)
- Committer:
- ansond
- Date:
- Thu Jun 11 03:27:03 2015 +0000
- Revision:
- 0:137634ff4186
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:137634ff4186 | 1 | /** |
ansond | 0:137634ff4186 | 2 | * \file debug.h |
ansond | 0:137634ff4186 | 3 | * |
ansond | 0:137634ff4186 | 4 | * \brief Debug functions |
ansond | 0:137634ff4186 | 5 | * |
ansond | 0:137634ff4186 | 6 | * Copyright (C) 2006-2011, ARM Limited, All Rights Reserved |
ansond | 0:137634ff4186 | 7 | * |
ansond | 0:137634ff4186 | 8 | * This file is part of mbed TLS (https://tls.mbed.org) |
ansond | 0:137634ff4186 | 9 | * |
ansond | 0:137634ff4186 | 10 | * This program is free software; you can redistribute it and/or modify |
ansond | 0:137634ff4186 | 11 | * it under the terms of the GNU General Public License as published by |
ansond | 0:137634ff4186 | 12 | * the Free Software Foundation; either version 2 of the License, or |
ansond | 0:137634ff4186 | 13 | * (at your option) any later version. |
ansond | 0:137634ff4186 | 14 | * |
ansond | 0:137634ff4186 | 15 | * This program is distributed in the hope that it will be useful, |
ansond | 0:137634ff4186 | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ansond | 0:137634ff4186 | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ansond | 0:137634ff4186 | 18 | * GNU General Public License for more details. |
ansond | 0:137634ff4186 | 19 | * |
ansond | 0:137634ff4186 | 20 | * You should have received a copy of the GNU General Public License along |
ansond | 0:137634ff4186 | 21 | * with this program; if not, write to the Free Software Foundation, Inc., |
ansond | 0:137634ff4186 | 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ansond | 0:137634ff4186 | 23 | */ |
ansond | 0:137634ff4186 | 24 | #ifndef POLARSSL_DEBUG_H |
ansond | 0:137634ff4186 | 25 | #define POLARSSL_DEBUG_H |
ansond | 0:137634ff4186 | 26 | |
ansond | 0:137634ff4186 | 27 | #if !defined(POLARSSL_CONFIG_FILE) |
ansond | 0:137634ff4186 | 28 | #include "config.h" |
ansond | 0:137634ff4186 | 29 | #else |
ansond | 0:137634ff4186 | 30 | #include POLARSSL_CONFIG_FILE |
ansond | 0:137634ff4186 | 31 | #endif |
ansond | 0:137634ff4186 | 32 | |
ansond | 0:137634ff4186 | 33 | #include "ssl.h" |
ansond | 0:137634ff4186 | 34 | |
ansond | 0:137634ff4186 | 35 | #if defined(POLARSSL_ECP_C) |
ansond | 0:137634ff4186 | 36 | #include "ecp.h" |
ansond | 0:137634ff4186 | 37 | #endif |
ansond | 0:137634ff4186 | 38 | |
ansond | 0:137634ff4186 | 39 | #if defined(POLARSSL_DEBUG_C) |
ansond | 0:137634ff4186 | 40 | |
ansond | 0:137634ff4186 | 41 | #define POLARSSL_DEBUG_LOG_FULL 0 /**< Include file:line in log lines */ |
ansond | 0:137634ff4186 | 42 | #define POLARSSL_DEBUG_LOG_RAW 1 /**< Only log raw debug lines */ |
ansond | 0:137634ff4186 | 43 | |
ansond | 0:137634ff4186 | 44 | /** |
ansond | 0:137634ff4186 | 45 | * \name SECTION: Module settings |
ansond | 0:137634ff4186 | 46 | * |
ansond | 0:137634ff4186 | 47 | * The configuration options you can set for this module are in this section. |
ansond | 0:137634ff4186 | 48 | * Either change them in config.h or define them on the compiler command line. |
ansond | 0:137634ff4186 | 49 | * \{ |
ansond | 0:137634ff4186 | 50 | */ |
ansond | 0:137634ff4186 | 51 | |
ansond | 0:137634ff4186 | 52 | #if !defined(POLARSSL_DEBUG_DFL_MODE) |
ansond | 0:137634ff4186 | 53 | #define POLARSSL_DEBUG_DFL_MODE POLARSSL_DEBUG_LOG_FULL /**< Default log: Full or Raw */ |
ansond | 0:137634ff4186 | 54 | #endif |
ansond | 0:137634ff4186 | 55 | |
ansond | 0:137634ff4186 | 56 | /* \} name SECTION: Module settings */ |
ansond | 0:137634ff4186 | 57 | |
ansond | 0:137634ff4186 | 58 | |
ansond | 0:137634ff4186 | 59 | #define SSL_DEBUG_MSG( level, args ) \ |
ansond | 0:137634ff4186 | 60 | debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args ); |
ansond | 0:137634ff4186 | 61 | |
ansond | 0:137634ff4186 | 62 | #define SSL_DEBUG_RET( level, text, ret ) \ |
ansond | 0:137634ff4186 | 63 | debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ); |
ansond | 0:137634ff4186 | 64 | |
ansond | 0:137634ff4186 | 65 | #define SSL_DEBUG_BUF( level, text, buf, len ) \ |
ansond | 0:137634ff4186 | 66 | debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ); |
ansond | 0:137634ff4186 | 67 | |
ansond | 0:137634ff4186 | 68 | #if defined(POLARSSL_BIGNUM_C) |
ansond | 0:137634ff4186 | 69 | #define SSL_DEBUG_MPI( level, text, X ) \ |
ansond | 0:137634ff4186 | 70 | debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ); |
ansond | 0:137634ff4186 | 71 | #endif |
ansond | 0:137634ff4186 | 72 | |
ansond | 0:137634ff4186 | 73 | #if defined(POLARSSL_ECP_C) |
ansond | 0:137634ff4186 | 74 | #define SSL_DEBUG_ECP( level, text, X ) \ |
ansond | 0:137634ff4186 | 75 | debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X ); |
ansond | 0:137634ff4186 | 76 | #endif |
ansond | 0:137634ff4186 | 77 | |
ansond | 0:137634ff4186 | 78 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
ansond | 0:137634ff4186 | 79 | #define SSL_DEBUG_CRT( level, text, crt ) \ |
ansond | 0:137634ff4186 | 80 | debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ); |
ansond | 0:137634ff4186 | 81 | #endif |
ansond | 0:137634ff4186 | 82 | |
ansond | 0:137634ff4186 | 83 | #else /* POLARSSL_DEBUG_C */ |
ansond | 0:137634ff4186 | 84 | |
ansond | 0:137634ff4186 | 85 | #define SSL_DEBUG_MSG( level, args ) do { } while( 0 ) |
ansond | 0:137634ff4186 | 86 | #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) |
ansond | 0:137634ff4186 | 87 | #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) |
ansond | 0:137634ff4186 | 88 | #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) |
ansond | 0:137634ff4186 | 89 | #define SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) |
ansond | 0:137634ff4186 | 90 | #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) |
ansond | 0:137634ff4186 | 91 | |
ansond | 0:137634ff4186 | 92 | #endif /* POLARSSL_DEBUG_C */ |
ansond | 0:137634ff4186 | 93 | |
ansond | 0:137634ff4186 | 94 | #ifdef __cplusplus |
ansond | 0:137634ff4186 | 95 | extern "C" { |
ansond | 0:137634ff4186 | 96 | #endif |
ansond | 0:137634ff4186 | 97 | |
ansond | 0:137634ff4186 | 98 | /** |
ansond | 0:137634ff4186 | 99 | * \brief Set the log mode for the debug functions globally |
ansond | 0:137634ff4186 | 100 | * (Default value: POLARSSL_DEBUG_DFL_MODE) |
ansond | 0:137634ff4186 | 101 | * |
ansond | 0:137634ff4186 | 102 | * \param log_mode The log mode to use (POLARSSL_DEBUG_LOG_FULL or |
ansond | 0:137634ff4186 | 103 | * POLARSSL_DEBUG_LOG_RAW) |
ansond | 0:137634ff4186 | 104 | */ |
ansond | 0:137634ff4186 | 105 | void debug_set_log_mode( int log_mode ); |
ansond | 0:137634ff4186 | 106 | |
ansond | 0:137634ff4186 | 107 | /** |
ansond | 0:137634ff4186 | 108 | * \brief Set the level threshold to handle globally. Messages that have a |
ansond | 0:137634ff4186 | 109 | * level over the threshold value are ignored. |
ansond | 0:137634ff4186 | 110 | * (Default value: 0 (No debug)) |
ansond | 0:137634ff4186 | 111 | * |
ansond | 0:137634ff4186 | 112 | * \param threshold maximum level of messages to pass on |
ansond | 0:137634ff4186 | 113 | */ |
ansond | 0:137634ff4186 | 114 | void debug_set_threshold( int threshold ); |
ansond | 0:137634ff4186 | 115 | |
ansond | 0:137634ff4186 | 116 | char *debug_fmt( const char *format, ... ); |
ansond | 0:137634ff4186 | 117 | |
ansond | 0:137634ff4186 | 118 | void debug_print_msg( const ssl_context *ssl, int level, |
ansond | 0:137634ff4186 | 119 | const char *file, int line, const char *text ); |
ansond | 0:137634ff4186 | 120 | |
ansond | 0:137634ff4186 | 121 | void debug_print_ret( const ssl_context *ssl, int level, |
ansond | 0:137634ff4186 | 122 | const char *file, int line, |
ansond | 0:137634ff4186 | 123 | const char *text, int ret ); |
ansond | 0:137634ff4186 | 124 | |
ansond | 0:137634ff4186 | 125 | void debug_print_buf( const ssl_context *ssl, int level, |
ansond | 0:137634ff4186 | 126 | const char *file, int line, const char *text, |
ansond | 0:137634ff4186 | 127 | unsigned char *buf, size_t len ); |
ansond | 0:137634ff4186 | 128 | |
ansond | 0:137634ff4186 | 129 | #if defined(POLARSSL_BIGNUM_C) |
ansond | 0:137634ff4186 | 130 | void debug_print_mpi( const ssl_context *ssl, int level, |
ansond | 0:137634ff4186 | 131 | const char *file, int line, |
ansond | 0:137634ff4186 | 132 | const char *text, const mpi *X ); |
ansond | 0:137634ff4186 | 133 | #endif |
ansond | 0:137634ff4186 | 134 | |
ansond | 0:137634ff4186 | 135 | #if defined(POLARSSL_ECP_C) |
ansond | 0:137634ff4186 | 136 | void debug_print_ecp( const ssl_context *ssl, int level, |
ansond | 0:137634ff4186 | 137 | const char *file, int line, |
ansond | 0:137634ff4186 | 138 | const char *text, const ecp_point *X ); |
ansond | 0:137634ff4186 | 139 | #endif |
ansond | 0:137634ff4186 | 140 | |
ansond | 0:137634ff4186 | 141 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
ansond | 0:137634ff4186 | 142 | void debug_print_crt( const ssl_context *ssl, int level, |
ansond | 0:137634ff4186 | 143 | const char *file, int line, |
ansond | 0:137634ff4186 | 144 | const char *text, const x509_crt *crt ); |
ansond | 0:137634ff4186 | 145 | #endif |
ansond | 0:137634ff4186 | 146 | |
ansond | 0:137634ff4186 | 147 | #ifdef __cplusplus |
ansond | 0:137634ff4186 | 148 | } |
ansond | 0:137634ff4186 | 149 | #endif |
ansond | 0:137634ff4186 | 150 | |
ansond | 0:137634ff4186 | 151 | #endif /* debug.h */ |
ansond | 0:137634ff4186 | 152 |