significant upgrade to selftest, added echotest, better checks for data in queue before socket closure

This commit is contained in:
Joseph Henry
2017-06-16 16:58:30 -07:00
parent 4403f902a4
commit 195cac6d55
17 changed files with 1038 additions and 658 deletions

View File

@@ -24,21 +24,19 @@
* of your own application.
*/
/****************************************************************************/
/* Debug */
/****************************************************************************/
#include <pthread.h>
#include <sys/syscall.h>
#include <sys/types.h>
#define ZT_DEBUG_LEVEL 5 // Set this to adjust what you'd like to see in the debug traces
#define ZT_DEBUG_LEVEL 6 // Set this to adjust what you'd like to see in the debug traces
#define ZT_MSG_ERROR 1 // Errors
#define ZT_MSG_TRANSFER 2 // RX/TX specific statements
#define ZT_MSG_TEST 1 // For use in selftest
#define ZT_MSG_ERROR 2 // Errors
#define ZT_MSG_INFO 3 // Information which is generally useful to any developer
#define ZT_MSG_EXTRA 4 // If nothing in your world makes sense
#define ZT_MSG_FLOW 5 // High-level flow messages
#define ZT_MSG_TRANSFER 5 // RX/TX specific statements
#define ZT_MSG_FLOW 6 // High-level flow messages
#define ZT_COLOR true
// Debug output colors
@@ -87,8 +85,15 @@
#define ZT_LOG_TAG "ZTSDK"
#endif
#if ZT_DEBUG_LEVEL >= ZT_MSG_TEST
#define DEBUG_TEST(fmt, args...) fprintf(stderr, ZT_CYN "ZT_TEST [%d] : %16s:%5d:%25s: " fmt \
"\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
#else
#define DEBUG_ERROR(fmt, args...)
#endif
#if ZT_DEBUG_LEVEL >= ZT_MSG_ERROR
#define DEBUG_ERROR(fmt, args...) fprintf(stderr, ZT_RED "ZT_ERROR[%ld] : %16s:%5d:%25s: " fmt \
#define DEBUG_ERROR(fmt, args...) fprintf(stderr, ZT_RED "ZT_ERROR[%d] : %16s:%5d:%25s: " fmt \
"\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
#else
#define DEBUG_ERROR(fmt, args...)
@@ -106,13 +111,13 @@
"ZT_STACK: %16s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
#else
#define DEBUG_INFO(fmt, args...) fprintf(stderr, \
"ZT_INFO [%ld] : %16s:%5d:%25s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
"ZT_INFO [%d] : %16s:%5d:%25s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
#define DEBUG_ATTN(fmt, args...) fprintf(stderr, ZT_CYN \
"ZT_ATTN [%ld] : %16s:%5d:%25s: " fmt "\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
"ZT_ATTN [%d] : %16s:%5d:%25s: " fmt "\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
#define DEBUG_STACK(fmt, args...) fprintf(stderr, ZT_YEL \
"ZT_STACK[%ld] : %16s:%5d:%25s: " fmt "\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
"ZT_STACK[%d] : %16s:%5d:%25s: " fmt "\n" ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
#define DEBUG_BLANK(fmt, args...) fprintf(stderr, \
"ZT_INFO [%ld] : %16s:%5d:" fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, ##args)
"ZT_INFO [%d] : %16s:%5d:" fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, ##args)
#endif
#else
#define DEBUG_INFO(fmt, args...)
@@ -139,7 +144,7 @@
"ZT_EXTRA : %16s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
#else
#define DEBUG_EXTRA(fmt, args...) fprintf(stderr, \
"ZT_EXTRA[%ld] : %16s:%5d:%25s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
"ZT_EXTRA[%d] : %16s:%5d:%25s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
#endif
#else
#define DEBUG_EXTRA(fmt, args...)

View File

@@ -41,8 +41,8 @@
#define MAX_PICO_FRAME_RX_BUF_SZ ZT_MAX_MTU * 128
#define ZT_TCP_TX_BUF_SZ 1024 * 1024
#define ZT_TCP_RX_BUF_SZ 1024 * 1024
#define ZT_TCP_TX_BUF_SZ 1024 * 1024 * 5
#define ZT_TCP_RX_BUF_SZ 1024 * 1024 * 5
#define ZT_UDP_TX_BUF_SZ ZT_MAX_MTU
#define ZT_UDP_RX_BUF_SZ ZT_MAX_MTU * 10
@@ -50,11 +50,11 @@
#define ZT_CORE_VERSION_MAJOR 1
#define ZT_CORE_VERSION_MINOR 2
#define ZT_CORE_VERSION_REVISION 4
#define ZT_CORE_VERSION_REVISION 5
#define ZT_SDK_VERSION_MAJOR 1
#define ZT_SDK_VERSION_MINOR 0
#define ZT_SDK_VERSION_REVISION 0
#define ZT_LIB_VERSION_MAJOR 1
#define ZT_LIB_VERSION_MINOR 1
#define ZT_LIB_VERSION_REVISION 4
#define ZT_MAX_IPADDR_LEN 64
#define ZT_ID_LEN 10
@@ -77,6 +77,9 @@
#define ZT_SOCK_BEHAVIOR_LINGER true
#define ZT_SOCK_BEHAVIOR_LINGER_TIME 3 // s
// Wait time for socket closure if data is still present in the write queue
#define ZT_SDK_CLTIME 60
// After closing a pico_socket, other threads might still try to use the
// Connection object for remaining data I/O, as a safety measure we will wait to
// delete this Connection object until the socket has been closed for some arbitrary
@@ -115,7 +118,7 @@
/****************************************************************************/
/* SDK Socket API (ZeroTier Service Controls) */
/* Implemented in SDKService.cpp */
/* Implemented in libzt.cpp */
/****************************************************************************/
#ifdef __cplusplus
@@ -169,9 +172,9 @@ void zts_get_homepath(char *homePath, const int len);
void zts_core_version(char *ver);
/**
* Provides core SDK service version
* Provides core libzt service version
*/
void zts_sdk_version(char *ver);
void zts_lib_version(char *ver);
/**
* Get device ID