Updated CMake build script for Windows. Moving away from MinGW requirement for build
This commit is contained in:
@@ -35,10 +35,19 @@ set (CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/bin)
|
|||||||
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
||||||
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
|
||||||
# Flags for various build types
|
if (WIN32)
|
||||||
|
set (CMAKE_C_FLAGS "-DZT_SDK=1")
|
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNOMINMAX")
|
||||||
|
set (LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/win32/include)
|
||||||
|
#set (COMMON_DEBUG_FLAGS "-DLIBZT_TRACE=1 -DLIBZT_DEBUG=1 -DNS_TRACE=1 -DNS_DEBUG=1")
|
||||||
|
else()
|
||||||
set (CMAKE_C_FLAGS "-fvisibility=hidden -fstack-protector -DZT_SDK=1")
|
set (CMAKE_C_FLAGS "-fvisibility=hidden -fstack-protector -DZT_SDK=1")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11")
|
set (LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/unix/include)
|
||||||
set (COMMON_DEBUG_FLAGS "-g -DLIBZT_TRACE=1 -DLIBZT_DEBUG=1 -DNS_TRACE=1 -DNS_DEBUG=1")
|
set (COMMON_DEBUG_FLAGS "-g -DLIBZT_TRACE=1 -DLIBZT_DEBUG=1 -DNS_TRACE=1 -DNS_DEBUG=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Flags for various build types
|
||||||
|
set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
# C
|
# C
|
||||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS} ${COMMON_DEBUG_FLAGS}")
|
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS} ${COMMON_DEBUG_FLAGS}")
|
||||||
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${CMAKE_C_FLAGS}")
|
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${CMAKE_C_FLAGS}")
|
||||||
@@ -60,11 +69,11 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS}")
|
|||||||
# lwIP Userspace Networking Stack
|
# lwIP Userspace Networking Stack
|
||||||
set (LWIP_SRC_DIR ${PROJ_DIR}/ext/lwip/src)
|
set (LWIP_SRC_DIR ${PROJ_DIR}/ext/lwip/src)
|
||||||
include_directories (${LWIP_SRC_DIR}/include)
|
include_directories (${LWIP_SRC_DIR}/include)
|
||||||
include_directories(${PROJ_DIR}/ext/lwip-contrib/ports/unix/include)
|
include_directories (${LWIP_PORT_DIR})
|
||||||
file (GLOB lwip_src_glob
|
file (GLOB lwip_src_glob
|
||||||
${LWIP_SRC_DIR}/netif/*.c
|
${LWIP_SRC_DIR}/netif/*.c
|
||||||
${LWIP_SRC_DIR}/api/*.c
|
${LWIP_SRC_DIR}/api/*.c
|
||||||
${PROJ_DIR}/ext/lwip-contrib/ports/unix/port/sys_arch.c
|
${LWIP_PORT_DIR}/sys_arch.c
|
||||||
${LWIP_SRC_DIR}/core/*.c
|
${LWIP_SRC_DIR}/core/*.c
|
||||||
${LWIP_SRC_DIR}/core/ipv4/*.c
|
${LWIP_SRC_DIR}/core/ipv4/*.c
|
||||||
${LWIP_SRC_DIR}/core/ipv6/*.c)
|
${LWIP_SRC_DIR}/core/ipv6/*.c)
|
||||||
|
|||||||
@@ -25,21 +25,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(_WIN32)
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
|
||||||
#include <WinSock2.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libzt.h"
|
#include "libzt.h"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ typedef int sys_prot_t;
|
|||||||
printf("Assertion \"%s\" failed at line %d in %s\n", message, __LINE__, __FILE__); \
|
printf("Assertion \"%s\" failed at line %d in %s\n", message, __LINE__, __FILE__); \
|
||||||
fflush(NULL);handler;} } while(0)
|
fflush(NULL);handler;} } while(0)
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if _MSC_VER < 1900
|
||||||
/* C runtime functions redefined */
|
/* C runtime functions redefined */
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
|
|||||||
@@ -33,9 +33,14 @@
|
|||||||
#ifndef LIBZT_SYSUTILS_H
|
#ifndef LIBZT_SYSUTILS_H
|
||||||
#define LIBZT_SYSUTILS_H
|
#define LIBZT_SYSUTILS_H
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <Windows.h>
|
||||||
|
#else
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the thread-id. Used in debug traces.
|
* @brief Returns the thread-id. Used in debug traces.
|
||||||
*
|
*
|
||||||
@@ -52,7 +57,7 @@ inline unsigned int gettid();
|
|||||||
*/
|
*/
|
||||||
inline uint64_t time_now()
|
inline uint64_t time_now()
|
||||||
{
|
{
|
||||||
#ifdef __WINDOWS__
|
#ifdef _WIN32
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
ULARGE_INTEGER tmp;
|
ULARGE_INTEGER tmp;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace ZeroTier {
|
|||||||
struct InetAddress;
|
struct InetAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(_WIN32_FALSE)
|
||||||
|
|
||||||
#define NS_INADDRSZ 4
|
#define NS_INADDRSZ 4
|
||||||
#define NS_IN6ADDRSZ 16
|
#define NS_IN6ADDRSZ 16
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
* VirtualSocket management layer
|
* VirtualSocket management layer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include "InetAddress.hpp"
|
#include "libztDefs.h"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
class Mutex;
|
class Mutex;
|
||||||
|
|||||||
@@ -42,21 +42,19 @@ extern int errno;
|
|||||||
#include "Thread.hpp"
|
#include "Thread.hpp"
|
||||||
#include "Phy.hpp"
|
#include "Phy.hpp"
|
||||||
|
|
||||||
#include "libztDefs.h"
|
#include "libzt.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
extern std::vector<void*> vtaps;
|
extern std::vector<void*> vtaps;
|
||||||
extern ZeroTier::Mutex _vtaps_lock;
|
extern ZeroTier::Mutex _vtaps_lock;
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(_WIN32)
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <IPHlpApi.h>
|
#include <IPHlpApi.h>
|
||||||
#include <Ifdef.h>
|
#include <Ifdef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace ZeroTier;
|
using namespace ZeroTier;
|
||||||
|
|
||||||
class VirtualSocket;
|
class VirtualSocket;
|
||||||
|
|||||||
@@ -30,6 +30,10 @@
|
|||||||
* ZeroTier One service control wrapper header file
|
* ZeroTier One service control wrapper header file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ZeroTierOne.h"
|
#include "ZeroTierOne.h"
|
||||||
#include "InetAddress.hpp"
|
#include "InetAddress.hpp"
|
||||||
#include "libztDefs.h"
|
#include "libztDefs.h"
|
||||||
@@ -67,7 +71,11 @@ std::vector<ZT_VirtualNetworkRoute> *zts_get_network_routes(const uint64_t nwid)
|
|||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
#if defined(_WIN32)
|
||||||
|
DWORD WINAPI zts_start_service(LPVOID thread_id);
|
||||||
|
#else
|
||||||
void *zts_start_service(void *thread_id);
|
void *zts_start_service(void *thread_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns masked address for subnet comparisons
|
* @brief Returns masked address for subnet comparisons
|
||||||
|
|||||||
@@ -34,30 +34,27 @@
|
|||||||
#define LIBZT_H
|
#define LIBZT_H
|
||||||
|
|
||||||
#include "libztDebug.h"
|
#include "libztDebug.h"
|
||||||
|
#include "libztDefs.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(_WIN32)
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
int inet_pton(int af, const char *src, void *dst);
|
//int inet_pton(int af, const char *src, void *dst);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DLL export for Windows (and other cruft) */
|
/* DLL export for Windows (and other cruft) */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#if (defined(_WIN32) || defined(_WIN64)) && !(defined(__MINGW32__) || defined(__MINGW64__))
|
|
||||||
typedef int ssize_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__MING32__) || defined(__MING64__)
|
#if defined(__MING32__) || defined(__MING64__)
|
||||||
#ifdef ADD_EXPORTS
|
#ifdef ADD_EXPORTS
|
||||||
#define ZT_SOCKET_API __declspec(dllexport)
|
#define ZT_SOCKET_API __declspec(dllexport)
|
||||||
|
|||||||
@@ -33,15 +33,12 @@
|
|||||||
#ifndef LIBZT_DEBUG_HPP
|
#ifndef LIBZT_DEBUG_HPP
|
||||||
#define LIBZT_DEBUG_HPP
|
#define LIBZT_DEBUG_HPP
|
||||||
|
|
||||||
#if defined(__MINGW32__) || !defined(_WIN32)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
|
#include <sys/syscall.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define ZT_MSG_ERROR true // Errors
|
#define ZT_MSG_ERROR true // Errors
|
||||||
@@ -56,7 +53,7 @@
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include "TargetConditionals.h"
|
#include "TargetConditionals.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(ZT_COLOR) && !defined(__MINGW32__) && !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_IPHONE_SIMULATOR) && !defined(__APP_FRAMEWORK__)
|
#if defined(ZT_COLOR) && !defined(_WIN32) && !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_IPHONE_SIMULATOR) && !defined(__APP_FRAMEWORK__)
|
||||||
#define ZT_RED "\x1B[31m"
|
#define ZT_RED "\x1B[31m"
|
||||||
#define ZT_GRN "\x1B[32m"
|
#define ZT_GRN "\x1B[32m"
|
||||||
#define ZT_YEL "\x1B[33m"
|
#define ZT_YEL "\x1B[33m"
|
||||||
@@ -86,7 +83,7 @@ extern unsigned int gettid();
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#define ZT_THREAD_ID (long)0 //(long)gettid()
|
#define ZT_THREAD_ID (long)0 //(long)gettid()
|
||||||
#endif
|
#endif
|
||||||
#ifdef __MINGW32__
|
#ifdef _WIN32
|
||||||
#define ZT_THREAD_ID (long)0
|
#define ZT_THREAD_ID (long)0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -103,7 +100,7 @@ extern unsigned int gettid();
|
|||||||
#define DEBUG_STACK(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
#define DEBUG_STACK(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||||
"STACK[%ld]: %17s:%5d:%20s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
"STACK[%ld]: %17s:%5d:%20s: " fmt "\n", ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_STACK(fmt, args, ...) fprintf(stderr, ZT_YEL "STACK[%ld]: %17s:%5d:%25s: " fmt \
|
#define DEBUG_STACK(fmt, args, ...) fprintf(stderr, ZT_YEL "STACK[%ld]: %17s:%5d:%25s: " fmt \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||||
#else
|
#else
|
||||||
@@ -119,7 +116,7 @@ extern unsigned int gettid();
|
|||||||
#define DEBUG_TEST(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
#define DEBUG_TEST(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||||
"TEST : %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
"TEST : %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_TEST(fmt, args, ...) fprintf(stderr, ZT_CYN "TEST [%ld]: %17s:%5d:%25s: " fmt "\n" \
|
#define DEBUG_TEST(fmt, args, ...) fprintf(stderr, ZT_CYN "TEST [%ld]: %17s:%5d:%25s: " fmt "\n" \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||||
#else
|
#else
|
||||||
@@ -136,7 +133,7 @@ extern unsigned int gettid();
|
|||||||
#define DEBUG_ERROR(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
#define DEBUG_ERROR(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||||
"ERROR: %17s:%5d:%20s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
"ERROR: %17s:%5d:%20s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_ERROR(fmt, args, ...) fprintf(stderr, ZT_RED "ERROR[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
#define DEBUG_ERROR(fmt, args, ...) fprintf(stderr, ZT_RED "ERROR[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||||
#else
|
#else
|
||||||
@@ -153,7 +150,7 @@ extern unsigned int gettid();
|
|||||||
#define DEBUG_INFO(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
#define DEBUG_INFO(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||||
"INFO : %17s:%5d:%20s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
"INFO : %17s:%5d:%20s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_INFO(fmt, args, ...) fprintf(stderr, ZT_WHT "INFO [%ld]: %17s:%5d:%25s: " fmt "\n" \
|
#define DEBUG_INFO(fmt, args, ...) fprintf(stderr, ZT_WHT "INFO [%ld]: %17s:%5d:%25s: " fmt "\n" \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||||
#else
|
#else
|
||||||
@@ -170,7 +167,7 @@ extern unsigned int gettid();
|
|||||||
#define DEBUG_TRANS(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
#define DEBUG_TRANS(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||||
"TRANS: %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
"TRANS: %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_TRANS(fmt, args, ...) fprintf(stderr, ZT_GRN "TRANS[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
#define DEBUG_TRANS(fmt, args, ...) fprintf(stderr, ZT_GRN "TRANS[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||||
#else
|
#else
|
||||||
@@ -187,9 +184,9 @@ extern unsigned int gettid();
|
|||||||
#define DEBUG_EXTRA(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
#define DEBUG_EXTRA(fmt, args...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, ZT_LOG_TAG, \
|
||||||
"EXTRA: %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
"EXTRA: %17s:%5d:%25s: " fmt "\n", ZT_FILENAME, __LINE__, __FUNCTION__, ##args))
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_EXTRA(fmt, args, ...) fprintf(stderr, ZT_WHT "EXTRA[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
#define DEBUG_EXTRA(fmt, args, ...) fprintf(stderr, ZT_WHT "EXTRA[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args, (long)0)
|
||||||
#else
|
#else
|
||||||
#define DEBUG_EXTRA(fmt, args ...) fprintf(stderr, ZT_WHT "EXTRA[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
#define DEBUG_EXTRA(fmt, args ...) fprintf(stderr, ZT_WHT "EXTRA[%ld]: %17s:%5d:%25s: " fmt "\n" \
|
||||||
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
ZT_RESET, ZT_THREAD_ID, ZT_FILENAME, __LINE__, __FUNCTION__, ##args)
|
||||||
@@ -199,14 +196,14 @@ extern unsigned int gettid();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else // !LIBZT_DEBUG || !__NATIVE_TEST__
|
#else // !LIBZT_DEBUG || !__NATIVE_TEST__
|
||||||
#if defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__)) // WINDOWS
|
#if defined(_WIN32)
|
||||||
#define DEBUG_ERROR(fmt, args, ...)
|
#define DEBUG_ERROR(...)
|
||||||
#define DEBUG_TEST(fmt, args, ...)
|
#define DEBUG_TEST(...)
|
||||||
#define DEBUG_INFO(fmt, args, ...)
|
#define DEBUG_INFO(...)
|
||||||
#define DEBUG_BLANK(fmt, args, ...)
|
#define DEBUG_BLANK(...)
|
||||||
#define DEBUG_ATTN(fmt, args, ...)
|
#define DEBUG_ATTN(...)
|
||||||
#define DEBUG_TRANS(fmt, args, ...)
|
#define DEBUG_TRANS(...)
|
||||||
#define DEBUG_EXTRA(fmt, args, ...)
|
#define DEBUG_EXTRA(...)
|
||||||
#else
|
#else
|
||||||
#define DEBUG_ERROR(fmt, args...)
|
#define DEBUG_ERROR(fmt, args...)
|
||||||
#define DEBUG_TEST(fmt, args...)
|
#define DEBUG_TEST(fmt, args...)
|
||||||
|
|||||||
@@ -127,8 +127,13 @@
|
|||||||
*/
|
*/
|
||||||
#define ZTO_ID_LEN 16
|
#define ZTO_ID_LEN 16
|
||||||
|
|
||||||
#if !defined(__MINGW32__)
|
//#if !defined(__WIN32__)
|
||||||
typedef unsigned int socklen_t;
|
//typedef unsigned int socklen_t;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|||||||
@@ -43,11 +43,11 @@
|
|||||||
|
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SysUtils.h"
|
#include "SysUtils.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(_WIN32_FALSE)
|
||||||
|
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ std::string netDir; // Where network .conf files are to be written
|
|||||||
|
|
||||||
ZeroTier::Mutex _multiplexer_lock;
|
ZeroTier::Mutex _multiplexer_lock;
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(_WIN32)
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// prototype
|
// prototype
|
||||||
@@ -180,7 +181,11 @@ uint64_t zts_get_node_id_from_file(const char *filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Starts a ZeroTier service in the background
|
// Starts a ZeroTier service in the background
|
||||||
|
#if defined(_WIN32)
|
||||||
|
DWORD WINAPI zts_start_service(LPVOID thread_id)
|
||||||
|
#else
|
||||||
void *zts_start_service(void *thread_id)
|
void *zts_start_service(void *thread_id)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
DEBUG_INFO("zto-thread, path=%s", homeDir.c_str());
|
DEBUG_INFO("zto-thread, path=%s", homeDir.c_str());
|
||||||
// Where network .conf files will be stored
|
// Where network .conf files will be stored
|
||||||
@@ -414,11 +419,15 @@ int zts_start(const char *path, bool blocking = false)
|
|||||||
if (path) {
|
if (path) {
|
||||||
homeDir = path;
|
homeDir = path;
|
||||||
}
|
}
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
int err;
|
||||||
|
#if defined(_WIN32)
|
||||||
WSAStartup(MAKEWORD(2, 2), &wsaData); // initialize WinSock. Used in Phy for loopback pipe
|
WSAStartup(MAKEWORD(2, 2), &wsaData); // initialize WinSock. Used in Phy for loopback pipe
|
||||||
#endif
|
HANDLE thr = CreateThread(NULL, 0, zts_start_service, NULL, 0, NULL);
|
||||||
|
#else
|
||||||
pthread_t service_thread;
|
pthread_t service_thread;
|
||||||
int err = pthread_create(&service_thread, NULL, zts_start_service, NULL);
|
err = pthread_create(&service_thread, NULL, zts_start_service, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (blocking) { // block to prevent service calls before we're ready
|
if (blocking) { // block to prevent service calls before we're ready
|
||||||
ZT_NodeStatus status;
|
ZT_NodeStatus status;
|
||||||
while (zts_core_running() == false || zt1Service->getNode() == NULL) {
|
while (zts_core_running() == false || zt1Service->getNode() == NULL) {
|
||||||
@@ -463,7 +472,7 @@ void zts_stop()
|
|||||||
zt1Service->terminate();
|
zt1Service->terminate();
|
||||||
// disableTaps();
|
// disableTaps();
|
||||||
}
|
}
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(_WIN32)
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -555,9 +564,13 @@ bool _ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr)
|
|||||||
|
|
||||||
void api_sleep(int interval_ms)
|
void api_sleep(int interval_ms)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
Sleep(interval_ms);
|
||||||
|
#else
|
||||||
struct timespec sleepValue = {0};
|
struct timespec sleepValue = {0};
|
||||||
sleepValue.tv_nsec = interval_ms * 500000;
|
sleepValue.tv_nsec = interval_ms * 500000;
|
||||||
nanosleep(&sleepValue, NULL);
|
nanosleep(&sleepValue, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ int platform_adjusted_socket_family(int family)
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
return family == 30 ? AF_INET6 : family; // 10
|
return family == 30 ? AF_INET6 : family; // 10
|
||||||
#endif
|
#endif
|
||||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
#if defined(_WIN32)
|
||||||
return family == 23 ? AF_INET6 : family; // 10
|
return family == 23 ? AF_INET6 : family; // 10
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ void lwip_driver_init()
|
|||||||
if (lwip_driver_initialized == true) {
|
if (lwip_driver_initialized == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if defined(__MINGW32__)
|
#if defined(_WIN32)
|
||||||
sys_init(); // required for win32 initializtion of critical sections
|
sys_init(); // required for win32 initializtion of critical sections
|
||||||
#endif
|
#endif
|
||||||
sys_thread_new("main_thread", main_thread,
|
sys_thread_new("main_thread", main_thread,
|
||||||
|
|||||||
Reference in New Issue
Block a user