ssh lib

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:23:49 2019 +0000
Revision:
1:e4ea39eba2fb
Parent:
0:1387ff3eed4a
improved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sPymbed 0:1387ff3eed4a 1 /* logging.h
sPymbed 0:1387ff3eed4a 2 *
sPymbed 0:1387ff3eed4a 3 * Copyright (C) 2006-2017 wolfSSL Inc.
sPymbed 0:1387ff3eed4a 4 *
sPymbed 0:1387ff3eed4a 5 * This file is part of wolfSSL.
sPymbed 0:1387ff3eed4a 6 *
sPymbed 0:1387ff3eed4a 7 * wolfSSL is free software; you can redistribute it and/or modify
sPymbed 0:1387ff3eed4a 8 * it under the terms of the GNU General Public License as published by
sPymbed 0:1387ff3eed4a 9 * the Free Software Foundation; either version 2 of the License, or
sPymbed 0:1387ff3eed4a 10 * (at your option) any later version.
sPymbed 0:1387ff3eed4a 11 *
sPymbed 0:1387ff3eed4a 12 * wolfSSL is distributed in the hope that it will be useful,
sPymbed 0:1387ff3eed4a 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
sPymbed 0:1387ff3eed4a 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
sPymbed 0:1387ff3eed4a 15 * GNU General Public License for more details.
sPymbed 0:1387ff3eed4a 16 *
sPymbed 0:1387ff3eed4a 17 * You should have received a copy of the GNU General Public License
sPymbed 0:1387ff3eed4a 18 * along with this program; if not, write to the Free Software
sPymbed 0:1387ff3eed4a 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
sPymbed 0:1387ff3eed4a 20 */
sPymbed 0:1387ff3eed4a 21
sPymbed 0:1387ff3eed4a 22 /*!
sPymbed 0:1387ff3eed4a 23 \file wolfssl/wolfcrypt/logging.h
sPymbed 0:1387ff3eed4a 24 */
sPymbed 0:1387ff3eed4a 25
sPymbed 0:1387ff3eed4a 26
sPymbed 0:1387ff3eed4a 27 /* submitted by eof */
sPymbed 0:1387ff3eed4a 28
sPymbed 0:1387ff3eed4a 29
sPymbed 0:1387ff3eed4a 30 #ifndef WOLFSSL_LOGGING_H
sPymbed 0:1387ff3eed4a 31 #define WOLFSSL_LOGGING_H
sPymbed 0:1387ff3eed4a 32
sPymbed 0:1387ff3eed4a 33 #include <wolfcrypt/types.h>
sPymbed 0:1387ff3eed4a 34
sPymbed 0:1387ff3eed4a 35 #ifdef __cplusplus
sPymbed 0:1387ff3eed4a 36 extern "C" {
sPymbed 0:1387ff3eed4a 37 #endif
sPymbed 0:1387ff3eed4a 38
sPymbed 0:1387ff3eed4a 39
sPymbed 0:1387ff3eed4a 40 enum wc_LogLevels {
sPymbed 0:1387ff3eed4a 41 ERROR_LOG = 0,
sPymbed 0:1387ff3eed4a 42 INFO_LOG,
sPymbed 0:1387ff3eed4a 43 ENTER_LOG,
sPymbed 0:1387ff3eed4a 44 LEAVE_LOG,
sPymbed 0:1387ff3eed4a 45 OTHER_LOG
sPymbed 0:1387ff3eed4a 46 };
sPymbed 0:1387ff3eed4a 47
sPymbed 0:1387ff3eed4a 48 #ifdef WOLFSSL_FUNC_TIME
sPymbed 0:1387ff3eed4a 49 /* WARNING: This code is only to be used for debugging performance.
sPymbed 0:1387ff3eed4a 50 * The code is not thread-safe.
sPymbed 0:1387ff3eed4a 51 * Do not use WOLFSSL_FUNC_TIME in production code.
sPymbed 0:1387ff3eed4a 52 */
sPymbed 0:1387ff3eed4a 53 enum wc_FuncNum {
sPymbed 0:1387ff3eed4a 54 WC_FUNC_CLIENT_HELLO_SEND = 0,
sPymbed 0:1387ff3eed4a 55 WC_FUNC_CLIENT_HELLO_DO,
sPymbed 0:1387ff3eed4a 56 WC_FUNC_SERVER_HELLO_SEND,
sPymbed 0:1387ff3eed4a 57 WC_FUNC_SERVER_HELLO_DO,
sPymbed 0:1387ff3eed4a 58 WC_FUNC_ENCRYPTED_EXTENSIONS_SEND,
sPymbed 0:1387ff3eed4a 59 WC_FUNC_ENCRYPTED_EXTENSIONS_DO,
sPymbed 0:1387ff3eed4a 60 WC_FUNC_CERTIFICATE_REQUEST_SEND,
sPymbed 0:1387ff3eed4a 61 WC_FUNC_CERTIFICATE_REQUEST_DO,
sPymbed 0:1387ff3eed4a 62 WC_FUNC_CERTIFICATE_SEND,
sPymbed 0:1387ff3eed4a 63 WC_FUNC_CERTIFICATE_DO,
sPymbed 0:1387ff3eed4a 64 WC_FUNC_CERTIFICATE_VERIFY_SEND,
sPymbed 0:1387ff3eed4a 65 WC_FUNC_CERTIFICATE_VERIFY_DO,
sPymbed 0:1387ff3eed4a 66 WC_FUNC_FINISHED_SEND,
sPymbed 0:1387ff3eed4a 67 WC_FUNC_FINISHED_DO,
sPymbed 0:1387ff3eed4a 68 WC_FUNC_KEY_UPDATE_SEND,
sPymbed 0:1387ff3eed4a 69 WC_FUNC_KEY_UPDATE_DO,
sPymbed 0:1387ff3eed4a 70 WC_FUNC_EARLY_DATA_SEND,
sPymbed 0:1387ff3eed4a 71 WC_FUNC_EARLY_DATA_DO,
sPymbed 0:1387ff3eed4a 72 WC_FUNC_NEW_SESSION_TICKET_SEND,
sPymbed 0:1387ff3eed4a 73 WC_FUNC_NEW_SESSION_TICKET_DO,
sPymbed 0:1387ff3eed4a 74 WC_FUNC_SERVER_HELLO_DONE_SEND,
sPymbed 0:1387ff3eed4a 75 WC_FUNC_SERVER_HELLO_DONE_DO,
sPymbed 0:1387ff3eed4a 76 WC_FUNC_TICKET_SEND,
sPymbed 0:1387ff3eed4a 77 WC_FUNC_TICKET_DO,
sPymbed 0:1387ff3eed4a 78 WC_FUNC_CLIENT_KEY_EXCHANGE_SEND,
sPymbed 0:1387ff3eed4a 79 WC_FUNC_CLIENT_KEY_EXCHANGE_DO,
sPymbed 0:1387ff3eed4a 80 WC_FUNC_CERTIFICATE_STATUS_SEND,
sPymbed 0:1387ff3eed4a 81 WC_FUNC_CERTIFICATE_STATUS_DO,
sPymbed 0:1387ff3eed4a 82 WC_FUNC_SERVER_KEY_EXCHANGE_SEND,
sPymbed 0:1387ff3eed4a 83 WC_FUNC_SERVER_KEY_EXCHANGE_DO,
sPymbed 0:1387ff3eed4a 84 WC_FUNC_END_OF_EARLY_DATA_SEND,
sPymbed 0:1387ff3eed4a 85 WC_FUNC_END_OF_EARLY_DATA_DO,
sPymbed 0:1387ff3eed4a 86 WC_FUNC_COUNT
sPymbed 0:1387ff3eed4a 87 };
sPymbed 0:1387ff3eed4a 88 #endif
sPymbed 0:1387ff3eed4a 89
sPymbed 0:1387ff3eed4a 90 typedef void (*wolfSSL_Logging_cb)(const int logLevel,
sPymbed 0:1387ff3eed4a 91 const char *const logMessage);
sPymbed 0:1387ff3eed4a 92
sPymbed 0:1387ff3eed4a 93 WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
sPymbed 0:1387ff3eed4a 94
sPymbed 0:1387ff3eed4a 95 /* turn logging on, only if compiled in */
sPymbed 0:1387ff3eed4a 96 WOLFSSL_API int wolfSSL_Debugging_ON(void);
sPymbed 0:1387ff3eed4a 97 /* turn logging off */
sPymbed 0:1387ff3eed4a 98 WOLFSSL_API void wolfSSL_Debugging_OFF(void);
sPymbed 0:1387ff3eed4a 99
sPymbed 0:1387ff3eed4a 100
sPymbed 0:1387ff3eed4a 101 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
sPymbed 0:1387ff3eed4a 102 WOLFSSL_LOCAL int wc_LoggingInit(void);
sPymbed 0:1387ff3eed4a 103 WOLFSSL_LOCAL int wc_LoggingCleanup(void);
sPymbed 0:1387ff3eed4a 104 WOLFSSL_LOCAL int wc_AddErrorNode(int error, int line, char* buf,
sPymbed 0:1387ff3eed4a 105 char* file);
sPymbed 0:1387ff3eed4a 106 WOLFSSL_LOCAL int wc_PeekErrorNode(int index, const char **file,
sPymbed 0:1387ff3eed4a 107 const char **reason, int *line);
sPymbed 0:1387ff3eed4a 108 WOLFSSL_LOCAL void wc_RemoveErrorNode(int index);
sPymbed 0:1387ff3eed4a 109 WOLFSSL_LOCAL void wc_ClearErrorNodes(void);
sPymbed 0:1387ff3eed4a 110 WOLFSSL_LOCAL int wc_PullErrorNode(const char **file, const char **reason,
sPymbed 0:1387ff3eed4a 111 int *line);
sPymbed 0:1387ff3eed4a 112 WOLFSSL_API int wc_SetLoggingHeap(void* h);
sPymbed 0:1387ff3eed4a 113 WOLFSSL_API int wc_ERR_remove_state(void);
sPymbed 0:1387ff3eed4a 114 #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
sPymbed 0:1387ff3eed4a 115 WOLFSSL_API void wc_ERR_print_errors_fp(XFILE fp);
sPymbed 0:1387ff3eed4a 116 #endif
sPymbed 0:1387ff3eed4a 117 #endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE */
sPymbed 0:1387ff3eed4a 118
sPymbed 0:1387ff3eed4a 119 #ifdef WOLFSSL_FUNC_TIME
sPymbed 0:1387ff3eed4a 120 /* WARNING: This code is only to be used for debugging performance.
sPymbed 0:1387ff3eed4a 121 * The code is not thread-safe.
sPymbed 0:1387ff3eed4a 122 * Do not use WOLFSSL_FUNC_TIME in production code.
sPymbed 0:1387ff3eed4a 123 */
sPymbed 0:1387ff3eed4a 124 WOLFSSL_API void WOLFSSL_START(int funcNum);
sPymbed 0:1387ff3eed4a 125 WOLFSSL_API void WOLFSSL_END(int funcNum);
sPymbed 0:1387ff3eed4a 126 WOLFSSL_API void WOLFSSL_TIME(int count);
sPymbed 0:1387ff3eed4a 127 #else
sPymbed 0:1387ff3eed4a 128 #define WOLFSSL_START(n)
sPymbed 0:1387ff3eed4a 129 #define WOLFSSL_END(n)
sPymbed 0:1387ff3eed4a 130 #define WOLFSSL_TIME(n)
sPymbed 0:1387ff3eed4a 131 #endif
sPymbed 0:1387ff3eed4a 132
sPymbed 0:1387ff3eed4a 133 #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY)
sPymbed 0:1387ff3eed4a 134 #if defined(_WIN32)
sPymbed 0:1387ff3eed4a 135 #if defined(INTIME_RTOS)
sPymbed 0:1387ff3eed4a 136 #define __func__ NULL
sPymbed 0:1387ff3eed4a 137 #else
sPymbed 0:1387ff3eed4a 138 #define __func__ __FUNCTION__
sPymbed 0:1387ff3eed4a 139 #endif
sPymbed 0:1387ff3eed4a 140 #endif
sPymbed 0:1387ff3eed4a 141
sPymbed 0:1387ff3eed4a 142 /* a is prepended to m and b is appended, creating a log msg a + m + b */
sPymbed 0:1387ff3eed4a 143 #define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b
sPymbed 0:1387ff3eed4a 144
sPymbed 0:1387ff3eed4a 145 WOLFSSL_API void WOLFSSL_ENTER(const char* msg);
sPymbed 0:1387ff3eed4a 146 WOLFSSL_API void WOLFSSL_LEAVE(const char* msg, int ret);
sPymbed 0:1387ff3eed4a 147 #define WOLFSSL_STUB(m) \
sPymbed 0:1387ff3eed4a 148 WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
sPymbed 0:1387ff3eed4a 149
sPymbed 0:1387ff3eed4a 150 WOLFSSL_API void WOLFSSL_MSG(const char* msg);
sPymbed 0:1387ff3eed4a 151 WOLFSSL_API void WOLFSSL_BUFFER(const byte* buffer, word32 length);
sPymbed 0:1387ff3eed4a 152
sPymbed 0:1387ff3eed4a 153 #else
sPymbed 0:1387ff3eed4a 154
sPymbed 0:1387ff3eed4a 155 #define WOLFSSL_ENTER(m)
sPymbed 0:1387ff3eed4a 156 #define WOLFSSL_LEAVE(m, r)
sPymbed 0:1387ff3eed4a 157 #define WOLFSSL_STUB(m)
sPymbed 0:1387ff3eed4a 158
sPymbed 0:1387ff3eed4a 159 #define WOLFSSL_MSG(m)
sPymbed 0:1387ff3eed4a 160 #define WOLFSSL_BUFFER(b, l)
sPymbed 0:1387ff3eed4a 161
sPymbed 0:1387ff3eed4a 162 #endif /* DEBUG_WOLFSSL && !WOLFSSL_DEBUG_ERRORS_ONLY */
sPymbed 0:1387ff3eed4a 163
sPymbed 0:1387ff3eed4a 164 #if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
sPymbed 0:1387ff3eed4a 165
sPymbed 0:1387ff3eed4a 166 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
sPymbed 0:1387ff3eed4a 167 WOLFSSL_API void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line,
sPymbed 0:1387ff3eed4a 168 const char* file, void* ctx);
sPymbed 0:1387ff3eed4a 169 #define WOLFSSL_ERROR(x) \
sPymbed 0:1387ff3eed4a 170 WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__, NULL)
sPymbed 0:1387ff3eed4a 171 #else
sPymbed 0:1387ff3eed4a 172 WOLFSSL_API void WOLFSSL_ERROR(int err);
sPymbed 0:1387ff3eed4a 173 #endif
sPymbed 0:1387ff3eed4a 174 WOLFSSL_API void WOLFSSL_ERROR_MSG(const char* msg);
sPymbed 0:1387ff3eed4a 175
sPymbed 0:1387ff3eed4a 176 #else
sPymbed 0:1387ff3eed4a 177 #define WOLFSSL_ERROR(e)
sPymbed 0:1387ff3eed4a 178 #define WOLFSSL_ERROR_MSG(m)
sPymbed 0:1387ff3eed4a 179 #endif
sPymbed 0:1387ff3eed4a 180
sPymbed 0:1387ff3eed4a 181 #ifdef __cplusplus
sPymbed 0:1387ff3eed4a 182 }
sPymbed 0:1387ff3eed4a 183 #endif
sPymbed 0:1387ff3eed4a 184 #endif /* WOLFSSL_LOGGING_H */
sPymbed 0:1387ff3eed4a 185
sPymbed 0:1387ff3eed4a 186