Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
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 "mbedtls/config.h" 00029 #else 00030 #include MBEDTLS_CONFIG_FILE 00031 #endif 00032 00033 #include "mbedtls/ssl.h" 00034 00035 #if defined(MBEDTLS_ECP_C) 00036 #include "mbedtls/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 #if defined(MBEDTLS_ECDH_C) 00069 #define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) \ 00070 mbedtls_debug_printf_ecdh( ssl, level, __FILE__, __LINE__, ecdh, attr ) 00071 #endif 00072 00073 #else /* MBEDTLS_DEBUG_C */ 00074 00075 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 ) 00076 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) 00077 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) 00078 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) 00079 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) 00080 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) 00081 #define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) do { } while( 0 ) 00082 00083 #endif /* MBEDTLS_DEBUG_C */ 00084 00085 #ifdef __cplusplus 00086 extern "C" { 00087 #endif 00088 00089 /** 00090 * \brief Set the threshold error level to handle globally all debug output. 00091 * Debug messages that have a level over the threshold value are 00092 * discarded. 00093 * (Default value: 0 = No debug ) 00094 * 00095 * \param threshold theshold level of messages to filter on. Messages at a 00096 * higher level will be discarded. 00097 * - Debug levels 00098 * - 0 No debug 00099 * - 1 Error 00100 * - 2 State change 00101 * - 3 Informational 00102 * - 4 Verbose 00103 */ 00104 void mbedtls_debug_set_threshold( int threshold ); 00105 00106 /** 00107 * \brief Print a message to the debug output. This function is always used 00108 * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl 00109 * context, file and line number parameters. 00110 * 00111 * \param ssl SSL context 00112 * \param level error level of the debug message 00113 * \param file file the message has occurred in 00114 * \param line line number the message has occurred at 00115 * \param format format specifier, in printf format 00116 * \param ... variables used by the format specifier 00117 * 00118 * \attention This function is intended for INTERNAL usage within the 00119 * library only. 00120 */ 00121 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, 00122 const char *file, int line, 00123 const char *format, ... ); 00124 00125 /** 00126 * \brief Print the return value of a function to the debug output. This 00127 * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro, 00128 * which supplies the ssl context, file and line number parameters. 00129 * 00130 * \param ssl SSL context 00131 * \param level error level of the debug message 00132 * \param file file the error has occurred in 00133 * \param line line number the error has occurred in 00134 * \param text the name of the function that returned the error 00135 * \param ret the return code value 00136 * 00137 * \attention This function is intended for INTERNAL usage within the 00138 * library only. 00139 */ 00140 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, 00141 const char *file, int line, 00142 const char *text, int ret ); 00143 00144 /** 00145 * \brief Output a buffer of size len bytes to the debug output. This function 00146 * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro, 00147 * which supplies the ssl context, file and line number parameters. 00148 * 00149 * \param ssl SSL context 00150 * \param level error level of the debug message 00151 * \param file file the error has occurred in 00152 * \param line line number the error has occurred in 00153 * \param text a name or label for the buffer being dumped. Normally the 00154 * variable or buffer name 00155 * \param buf the buffer to be outputted 00156 * \param len length of the buffer 00157 * 00158 * \attention This function is intended for INTERNAL usage within the 00159 * library only. 00160 */ 00161 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level, 00162 const char *file, int line, const char *text, 00163 const unsigned char *buf, size_t len ); 00164 00165 #if defined(MBEDTLS_BIGNUM_C) 00166 /** 00167 * \brief Print a MPI variable to the debug output. This function is always 00168 * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the 00169 * ssl context, file and line number parameters. 00170 * 00171 * \param ssl SSL context 00172 * \param level error level of the debug message 00173 * \param file file the error has occurred in 00174 * \param line line number the error has occurred in 00175 * \param text a name or label for the MPI being output. Normally the 00176 * variable name 00177 * \param X the MPI variable 00178 * 00179 * \attention This function is intended for INTERNAL usage within the 00180 * library only. 00181 */ 00182 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, 00183 const char *file, int line, 00184 const char *text, const mbedtls_mpi *X ); 00185 #endif 00186 00187 #if defined(MBEDTLS_ECP_C) 00188 /** 00189 * \brief Print an ECP point to the debug output. This function is always 00190 * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the 00191 * ssl context, file and line number parameters. 00192 * 00193 * \param ssl SSL context 00194 * \param level error level of the debug message 00195 * \param file file the error has occurred in 00196 * \param line line number the error has occurred in 00197 * \param text a name or label for the ECP point being output. Normally the 00198 * variable name 00199 * \param X the ECP point 00200 * 00201 * \attention This function is intended for INTERNAL usage within the 00202 * library only. 00203 */ 00204 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level, 00205 const char *file, int line, 00206 const char *text, const mbedtls_ecp_point *X ); 00207 #endif 00208 00209 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00210 /** 00211 * \brief Print a X.509 certificate structure to the debug output. This 00212 * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro, 00213 * which supplies the ssl context, file and line number parameters. 00214 * 00215 * \param ssl SSL context 00216 * \param level error level of the debug message 00217 * \param file file the error has occurred in 00218 * \param line line number the error has occurred in 00219 * \param text a name or label for the certificate being output 00220 * \param crt X.509 certificate structure 00221 * 00222 * \attention This function is intended for INTERNAL usage within the 00223 * library only. 00224 */ 00225 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, 00226 const char *file, int line, 00227 const char *text, const mbedtls_x509_crt *crt ); 00228 #endif 00229 00230 #if defined(MBEDTLS_ECDH_C) 00231 typedef enum 00232 { 00233 MBEDTLS_DEBUG_ECDH_Q, 00234 MBEDTLS_DEBUG_ECDH_QP, 00235 MBEDTLS_DEBUG_ECDH_Z, 00236 } mbedtls_debug_ecdh_attr; 00237 00238 /** 00239 * \brief Print a field of the ECDH structure in the SSL context to the debug 00240 * output. This function is always used through the 00241 * MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file 00242 * and line number parameters. 00243 * 00244 * \param ssl SSL context 00245 * \param level error level of the debug message 00246 * \param file file the error has occurred in 00247 * \param line line number the error has occurred in 00248 * \param ecdh the ECDH context 00249 * \param attr the identifier of the attribute being output 00250 * 00251 * \attention This function is intended for INTERNAL usage within the 00252 * library only. 00253 */ 00254 void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level, 00255 const char *file, int line, 00256 const mbedtls_ecdh_context *ecdh, 00257 mbedtls_debug_ecdh_attr attr ); 00258 #endif 00259 00260 #ifdef __cplusplus 00261 } 00262 #endif 00263 00264 #endif /* debug.h */
Generated on Tue Jul 12 2022 13:54:16 by
