we NEED NT >= 6 for event loop

pull/47/head
Jeff Becker 6 years ago
parent 0a236d9f8c
commit a59343cfec
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -198,7 +198,7 @@ if(UNIX)
endif()
elseif(WIN32)
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-windows.c)
add_definitions(-DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x500 -D_WIN32_WINNT=0x500)
add_definitions(-DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x600 -D_WIN32_WINNT=0x600)
else()
message(FATAL_ERROR "What operating system _are_ you building on/for?")
endif(UNIX)

@ -61,7 +61,7 @@ namespace llarp
operator<<(std::ostream& out, const AddressInfo& a)
{
char tmp[128] = {0};
inet_ntop(AF_INET6, &a.ip, tmp, sizeof(tmp));
inet_ntop(AF_INET6, (void*)&a.ip, tmp, sizeof(tmp));
out << tmp << ".";
#if defined(ANDROID) || defined(RPI)
snprintf(tmp, sizeof(tmp), "%u", a.port);

@ -48,7 +48,7 @@ namespace llarp
operator<<(std::ostream &out, const ExitInfo &xi)
{
char tmp[128] = {0};
if(inet_ntop(AF_INET6, &xi.address, tmp, sizeof(tmp)))
if(inet_ntop(AF_INET6, (void *)&xi.address, tmp, sizeof(tmp)))
out << std::string(tmp);
else
return out;

@ -250,8 +250,8 @@ namespace llarp
{
char strbuf[32] = {0};
char netbuf[32] = {0};
inet_ntop(AF_INET, &a.addr, strbuf, sizeof(strbuf));
inet_ntop(AF_INET, &a.netmask_bits, netbuf, sizeof(netbuf));
inet_ntop(AF_INET, (void*)&a.addr, strbuf, sizeof(strbuf));
inet_ntop(AF_INET, (void*)&a.netmask_bits, netbuf, sizeof(netbuf));
out << std::string(strbuf) + "/" + std::string(netbuf);
return out;
}

@ -31,21 +31,27 @@
// we already have our own definition of these
// -despair
#ifndef inet_ntop
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);
}
}
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);
}
} // namespace
#endif
//######################################################################
const char *libutp::inet_ntop(int af, const void *src, char *dest, size_t length)
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, (void *)src, dest, length);
}
//######################################################################
int libutp::inet_pton(int af, const char* src, void* dest)
int
libutp::inet_pton(int af, const char *src, void *dest)
{
return ::inet_pton(af, src, dest);
return ::inet_pton(af, src, dest);
}

@ -140,7 +140,7 @@ namespace llarp
if(!bencode_write_bytestring(buff, pubkey, PUBKEYSIZE))
return false;
/** ip */
ipstr = inet_ntop(AF_INET6, &ip, ipbuff, sizeof(ipbuff));
ipstr = inet_ntop(AF_INET6, (void *)&ip, ipbuff, sizeof(ipbuff));
if(!ipstr)
return false;
if(!bencode_write_bytestring(buff, "i", 1))

@ -17,14 +17,14 @@
#endif
#ifndef MAX_WRITE_QUEUE_SIZE
#define MAX_WRITE_QUEUE_SIZE 1024
#define MAX_WRITE_QUEUE_SIZE (1024UL)
#endif
#ifndef EV_READ_BUF_SZ
#define EV_READ_BUF_SZ (4 * 1024)
#define EV_READ_BUF_SZ (4 * 1024UL)
#endif
#ifndef EV_WRITE_BUF_SZ
#define EV_WRITE_BUF_SZ (2 * 1024)
#define EV_WRITE_BUF_SZ (2 * 1024UL)
#endif
namespace llarp

@ -365,38 +365,28 @@ struct llarp_win32_loop : public llarp_ev_loop
int
tick(int ms)
{
// The only field we really care about is
// the listener_id, as it contains the address
// of the ev_io instance.
DWORD iolen = 0;
// ULONG_PTR is guaranteed to be the same size
// as an arch-specific pointer value
ULONG_PTR ev_id = 0;
WSAOVERLAPPED* qdata = nullptr;
int idx = 0;
BOOL result =
::GetQueuedCompletionStatus(iocpfd, &iolen, &ev_id, &qdata, ms);
llarp::ev_io* ev = reinterpret_cast< llarp::ev_io* >(ev_id);
if(ev && qdata)
OVERLAPPED_ENTRY events[1024];
ULONG numEvents = 0;
if(::GetQueuedCompletionStatusEx(iocpfd, events, 1024, &numEvents, ms,
false))
{
llarp::LogDebug("size: ", iolen, "\tev_id: ", ev_id, "\tqdata: ", qdata);
if(ev->write)
ev->flush_write();
else
ev->read(readbuf, iolen);
++idx;
}
if(!idx)
return -1;
else
{
result = idx;
tick_listeners();
for(ULONG idx = 0; idx < numEvents; ++idx)
{
llarp::ev_io* ev =
reinterpret_cast< llarp::ev_io* >(events[idx].lpCompletionKey);
if(ev)
{
if(ev->write)
ev->flush_write();
auto amount =
std::min(EV_READ_BUF_SZ, events[idx].dwNumberOfBytesTransferred);
memcpy(readbuf, events[idx].lpOverlapped->Pointer, amount);
ev->read(readbuf, amount);
}
}
}
return result;
tick_listeners();
return 0;
}
// ok apparently this isn't being used yet...

@ -31,12 +31,12 @@ namespace llarp
if(!bencode_start_dict(buf))
return false;
if(!inet_ntop(AF_INET6, &address, tmp, sizeof(tmp)))
if(!inet_ntop(AF_INET6, (void*)&address, tmp, sizeof(tmp)))
return false;
if(!BEncodeWriteDictString("a", std::string(tmp), buf))
return false;
if(!inet_ntop(AF_INET6, &netmask, tmp, sizeof(tmp)))
if(!inet_ntop(AF_INET6, (void*)&netmask, tmp, sizeof(tmp)))
return false;
if(!BEncodeWriteDictString("b", std::string(tmp), buf))
return false;

Loading…
Cancel
Save