-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlogging.h
More file actions
588 lines (542 loc) · 21.2 KB
/
logging.h
File metadata and controls
588 lines (542 loc) · 21.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
/* logging.h
*
* Copyright (C) 2006-2025 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/*!
\file wolfssl/wolfcrypt/logging.h
*/
/* submitted by eof */
/*
* Enable wolfSSL debugging with DEBUG_WOLFSSL
*
* Certificate debugging is a subset of DEBUG_WOLFSSL but can be enabled
* exclusively with WOLFSSL_DEBUG_CERTS.
*
* When DEBUG_WOLFSSL is enabled, but the subset of certificate debugging
* is not desired, it can disabled with NO_WOLFSSL_DEBUG_CERTS
*
* ****************************************************************************
* Message / printf debugging
* ****************************************************************************
*
* WOLFSSL_DEBUG_PRINTF()
* Utility macro: A buffer-less, non-truncating debug message renderer. On
* supported targets, it is always functional, i.e. it is not affected by
* DEBUG_WOLFSSL or wolfSSL_Debugging_{ON,OFF}(). Test for support using
* defined(WOLFSSL_DEBUG_PRINTF) -- if it is unsupported it is not defined.
*
* WOLFSSL_DEBUG_PRINTF_FN
* Used to supply an override definition of the target platform's printf-like
* function. By default, it is defined to fprintf. If defined, this is used
* as the underlying function for all logging by the library.
*
* WOLFSSL_DEBUG_PRINTF_FIRST_ARGS
* Used to supply an override definition of the initial args to the target
* platform's printf-like function, with a trailing comma. This can be
* defined to nothing if there are no initial args to supply. By default, it
* is defined to stderr plus a trailing comma. If defined, the args are
* passed to WOLFSSL_DEBUG_PRINTF_FN wherever it is called.
*
* WOLFSSL_MSG_EX_BUF_SZ
* Re-definable macro: maximum length of WOLFSSL_MSG_EX debugging messages.
*
* WOLFSSL_MSG
* Single message parameter. Works everywhere.
*
* WOLFSSL_MSG_EX
* Variable number of parameters. Should be supported nearly everywhere.
*
* WOLFSSL_MSG_EX2
* Variable number of parameters. Should be supported nearly everywhere.
* Special case where first two parameters are const char *file, int line
*
* ****************************************************************************
* Certificate Debugging: a subset of DEBUG_WOLFSSL
* or can be used alone WOLFSSL_DEBUG_CERTS without all the debugging noise
* ****************************************************************************
*
* WOLFSSL_MSG_CERT_BUF_SZ
* Used by WOLFSSL_MSG_CERT and WOLFSSL_MSG_CERT_EX
* Re-definable macro: maximum length of debugging messages.
*
* WOLFSSL_MSG_CERT
* Single message parameter. Works everywhere.
* Print only during WOLFSSL_DEBUG_CERTS
*
* WOLFSSL_MSG_CERT_LOG
* Single message parameter. Works everywhere.
* Print during either DEBUG_WOLFSSL or WOLFSSL_DEBUG_CERTS
*
* WOLFSSL_MSG_CERT_EX
* Variable number of parameters. Should be supported nearly everywhere.
*
* WOLFSSL_MSG_CERT_LOG_EX
* Variable number of parameters. Should be supported nearly everywhere.
* Print during either DEBUG_WOLFSSL or WOLFSSL_DEBUG_CERTS
*
* When any of the above are disabled:
* With WOLF_NO_VARIADIC_MACROS a do nothing placeholder function is used.
* Otherwise, a do-nothing macro. See WC_DO_NOTHING
*
* Optional user callbacks:
* wolfSSL_SetLoggingCb(my_log_cb);
*
* To disable certificate debugging:
* Do not define WOLFSSL_DEBUG_CERTS when used without DEBUG_WOLFSSL
* or
* Define NO_WOLFSSL_DEBUG_CERTS when DEBUG_WOLFSSL is enabled
*
* If NO_WOLFSSL_DEBUG_CERTS is detected in settings.h, the respective
* WOLFSSL_DEBUG_CERTS will be undefined. The explicit NO_WOLFSSL_DEBUG_CERTS
* checks are still performed in logging source for code clarity only.
*
* ****************************************************************************
* At runtime with debugging enabled:
* ****************************************************************************
*
* Display debug messages:
* int wolfSSL_Debugging_ON(void)
* int wolfSSL_CertDebugging_ON(void)
*
* Disable debug messages until re-enabled at runtime:
* void wolfSSL_Debugging_OFF(void);
* int wolfSSL_CertDebugging_OFF(void)
*
* See also:
* int WOLFSSL_IS_DEBUG_ON(void)
*
* Note: does not affect WOLFSSL_DEBUG_PRINTF(), which renders unconditionally.
*
*/
#ifndef WOLFSSL_LOGGING_H
#define WOLFSSL_LOGGING_H
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef __cplusplus
extern "C" {
#endif
enum wc_LogLevels {
ERROR_LOG = 0,
INFO_LOG,
ENTER_LOG,
LEAVE_LOG,
CERT_LOG,
OTHER_LOG
};
#ifdef WOLFSSL_FUNC_TIME
/* WARNING: This code is only to be used for debugging performance.
* The code is not thread-safe.
* Do not use WOLFSSL_FUNC_TIME in production code.
*/
enum wc_FuncNum {
WC_FUNC_HELLO_REQUEST_SEND = 0,
WC_FUNC_HELLO_REQUEST_DO,
WC_FUNC_CLIENT_HELLO_SEND,
WC_FUNC_CLIENT_HELLO_DO,
WC_FUNC_SERVER_HELLO_SEND,
WC_FUNC_SERVER_HELLO_DO,
WC_FUNC_ENCRYPTED_EXTENSIONS_SEND,
WC_FUNC_ENCRYPTED_EXTENSIONS_DO,
WC_FUNC_CERTIFICATE_REQUEST_SEND,
WC_FUNC_CERTIFICATE_REQUEST_DO,
WC_FUNC_CERTIFICATE_SEND,
WC_FUNC_CERTIFICATE_DO,
WC_FUNC_CERTIFICATE_VERIFY_SEND,
WC_FUNC_CERTIFICATE_VERIFY_DO,
WC_FUNC_FINISHED_SEND,
WC_FUNC_FINISHED_DO,
WC_FUNC_KEY_UPDATE_SEND,
WC_FUNC_KEY_UPDATE_DO,
WC_FUNC_EARLY_DATA_SEND,
WC_FUNC_EARLY_DATA_DO,
WC_FUNC_NEW_SESSION_TICKET_SEND,
WC_FUNC_NEW_SESSION_TICKET_DO,
WC_FUNC_SERVER_HELLO_DONE_SEND,
WC_FUNC_SERVER_HELLO_DONE_DO,
WC_FUNC_TICKET_SEND,
WC_FUNC_TICKET_DO,
WC_FUNC_CLIENT_KEY_EXCHANGE_SEND,
WC_FUNC_CLIENT_KEY_EXCHANGE_DO,
WC_FUNC_CERTIFICATE_STATUS_SEND,
WC_FUNC_CERTIFICATE_STATUS_DO,
WC_FUNC_SERVER_KEY_EXCHANGE_SEND,
WC_FUNC_SERVER_KEY_EXCHANGE_DO,
WC_FUNC_END_OF_EARLY_DATA_SEND,
WC_FUNC_END_OF_EARLY_DATA_DO,
WC_FUNC_COUNT
};
#endif
typedef void (*wolfSSL_Logging_cb)(const int logLevel,
const char *const logMessage);
WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
WOLFSSL_API wolfSSL_Logging_cb wolfSSL_GetLoggingCb(void);
/* turn logging on, only if compiled in */
WOLFSSL_API int wolfSSL_Debugging_ON(void);
/* turn logging off */
WOLFSSL_API void wolfSSL_Debugging_OFF(void);
/* turn cert debugging on, only if compiled in */
WOLFSSL_API int wolfSSL_CertDebugging_ON(void);
/* turn cert debugging off */
WOLFSSL_API int wolfSSL_CertDebugging_OFF(void);
WOLFSSL_API void wolfSSL_SetLoggingPrefix(const char* prefix);
#ifdef HAVE_WC_INTROSPECTION
WOLFSSL_API const char *wolfSSL_configure_args(void);
WOLFSSL_API const char *wolfSSL_global_cflags(void);
#endif
#if (defined(OPENSSL_EXTRA) && !defined(_WIN32) && \
!defined(NO_ERROR_QUEUE)) || defined(DEBUG_WOLFSSL_VERBOSE) \
|| defined(HAVE_MEMCACHED)
#define WOLFSSL_HAVE_ERROR_QUEUE
#endif
#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) || defined(HAVE_MEMCACHED)
WOLFSSL_LOCAL int wc_LoggingInit(void);
WOLFSSL_LOCAL int wc_LoggingCleanup(void);
WOLFSSL_LOCAL int wc_AddErrorNode(int error, int line, char* buf,
char* file);
WOLFSSL_LOCAL int wc_PeekErrorNode(int idx, const char **file,
const char **reason, int *line);
WOLFSSL_LOCAL void wc_RemoveErrorNode(int idx);
WOLFSSL_LOCAL void wc_ClearErrorNodes(void);
WOLFSSL_LOCAL int wc_PullErrorNode(const char **file, const char **reason,
int *line);
WOLFSSL_API int wc_SetLoggingHeap(void* h);
WOLFSSL_API int wc_ERR_remove_state(void);
WOLFSSL_LOCAL unsigned long wc_PeekErrorNodeLineData(
const char **file, int *line, const char **data, int *flags,
int (*ignore_err)(int err));
WOLFSSL_LOCAL int wc_GetErrorNodeErr(void);
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
WOLFSSL_API void wc_ERR_print_errors_fp(XFILE fp);
WOLFSSL_API void wc_ERR_print_errors_cb(int (*cb)(const char *str,
size_t len, void *u), void *u);
#endif
#endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE || HAVE_MEMCACHED */
#ifdef WOLFSSL_FUNC_TIME
/* WARNING: This code is only to be used for debugging performance.
* The code is not thread-safe.
* Do not use WOLFSSL_FUNC_TIME in production code.
*/
WOLFSSL_API void WOLFSSL_START(int funcNum);
WOLFSSL_API void WOLFSSL_END(int funcNum);
WOLFSSL_API void WOLFSSL_TIME(int count);
#else
#define WOLFSSL_START(n) WC_DO_NOTHING
#define WOLFSSL_END(n) WC_DO_NOTHING
#define WOLFSSL_TIME(n) WC_DO_NOTHING
#endif
/* Certificate Debugging: WOLFSSL_MSG_CERT */
#if defined(XVSNPRINTF) && !defined(NO_WOLFSSL_DEBUG_CERTS) && \
(defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_CERTS))
#define HAVE_WOLFSSL_DEBUG_CERTS
#ifndef WOLFSSL_MSG_CERT_INDENT
#define WOLFSSL_MSG_CERT_INDENT "\t- "
#endif
WOLFSSL_API int WOLFSSL_MSG_CERT(const char* msg);
WOLFSSL_API int WOLFSSL_MSG_CERT_EX(const char* fmt, ...);
#else
/* No Certificate Debugging */
#undef WOLFSSL_DEBUG_CERTS
#ifndef WOLFSSL_MSG_CERT_INDENT
#define WOLFSSL_MSG_CERT_INDENT ""
#endif
#ifdef WOLF_NO_VARIADIC_MACROS
/* The issue is variadic macros, not function parameters. e.g Watcom
* Additionally, Watcom needs the empty declaration here: */
#ifdef __WATCOMC__
/* don't use WOLFSSL_API nor inline for Watcom stubs */
static int WOLFSSL_MSG_CERT(const char* msg)
{
(void)msg;
return NOT_COMPILED_IN;
}
static int WOLFSSL_MSG_CERT_EX(const char* fmt, ...)
{
(void)fmt;
return NOT_COMPILED_IN;
}
#else
WOLFSSL_API int WOLFSSL_MSG_CERT(const char* msg);
WOLFSSL_API int WOLFSSL_MSG_CERT_EX(const char* fmt, ...);
#endif
#else
/* Nearly all compilers will support variadic macros */
#define WOLFSSL_MSG_CERT(m) WC_DO_NOTHING
#define WOLFSSL_MSG_CERT_EX(...) WC_DO_NOTHING
#endif
#endif /* Certificate Debugging: WOLFSSL_MSG_CERT */
#if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY)
#if defined(_WIN32) && !defined(__WATCOMC__)
#if defined(INTIME_RTOS)
#define __func__ NULL
#else
#define __func__ __FUNCTION__
#endif
#endif
/* a is prepended to m and b is appended, creating a log msg a + m + b */
#define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b
WOLFSSL_API void WOLFSSL_ENTER(const char* msg);
WOLFSSL_API void WOLFSSL_LEAVE(const char* msg, int ret);
#define WOLFSSL_STUB(m) \
WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
WOLFSSL_API int WOLFSSL_IS_DEBUG_ON(void);
/* WOLFSSL_MSG_EX may not be available. Check with HAVE_WOLFSSL_MSG_EX */
#if defined(XVSNPRINTF) && !defined(NO_WOLFSSL_MSG_EX)
WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...);
#define HAVE_WOLFSSL_MSG_EX
#else
#ifdef WOLF_NO_VARIADIC_MACROS
/* We need a do-nothing function with a variable number of parameters */
/* see logging.c
* static inline void WOLFSSL_MSG_EX(const char* fmt, ...); */
#else
#define WOLFSSL_MSG_EX(...) WC_DO_NOTHING
#endif
#endif
WOLFSSL_API void WOLFSSL_MSG(const char* msg);
#ifdef WOLFSSL_DEBUG_CODEPOINTS
WOLFSSL_API void WOLFSSL_MSG2(
const char *file, int line, const char* msg);
WOLFSSL_API void WOLFSSL_ENTER2(
const char *file, int line, const char* msg);
WOLFSSL_API void WOLFSSL_LEAVE2(
const char *file, int line, const char* msg, int ret);
#define WOLFSSL_MSG(msg) WOLFSSL_MSG2(__FILE__, __LINE__, msg)
#define WOLFSSL_ENTER(msg) WOLFSSL_ENTER2(__FILE__, __LINE__, msg)
#define WOLFSSL_LEAVE(msg, ret) WOLFSSL_LEAVE2(__FILE__, __LINE__, msg, ret)
#ifdef XVSNPRINTF
WOLFSSL_API void WOLFSSL_MSG_EX2(
const char *file, int line, const char* fmt, ...);
#define WOLFSSL_MSG_EX(fmt, args...) \
WOLFSSL_MSG_EX2(__FILE__, __LINE__, fmt, ## args)
#else
#ifdef WOLF_NO_VARIADIC_MACROS
#define WOLFSSL_MSG_EX2() WC_DO_NOTHING
#else
#define WOLFSSL_MSG_EX2(...) WC_DO_NOTHING
#endif
#endif
#endif
WOLFSSL_API void WOLFSSL_BUFFER(const byte* buffer, word32 length);
#else
/* ! (defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY)) */
#define WOLFSSL_ENTER(m) WC_DO_NOTHING
#define WOLFSSL_LEAVE(m, r) WC_DO_NOTHING
#define WOLFSSL_STUB(m) WC_DO_NOTHING
#define WOLFSSL_IS_DEBUG_ON() 0
#ifdef WOLF_NO_VARIADIC_MACROS
/* note, modern preprocessors will generate errors with this definition.
* "error: macro "WOLFSSL_MSG_EX" passed 2 arguments, but takes just 0"
*
* #define WOLFSSL_MSG_EX(a, b) WC_DO_NOTHING
*
* We need a do-nothing function with a variable number of parameters: */
#ifdef __WATCOMC__
/* don't use WOLFSSL_API nor inline for Watcom stubs */
static void WOLFSSL_MSG_EX(const char* fmt, ...)
{
(void)fmt;
}
#else
WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...);
#endif
#else
#define WOLFSSL_MSG_EX(...) WC_DO_NOTHING
#endif
#define WOLFSSL_MSG(m) WC_DO_NOTHING
#define WOLFSSL_BUFFER(b, l) WC_DO_NOTHING
#endif /* DEBUG_WOLFSSL && !WOLFSSL_DEBUG_ERRORS_ONLY */
/* A special case of certificate-related debug AND regular debug.
* WOLFSSL_MSG_CERT_LOG will always print during DEBUG_WOLFSSL
* even if cert debugging disabled with NO_WOLFSSL_DEBUG_CERTS.
*
* WOLFSSL_MSG_CERT_LOG will also print during WOLFSSL_DEBUG_CERTS
* even if standard DEBUG_WOLFSSL is not enabled. */
#if defined(WOLFSSL_DEBUG_CERTS)
#define WOLFSSL_MSG_CERT_LOG(msg) WOLFSSL_MSG_CERT(msg)
#define WOLFSSL_MSG_CERT_LOG_EX WOLFSSL_MSG_CERT_EX
#elif defined(DEBUG_WOLFSSL)
#define WOLFSSL_MSG_CERT_LOG(msg) WOLFSSL_MSG(msg)
#define WOLFSSL_MSG_CERT_LOG_EX WOLFSSL_MSG_EX
#else
#define WOLFSSL_MSG_CERT_LOG(msg) WC_DO_NOTHING
#define WOLFSSL_MSG_CERT_LOG_EX WOLFSSL_MSG_EX
#endif
/* WOLFSSL_ERROR and WOLFSSL_HAVE_ERROR_QUEUE */
#if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) ||\
defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA)
#ifdef WOLFSSL_HAVE_ERROR_QUEUE
WOLFSSL_API void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line,
const char* file, void* ctx);
#ifdef WOLF_C89
#define WOLFSSL_ERROR(x) \
WOLFSSL_ERROR_LINE((x), __FILE__, __LINE__, __FILE__, NULL)
#else
#define WOLFSSL_ERROR(x) \
WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__, NULL)
#endif
#else
WOLFSSL_API void WOLFSSL_ERROR(int err);
#endif /* WOLFSSL_HAVE_ERROR_QUEUE */
WOLFSSL_API void WOLFSSL_ERROR_MSG(const char* msg);
#else
#define WOLFSSL_ERROR(e) (void)(e)
#define WOLFSSL_ERROR_MSG(m) (void)(m)
#endif /* DEBUG_WOLFSSL | OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY ||
OPENSSL_EXTRA */
#ifdef WOLFSSL_VERBOSE_ERRORS
#define WOLFSSL_ERROR_VERBOSE(e) WOLFSSL_ERROR(e)
#else
#define WOLFSSL_ERROR_VERBOSE(e) (void)(e)
#endif /* WOLFSSL_VERBOSE_ERRORS */
#ifdef HAVE_STACK_SIZE_VERBOSE
extern WOLFSSL_API THREAD_LS_T unsigned char *StackSizeCheck_myStack;
extern WOLFSSL_API THREAD_LS_T size_t StackSizeCheck_stackSize;
extern WOLFSSL_API THREAD_LS_T size_t StackSizeCheck_stackSizeHWM;
extern WOLFSSL_API THREAD_LS_T size_t *StackSizeCheck_stackSizeHWM_ptr;
extern WOLFSSL_API THREAD_LS_T void *StackSizeCheck_stackOffsetPointer;
#endif
/* Port-specific includes and printf methods: */
#if defined(ARDUINO)
/* implemented in Arduino wolfssl.h */
extern WOLFSSL_API int wolfSSL_Arduino_Serial_Print(const char* const s);
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
/* see wc_port.h for fio.h and nio.h includes */
#elif defined(WOLFSSL_SGX)
/* Declare sprintf for ocall */
int sprintf(char* buf, const char *fmt, ...);
#elif defined(WOLFSSL_DEOS)
#elif defined(MICRIUM)
#if (BSP_SER_COMM_EN == DEF_ENABLED)
#include <bsp_ser.h>
#endif
#elif defined(WOLFSSL_USER_LOG)
/* user includes their own headers */
#elif defined(WOLFSSL_ESPIDF)
#include "esp_types.h"
#include "esp_log.h"
#elif defined(WOLFSSL_TELIT_M2MB)
#include <stdio.h>
#include "m2m_log.h"
#elif defined(WOLFSSL_ANDROID_DEBUG)
#include <android/log.h>
#elif defined(WOLFSSL_XILINX)
#include "xil_printf.h"
#elif defined(WOLFSSL_LINUXKM)
/* the requisite linux/kernel.h is included in linuxkm_wc_port.h, with
* incompatible warnings masked out.
*/
#elif defined(WOLFSSL_BSDKM)
/* see bsdkm/bsdkm_wc_port.h for includes and defines. */
#elif defined(FUSION_RTOS)
#include <fclstdio.h>
#define fprintf FCL_FPRINTF
#else
#include <stdio.h> /* for default printf stuff */
#endif
#if defined(THREADX) && !defined(THREADX_NO_DC_PRINTF)
int dc_log_printf(char*, ...);
#endif
/* WOLFSSL_DEBUG_PRINTF_FN is intended to be used only in wolfssl_log(),
* but is exposed in header as a customer cross-platform debugging capability.
*
* All general wolfSSL debugging should use:
* WOLFSSL_MSG and WOLFSSL_MSG_EX
*
* All wolfSSL certificate-related debugging should use:
* WOLFSSL_MSG_CERT and WOLFSSL_MSG_CERT_EX
*
* For custom debugging output, define your own WOLFSSL_DEBUG_PRINTF_FN
*/
#ifdef WOLFSSL_DEBUG_PRINTF_FN
/* user-supplied definition */
#elif defined(ARDUINO)
/* ARDUINO only has print and sprintf, no printf. */
#elif defined(__WATCOMC__)
#if defined(DEBUG_WOLFSSL) || defined(WOLFSSL_DEBUG_CERTS)
#include <stdio.h>
#define WOLFSSL_DEBUG_PRINTF_FN printf
#else
/* Watcom does not support variadic macros; we need a no-op function */
static int WOLFSSL_DEBUG_PRINTF(const char* fmt, ...)
{
(void)fmt;
return NOT_COMPILED_IN;
}
#endif /* __WATCOMC__ */
#elif defined(WOLFSSL_LOG_PRINTF) || defined(WOLFSSL_DEOS)
#define WOLFSSL_DEBUG_PRINTF_FN printf
#elif defined(THREADX) && !defined(THREADX_NO_DC_PRINTF)
#define WOLFSSL_DEBUG_PRINTF_FN dc_log_printf
#elif defined(MICRIUM)
#define WOLFSSL_DEBUG_PRINTF_FN BSP_Ser_Printf
#elif defined(WOLFSSL_MDK_ARM)
#define WOLFSSL_DEBUG_PRINTF_FN printf
#elif defined(WOLFSSL_UTASKER)
/* WOLFSSL_UTASKER only has fnDebugMsg and related primitives, no printf. */
#elif defined(MQX_USE_IO_OLD)
#define WOLFSSL_DEBUG_PRINTF_FN fprintf
#define WOLFSSL_DEBUG_PRINTF_FIRST_ARGS _mqxio_stderr,
#elif defined(WOLFSSL_APACHE_MYNEWT)
#define WOLFSSL_DEBUG_PRINTF_FN LOG_DEBUG
#define WOLFSSL_DEBUG_PRINTF_FIRST_ARGS &mynewt_log, LOG_MODULE_DEFAULT,
#elif defined(WOLFSSL_ESPIDF)
#define WOLFSSL_DEBUG_PRINTF_FN ESP_LOGI
#define WOLFSSL_DEBUG_PRINTF_FIRST_ARGS "wolfssl",
#elif defined(WOLFSSL_ZEPHYR)
#define WOLFSSL_DEBUG_PRINTF_FN printk
#elif defined(WOLFSSL_TELIT_M2MB)
#define WOLFSSL_DEBUG_PRINTF_FN M2M_LOG_INFO
#elif defined(WOLFSSL_ANDROID_DEBUG)
#define WOLFSSL_DEBUG_PRINTF_FN __android_log_print
#define WOLFSSL_DEBUG_PRINTF_FIRST_ARGS ANDROID_LOG_VERBOSE, "[wolfSSL]",
#elif defined(WOLFSSL_XILINX)
#define WOLFSSL_DEBUG_PRINTF_FN xil_printf
#elif defined(WOLFSSL_LINUXKM)
#define WOLFSSL_DEBUG_PRINTF_FN printk
#elif defined(WOLFSSL_RENESAS_RA6M4)
#define WOLFSSL_DEBUG_PRINTF_FN myprintf
#elif defined(NO_STDIO_FILESYSTEM)
#define WOLFSSL_DEBUG_PRINTF_FN printf
#else
#define WOLFSSL_DEBUG_PRINTF_FN fprintf
#define WOLFSSL_DEBUG_PRINTF_FIRST_ARGS stderr,
#endif
#ifndef WOLFSSL_DEBUG_PRINTF_FIRST_ARGS
#define WOLFSSL_DEBUG_PRINTF_FIRST_ARGS
#endif
#if defined(WOLFSSL_DEBUG_PRINTF_FN) && !defined(WOLFSSL_DEBUG_PRINTF)
#if defined(WOLF_NO_VARIADIC_MACROS)
#define WOLFSSL_DEBUG_PRINTF(a) \
WOLFSSL_DEBUG_PRINTF_FN(WOLFSSL_DEBUG_PRINTF_FIRST_ARGS a)
#else
#define WOLFSSL_DEBUG_PRINTF(...) \
WOLFSSL_DEBUG_PRINTF_FN(WOLFSSL_DEBUG_PRINTF_FIRST_ARGS __VA_ARGS__)
#endif
#endif
/* Sanity Checks */
#if defined(WOLFSSL_DEBUG_ERRORS_ONLY) && defined(DEBUG_WOLFSSL)
#error "Failed: WOLFSSL_DEBUG_ERRORS_ONLY and DEBUG_WOLFSSL pick one"
#endif
#if defined(WOLFSSL_DEBUG_ERRORS_ONLY) && defined(WOLFSSL_DEBUG_CERTS)
#error "Failed: Cannot WOLFSSL_DEBUG_CERTS with WOLFSSL_DEBUG_ERRORS_ONLY"
#endif
#ifdef __cplusplus
}
#endif
#endif /* WOLFSSL_LOGGING_H */