BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
debug.h
00001 /** 00002 * \file debug.h 00003 * 00004 * \brief Functions for controlling and providing debug output from the library. 00005 */ 00006 /* 00007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00008 * SPDX-License-Identifier: Apache-2.0 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00011 * not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00018 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 * 00022 * This file is part of mbed TLS (https://tls.mbed.org) 00023 */ 00024 #ifndef MBEDTLS_DEBUG_H 00025 #define MBEDTLS_DEBUG_H 00026 00027 #if !defined(MBEDTLS_CONFIG_FILE) 00028 #include "config.h" 00029 #else 00030 #include MBEDTLS_CONFIG_FILE 00031 #endif 00032 00033 #include "ssl.h" 00034 00035 #if defined(MBEDTLS_ECP_C) 00036 #include "ecp.h" 00037 #endif 00038 00039 #if defined(MBEDTLS_DEBUG_C) 00040 00041 #define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__ 00042 00043 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) \ 00044 mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \ 00045 MBEDTLS_DEBUG_STRIP_PARENS args ) 00046 00047 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \ 00048 mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ) 00049 00050 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \ 00051 mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ) 00052 00053 #if defined(MBEDTLS_BIGNUM_C) 00054 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \ 00055 mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ) 00056 #endif 00057 00058 #if defined(MBEDTLS_ECP_C) 00059 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \ 00060 mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X ) 00061 #endif 00062 00063 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00064 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \ 00065 mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ) 00066 #endif 00067 00068 #else /* MBEDTLS_DEBUG_C */ 00069 00070 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 ) 00071 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) 00072 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) 00073 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) 00074 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) 00075 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) 00076 00077 #endif /* MBEDTLS_DEBUG_C */ 00078 00079 #ifdef __cplusplus 00080 extern "C" { 00081 #endif 00082 00083 /** 00084 * \brief Set the threshold error level to handle globally all debug output. 00085 * Debug messages that have a level over the threshold value are 00086 * discarded. 00087 * (Default value: 0 = No debug ) 00088 * 00089 * \param threshold theshold level of messages to filter on. Messages at a 00090 * higher level will be discarded. 00091 * - Debug levels 00092 * - 0 No debug 00093 * - 1 Error 00094 * - 2 State change 00095 * - 3 Informational 00096 * - 4 Verbose 00097 */ 00098 void mbedtls_debug_set_threshold( int threshold ); 00099 00100 /** 00101 * \brief Print a message to the debug output. This function is always used 00102 * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl 00103 * context, file and line number parameters. 00104 * 00105 * \param ssl SSL context 00106 * \param level error level of the debug message 00107 * \param file file the message has occurred in 00108 * \param line line number the message has occurred at 00109 * \param format format specifier, in printf format 00110 * \param ... variables used by the format specifier 00111 * 00112 * \attention This function is intended for INTERNAL usage within the 00113 * library only. 00114 */ 00115 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, 00116 const char *file, int line, 00117 const char *format, ... ); 00118 00119 /** 00120 * \brief Print the return value of a function to the debug output. This 00121 * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro, 00122 * which supplies the ssl context, file and line number parameters. 00123 * 00124 * \param ssl SSL context 00125 * \param level error level of the debug message 00126 * \param file file the error has occurred in 00127 * \param line line number the error has occurred in 00128 * \param text the name of the function that returned the error 00129 * \param ret the return code value 00130 * 00131 * \attention This function is intended for INTERNAL usage within the 00132 * library only. 00133 */ 00134 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, 00135 const char *file, int line, 00136 const char *text, int ret ); 00137 00138 /** 00139 * \brief Output a buffer of size len bytes to the debug output. This function 00140 * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro, 00141 * which supplies the ssl context, file and line number parameters. 00142 * 00143 * \param ssl SSL context 00144 * \param level error level of the debug message 00145 * \param file file the error has occurred in 00146 * \param line line number the error has occurred in 00147 * \param text a name or label for the buffer being dumped. Normally the 00148 * variable or buffer name 00149 * \param buf the buffer to be outputted 00150 * \param len length of the buffer 00151 * 00152 * \attention This function is intended for INTERNAL usage within the 00153 * library only. 00154 */ 00155 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level, 00156 const char *file, int line, const char *text, 00157 const unsigned char *buf, size_t len ); 00158 00159 #if defined(MBEDTLS_BIGNUM_C) 00160 /** 00161 * \brief Print a MPI variable to the debug output. This function is always 00162 * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the 00163 * ssl context, file and line number parameters. 00164 * 00165 * \param ssl SSL context 00166 * \param level error level of the debug message 00167 * \param file file the error has occurred in 00168 * \param line line number the error has occurred in 00169 * \param text a name or label for the MPI being output. Normally the 00170 * variable name 00171 * \param X the MPI variable 00172 * 00173 * \attention This function is intended for INTERNAL usage within the 00174 * library only. 00175 */ 00176 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, 00177 const char *file, int line, 00178 const char *text, const mbedtls_mpi *X ); 00179 #endif 00180 00181 #if defined(MBEDTLS_ECP_C) 00182 /** 00183 * \brief Print an ECP point to the debug output. This function is always 00184 * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the 00185 * ssl context, file and line number parameters. 00186 * 00187 * \param ssl SSL context 00188 * \param level error level of the debug message 00189 * \param file file the error has occurred in 00190 * \param line line number the error has occurred in 00191 * \param text a name or label for the ECP point being output. Normally the 00192 * variable name 00193 * \param X the ECP point 00194 * 00195 * \attention This function is intended for INTERNAL usage within the 00196 * library only. 00197 */ 00198 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level, 00199 const char *file, int line, 00200 const char *text, const mbedtls_ecp_point *X ); 00201 #endif 00202 00203 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00204 /** 00205 * \brief Print a X.509 certificate structure to the debug output. This 00206 * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro, 00207 * which supplies the ssl context, file and line number parameters. 00208 * 00209 * \param ssl SSL context 00210 * \param level error level of the debug message 00211 * \param file file the error has occurred in 00212 * \param line line number the error has occurred in 00213 * \param text a name or label for the certificate being output 00214 * \param crt X.509 certificate structure 00215 * 00216 * \attention This function is intended for INTERNAL usage within the 00217 * library only. 00218 */ 00219 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, 00220 const char *file, int line, 00221 const char *text, const mbedtls_x509_crt *crt ); 00222 #endif 00223 00224 #ifdef __cplusplus 00225 } 00226 #endif 00227 00228 #endif /* debug.h */ 00229
Generated on Tue Jul 12 2022 12:21:48 by
