]> granicus.if.org Git - esp-idf/commitdiff
components/openssl: refacetor the SSL debug function
authorDong Heng <dongheng@espressif.com>
Tue, 1 Nov 2016 06:59:50 +0000 (14:59 +0800)
committerDong Heng <dongheng@espressif.com>
Tue, 1 Nov 2016 06:59:50 +0000 (14:59 +0800)
Add the "ssl_opt.h" file to make user able t add its platform interface

components/openssl/include/internal/ssl_dbg.h
components/openssl/include/platform/ssl_port.h
components/openssl/platform/ssl_port.c

index 1b0a73f167c1fb9f247fd2f359ad4bc4c51dd542..5b909955e4c279f90b8dda5ddf2249143ef74d54 100644 (file)
 #define SSL_DEBUG_LOCATION_ENABLE 0
 #endif
 
-#ifndef SSL_PRINT
-    #include "stdio.h"
-    extern int printf(const char *fmt, ...);
-    #define SSL_PRINT printf
+#if SSL_DEBUG_ENBALE
+    #ifndef SSL_PRINT
+        #include "stdio.h"
+        extern int printf(const char *fmt, ...);
+        #define SSL_PRINT printf
+    #endif
+#else
+    #ifdef SSL_PRINT
+        #undef SSL_PRINT
+        #define SSL_PRINT(...)
+    #endif
 #endif
 
 #if SSL_DEBUG_LOCATION_ENABLE
     #define SSL_ASSERT(s)
 #endif
 
-#define SSL_ERR(err, go, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(__VA_ARGS__); ret = err; goto go; }
+#define SSL_ERR(err, go, fmt, ...) { SSL_DEBUG_LOCATION(); SSL_PRINT(fmt, ##__VA_ARGS__); ret = err; goto go; }
 
-#define SSL_RET(go, ...) {  SSL_DEBUG_LOCATION(); SSL_PRINT(__VA_ARGS__); goto go; }
+#define SSL_RET(go, fmt, ...) {  SSL_DEBUG_LOCATION(); SSL_PRINT(fmt, ##__VA_ARGS__); goto go; }
 
-#define SSL_DEBUG(level, ...) { if (level > SSL_DEBUG_LEVEL) {SSL_PRINT(__VA_ARGS__);} }
+#define SSL_DEBUG(level, fmt, ...) { if (level > SSL_DEBUG_LEVEL) {SSL_PRINT(fmt, ##__VA_ARGS__);} }
 
 #ifdef __cplusplus
 }
index 4a319c91ae77a16adc4fee70d36c3d660ec9a14f..1e4c2f31f97b3aea1937fa688f68d0804ee20bc9 100644 (file)
@@ -24,6 +24,7 @@
 #ifdef ESP32_IDF_PLATFORM
 
 #include "esp_types.h"
+#include "esp_log.h"
 
 void *ssl_mem_zalloc(size_t size);
 void *ssl_mem_malloc(size_t size);
@@ -35,6 +36,8 @@ size_t ssl_strlen(const char *src);
 void ssl_speed_up_enter(void);
 void ssl_speed_up_exit(void);
 
+#define SSL_PRINT(fmt, ...) ESP_LOGD("OpenSSL", fmt, ##__VA_ARGS__)
+
 #elif defined(SSL_PLATFORM_USER_INCLUDE)
 
 SSL_PLATFORM_USER_INCLUDE
index 1f195101164d4e68c56e7401dbb6672fdc1b6f54..ae3b849ca3c71af6088c5bfdb49c72c9784fa0f3 100644 (file)
@@ -22,7 +22,7 @@
 /*********************************************************************************************/
 /********************************* SSL general interface *************************************/
 
-void* ssl_zalloc(size_t size)
+void* ssl_mem_zalloc(size_t size)
 {
     void *p = malloc(size);
 
@@ -32,12 +32,12 @@ void* ssl_zalloc(size_t size)
     return p;
 }
 
-void *ssl_malloc(size_t size)
+void *ssl_mem_malloc(size_t size)
 {
     return malloc(size);
 }
 
-void ssl_free(void *p)
+void ssl_mem_free(void *p)
 {
     free(p);
 }