mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
fix windows build
This commit is contained in:
parent
8117960843
commit
7f809eb53b
8 changed files with 47 additions and 21 deletions
|
@ -38,6 +38,16 @@ if (NOT MSVC)
|
|||
add_cxxflags("-fpermissive")
|
||||
endif (NOT MSVC)
|
||||
|
||||
if (WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
|
||||
if (USING_CLANG)
|
||||
add_cxxflags("-Wno-unused-command-line-argument -Wno-c++11-narrowing")
|
||||
add_cflags("-Wno-unused-command-line-argument")
|
||||
# because clang is insane enough to inline whole sections of the C++ library!
|
||||
# May have been fixed in llvm-7.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition --rtlib=libgcc")
|
||||
endif(USING_CLANG)
|
||||
endif()
|
||||
|
||||
if(DEBIAN)
|
||||
add_definitions(-DDEBIAN)
|
||||
endif()
|
||||
|
@ -470,20 +480,14 @@ add_shadow_plugin(shadow-plugin-${SHARED_LIB} ${EXE_SRC} ${LIB_SRC} ${LIB_PLATFO
|
|||
target_link_libraries(shadow-plugin-${SHARED_LIB} ${LIBS})
|
||||
install(TARGETS shadow-plugin-${SHARED_LIB} DESTINATION plugins)
|
||||
else()
|
||||
add_executable(${RC_EXE} ${RC_SRC})
|
||||
add_executable(${RC_EXE} ${RC_SRC})
|
||||
add_executable(${EXE} ${EXE_SRC})
|
||||
add_executable(${CLIENT_EXE} ${CLIENT_SRC})
|
||||
add_executable(${DNS_EXE} ${DNS_SRC})
|
||||
add_executable(${DNS_EXE} ${DNS_SRC})
|
||||
add_subdirectory(${GTEST_DIR})
|
||||
include_directories(${GTEST_DIR}/include ${GTEST_DIR})
|
||||
add_executable(${TEST_EXE} ${TEST_SRC})
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ws2_32 iphlpapi)
|
||||
else()
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB})
|
||||
endif(WIN32)
|
||||
|
||||
if(WITH_STATIC)
|
||||
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
||||
if(NOT HAVE_CXX17_FILESYSTEM)
|
||||
|
@ -504,19 +508,23 @@ if(WITH_STATIC)
|
|||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB})
|
||||
if (WIN32)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${BACKPORT_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
endif(WIN32)
|
||||
else()
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB})
|
||||
if (WIN32)
|
||||
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
|
||||
endif(WIN32)
|
||||
endif(NOT HAVE_CXX17_FILESYSTEM)
|
||||
if (WIN32)
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include <llarp/net.hpp> // for llarp::Addr
|
||||
|
||||
|
|
|
@ -10,9 +10,16 @@
|
|||
#include <stdlib.h> // for itoa
|
||||
|
||||
// for addrinfo
|
||||
#ifndef _WIN32
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <wspiapi.h>
|
||||
#define inet_aton(x,y) inet_pton(AF_INET,x,y)
|
||||
#endif
|
||||
|
||||
bool
|
||||
operator==(const sockaddr& a, const sockaddr& b);
|
||||
|
|
|
@ -30,19 +30,21 @@
|
|||
|
||||
// we already have our own definition of these
|
||||
// -despair
|
||||
namespace {
|
||||
extern "C" {
|
||||
const char* inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||
int inet_pton(int af, const char *src, void *dst);
|
||||
}
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
const char *libutp::inet_ntop(int af, const void *src, char *dest, size_t length)
|
||||
{
|
||||
return inet_ntop(af, src, dest, length);
|
||||
return ::inet_ntop(af, src, dest, length);
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
int libutp::inet_pton(int af, const char* src, void* dest)
|
||||
{
|
||||
return inet_pton(af, src, dest);
|
||||
return ::inet_pton(af, src, dest);
|
||||
}
|
||||
|
|
|
@ -462,7 +462,7 @@ raw_resolve_host(struct dnsc_context *dnsc, const char *url,
|
|||
llarp::LogInfo("Waiting for recv");
|
||||
|
||||
// Timeout?
|
||||
ret = recvfrom(sockfd, buffer, DNC_BUF_SIZE, 0, (struct sockaddr *)&addr,
|
||||
ret = recvfrom(sockfd, (char*)buffer, DNC_BUF_SIZE, 0, (struct sockaddr *)&addr,
|
||||
&size);
|
||||
llarp::LogInfo("recv done ", size);
|
||||
if(ret < 0)
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
#include <llarp/handlers/tun.hpp>
|
||||
#include "router.hpp"
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#ifndef DNS_PORT
|
||||
#define DNS_PORT (53)
|
||||
|
@ -102,11 +104,11 @@ namespace llarp
|
|||
strncpy(tunif.ifaddr, addr.c_str(), sizeof(tunif.ifaddr) - 1);
|
||||
|
||||
// set up address in dotLokiLookup
|
||||
struct sockaddr_in s_addr;
|
||||
s_addr.sin_addr.s_addr = inet_addr(tunif.ifaddr);
|
||||
s_addr.sin_family = AF_INET;
|
||||
struct sockaddr_in source_addr;
|
||||
source_addr.sin_addr.s_addr = inet_addr(tunif.ifaddr);
|
||||
source_addr.sin_family = AF_INET;
|
||||
|
||||
llarp::Addr tunIp(s_addr);
|
||||
llarp::Addr tunIp(source_addr);
|
||||
// related to dns_iptracker_setup_dotLokiLookup(&this->dll, tunIp);
|
||||
dns_iptracker_setup(tunIp); // claim GW IP to make sure it's not inuse
|
||||
return true;
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
#include <netinet/ip_icmp.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <wspiapi.h>
|
||||
#endif
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
namespace utp
|
||||
|
@ -342,7 +348,7 @@ namespace llarp
|
|||
static_cast< LinkLayer* >(utp_context_get_userdata(arg->context));
|
||||
llarp::LogDebug("utp_sendto ", Addr(*arg->address), " ", arg->len,
|
||||
" bytes");
|
||||
if(sendto(l->m_udp.fd, arg->buf, arg->len, arg->flags, arg->address,
|
||||
if(::sendto(l->m_udp.fd, (char*)arg->buf, arg->len, arg->flags, arg->address,
|
||||
arg->address_len)
|
||||
== -1)
|
||||
{
|
||||
|
|
|
@ -20,12 +20,11 @@ option(gtest_build_tests "Build all of gtest's own tests." OFF)
|
|||
|
||||
option(gtest_build_samples "Build gtest's sample programs." OFF)
|
||||
|
||||
if (NOT WIN32)
|
||||
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
|
||||
|
||||
# use native windows nt threading even in gcc or clang
|
||||
if (WIN32)
|
||||
option(gtest_disable_pthreads ON)
|
||||
endif(WIN32)
|
||||
else()
|
||||
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON)
|
||||
endif(NOT WIN32)
|
||||
|
||||
option(
|
||||
gtest_hide_internal_symbols
|
||||
|
|
Loading…
Reference in a new issue