wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue Aug 22 10:48:22 2017 +0000
Revision:
13:f67a6c6013ca
wolfSSL3.12.0 with TLS1.3

Who changed what in which revision?

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