Updated lwip.patch for Linux compatibility, CMakeLists.txt, and fixed other minor compile-time warnings
This commit is contained in:
101
CMakeLists.txt
101
CMakeLists.txt
@@ -60,9 +60,9 @@ else()
|
|||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fstack-protector")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fstack-protector")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBZT_FLAGS} -O3 -Wall -Wextra -std=c++11")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBZT_FLAGS} ${SILENCE} -O3 -Wall -Wextra -std=c++11")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${LIBZT_FLAGS_DEBUG} ${SILENCE} -std=c++11 -DLWIP_DEBUG=1")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${LIBZT_FLAGS_DEBUG} ${SILENCE} -std=c++11 -DLWIP_DEBUG=1")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBZT_FLAGS} -O3 -std=c++11")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBZT_FLAGS} ${SILENCE} -O3 -std=c++11")
|
||||||
set(LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/unix/port)
|
set(LWIP_PORT_DIR ${PROJ_DIR}/ext/lwip-contrib/ports/unix/port)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -108,9 +108,42 @@ endif()
|
|||||||
add_definitions(-DSDK_JNI=1)
|
add_definitions(-DSDK_JNI=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- BUILD TARGETS
|
# --- BUILD TARGETS (FINAL PRODUCT)
|
||||||
|
|
||||||
# lwip
|
# libzt (static)
|
||||||
|
set(LIBZT_SRC_DIR ${PROJ_DIR}/src)
|
||||||
|
include_directories ("${LIBZT_SRC_DIR}")
|
||||||
|
include_directories ("${PROJ_DIR}/include")
|
||||||
|
file (GLOB libzt_src_glob ${LIBZT_SRC_DIR}/*.cpp)
|
||||||
|
add_library (zt STATIC
|
||||||
|
$<TARGET_OBJECTS:lwip_obj>
|
||||||
|
$<TARGET_OBJECTS:zto_obj>
|
||||||
|
$<TARGET_OBJECTS:http_obj> ${libzt_src_glob})
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries (zt ws2_32)
|
||||||
|
target_link_libraries (zt ${lshlwapi_LIBRARY_PATH})
|
||||||
|
target_link_libraries (zt ${liphlpapi_LIBRARY_PATH})
|
||||||
|
else()
|
||||||
|
target_link_libraries (zt pthread)
|
||||||
|
endif()
|
||||||
|
set_target_properties (zt PROPERTIES OUTPUT_NAME zt)
|
||||||
|
|
||||||
|
# libzt (shared)
|
||||||
|
add_library (ztshared SHARED
|
||||||
|
$<TARGET_OBJECTS:lwip_pic_obj>
|
||||||
|
$<TARGET_OBJECTS:zto_pic_obj>
|
||||||
|
$<TARGET_OBJECTS:http_pic_obj> ${libzt_src_glob})
|
||||||
|
set_target_properties (ztshared PROPERTIES OUTPUT_NAME zt)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
||||||
|
target_link_libraries (zt lwip zto android log)
|
||||||
|
else()
|
||||||
|
target_link_libraries (zt pthread)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# --- OBJECT LIBRARIES (INTERMEDIATE)
|
||||||
|
|
||||||
|
# lwip_obj
|
||||||
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 (${LWIP_PORT_DIR}/include)
|
include_directories (${LWIP_PORT_DIR}/include)
|
||||||
@@ -121,11 +154,12 @@ file (GLOB lwip_src_glob
|
|||||||
${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)
|
||||||
add_library (lwip STATIC ${lwip_src_glob})
|
list(REMOVE_ITEM lwip_src_glob ${LWIP_SRC_DIR}/netif/slipif.c)
|
||||||
add_library (lwip_pic STATIC ${lwip_src_glob})
|
add_library (lwip_obj OBJECT ${lwip_src_glob})
|
||||||
set_target_properties (lwip_pic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
add_library (lwip_pic_obj OBJECT ${lwip_src_glob})
|
||||||
|
set_target_properties (lwip_pic_obj PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
# zto
|
# zto_obj
|
||||||
set(ZTO_SRC_DIR ${PROJ_DIR}/ext/ZeroTierOne)
|
set(ZTO_SRC_DIR ${PROJ_DIR}/ext/ZeroTierOne)
|
||||||
include_directories (${ZTO_SRC_DIR}/include)
|
include_directories (${ZTO_SRC_DIR}/include)
|
||||||
include_directories (${ZTO_SRC_DIR}/osdep)
|
include_directories (${ZTO_SRC_DIR}/osdep)
|
||||||
@@ -137,47 +171,20 @@ file (GLOB zto_src_glob
|
|||||||
${ZTO_SRC_DIR}/osdep/OSUtils.cpp
|
${ZTO_SRC_DIR}/osdep/OSUtils.cpp
|
||||||
${ZTO_SRC_DIR}/controller/*.cpp
|
${ZTO_SRC_DIR}/controller/*.cpp
|
||||||
${ZTO_SRC_DIR}/osdep/ManagedRoute.cpp)
|
${ZTO_SRC_DIR}/osdep/ManagedRoute.cpp)
|
||||||
add_library (zto STATIC ${zto_src_glob})
|
add_library (zto_obj OBJECT ${zto_src_glob})
|
||||||
target_link_libraries (zto http)
|
|
||||||
target_link_libraries (zto zt)
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries (zto ws2_32)
|
target_link_libraries (zto ws2_32)
|
||||||
target_link_libraries (zto ${lshlwapi_LIBRARY_PATH})
|
target_link_libraries (zto ${lshlwapi_LIBRARY_PATH})
|
||||||
target_link_libraries (zto ${liphlpapi_LIBRARY_PATH})
|
target_link_libraries (zto ${liphlpapi_LIBRARY_PATH})
|
||||||
endif()
|
endif()
|
||||||
add_library (zto_pic STATIC ${zto_src_glob})
|
add_library (zto_pic_obj OBJECT ${zto_src_glob})
|
||||||
target_link_libraries (zto_pic http_pic zt)
|
set_target_properties (zto_pic_obj PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
set_target_properties (zto_pic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
# http
|
# http_obj
|
||||||
# HTTP Control Plane for ZT Service
|
# HTTP Control Plane for ZT Service
|
||||||
add_library (http STATIC "${ZTO_SRC_DIR}/ext/http-parser/http_parser.c")
|
add_library (http_obj OBJECT "${ZTO_SRC_DIR}/ext/http-parser/http_parser.c")
|
||||||
add_library (http_pic STATIC "${ZTO_SRC_DIR}/ext/http-parser/http_parser.c")
|
add_library (http_pic_obj OBJECT "${ZTO_SRC_DIR}/ext/http-parser/http_parser.c")
|
||||||
set_target_properties (http_pic PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
set_target_properties (http_pic_obj PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
# libzt (static)
|
|
||||||
set(LIBZT_SRC_DIR ${PROJ_DIR}/src)
|
|
||||||
include_directories ("${LIBZT_SRC_DIR}")
|
|
||||||
include_directories ("${PROJ_DIR}/include")
|
|
||||||
file (GLOB libzt_src_glob ${LIBZT_SRC_DIR}/*.cpp)
|
|
||||||
add_library (zt ${libzt_src_glob})
|
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries (zto ws2_32)
|
|
||||||
target_link_libraries (zto ${lshlwapi_LIBRARY_PATH})
|
|
||||||
target_link_libraries (zto ${liphlpapi_LIBRARY_PATH})
|
|
||||||
endif()
|
|
||||||
set_target_properties (zt PROPERTIES OUTPUT_NAME zt)
|
|
||||||
target_link_libraries (zt zto lwip)
|
|
||||||
|
|
||||||
# libzt (shared)
|
|
||||||
add_library (ztshared SHARED ${libzt_src_glob})
|
|
||||||
target_link_libraries (ztshared zto_pic lwip_pic)
|
|
||||||
set_target_properties (ztshared PROPERTIES OUTPUT_NAME zt)
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|
||||||
target_link_libraries (zt lwip zto android log)
|
|
||||||
else()
|
|
||||||
target_link_libraries (zt pthread lwip zto)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- TEST APPLICATIONS AND EXAMPLES
|
# --- TEST APPLICATIONS AND EXAMPLES
|
||||||
|
|
||||||
@@ -194,23 +201,23 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|||||||
get_filename_component (testname ${testname} NAME)
|
get_filename_component (testname ${testname} NAME)
|
||||||
add_executable (${testname} ${testsourcefile})
|
add_executable (${testname} ${testsourcefile})
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries (${testname} lwip zto zt)
|
target_link_libraries (${testname} zt)
|
||||||
else()
|
else()
|
||||||
target_link_libraries (${testname} zt pthread dl)
|
target_link_libraries (${testname} zt pthread dl)
|
||||||
endif()
|
endif()
|
||||||
endforeach (testsourcefile ${APP_SOURCES})
|
endforeach (testsourcefile ${APP_SOURCES})
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
# selftest
|
# selftest
|
||||||
add_executable (selftest ${PROJ_DIR}/test/selftest.cpp)
|
add_executable (selftest ${PROJ_DIR}/test/selftest.cpp)
|
||||||
target_compile_options (selftest PRIVATE -D__SELFTEST__)
|
target_compile_options (selftest PRIVATE -D__SELFTEST__)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries (selftest lwip zto zt ${ws2_32_LIBRARY_PATH} ${lshlwapi_LIBRARY_PATH} ${liphlpapi_LIBRARY_PATH})
|
target_link_libraries (selftest zt ${ws2_32_LIBRARY_PATH} ${lshlwapi_LIBRARY_PATH} ${liphlpapi_LIBRARY_PATH})
|
||||||
else()
|
else()
|
||||||
target_link_libraries (selftest pthread lwip zto zt)
|
target_link_libraries (selftest zt pthread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# nativetest
|
# nativetest
|
||||||
add_executable (nativetest ${PROJ_DIR}/test/selftest.cpp)
|
add_executable (nativetest ${PROJ_DIR}/test/selftest.cpp)
|
||||||
target_compile_options (nativetest PRIVATE -D__NATIVETEST__)
|
target_compile_options (nativetest PRIVATE -D__NATIVETEST__)
|
||||||
target_link_libraries (nativetest lwip zto zt)
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -51,7 +51,7 @@ int main(int argc, char **argv)
|
|||||||
std::string path = argv[1];
|
std::string path = argv[1];
|
||||||
std::string nwidstr = argv[2];
|
std::string nwidstr = argv[2];
|
||||||
int bind_port = atoi(argv[3]);
|
int bind_port = atoi(argv[3]);
|
||||||
int w=0, r=0, err=0, sockfd, accfd, flags = 0;
|
int w=0, r=0, err=0, sockfd = 0, accfd = 0, flags = 0;
|
||||||
char rbuf[32];
|
char rbuf[32];
|
||||||
memset(rbuf, 0, sizeof rbuf);
|
memset(rbuf, 0, sizeof rbuf);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,30 @@
|
|||||||
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
diff --git a/src/api/sockets.c b/src/api/sockets.c
|
||||||
index b7632489..f6ab59f6 100644
|
index b7632489..786a294e 100644
|
||||||
--- a/src/api/sockets.c
|
--- a/src/api/sockets.c
|
||||||
+++ b/src/api/sockets.c
|
+++ b/src/api/sockets.c
|
||||||
@@ -44,6 +44,8 @@
|
@@ -44,6 +44,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
+#include <errno.h>
|
+//#include <errno.h>
|
||||||
+
|
+
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
|
||||||
|
diff --git a/src/include/lwip/errno.h b/src/include/lwip/errno.h
|
||||||
|
index 641cffb0..cec43f7f 100644
|
||||||
|
--- a/src/include/lwip/errno.h
|
||||||
|
+++ b/src/include/lwip/errno.h
|
||||||
|
@@ -174,7 +174,11 @@ extern "C" {
|
||||||
|
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||||
|
|
||||||
|
#ifndef errno
|
||||||
|
-extern int errno;
|
||||||
|
+#if defined(__linux__) && !defined(__ANDROID__)
|
||||||
|
+ #include <errno.h>
|
||||||
|
+#else
|
||||||
|
+ extern int errno;
|
||||||
|
+#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else /* LWIP_PROVIDE_ERRNO */
|
||||||
|
|||||||
@@ -30,11 +30,12 @@
|
|||||||
* Virtual Ethernet tap device
|
* Virtual Ethernet tap device
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ZT_VIRTUALTAP_HPP
|
#ifndef ZT_VIRTUALTAP_H
|
||||||
#define ZT_VIRTUALTAP_HPP
|
#define ZT_VIRTUALTAP_H
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Mutex.hpp"
|
#include "Mutex.hpp"
|
||||||
#include "MulticastGroup.hpp"
|
#include "MulticastGroup.hpp"
|
||||||
|
|||||||
@@ -39,16 +39,14 @@
|
|||||||
#ifndef __LWIPOPTS_H__
|
#ifndef __LWIPOPTS_H__
|
||||||
#define __LWIPOPTS_H__
|
#define __LWIPOPTS_H__
|
||||||
|
|
||||||
//#define LWIP_SUPPORT_CUSTOM_PBUF 0
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Provides its own errno
|
* Provides its own errno
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
#define LWIP_PROVIDE_ERRNO 0
|
#define LWIP_PROVIDE_ERRNO 0
|
||||||
#else
|
#elif !defined(_MSC_VER)
|
||||||
#define LWIP_PROVIDE_ERRNO 0
|
#define LWIP_PROVIDE_ERRNO 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ VirtualTap *getTapByAddr(ZeroTier::InetAddress *addr)
|
|||||||
for (size_t i=0; i<vtaps.size(); i++) {
|
for (size_t i=0; i<vtaps.size(); i++) {
|
||||||
s = (VirtualTap*)vtaps[i];
|
s = (VirtualTap*)vtaps[i];
|
||||||
// check address schemes
|
// check address schemes
|
||||||
for (ssize_t j=0; j<s->_ips.size(); j++) {
|
for (int j=0; j<(int)(s->_ips.size()); j++) {
|
||||||
if ((s->_ips[j].isV4() && addr->isV4()) || (s->_ips[j].isV6() && addr->isV6())) {
|
if ((s->_ips[j].isV4() && addr->isV4()) || (s->_ips[j].isV6() && addr->isV6())) {
|
||||||
/* DEBUG_EXTRA("looking at tap %s, <addr=%s> --- for <%s>", s->_dev.c_str(),
|
/* DEBUG_EXTRA("looking at tap %s, <addr=%s> --- for <%s>", s->_dev.c_str(),
|
||||||
s->_ips[j].toString(ipbuf), addr->toIpString(ipbuf2)); */
|
s->_ips[j].toString(ipbuf), addr->toIpString(ipbuf2)); */
|
||||||
@@ -283,7 +283,7 @@ int zts_get_address_at_index(
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
_vtaps_lock.lock();
|
_vtaps_lock.lock();
|
||||||
if (index > -1 && index <= tap->_ips.size()) {
|
if (index > -1 && index <= (int)tap->_ips.size()) {
|
||||||
memcpy(addr, &(tap->_ips[index]), *addrlen);
|
memcpy(addr, &(tap->_ips[index]), *addrlen);
|
||||||
*addrlen = tap->_ips[index].isV4() ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
|
*addrlen = tap->_ips[index].isV4() ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ int platform_adjusted_socket_family(int family)
|
|||||||
if (family == 2) {
|
if (family == 2) {
|
||||||
return AF_INET;
|
return AF_INET;
|
||||||
}
|
}
|
||||||
family; // 10
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -551,7 +551,7 @@ void tcp_select_server(TCP_UNIT_TEST_SIG_4)
|
|||||||
#else
|
#else
|
||||||
r = _READ(fd_i, rbuf, len);
|
r = _READ(fd_i, rbuf, len);
|
||||||
#endif
|
#endif
|
||||||
if (r == msg.length()) {
|
if (r == (int)msg.length()) {
|
||||||
rx_num++;
|
rx_num++;
|
||||||
DEBUG_TEST("rx=%d", rx_num);
|
DEBUG_TEST("rx=%d", rx_num);
|
||||||
}
|
}
|
||||||
@@ -563,7 +563,7 @@ void tcp_select_server(TCP_UNIT_TEST_SIG_4)
|
|||||||
#else
|
#else
|
||||||
w = _WRITE(fd_i, msg.c_str(), len);
|
w = _WRITE(fd_i, msg.c_str(), len);
|
||||||
#endif
|
#endif
|
||||||
if (w == msg.length()) {
|
if (w == (int)msg.length()) {
|
||||||
tx_num++;
|
tx_num++;
|
||||||
DEBUG_TEST("tx=%d", tx_num);
|
DEBUG_TEST("tx=%d", tx_num);
|
||||||
}
|
}
|
||||||
@@ -638,7 +638,7 @@ void tcp_select_client(TCP_UNIT_TEST_SIG_4)
|
|||||||
#else
|
#else
|
||||||
r = _READ(fd_i, rbuf, len);
|
r = _READ(fd_i, rbuf, len);
|
||||||
#endif
|
#endif
|
||||||
if (r == msg.length()) {
|
if (r == (int)msg.length()) {
|
||||||
rx_num++;
|
rx_num++;
|
||||||
DEBUG_TEST("rx=%d", rx_num);
|
DEBUG_TEST("rx=%d", rx_num);
|
||||||
}
|
}
|
||||||
@@ -650,7 +650,7 @@ void tcp_select_client(TCP_UNIT_TEST_SIG_4)
|
|||||||
#else
|
#else
|
||||||
w = _WRITE(fd_i, msg.c_str(), len);
|
w = _WRITE(fd_i, msg.c_str(), len);
|
||||||
#endif
|
#endif
|
||||||
if (w == msg.length()) {
|
if (w == (int)msg.length()) {
|
||||||
tx_num++;
|
tx_num++;
|
||||||
DEBUG_TEST("tx=%d", tx_num);
|
DEBUG_TEST("tx=%d", tx_num);
|
||||||
}
|
}
|
||||||
@@ -962,7 +962,7 @@ void udp_client_4(UDP_UNIT_TEST_SIG_4)
|
|||||||
int serverlen = sizeof(struct sockaddr_storage);
|
int serverlen = sizeof(struct sockaddr_storage);
|
||||||
// rx
|
// rx
|
||||||
r = _RECVFROM(fd, rbuf, STR_SIZE, 0, (struct sockaddr *)&saddr, (socklen_t *)&serverlen);
|
r = _RECVFROM(fd, rbuf, STR_SIZE, 0, (struct sockaddr *)&saddr, (socklen_t *)&serverlen);
|
||||||
if (r == strlen(msg.c_str())) {
|
if (r == (int)strlen(msg.c_str())) {
|
||||||
sleep(ARTIFICIAL_SOCKET_LINGER);
|
sleep(ARTIFICIAL_SOCKET_LINGER);
|
||||||
err = _CLOSE(fd);
|
err = _CLOSE(fd);
|
||||||
DEBUG_TEST("%s, err=%d, r=%d, w=%d", testname.c_str(), err, r, w);
|
DEBUG_TEST("%s, err=%d, r=%d, w=%d", testname.c_str(), err, r, w);
|
||||||
|
|||||||
Reference in New Issue
Block a user