clang-format

pull/20/head
despair86 6 years ago
parent 3c7b7f2176
commit 3c13101beb

@ -100,7 +100,8 @@ main(int argc, char *argv[])
conffname = fname.string();
if(basedir.string().empty())
{
if(!llarp_ensure_config(fname.string().c_str(), nullptr, overWrite, asRouter))
if(!llarp_ensure_config(fname.string().c_str(), nullptr, overWrite,
asRouter))
return 1;
}
else

@ -137,18 +137,18 @@ namespace llarp
size_t m_NumPaths;
private:
typedef std::pair< RouterID, PathID_t > PathInfo_t;
struct PathInfoHash
{
size_t operator()(const PathInfo_t & i) const
size_t
operator()(const PathInfo_t& i) const
{
return *i.first.data_l() ^ *i.second.data_l();
}
};
typedef std::unordered_map< PathInfo_t, Path* , PathInfoHash> PathMap_t;
typedef std::unordered_map< PathInfo_t, Path*, PathInfoHash > PathMap_t;
PathMap_t m_Paths;
};

@ -82,7 +82,7 @@ writecname_dnss_response(std::string cname, const struct sockaddr *from,
dnsd_question_request *request)
{
const size_t BUFFER_SIZE = 1024 + (request->question.name.size() * 2);
char buf[BUFFER_SIZE]; // heh, another UNIX compiler extension: VLAs in C++
char buf[BUFFER_SIZE]; // heh, another UNIX compiler extension: VLAs in C++
memset(buf, 0, BUFFER_SIZE);
char *write_buffer = buf;
char *bufferBegin = buf;

@ -206,13 +206,13 @@ struct llarp_kqueue_loop : public llarp_ev_loop
while(idx < result)
{
llarp::ev_io* ev = static_cast< llarp::ev_io* >(events[idx].udata);
if (ev)
if(ev)
{
ev->read(readbuf, sizeof(readbuf));
}
else
{
llarp::LogWarn("event[", idx,"] udata is not an ev_io");
llarp::LogWarn("event[", idx, "] udata is not an ev_io");
}
++idx;
}

@ -22,7 +22,7 @@ namespace llarp
udp_listener(SOCKET fd, llarp_udp_io* u) : ev_io(fd), udp(u)
{
memset((void*)&portfd, 0, sizeof(WSAOVERLAPPED));
memset((void*)&portfd, 0, sizeof(WSAOVERLAPPED));
};
~udp_listener()
@ -46,9 +46,8 @@ namespace llarp
WSABUF wbuf = {sz, static_cast< char* >(buf)};
// WSARecvFrom
llarp::LogDebug("read ", sz, " bytes into socket");
int ret =
::WSARecvFrom(std::get< SOCKET >(fd), &wbuf, 1, nullptr, &flags, addr,
&slen, &portfd, nullptr);
int ret = ::WSARecvFrom(std::get< SOCKET >(fd), &wbuf, 1, nullptr, &flags,
addr, &slen, &portfd, nullptr);
// 997 is the error code for queued ops
int s_errno = ::WSAGetLastError();
if(ret && s_errno != 997)
@ -121,7 +120,7 @@ namespace llarp
ev_io::flush_write();
}
bool
bool
do_write(void* data, size_t sz)
{
return WriteFile(std::get< HANDLE >(fd), data, sz, nullptr, tun_async);
@ -212,7 +211,7 @@ struct llarp_win32_loop : public llarp_ev_loop
// as an arch-specific pointer value
ULONG_PTR ev_id = 0;
WSAOVERLAPPED* qdata = nullptr;
int idx = 0;
int idx = 0;
BOOL result =
::GetQueuedCompletionStatus(iocpfd, &iolen, &ev_id, &qdata, ms);
@ -221,7 +220,8 @@ struct llarp_win32_loop : public llarp_ev_loop
llarp::udp_listener* ev = reinterpret_cast< llarp::udp_listener* >(ev_id);
if(ev && !ev->fd.valueless_by_exception())
{
llarp::LogDebug("size: ", iolen, "\tev_id: ", ev_id, "\tqdata: ", qdata);
llarp::LogDebug("size: ", iolen, "\tev_id: ", ev_id,
"\tqdata: ", qdata);
ev->getData(readbuf, sizeof(readbuf), iolen);
}
++idx;
@ -251,22 +251,21 @@ struct llarp_win32_loop : public llarp_ev_loop
ULONG_PTR ev_id = 0;
WSAOVERLAPPED* qdata = nullptr;
int idx = 0;
int result = ::GetQueuedCompletionStatus(iocpfd, &iolen, &ev_id, &qdata, 10);
int result =
::GetQueuedCompletionStatus(iocpfd, &iolen, &ev_id, &qdata, 10);
// unlike epoll and kqueue, we only need to run so long as the
// system call returns TRUE
if(result)
if(result)
{
llarp::udp_listener* ev = reinterpret_cast< llarp::udp_listener* >(ev_id);
if(ev && !ev->fd.valueless_by_exception())
{
llarp::udp_listener* ev =
reinterpret_cast< llarp::udp_listener* >(ev_id);
if(ev && !ev->fd.valueless_by_exception())
{
llarp::LogInfo("size: ", iolen, "\tev_id: ", ev_id,
"\tqdata: ", qdata);
ev->getData(readbuf, sizeof(readbuf), iolen);
}
++idx;
llarp::LogInfo("size: ", iolen, "\tev_id: ", ev_id, "\tqdata: ", qdata);
ev->getData(readbuf, sizeof(readbuf), iolen);
}
++idx;
}
if(!idx)
return -1;
@ -294,7 +293,7 @@ struct llarp_win32_loop : public llarp_ev_loop
default:
return INVALID_SOCKET;
}
DWORD on = 1;
DWORD on = 1;
SOCKET fd = ::socket(addr->sa_family, SOCK_DGRAM, 0);
if(fd == INVALID_SOCKET)
{
@ -365,33 +364,34 @@ struct llarp_win32_loop : public llarp_ev_loop
bool
add_ev(llarp::ev_io* ev, bool write)
{
uint8_t buf[1024];
llarp::udp_listener *udp = nullptr;
llarp::tun *t = nullptr;
ev->listener_id = reinterpret_cast< ULONG_PTR >(ev);
uint8_t buf[1024];
llarp::udp_listener* udp = nullptr;
llarp::tun* t = nullptr;
ev->listener_id = reinterpret_cast< ULONG_PTR >(ev);
memset(&buf, 0, 1024);
switch(ev->fd.index())
{
case 0:
udp = dynamic_cast<llarp::udp_listener*>(ev);
udp = dynamic_cast< llarp::udp_listener* >(ev);
if(!::CreateIoCompletionPort((HANDLE)std::get< 0 >(ev->fd), iocpfd,
ev->listener_id, 0))
{
delete ev;
return false;
}
::ReadFile((HANDLE)std::get<0>(ev->fd), &buf, 1024, nullptr, &udp->portfd);
::ReadFile((HANDLE)std::get< 0 >(ev->fd), &buf, 1024, nullptr,
&udp->portfd);
break;
case 1:
t = dynamic_cast<llarp::tun*>(ev);
t = dynamic_cast< llarp::tun* >(ev);
if(!::CreateIoCompletionPort(std::get< 1 >(ev->fd), iocpfd,
ev->listener_id, 0))
{
delete ev;
return false;
}
::ReadFile(std::get<1>(ev->fd), &buf, 1024, nullptr, t->tun_async);
::ReadFile(std::get< 1 >(ev->fd), &buf, 1024, nullptr, t->tun_async);
break;
default:
return false;

@ -110,7 +110,8 @@ namespace llarp
llarp::Addr tunIp(source_addr);
// related to dns_iptracker_setup_dotLokiLookup(&this->dll, tunIp);
dns_iptracker_setup(this->dll.ip_tracker, tunIp); // claim GW IP to make sure it's not inuse
dns_iptracker_setup(this->dll.ip_tracker,
tunIp); // claim GW IP to make sure it's not inuse
return true;
}
return Endpoint::SetOption(k, v);
@ -150,7 +151,8 @@ namespace llarp
llarp::Addr tunIp(tunif.ifaddr);
dns_iptracker_setup_dotLokiLookup(
&this->dll, tunIp); // just set ups dll to use global iptracker
dns_iptracker_setup(this->dll.ip_tracker, tunIp); // claim GW IP to make sure it's not inuse
dns_iptracker_setup(this->dll.ip_tracker,
tunIp); // claim GW IP to make sure it's not inuse
// set up networking in currrent thread if we are not isolated
if(!SetupNetworking())
@ -162,8 +164,9 @@ namespace llarp
llarp::Addr tunIp(tunif.ifaddr);
this->dll.ip_tracker = new dns_iptracker;
dns_iptracker_setup_dotLokiLookup(
&this->dll, tunIp); // just set ups dll to use global iptracker
dns_iptracker_setup(this->dll.ip_tracker, tunIp); // claim GW IP to make sure it's not inuse
&this->dll, tunIp); // just set ups dll to use global iptracker
dns_iptracker_setup(this->dll.ip_tracker,
tunIp); // claim GW IP to make sure it's not inuse
}
// wait for result for network setup
llarp::LogInfo("waiting for tun interface...");
@ -254,7 +257,8 @@ namespace llarp
{
llarp::LogInfo("Set Up networking for ", Name());
bool result = SetupTun();
m_TunSetupResult.set_value(result); // now that NT has tun, we don't need the CPP guard
m_TunSetupResult.set_value(
result); // now that NT has tun, we don't need the CPP guard
if(!NetworkIsIsolated())
{
// need to check to see if we have more than one hidden service

@ -350,7 +350,8 @@ namespace llarp
" bytes");
if(::sendto(l->m_udp.fd, (char*)arg->buf, arg->len, arg->flags,
arg->address, arg->address_len)
== -1 && errno)
== -1
&& errno)
{
llarp::LogError("sendto failed: ", strerror(errno));
}

Loading…
Cancel
Save