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