Commit d56b3fc4 authored by Oleksandr Dmytrenko's avatar Oleksandr Dmytrenko

mbedtls error and verify info logging

Added macroses for:
1) mbedtls error logging
2) verify info logging

Change-Id: I9ee474ff8b2ec3ab40dded3af6d208c780d4d3d4
Signed-off-by: default avatarOleksandr Dmytrenko <o.dmytrenko@samsung.com>
parent dd5ed50a
......@@ -35,7 +35,9 @@ extern "C"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#if defined (__WITH_TLS__) || defined(__WITH_DTLS__)
#include "mbedtls/error.h"
#endif
typedef struct OicParseQueryIter OicParseQueryIter_t;
/**
......@@ -110,7 +112,7 @@ struct OicParseQueryIter
#define VERIFY_NOT_NULL_RETURN(tag, arg, logLevel, retValue) do { if (NULL == (arg)) \
{ OIC_LOG((logLevel), tag, #arg " is NULL"); return retValue; } } while(0)
#endif
#if defined (__WITH_TLS__) || defined(__WITH_DTLS__)
/**
* Macro to log an mbedtls error
* For mbedtls functions that return 0 as non-error
......@@ -120,6 +122,31 @@ struct OicParseQueryIter
mbedtls_strerror((ret), (buf), (bufSize)); \
OIC_LOG_V((logLevel), (tag), "mbedtls error: %s", (buf)); } }while(0)
#define LOG_MBEDTLS_ERROR(ret) do{ \
if (0!=(ret)) {\
char *buf = (char*)OICCalloc(2048, 1);\
if (buf)\
{\
mbedtls_strerror((ret), buf, 2048); \
OIC_LOG_V(ERROR, TAG, "mbedtls error: %s", buf); \
OICFree(buf);\
}\
} }while(0)
#define LOG_MBEDTLS_VERIFY_ERROR(flags) do{ \
if (0!=(flags)) { \
char *buf = (char*)OICCalloc(2048, 1); \
if (buf) \
{ \
mbedtls_x509_crt_verify_info(buf, 2048, "", flags); \
OIC_LOG_V(ERROR, TAG, "mbedtls verify error: %s", buf); \
OICFree(buf); \
} \
} }while(0)
#endif //(__WITH_TLS__) || defined(__WITH_DTLS__)
/**
* This method initializes the @ref OicParseQueryIter_t struct.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment