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.
logging.h
00001 /* logging.h 00002 * 00003 * Copyright (C) 2006-2017 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 /*! 00023 \file wolfssl/wolfcrypt/logging.h 00024 */ 00025 00026 00027 /* submitted by eof */ 00028 00029 00030 #ifndef WOLFSSL_LOGGING_H 00031 #define WOLFSSL_LOGGING_H 00032 00033 #include <wolfcrypt/types.h> 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 00040 enum wc_LogLevels { 00041 ERROR_LOG = 0, 00042 INFO_LOG, 00043 ENTER_LOG, 00044 LEAVE_LOG, 00045 OTHER_LOG 00046 }; 00047 00048 #ifdef WOLFSSL_FUNC_TIME 00049 /* WARNING: This code is only to be used for debugging performance. 00050 * The code is not thread-safe. 00051 * Do not use WOLFSSL_FUNC_TIME in production code. 00052 */ 00053 enum wc_FuncNum { 00054 WC_FUNC_CLIENT_HELLO_SEND = 0, 00055 WC_FUNC_CLIENT_HELLO_DO, 00056 WC_FUNC_SERVER_HELLO_SEND, 00057 WC_FUNC_SERVER_HELLO_DO, 00058 WC_FUNC_ENCRYPTED_EXTENSIONS_SEND, 00059 WC_FUNC_ENCRYPTED_EXTENSIONS_DO, 00060 WC_FUNC_CERTIFICATE_REQUEST_SEND, 00061 WC_FUNC_CERTIFICATE_REQUEST_DO, 00062 WC_FUNC_CERTIFICATE_SEND, 00063 WC_FUNC_CERTIFICATE_DO, 00064 WC_FUNC_CERTIFICATE_VERIFY_SEND, 00065 WC_FUNC_CERTIFICATE_VERIFY_DO, 00066 WC_FUNC_FINISHED_SEND, 00067 WC_FUNC_FINISHED_DO, 00068 WC_FUNC_KEY_UPDATE_SEND, 00069 WC_FUNC_KEY_UPDATE_DO, 00070 WC_FUNC_EARLY_DATA_SEND, 00071 WC_FUNC_EARLY_DATA_DO, 00072 WC_FUNC_NEW_SESSION_TICKET_SEND, 00073 WC_FUNC_NEW_SESSION_TICKET_DO, 00074 WC_FUNC_SERVER_HELLO_DONE_SEND, 00075 WC_FUNC_SERVER_HELLO_DONE_DO, 00076 WC_FUNC_TICKET_SEND, 00077 WC_FUNC_TICKET_DO, 00078 WC_FUNC_CLIENT_KEY_EXCHANGE_SEND, 00079 WC_FUNC_CLIENT_KEY_EXCHANGE_DO, 00080 WC_FUNC_CERTIFICATE_STATUS_SEND, 00081 WC_FUNC_CERTIFICATE_STATUS_DO, 00082 WC_FUNC_SERVER_KEY_EXCHANGE_SEND, 00083 WC_FUNC_SERVER_KEY_EXCHANGE_DO, 00084 WC_FUNC_END_OF_EARLY_DATA_SEND, 00085 WC_FUNC_END_OF_EARLY_DATA_DO, 00086 WC_FUNC_COUNT 00087 }; 00088 #endif 00089 00090 typedef void (*wolfSSL_Logging_cb)(const int logLevel, 00091 const char *const logMessage); 00092 00093 WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function); 00094 00095 /* turn logging on, only if compiled in */ 00096 WOLFSSL_API int wolfSSL_Debugging_ON(void); 00097 /* turn logging off */ 00098 WOLFSSL_API void wolfSSL_Debugging_OFF(void); 00099 00100 00101 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) 00102 WOLFSSL_LOCAL int wc_LoggingInit(void); 00103 WOLFSSL_LOCAL int wc_LoggingCleanup(void); 00104 WOLFSSL_LOCAL int wc_AddErrorNode(int error, int line, char* buf, 00105 char* file); 00106 WOLFSSL_LOCAL int wc_PeekErrorNode(int index, const char **file, 00107 const char **reason, int *line); 00108 WOLFSSL_LOCAL void wc_RemoveErrorNode(int index); 00109 WOLFSSL_LOCAL void wc_ClearErrorNodes(void); 00110 WOLFSSL_LOCAL int wc_PullErrorNode(const char **file, const char **reason, 00111 int *line); 00112 WOLFSSL_API int wc_SetLoggingHeap(void* h); 00113 WOLFSSL_API int wc_ERR_remove_state(void); 00114 #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) 00115 WOLFSSL_API void wc_ERR_print_errors_fp(XFILE fp); 00116 #endif 00117 #endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE */ 00118 00119 #ifdef WOLFSSL_FUNC_TIME 00120 /* WARNING: This code is only to be used for debugging performance. 00121 * The code is not thread-safe. 00122 * Do not use WOLFSSL_FUNC_TIME in production code. 00123 */ 00124 WOLFSSL_API void WOLFSSL_START(int funcNum); 00125 WOLFSSL_API void WOLFSSL_END(int funcNum); 00126 WOLFSSL_API void WOLFSSL_TIME(int count); 00127 #else 00128 #define WOLFSSL_START(n) 00129 #define WOLFSSL_END(n) 00130 #define WOLFSSL_TIME(n) 00131 #endif 00132 00133 #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY) 00134 #if defined(_WIN32) 00135 #if defined(INTIME_RTOS) 00136 #define __func__ NULL 00137 #else 00138 #define __func__ __FUNCTION__ 00139 #endif 00140 #endif 00141 00142 /* a is prepended to m and b is appended, creating a log msg a + m + b */ 00143 #define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b 00144 00145 WOLFSSL_API void WOLFSSL_ENTER(const char* msg); 00146 WOLFSSL_API void WOLFSSL_LEAVE(const char* msg, int ret); 00147 #define WOLFSSL_STUB(m) \ 00148 WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented)) 00149 00150 WOLFSSL_API void WOLFSSL_MSG(const char* msg); 00151 WOLFSSL_API void WOLFSSL_BUFFER(const byte* buffer, word32 length); 00152 00153 #else 00154 00155 #define WOLFSSL_ENTER(m) 00156 #define WOLFSSL_LEAVE(m, r) 00157 #define WOLFSSL_STUB(m) 00158 00159 #define WOLFSSL_MSG(m) 00160 #define WOLFSSL_BUFFER(b, l) 00161 00162 #endif /* DEBUG_WOLFSSL && !WOLFSSL_DEBUG_ERRORS_ONLY */ 00163 00164 #if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 00165 00166 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) 00167 WOLFSSL_API void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line, 00168 const char* file, void* ctx); 00169 #define WOLFSSL_ERROR(x) \ 00170 WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__, NULL) 00171 #else 00172 WOLFSSL_API void WOLFSSL_ERROR(int err); 00173 #endif 00174 WOLFSSL_API void WOLFSSL_ERROR_MSG(const char* msg); 00175 00176 #else 00177 #define WOLFSSL_ERROR(e) 00178 #define WOLFSSL_ERROR_MSG(m) 00179 #endif 00180 00181 #ifdef __cplusplus 00182 } 00183 #endif 00184 #endif /* WOLFSSL_LOGGING_H */ 00185 00186
Generated on Tue Jul 12 2022 16:58:06 by
1.7.2