mirror of https://github.com/oxen-io/lokinet
make windows build happy
This commit is contained in:
parent
05d2729157
commit
baa94ec345
|
@ -8,11 +8,16 @@ option(USE_LIBABYSS "enable libabyss" )
|
|||
option(USE_AVX2 "enable avx2 code" )
|
||||
option(USE_NETNS "enable networking namespace support" )
|
||||
|
||||
# Require C++11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
if(WIN32)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
|
||||
|
||||
# turns off those annoying warnings for
|
||||
# target-specific crypto code paths not
|
||||
# applicable to the host's FPU -rick
|
||||
|
|
|
@ -177,10 +177,9 @@ namespace llarp
|
|||
/// handles setup, given value true on success and false on failure to set
|
||||
/// up interface
|
||||
std::promise< bool > m_TunSetupResult;
|
||||
#endif
|
||||
|
||||
/// handles fd injection force android
|
||||
std::promise< int > m_VPNPromise;
|
||||
|
||||
#endif
|
||||
/// DNS server per tun
|
||||
struct dnsd_context dnsd;
|
||||
/// DNS loki lookup subsystem configuration (also holds optional iptracker
|
||||
|
|
|
@ -17,7 +17,7 @@ raw_sendto_dns_hook_func(void *sock, const struct sockaddr *from,
|
|||
int *fd = (int *)sock;
|
||||
// how do we get to these??
|
||||
socklen_t addrLen = sizeof(struct sockaddr_in);
|
||||
return sendto(*fd, buf.base, buf.sz, 0, from, addrLen);
|
||||
return sendto(*fd, (const char *)buf.base, buf.sz, 0, from, addrLen);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
|
|
37
llarp/ev.hpp
37
llarp/ev.hpp
|
@ -1,6 +1,7 @@
|
|||
#ifndef LLARP_EV_HPP
|
||||
#define LLARP_EV_HPP
|
||||
#include <llarp/ev.h>
|
||||
#include <llarp/threading.hpp>
|
||||
// writev
|
||||
#ifndef _WIN32
|
||||
#include <sys/uio.h>
|
||||
|
@ -62,6 +63,20 @@ namespace llarp
|
|||
}
|
||||
};
|
||||
|
||||
struct GetNow
|
||||
{
|
||||
llarp_ev_loop* loop;
|
||||
GetNow(llarp_ev_loop* l) : loop(l)
|
||||
{
|
||||
}
|
||||
|
||||
llarp_time_t
|
||||
operator()() const
|
||||
{
|
||||
return llarp_ev_loop_time_now_ms(loop);
|
||||
}
|
||||
};
|
||||
|
||||
struct PutTime
|
||||
{
|
||||
llarp_ev_loop* loop;
|
||||
|
@ -88,8 +103,8 @@ namespace llarp
|
|||
using LossyWriteQueue_t =
|
||||
llarp::util::CoDelQueue< WriteBuffer, WriteBuffer::GetTime,
|
||||
WriteBuffer::PutTime, WriteBuffer::Compare,
|
||||
llarp::util::NullMutex, llarp::util::NullLock,
|
||||
5, 100, 128 >;
|
||||
WriteBuffer::GetNow, llarp::util::NullMutex,
|
||||
llarp::util::NullLock, 5, 100, 128 >;
|
||||
|
||||
using LosslessWriteQueue_t = std::deque< WriteBuffer >;
|
||||
|
||||
|
@ -121,7 +136,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
virtual int
|
||||
read(void* buf, size_t sz) = 0;
|
||||
read(byte_t* buf, size_t sz) = 0;
|
||||
|
||||
virtual int
|
||||
sendto(const sockaddr* dst, const void* data, size_t sz)
|
||||
|
@ -610,6 +625,21 @@ namespace llarp
|
|||
|
||||
}; // namespace llarp
|
||||
|
||||
#ifdef _WIN32
|
||||
struct llarp_fd_promise
|
||||
{
|
||||
void
|
||||
Set(int)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
Get()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
#else
|
||||
struct llarp_fd_promise
|
||||
{
|
||||
llarp_fd_promise(std::promise< int >* p) : _impl(p)
|
||||
|
@ -631,6 +661,7 @@ struct llarp_fd_promise
|
|||
return future.get();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
// this (nearly!) abstract base class
|
||||
// is overriden for each platform
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace llarp
|
||||
{
|
||||
int
|
||||
tcp_conn::read(void* buf, size_t sz)
|
||||
tcp_conn::read(byte_t* buf, size_t sz)
|
||||
{
|
||||
if(sz == 0)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
int
|
||||
tcp_serv::read(void*, size_t)
|
||||
tcp_serv::read(byte_t*, size_t)
|
||||
{
|
||||
int new_fd = ::accept(fd, nullptr, nullptr);
|
||||
if(new_fd == -1)
|
||||
|
@ -155,7 +155,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
virtual int
|
||||
read(void* buf, size_t sz)
|
||||
read(byte_t* buf, size_t sz)
|
||||
{
|
||||
sockaddr_in6 src;
|
||||
socklen_t slen = sizeof(sockaddr_in6);
|
||||
|
@ -262,7 +262,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
int
|
||||
read(void* buf, size_t sz)
|
||||
read(byte_t* buf, size_t sz)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
const ssize_t offset = 4;
|
||||
|
@ -272,9 +272,9 @@ namespace llarp
|
|||
ssize_t ret = tuntap_read(tunif, buf, sz);
|
||||
if(ret > offset && t->recvpkt)
|
||||
{
|
||||
byte_t* ptr = ((byte_t*)buf) + offset;
|
||||
buf += offset;
|
||||
ret -= offset;
|
||||
t->recvpkt(t, llarp::InitBuffer(ptr, ret));
|
||||
t->recvpkt(t, llarp::InitBuffer(buf, ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -616,6 +616,13 @@ struct llarp_kqueue_loop : public llarp_ev_loop
|
|||
void
|
||||
stop()
|
||||
{
|
||||
auto itr = handlers.begin();
|
||||
while(itr != handlers.end())
|
||||
{
|
||||
close_ev(itr->get());
|
||||
itr = handlers.erase(itr);
|
||||
}
|
||||
|
||||
if(kqueuefd != -1)
|
||||
::close(kqueuefd);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace llarp
|
||||
{
|
||||
int
|
||||
tcp_conn::read(void* buf, size_t sz)
|
||||
tcp_conn::read(byte_t* buf, size_t sz)
|
||||
{
|
||||
WSABUF r_buf = {(u_long)sz, (char*)buf};
|
||||
DWORD amount = 0;
|
||||
|
@ -28,7 +28,7 @@ namespace llarp
|
|||
if(amount > 0)
|
||||
{
|
||||
if(tcp.read)
|
||||
tcp.read(&tcp, llarp::InitBuffer(buf, amount);
|
||||
tcp.read(&tcp, llarp::InitBuffer(buf, amount));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
int
|
||||
tcp_serv::read(void*, size_t)
|
||||
tcp_serv::read(byte_t*, size_t)
|
||||
{
|
||||
SOCKET new_fd = ::accept(std::get< SOCKET >(fd), nullptr, nullptr);
|
||||
if(new_fd == INVALID_SOCKET)
|
||||
|
@ -134,14 +134,14 @@ namespace llarp
|
|||
}
|
||||
|
||||
virtual int
|
||||
read(void* buf, size_t sz)
|
||||
read(byte_t* buf, size_t sz)
|
||||
{
|
||||
printf("read\n");
|
||||
sockaddr_in6 src;
|
||||
socklen_t slen = sizeof(src);
|
||||
sockaddr* addr = (sockaddr*)&src;
|
||||
unsigned long flags = 0;
|
||||
WSABUF wbuf = {(u_long)sz, static_cast< char* >(buf)};
|
||||
WSABUF wbuf = {(u_long)sz, (char*)buf};
|
||||
// WSARecvFrom
|
||||
llarp::LogDebug("read ", sz, " bytes from socket");
|
||||
int ret = ::WSARecvFrom(std::get< SOCKET >(fd), &wbuf, 1, nullptr, &flags,
|
||||
|
@ -234,7 +234,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
int
|
||||
read(void* buf, size_t sz)
|
||||
read(byte_t* buf, size_t sz)
|
||||
{
|
||||
ssize_t ret = tuntap_read(tunif, buf, sz);
|
||||
if(ret > 0 && t->recvpkt)
|
||||
|
@ -631,4 +631,4 @@ struct llarp_win32_loop : public llarp_ev_loop
|
|||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -33,8 +33,13 @@ namespace llarp
|
|||
#endif
|
||||
tunif.user = this;
|
||||
tunif.netmask = DefaultTunNetmask;
|
||||
#ifdef _WIN32
|
||||
llarp::Zero(tunif.ifaddr, sizeof(tunif.ifaddr));
|
||||
llarp::Zero(tunif.ifname, sizeof(tunif.ifname));
|
||||
#else
|
||||
strncpy(tunif.ifaddr, DefaultTunSrcAddr, sizeof(tunif.ifaddr) - 1);
|
||||
strncpy(tunif.ifname, DefaultTunIfname, sizeof(tunif.ifname) - 1);
|
||||
#endif
|
||||
tunif.tick = nullptr;
|
||||
tunif.before_write = &tunifBeforeWrite;
|
||||
tunif.recvpkt = &tunifRecvPkt;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "queue_manager.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <llarp/threading.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue