wolfSSL 3.11.1 for TLS1.3 beta

Fork of wolfSSL by wolf SSL

Committer:
wolfSSL
Date:
Tue May 30 06:16:19 2017 +0000
Revision:
13:80fb167dafdf
wolfSSL 3.11.1: TLS1.3 Beta

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 13:80fb167dafdf 1 /* logging.h
wolfSSL 13:80fb167dafdf 2 *
wolfSSL 13:80fb167dafdf 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 13:80fb167dafdf 4 *
wolfSSL 13:80fb167dafdf 5 * This file is part of wolfSSL.
wolfSSL 13:80fb167dafdf 6 *
wolfSSL 13:80fb167dafdf 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 13:80fb167dafdf 8 * it under the terms of the GNU General Public License as published by
wolfSSL 13:80fb167dafdf 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 13:80fb167dafdf 10 * (at your option) any later version.
wolfSSL 13:80fb167dafdf 11 *
wolfSSL 13:80fb167dafdf 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 13:80fb167dafdf 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 13:80fb167dafdf 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 13:80fb167dafdf 15 * GNU General Public License for more details.
wolfSSL 13:80fb167dafdf 16 *
wolfSSL 13:80fb167dafdf 17 * You should have received a copy of the GNU General Public License
wolfSSL 13:80fb167dafdf 18 * along with this program; if not, write to the Free Software
wolfSSL 13:80fb167dafdf 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 13:80fb167dafdf 20 */
wolfSSL 13:80fb167dafdf 21
wolfSSL 13:80fb167dafdf 22
wolfSSL 13:80fb167dafdf 23 /* submitted by eof */
wolfSSL 13:80fb167dafdf 24
wolfSSL 13:80fb167dafdf 25
wolfSSL 13:80fb167dafdf 26 #ifndef WOLFSSL_LOGGING_H
wolfSSL 13:80fb167dafdf 27 #define WOLFSSL_LOGGING_H
wolfSSL 13:80fb167dafdf 28
wolfSSL 13:80fb167dafdf 29 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 13:80fb167dafdf 30
wolfSSL 13:80fb167dafdf 31 #ifdef __cplusplus
wolfSSL 13:80fb167dafdf 32 extern "C" {
wolfSSL 13:80fb167dafdf 33 #endif
wolfSSL 13:80fb167dafdf 34
wolfSSL 13:80fb167dafdf 35
wolfSSL 13:80fb167dafdf 36 enum CYA_Log_Levels {
wolfSSL 13:80fb167dafdf 37 ERROR_LOG = 0,
wolfSSL 13:80fb167dafdf 38 INFO_LOG,
wolfSSL 13:80fb167dafdf 39 ENTER_LOG,
wolfSSL 13:80fb167dafdf 40 LEAVE_LOG,
wolfSSL 13:80fb167dafdf 41 OTHER_LOG
wolfSSL 13:80fb167dafdf 42 };
wolfSSL 13:80fb167dafdf 43
wolfSSL 13:80fb167dafdf 44 typedef void (*wolfSSL_Logging_cb)(const int logLevel,
wolfSSL 13:80fb167dafdf 45 const char *const logMessage);
wolfSSL 13:80fb167dafdf 46
wolfSSL 13:80fb167dafdf 47 WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
wolfSSL 13:80fb167dafdf 48
wolfSSL 13:80fb167dafdf 49 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
wolfSSL 13:80fb167dafdf 50 WOLFSSL_LOCAL int wc_LoggingInit(void);
wolfSSL 13:80fb167dafdf 51 WOLFSSL_LOCAL int wc_LoggingCleanup(void);
wolfSSL 13:80fb167dafdf 52 WOLFSSL_LOCAL int wc_AddErrorNode(int error, int line, char* buf,
wolfSSL 13:80fb167dafdf 53 char* file);
wolfSSL 13:80fb167dafdf 54 WOLFSSL_LOCAL int wc_PeekErrorNode(int index, const char **file,
wolfSSL 13:80fb167dafdf 55 const char **reason, int *line);
wolfSSL 13:80fb167dafdf 56 WOLFSSL_LOCAL void wc_RemoveErrorNode(int index);
wolfSSL 13:80fb167dafdf 57 WOLFSSL_LOCAL void wc_ClearErrorNodes(void);
wolfSSL 13:80fb167dafdf 58 WOLFSSL_API int wc_SetLoggingHeap(void* h);
wolfSSL 13:80fb167dafdf 59 #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
wolfSSL 13:80fb167dafdf 60 WOLFSSL_API void wc_ERR_print_errors_fp(FILE* fp);
wolfSSL 13:80fb167dafdf 61 #endif
wolfSSL 13:80fb167dafdf 62 #endif /* defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) */
wolfSSL 13:80fb167dafdf 63
wolfSSL 13:80fb167dafdf 64 #ifdef DEBUG_WOLFSSL
wolfSSL 13:80fb167dafdf 65 #if defined(_WIN32)
wolfSSL 13:80fb167dafdf 66 #if defined(INTIME_RTOS)
wolfSSL 13:80fb167dafdf 67 #define __func__ NULL
wolfSSL 13:80fb167dafdf 68 #else
wolfSSL 13:80fb167dafdf 69 #define __func__ __FUNCTION__
wolfSSL 13:80fb167dafdf 70 #endif
wolfSSL 13:80fb167dafdf 71 #endif
wolfSSL 13:80fb167dafdf 72
wolfSSL 13:80fb167dafdf 73 /* a is prepended to m and b is appended, creating a log msg a + m + b */
wolfSSL 13:80fb167dafdf 74 #define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b
wolfSSL 13:80fb167dafdf 75
wolfSSL 13:80fb167dafdf 76 void WOLFSSL_ENTER(const char* msg);
wolfSSL 13:80fb167dafdf 77 void WOLFSSL_LEAVE(const char* msg, int ret);
wolfSSL 13:80fb167dafdf 78 #define WOLFSSL_STUB(m) \
wolfSSL 13:80fb167dafdf 79 WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
wolfSSL 13:80fb167dafdf 80
wolfSSL 13:80fb167dafdf 81 void WOLFSSL_MSG(const char* msg);
wolfSSL 13:80fb167dafdf 82 void WOLFSSL_BUFFER(const byte* buffer, word32 length);
wolfSSL 13:80fb167dafdf 83
wolfSSL 13:80fb167dafdf 84 #else /* DEBUG_WOLFSSL */
wolfSSL 13:80fb167dafdf 85
wolfSSL 13:80fb167dafdf 86 #define WOLFSSL_ENTER(m)
wolfSSL 13:80fb167dafdf 87 #define WOLFSSL_LEAVE(m, r)
wolfSSL 13:80fb167dafdf 88 #define WOLFSSL_STUB(m)
wolfSSL 13:80fb167dafdf 89
wolfSSL 13:80fb167dafdf 90 #define WOLFSSL_MSG(m)
wolfSSL 13:80fb167dafdf 91 #define WOLFSSL_BUFFER(b, l)
wolfSSL 13:80fb167dafdf 92
wolfSSL 13:80fb167dafdf 93 #endif /* DEBUG_WOLFSSL */
wolfSSL 13:80fb167dafdf 94
wolfSSL 13:80fb167dafdf 95 #if (defined(DEBUG_WOLFSSL) || defined(WOLFSSL_NGINX)) || defined(WOLFSSL_HAPROXY)
wolfSSL 13:80fb167dafdf 96 #if (defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE))
wolfSSL 13:80fb167dafdf 97 void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line,
wolfSSL 13:80fb167dafdf 98 const char* file, void* ctx);
wolfSSL 13:80fb167dafdf 99 #define WOLFSSL_ERROR(x) WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__,NULL)
wolfSSL 13:80fb167dafdf 100 #else
wolfSSL 13:80fb167dafdf 101 void WOLFSSL_ERROR(int);
wolfSSL 13:80fb167dafdf 102 #endif
wolfSSL 13:80fb167dafdf 103 #else
wolfSSL 13:80fb167dafdf 104 #define WOLFSSL_ERROR(e)
wolfSSL 13:80fb167dafdf 105 #endif
wolfSSL 13:80fb167dafdf 106
wolfSSL 13:80fb167dafdf 107 #ifdef __cplusplus
wolfSSL 13:80fb167dafdf 108 }
wolfSSL 13:80fb167dafdf 109 #endif
wolfSSL 13:80fb167dafdf 110 #endif /* WOLFSSL_LOGGING_H */
wolfSSL 13:80fb167dafdf 111
wolfSSL 13:80fb167dafdf 112