source: azure_iot_hub_f767zi/trunk/wolfssl-4.7.0/wolfssl/wolfcrypt/logging.h@ 464

Last change on this file since 464 was 464, checked in by coas-nagasima, 3 years ago

WolfSSLとAzure IoT SDKを更新

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